|
|
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_overlay.c ! 27: ** ! 28: ** The routines overlay() and overwrite(). ! 29: ** ! 30: ** $Log: RCS/lib_overlay.v $ ! 31: * Revision 2.3 91/04/20 21:33:39 munk ! 32: * Usage of register variables ! 33: * ! 34: * Revision 2.2 82/10/28 18:10:11 pavel ! 35: * Fixed confusion about which direction the copy was supposed to go and ! 36: * also added updates to win2->_{first,last}char. ! 37: * ! 38: * Revision 2.1 82/10/25 14:48:35 pavel ! 39: * Added Copyright Notice ! 40: * ! 41: * Revision 2.0 82/10/25 13:48:09 pavel ! 42: * Beta-one Test Release ! 43: * ! 44: ** ! 45: */ ! 46: ! 47: #ifdef RCSHDR ! 48: static char RCSid[] = ! 49: "$Header: RCS/lib_overlay.v Revision 2.3 91/04/20 21:33:39 munk Exp$"; ! 50: #endif ! 51: ! 52: #include "curses.h" ! 53: #include "curses.priv.h" ! 54: ! 55: ! 56: /* ! 57: ** ! 58: ** overlay(win1, win2) ! 59: ** ! 60: ** ! 61: ** overlay() writes win1 on win2 non-destructively. ! 62: ** ! 63: **/ ! 64: ! 65: overlay(win1, win2) ! 66: WINDOW *win1, *win2; ! 67: { ! 68: int col, line, last_line, last_col; ! 69: short *firstchar, *lastchar; ! 70: register chtype *w1ptr, *w2ptr; ! 71: chtype attrs; ! 72: ! 73: #ifdef TRACE ! 74: if (_tracing) ! 75: _tracef("overlay(%o, %o) called", win1, win2); ! 76: #endif ! 77: ! 78: last_col = min(win1->_maxx, win2->_maxx); ! 79: last_line = min(win1->_maxy, win2->_maxy); ! 80: attrs = win2->_attrs; ! 81: firstchar = win2->_firstchar; ! 82: lastchar = win2->_lastchar; ! 83: ! 84: for(line = 0; line <= last_line; line++) ! 85: { ! 86: short fc, lc; ! 87: ! 88: w1ptr = win1->_line[line]; ! 89: w2ptr = win2->_line[line]; ! 90: fc = _NOCHANGE; ! 91: ! 92: for(col = 0; col <= last_col; col++) ! 93: { ! 94: if ((*w1ptr & A_CHARTEXT) != ' ') ! 95: { ! 96: *w2ptr = (*w1ptr & A_CHARTEXT) | attrs; ! 97: if (fc == _NOCHANGE) ! 98: fc = col; ! 99: lc = col; ! 100: } ! 101: ! 102: w1ptr++; ! 103: w2ptr++; ! 104: } ! 105: ! 106: if (*firstchar == _NOCHANGE) ! 107: { ! 108: *firstchar = fc; ! 109: *lastchar = lc; ! 110: } ! 111: else if (fc != _NOCHANGE) ! 112: { ! 113: if (fc < *firstchar) ! 114: *firstchar = fc; ! 115: ! 116: if (lc > *lastchar) ! 117: *lastchar = lc; ! 118: } ! 119: ! 120: firstchar++; ! 121: lastchar++; ! 122: } ! 123: } ! 124: ! 125: ! 126: /* ! 127: ** ! 128: ** overwrite(win1, win2) ! 129: ** ! 130: ** ! 131: ** overwrite() writes win1 on win2 destructively. ! 132: ** ! 133: **/ ! 134: ! 135: overwrite(win1, win2) ! 136: WINDOW *win1, *win2; ! 137: { ! 138: int col, line, last_line, last_col; ! 139: short *firstchar, *lastchar; ! 140: register chtype *w1ptr, *w2ptr; ! 141: chtype attrs; ! 142: ! 143: #ifdef TRACE ! 144: if (_tracing) ! 145: _tracef("overwrite(%o, %o) called", win1, win2); ! 146: #endif ! 147: ! 148: last_col = min(win1->_maxx, win2->_maxx); ! 149: last_line = min(win1->_maxy, win2->_maxy); ! 150: attrs = win2->_attrs; ! 151: firstchar = win2->_firstchar; ! 152: lastchar = win2->_lastchar; ! 153: ! 154: for(line = 0; line <= last_line; line++) ! 155: { ! 156: short fc, lc; ! 157: ! 158: w1ptr = win1->_line[line]; ! 159: w2ptr = win2->_line[line]; ! 160: fc = _NOCHANGE; ! 161: ! 162: for(col = 0; col <= last_col; col++) ! 163: { ! 164: if ((*w1ptr & A_CHARTEXT) != (*w2ptr & A_CHARTEXT)) ! 165: { ! 166: *w2ptr = (*w1ptr & A_CHARTEXT) | attrs; ! 167: if (fc == _NOCHANGE) ! 168: fc = col; ! 169: lc = col; ! 170: } ! 171: ! 172: w1ptr++; ! 173: w2ptr++; ! 174: } ! 175: ! 176: if (*firstchar == _NOCHANGE) ! 177: { ! 178: *firstchar = fc; ! 179: *lastchar = lc; ! 180: } ! 181: else if (fc != _NOCHANGE) ! 182: { ! 183: if (fc < *firstchar) ! 184: *firstchar = fc; ! 185: ! 186: if (lc > *lastchar) ! 187: *lastchar = lc; ! 188: } ! 189: ! 190: firstchar++; ! 191: lastchar++; ! 192: } ! 193: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.