|
|
1.1 ! root 1: /********************************************************************* ! 2: * COPYRIGHT NOTICE * ! 3: ********************************************************************** ! 4: * This software is copyright (C) 1982 by Pavel Curtis * ! 5: * * ! 6: * Permission is granted to reproduce and distribute * ! 7: * this file by any means so long as no fee is charged * ! 8: * above a nominal handling fee and so long as this * ! 9: * notice is always included in the copies. * ! 10: * * ! 11: * Other rights are reserved except as explicitly granted * ! 12: * by written permission of the author. * ! 13: * Pavel Curtis * ! 14: * Computer Science Dept. * ! 15: * 405 Upson Hall * ! 16: * Cornell University * ! 17: * Ithaca, NY 14853 * ! 18: * * ! 19: * Ph- (607) 256-4934 * ! 20: * * ! 21: * Pavel.Cornell@Udel-Relay (ARPAnet) * ! 22: * decvax!cornell!pavel (UUCPnet) * ! 23: *********************************************************************/ ! 24: ! 25: /* ! 26: ** lib_addch.c ! 27: ** ! 28: ** The routine waddch(). ! 29: ** ! 30: ** $Log: lib_addch.c,v $ ! 31: * Revision 1.8 93/04/12 14:13:19 bin ! 32: * Udo: third color update ! 33: * ! 34: * Revision 2.3 92/11/01 15:55:32 munk ! 35: * Second parameter is a chtype now ! 36: * ! 37: * Revision 1.2 92/04/13 14:36:58 bin ! 38: * update by vlad ! 39: * ! 40: * Revision 2.2 91/04/20 17:52:20 munk ! 41: * Usage of register variables ! 42: * ! 43: * Revision 2.1 82/10/25 14:46:23 pavel ! 44: * Added Copyright Notice ! 45: * ! 46: * Revision 2.0 82/10/24 15:19:46 pavel ! 47: * Beta-one Test Release ! 48: * ! 49: ** ! 50: */ ! 51: ! 52: #ifdef RCSHDR ! 53: static char RCSid[] = ! 54: "$Header: /src386/usr/lib/ncurses/RCS/lib_addch.c,v 1.8 93/04/12 14:13:19 bin Exp Locker: bin $"; ! 55: #endif ! 56: ! 57: #include "curses.h" ! 58: #include "curses.priv.h" ! 59: #include "terminfo.h" ! 60: #include "unctrl.h" ! 61: ! 62: ! 63: waddch(win, ch) ! 64: register WINDOW *win; ! 65: chtype ch; ! 66: { ! 67: register int x, y; ! 68: int newx; ! 69: ! 70: #ifdef TRACE ! 71: if (_tracing) ! 72: _tracef("waddch(%o,%o) called", win, ch); ! 73: #endif ! 74: ! 75: x = win->_curx; ! 76: y = win->_cury; ! 77: ! 78: if (y > win->_maxy || x > win->_maxx || y < 0 || x < 0) ! 79: return(ERR); ! 80: ! 81: switch (ch & A_CHARTEXT) ! 82: { ! 83: case '\t': ! 84: for (newx = x + (8 - (x & 07)); x < newx; x++) ! 85: if (waddch(win, ' ') == ERR) ! 86: return(ERR); ! 87: return(OK); ! 88: ! 89: case '\n': ! 90: wclrtoeol(win); ! 91: if (SP->_nl) ! 92: x = 0; ! 93: goto newline; ! 94: ! 95: case '\r': ! 96: x = 0; ! 97: break; ! 98: ! 99: case '\b': ! 100: if (--x < 0) ! 101: x = 0; ! 102: break; ! 103: ! 104: default: ! 105: if ((ch & A_CHARTEXT) < ' ') ! 106: return(waddstr(win, unctrl(ch))); ! 107: ! 108: ch |= (ch & A_COLOR) ? (win->_attrs & ~A_COLOR) : win->_attrs; ! 109: ! 110: /* ch |= win->_attrs; */ ! 111: ! 112: if (win->_line[y][x] != ch) ! 113: { ! 114: if (win->_firstchar[y] == _NOCHANGE) ! 115: win->_firstchar[y] = win->_lastchar[y] = x; ! 116: else if (x < win->_firstchar[y]) ! 117: win->_firstchar[y] = x; ! 118: else if (x > win->_lastchar[y]) ! 119: win->_lastchar[y] = x; ! 120: ! 121: win->_numchngd[y]++; ! 122: } ! 123: ! 124: win->_line[y][x++] = ch; ! 125: if (x > win->_maxx) ! 126: { ! 127: x = 0; ! 128: newline: ! 129: y++; ! 130: if (y > win->_regbottom) ! 131: { ! 132: y--; ! 133: if (win->_scroll) ! 134: scroll(win); ! 135: else ! 136: return ERR; ! 137: } ! 138: } ! 139: break; ! 140: } ! 141: ! 142: win->_curx = x; ! 143: win->_cury = y; ! 144: ! 145: return(OK); ! 146: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.