|
|
1.1 ! root 1: # include "curses.ext" ! 2: ! 3: /* ! 4: * This routine adds the character to the current position ! 5: * ! 6: * @(#)addch.c 1.5 (Berkeley) 5/19/83 ! 7: */ ! 8: waddch(win, c) ! 9: reg WINDOW *win; ! 10: char c; ! 11: { ! 12: reg int x, y; ! 13: reg WINDOW *wp; ! 14: ! 15: x = win->_curx; ! 16: y = win->_cury; ! 17: # ifdef FULLDEBUG ! 18: fprintf(outf, "ADDCH('%c') at (%d, %d)\n", c, y, x); ! 19: # endif ! 20: if (y >= win->_maxy || x >= win->_maxx || y < 0 || x < 0) ! 21: return ERR; ! 22: switch (c) { ! 23: case '\t': ! 24: { ! 25: reg int newx; ! 26: ! 27: for (newx = x + (8 - (x & 07)); x < newx; x++) ! 28: if (waddch(win, ' ') == ERR) ! 29: return ERR; ! 30: return OK; ! 31: } ! 32: ! 33: default: ! 34: # ifdef FULLDEBUG ! 35: fprintf(outf, "ADDCH: 1: y = %d, x = %d, firstch = %d, lastch = %d\n", y, x, win->_firstch[y], win->_lastch[y]); ! 36: # endif ! 37: if (win->_flags & _STANDOUT) ! 38: c |= _STANDOUT; ! 39: set_ch(win, y, x, c, NULL); ! 40: for (wp = win->_nextp; wp != win; wp = wp->_nextp) ! 41: set_ch(wp, y, x, c, win); ! 42: win->_y[y][x++] = c; ! 43: if (x >= win->_maxx) { ! 44: x = 0; ! 45: newline: ! 46: if (++y >= win->_maxy) ! 47: if (win->_scroll) { ! 48: wrefresh(win); ! 49: scroll(win); ! 50: --y; ! 51: } ! 52: else ! 53: return ERR; ! 54: } ! 55: # ifdef FULLDEBUG ! 56: fprintf(outf, "ADDCH: 2: y = %d, x = %d, firstch = %d, lastch = %d\n", y, x, win->_firstch[y], win->_lastch[y]); ! 57: # endif ! 58: break; ! 59: case '\n': ! 60: wclrtoeol(win); ! 61: if (!NONL) ! 62: x = 0; ! 63: goto newline; ! 64: case '\r': ! 65: x = 0; ! 66: break; ! 67: case '\b': ! 68: if (--x < 0) ! 69: x = 0; ! 70: break; ! 71: } ! 72: win->_curx = x; ! 73: win->_cury = y; ! 74: return OK; ! 75: } ! 76: ! 77: /* ! 78: * set_ch: ! 79: * Set the first and last change flags for this window. ! 80: */ ! 81: static ! 82: set_ch(win, y, x, ch, orig) ! 83: reg WINDOW *win; ! 84: int y, x; ! 85: WINDOW *orig; { ! 86: ! 87: if (orig != NULL) { ! 88: y -= win->_begy - orig->_begy; ! 89: x -= win->_begx - orig->_begx; ! 90: } ! 91: if (y < 0 || y >= win->_maxy || x < 0 || x >= win->_maxx) ! 92: return; ! 93: if (win->_y[y][x] != ch) { ! 94: if (win->_firstch[y] == _NOCHANGE) ! 95: win->_firstch[y] = win->_lastch[y] = x; ! 96: else if (x < win->_firstch[y]) ! 97: win->_firstch[y] = x; ! 98: else if (x > win->_lastch[y]) ! 99: win->_lastch[y] = x; ! 100: } ! 101: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.