1 /****************************************************************************
2 * Copyright (c) 1998-2016,2017 Free Software Foundation, Inc. *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
27 ****************************************************************************/
29 /****************************************************************************
30 * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
31 * and: Eric S. Raymond <esr@snark.thyrsus.com> *
32 * and: Thomas E. Dickey 1996-on *
33 * and: Juergen Pfeifer 2009 *
34 ****************************************************************************/
36 /*-----------------------------------------------------------------
40 * The routine doupdate() and its dependents.
41 * All physical output is concentrated here (except _nc_outch()
44 *-----------------------------------------------------------------*/
46 #define NEW_PAIR_INTERNAL 1
48 #include <curses.priv.h>
51 #define CUR SP_TERMTYPE
54 #if defined __HAIKU__ && defined __BEOS__
64 #if defined(TRACE) && HAVE_SYS_TIMES_H && HAVE_TIMES
65 #define USE_TRACE_TIMES 1
67 #define USE_TRACE_TIMES 0
70 #if HAVE_SYS_TIME_H && HAVE_SYS_TIME_SELECT
75 #include <sys/times.h>
81 #include <sys/select.h>
87 MODULE_ID("$Id: tty_update.c,v 1.290 2017/07/22 23:30:28 tom Exp $")
90 * This define controls the line-breakout optimization. Every once in a
91 * while during screen refresh, we want to check for input and abort the
92 * update if there's some waiting. CHECK_INTERVAL controls the number of
93 * changed lines to be emitted between input checks.
95 * Note: Input-check-and-abort is no longer done if the screen is being
96 * updated from scratch. This is a feature, not a bug.
98 #define CHECK_INTERVAL 5
100 #define FILL_BCE(sp) (sp->_coloron && !sp->_default_color && !back_color_erase)
102 static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT);
103 static NCURSES_CH_T normal = NewChar(BLANK_TEXT);
106 * Enable checking to see if doupdate and friends are tracking the true
107 * cursor position correctly. NOTE: this is a debugging hack which will
108 * work ONLY on ANSI-compatible terminals!
110 /* #define POSITION_DEBUG */
112 static NCURSES_INLINE NCURSES_CH_T ClrBlank(NCURSES_SP_DCLx WINDOW *win);
115 static int ClrBottom(SCREEN *, int total);
116 static void ClearScreen(SCREEN *, NCURSES_CH_T blank);
117 static void ClrUpdate(SCREEN *);
118 static void DelChar(SCREEN *, int count);
119 static void InsStr(SCREEN *, NCURSES_CH_T * line, int count);
120 static void TransformLine(SCREEN *, int const lineno);
122 static int ClrBottom(int total);
123 static void ClearScreen(NCURSES_CH_T blank);
124 static void ClrUpdate(void);
125 static void DelChar(int count);
126 static void InsStr(NCURSES_CH_T * line, int count);
127 static void TransformLine(int const lineno);
130 #ifdef POSITION_DEBUG
131 /****************************************************************************
133 * Debugging code. Only works on ANSI-standard terminals.
135 ****************************************************************************/
138 position_check(NCURSES_SP_DCLx int expected_y, int expected_x, char *legend)
139 /* check to see if the real cursor position matches the virtual */
145 if (!_nc_tracing || (expected_y < 0 && expected_x < 0))
148 NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
149 memset(buf, '\0', sizeof(buf));
150 NCURSES_PUTP2_FLUSH("cpr", "\033[6n"); /* only works on ANSI-compatibles */
153 int ask = sizeof(buf) - 1 - (s - buf);
154 int got = read(0, s, ask);
158 } while (strchr(buf, 'R') == 0);
159 _tracef("probe returned %s", _nc_visbuf(buf));
161 /* try to interpret as a position report */
162 if (sscanf(buf, "\033[%d;%dR", &y, &x) != 2) {
163 _tracef("position probe failed in %s", legend);
169 if (y - 1 != expected_y || x - 1 != expected_x) {
170 NCURSES_SP_NAME(beep) (NCURSES_SP_ARG);
171 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
175 1, NCURSES_SP_NAME(_nc_outch));
176 _tracef("position seen (%d, %d) doesn't match expected one (%d, %d) in %s",
177 y - 1, x - 1, expected_y, expected_x, legend);
179 _tracef("position matches OK in %s", legend);
184 #define position_check(expected_y, expected_x, legend) /* nothing */
185 #endif /* POSITION_DEBUG */
187 /****************************************************************************
189 * Optimized update code
191 ****************************************************************************/
193 static NCURSES_INLINE void
194 GoTo(NCURSES_SP_DCLx int const row, int const col)
196 TR(TRACE_MOVE, ("GoTo(%p, %d, %d) from (%d, %d)",
197 (void *) SP_PARM, row, col, SP_PARM->_cursrow, SP_PARM->_curscol));
199 position_check(NCURSES_SP_ARGx
201 SP_PARM->_curscol, "GoTo");
203 TINFO_MVCUR(NCURSES_SP_ARGx
207 position_check(NCURSES_SP_ARGx
209 SP_PARM->_curscol, "GoTo2");
212 #if !NCURSES_WCWIDTH_GRAPHICS
214 is_wacs_value(unsigned ch)
218 case 0x00a3: /* FALLTHRU - ncurses pound-sterling symbol */
219 case 0x00b0: /* FALLTHRU - VT100 degree symbol */
220 case 0x00b1: /* FALLTHRU - VT100 plus/minus */
221 case 0x00b7: /* FALLTHRU - VT100 bullet */
222 case 0x03c0: /* FALLTHRU - ncurses greek pi */
223 case 0x2190: /* FALLTHRU - Teletype arrow pointing left */
224 case 0x2191: /* FALLTHRU - Teletype arrow pointing up */
225 case 0x2192: /* FALLTHRU - Teletype arrow pointing right */
226 case 0x2193: /* FALLTHRU - Teletype arrow pointing down */
227 case 0x2260: /* FALLTHRU - ncurses not-equal */
228 case 0x2264: /* FALLTHRU - ncurses less-than-or-equal-to */
229 case 0x2265: /* FALLTHRU - ncurses greater-than-or-equal-to */
230 case 0x23ba: /* FALLTHRU - VT100 scan line 1 */
231 case 0x23bb: /* FALLTHRU - ncurses scan line 3 */
232 case 0x23bc: /* FALLTHRU - ncurses scan line 7 */
233 case 0x23bd: /* FALLTHRU - VT100 scan line 9 */
234 case 0x2500: /* FALLTHRU - VT100 horizontal line */
235 case 0x2501: /* FALLTHRU - thick horizontal line */
236 case 0x2502: /* FALLTHRU - VT100 vertical line */
237 case 0x2503: /* FALLTHRU - thick vertical line */
238 case 0x250c: /* FALLTHRU - VT100 upper left corner */
239 case 0x250f: /* FALLTHRU - thick upper left corner */
240 case 0x2510: /* FALLTHRU - VT100 upper right corner */
241 case 0x2513: /* FALLTHRU - thick upper right corner */
242 case 0x2514: /* FALLTHRU - VT100 lower left corner */
243 case 0x2517: /* FALLTHRU - thick lower left corner */
244 case 0x2518: /* FALLTHRU - VT100 lower right corner */
245 case 0x251b: /* FALLTHRU - thick lower right corner */
246 case 0x251c: /* FALLTHRU - VT100 tee pointing left */
247 case 0x2523: /* FALLTHRU - thick tee pointing left */
248 case 0x2524: /* FALLTHRU - VT100 tee pointing right */
249 case 0x252b: /* FALLTHRU - thick tee pointing right */
250 case 0x252c: /* FALLTHRU - VT100 tee pointing down */
251 case 0x2533: /* FALLTHRU - thick tee pointing down */
252 case 0x2534: /* FALLTHRU - VT100 tee pointing up */
253 case 0x253b: /* FALLTHRU - thick tee pointing up */
254 case 0x253c: /* FALLTHRU - VT100 large plus or crossover */
255 case 0x254b: /* FALLTHRU - thick large plus or crossover */
256 case 0x2550: /* FALLTHRU - double horizontal line */
257 case 0x2551: /* FALLTHRU - double vertical line */
258 case 0x2554: /* FALLTHRU - double upper left corner */
259 case 0x2557: /* FALLTHRU - double upper right corner */
260 case 0x255a: /* FALLTHRU - double lower left corner */
261 case 0x255d: /* FALLTHRU - double lower right corner */
262 case 0x2560: /* FALLTHRU - double tee pointing right */
263 case 0x2563: /* FALLTHRU - double tee pointing left */
264 case 0x2566: /* FALLTHRU - double tee pointing down */
265 case 0x2569: /* FALLTHRU - double tee pointing up */
266 case 0x256c: /* FALLTHRU - double large plus or crossover */
267 case 0x2592: /* FALLTHRU - VT100 checker board (stipple) */
268 case 0x25ae: /* FALLTHRU - Teletype solid square block */
269 case 0x25c6: /* FALLTHRU - VT100 diamond */
270 case 0x2603: /* FALLTHRU - Teletype lantern symbol */
281 static NCURSES_INLINE void
282 PutAttrChar(NCURSES_SP_DCLx CARG_CH_T ch)
286 #if USE_WIDEC_SUPPORT
290 NCURSES_CH_T attr = CHDEREF(ch);
292 TR(TRACE_CHARPUT, ("PutAttrChar(%s) at (%d, %d)",
294 SP_PARM->_cursrow, SP_PARM->_curscol));
295 #if USE_WIDEC_SUPPORT
297 * If this is not a valid character, there is nothing more to do.
299 if (isWidecExt(CHDEREF(ch))) {
300 TR(TRACE_CHARPUT, ("...skip"));
304 * Determine the number of character cells which the 'ch' value will use
305 * on the screen. It should be at least one.
307 if ((chlen = wcwidth(CharOf(CHDEREF(ch)))) <= 0) {
308 static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
311 * If the character falls into any of these special cases, do
312 * not force the result to a blank:
314 * a) it is printable (this works around a bug in wcwidth()).
315 * b) use_legacy_coding() has been called to modify the treatment
317 * c) the acs_map[] has been initialized to allow codes 0-31
318 * to be rendered. This supports Linux console's "PC"
319 * characters. Codes 128-255 are allowed though this is
322 if (is8bits(CharOf(CHDEREF(ch)))
323 && (isprint(CharOf(CHDEREF(ch)))
324 || (SP_PARM->_legacy_coding > 0 && CharOf(CHDEREF(ch)) >= 160)
325 || (SP_PARM->_legacy_coding > 1 && CharOf(CHDEREF(ch)) >= 128)
326 || (AttrOf(attr) & A_ALTCHARSET
327 && ((CharOfD(ch) < ACS_LEN
328 && SP_PARM->_acs_map != 0
329 && SP_PARM->_acs_map[CharOfD(ch)] != 0)
330 || (CharOfD(ch) >= 128))))) {
334 TR(TRACE_CHARPUT, ("forced to blank"));
340 if ((AttrOf(attr) & A_ALTCHARSET)
341 && SP_PARM->_acs_map != 0
342 && ((CharOfD(ch) < ACS_LEN)
343 #if !NCURSES_WCWIDTH_GRAPHICS
344 || is_wacs_value(CharOfD(ch))
347 my_ch = CHDEREF(ch); /* work around const param */
348 #if USE_WIDEC_SUPPORT
350 * This is crude & ugly, but works most of the time. It checks if the
351 * acs_chars string specified that we have a mapping for this
352 * character, and uses the wide-character mapping when we expect the
353 * normal one to be broken (by mis-design ;-).
355 if (SP_PARM->_screen_unicode
356 && _nc_wacs[CharOf(my_ch)].chars[0]) {
357 if (SP_PARM->_screen_acs_map[CharOf(my_ch)]) {
358 if (SP_PARM->_screen_acs_fix) {
359 RemAttr(attr, A_ALTCHARSET);
360 my_ch = _nc_wacs[CharOf(my_ch)];
363 RemAttr(attr, A_ALTCHARSET);
364 my_ch = _nc_wacs[CharOf(my_ch)];
366 #if !NCURSES_WCWIDTH_GRAPHICS
367 if (!(AttrOf(attr) & A_ALTCHARSET)) {
370 #endif /* !NCURSES_WCWIDTH_GRAPHICS */
374 * If we (still) have alternate character set, it is the normal 8bit
375 * flavor. The _screen_acs_map[] array tells if the character was
376 * really in acs_chars, needed because of the way wide/normal line
377 * drawing flavors are integrated.
379 if (AttrOf(attr) & A_ALTCHARSET) {
381 chtype temp = UChar(SP_PARM->_acs_map[j]);
384 SetChar(my_ch, temp, AttrOf(attr));
387 RemAttr(attr, A_ALTCHARSET);
392 #if USE_WIDEC_SUPPORT && !NCURSES_WCWIDTH_GRAPHICS
393 else if (chlen > 1 && is_wacs_value(CharOfD(ch))) {
397 if (tilde_glitch && (CharOfD(ch) == L('~'))) {
398 SetChar(tilde, L('`'), AttrOf(attr));
402 UpdateAttrs(SP_PARM, attr);
404 #if !USE_WIDEC_SUPPORT
407 SP_PARM->_curscol += chlen;
409 NCURSES_PUTP2("char_padding", char_padding);
414 check_pending(NCURSES_SP_DCL0)
415 /* check for pending input */
417 bool have_pending = FALSE;
420 * Only carry out this check when the flag is zero, otherwise we'll
421 * have the refreshing slow down drastically (or stop) if there's an
422 * unread character available.
424 if (SP_PARM->_fifohold != 0)
427 if (SP_PARM->_checkfd >= 0) {
429 struct pollfd fds[1];
430 fds[0].fd = SP_PARM->_checkfd;
431 fds[0].events = POLLIN;
432 if (poll(fds, (size_t) 1, 0) > 0) {
435 #elif defined(__BEOS__)
437 * BeOS's select() is declared in socket.h, so the configure script does
438 * not see it. That's just as well, since that function works only for
439 * sockets. This (using snooze and ioctl) was distilled from Be's patch
440 * for ncurses which uses a separate thread to simulate select().
442 * FIXME: the return values from the ioctl aren't very clear if we get
446 int howmany = ioctl(0, 'ichr', &n);
447 if (howmany >= 0 && n > 0) {
452 struct timeval ktimeout;
455 ktimeout.tv_usec = 0;
458 FD_SET(SP_PARM->_checkfd, &fdset);
459 if (select(SP_PARM->_checkfd + 1, &fdset, NULL, NULL, &ktimeout) != 0) {
465 SP_PARM->_fifohold = 5;
466 NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
471 /* put char at lower right corner */
473 PutCharLR(NCURSES_SP_DCLx const ARG_CH_T ch)
475 if (!auto_right_margin) {
476 /* we can put the char directly */
477 PutAttrChar(NCURSES_SP_ARGx ch);
478 } else if (enter_am_mode && exit_am_mode) {
479 /* we can suppress automargin */
480 NCURSES_PUTP2("exit_am_mode", exit_am_mode);
482 PutAttrChar(NCURSES_SP_ARGx ch);
484 position_check(NCURSES_SP_ARGx
489 NCURSES_PUTP2("enter_am_mode", enter_am_mode);
490 } else if ((enter_insert_mode && exit_insert_mode)
491 || insert_character || parm_ich) {
493 screen_lines(SP_PARM) - 1,
494 screen_columns(SP_PARM) - 2);
495 PutAttrChar(NCURSES_SP_ARGx ch);
497 screen_lines(SP_PARM) - 1,
498 screen_columns(SP_PARM) - 2);
499 InsStr(NCURSES_SP_ARGx
500 NewScreen(SP_PARM)->_line[screen_lines(SP_PARM) - 1].text +
501 screen_columns(SP_PARM) - 2, 1);
506 * Wrap the cursor position, i.e., advance to the beginning of the next line.
509 wrap_cursor(NCURSES_SP_DCL0)
511 if (eat_newline_glitch) {
513 * xenl can manifest two different ways. The vt100 way is that, when
514 * you'd expect the cursor to wrap, it stays hung at the right margin
515 * (on top of the character just emitted) and doesn't wrap until the
516 * *next* graphic char is emitted. The c100 way is to ignore LF
517 * received just after an am wrap.
519 * An aggressive way to handle this would be to emit CR/LF after the
520 * char and then assume the wrap is done, you're on the first position
521 * of the next line, and the terminal out of its weird state. Here
522 * it's safe to just tell the code that the cursor is in hyperspace and
523 * let the next mvcur() call straighten things out.
525 SP_PARM->_curscol = -1;
526 SP_PARM->_cursrow = -1;
527 } else if (auto_right_margin) {
528 SP_PARM->_curscol = 0;
531 * We've actually moved - but may have to work around problems with
532 * video attributes not working.
534 if (!move_standout_mode && AttrOf(SCREEN_ATTRS(SP_PARM))) {
535 TR(TRACE_CHARPUT, ("turning off (%#lx) %s before wrapping",
536 (unsigned long) AttrOf(SCREEN_ATTRS(SP_PARM)),
537 _traceattr(AttrOf(SCREEN_ATTRS(SP_PARM)))));
538 (void) VIDATTR(SP_PARM, A_NORMAL, 0);
543 position_check(NCURSES_SP_ARGx
549 static NCURSES_INLINE void
550 PutChar(NCURSES_SP_DCLx const ARG_CH_T ch)
551 /* insert character, handling automargin stuff */
553 if (SP_PARM->_cursrow == screen_lines(SP_PARM) - 1 &&
554 SP_PARM->_curscol == screen_columns(SP_PARM) - 1) {
555 PutCharLR(NCURSES_SP_ARGx ch);
557 PutAttrChar(NCURSES_SP_ARGx ch);
560 if (SP_PARM->_curscol >= screen_columns(SP_PARM))
561 wrap_cursor(NCURSES_SP_ARG);
563 position_check(NCURSES_SP_ARGx
565 SP_PARM->_curscol, "PutChar");
569 * Check whether the given character can be output by clearing commands. This
570 * includes test for being a space and not including any 'bad' attributes, such
571 * as A_REVERSE. All attribute flags which don't affect appearance of a space
572 * or can be output by clearing (A_COLOR in case of bce-terminal) are excluded.
574 static NCURSES_INLINE bool
575 can_clear_with(NCURSES_SP_DCLx ARG_CH_T ch)
577 if (!back_color_erase && SP_PARM->_coloron) {
578 #if NCURSES_EXT_FUNCS
581 if (!SP_PARM->_default_color)
583 if (!(isDefaultColor(SP_PARM->_default_fg) &&
584 isDefaultColor(SP_PARM->_default_bg)))
586 if ((pair = GetPair(CHDEREF(ch))) != 0) {
587 NCURSES_COLOR_T fg, bg;
588 if (NCURSES_SP_NAME(pair_content) (NCURSES_SP_ARGx
591 || !(isDefaultColor(fg) && isDefaultColor(bg))) {
596 if (AttrOfD(ch) & A_COLOR)
600 return (ISBLANK(CHDEREF(ch)) &&
601 (AttrOfD(ch) & ~(NONBLANK_ATTR | A_COLOR)) == BLANK_ATTR);
605 * Issue a given span of characters from an array.
606 * Must be functionally equivalent to:
607 * for (i = 0; i < num; i++)
609 * but can leave the cursor positioned at the middle of the interval.
611 * Returns: 0 - cursor is at the end of interval
612 * 1 - cursor is somewhere in the middle
614 * This code is optimized using ech and rep.
617 EmitRange(NCURSES_SP_DCLx const NCURSES_CH_T * ntext, int num)
621 TR(TRACE_CHARPUT, ("EmitRange %d:%s", num, _nc_viscbuf(ntext, num)));
623 if (erase_chars || repeat_char) {
628 while (num > 1 && !CharEq(ntext[0], ntext[1])) {
629 PutChar(NCURSES_SP_ARGx CHREF(ntext[0]));
635 PutChar(NCURSES_SP_ARGx CHREF(ntext0));
640 while (runcount < num && CharEq(ntext[runcount], ntext0))
644 * The cost expression in the middle isn't exactly right.
645 * _cup_ch_cost is an upper bound on the cost for moving to the
646 * end of the erased area, but not the cost itself (which we
647 * can't compute without emitting the move). This may result
648 * in erase_chars not getting used in some situations for
649 * which it would be marginally advantageous.
652 && runcount > SP_PARM->_ech_cost + SP_PARM->_cup_ch_cost
653 && can_clear_with(NCURSES_SP_ARGx CHREF(ntext0))) {
654 UpdateAttrs(SP_PARM, ntext0);
655 NCURSES_PUTP2("erase_chars", TPARM_1(erase_chars, runcount));
658 * If this is the last part of the given interval,
659 * don't bother moving cursor, since it can be the
660 * last update on the line.
662 if (runcount < num) {
665 SP_PARM->_curscol + runcount);
667 return 1; /* cursor stays in the middle */
669 } else if (repeat_char && runcount > SP_PARM->_rep_cost) {
670 bool wrap_possible = (SP_PARM->_curscol + runcount >=
671 screen_columns(SP_PARM));
672 int rep_count = runcount;
677 UpdateAttrs(SP_PARM, ntext0);
678 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
683 NCURSES_SP_NAME(_nc_outch));
684 SP_PARM->_curscol += rep_count;
687 PutChar(NCURSES_SP_ARGx CHREF(ntext0));
689 for (i = 0; i < runcount; i++)
690 PutChar(NCURSES_SP_ARGx CHREF(ntext[i]));
698 for (i = 0; i < num; i++)
699 PutChar(NCURSES_SP_ARGx CHREF(ntext[i]));
704 * Output the line in the given range [first .. last]
706 * If there's a run of identical characters that's long enough to justify
707 * cursor movement, use that also.
709 * Returns: same as EmitRange
712 PutRange(NCURSES_SP_DCLx
713 const NCURSES_CH_T * otext,
714 const NCURSES_CH_T * ntext,
720 TR(TRACE_CHARPUT, ("PutRange(%p, %p, %p, %d, %d, %d)",
722 (const void *) otext,
723 (const void *) ntext,
727 && (last - first + 1) > SP_PARM->_inline_cost) {
730 for (j = first, same = 0; j <= last; j++) {
731 if (!same && isWidecExt(otext[j]))
733 if (CharEq(otext[j], ntext[j])) {
736 if (same > SP_PARM->_inline_cost) {
737 EmitRange(NCURSES_SP_ARGx ntext + first, j - same - first);
738 GoTo(NCURSES_SP_ARGx row, first = j);
743 i = EmitRange(NCURSES_SP_ARGx ntext + first, j - same - first);
745 * Always return 1 for the next GoTo() after a PutRange() if we found
746 * identical characters at end of interval
748 rc = (same == 0 ? i : 1);
750 rc = EmitRange(NCURSES_SP_ARGx ntext + first, last - first + 1);
755 /* leave unbracketed here so 'indent' works */
756 #define MARK_NOCHANGE(win,row) \
757 win->_line[row].firstchar = _NOCHANGE; \
758 win->_line[row].lastchar = _NOCHANGE; \
759 if_USE_SCROLL_HINTS(win->_line[row].oldindex = row)
762 TINFO_DOUPDATE(NCURSES_SP_DCL0)
767 struct tms before, after;
768 #endif /* USE_TRACE_TIMES */
770 T((T_CALLED("_nc_tinfo:doupdate(%p)"), (void *) SP_PARM));
772 _nc_lock_global(update);
775 _nc_unlock_global(update);
780 * It is "legal" but unlikely that an application could assign a new
781 * value to one of the standard windows. Check for that possibility
782 * and try to recover.
784 * We do not allow applications to assign new values in the reentrant
787 #define SyncScreens(internal,exported) \
788 if (internal == 0) internal = exported; \
789 if (internal != exported) exported = internal
791 SyncScreens(CurScreen(SP_PARM), curscr);
792 SyncScreens(NewScreen(SP_PARM), newscr);
793 SyncScreens(StdScreen(SP_PARM), stdscr);
796 if (CurScreen(SP_PARM) == 0
797 || NewScreen(SP_PARM) == 0
798 || StdScreen(SP_PARM) == 0) {
799 _nc_unlock_global(update);
803 if (USE_TRACEF(TRACE_UPDATE)) {
804 if (CurScreen(SP_PARM)->_clear)
805 _tracef("curscr is clear");
807 _tracedump("curscr", CurScreen(SP_PARM));
808 _tracedump("newscr", NewScreen(SP_PARM));
809 _nc_unlock_global(tracef);
813 _nc_signal_handler(FALSE);
815 if (SP_PARM->_fifohold)
816 SP_PARM->_fifohold--;
819 if ((SP_PARM->_endwin == ewRunning)
820 || _nc_handle_sigwinch(SP_PARM)) {
822 * This is a transparent extension: XSI does not address it,
823 * and applications need not know that ncurses can do it.
825 * Check if the terminal size has changed while curses was off
826 * (this can happen in an xterm, for example), and resize the
827 * ncurses data structures accordingly.
829 _nc_update_screensize(SP_PARM);
833 if (SP_PARM->_endwin == ewSuspend) {
835 T(("coming back from shell mode"));
836 NCURSES_SP_NAME(reset_prog_mode) (NCURSES_SP_ARG);
838 NCURSES_SP_NAME(_nc_mvcur_resume) (NCURSES_SP_ARG);
839 NCURSES_SP_NAME(_nc_screen_resume) (NCURSES_SP_ARG);
840 SP_PARM->_mouse_resume(SP_PARM);
842 SP_PARM->_endwin = ewRunning;
845 /* zero the metering machinery */
847 (void) times(&before);
848 #endif /* USE_TRACE_TIMES */
851 * This is the support for magic-cookie terminals. The theory: we scan
852 * the virtual screen looking for attribute turnons. Where we find one,
853 * check to make sure it's realizable by seeing if the required number of
854 * un-attributed blanks are present before and after the attributed range;
855 * try to shift the range boundaries over blanks (not changing the screen
856 * display) so this becomes true. If it is, shift the beginning attribute
857 * change appropriately (the end one, if we've gotten this far, is
858 * guaranteed room for its cookie). If not, nuke the added attributes out
862 if (magic_cookie_glitch > 0) {
864 attr_t rattr = A_NORMAL;
866 for (i = 0; i < screen_lines(SP_PARM); i++) {
867 for (j = 0; j < screen_columns(SP_PARM); j++) {
869 NCURSES_CH_T *thisline = NewScreen(SP_PARM)->_line[i].text;
870 attr_t thisattr = AttrOf(thisline[j]) & SP_PARM->_xmc_triggers;
871 attr_t turnon = thisattr & ~rattr;
873 /* is an attribute turned on here? */
879 TR(TRACE_ATTRS, ("At (%d, %d): from %s...", i, j, _traceattr(rattr)));
880 TR(TRACE_ATTRS, ("...to %s", _traceattr(turnon)));
883 * If the attribute change location is a blank with a "safe"
884 * attribute, undo the attribute turnon. This may ensure
885 * there's enough room to set the attribute before the first
886 * non-blank in the run.
888 #define SAFE(scr,a) (!((a) & (scr)->_xmc_triggers))
889 if (ISBLANK(thisline[j]) && SAFE(SP_PARM, turnon)) {
890 RemAttr(thisline[j], turnon);
894 /* check that there's enough room at start of span */
895 for (k = 1; k <= magic_cookie_glitch; k++) {
897 || !ISBLANK(thisline[j - k])
898 || !SAFE(SP_PARM, AttrOf(thisline[j - k]))) {
900 TR(TRACE_ATTRS, ("No room at start in %d,%d%s%s",
902 (ISBLANK(thisline[j - k])
905 (SAFE(SP_PARM, AttrOf(thisline[j - k]))
912 bool end_onscreen = FALSE;
915 /* find end of span, if it's onscreen */
916 for (m = i; m < screen_lines(SP_PARM); m++) {
917 for (; n < screen_columns(SP_PARM); n++) {
919 AttrOf(NewScreen(SP_PARM)->_line[m].text[n]);
920 if ((testattr & SP_PARM->_xmc_triggers) == rattr) {
923 ("Range attributed with %s ends at (%d, %d)",
924 _traceattr(turnon), m, n));
931 ("Range attributed with %s ends offscreen",
932 _traceattr(turnon)));
936 NCURSES_CH_T *lastline =
937 NewScreen(SP_PARM)->_line[m].text;
940 * If there are safely-attributed blanks at the end of
941 * the range, shorten the range. This will help ensure
942 * that there is enough room at end of span.
945 && ISBLANK(lastline[n])
946 && SAFE(SP_PARM, AttrOf(lastline[n]))) {
947 RemAttr(lastline[n--], turnon);
950 /* check that there's enough room at end of span */
951 for (k = 1; k <= magic_cookie_glitch; k++) {
952 if (n + k >= screen_columns(SP_PARM)
953 || !ISBLANK(lastline[n + k])
954 || !SAFE(SP_PARM, AttrOf(lastline[n + k]))) {
957 ("No room at end in %d,%d%s%s",
959 (ISBLANK(lastline[n + k])
962 (SAFE(SP_PARM, AttrOf(lastline[n + k]))
975 ("Clearing %s beginning at (%d, %d)",
976 _traceattr(turnon), i, j));
978 /* turn off new attributes over span */
979 for (p = i; p < screen_lines(SP_PARM); p++) {
980 for (; q < screen_columns(SP_PARM); q++) {
981 attr_t testattr = AttrOf(newscr->_line[p].text[q]);
982 if ((testattr & SP_PARM->_xmc_triggers) == rattr)
984 RemAttr(NewScreen(SP_PARM)->_line[p].text[q], turnon);
991 ("Cookie space for %s found before (%d, %d)",
992 _traceattr(turnon), i, j));
995 * Back up the start of range so there's room for cookies
996 * before the first nonblank character.
998 for (k = 1; k <= magic_cookie_glitch; k++)
999 AddAttr(thisline[j - k], turnon);
1007 /* show altered highlights after magic-cookie check */
1008 if (USE_TRACEF(TRACE_UPDATE)) {
1009 _tracef("After magic-cookie check...");
1010 _tracedump("newscr", NewScreen(SP_PARM));
1011 _nc_unlock_global(tracef);
1015 #endif /* USE_XMC_SUPPORT */
1018 if (CurScreen(SP_PARM)->_clear || NewScreen(SP_PARM)->_clear) { /* force refresh ? */
1019 ClrUpdate(NCURSES_SP_ARG);
1020 CurScreen(SP_PARM)->_clear = FALSE; /* reset flag */
1021 NewScreen(SP_PARM)->_clear = FALSE; /* reset flag */
1023 int changedlines = CHECK_INTERVAL;
1025 if (check_pending(NCURSES_SP_ARG))
1028 nonempty = min(screen_lines(SP_PARM), NewScreen(SP_PARM)->_maxy + 1);
1030 if (SP_PARM->_scrolling) {
1031 NCURSES_SP_NAME(_nc_scroll_optimize) (NCURSES_SP_ARG);
1034 nonempty = ClrBottom(NCURSES_SP_ARGx nonempty);
1036 TR(TRACE_UPDATE, ("Transforming lines, nonempty %d", nonempty));
1037 for (i = 0; i < nonempty; i++) {
1039 * Here is our line-breakout optimization.
1041 if (changedlines == CHECK_INTERVAL) {
1042 if (check_pending(NCURSES_SP_ARG))
1048 * newscr->line[i].firstchar is normally set
1049 * by wnoutrefresh. curscr->line[i].firstchar
1050 * is normally set by _nc_scroll_window in the
1051 * vertical-movement optimization code,
1053 if (NewScreen(SP_PARM)->_line[i].firstchar != _NOCHANGE
1054 || CurScreen(SP_PARM)->_line[i].firstchar != _NOCHANGE) {
1055 TransformLine(NCURSES_SP_ARGx i);
1059 /* mark line changed successfully */
1060 if (i <= NewScreen(SP_PARM)->_maxy) {
1061 MARK_NOCHANGE(NewScreen(SP_PARM), i);
1063 if (i <= CurScreen(SP_PARM)->_maxy) {
1064 MARK_NOCHANGE(CurScreen(SP_PARM), i);
1069 /* put everything back in sync */
1070 for (i = nonempty; i <= NewScreen(SP_PARM)->_maxy; i++) {
1071 MARK_NOCHANGE(NewScreen(SP_PARM), i);
1073 for (i = nonempty; i <= CurScreen(SP_PARM)->_maxy; i++) {
1074 MARK_NOCHANGE(CurScreen(SP_PARM), i);
1077 if (!NewScreen(SP_PARM)->_leaveok) {
1078 CurScreen(SP_PARM)->_curx = NewScreen(SP_PARM)->_curx;
1079 CurScreen(SP_PARM)->_cury = NewScreen(SP_PARM)->_cury;
1081 GoTo(NCURSES_SP_ARGx CurScreen(SP_PARM)->_cury, CurScreen(SP_PARM)->_curx);
1086 * We would like to keep the physical screen in normal mode in case we get
1087 * other processes writing to the screen. This goal cannot be met for
1088 * magic cookies since it interferes with attributes that may propagate
1089 * past the current position.
1092 if (magic_cookie_glitch != 0)
1094 UpdateAttrs(SP_PARM, normal);
1096 NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
1097 WINDOW_ATTRS(CurScreen(SP_PARM)) = WINDOW_ATTRS(NewScreen(SP_PARM));
1100 (void) times(&after);
1102 ("Update cost: %ld chars, %ld clocks system time, %ld clocks user time",
1104 (long) (after.tms_stime - before.tms_stime),
1105 (long) (after.tms_utime - before.tms_utime)));
1106 #endif /* USE_TRACE_TIMES */
1108 _nc_signal_handler(TRUE);
1110 _nc_unlock_global(update);
1114 #if NCURSES_SP_FUNCS && !defined(USE_TERM_DRIVER)
1118 return TINFO_DOUPDATE(CURRENT_SCREEN);
1125 * Returns the attributed character that corresponds to the "cleared"
1126 * screen. If the terminal has the back-color-erase feature, this will be
1127 * colored according to the wbkgd() call.
1129 * We treat 'curscr' specially because it isn't supposed to be set directly
1130 * in the wbkgd() call. Assume 'stdscr' for this case.
1132 #define BCE_ATTRS (A_NORMAL|A_COLOR)
1133 #define BCE_BKGD(sp,win) (((win) == CurScreen(sp) ? StdScreen(sp) : (win))->_nc_bkgd)
1135 static NCURSES_INLINE NCURSES_CH_T
1136 ClrBlank(NCURSES_SP_DCLx WINDOW *win)
1138 NCURSES_CH_T blank = blankchar;
1139 if (back_color_erase)
1140 AddAttr(blank, (AttrOf(BCE_BKGD(SP_PARM, win)) & BCE_ATTRS));
1147 ** Update by clearing and redrawing the entire screen.
1152 ClrUpdate(NCURSES_SP_DCL0)
1154 TR(TRACE_UPDATE, (T_CALLED("ClrUpdate")));
1157 NCURSES_CH_T blank = ClrBlank(NCURSES_SP_ARGx StdScreen(SP_PARM));
1158 int nonempty = min(screen_lines(SP_PARM),
1159 NewScreen(SP_PARM)->_maxy + 1);
1161 ClearScreen(NCURSES_SP_ARGx blank);
1163 TR(TRACE_UPDATE, ("updating screen from scratch"));
1165 nonempty = ClrBottom(NCURSES_SP_ARGx nonempty);
1167 for (i = 0; i < nonempty; i++)
1168 TransformLine(NCURSES_SP_ARGx i);
1170 TR(TRACE_UPDATE, (T_RETURN("")));
1176 ** Clear to end of current line, starting at the cursor position
1180 ClrToEOL(NCURSES_SP_DCLx NCURSES_CH_T blank, int needclear)
1182 if (CurScreen(SP_PARM) != 0
1183 && SP_PARM->_cursrow >= 0) {
1186 for (j = SP_PARM->_curscol; j < screen_columns(SP_PARM); j++) {
1189 &(CurScreen(SP_PARM)->_line[SP_PARM->_cursrow].text[j]);
1191 if (!CharEq(*cp, blank)) {
1200 UpdateAttrs(SP_PARM, blank);
1201 if (clr_eol && SP_PARM->_el_cost <= (screen_columns(SP_PARM) - SP_PARM->_curscol)) {
1202 NCURSES_PUTP2("clr_eol", clr_eol);
1204 int count = (screen_columns(SP_PARM) - SP_PARM->_curscol);
1206 PutChar(NCURSES_SP_ARGx CHREF(blank));
1214 ** Clear to end of screen, starting at the cursor position
1218 ClrToEOS(NCURSES_SP_DCLx NCURSES_CH_T blank)
1222 row = SP_PARM->_cursrow;
1223 col = SP_PARM->_curscol;
1230 UpdateAttrs(SP_PARM, blank);
1231 TPUTS_TRACE("clr_eos");
1232 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1234 screen_lines(SP_PARM) - row,
1235 NCURSES_SP_NAME(_nc_outch));
1237 while (col < screen_columns(SP_PARM))
1238 CurScreen(SP_PARM)->_line[row].text[col++] = blank;
1240 for (row++; row < screen_lines(SP_PARM); row++) {
1241 for (col = 0; col < screen_columns(SP_PARM); col++)
1242 CurScreen(SP_PARM)->_line[row].text[col] = blank;
1249 * Test if clearing the end of the screen would satisfy part of the
1250 * screen-update. Do this by scanning backwards through the lines in the
1251 * screen, checking if each is blank, and one or more are changed.
1254 ClrBottom(NCURSES_SP_DCLx int total)
1257 int last = min(screen_columns(SP_PARM), NewScreen(SP_PARM)->_maxx + 1);
1258 NCURSES_CH_T blank = NewScreen(SP_PARM)->_line[total - 1].text[last - 1];
1260 if (clr_eos && can_clear_with(NCURSES_SP_ARGx CHREF(blank))) {
1263 for (row = total - 1; row >= 0; row--) {
1267 for (col = 0, ok = TRUE; ok && col < last; col++) {
1268 ok = (CharEq(NewScreen(SP_PARM)->_line[row].text[col], blank));
1273 for (col = 0; ok && col < last; col++) {
1274 ok = (CharEq(CurScreen(SP_PARM)->_line[row].text[col], blank));
1280 /* don't use clr_eos for just one line if clr_eol available */
1282 GoTo(NCURSES_SP_ARGx top, 0);
1283 ClrToEOS(NCURSES_SP_ARGx blank);
1284 if (SP_PARM->oldhash && SP_PARM->newhash) {
1285 for (row = top; row < screen_lines(SP_PARM); row++)
1286 SP_PARM->oldhash[row] = SP_PARM->newhash[row];
1294 #if USE_WIDEC_SUPPORT
1295 #define check_xmc_transition(sp, a, b) \
1296 ((((a)->attr ^ (b)->attr) & ~((a)->attr) & (sp)->_xmc_triggers) != 0)
1297 #define xmc_turn_on(sp,a,b) check_xmc_transition(sp,&(a), &(b))
1299 #define xmc_turn_on(sp,a,b) ((((a)^(b)) & ~(a) & (sp)->_xmc_triggers) != 0)
1302 #define xmc_new(sp,r,c) NewScreen(sp)->_line[r].text[c]
1303 #define xmc_turn_off(sp,a,b) xmc_turn_on(sp,b,a)
1304 #endif /* USE_XMC_SUPPORT */
1307 ** TransformLine(lineno)
1309 ** Transform the given line in curscr to the one in newscr, using
1310 ** Insert/Delete Character if idcok && has_ic().
1312 ** firstChar = position of first different character in line
1313 ** oLastChar = position of last different character in old line
1314 ** nLastChar = position of last different character in new line
1316 ** move to firstChar
1317 ** overwrite chars up to min(oLastChar, nLastChar)
1318 ** if oLastChar < nLastChar
1319 ** insert newLine[oLastChar+1..nLastChar]
1321 ** delete oLastChar - nLastChar spaces
1325 TransformLine(NCURSES_SP_DCLx int const lineno)
1327 int firstChar, oLastChar, nLastChar;
1328 NCURSES_CH_T *newLine = NewScreen(SP_PARM)->_line[lineno].text;
1329 NCURSES_CH_T *oldLine = CurScreen(SP_PARM)->_line[lineno].text;
1331 bool attrchanged = FALSE;
1333 TR(TRACE_UPDATE, (T_CALLED("TransformLine(%p, %d)"), (void *) SP_PARM, lineno));
1335 /* copy new hash value to old one */
1336 if (SP_PARM->oldhash && SP_PARM->newhash)
1337 SP_PARM->oldhash[lineno] = SP_PARM->newhash[lineno];
1340 * If we have colors, there is the possibility of having two color pairs
1341 * that display as the same colors. For instance, Lynx does this. Check
1342 * for this case, and update the old line with the new line's colors when
1343 * they are equivalent.
1345 if (SP_PARM->_coloron) {
1349 for (n = 0; n < screen_columns(SP_PARM); n++) {
1350 if (!CharEq(newLine[n], oldLine[n])) {
1351 oldPair = GetPair(oldLine[n]);
1352 newPair = GetPair(newLine[n]);
1353 if (oldPair != newPair
1354 && unColor(oldLine[n]) == unColor(newLine[n])) {
1355 if (oldPair < SP_PARM->_pair_limit
1356 && newPair < SP_PARM->_pair_limit
1357 && (isSamePair(SP_PARM->_color_pairs[oldPair],
1358 SP_PARM->_color_pairs[newPair]))) {
1359 SetPair(oldLine[n], GetPair(newLine[n]));
1366 if (ceol_standout_glitch && clr_eol) {
1368 while (firstChar < screen_columns(SP_PARM)) {
1369 if (!SameAttrOf(newLine[firstChar], oldLine[firstChar])) {
1379 if (attrchanged) { /* we may have to disregard the whole line */
1380 GoTo(NCURSES_SP_ARGx lineno, firstChar);
1381 ClrToEOL(NCURSES_SP_ARGx
1382 ClrBlank(NCURSES_SP_ARGx
1383 CurScreen(SP_PARM)), FALSE);
1384 PutRange(NCURSES_SP_ARGx
1385 oldLine, newLine, lineno, 0,
1386 screen_columns(SP_PARM) - 1);
1390 * This is a very simple loop to paint characters which may have the
1391 * magic cookie glitch embedded. It doesn't know much about video
1392 * attributes which are continued from one line to the next. It
1393 * assumes that we have filtered out requests for attribute changes
1394 * that do not get mapped to blank positions.
1396 * FIXME: we are not keeping track of where we put the cookies, so this
1397 * will work properly only once, since we may overwrite a cookie in a
1398 * following operation.
1400 } else if (magic_cookie_glitch > 0) {
1401 GoTo(NCURSES_SP_ARGx lineno, firstChar);
1402 for (n = 0; n < screen_columns(SP_PARM); n++) {
1403 int m = n + magic_cookie_glitch;
1405 /* check for turn-on:
1406 * If we are writing an attributed blank, where the
1407 * previous cell is not attributed.
1409 if (ISBLANK(newLine[n])
1411 && xmc_turn_on(SP_PARM, newLine[n - 1], newLine[n]))
1414 && xmc_turn_on(SP_PARM,
1415 xmc_new(SP_PARM, lineno - 1,
1416 screen_columns(SP_PARM) - 1),
1421 PutChar(NCURSES_SP_ARGx CHREF(newLine[n]));
1423 /* check for turn-off:
1424 * If we are writing an attributed non-blank, where the
1425 * next cell is blank, and not attributed.
1427 if (!ISBLANK(newLine[n])
1428 && ((n + 1 < screen_columns(SP_PARM)
1429 && xmc_turn_off(SP_PARM, newLine[n], newLine[n + 1]))
1430 || (n + 1 >= screen_columns(SP_PARM)
1431 && lineno + 1 < screen_lines(SP_PARM)
1432 && xmc_turn_off(SP_PARM,
1434 xmc_new(SP_PARM, lineno + 1, 0))))) {
1443 /* it may be cheap to clear leading whitespace with clr_bol */
1445 if (clr_bol && can_clear_with(NCURSES_SP_ARGx CHREF(blank))) {
1446 int oFirstChar, nFirstChar;
1448 for (oFirstChar = 0;
1449 oFirstChar < screen_columns(SP_PARM);
1451 if (!CharEq(oldLine[oFirstChar], blank))
1453 for (nFirstChar = 0;
1454 nFirstChar < screen_columns(SP_PARM);
1456 if (!CharEq(newLine[nFirstChar], blank))
1459 if (nFirstChar == oFirstChar) {
1460 firstChar = nFirstChar;
1461 /* find the first differing character */
1462 while (firstChar < screen_columns(SP_PARM)
1463 && CharEq(newLine[firstChar], oldLine[firstChar]))
1465 } else if (oFirstChar > nFirstChar) {
1466 firstChar = nFirstChar;
1467 } else { /* oFirstChar < nFirstChar */
1468 firstChar = oFirstChar;
1469 if (SP_PARM->_el1_cost < nFirstChar - oFirstChar) {
1470 if (nFirstChar >= screen_columns(SP_PARM)
1471 && SP_PARM->_el_cost <= SP_PARM->_el1_cost) {
1472 GoTo(NCURSES_SP_ARGx lineno, 0);
1473 UpdateAttrs(SP_PARM, blank);
1474 NCURSES_PUTP2("clr_eol", clr_eol);
1476 GoTo(NCURSES_SP_ARGx lineno, nFirstChar - 1);
1477 UpdateAttrs(SP_PARM, blank);
1478 NCURSES_PUTP2("clr_bol", clr_bol);
1481 while (firstChar < nFirstChar)
1482 oldLine[firstChar++] = blank;
1486 /* find the first differing character */
1487 while (firstChar < screen_columns(SP_PARM)
1488 && CharEq(newLine[firstChar], oldLine[firstChar]))
1491 /* if there wasn't one, we're done */
1492 if (firstChar >= screen_columns(SP_PARM)) {
1493 TR(TRACE_UPDATE, (T_RETURN("")));
1497 blank = newLine[screen_columns(SP_PARM) - 1];
1499 if (!can_clear_with(NCURSES_SP_ARGx CHREF(blank))) {
1500 /* find the last differing character */
1501 nLastChar = screen_columns(SP_PARM) - 1;
1503 while (nLastChar > firstChar
1504 && CharEq(newLine[nLastChar], oldLine[nLastChar]))
1507 if (nLastChar >= firstChar) {
1508 GoTo(NCURSES_SP_ARGx lineno, firstChar);
1509 PutRange(NCURSES_SP_ARGx
1515 memcpy(oldLine + firstChar,
1516 newLine + firstChar,
1517 (unsigned) (nLastChar - firstChar + 1) * sizeof(NCURSES_CH_T));
1519 TR(TRACE_UPDATE, (T_RETURN("")));
1523 /* find last non-blank character on old line */
1524 oLastChar = screen_columns(SP_PARM) - 1;
1525 while (oLastChar > firstChar && CharEq(oldLine[oLastChar], blank))
1528 /* find last non-blank character on new line */
1529 nLastChar = screen_columns(SP_PARM) - 1;
1530 while (nLastChar > firstChar && CharEq(newLine[nLastChar], blank))
1533 if ((nLastChar == firstChar)
1534 && (SP_PARM->_el_cost < (oLastChar - nLastChar))) {
1535 GoTo(NCURSES_SP_ARGx lineno, firstChar);
1536 if (!CharEq(newLine[firstChar], blank))
1537 PutChar(NCURSES_SP_ARGx CHREF(newLine[firstChar]));
1538 ClrToEOL(NCURSES_SP_ARGx blank, FALSE);
1539 } else if ((nLastChar != oLastChar)
1540 && (!CharEq(newLine[nLastChar], oldLine[oLastChar])
1541 || !(SP_PARM->_nc_sp_idcok
1542 && NCURSES_SP_NAME(has_ic) (NCURSES_SP_ARG)))) {
1543 GoTo(NCURSES_SP_ARGx lineno, firstChar);
1544 if ((oLastChar - nLastChar) > SP_PARM->_el_cost) {
1545 if (PutRange(NCURSES_SP_ARGx
1551 GoTo(NCURSES_SP_ARGx lineno, nLastChar + 1);
1553 ClrToEOL(NCURSES_SP_ARGx blank, FALSE);
1555 n = max(nLastChar, oLastChar);
1556 PutRange(NCURSES_SP_ARGx
1564 int nLastNonblank = nLastChar;
1565 int oLastNonblank = oLastChar;
1567 /* find the last characters that really differ */
1568 /* can be -1 if no characters differ */
1569 while (CharEq(newLine[nLastChar], oldLine[oLastChar])) {
1570 /* don't split a wide char */
1571 if (isWidecExt(newLine[nLastChar]) &&
1572 !CharEq(newLine[nLastChar - 1], oldLine[oLastChar - 1]))
1576 if (nLastChar == -1 || oLastChar == -1)
1580 n = min(oLastChar, nLastChar);
1581 if (n >= firstChar) {
1582 GoTo(NCURSES_SP_ARGx lineno, firstChar);
1583 PutRange(NCURSES_SP_ARGx
1591 if (oLastChar < nLastChar) {
1592 int m = max(nLastNonblank, oLastNonblank);
1593 #if USE_WIDEC_SUPPORT
1595 while (isWidecExt(newLine[n + 1]) && n) {
1597 --oLastChar; /* increase cost */
1599 } else if (n >= firstChar &&
1600 isWidecBase(newLine[n])) {
1601 while (isWidecExt(newLine[n + 1])) {
1603 ++oLastChar; /* decrease cost */
1607 GoTo(NCURSES_SP_ARGx lineno, n + 1);
1608 if ((nLastChar < nLastNonblank)
1609 || InsCharCost(SP_PARM, nLastChar - oLastChar) > (m - n)) {
1610 PutRange(NCURSES_SP_ARGx
1617 InsStr(NCURSES_SP_ARGx &newLine[n + 1], nLastChar - oLastChar);
1619 } else if (oLastChar > nLastChar) {
1620 GoTo(NCURSES_SP_ARGx lineno, n + 1);
1621 if (DelCharCost(SP_PARM, oLastChar - nLastChar)
1622 > SP_PARM->_el_cost + nLastNonblank - (n + 1)) {
1623 if (PutRange(NCURSES_SP_ARGx oldLine, newLine, lineno,
1624 n + 1, nLastNonblank)) {
1625 GoTo(NCURSES_SP_ARGx lineno, nLastNonblank + 1);
1627 ClrToEOL(NCURSES_SP_ARGx blank, FALSE);
1630 * The delete-char sequence will
1631 * effectively shift in blanks from the
1632 * right margin of the screen. Ensure
1633 * that they are the right color by
1634 * setting the video attributes from
1635 * the last character on the row.
1637 UpdateAttrs(SP_PARM, blank);
1638 DelChar(NCURSES_SP_ARGx oLastChar - nLastChar);
1644 /* update the code's internal representation */
1645 if (screen_columns(SP_PARM) > firstChar)
1646 memcpy(oldLine + firstChar,
1647 newLine + firstChar,
1648 (unsigned) (screen_columns(SP_PARM) - firstChar) * sizeof(NCURSES_CH_T));
1649 TR(TRACE_UPDATE, (T_RETURN("")));
1654 ** ClearScreen(blank)
1656 ** Clear the physical screen and put cursor at home
1661 ClearScreen(NCURSES_SP_DCLx NCURSES_CH_T blank)
1664 bool fast_clear = (clear_screen || clr_eos || clr_eol);
1666 TR(TRACE_UPDATE, ("ClearScreen() called"));
1668 #if NCURSES_EXT_FUNCS
1669 if (SP_PARM->_coloron
1670 && !SP_PARM->_default_color) {
1671 NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx
1672 (short) GET_SCREEN_PAIR(SP_PARM),
1675 NCURSES_SP_NAME(_nc_outch));
1676 if (!back_color_erase) {
1684 UpdateAttrs(SP_PARM, blank);
1685 NCURSES_PUTP2("clear_screen", clear_screen);
1686 SP_PARM->_cursrow = SP_PARM->_curscol = 0;
1687 position_check(NCURSES_SP_ARGx
1691 } else if (clr_eos) {
1692 SP_PARM->_cursrow = SP_PARM->_curscol = -1;
1693 GoTo(NCURSES_SP_ARGx 0, 0);
1694 UpdateAttrs(SP_PARM, blank);
1695 TPUTS_TRACE("clr_eos");
1696 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1698 screen_lines(SP_PARM),
1699 NCURSES_SP_NAME(_nc_outch));
1700 } else if (clr_eol) {
1701 SP_PARM->_cursrow = SP_PARM->_curscol = -1;
1702 UpdateAttrs(SP_PARM, blank);
1703 for (i = 0; i < screen_lines(SP_PARM); i++) {
1704 GoTo(NCURSES_SP_ARGx i, 0);
1705 NCURSES_PUTP2("clr_eol", clr_eol);
1707 GoTo(NCURSES_SP_ARGx 0, 0);
1710 UpdateAttrs(SP_PARM, blank);
1711 for (i = 0; i < screen_lines(SP_PARM); i++) {
1712 GoTo(NCURSES_SP_ARGx i, 0);
1713 for (j = 0; j < screen_columns(SP_PARM); j++)
1714 PutChar(NCURSES_SP_ARGx CHREF(blank));
1716 GoTo(NCURSES_SP_ARGx 0, 0);
1719 for (i = 0; i < screen_lines(SP_PARM); i++) {
1720 for (j = 0; j < screen_columns(SP_PARM); j++)
1721 CurScreen(SP_PARM)->_line[i].text[j] = blank;
1724 TR(TRACE_UPDATE, ("screen cleared"));
1728 ** InsStr(line, count)
1730 ** Insert the count characters pointed to by line.
1735 InsStr(NCURSES_SP_DCLx NCURSES_CH_T * line, int count)
1737 TR(TRACE_UPDATE, ("InsStr(%p, %p,%d) called",
1739 (void *) line, count));
1741 /* Prefer parm_ich as it has the smallest cost - no need to shift
1742 * the whole line on each character. */
1743 /* The order must match that of InsCharCost. */
1745 TPUTS_TRACE("parm_ich");
1746 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1747 TPARM_1(parm_ich, count),
1749 NCURSES_SP_NAME(_nc_outch));
1751 PutAttrChar(NCURSES_SP_ARGx CHREF(*line));
1755 } else if (enter_insert_mode && exit_insert_mode) {
1756 NCURSES_PUTP2("enter_insert_mode", enter_insert_mode);
1758 PutAttrChar(NCURSES_SP_ARGx CHREF(*line));
1759 if (insert_padding) {
1760 NCURSES_PUTP2("insert_padding", insert_padding);
1765 NCURSES_PUTP2("exit_insert_mode", exit_insert_mode);
1768 NCURSES_PUTP2("insert_character", insert_character);
1769 PutAttrChar(NCURSES_SP_ARGx CHREF(*line));
1770 if (insert_padding) {
1771 NCURSES_PUTP2("insert_padding", insert_padding);
1777 position_check(NCURSES_SP_ARGx
1779 SP_PARM->_curscol, "InsStr");
1785 ** Delete count characters at current position
1790 DelChar(NCURSES_SP_DCLx int count)
1792 TR(TRACE_UPDATE, ("DelChar(%p, %d) called, position = (%ld,%ld)",
1793 (void *) SP_PARM, count,
1794 (long) NewScreen(SP_PARM)->_cury,
1795 (long) NewScreen(SP_PARM)->_curx));
1798 TPUTS_TRACE("parm_dch");
1799 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1800 TPARM_1(parm_dch, count),
1802 NCURSES_SP_NAME(_nc_outch));
1806 for (n = 0; n < count; n++) {
1807 NCURSES_PUTP2("delete_character", delete_character);
1813 * Physical-scrolling support
1815 * This code was adapted from Keith Bostic's hardware scrolling
1816 * support for 4.4BSD curses. I (esr) translated it to use terminfo
1817 * capabilities, narrowed the call interface slightly, and cleaned
1818 * up some convoluted tests. I also added support for the memory_above
1819 * memory_below, and non_dest_scroll_region capabilities.
1821 * For this code to work, we must have either
1822 * change_scroll_region and scroll forward/reverse commands, or
1823 * insert and delete line capabilities.
1824 * When the scrolling region has been set, the cursor has to
1825 * be at the last line of the region to make the scroll up
1826 * happen, or on the first line of region to scroll down.
1828 * This code makes one aesthetic decision in the opposite way from
1829 * BSD curses. BSD curses preferred pairs of il/dl operations
1830 * over scrolls, allegedly because il/dl looked faster. We, on
1831 * the other hand, prefer scrolls because (a) they're just as fast
1832 * on many terminals and (b) using them avoids bouncing an
1833 * unchanged bottom section of the screen up and down, which is
1836 * (lav): added more cases, used dl/il when bot==maxy and in csr case.
1838 * I used assumption that capabilities il/il1/dl/dl1 work inside
1839 * changed scroll region not shifting screen contents outside of it.
1840 * If there are any terminals behaving different way, it would be
1841 * necessary to add some conditions to scroll_csr_forward/backward.
1844 /* Try to scroll up assuming given csr (miny, maxy). Returns ERR on failure */
1846 scroll_csr_forward(NCURSES_SP_DCLx
1856 if (n == 1 && scroll_forward && top == miny && bot == maxy) {
1857 GoTo(NCURSES_SP_ARGx bot, 0);
1858 UpdateAttrs(SP_PARM, blank);
1859 NCURSES_PUTP2("scroll_forward", scroll_forward);
1860 } else if (n == 1 && delete_line && bot == maxy) {
1861 GoTo(NCURSES_SP_ARGx top, 0);
1862 UpdateAttrs(SP_PARM, blank);
1863 NCURSES_PUTP2("delete_line", delete_line);
1864 } else if (parm_index && top == miny && bot == maxy) {
1865 GoTo(NCURSES_SP_ARGx bot, 0);
1866 UpdateAttrs(SP_PARM, blank);
1867 TPUTS_TRACE("parm_index");
1868 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1869 TPARM_2(parm_index, n, 0),
1871 NCURSES_SP_NAME(_nc_outch));
1872 } else if (parm_delete_line && bot == maxy) {
1873 GoTo(NCURSES_SP_ARGx top, 0);
1874 UpdateAttrs(SP_PARM, blank);
1875 TPUTS_TRACE("parm_delete_line");
1876 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1877 TPARM_2(parm_delete_line, n, 0),
1879 NCURSES_SP_NAME(_nc_outch));
1880 } else if (scroll_forward && top == miny && bot == maxy) {
1881 GoTo(NCURSES_SP_ARGx bot, 0);
1882 UpdateAttrs(SP_PARM, blank);
1883 for (i = 0; i < n; i++) {
1884 NCURSES_PUTP2("scroll_forward", scroll_forward);
1886 } else if (delete_line && bot == maxy) {
1887 GoTo(NCURSES_SP_ARGx top, 0);
1888 UpdateAttrs(SP_PARM, blank);
1889 for (i = 0; i < n; i++) {
1890 NCURSES_PUTP2("delete_line", delete_line);
1895 #if NCURSES_EXT_FUNCS
1896 if (FILL_BCE(SP_PARM)) {
1898 for (i = 0; i < n; i++) {
1899 GoTo(NCURSES_SP_ARGx bot - i, 0);
1900 for (j = 0; j < screen_columns(SP_PARM); j++)
1901 PutChar(NCURSES_SP_ARGx CHREF(blank));
1908 /* Try to scroll down assuming given csr (miny, maxy). Returns ERR on failure */
1911 scroll_csr_backward(NCURSES_SP_DCLx
1921 if (n == 1 && scroll_reverse && top == miny && bot == maxy) {
1922 GoTo(NCURSES_SP_ARGx top, 0);
1923 UpdateAttrs(SP_PARM, blank);
1924 NCURSES_PUTP2("scroll_reverse", scroll_reverse);
1925 } else if (n == 1 && insert_line && bot == maxy) {
1926 GoTo(NCURSES_SP_ARGx top, 0);
1927 UpdateAttrs(SP_PARM, blank);
1928 NCURSES_PUTP2("insert_line", insert_line);
1929 } else if (parm_rindex && top == miny && bot == maxy) {
1930 GoTo(NCURSES_SP_ARGx top, 0);
1931 UpdateAttrs(SP_PARM, blank);
1932 TPUTS_TRACE("parm_rindex");
1933 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1934 TPARM_2(parm_rindex, n, 0),
1936 NCURSES_SP_NAME(_nc_outch));
1937 } else if (parm_insert_line && bot == maxy) {
1938 GoTo(NCURSES_SP_ARGx top, 0);
1939 UpdateAttrs(SP_PARM, blank);
1940 TPUTS_TRACE("parm_insert_line");
1941 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1942 TPARM_2(parm_insert_line, n, 0),
1944 NCURSES_SP_NAME(_nc_outch));
1945 } else if (scroll_reverse && top == miny && bot == maxy) {
1946 GoTo(NCURSES_SP_ARGx top, 0);
1947 UpdateAttrs(SP_PARM, blank);
1948 for (i = 0; i < n; i++) {
1949 NCURSES_PUTP2("scroll_reverse", scroll_reverse);
1951 } else if (insert_line && bot == maxy) {
1952 GoTo(NCURSES_SP_ARGx top, 0);
1953 UpdateAttrs(SP_PARM, blank);
1954 for (i = 0; i < n; i++) {
1955 NCURSES_PUTP2("insert_line", insert_line);
1960 #if NCURSES_EXT_FUNCS
1961 if (FILL_BCE(SP_PARM)) {
1963 for (i = 0; i < n; i++) {
1964 GoTo(NCURSES_SP_ARGx top + i, 0);
1965 for (j = 0; j < screen_columns(SP_PARM); j++)
1966 PutChar(NCURSES_SP_ARGx CHREF(blank));
1973 /* scroll by using delete_line at del and insert_line at ins */
1976 scroll_idl(NCURSES_SP_DCLx int n, int del, int ins, NCURSES_CH_T blank)
1980 if (!((parm_delete_line || delete_line) && (parm_insert_line || insert_line)))
1983 GoTo(NCURSES_SP_ARGx del, 0);
1984 UpdateAttrs(SP_PARM, blank);
1985 if (n == 1 && delete_line) {
1986 NCURSES_PUTP2("delete_line", delete_line);
1987 } else if (parm_delete_line) {
1988 TPUTS_TRACE("parm_delete_line");
1989 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1990 TPARM_2(parm_delete_line, n, 0),
1992 NCURSES_SP_NAME(_nc_outch));
1993 } else { /* if (delete_line) */
1994 for (i = 0; i < n; i++) {
1995 NCURSES_PUTP2("delete_line", delete_line);
1999 GoTo(NCURSES_SP_ARGx ins, 0);
2000 UpdateAttrs(SP_PARM, blank);
2001 if (n == 1 && insert_line) {
2002 NCURSES_PUTP2("insert_line", insert_line);
2003 } else if (parm_insert_line) {
2004 TPUTS_TRACE("parm_insert_line");
2005 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
2006 TPARM_2(parm_insert_line, n, 0),
2008 NCURSES_SP_NAME(_nc_outch));
2009 } else { /* if (insert_line) */
2010 for (i = 0; i < n; i++) {
2011 NCURSES_PUTP2("insert_line", insert_line);
2019 * Note: some terminals require the cursor to be within the scrolling margins
2020 * before setting them. Generally, the cursor must be at the appropriate end
2021 * of the scrolling margins when issuing an indexing operation (it is not
2022 * apparent whether it must also be at the left margin; we do this just to be
2023 * safe). To make the related cursor movement a little faster, we use the
2024 * save/restore cursor capabilities if the terminal has them.
2027 NCURSES_SP_NAME(_nc_scrolln) (NCURSES_SP_DCLx
2032 /* scroll region from top to bot by n lines */
2036 bool cursor_saved = FALSE;
2039 TR(TRACE_MOVE, ("_nc_scrolln(%p, %d, %d, %d, %d)",
2040 (void *) SP_PARM, n, top, bot, maxy));
2042 if (!IsValidScreen(SP_PARM))
2045 blank = ClrBlank(NCURSES_SP_ARGx StdScreen(SP_PARM));
2049 * If we scroll, we might remove a cookie.
2051 if (magic_cookie_glitch > 0) {
2056 if (n > 0) { /* scroll up (forward) */
2058 * Explicitly clear if stuff pushed off top of region might
2059 * be saved by the terminal.
2061 res = scroll_csr_forward(NCURSES_SP_ARGx n, top, bot, 0, maxy, blank);
2063 if (res == ERR && change_scroll_region) {
2064 if ((((n == 1 && scroll_forward) || parm_index)
2065 && (SP_PARM->_cursrow == bot || SP_PARM->_cursrow == bot - 1))
2066 && save_cursor && restore_cursor) {
2067 cursor_saved = TRUE;
2068 NCURSES_PUTP2("save_cursor", save_cursor);
2070 NCURSES_PUTP2("change_scroll_region",
2071 TPARM_2(change_scroll_region, top, bot));
2073 NCURSES_PUTP2("restore_cursor", restore_cursor);
2075 SP_PARM->_cursrow = SP_PARM->_curscol = -1;
2078 res = scroll_csr_forward(NCURSES_SP_ARGx n, top, bot, top, bot, blank);
2080 NCURSES_PUTP2("change_scroll_region",
2081 TPARM_2(change_scroll_region, 0, maxy));
2082 SP_PARM->_cursrow = SP_PARM->_curscol = -1;
2085 if (res == ERR && SP_PARM->_nc_sp_idlok)
2086 res = scroll_idl(NCURSES_SP_ARGx n, top, bot - n + 1, blank);
2089 * Clear the newly shifted-in text.
2092 && (non_dest_scroll_region || (memory_below && bot == maxy))) {
2093 static const NCURSES_CH_T blank2 = NewChar(BLANK_TEXT);
2094 if (bot == maxy && clr_eos) {
2095 GoTo(NCURSES_SP_ARGx bot - n + 1, 0);
2096 ClrToEOS(NCURSES_SP_ARGx blank2);
2098 for (i = 0; i < n; i++) {
2099 GoTo(NCURSES_SP_ARGx bot - i, 0);
2100 ClrToEOL(NCURSES_SP_ARGx blank2, FALSE);
2105 } else { /* (n < 0) - scroll down (backward) */
2106 res = scroll_csr_backward(NCURSES_SP_ARGx -n, top, bot, 0, maxy, blank);
2108 if (res == ERR && change_scroll_region) {
2110 && (SP_PARM->_cursrow == top ||
2111 SP_PARM->_cursrow == top - 1)
2112 && save_cursor && restore_cursor) {
2113 cursor_saved = TRUE;
2114 NCURSES_PUTP2("save_cursor", save_cursor);
2116 NCURSES_PUTP2("change_scroll_region",
2117 TPARM_2(change_scroll_region, top, bot));
2119 NCURSES_PUTP2("restore_cursor", restore_cursor);
2121 SP_PARM->_cursrow = SP_PARM->_curscol = -1;
2124 res = scroll_csr_backward(NCURSES_SP_ARGx
2125 -n, top, bot, top, bot, blank);
2127 NCURSES_PUTP2("change_scroll_region",
2128 TPARM_2(change_scroll_region, 0, maxy));
2129 SP_PARM->_cursrow = SP_PARM->_curscol = -1;
2132 if (res == ERR && SP_PARM->_nc_sp_idlok)
2133 res = scroll_idl(NCURSES_SP_ARGx -n, bot + n + 1, top, blank);
2136 * Clear the newly shifted-in text.
2139 && (non_dest_scroll_region || (memory_above && top == 0))) {
2140 static const NCURSES_CH_T blank2 = NewChar(BLANK_TEXT);
2141 for (i = 0; i < -n; i++) {
2142 GoTo(NCURSES_SP_ARGx i + top, 0);
2143 ClrToEOL(NCURSES_SP_ARGx blank2, FALSE);
2151 _nc_scroll_window(CurScreen(SP_PARM), n,
2152 (NCURSES_SIZE_T) top,
2153 (NCURSES_SIZE_T) bot,
2156 /* shift hash values too - they can be reused */
2157 NCURSES_SP_NAME(_nc_scroll_oldhash) (NCURSES_SP_ARGx n, top, bot);
2162 #if NCURSES_SP_FUNCS
2164 _nc_scrolln(int n, int top, int bot, int maxy)
2166 return NCURSES_SP_NAME(_nc_scrolln) (CURRENT_SCREEN, n, top, bot, maxy);
2170 NCURSES_EXPORT(void)
2171 NCURSES_SP_NAME(_nc_screen_resume) (NCURSES_SP_DCL0)
2175 /* make sure terminal is in a sane known state */
2176 SetAttr(SCREEN_ATTRS(SP_PARM), A_NORMAL);
2177 NewScreen(SP_PARM)->_clear = TRUE;
2179 /* reset color pairs and definitions */
2180 if (SP_PARM->_coloron || SP_PARM->_color_defs)
2181 NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_ARG);
2183 /* restore user-defined colors, if any */
2184 if (SP_PARM->_color_defs < 0) {
2186 SP_PARM->_color_defs = -(SP_PARM->_color_defs);
2187 for (n = 0; n < SP_PARM->_color_defs; ++n) {
2188 if (SP_PARM->_color_table[n].init) {
2189 _nc_init_color(SP_PARM,
2191 SP_PARM->_color_table[n].r,
2192 SP_PARM->_color_table[n].g,
2193 SP_PARM->_color_table[n].b);
2198 if (exit_attribute_mode)
2199 NCURSES_PUTP2("exit_attribute_mode", exit_attribute_mode);
2201 /* turn off attributes */
2202 if (exit_alt_charset_mode)
2203 NCURSES_PUTP2("exit_alt_charset_mode", exit_alt_charset_mode);
2204 if (exit_standout_mode)
2205 NCURSES_PUTP2("exit_standout_mode", exit_standout_mode);
2206 if (exit_underline_mode)
2207 NCURSES_PUTP2("exit_underline_mode", exit_underline_mode);
2209 if (exit_insert_mode)
2210 NCURSES_PUTP2("exit_insert_mode", exit_insert_mode);
2211 if (enter_am_mode && exit_am_mode) {
2212 if (auto_right_margin) {
2213 NCURSES_PUTP2("enter_am_mode", enter_am_mode);
2215 NCURSES_PUTP2("exit_am_mode", exit_am_mode);
2220 #if NCURSES_SP_FUNCS
2221 NCURSES_EXPORT(void)
2222 _nc_screen_resume(void)
2224 NCURSES_SP_NAME(_nc_screen_resume) (CURRENT_SCREEN);
2228 NCURSES_EXPORT(void)
2229 NCURSES_SP_NAME(_nc_screen_init) (NCURSES_SP_DCL0)
2231 NCURSES_SP_NAME(_nc_screen_resume) (NCURSES_SP_ARG);
2234 #if NCURSES_SP_FUNCS
2235 NCURSES_EXPORT(void)
2236 _nc_screen_init(void)
2238 NCURSES_SP_NAME(_nc_screen_init) (CURRENT_SCREEN);
2242 /* wrap up screen handling */
2243 NCURSES_EXPORT(void)
2244 NCURSES_SP_NAME(_nc_screen_wrap) (NCURSES_SP_DCL0)
2248 UpdateAttrs(SP_PARM, normal);
2249 #if NCURSES_EXT_FUNCS
2250 if (SP_PARM->_coloron
2251 && !SP_PARM->_default_color) {
2252 static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
2253 SP_PARM->_default_color = TRUE;
2254 NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx
2258 NCURSES_SP_NAME(_nc_outch));
2259 SP_PARM->_default_color = FALSE;
2261 TINFO_MVCUR(NCURSES_SP_ARGx
2264 screen_lines(SP_PARM) - 1,
2267 ClrToEOL(NCURSES_SP_ARGx blank, TRUE);
2270 if (SP_PARM->_color_defs) {
2271 NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_ARG);
2276 #if NCURSES_SP_FUNCS
2277 NCURSES_EXPORT(void)
2278 _nc_screen_wrap(void)
2280 NCURSES_SP_NAME(_nc_screen_wrap) (CURRENT_SCREEN);
2285 NCURSES_EXPORT(void)
2286 NCURSES_SP_NAME(_nc_do_xmc_glitch) (NCURSES_SP_DCLx attr_t previous)
2289 attr_t chg = XMC_CHANGES(previous ^ AttrOf(SCREEN_ATTRS(SP_PARM)));
2293 SP_PARM->_curscol += magic_cookie_glitch;
2294 if (SP_PARM->_curscol >= SP_PARM->_columns)
2295 wrap_cursor(NCURSES_SP_ARG);
2296 TR(TRACE_UPDATE, ("bumped to %d,%d after cookie",
2297 SP_PARM->_cursrow, SP_PARM->_curscol));
2304 #if NCURSES_SP_FUNCS
2305 NCURSES_EXPORT(void)
2306 _nc_do_xmc_glitch(attr_t previous)
2308 NCURSES_SP_NAME(_nc_do_xmc_glitch) (CURRENT_SCREEN, previous);
2312 #endif /* USE_XMC_SUPPORT */