1 /****************************************************************************
2 * Copyright (c) 1998-2015,2016 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 #include <curses.priv.h>
49 #define CUR SP_TERMTYPE
52 #if defined __HAIKU__ && defined __BEOS__
62 #if defined(TRACE) && HAVE_SYS_TIMES_H && HAVE_TIMES
63 #define USE_TRACE_TIMES 1
65 #define USE_TRACE_TIMES 0
68 #if HAVE_SYS_TIME_H && HAVE_SYS_TIME_SELECT
73 #include <sys/times.h>
79 #include <sys/select.h>
85 MODULE_ID("$Id: tty_update.c,v 1.284 2016/10/15 23:00:29 tom Exp $")
88 * This define controls the line-breakout optimization. Every once in a
89 * while during screen refresh, we want to check for input and abort the
90 * update if there's some waiting. CHECK_INTERVAL controls the number of
91 * changed lines to be emitted between input checks.
93 * Note: Input-check-and-abort is no longer done if the screen is being
94 * updated from scratch. This is a feature, not a bug.
96 #define CHECK_INTERVAL 5
98 #define FILL_BCE(sp) (sp->_coloron && !sp->_default_color && !back_color_erase)
100 static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT);
101 static NCURSES_CH_T normal = NewChar(BLANK_TEXT);
104 * Enable checking to see if doupdate and friends are tracking the true
105 * cursor position correctly. NOTE: this is a debugging hack which will
106 * work ONLY on ANSI-compatible terminals!
108 /* #define POSITION_DEBUG */
110 static NCURSES_INLINE NCURSES_CH_T ClrBlank(NCURSES_SP_DCLx WINDOW *win);
113 static int ClrBottom(SCREEN *, int total);
114 static void ClearScreen(SCREEN *, NCURSES_CH_T blank);
115 static void ClrUpdate(SCREEN *);
116 static void DelChar(SCREEN *, int count);
117 static void InsStr(SCREEN *, NCURSES_CH_T * line, int count);
118 static void TransformLine(SCREEN *, int const lineno);
120 static int ClrBottom(int total);
121 static void ClearScreen(NCURSES_CH_T blank);
122 static void ClrUpdate(void);
123 static void DelChar(int count);
124 static void InsStr(NCURSES_CH_T * line, int count);
125 static void TransformLine(int const lineno);
128 #ifdef POSITION_DEBUG
129 /****************************************************************************
131 * Debugging code. Only works on ANSI-standard terminals.
133 ****************************************************************************/
136 position_check(NCURSES_SP_DCLx int expected_y, int expected_x, char *legend)
137 /* check to see if the real cursor position matches the virtual */
143 if (!_nc_tracing || (expected_y < 0 && expected_x < 0))
146 NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
147 memset(buf, '\0', sizeof(buf));
148 NCURSES_PUTP2_FLUSH("cpr", "\033[6n"); /* only works on ANSI-compatibles */
151 int ask = sizeof(buf) - 1 - (s - buf);
152 int got = read(0, s, ask);
156 } while (strchr(buf, 'R') == 0);
157 _tracef("probe returned %s", _nc_visbuf(buf));
159 /* try to interpret as a position report */
160 if (sscanf(buf, "\033[%d;%dR", &y, &x) != 2) {
161 _tracef("position probe failed in %s", legend);
167 if (y - 1 != expected_y || x - 1 != expected_x) {
168 NCURSES_SP_NAME(beep) (NCURSES_SP_ARG);
169 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
173 1, NCURSES_SP_NAME(_nc_outch));
174 _tracef("position seen (%d, %d) doesn't match expected one (%d, %d) in %s",
175 y - 1, x - 1, expected_y, expected_x, legend);
177 _tracef("position matches OK in %s", legend);
182 #define position_check(expected_y, expected_x, legend) /* nothing */
183 #endif /* POSITION_DEBUG */
185 /****************************************************************************
187 * Optimized update code
189 ****************************************************************************/
191 static NCURSES_INLINE void
192 GoTo(NCURSES_SP_DCLx int const row, int const col)
194 TR(TRACE_MOVE, ("GoTo(%p, %d, %d) from (%d, %d)",
195 (void *) SP_PARM, row, col, SP_PARM->_cursrow, SP_PARM->_curscol));
197 position_check(NCURSES_SP_ARGx
199 SP_PARM->_curscol, "GoTo");
201 TINFO_MVCUR(NCURSES_SP_ARGx
205 position_check(NCURSES_SP_ARGx
207 SP_PARM->_curscol, "GoTo2");
210 #if !NCURSES_WCWIDTH_GRAPHICS
212 is_wacs_value(unsigned ch)
216 case 0x00a3: /* FALLTHRU - ncurses pound-sterling symbol */
217 case 0x00b0: /* FALLTHRU - VT100 degree symbol */
218 case 0x00b1: /* FALLTHRU - VT100 plus/minus */
219 case 0x00b7: /* FALLTHRU - VT100 bullet */
220 case 0x03c0: /* FALLTHRU - ncurses greek pi */
221 case 0x2190: /* FALLTHRU - Teletype arrow pointing left */
222 case 0x2191: /* FALLTHRU - Teletype arrow pointing up */
223 case 0x2192: /* FALLTHRU - Teletype arrow pointing right */
224 case 0x2193: /* FALLTHRU - Teletype arrow pointing down */
225 case 0x2260: /* FALLTHRU - ncurses not-equal */
226 case 0x2264: /* FALLTHRU - ncurses less-than-or-equal-to */
227 case 0x2265: /* FALLTHRU - ncurses greater-than-or-equal-to */
228 case 0x23ba: /* FALLTHRU - VT100 scan line 1 */
229 case 0x23bb: /* FALLTHRU - ncurses scan line 3 */
230 case 0x23bc: /* FALLTHRU - ncurses scan line 7 */
231 case 0x23bd: /* FALLTHRU - VT100 scan line 9 */
232 case 0x2500: /* FALLTHRU - VT100 horizontal line */
233 case 0x2501: /* FALLTHRU - thick horizontal line */
234 case 0x2502: /* FALLTHRU - VT100 vertical line */
235 case 0x2503: /* FALLTHRU - thick vertical line */
236 case 0x250c: /* FALLTHRU - VT100 upper left corner */
237 case 0x250f: /* FALLTHRU - thick upper left corner */
238 case 0x2510: /* FALLTHRU - VT100 upper right corner */
239 case 0x2513: /* FALLTHRU - thick upper right corner */
240 case 0x2514: /* FALLTHRU - VT100 lower left corner */
241 case 0x2517: /* FALLTHRU - thick lower left corner */
242 case 0x2518: /* FALLTHRU - VT100 lower right corner */
243 case 0x251b: /* FALLTHRU - thick lower right corner */
244 case 0x251c: /* FALLTHRU - VT100 tee pointing left */
245 case 0x2523: /* FALLTHRU - thick tee pointing left */
246 case 0x2524: /* FALLTHRU - VT100 tee pointing right */
247 case 0x252b: /* FALLTHRU - thick tee pointing right */
248 case 0x252c: /* FALLTHRU - VT100 tee pointing down */
249 case 0x2533: /* FALLTHRU - thick tee pointing down */
250 case 0x2534: /* FALLTHRU - VT100 tee pointing up */
251 case 0x253b: /* FALLTHRU - thick tee pointing up */
252 case 0x253c: /* FALLTHRU - VT100 large plus or crossover */
253 case 0x254b: /* FALLTHRU - thick large plus or crossover */
254 case 0x2550: /* FALLTHRU - double horizontal line */
255 case 0x2551: /* FALLTHRU - double vertical line */
256 case 0x2554: /* FALLTHRU - double upper left corner */
257 case 0x2557: /* FALLTHRU - double upper right corner */
258 case 0x255a: /* FALLTHRU - double lower left corner */
259 case 0x255d: /* FALLTHRU - double lower right corner */
260 case 0x2560: /* FALLTHRU - double tee pointing right */
261 case 0x2563: /* FALLTHRU - double tee pointing left */
262 case 0x2566: /* FALLTHRU - double tee pointing down */
263 case 0x2569: /* FALLTHRU - double tee pointing up */
264 case 0x256c: /* FALLTHRU - double large plus or crossover */
265 case 0x2592: /* FALLTHRU - VT100 checker board (stipple) */
266 case 0x25ae: /* FALLTHRU - Teletype solid square block */
267 case 0x25c6: /* FALLTHRU - VT100 diamond */
268 case 0x2603: /* FALLTHRU - Teletype lantern symbol */
279 static NCURSES_INLINE void
280 PutAttrChar(NCURSES_SP_DCLx CARG_CH_T ch)
284 #if USE_WIDEC_SUPPORT
288 NCURSES_CH_T attr = CHDEREF(ch);
290 TR(TRACE_CHARPUT, ("PutAttrChar(%s) at (%d, %d)",
292 SP_PARM->_cursrow, SP_PARM->_curscol));
293 #if USE_WIDEC_SUPPORT
295 * If this is not a valid character, there is nothing more to do.
297 if (isWidecExt(CHDEREF(ch))) {
298 TR(TRACE_CHARPUT, ("...skip"));
302 * Determine the number of character cells which the 'ch' value will use
303 * on the screen. It should be at least one.
305 if ((chlen = wcwidth(CharOf(CHDEREF(ch)))) <= 0) {
306 static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
309 * If the character falls into any of these special cases, do
310 * not force the result to a blank:
312 * a) it is printable (this works around a bug in wcwidth()).
313 * b) use_legacy_coding() has been called to modify the treatment
315 * c) the acs_map[] has been initialized to allow codes 0-31
316 * to be rendered. This supports Linux console's "PC"
317 * characters. Codes 128-255 are allowed though this is
320 if (is8bits(CharOf(CHDEREF(ch)))
321 && (isprint(CharOf(CHDEREF(ch)))
322 || (SP_PARM->_legacy_coding > 0 && CharOf(CHDEREF(ch)) >= 160)
323 || (SP_PARM->_legacy_coding > 1 && CharOf(CHDEREF(ch)) >= 128)
324 || (AttrOf(attr) & A_ALTCHARSET
325 && ((CharOfD(ch) < ACS_LEN
326 && SP_PARM->_acs_map != 0
327 && SP_PARM->_acs_map[CharOfD(ch)] != 0)
328 || (CharOfD(ch) >= 128))))) {
332 TR(TRACE_CHARPUT, ("forced to blank"));
338 if ((AttrOf(attr) & A_ALTCHARSET)
339 && SP_PARM->_acs_map != 0
340 && ((CharOfD(ch) < ACS_LEN)
341 #if !NCURSES_WCWIDTH_GRAPHICS
342 || is_wacs_value(CharOfD(ch))
345 my_ch = CHDEREF(ch); /* work around const param */
346 #if USE_WIDEC_SUPPORT
348 * This is crude & ugly, but works most of the time. It checks if the
349 * acs_chars string specified that we have a mapping for this
350 * character, and uses the wide-character mapping when we expect the
351 * normal one to be broken (by mis-design ;-).
353 if (SP_PARM->_screen_unicode
354 && _nc_wacs[CharOf(my_ch)].chars[0]) {
355 if (SP_PARM->_screen_acs_map[CharOf(my_ch)]) {
356 if (SP_PARM->_screen_acs_fix) {
357 RemAttr(attr, A_ALTCHARSET);
358 my_ch = _nc_wacs[CharOf(my_ch)];
361 RemAttr(attr, A_ALTCHARSET);
362 my_ch = _nc_wacs[CharOf(my_ch)];
364 #if !NCURSES_WCWIDTH_GRAPHICS
365 if (!(AttrOf(attr) & A_ALTCHARSET)) {
368 #endif /* !NCURSES_WCWIDTH_GRAPHICS */
372 * If we (still) have alternate character set, it is the normal 8bit
373 * flavor. The _screen_acs_map[] array tells if the character was
374 * really in acs_chars, needed because of the way wide/normal line
375 * drawing flavors are integrated.
377 if (AttrOf(attr) & A_ALTCHARSET) {
379 chtype temp = UChar(SP_PARM->_acs_map[j]);
382 SetChar(my_ch, temp, AttrOf(attr));
385 RemAttr(attr, A_ALTCHARSET);
390 #if USE_WIDEC_SUPPORT && !NCURSES_WCWIDTH_GRAPHICS
391 else if (chlen > 1 && is_wacs_value(CharOfD(ch))) {
395 if (tilde_glitch && (CharOfD(ch) == L('~'))) {
396 SetChar(tilde, L('`'), AttrOf(attr));
400 UpdateAttrs(SP_PARM, attr);
402 #if !USE_WIDEC_SUPPORT
405 SP_PARM->_curscol += chlen;
407 NCURSES_PUTP2("char_padding", char_padding);
412 check_pending(NCURSES_SP_DCL0)
413 /* check for pending input */
415 bool have_pending = FALSE;
418 * Only carry out this check when the flag is zero, otherwise we'll
419 * have the refreshing slow down drastically (or stop) if there's an
420 * unread character available.
422 if (SP_PARM->_fifohold != 0)
425 if (SP_PARM->_checkfd >= 0) {
427 struct pollfd fds[1];
428 fds[0].fd = SP_PARM->_checkfd;
429 fds[0].events = POLLIN;
430 if (poll(fds, (size_t) 1, 0) > 0) {
433 #elif defined(__BEOS__)
435 * BeOS's select() is declared in socket.h, so the configure script does
436 * not see it. That's just as well, since that function works only for
437 * sockets. This (using snooze and ioctl) was distilled from Be's patch
438 * for ncurses which uses a separate thread to simulate select().
440 * FIXME: the return values from the ioctl aren't very clear if we get
444 int howmany = ioctl(0, 'ichr', &n);
445 if (howmany >= 0 && n > 0) {
450 struct timeval ktimeout;
453 ktimeout.tv_usec = 0;
456 FD_SET(SP_PARM->_checkfd, &fdset);
457 if (select(SP_PARM->_checkfd + 1, &fdset, NULL, NULL, &ktimeout) != 0) {
463 SP_PARM->_fifohold = 5;
464 NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
469 /* put char at lower right corner */
471 PutCharLR(NCURSES_SP_DCLx const ARG_CH_T ch)
473 if (!auto_right_margin) {
474 /* we can put the char directly */
475 PutAttrChar(NCURSES_SP_ARGx ch);
476 } else if (enter_am_mode && exit_am_mode) {
477 /* we can suppress automargin */
478 NCURSES_PUTP2("exit_am_mode", exit_am_mode);
480 PutAttrChar(NCURSES_SP_ARGx ch);
482 position_check(NCURSES_SP_ARGx
487 NCURSES_PUTP2("enter_am_mode", enter_am_mode);
488 } else if ((enter_insert_mode && exit_insert_mode)
489 || insert_character || parm_ich) {
491 screen_lines(SP_PARM) - 1,
492 screen_columns(SP_PARM) - 2);
493 PutAttrChar(NCURSES_SP_ARGx ch);
495 screen_lines(SP_PARM) - 1,
496 screen_columns(SP_PARM) - 2);
497 InsStr(NCURSES_SP_ARGx
498 NewScreen(SP_PARM)->_line[screen_lines(SP_PARM) - 1].text +
499 screen_columns(SP_PARM) - 2, 1);
504 * Wrap the cursor position, i.e., advance to the beginning of the next line.
507 wrap_cursor(NCURSES_SP_DCL0)
509 if (eat_newline_glitch) {
511 * xenl can manifest two different ways. The vt100 way is that, when
512 * you'd expect the cursor to wrap, it stays hung at the right margin
513 * (on top of the character just emitted) and doesn't wrap until the
514 * *next* graphic char is emitted. The c100 way is to ignore LF
515 * received just after an am wrap.
517 * An aggressive way to handle this would be to emit CR/LF after the
518 * char and then assume the wrap is done, you're on the first position
519 * of the next line, and the terminal out of its weird state. Here
520 * it's safe to just tell the code that the cursor is in hyperspace and
521 * let the next mvcur() call straighten things out.
523 SP_PARM->_curscol = -1;
524 SP_PARM->_cursrow = -1;
525 } else if (auto_right_margin) {
526 SP_PARM->_curscol = 0;
529 * We've actually moved - but may have to work around problems with
530 * video attributes not working.
532 if (!move_standout_mode && AttrOf(SCREEN_ATTRS(SP_PARM))) {
533 TR(TRACE_CHARPUT, ("turning off (%#lx) %s before wrapping",
534 (unsigned long) AttrOf(SCREEN_ATTRS(SP_PARM)),
535 _traceattr(AttrOf(SCREEN_ATTRS(SP_PARM)))));
536 (void) VIDATTR(SP_PARM, A_NORMAL, 0);
541 position_check(NCURSES_SP_ARGx
547 static NCURSES_INLINE void
548 PutChar(NCURSES_SP_DCLx const ARG_CH_T ch)
549 /* insert character, handling automargin stuff */
551 if (SP_PARM->_cursrow == screen_lines(SP_PARM) - 1 &&
552 SP_PARM->_curscol == screen_columns(SP_PARM) - 1) {
553 PutCharLR(NCURSES_SP_ARGx ch);
555 PutAttrChar(NCURSES_SP_ARGx ch);
558 if (SP_PARM->_curscol >= screen_columns(SP_PARM))
559 wrap_cursor(NCURSES_SP_ARG);
561 position_check(NCURSES_SP_ARGx
563 SP_PARM->_curscol, "PutChar");
567 * Check whether the given character can be output by clearing commands. This
568 * includes test for being a space and not including any 'bad' attributes, such
569 * as A_REVERSE. All attribute flags which don't affect appearance of a space
570 * or can be output by clearing (A_COLOR in case of bce-terminal) are excluded.
572 static NCURSES_INLINE bool
573 can_clear_with(NCURSES_SP_DCLx ARG_CH_T ch)
575 if (!back_color_erase && SP_PARM->_coloron) {
576 #if NCURSES_EXT_FUNCS
579 if (!SP_PARM->_default_color)
581 if (SP_PARM->_default_fg != C_MASK || SP_PARM->_default_bg != C_MASK)
583 if ((pair = GetPair(CHDEREF(ch))) != 0) {
584 NCURSES_COLOR_T fg, bg;
585 if (NCURSES_SP_NAME(pair_content) (NCURSES_SP_ARGx
588 || (fg != C_MASK || bg != C_MASK)) {
593 if (AttrOfD(ch) & A_COLOR)
597 return (ISBLANK(CHDEREF(ch)) &&
598 (AttrOfD(ch) & ~(NONBLANK_ATTR | A_COLOR)) == BLANK_ATTR);
602 * Issue a given span of characters from an array.
603 * Must be functionally equivalent to:
604 * for (i = 0; i < num; i++)
606 * but can leave the cursor positioned at the middle of the interval.
608 * Returns: 0 - cursor is at the end of interval
609 * 1 - cursor is somewhere in the middle
611 * This code is optimized using ech and rep.
614 EmitRange(NCURSES_SP_DCLx const NCURSES_CH_T * ntext, int num)
618 TR(TRACE_CHARPUT, ("EmitRange %d:%s", num, _nc_viscbuf(ntext, num)));
620 if (erase_chars || repeat_char) {
625 while (num > 1 && !CharEq(ntext[0], ntext[1])) {
626 PutChar(NCURSES_SP_ARGx CHREF(ntext[0]));
632 PutChar(NCURSES_SP_ARGx CHREF(ntext0));
637 while (runcount < num && CharEq(ntext[runcount], ntext0))
641 * The cost expression in the middle isn't exactly right.
642 * _cup_ch_cost is an upper bound on the cost for moving to the
643 * end of the erased area, but not the cost itself (which we
644 * can't compute without emitting the move). This may result
645 * in erase_chars not getting used in some situations for
646 * which it would be marginally advantageous.
649 && runcount > SP_PARM->_ech_cost + SP_PARM->_cup_ch_cost
650 && can_clear_with(NCURSES_SP_ARGx CHREF(ntext0))) {
651 UpdateAttrs(SP_PARM, ntext0);
652 NCURSES_PUTP2("erase_chars", TPARM_1(erase_chars, runcount));
655 * If this is the last part of the given interval,
656 * don't bother moving cursor, since it can be the
657 * last update on the line.
659 if (runcount < num) {
662 SP_PARM->_curscol + runcount);
664 return 1; /* cursor stays in the middle */
666 } else if (repeat_char && runcount > SP_PARM->_rep_cost) {
667 bool wrap_possible = (SP_PARM->_curscol + runcount >=
668 screen_columns(SP_PARM));
669 int rep_count = runcount;
674 UpdateAttrs(SP_PARM, ntext0);
675 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
680 NCURSES_SP_NAME(_nc_outch));
681 SP_PARM->_curscol += rep_count;
684 PutChar(NCURSES_SP_ARGx CHREF(ntext0));
686 for (i = 0; i < runcount; i++)
687 PutChar(NCURSES_SP_ARGx CHREF(ntext[i]));
695 for (i = 0; i < num; i++)
696 PutChar(NCURSES_SP_ARGx CHREF(ntext[i]));
701 * Output the line in the given range [first .. last]
703 * If there's a run of identical characters that's long enough to justify
704 * cursor movement, use that also.
706 * Returns: same as EmitRange
709 PutRange(NCURSES_SP_DCLx
710 const NCURSES_CH_T * otext,
711 const NCURSES_CH_T * ntext,
717 TR(TRACE_CHARPUT, ("PutRange(%p, %p, %p, %d, %d, %d)",
719 (const void *) otext,
720 (const void *) ntext,
724 && (last - first + 1) > SP_PARM->_inline_cost) {
727 for (j = first, same = 0; j <= last; j++) {
728 if (!same && isWidecExt(otext[j]))
730 if (CharEq(otext[j], ntext[j])) {
733 if (same > SP_PARM->_inline_cost) {
734 EmitRange(NCURSES_SP_ARGx ntext + first, j - same - first);
735 GoTo(NCURSES_SP_ARGx row, first = j);
740 i = EmitRange(NCURSES_SP_ARGx ntext + first, j - same - first);
742 * Always return 1 for the next GoTo() after a PutRange() if we found
743 * identical characters at end of interval
745 rc = (same == 0 ? i : 1);
747 rc = EmitRange(NCURSES_SP_ARGx ntext + first, last - first + 1);
752 /* leave unbracketed here so 'indent' works */
753 #define MARK_NOCHANGE(win,row) \
754 win->_line[row].firstchar = _NOCHANGE; \
755 win->_line[row].lastchar = _NOCHANGE; \
756 if_USE_SCROLL_HINTS(win->_line[row].oldindex = row)
759 TINFO_DOUPDATE(NCURSES_SP_DCL0)
764 struct tms before, after;
765 #endif /* USE_TRACE_TIMES */
767 T((T_CALLED("_nc_tinfo:doupdate(%p)"), (void *) SP_PARM));
774 * It is "legal" but unlikely that an application could assign a new
775 * value to one of the standard windows. Check for that possibility
776 * and try to recover.
778 * We do not allow applications to assign new values in the reentrant
781 #define SyncScreens(internal,exported) \
782 if (internal == 0) internal = exported; \
783 if (internal != exported) exported = internal
785 SyncScreens(CurScreen(SP_PARM), curscr);
786 SyncScreens(NewScreen(SP_PARM), newscr);
787 SyncScreens(StdScreen(SP_PARM), stdscr);
790 if (CurScreen(SP_PARM) == 0
791 || NewScreen(SP_PARM) == 0
792 || StdScreen(SP_PARM) == 0)
796 if (USE_TRACEF(TRACE_UPDATE)) {
797 if (CurScreen(SP_PARM)->_clear)
798 _tracef("curscr is clear");
800 _tracedump("curscr", CurScreen(SP_PARM));
801 _tracedump("newscr", NewScreen(SP_PARM));
802 _nc_unlock_global(tracef);
806 _nc_signal_handler(FALSE);
808 if (SP_PARM->_fifohold)
809 SP_PARM->_fifohold--;
812 if (SP_PARM->_endwin || _nc_handle_sigwinch(SP_PARM)) {
814 * This is a transparent extension: XSI does not address it,
815 * and applications need not know that ncurses can do it.
817 * Check if the terminal size has changed while curses was off
818 * (this can happen in an xterm, for example), and resize the
819 * ncurses data structures accordingly.
821 _nc_update_screensize(SP_PARM);
825 if (SP_PARM->_endwin) {
827 T(("coming back from shell mode"));
828 NCURSES_SP_NAME(reset_prog_mode) (NCURSES_SP_ARG);
830 NCURSES_SP_NAME(_nc_mvcur_resume) (NCURSES_SP_ARG);
831 NCURSES_SP_NAME(_nc_screen_resume) (NCURSES_SP_ARG);
832 SP_PARM->_mouse_resume(SP_PARM);
834 SP_PARM->_endwin = FALSE;
837 /* zero the metering machinery */
839 (void) times(&before);
840 #endif /* USE_TRACE_TIMES */
843 * This is the support for magic-cookie terminals. The theory: we scan
844 * the virtual screen looking for attribute turnons. Where we find one,
845 * check to make sure it's realizable by seeing if the required number of
846 * un-attributed blanks are present before and after the attributed range;
847 * try to shift the range boundaries over blanks (not changing the screen
848 * display) so this becomes true. If it is, shift the beginning attribute
849 * change appropriately (the end one, if we've gotten this far, is
850 * guaranteed room for its cookie). If not, nuke the added attributes out
854 if (magic_cookie_glitch > 0) {
856 attr_t rattr = A_NORMAL;
858 for (i = 0; i < screen_lines(SP_PARM); i++) {
859 for (j = 0; j < screen_columns(SP_PARM); j++) {
861 NCURSES_CH_T *thisline = NewScreen(SP_PARM)->_line[i].text;
862 attr_t thisattr = AttrOf(thisline[j]) & SP_PARM->_xmc_triggers;
863 attr_t turnon = thisattr & ~rattr;
865 /* is an attribute turned on here? */
871 TR(TRACE_ATTRS, ("At (%d, %d): from %s...", i, j, _traceattr(rattr)));
872 TR(TRACE_ATTRS, ("...to %s", _traceattr(turnon)));
875 * If the attribute change location is a blank with a "safe"
876 * attribute, undo the attribute turnon. This may ensure
877 * there's enough room to set the attribute before the first
878 * non-blank in the run.
880 #define SAFE(scr,a) (!((a) & (scr)->_xmc_triggers))
881 if (ISBLANK(thisline[j]) && SAFE(SP_PARM, turnon)) {
882 RemAttr(thisline[j], turnon);
886 /* check that there's enough room at start of span */
887 for (k = 1; k <= magic_cookie_glitch; k++) {
889 || !ISBLANK(thisline[j - k])
890 || !SAFE(SP_PARM, AttrOf(thisline[j - k]))) {
892 TR(TRACE_ATTRS, ("No room at start in %d,%d%s%s",
894 (ISBLANK(thisline[j - k])
897 (SAFE(SP_PARM, AttrOf(thisline[j - k]))
904 bool end_onscreen = FALSE;
907 /* find end of span, if it's onscreen */
908 for (m = i; m < screen_lines(SP_PARM); m++) {
909 for (; n < screen_columns(SP_PARM); n++) {
911 AttrOf(NewScreen(SP_PARM)->_line[m].text[n]);
912 if ((testattr & SP_PARM->_xmc_triggers) == rattr) {
915 ("Range attributed with %s ends at (%d, %d)",
916 _traceattr(turnon), m, n));
923 ("Range attributed with %s ends offscreen",
924 _traceattr(turnon)));
928 NCURSES_CH_T *lastline =
929 NewScreen(SP_PARM)->_line[m].text;
932 * If there are safely-attributed blanks at the end of
933 * the range, shorten the range. This will help ensure
934 * that there is enough room at end of span.
937 && ISBLANK(lastline[n])
938 && SAFE(SP_PARM, AttrOf(lastline[n]))) {
939 RemAttr(lastline[n--], turnon);
942 /* check that there's enough room at end of span */
943 for (k = 1; k <= magic_cookie_glitch; k++) {
944 if (n + k >= screen_columns(SP_PARM)
945 || !ISBLANK(lastline[n + k])
946 || !SAFE(SP_PARM, AttrOf(lastline[n + k]))) {
949 ("No room at end in %d,%d%s%s",
951 (ISBLANK(lastline[n + k])
954 (SAFE(SP_PARM, AttrOf(lastline[n + k]))
967 ("Clearing %s beginning at (%d, %d)",
968 _traceattr(turnon), i, j));
970 /* turn off new attributes over span */
971 for (p = i; p < screen_lines(SP_PARM); p++) {
972 for (; q < screen_columns(SP_PARM); q++) {
973 attr_t testattr = AttrOf(newscr->_line[p].text[q]);
974 if ((testattr & SP_PARM->_xmc_triggers) == rattr)
976 RemAttr(NewScreen(SP_PARM)->_line[p].text[q], turnon);
983 ("Cookie space for %s found before (%d, %d)",
984 _traceattr(turnon), i, j));
987 * Back up the start of range so there's room for cookies
988 * before the first nonblank character.
990 for (k = 1; k <= magic_cookie_glitch; k++)
991 AddAttr(thisline[j - k], turnon);
999 /* show altered highlights after magic-cookie check */
1000 if (USE_TRACEF(TRACE_UPDATE)) {
1001 _tracef("After magic-cookie check...");
1002 _tracedump("newscr", NewScreen(SP_PARM));
1003 _nc_unlock_global(tracef);
1007 #endif /* USE_XMC_SUPPORT */
1010 if (CurScreen(SP_PARM)->_clear || NewScreen(SP_PARM)->_clear) { /* force refresh ? */
1011 ClrUpdate(NCURSES_SP_ARG);
1012 CurScreen(SP_PARM)->_clear = FALSE; /* reset flag */
1013 NewScreen(SP_PARM)->_clear = FALSE; /* reset flag */
1015 int changedlines = CHECK_INTERVAL;
1017 if (check_pending(NCURSES_SP_ARG))
1020 nonempty = min(screen_lines(SP_PARM), NewScreen(SP_PARM)->_maxy + 1);
1022 if (SP_PARM->_scrolling) {
1023 NCURSES_SP_NAME(_nc_scroll_optimize) (NCURSES_SP_ARG);
1026 nonempty = ClrBottom(NCURSES_SP_ARGx nonempty);
1028 TR(TRACE_UPDATE, ("Transforming lines, nonempty %d", nonempty));
1029 for (i = 0; i < nonempty; i++) {
1031 * Here is our line-breakout optimization.
1033 if (changedlines == CHECK_INTERVAL) {
1034 if (check_pending(NCURSES_SP_ARG))
1040 * newscr->line[i].firstchar is normally set
1041 * by wnoutrefresh. curscr->line[i].firstchar
1042 * is normally set by _nc_scroll_window in the
1043 * vertical-movement optimization code,
1045 if (NewScreen(SP_PARM)->_line[i].firstchar != _NOCHANGE
1046 || CurScreen(SP_PARM)->_line[i].firstchar != _NOCHANGE) {
1047 TransformLine(NCURSES_SP_ARGx i);
1051 /* mark line changed successfully */
1052 if (i <= NewScreen(SP_PARM)->_maxy) {
1053 MARK_NOCHANGE(NewScreen(SP_PARM), i);
1055 if (i <= CurScreen(SP_PARM)->_maxy) {
1056 MARK_NOCHANGE(CurScreen(SP_PARM), i);
1061 /* put everything back in sync */
1062 for (i = nonempty; i <= NewScreen(SP_PARM)->_maxy; i++) {
1063 MARK_NOCHANGE(NewScreen(SP_PARM), i);
1065 for (i = nonempty; i <= CurScreen(SP_PARM)->_maxy; i++) {
1066 MARK_NOCHANGE(CurScreen(SP_PARM), i);
1069 if (!NewScreen(SP_PARM)->_leaveok) {
1070 CurScreen(SP_PARM)->_curx = NewScreen(SP_PARM)->_curx;
1071 CurScreen(SP_PARM)->_cury = NewScreen(SP_PARM)->_cury;
1073 GoTo(NCURSES_SP_ARGx CurScreen(SP_PARM)->_cury, CurScreen(SP_PARM)->_curx);
1078 * We would like to keep the physical screen in normal mode in case we get
1079 * other processes writing to the screen. This goal cannot be met for
1080 * magic cookies since it interferes with attributes that may propagate
1081 * past the current position.
1084 if (magic_cookie_glitch != 0)
1086 UpdateAttrs(SP_PARM, normal);
1088 NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
1089 WINDOW_ATTRS(CurScreen(SP_PARM)) = WINDOW_ATTRS(NewScreen(SP_PARM));
1092 (void) times(&after);
1094 ("Update cost: %ld chars, %ld clocks system time, %ld clocks user time",
1096 (long) (after.tms_stime - before.tms_stime),
1097 (long) (after.tms_utime - before.tms_utime)));
1098 #endif /* USE_TRACE_TIMES */
1100 _nc_signal_handler(TRUE);
1105 #if NCURSES_SP_FUNCS && !defined(USE_TERM_DRIVER)
1109 return TINFO_DOUPDATE(CURRENT_SCREEN);
1116 * Returns the attributed character that corresponds to the "cleared"
1117 * screen. If the terminal has the back-color-erase feature, this will be
1118 * colored according to the wbkgd() call.
1120 * We treat 'curscr' specially because it isn't supposed to be set directly
1121 * in the wbkgd() call. Assume 'stdscr' for this case.
1123 #define BCE_ATTRS (A_NORMAL|A_COLOR)
1124 #define BCE_BKGD(sp,win) (((win) == CurScreen(sp) ? StdScreen(sp) : (win))->_nc_bkgd)
1126 static NCURSES_INLINE NCURSES_CH_T
1127 ClrBlank(NCURSES_SP_DCLx WINDOW *win)
1129 NCURSES_CH_T blank = blankchar;
1130 if (back_color_erase)
1131 AddAttr(blank, (AttrOf(BCE_BKGD(SP_PARM, win)) & BCE_ATTRS));
1138 ** Update by clearing and redrawing the entire screen.
1143 ClrUpdate(NCURSES_SP_DCL0)
1145 TR(TRACE_UPDATE, (T_CALLED("ClrUpdate")));
1148 NCURSES_CH_T blank = ClrBlank(NCURSES_SP_ARGx StdScreen(SP_PARM));
1149 int nonempty = min(screen_lines(SP_PARM),
1150 NewScreen(SP_PARM)->_maxy + 1);
1152 ClearScreen(NCURSES_SP_ARGx blank);
1154 TR(TRACE_UPDATE, ("updating screen from scratch"));
1156 nonempty = ClrBottom(NCURSES_SP_ARGx nonempty);
1158 for (i = 0; i < nonempty; i++)
1159 TransformLine(NCURSES_SP_ARGx i);
1161 TR(TRACE_UPDATE, (T_RETURN("")));
1167 ** Clear to end of current line, starting at the cursor position
1171 ClrToEOL(NCURSES_SP_DCLx NCURSES_CH_T blank, int needclear)
1173 if (CurScreen(SP_PARM) != 0
1174 && SP_PARM->_cursrow >= 0) {
1177 for (j = SP_PARM->_curscol; j < screen_columns(SP_PARM); j++) {
1180 &(CurScreen(SP_PARM)->_line[SP_PARM->_cursrow].text[j]);
1182 if (!CharEq(*cp, blank)) {
1191 UpdateAttrs(SP_PARM, blank);
1192 if (clr_eol && SP_PARM->_el_cost <= (screen_columns(SP_PARM) - SP_PARM->_curscol)) {
1193 NCURSES_PUTP2("clr_eol", clr_eol);
1195 int count = (screen_columns(SP_PARM) - SP_PARM->_curscol);
1197 PutChar(NCURSES_SP_ARGx CHREF(blank));
1205 ** Clear to end of screen, starting at the cursor position
1209 ClrToEOS(NCURSES_SP_DCLx NCURSES_CH_T blank)
1213 row = SP_PARM->_cursrow;
1214 col = SP_PARM->_curscol;
1221 UpdateAttrs(SP_PARM, blank);
1222 TPUTS_TRACE("clr_eos");
1223 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1225 screen_lines(SP_PARM) - row,
1226 NCURSES_SP_NAME(_nc_outch));
1228 while (col < screen_columns(SP_PARM))
1229 CurScreen(SP_PARM)->_line[row].text[col++] = blank;
1231 for (row++; row < screen_lines(SP_PARM); row++) {
1232 for (col = 0; col < screen_columns(SP_PARM); col++)
1233 CurScreen(SP_PARM)->_line[row].text[col] = blank;
1240 * Test if clearing the end of the screen would satisfy part of the
1241 * screen-update. Do this by scanning backwards through the lines in the
1242 * screen, checking if each is blank, and one or more are changed.
1245 ClrBottom(NCURSES_SP_DCLx int total)
1248 int last = min(screen_columns(SP_PARM), NewScreen(SP_PARM)->_maxx + 1);
1249 NCURSES_CH_T blank = NewScreen(SP_PARM)->_line[total - 1].text[last - 1];
1251 if (clr_eos && can_clear_with(NCURSES_SP_ARGx CHREF(blank))) {
1254 for (row = total - 1; row >= 0; row--) {
1258 for (col = 0, ok = TRUE; ok && col < last; col++) {
1259 ok = (CharEq(NewScreen(SP_PARM)->_line[row].text[col], blank));
1264 for (col = 0; ok && col < last; col++) {
1265 ok = (CharEq(CurScreen(SP_PARM)->_line[row].text[col], blank));
1271 /* don't use clr_eos for just one line if clr_eol available */
1273 GoTo(NCURSES_SP_ARGx top, 0);
1274 ClrToEOS(NCURSES_SP_ARGx blank);
1275 if (SP_PARM->oldhash && SP_PARM->newhash) {
1276 for (row = top; row < screen_lines(SP_PARM); row++)
1277 SP_PARM->oldhash[row] = SP_PARM->newhash[row];
1285 #if USE_WIDEC_SUPPORT
1286 #define check_xmc_transition(sp, a, b) \
1287 ((((a)->attr ^ (b)->attr) & ~((a)->attr) & (sp)->_xmc_triggers) != 0)
1288 #define xmc_turn_on(sp,a,b) check_xmc_transition(sp,&(a), &(b))
1290 #define xmc_turn_on(sp,a,b) ((((a)^(b)) & ~(a) & (sp)->_xmc_triggers) != 0)
1293 #define xmc_new(sp,r,c) NewScreen(sp)->_line[r].text[c]
1294 #define xmc_turn_off(sp,a,b) xmc_turn_on(sp,b,a)
1295 #endif /* USE_XMC_SUPPORT */
1298 ** TransformLine(lineno)
1300 ** Transform the given line in curscr to the one in newscr, using
1301 ** Insert/Delete Character if idcok && has_ic().
1303 ** firstChar = position of first different character in line
1304 ** oLastChar = position of last different character in old line
1305 ** nLastChar = position of last different character in new line
1307 ** move to firstChar
1308 ** overwrite chars up to min(oLastChar, nLastChar)
1309 ** if oLastChar < nLastChar
1310 ** insert newLine[oLastChar+1..nLastChar]
1312 ** delete oLastChar - nLastChar spaces
1316 TransformLine(NCURSES_SP_DCLx int const lineno)
1318 int firstChar, oLastChar, nLastChar;
1319 NCURSES_CH_T *newLine = NewScreen(SP_PARM)->_line[lineno].text;
1320 NCURSES_CH_T *oldLine = CurScreen(SP_PARM)->_line[lineno].text;
1322 bool attrchanged = FALSE;
1324 TR(TRACE_UPDATE, (T_CALLED("TransformLine(%p, %d)"), (void *) SP_PARM, lineno));
1326 /* copy new hash value to old one */
1327 if (SP_PARM->oldhash && SP_PARM->newhash)
1328 SP_PARM->oldhash[lineno] = SP_PARM->newhash[lineno];
1331 * If we have colors, there is the possibility of having two color pairs
1332 * that display as the same colors. For instance, Lynx does this. Check
1333 * for this case, and update the old line with the new line's colors when
1334 * they are equivalent.
1336 if (SP_PARM->_coloron) {
1340 for (n = 0; n < screen_columns(SP_PARM); n++) {
1341 if (!CharEq(newLine[n], oldLine[n])) {
1342 oldPair = GetPair(oldLine[n]);
1343 newPair = GetPair(newLine[n]);
1344 if (oldPair != newPair
1345 && unColor(oldLine[n]) == unColor(newLine[n])) {
1346 if (oldPair < SP_PARM->_pair_limit
1347 && newPair < SP_PARM->_pair_limit
1348 && (SP_PARM->_color_pairs[oldPair] ==
1349 SP_PARM->_color_pairs[newPair])) {
1350 SetPair(oldLine[n], GetPair(newLine[n]));
1357 if (ceol_standout_glitch && clr_eol) {
1359 while (firstChar < screen_columns(SP_PARM)) {
1360 if (!SameAttrOf(newLine[firstChar], oldLine[firstChar])) {
1370 if (attrchanged) { /* we may have to disregard the whole line */
1371 GoTo(NCURSES_SP_ARGx lineno, firstChar);
1372 ClrToEOL(NCURSES_SP_ARGx
1373 ClrBlank(NCURSES_SP_ARGx
1374 CurScreen(SP_PARM)), FALSE);
1375 PutRange(NCURSES_SP_ARGx
1376 oldLine, newLine, lineno, 0,
1377 screen_columns(SP_PARM) - 1);
1381 * This is a very simple loop to paint characters which may have the
1382 * magic cookie glitch embedded. It doesn't know much about video
1383 * attributes which are continued from one line to the next. It
1384 * assumes that we have filtered out requests for attribute changes
1385 * that do not get mapped to blank positions.
1387 * FIXME: we are not keeping track of where we put the cookies, so this
1388 * will work properly only once, since we may overwrite a cookie in a
1389 * following operation.
1391 } else if (magic_cookie_glitch > 0) {
1392 GoTo(NCURSES_SP_ARGx lineno, firstChar);
1393 for (n = 0; n < screen_columns(SP_PARM); n++) {
1394 int m = n + magic_cookie_glitch;
1396 /* check for turn-on:
1397 * If we are writing an attributed blank, where the
1398 * previous cell is not attributed.
1400 if (ISBLANK(newLine[n])
1402 && xmc_turn_on(SP_PARM, newLine[n - 1], newLine[n]))
1405 && xmc_turn_on(SP_PARM,
1406 xmc_new(SP_PARM, lineno - 1,
1407 screen_columns(SP_PARM) - 1),
1412 PutChar(NCURSES_SP_ARGx CHREF(newLine[n]));
1414 /* check for turn-off:
1415 * If we are writing an attributed non-blank, where the
1416 * next cell is blank, and not attributed.
1418 if (!ISBLANK(newLine[n])
1419 && ((n + 1 < screen_columns(SP_PARM)
1420 && xmc_turn_off(SP_PARM, newLine[n], newLine[n + 1]))
1421 || (n + 1 >= screen_columns(SP_PARM)
1422 && lineno + 1 < screen_lines(SP_PARM)
1423 && xmc_turn_off(SP_PARM,
1425 xmc_new(SP_PARM, lineno + 1, 0))))) {
1434 /* it may be cheap to clear leading whitespace with clr_bol */
1436 if (clr_bol && can_clear_with(NCURSES_SP_ARGx CHREF(blank))) {
1437 int oFirstChar, nFirstChar;
1439 for (oFirstChar = 0;
1440 oFirstChar < screen_columns(SP_PARM);
1442 if (!CharEq(oldLine[oFirstChar], blank))
1444 for (nFirstChar = 0;
1445 nFirstChar < screen_columns(SP_PARM);
1447 if (!CharEq(newLine[nFirstChar], blank))
1450 if (nFirstChar == oFirstChar) {
1451 firstChar = nFirstChar;
1452 /* find the first differing character */
1453 while (firstChar < screen_columns(SP_PARM)
1454 && CharEq(newLine[firstChar], oldLine[firstChar]))
1456 } else if (oFirstChar > nFirstChar) {
1457 firstChar = nFirstChar;
1458 } else { /* oFirstChar < nFirstChar */
1459 firstChar = oFirstChar;
1460 if (SP_PARM->_el1_cost < nFirstChar - oFirstChar) {
1461 if (nFirstChar >= screen_columns(SP_PARM)
1462 && SP_PARM->_el_cost <= SP_PARM->_el1_cost) {
1463 GoTo(NCURSES_SP_ARGx lineno, 0);
1464 UpdateAttrs(SP_PARM, blank);
1465 NCURSES_PUTP2("clr_eol", clr_eol);
1467 GoTo(NCURSES_SP_ARGx lineno, nFirstChar - 1);
1468 UpdateAttrs(SP_PARM, blank);
1469 NCURSES_PUTP2("clr_bol", clr_bol);
1472 while (firstChar < nFirstChar)
1473 oldLine[firstChar++] = blank;
1477 /* find the first differing character */
1478 while (firstChar < screen_columns(SP_PARM)
1479 && CharEq(newLine[firstChar], oldLine[firstChar]))
1482 /* if there wasn't one, we're done */
1483 if (firstChar >= screen_columns(SP_PARM)) {
1484 TR(TRACE_UPDATE, (T_RETURN("")));
1488 blank = newLine[screen_columns(SP_PARM) - 1];
1490 if (!can_clear_with(NCURSES_SP_ARGx CHREF(blank))) {
1491 /* find the last differing character */
1492 nLastChar = screen_columns(SP_PARM) - 1;
1494 while (nLastChar > firstChar
1495 && CharEq(newLine[nLastChar], oldLine[nLastChar]))
1498 if (nLastChar >= firstChar) {
1499 GoTo(NCURSES_SP_ARGx lineno, firstChar);
1500 PutRange(NCURSES_SP_ARGx
1506 memcpy(oldLine + firstChar,
1507 newLine + firstChar,
1508 (unsigned) (nLastChar - firstChar + 1) * sizeof(NCURSES_CH_T));
1510 TR(TRACE_UPDATE, (T_RETURN("")));
1514 /* find last non-blank character on old line */
1515 oLastChar = screen_columns(SP_PARM) - 1;
1516 while (oLastChar > firstChar && CharEq(oldLine[oLastChar], blank))
1519 /* find last non-blank character on new line */
1520 nLastChar = screen_columns(SP_PARM) - 1;
1521 while (nLastChar > firstChar && CharEq(newLine[nLastChar], blank))
1524 if ((nLastChar == firstChar)
1525 && (SP_PARM->_el_cost < (oLastChar - nLastChar))) {
1526 GoTo(NCURSES_SP_ARGx lineno, firstChar);
1527 if (!CharEq(newLine[firstChar], blank))
1528 PutChar(NCURSES_SP_ARGx CHREF(newLine[firstChar]));
1529 ClrToEOL(NCURSES_SP_ARGx blank, FALSE);
1530 } else if ((nLastChar != oLastChar)
1531 && (!CharEq(newLine[nLastChar], oldLine[oLastChar])
1532 || !(SP_PARM->_nc_sp_idcok
1533 && NCURSES_SP_NAME(has_ic) (NCURSES_SP_ARG)))) {
1534 GoTo(NCURSES_SP_ARGx lineno, firstChar);
1535 if ((oLastChar - nLastChar) > SP_PARM->_el_cost) {
1536 if (PutRange(NCURSES_SP_ARGx
1542 GoTo(NCURSES_SP_ARGx lineno, nLastChar + 1);
1544 ClrToEOL(NCURSES_SP_ARGx blank, FALSE);
1546 n = max(nLastChar, oLastChar);
1547 PutRange(NCURSES_SP_ARGx
1555 int nLastNonblank = nLastChar;
1556 int oLastNonblank = oLastChar;
1558 /* find the last characters that really differ */
1559 /* can be -1 if no characters differ */
1560 while (CharEq(newLine[nLastChar], oldLine[oLastChar])) {
1561 /* don't split a wide char */
1562 if (isWidecExt(newLine[nLastChar]) &&
1563 !CharEq(newLine[nLastChar - 1], oldLine[oLastChar - 1]))
1567 if (nLastChar == -1 || oLastChar == -1)
1571 n = min(oLastChar, nLastChar);
1572 if (n >= firstChar) {
1573 GoTo(NCURSES_SP_ARGx lineno, firstChar);
1574 PutRange(NCURSES_SP_ARGx
1582 if (oLastChar < nLastChar) {
1583 int m = max(nLastNonblank, oLastNonblank);
1584 #if USE_WIDEC_SUPPORT
1586 while (isWidecExt(newLine[n + 1]) && n) {
1588 --oLastChar; /* increase cost */
1590 } else if (n >= firstChar &&
1591 isWidecBase(newLine[n])) {
1592 while (isWidecExt(newLine[n + 1])) {
1594 ++oLastChar; /* decrease cost */
1598 GoTo(NCURSES_SP_ARGx lineno, n + 1);
1599 if ((nLastChar < nLastNonblank)
1600 || InsCharCost(SP_PARM, nLastChar - oLastChar) > (m - n)) {
1601 PutRange(NCURSES_SP_ARGx
1608 InsStr(NCURSES_SP_ARGx &newLine[n + 1], nLastChar - oLastChar);
1610 } else if (oLastChar > nLastChar) {
1611 GoTo(NCURSES_SP_ARGx lineno, n + 1);
1612 if (DelCharCost(SP_PARM, oLastChar - nLastChar)
1613 > SP_PARM->_el_cost + nLastNonblank - (n + 1)) {
1614 if (PutRange(NCURSES_SP_ARGx oldLine, newLine, lineno,
1615 n + 1, nLastNonblank)) {
1616 GoTo(NCURSES_SP_ARGx lineno, nLastNonblank + 1);
1618 ClrToEOL(NCURSES_SP_ARGx blank, FALSE);
1621 * The delete-char sequence will
1622 * effectively shift in blanks from the
1623 * right margin of the screen. Ensure
1624 * that they are the right color by
1625 * setting the video attributes from
1626 * the last character on the row.
1628 UpdateAttrs(SP_PARM, blank);
1629 DelChar(NCURSES_SP_ARGx oLastChar - nLastChar);
1635 /* update the code's internal representation */
1636 if (screen_columns(SP_PARM) > firstChar)
1637 memcpy(oldLine + firstChar,
1638 newLine + firstChar,
1639 (unsigned) (screen_columns(SP_PARM) - firstChar) * sizeof(NCURSES_CH_T));
1640 TR(TRACE_UPDATE, (T_RETURN("")));
1645 ** ClearScreen(blank)
1647 ** Clear the physical screen and put cursor at home
1652 ClearScreen(NCURSES_SP_DCLx NCURSES_CH_T blank)
1655 bool fast_clear = (clear_screen || clr_eos || clr_eol);
1657 TR(TRACE_UPDATE, ("ClearScreen() called"));
1659 #if NCURSES_EXT_FUNCS
1660 if (SP_PARM->_coloron
1661 && !SP_PARM->_default_color) {
1662 NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx
1663 (short) GET_SCREEN_PAIR(SP_PARM),
1666 NCURSES_SP_NAME(_nc_outch));
1667 if (!back_color_erase) {
1675 UpdateAttrs(SP_PARM, blank);
1676 NCURSES_PUTP2("clear_screen", clear_screen);
1677 SP_PARM->_cursrow = SP_PARM->_curscol = 0;
1678 position_check(NCURSES_SP_ARGx
1682 } else if (clr_eos) {
1683 SP_PARM->_cursrow = SP_PARM->_curscol = -1;
1684 GoTo(NCURSES_SP_ARGx 0, 0);
1685 UpdateAttrs(SP_PARM, blank);
1686 TPUTS_TRACE("clr_eos");
1687 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1689 screen_lines(SP_PARM),
1690 NCURSES_SP_NAME(_nc_outch));
1691 } else if (clr_eol) {
1692 SP_PARM->_cursrow = SP_PARM->_curscol = -1;
1693 UpdateAttrs(SP_PARM, blank);
1694 for (i = 0; i < screen_lines(SP_PARM); i++) {
1695 GoTo(NCURSES_SP_ARGx i, 0);
1696 NCURSES_PUTP2("clr_eol", clr_eol);
1698 GoTo(NCURSES_SP_ARGx 0, 0);
1701 UpdateAttrs(SP_PARM, blank);
1702 for (i = 0; i < screen_lines(SP_PARM); i++) {
1703 GoTo(NCURSES_SP_ARGx i, 0);
1704 for (j = 0; j < screen_columns(SP_PARM); j++)
1705 PutChar(NCURSES_SP_ARGx CHREF(blank));
1707 GoTo(NCURSES_SP_ARGx 0, 0);
1710 for (i = 0; i < screen_lines(SP_PARM); i++) {
1711 for (j = 0; j < screen_columns(SP_PARM); j++)
1712 CurScreen(SP_PARM)->_line[i].text[j] = blank;
1715 TR(TRACE_UPDATE, ("screen cleared"));
1719 ** InsStr(line, count)
1721 ** Insert the count characters pointed to by line.
1726 InsStr(NCURSES_SP_DCLx NCURSES_CH_T * line, int count)
1728 TR(TRACE_UPDATE, ("InsStr(%p, %p,%d) called",
1730 (void *) line, count));
1732 /* Prefer parm_ich as it has the smallest cost - no need to shift
1733 * the whole line on each character. */
1734 /* The order must match that of InsCharCost. */
1736 TPUTS_TRACE("parm_ich");
1737 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1738 TPARM_1(parm_ich, count),
1740 NCURSES_SP_NAME(_nc_outch));
1742 PutAttrChar(NCURSES_SP_ARGx CHREF(*line));
1746 } else if (enter_insert_mode && exit_insert_mode) {
1747 NCURSES_PUTP2("enter_insert_mode", enter_insert_mode);
1749 PutAttrChar(NCURSES_SP_ARGx CHREF(*line));
1750 if (insert_padding) {
1751 NCURSES_PUTP2("insert_padding", insert_padding);
1756 NCURSES_PUTP2("exit_insert_mode", exit_insert_mode);
1759 NCURSES_PUTP2("insert_character", insert_character);
1760 PutAttrChar(NCURSES_SP_ARGx CHREF(*line));
1761 if (insert_padding) {
1762 NCURSES_PUTP2("insert_padding", insert_padding);
1768 position_check(NCURSES_SP_ARGx
1770 SP_PARM->_curscol, "InsStr");
1776 ** Delete count characters at current position
1781 DelChar(NCURSES_SP_DCLx int count)
1783 TR(TRACE_UPDATE, ("DelChar(%p, %d) called, position = (%ld,%ld)",
1784 (void *) SP_PARM, count,
1785 (long) NewScreen(SP_PARM)->_cury,
1786 (long) NewScreen(SP_PARM)->_curx));
1789 TPUTS_TRACE("parm_dch");
1790 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1791 TPARM_1(parm_dch, count),
1793 NCURSES_SP_NAME(_nc_outch));
1797 for (n = 0; n < count; n++) {
1798 NCURSES_PUTP2("delete_character", delete_character);
1804 * Physical-scrolling support
1806 * This code was adapted from Keith Bostic's hardware scrolling
1807 * support for 4.4BSD curses. I (esr) translated it to use terminfo
1808 * capabilities, narrowed the call interface slightly, and cleaned
1809 * up some convoluted tests. I also added support for the memory_above
1810 * memory_below, and non_dest_scroll_region capabilities.
1812 * For this code to work, we must have either
1813 * change_scroll_region and scroll forward/reverse commands, or
1814 * insert and delete line capabilities.
1815 * When the scrolling region has been set, the cursor has to
1816 * be at the last line of the region to make the scroll up
1817 * happen, or on the first line of region to scroll down.
1819 * This code makes one aesthetic decision in the opposite way from
1820 * BSD curses. BSD curses preferred pairs of il/dl operations
1821 * over scrolls, allegedly because il/dl looked faster. We, on
1822 * the other hand, prefer scrolls because (a) they're just as fast
1823 * on many terminals and (b) using them avoids bouncing an
1824 * unchanged bottom section of the screen up and down, which is
1827 * (lav): added more cases, used dl/il when bot==maxy and in csr case.
1829 * I used assumption that capabilities il/il1/dl/dl1 work inside
1830 * changed scroll region not shifting screen contents outside of it.
1831 * If there are any terminals behaving different way, it would be
1832 * necessary to add some conditions to scroll_csr_forward/backward.
1835 /* Try to scroll up assuming given csr (miny, maxy). Returns ERR on failure */
1837 scroll_csr_forward(NCURSES_SP_DCLx
1847 if (n == 1 && scroll_forward && top == miny && bot == maxy) {
1848 GoTo(NCURSES_SP_ARGx bot, 0);
1849 UpdateAttrs(SP_PARM, blank);
1850 NCURSES_PUTP2("scroll_forward", scroll_forward);
1851 } else if (n == 1 && delete_line && bot == maxy) {
1852 GoTo(NCURSES_SP_ARGx top, 0);
1853 UpdateAttrs(SP_PARM, blank);
1854 NCURSES_PUTP2("delete_line", delete_line);
1855 } else if (parm_index && top == miny && bot == maxy) {
1856 GoTo(NCURSES_SP_ARGx bot, 0);
1857 UpdateAttrs(SP_PARM, blank);
1858 TPUTS_TRACE("parm_index");
1859 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1860 TPARM_2(parm_index, n, 0),
1862 NCURSES_SP_NAME(_nc_outch));
1863 } else if (parm_delete_line && bot == maxy) {
1864 GoTo(NCURSES_SP_ARGx top, 0);
1865 UpdateAttrs(SP_PARM, blank);
1866 TPUTS_TRACE("parm_delete_line");
1867 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1868 TPARM_2(parm_delete_line, n, 0),
1870 NCURSES_SP_NAME(_nc_outch));
1871 } else if (scroll_forward && top == miny && bot == maxy) {
1872 GoTo(NCURSES_SP_ARGx bot, 0);
1873 UpdateAttrs(SP_PARM, blank);
1874 for (i = 0; i < n; i++) {
1875 NCURSES_PUTP2("scroll_forward", scroll_forward);
1877 } else if (delete_line && bot == maxy) {
1878 GoTo(NCURSES_SP_ARGx top, 0);
1879 UpdateAttrs(SP_PARM, blank);
1880 for (i = 0; i < n; i++) {
1881 NCURSES_PUTP2("delete_line", delete_line);
1886 #if NCURSES_EXT_FUNCS
1887 if (FILL_BCE(SP_PARM)) {
1889 for (i = 0; i < n; i++) {
1890 GoTo(NCURSES_SP_ARGx bot - i, 0);
1891 for (j = 0; j < screen_columns(SP_PARM); j++)
1892 PutChar(NCURSES_SP_ARGx CHREF(blank));
1899 /* Try to scroll down assuming given csr (miny, maxy). Returns ERR on failure */
1902 scroll_csr_backward(NCURSES_SP_DCLx
1912 if (n == 1 && scroll_reverse && top == miny && bot == maxy) {
1913 GoTo(NCURSES_SP_ARGx top, 0);
1914 UpdateAttrs(SP_PARM, blank);
1915 NCURSES_PUTP2("scroll_reverse", scroll_reverse);
1916 } else if (n == 1 && insert_line && bot == maxy) {
1917 GoTo(NCURSES_SP_ARGx top, 0);
1918 UpdateAttrs(SP_PARM, blank);
1919 NCURSES_PUTP2("insert_line", insert_line);
1920 } else if (parm_rindex && top == miny && bot == maxy) {
1921 GoTo(NCURSES_SP_ARGx top, 0);
1922 UpdateAttrs(SP_PARM, blank);
1923 TPUTS_TRACE("parm_rindex");
1924 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1925 TPARM_2(parm_rindex, n, 0),
1927 NCURSES_SP_NAME(_nc_outch));
1928 } else if (parm_insert_line && bot == maxy) {
1929 GoTo(NCURSES_SP_ARGx top, 0);
1930 UpdateAttrs(SP_PARM, blank);
1931 TPUTS_TRACE("parm_insert_line");
1932 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1933 TPARM_2(parm_insert_line, n, 0),
1935 NCURSES_SP_NAME(_nc_outch));
1936 } else if (scroll_reverse && top == miny && bot == maxy) {
1937 GoTo(NCURSES_SP_ARGx top, 0);
1938 UpdateAttrs(SP_PARM, blank);
1939 for (i = 0; i < n; i++) {
1940 NCURSES_PUTP2("scroll_reverse", scroll_reverse);
1942 } else if (insert_line && bot == maxy) {
1943 GoTo(NCURSES_SP_ARGx top, 0);
1944 UpdateAttrs(SP_PARM, blank);
1945 for (i = 0; i < n; i++) {
1946 NCURSES_PUTP2("insert_line", insert_line);
1951 #if NCURSES_EXT_FUNCS
1952 if (FILL_BCE(SP_PARM)) {
1954 for (i = 0; i < n; i++) {
1955 GoTo(NCURSES_SP_ARGx top + i, 0);
1956 for (j = 0; j < screen_columns(SP_PARM); j++)
1957 PutChar(NCURSES_SP_ARGx CHREF(blank));
1964 /* scroll by using delete_line at del and insert_line at ins */
1967 scroll_idl(NCURSES_SP_DCLx int n, int del, int ins, NCURSES_CH_T blank)
1971 if (!((parm_delete_line || delete_line) && (parm_insert_line || insert_line)))
1974 GoTo(NCURSES_SP_ARGx del, 0);
1975 UpdateAttrs(SP_PARM, blank);
1976 if (n == 1 && delete_line) {
1977 NCURSES_PUTP2("delete_line", delete_line);
1978 } else if (parm_delete_line) {
1979 TPUTS_TRACE("parm_delete_line");
1980 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1981 TPARM_2(parm_delete_line, n, 0),
1983 NCURSES_SP_NAME(_nc_outch));
1984 } else { /* if (delete_line) */
1985 for (i = 0; i < n; i++) {
1986 NCURSES_PUTP2("delete_line", delete_line);
1990 GoTo(NCURSES_SP_ARGx ins, 0);
1991 UpdateAttrs(SP_PARM, blank);
1992 if (n == 1 && insert_line) {
1993 NCURSES_PUTP2("insert_line", insert_line);
1994 } else if (parm_insert_line) {
1995 TPUTS_TRACE("parm_insert_line");
1996 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1997 TPARM_2(parm_insert_line, n, 0),
1999 NCURSES_SP_NAME(_nc_outch));
2000 } else { /* if (insert_line) */
2001 for (i = 0; i < n; i++) {
2002 NCURSES_PUTP2("insert_line", insert_line);
2010 * Note: some terminals require the cursor to be within the scrolling margins
2011 * before setting them. Generally, the cursor must be at the appropriate end
2012 * of the scrolling margins when issuing an indexing operation (it is not
2013 * apparent whether it must also be at the left margin; we do this just to be
2014 * safe). To make the related cursor movement a little faster, we use the
2015 * save/restore cursor capabilities if the terminal has them.
2018 NCURSES_SP_NAME(_nc_scrolln) (NCURSES_SP_DCLx
2023 /* scroll region from top to bot by n lines */
2027 bool cursor_saved = FALSE;
2030 TR(TRACE_MOVE, ("_nc_scrolln(%p, %d, %d, %d, %d)",
2031 (void *) SP_PARM, n, top, bot, maxy));
2033 if (!IsValidScreen(SP_PARM))
2036 blank = ClrBlank(NCURSES_SP_ARGx StdScreen(SP_PARM));
2040 * If we scroll, we might remove a cookie.
2042 if (magic_cookie_glitch > 0) {
2047 if (n > 0) { /* scroll up (forward) */
2049 * Explicitly clear if stuff pushed off top of region might
2050 * be saved by the terminal.
2052 res = scroll_csr_forward(NCURSES_SP_ARGx n, top, bot, 0, maxy, blank);
2054 if (res == ERR && change_scroll_region) {
2055 if ((((n == 1 && scroll_forward) || parm_index)
2056 && (SP_PARM->_cursrow == bot || SP_PARM->_cursrow == bot - 1))
2057 && save_cursor && restore_cursor) {
2058 cursor_saved = TRUE;
2059 NCURSES_PUTP2("save_cursor", save_cursor);
2061 NCURSES_PUTP2("change_scroll_region",
2062 TPARM_2(change_scroll_region, top, bot));
2064 NCURSES_PUTP2("restore_cursor", restore_cursor);
2066 SP_PARM->_cursrow = SP_PARM->_curscol = -1;
2069 res = scroll_csr_forward(NCURSES_SP_ARGx n, top, bot, top, bot, blank);
2071 NCURSES_PUTP2("change_scroll_region",
2072 TPARM_2(change_scroll_region, 0, maxy));
2073 SP_PARM->_cursrow = SP_PARM->_curscol = -1;
2076 if (res == ERR && SP_PARM->_nc_sp_idlok)
2077 res = scroll_idl(NCURSES_SP_ARGx n, top, bot - n + 1, blank);
2080 * Clear the newly shifted-in text.
2083 && (non_dest_scroll_region || (memory_below && bot == maxy))) {
2084 static const NCURSES_CH_T blank2 = NewChar(BLANK_TEXT);
2085 if (bot == maxy && clr_eos) {
2086 GoTo(NCURSES_SP_ARGx bot - n + 1, 0);
2087 ClrToEOS(NCURSES_SP_ARGx blank2);
2089 for (i = 0; i < n; i++) {
2090 GoTo(NCURSES_SP_ARGx bot - i, 0);
2091 ClrToEOL(NCURSES_SP_ARGx blank2, FALSE);
2096 } else { /* (n < 0) - scroll down (backward) */
2097 res = scroll_csr_backward(NCURSES_SP_ARGx -n, top, bot, 0, maxy, blank);
2099 if (res == ERR && change_scroll_region) {
2101 && (SP_PARM->_cursrow == top ||
2102 SP_PARM->_cursrow == top - 1)
2103 && save_cursor && restore_cursor) {
2104 cursor_saved = TRUE;
2105 NCURSES_PUTP2("save_cursor", save_cursor);
2107 NCURSES_PUTP2("change_scroll_region",
2108 TPARM_2(change_scroll_region, top, bot));
2110 NCURSES_PUTP2("restore_cursor", restore_cursor);
2112 SP_PARM->_cursrow = SP_PARM->_curscol = -1;
2115 res = scroll_csr_backward(NCURSES_SP_ARGx
2116 -n, top, bot, top, bot, blank);
2118 NCURSES_PUTP2("change_scroll_region",
2119 TPARM_2(change_scroll_region, 0, maxy));
2120 SP_PARM->_cursrow = SP_PARM->_curscol = -1;
2123 if (res == ERR && SP_PARM->_nc_sp_idlok)
2124 res = scroll_idl(NCURSES_SP_ARGx -n, bot + n + 1, top, blank);
2127 * Clear the newly shifted-in text.
2130 && (non_dest_scroll_region || (memory_above && top == 0))) {
2131 static const NCURSES_CH_T blank2 = NewChar(BLANK_TEXT);
2132 for (i = 0; i < -n; i++) {
2133 GoTo(NCURSES_SP_ARGx i + top, 0);
2134 ClrToEOL(NCURSES_SP_ARGx blank2, FALSE);
2142 _nc_scroll_window(CurScreen(SP_PARM), n,
2143 (NCURSES_SIZE_T) top,
2144 (NCURSES_SIZE_T) bot,
2147 /* shift hash values too - they can be reused */
2148 NCURSES_SP_NAME(_nc_scroll_oldhash) (NCURSES_SP_ARGx n, top, bot);
2153 #if NCURSES_SP_FUNCS
2155 _nc_scrolln(int n, int top, int bot, int maxy)
2157 return NCURSES_SP_NAME(_nc_scrolln) (CURRENT_SCREEN, n, top, bot, maxy);
2161 NCURSES_EXPORT(void)
2162 NCURSES_SP_NAME(_nc_screen_resume) (NCURSES_SP_DCL0)
2166 /* make sure terminal is in a sane known state */
2167 SetAttr(SCREEN_ATTRS(SP_PARM), A_NORMAL);
2168 NewScreen(SP_PARM)->_clear = TRUE;
2170 /* reset color pairs and definitions */
2171 if (SP_PARM->_coloron || SP_PARM->_color_defs)
2172 NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_ARG);
2174 /* restore user-defined colors, if any */
2175 if (SP_PARM->_color_defs < 0) {
2177 SP_PARM->_color_defs = -(SP_PARM->_color_defs);
2178 for (n = 0; n < SP_PARM->_color_defs; ++n) {
2179 if (SP_PARM->_color_table[n].init) {
2180 NCURSES_SP_NAME(init_color) (NCURSES_SP_ARGx
2182 SP_PARM->_color_table[n].r,
2183 SP_PARM->_color_table[n].g,
2184 SP_PARM->_color_table[n].b);
2189 if (exit_attribute_mode)
2190 NCURSES_PUTP2("exit_attribute_mode", exit_attribute_mode);
2192 /* turn off attributes */
2193 if (exit_alt_charset_mode)
2194 NCURSES_PUTP2("exit_alt_charset_mode", exit_alt_charset_mode);
2195 if (exit_standout_mode)
2196 NCURSES_PUTP2("exit_standout_mode", exit_standout_mode);
2197 if (exit_underline_mode)
2198 NCURSES_PUTP2("exit_underline_mode", exit_underline_mode);
2200 if (exit_insert_mode)
2201 NCURSES_PUTP2("exit_insert_mode", exit_insert_mode);
2202 if (enter_am_mode && exit_am_mode) {
2203 if (auto_right_margin) {
2204 NCURSES_PUTP2("enter_am_mode", enter_am_mode);
2206 NCURSES_PUTP2("exit_am_mode", exit_am_mode);
2211 #if NCURSES_SP_FUNCS
2212 NCURSES_EXPORT(void)
2213 _nc_screen_resume(void)
2215 NCURSES_SP_NAME(_nc_screen_resume) (CURRENT_SCREEN);
2219 NCURSES_EXPORT(void)
2220 NCURSES_SP_NAME(_nc_screen_init) (NCURSES_SP_DCL0)
2222 NCURSES_SP_NAME(_nc_screen_resume) (NCURSES_SP_ARG);
2225 #if NCURSES_SP_FUNCS
2226 NCURSES_EXPORT(void)
2227 _nc_screen_init(void)
2229 NCURSES_SP_NAME(_nc_screen_init) (CURRENT_SCREEN);
2233 /* wrap up screen handling */
2234 NCURSES_EXPORT(void)
2235 NCURSES_SP_NAME(_nc_screen_wrap) (NCURSES_SP_DCL0)
2239 UpdateAttrs(SP_PARM, normal);
2240 #if NCURSES_EXT_FUNCS
2241 if (SP_PARM->_coloron
2242 && !SP_PARM->_default_color) {
2243 static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
2244 SP_PARM->_default_color = TRUE;
2245 NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx
2249 NCURSES_SP_NAME(_nc_outch));
2250 SP_PARM->_default_color = FALSE;
2252 TINFO_MVCUR(NCURSES_SP_ARGx
2255 screen_lines(SP_PARM) - 1,
2258 ClrToEOL(NCURSES_SP_ARGx blank, TRUE);
2261 if (SP_PARM->_color_defs) {
2262 NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_ARG);
2267 #if NCURSES_SP_FUNCS
2268 NCURSES_EXPORT(void)
2269 _nc_screen_wrap(void)
2271 NCURSES_SP_NAME(_nc_screen_wrap) (CURRENT_SCREEN);
2276 NCURSES_EXPORT(void)
2277 NCURSES_SP_NAME(_nc_do_xmc_glitch) (NCURSES_SP_DCLx attr_t previous)
2280 attr_t chg = XMC_CHANGES(previous ^ AttrOf(SCREEN_ATTRS(SP_PARM)));
2284 SP_PARM->_curscol += magic_cookie_glitch;
2285 if (SP_PARM->_curscol >= SP_PARM->_columns)
2286 wrap_cursor(NCURSES_SP_ARG);
2287 TR(TRACE_UPDATE, ("bumped to %d,%d after cookie",
2288 SP_PARM->_cursrow, SP_PARM->_curscol));
2295 #if NCURSES_SP_FUNCS
2296 NCURSES_EXPORT(void)
2297 _nc_do_xmc_glitch(attr_t previous)
2299 NCURSES_SP_NAME(_nc_do_xmc_glitch) (CURRENT_SCREEN, previous);
2303 #endif /* USE_XMC_SUPPORT */