|
|
1.1 root 1: /* @(#) clreolinln.c: 1.1 10/15/83 (1.21 2/11/83) */
2:
3: #include "curses.ext"
4:
5: extern int _clearhl();
6: extern int _dellines();
7: extern int _inslines();
8: extern int _outch();
9: extern int _pos();
10: extern int _setwind();
11: extern int clreol();
12: extern char *tparm();
13: extern int tputs();
14:
15: _clreol()
16: {
17: register int col;
18: register struct line *cb;
19:
20: #ifdef DEBUG
21: if(outf) fprintf(outf, "_clreol().\n");
22: #endif
23: if (!move_standout_mode)
24: _clearhl ();
25: if (clr_eol) {
26: tputs (clr_eol, columns-SP->phys_x, _outch);
27: } else if (delete_line && insert_line && SP->phys_x == 0) {
28: _dellines (1);
29: _inslines (1);
30: } else {
31: /*
32: * Should consider using delete/insert line here, too,
33: * if the part that would have to be redrawn is short,
34: * or if we have to get rid of some cemented highlights.
35: * This might win on the DTC 382 or the Teleray 1061.
36: */
37: cb = SP->cur_body[SP->phys_y+1];
38: for (col=SP->phys_x+1; col<cb->length; col++)
39: if (cb->body[col] != ' ') {
40: _pos(SP->phys_y, col);
41: _blanks(1);
42: }
43: /*
44: * Could save and restore SP->curptr position, but since we
45: * keep track of what _blanks does to it, it turns out
46: * that this is wasted. Not backspacing over the stuff
47: * cleared out is a real win on a super dumb terminal.
48: */
49: }
50: }
51:
52: _inslines (n)
53: {
54: register int i;
55:
56: #ifdef DEBUG
57: if(outf) fprintf(outf, "_inslines(%d).\n", n);
58: #endif
59: if (!move_standout_mode && SP->phys_gr)
60: _clearhl();
61: if (SP->phys_y + n >= lines && clr_eos) {
62: /*
63: * Really quick -- clear to end of screen.
64: */
65: tputs(clr_eos, lines-SP->phys_y, _outch);
66: return;
67: }
68:
69: /*
70: * We are about to _shove something off the bottom of the screen.
71: * Terminals with extra memory keep this around, and it might
72: * show up again to haunt us later if we do a delete line or
73: * scroll into it, or when we exit. So we clobber it now. We
74: * might get better performance by somehow remembering that this
75: * stuff is down there and worrying about it if/when we have to.
76: * In particular, having to do this extra pair of SP->curptr motions
77: * is a lose.
78: */
79: if (memory_below) {
80: int save;
81:
82: save = SP->phys_y;
83: if (save_cursor && restore_cursor)
84: tputs(save_cursor, 1, _outch);
85: if (clr_eos) {
86: _pos(lines-n, 0);
87: tputs(clr_eos, n, _outch);
88: } else {
89: for (i=0; i<n; i++) {
90: _pos(lines-n+i, 0);
91: _clreol();
92: }
93: }
94: if (save_cursor && restore_cursor)
95: tputs(restore_cursor, 1, _outch);
96: else
97: _pos(save, 0);
98: }
99:
100: /* Do the physical line deletion */
101: if (scroll_reverse && SP->phys_y == SP->des_top_mgn /* &&costSR<costAL */) {
102: /*
103: * Use reverse scroll mode of the terminal, at
104: * the top of the window. Reverse linefeed works
105: * too, since we only use it from top line of window.
106: */
107: _setwind();
108: for (i = n; i > 0; i--) {
109: _pos(SP->phys_y, 0);
110: tputs(scroll_reverse, 1, _outch);
111: if (SP->ml_above > 0)
112: SP->ml_above--;
113: /*
114: * If we are at the top of the screen, and the
115: * terminal retains display above, then we
116: * should try to clear to end of line.
117: * Have to use CE since we don't remember what is
118: * actually on the line.
119: */
120: if (clr_eol && memory_above)
121: tputs(clr_eol, 1, _outch);
122: }
123: } else if (parm_insert_line && (n>1 || *insert_line==0)) {
124: tputs(tparm(parm_insert_line, n, SP->phys_y), lines-SP->phys_y, _outch);
125: } else if (change_scroll_region && *insert_line==0) {
126: /* vt100 change scrolling region to fake AL */
127: tputs(save_cursor, 1, _outch);
128: tputs( tparm(change_scroll_region,
129: SP->phys_y, SP->des_bot_mgn), 1, _outch);
130: /* change_scroll_region homes stupid cursor */
131: tputs(restore_cursor, 1, _outch);
132: for (i=n; i>0; i--)
133: tputs(scroll_reverse, 1, _outch);/* should do @'s */
134: /* restore scrolling region */
135: tputs(tparm(change_scroll_region,
136: SP->des_top_mgn, SP->des_bot_mgn), 1, _outch);
137: tputs(restore_cursor, 1, _outch);/* Once again put it back */
138: SP->phys_top_mgn = SP->des_top_mgn;
139: SP->phys_bot_mgn = SP->des_bot_mgn;
140: } else {
141: tputs(insert_line, lines - SP->phys_y, _outch);
142: for (i = n - 1; i > 0; i--) {
143: tputs(insert_line, lines - SP->phys_y, _outch);
144: }
145: }
146: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.