1 /****************************************************************************
2 * Copyright (c) 1998-2001,2002 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 ****************************************************************************/
34 /*-----------------------------------------------------------------
38 * The routine doupdate() and its dependents. Also _nc_outstr(),
39 * so all physical output is concentrated here (except _nc_outch()
42 *-----------------------------------------------------------------*/
44 #include <curses.priv.h>
52 #if defined(TRACE) && HAVE_SYS_TIMES_H && HAVE_TIMES
53 #define USE_TRACE_TIMES 1
55 #define USE_TRACE_TIMES 0
58 #if HAVE_SYS_TIME_H && HAVE_SYS_TIME_SELECT
63 #include <sys/times.h>
69 #include <sys/select.h>
75 MODULE_ID("$Id: tty_update.c,v 1.177 2002/09/28 20:41:55 tom Exp $")
78 * This define controls the line-breakout optimization. Every once in a
79 * while during screen refresh, we want to check for input and abort the
80 * update if there's some waiting. CHECK_INTERVAL controls the number of
81 * changed lines to be emitted between input checks.
83 * Note: Input-check-and-abort is no longer done if the screen is being
84 * updated from scratch. This is a feature, not a bug.
86 #define CHECK_INTERVAL 5
88 #define FILL_BCE() (SP->_coloron && !SP->_default_color && !back_color_erase)
91 * Enable checking to see if doupdate and friends are tracking the true
92 * cursor position correctly. NOTE: this is a debugging hack which will
93 * work ONLY on ANSI-compatible terminals!
95 /* #define POSITION_DEBUG */
97 static inline NCURSES_CH_T ClrBlank(WINDOW *win);
98 static int ClrBottom(int total);
99 static void ClearScreen(NCURSES_CH_T blank);
100 static void ClrUpdate(void);
101 static void DelChar(int count);
102 static void InsStr(NCURSES_CH_T * line, int count);
103 static void TransformLine(int const lineno);
105 #ifdef POSITION_DEBUG
106 /****************************************************************************
108 * Debugging code. Only works on ANSI-standard terminals.
110 ****************************************************************************/
113 position_check(int expected_y, int expected_x, char *legend)
114 /* check to see if the real cursor position matches the virtual */
120 if (!_nc_tracing || (expected_y < 0 && expected_x < 0))
124 memset(buf, '\0', sizeof(buf));
125 putp("\033[6n"); /* only works on ANSI-compatibles */
129 int ask = sizeof(buf) - 1 - (s - buf);
130 int got = read(0, s, ask);
134 } while (strchr(buf, 'R') == 0);
135 _tracef("probe returned %s", _nc_visbuf(buf));
137 /* try to interpret as a position report */
138 if (sscanf(buf, "\033[%d;%dR", &y, &x) != 2) {
139 _tracef("position probe failed in %s", legend);
145 if (y - 1 != expected_y || x - 1 != expected_x) {
147 tputs(tparm("\033[%d;%dH", expected_y + 1, expected_x + 1), 1, _nc_outch);
148 _tracef("position seen (%d, %d) doesn't match expected one (%d, %d) in %s",
149 y - 1, x - 1, expected_y, expected_x, legend);
151 _tracef("position matches OK in %s", legend);
156 #define position_check(expected_y, expected_x, legend) /* nothing */
157 #endif /* POSITION_DEBUG */
159 /****************************************************************************
161 * Optimized update code
163 ****************************************************************************/
166 GoTo(int const row, int const col)
168 attr_t oldattr = SP->_current_attr;
170 TR(TRACE_MOVE, ("GoTo(%d, %d) from (%d, %d)",
171 row, col, SP->_cursrow, SP->_curscol));
173 position_check(SP->_cursrow, SP->_curscol, "GoTo");
176 * Force restore even if msgr is on when we're in an alternate
177 * character set -- these have a strong tendency to screw up the
178 * CR & LF used for local character motions!
180 if ((oldattr & A_ALTCHARSET)
181 || (oldattr && !move_standout_mode)) {
182 TR(TRACE_CHARPUT, ("turning off (%#lx) %s before move",
183 oldattr, _traceattr(oldattr)));
187 mvcur(SP->_cursrow, SP->_curscol, row, col);
190 position_check(SP->_cursrow, SP->_curscol, "GoTo2");
194 PutAttrChar(CARG_CH_T ch)
199 if (tilde_glitch && (CharOfD(ch) == L('~'))) {
200 SetChar(tilde, L('`'), AttrOfD(ch));
204 TR(TRACE_CHARPUT, ("PutAttrChar(%s) at (%d, %d)",
206 SP->_cursrow, SP->_curscol));
207 UpdateAttrs(AttrOfD(ch));
208 #if !USE_WIDEC_SUPPORT
209 /* FIXME - we do this special case for signal handling, should see how to
210 * make it work for wide characters.
212 if (SP->_outch != 0) {
213 SP->_outch((int) ch);
217 PUTC(CHDEREF(ch), SP->_ofp); /* macro's fastest... */
224 TPUTS_TRACE("char_padding");
231 /* check for pending input */
233 bool have_pending = FALSE;
236 * Only carry out this check when the flag is zero, otherwise we'll
237 * have the refreshing slow down drastically (or stop) if there's an
238 * unread character available.
240 if (SP->_fifohold != 0)
243 if (SP->_checkfd >= 0) {
245 struct pollfd fds[1];
246 fds[0].fd = SP->_checkfd;
247 fds[0].events = POLLIN;
248 if (poll(fds, 1, 0) > 0) {
251 #elif defined(__BEOS__)
253 * BeOS's select() is declared in socket.h, so the configure script does
254 * not see it. That's just as well, since that function works only for
255 * sockets. This (using snooze and ioctl) was distilled from Be's patch
256 * for ncurses which uses a separate thread to simulate select().
258 * FIXME: the return values from the ioctl aren't very clear if we get
262 int howmany = ioctl(0, 'ichr', &n);
263 if (howmany >= 0 && n > 0) {
268 struct timeval ktimeout;
271 ktimeout.tv_usec = 0;
274 FD_SET(SP->_checkfd, &fdset);
275 if (select(SP->_checkfd + 1, &fdset, NULL, NULL, &ktimeout) != 0) {
287 /* put char at lower right corner */
289 PutCharLR(const ARG_CH_T ch)
291 if (!auto_right_margin) {
292 /* we can put the char directly */
294 } else if (enter_am_mode && exit_am_mode) {
295 /* we can suppress automargin */
296 TPUTS_TRACE("exit_am_mode");
301 position_check(SP->_cursrow, SP->_curscol, "exit_am_mode");
303 TPUTS_TRACE("enter_am_mode");
305 } else if ((enter_insert_mode && exit_insert_mode)
306 || insert_character || parm_ich) {
307 GoTo(screen_lines - 1, screen_columns - 2);
309 GoTo(screen_lines - 1, screen_columns - 2);
310 InsStr(newscr->_line[screen_lines - 1].text + screen_columns - 2, 1);
317 if (eat_newline_glitch) {
319 * xenl can manifest two different ways. The vt100
320 * way is that, when you'd expect the cursor to wrap,
321 * it stays hung at the right margin (on top of the
322 * character just emitted) and doesn't wrap until the
323 * *next* graphic char is emitted. The c100 way is
324 * to ignore LF received just after an am wrap.
326 * An aggressive way to handle this would be to
327 * emit CR/LF after the char and then assume the wrap
328 * is done, you're on the first position of the next
329 * line, and the terminal out of its weird state.
330 * Here it's safe to just tell the code that the
331 * cursor is in hyperspace and let the next mvcur()
332 * call straighten things out.
336 } else if (auto_right_margin) {
342 position_check(SP->_cursrow, SP->_curscol, "wrap_cursor");
346 PutChar(const ARG_CH_T ch)
347 /* insert character, handling automargin stuff */
349 if (SP->_cursrow == screen_lines - 1 && SP->_curscol == screen_columns - 1)
354 if (SP->_curscol >= screen_columns)
357 position_check(SP->_cursrow, SP->_curscol, "PutChar");
361 * Check whether the given character can be output by clearing commands. This
362 * includes test for being a space and not including any 'bad' attributes, such
363 * as A_REVERSE. All attribute flags which don't affect appearance of a space
364 * or can be output by clearing (A_COLOR in case of bce-terminal) are excluded.
367 can_clear_with(ARG_CH_T ch)
369 if (!back_color_erase && SP->_coloron) {
370 #if NCURSES_EXT_FUNCS
371 if (!SP->_default_color)
373 if (SP->_default_fg != C_MASK || SP->_default_bg != C_MASK)
375 if (AttrOfD(ch) & A_COLOR) {
377 pair_content(PAIR_NUMBER(AttrOfD(ch)), &fg, &bg);
378 if (fg != C_MASK || bg != C_MASK)
382 if (AttrOfD(ch) & A_COLOR)
386 return (ISBLANK(CHDEREF(ch)) &&
387 (AttrOfD(ch) & ~(NONBLANK_ATTR | A_COLOR)) == BLANK_ATTR);
391 * Issue a given span of characters from an array.
392 * Must be functionally equivalent to:
393 * for (i = 0; i < num; i++)
395 * but can leave the cursor positioned at the middle of the interval.
397 * Returns: 0 - cursor is at the end of interval
398 * 1 - cursor is somewhere in the middle
400 * This code is optimized using ech and rep.
403 EmitRange(const NCURSES_CH_T * ntext, int num)
407 if (erase_chars || repeat_char) {
412 while (num > 1 && !CharEq(ntext[0], ntext[1])) {
413 PutChar(CHREF(ntext[0]));
419 PutChar(CHREF(ntext0));
424 while (runcount < num && CharEq(ntext[runcount], ntext0))
428 * The cost expression in the middle isn't exactly right.
429 * _cup_ch_cost is an upper bound on the cost for moving to the
430 * end of the erased area, but not the cost itself (which we
431 * can't compute without emitting the move). This may result
432 * in erase_chars not getting used in some situations for
433 * which it would be marginally advantageous.
436 && runcount > SP->_ech_cost + SP->_cup_ch_cost
437 && can_clear_with(CHREF(ntext0))) {
438 UpdateAttrs(AttrOf(ntext0));
439 putp(tparm(erase_chars, runcount));
442 * If this is the last part of the given interval,
443 * don't bother moving cursor, since it can be the
444 * last update on the line.
446 if (runcount < num) {
447 GoTo(SP->_cursrow, SP->_curscol + runcount);
449 return 1; /* cursor stays in the middle */
451 } else if (repeat_char && runcount > SP->_rep_cost) {
452 bool wrap_possible = (SP->_curscol + runcount >= screen_columns);
453 int rep_count = runcount;
458 UpdateAttrs(AttrOf(ntext0));
459 putp(tparm(repeat_char, CharOf(ntext0), rep_count));
460 SP->_curscol += rep_count;
463 PutChar(CHREF(ntext0));
465 for (i = 0; i < runcount; i++)
466 PutChar(CHREF(ntext[i]));
474 for (i = 0; i < num; i++)
475 PutChar(CHREF(ntext[i]));
480 * Output the line in the given range [first .. last]
482 * If there's a run of identical characters that's long enough to justify
483 * cursor movement, use that also.
485 * Returns: same as EmitRange
488 PutRange(const NCURSES_CH_T * otext,
489 const NCURSES_CH_T * ntext,
495 TR(TRACE_CHARPUT, ("PutRange(%p, %p, %d, %d, %d)",
496 otext, ntext, row, first, last));
499 && (last - first + 1) > SP->_inline_cost) {
500 for (j = first, run = 0; j <= last; j++) {
501 if (!run && isnac(otext[j]))
503 if (CharEq(otext[j], ntext[j])) {
506 if (run > SP->_inline_cost) {
507 int before_run = (j - run);
508 EmitRange(ntext + first, before_run - first);
509 GoTo(row, first = j);
515 return EmitRange(ntext + first, last - first + 1);
518 /* leave unbracketed here so 'indent' works */
519 #define MARK_NOCHANGE(win,row) \
520 win->_line[row].firstchar = _NOCHANGE; \
521 win->_line[row].lastchar = _NOCHANGE; \
522 if_USE_SCROLL_HINTS(win->_line[row].oldindex = row)
530 struct tms before, after;
531 #endif /* USE_TRACE_TIMES */
533 T((T_CALLED("doupdate()")));
536 if (_nc_tracing & TRACE_UPDATE) {
538 _tracef("curscr is clear");
540 _tracedump("curscr", curscr);
541 _tracedump("newscr", newscr);
545 _nc_signal_handler(FALSE);
551 if (SP->_endwin || SP->_sig_winch) {
553 * This is a transparent extension: XSI does not address it,
554 * and applications need not know that ncurses can do it.
556 * Check if the terminal size has changed while curses was off
557 * (this can happen in an xterm, for example), and resize the
558 * ncurses data structures accordingly.
560 _nc_update_screensize();
566 T(("coming back from shell mode"));
571 SP->_mouse_resume(SP);
576 /* zero the metering machinery */
578 (void) times(&before);
579 #endif /* USE_TRACE_TIMES */
582 * This is the support for magic-cookie terminals. The
583 * theory: we scan the virtual screen looking for attribute
584 * turnons. Where we find one, check to make sure it's
585 * realizable by seeing if the required number of
586 * un-attributed blanks are present before and after the
587 * attributed range; try to shift the range boundaries over
588 * blanks (not changing the screen display) so this becomes
589 * true. If it is, shift the beginning attribute change
590 * appropriately (the end one, if we've gotten this far, is
591 * guaranteed room for its cookie). If not, nuke the added
592 * attributes out of the span.
595 if (magic_cookie_glitch > 0) {
597 attr_t rattr = A_NORMAL;
599 for (i = 0; i < screen_lines; i++) {
600 for (j = 0; j < screen_columns; j++) {
602 attr_t turnon = AttrOf(newscr->_line[i].text[j]) & ~rattr;
604 /* is an attribute turned on here? */
606 rattr = AttrOf(newscr->_line[i].text[j]);
610 TR(TRACE_ATTRS, ("At (%d, %d): from %s...", i, j, _traceattr(rattr)));
611 TR(TRACE_ATTRS, ("...to %s", _traceattr(turnon)));
614 * If the attribute change location is a blank with a
615 * "safe" attribute, undo the attribute turnon. This may
616 * ensure there's enough room to set the attribute before
617 * the first non-blank in the run.
619 #define SAFE(a) (!((a) & (attr_t)~NONBLANK_ATTR))
620 if (ISBLANK(newscr->_line[i].text[j]) && SAFE(turnon)) {
621 RemAttr(newscr->_line[i].text[j], turnon);
625 /* check that there's enough room at start of span */
626 for (k = 1; k <= magic_cookie_glitch; k++) {
628 || !ISBLANK(newscr->_line[i].text[j - k])
629 || !SAFE(AttrOf(newscr->_line[i].text[j - k])))
633 bool end_onscreen = FALSE;
636 /* find end of span, if it's onscreen */
637 for (m = i; m < screen_lines; m++) {
638 for (; n < screen_columns; n++) {
639 if (AttrOf(newscr->_line[m].text[n]) == rattr) {
642 ("Range attributed with %s ends at (%d, %d)",
643 _traceattr(turnon), m, n));
650 ("Range attributed with %s ends offscreen",
651 _traceattr(turnon)));
655 NCURSES_CH_T *lastline = newscr->_line[m].text;
658 * If there are safely-attributed blanks at the
659 * end of the range, shorten the range. This will
660 * help ensure that there is enough room at end
664 && ISBLANK(lastline[n])
665 && SAFE(AttrOf(lastline[n])))
666 RemAttr(lastline[n--], turnon);
668 /* check that there's enough room at end of span */
669 for (k = 1; k <= magic_cookie_glitch; k++)
670 if (n + k >= screen_columns
671 || !ISBLANK(lastline[n + k])
672 || !SAFE(AttrOf(lastline[n + k])))
681 ("Clearing %s beginning at (%d, %d)",
682 _traceattr(turnon), i, j));
684 /* turn off new attributes over span */
685 for (p = i; p < screen_lines; p++) {
686 for (; q < screen_columns; q++) {
687 if (AttrOf(newscr->_line[p].text[q]) == rattr)
689 RemAttr(newscr->_line[p].text[q], turnon);
696 ("Cookie space for %s found before (%d, %d)",
697 _traceattr(turnon), i, j));
700 * back up the start of range so there's room
701 * for cookies before the first nonblank character
703 for (k = 1; k <= magic_cookie_glitch; k++)
704 AddAttr(newscr->_line[i].text[j - k], turnon);
707 rattr = AttrOf(newscr->_line[i].text[j]);
712 /* show altered highlights after magic-cookie check */
713 if (_nc_tracing & TRACE_UPDATE) {
714 _tracef("After magic-cookie check...");
715 _tracedump("newscr", newscr);
719 #endif /* USE_XMC_SUPPORT */
722 if (curscr->_clear || newscr->_clear) { /* force refresh ? */
723 TR(TRACE_UPDATE, ("clearing and updating from scratch"));
725 curscr->_clear = FALSE; /* reset flag */
726 newscr->_clear = FALSE; /* reset flag */
728 int changedlines = CHECK_INTERVAL;
733 nonempty = min(screen_lines, newscr->_maxy + 1);
735 if (SP->_scrolling) {
736 _nc_scroll_optimize();
739 nonempty = ClrBottom(nonempty);
741 TR(TRACE_UPDATE, ("Transforming lines, nonempty %d", nonempty));
742 for (i = 0; i < nonempty; i++) {
744 * Here is our line-breakout optimization.
746 if (changedlines == CHECK_INTERVAL) {
753 * newscr->line[i].firstchar is normally set
754 * by wnoutrefresh. curscr->line[i].firstchar
755 * is normally set by _nc_scroll_window in the
756 * vertical-movement optimization code,
758 if (newscr->_line[i].firstchar != _NOCHANGE
759 || curscr->_line[i].firstchar != _NOCHANGE) {
764 /* mark line changed successfully */
765 if (i <= newscr->_maxy) {
766 MARK_NOCHANGE(newscr, i);
768 if (i <= curscr->_maxy) {
769 MARK_NOCHANGE(curscr, i);
774 /* put everything back in sync */
775 for (i = nonempty; i <= newscr->_maxy; i++) {
776 MARK_NOCHANGE(newscr, i);
778 for (i = nonempty; i <= curscr->_maxy; i++) {
779 MARK_NOCHANGE(curscr, i);
782 if (!newscr->_leaveok) {
783 curscr->_curx = newscr->_curx;
784 curscr->_cury = newscr->_cury;
786 GoTo(curscr->_cury, curscr->_curx);
791 * Keep the physical screen in normal mode in case we get other
792 * processes writing to the screen.
794 UpdateAttrs(A_NORMAL);
797 curscr->_attrs = newscr->_attrs;
800 (void) times(&after);
802 ("Update cost: %ld chars, %ld clocks system time, %ld clocks user time",
804 (long) (after.tms_stime - before.tms_stime),
805 (long) (after.tms_utime - before.tms_utime)));
806 #endif /* USE_TRACE_TIMES */
808 _nc_signal_handler(TRUE);
816 * Returns the attributed character that corresponds to the "cleared"
817 * screen. If the terminal has the back-color-erase feature, this will be
818 * colored according to the wbkgd() call.
820 * We treat 'curscr' specially because it isn't supposed to be set directly
821 * in the wbkgd() call. Assume 'stdscr' for this case.
823 #define BCE_ATTRS (A_NORMAL|A_COLOR)
824 #define BCE_BKGD(win) (((win) == curscr ? stdscr : (win))->_nc_bkgd)
826 static inline NCURSES_CH_T
827 ClrBlank(WINDOW *win)
829 NCURSES_CH_T blank = NewChar(BLANK_TEXT);
830 if (back_color_erase)
831 AddAttr(blank, (AttrOf(BCE_BKGD(win)) & BCE_ATTRS));
838 ** Update by clearing and redrawing the entire screen.
846 NCURSES_CH_T blank = ClrBlank(stdscr);
847 int nonempty = min(screen_lines, newscr->_maxy + 1);
849 TR(TRACE_UPDATE, ("ClrUpdate() called"));
853 TR(TRACE_UPDATE, ("updating screen from scratch"));
855 nonempty = ClrBottom(nonempty);
857 for (i = 0; i < nonempty; i++)
864 ** Clear to end of current line, starting at the cursor position
868 ClrToEOL(NCURSES_CH_T blank, bool needclear)
873 && SP->_cursrow >= 0) {
874 for (j = SP->_curscol; j < screen_columns; j++) {
876 NCURSES_CH_T *cp = &(curscr->_line[SP->_cursrow].text[j]);
878 if (!CharEq(*cp, blank)) {
889 UpdateAttrs(AttrOf(blank));
890 TPUTS_TRACE("clr_eol");
891 if (SP->_el_cost > (screen_columns - SP->_curscol)) {
892 int count = (screen_columns - SP->_curscol);
894 PutChar(CHREF(blank));
904 ** Clear to end of screen, starting at the cursor position
908 ClrToEOS(NCURSES_CH_T blank)
915 UpdateAttrs(AttrOf(blank));
916 TPUTS_TRACE("clr_eos");
917 tputs(clr_eos, screen_lines - row, _nc_outch);
919 while (col < screen_columns)
920 curscr->_line[row].text[col++] = blank;
922 for (row++; row < screen_lines; row++) {
923 for (col = 0; col < screen_columns; col++)
924 curscr->_line[row].text[col] = blank;
931 * Test if clearing the end of the screen would satisfy part of the
932 * screen-update. Do this by scanning backwards through the lines in the
933 * screen, checking if each is blank, and one or more are changed.
941 int last = min(screen_columns, newscr->_maxx + 1);
942 NCURSES_CH_T blank = ClrBlank(stdscr);
945 if (clr_eos && can_clear_with(CHREF(blank))) {
947 for (row = total - 1; row >= 0; row--) {
948 for (col = 0, ok = TRUE; ok && col < last; col++) {
949 ok = (CharEq(newscr->_line[row].text[col], blank));
954 for (col = 0; ok && col < last; col++) {
955 ok = (CharEq(curscr->_line[row].text[col], blank));
961 /* don't use clr_eos for just one line if clr_eol available */
962 if (top < total - 1 || (top < total && !clr_eol && !clr_bol)) {
966 if (SP->oldhash && SP->newhash) {
967 for (row = top; row < screen_lines; row++)
968 SP->oldhash[row] = SP->newhash[row];
976 #if USE_WIDEC_SUPPORT
978 check_xmc_transition(NCURSES_CH_T * a, NCURSES_CH_T * b)
980 if (((a->attr ^ b->attr) & ~(a->attr) & SP->_xmc_triggers) != 0) {
985 #define xmc_turn_on(a,b) check_xmc_transition(&(a), &(b))
987 #define xmc_turn_on(a,b) ((((a)^(b)) & ~(a) & SP->_xmc_triggers) != 0)
990 #define xmc_new(r,c) newscr->_line[r].text[c]
991 #define xmc_turn_off(a,b) xmc_turn_on(b,a)
992 #endif /* USE_XMC_SUPPORT */
995 ** TransformLine(lineno)
997 ** Transform the given line in curscr to the one in newscr, using
998 ** Insert/Delete Character if _nc_idcok && has_ic().
1000 ** firstChar = position of first different character in line
1001 ** oLastChar = position of last different character in old line
1002 ** nLastChar = position of last different character in new line
1004 ** move to firstChar
1005 ** overwrite chars up to min(oLastChar, nLastChar)
1006 ** if oLastChar < nLastChar
1007 ** insert newLine[oLastChar+1..nLastChar]
1009 ** delete oLastChar - nLastChar spaces
1013 TransformLine(int const lineno)
1015 int firstChar, oLastChar, nLastChar;
1016 NCURSES_CH_T *newLine = newscr->_line[lineno].text;
1017 NCURSES_CH_T *oldLine = curscr->_line[lineno].text;
1019 bool attrchanged = FALSE;
1021 TR(TRACE_UPDATE, ("TransformLine(%d) called", lineno));
1023 /* copy new hash value to old one */
1024 if (SP->oldhash && SP->newhash)
1025 SP->oldhash[lineno] = SP->newhash[lineno];
1027 #define ColorOf(n) (AttrOf(n) & A_COLOR)
1028 #define unColor(n) (AttrOf(n) & ALL_BUT_COLOR)
1030 * If we have colors, there is the possibility of having two color pairs
1031 * that display as the same colors. For instance, Lynx does this. Check
1032 * for this case, and update the old line with the new line's colors when
1033 * they are equivalent.
1041 for (n = 0; n < screen_columns; n++) {
1042 if (!CharEq(newLine[n], oldLine[n])) {
1043 oldColor = ColorOf(oldLine[n]);
1044 newColor = ColorOf(newLine[n]);
1045 if (oldColor != newColor
1046 && unColor(oldLine[n]) == unColor(newLine[n])) {
1047 oldPair = PAIR_NUMBER(oldColor);
1048 newPair = PAIR_NUMBER(newColor);
1049 if (oldPair < COLOR_PAIRS
1050 && newPair < COLOR_PAIRS
1051 && SP->_color_pairs[oldPair] == SP->_color_pairs[newPair]) {
1052 RemAttr(oldLine[n], A_COLOR);
1053 AddAttr(oldLine[n], ColorOf(newLine[n]));
1060 if (ceol_standout_glitch && clr_eol) {
1062 while (firstChar < screen_columns) {
1063 if (AttrOf(newLine[firstChar]) != AttrOf(oldLine[firstChar]))
1071 if (attrchanged) { /* we may have to disregard the whole line */
1072 GoTo(lineno, firstChar);
1073 ClrToEOL(ClrBlank(curscr), FALSE);
1074 PutRange(oldLine, newLine, lineno, 0, (screen_columns - 1));
1078 * This is a very simple loop to paint characters which may have the
1079 * magic cookie glitch embedded. It doesn't know much about video
1080 * attributes which are continued from one line to the next. It
1081 * assumes that we have filtered out requests for attribute changes
1082 * that do not get mapped to blank positions.
1084 * FIXME: we are not keeping track of where we put the cookies, so this
1085 * will work properly only once, since we may overwrite a cookie in a
1086 * following operation.
1088 } else if (magic_cookie_glitch > 0) {
1089 GoTo(lineno, firstChar);
1090 for (n = 0; n < screen_columns; n++) {
1091 int m = n + magic_cookie_glitch;
1093 /* check for turn-on:
1094 * If we are writing an attributed blank, where the
1095 * previous cell is not attributed.
1097 if (ISBLANK(newLine[n])
1099 && xmc_turn_on(newLine[n - 1], newLine[n]))
1102 && xmc_turn_on(xmc_new(lineno - 1, screen_columns - 1),
1107 PutChar(CHREF(newLine[n]));
1109 /* check for turn-off:
1110 * If we are writing an attributed non-blank, where the
1111 * next cell is blank, and not attributed.
1113 if (!ISBLANK(newLine[n])
1114 && ((n + 1 < screen_columns
1115 && xmc_turn_off(newLine[n], newLine[n + 1]))
1116 || (n + 1 >= screen_columns
1117 && lineno + 1 < screen_lines
1118 && xmc_turn_off(newLine[n], xmc_new(lineno + 1, 0))))) {
1127 /* find the first differing character */
1128 while (firstChar < screen_columns &&
1129 CharEq(newLine[firstChar], oldLine[firstChar]))
1132 /* if there wasn't one, we're done */
1133 if (firstChar >= screen_columns)
1136 /* it may be cheap to clear leading whitespace with clr_bol */
1137 if (clr_bol && (blank = newLine[0], can_clear_with(CHREF(blank)))) {
1138 int oFirstChar, nFirstChar;
1140 for (oFirstChar = 0; oFirstChar < screen_columns; oFirstChar++)
1141 if (!CharEq(oldLine[oFirstChar], blank))
1143 for (nFirstChar = 0; nFirstChar < screen_columns; nFirstChar++)
1144 if (!CharEq(newLine[nFirstChar], blank))
1147 if (nFirstChar > oFirstChar + SP->_el1_cost) {
1148 if (nFirstChar >= screen_columns && SP->_el_cost <= SP->_el1_cost) {
1150 UpdateAttrs(AttrOf(blank));
1151 TPUTS_TRACE("clr_eol");
1154 GoTo(lineno, nFirstChar - 1);
1155 UpdateAttrs(AttrOf(blank));
1156 TPUTS_TRACE("clr_bol");
1160 while (firstChar < nFirstChar)
1161 oldLine[firstChar++] = blank;
1163 if (firstChar >= screen_columns)
1168 blank = newLine[screen_columns - 1];
1170 if (!can_clear_with(CHREF(blank))) {
1171 /* find the last differing character */
1172 nLastChar = screen_columns - 1;
1174 while (nLastChar > firstChar
1175 && CharEq(newLine[nLastChar], oldLine[nLastChar]))
1178 if (nLastChar >= firstChar) {
1179 GoTo(lineno, firstChar);
1180 PutRange(oldLine, newLine, lineno, firstChar, nLastChar);
1181 memcpy(oldLine + firstChar,
1182 newLine + firstChar,
1183 (nLastChar - firstChar + 1) * sizeof(NCURSES_CH_T));
1188 /* find last non-blank character on old line */
1189 oLastChar = screen_columns - 1;
1190 while (oLastChar > firstChar && CharEq(oldLine[oLastChar], blank))
1193 /* find last non-blank character on new line */
1194 nLastChar = screen_columns - 1;
1195 while (nLastChar > firstChar && CharEq(newLine[nLastChar], blank))
1198 if ((nLastChar == firstChar)
1199 && (SP->_el_cost < (oLastChar - nLastChar))) {
1200 GoTo(lineno, firstChar);
1201 if (!CharEq(newLine[firstChar], blank))
1202 PutChar(CHREF(newLine[firstChar]));
1203 ClrToEOL(blank, FALSE);
1204 } else if ((nLastChar != oLastChar)
1205 && (!CharEq(newLine[nLastChar], oldLine[oLastChar])
1206 || !(_nc_idcok && has_ic()))) {
1207 GoTo(lineno, firstChar);
1208 if ((oLastChar - nLastChar) > SP->_el_cost) {
1209 if (PutRange(oldLine, newLine, lineno, firstChar, nLastChar))
1210 GoTo(lineno, nLastChar + 1);
1211 ClrToEOL(blank, FALSE);
1213 n = max(nLastChar, oLastChar);
1214 PutRange(oldLine, newLine, lineno, firstChar, n);
1217 int nLastNonblank = nLastChar;
1218 int oLastNonblank = oLastChar;
1220 /* find the last characters that really differ */
1221 /* can be -1 if no characters differ */
1222 while (CharEq(newLine[nLastChar], oldLine[oLastChar])) {
1223 /* don't split a wide char */
1224 if (isnac(newLine[nLastChar]) &&
1225 !CharEq(newLine[nLastChar - 1], oldLine[oLastChar - 1]))
1229 if (nLastChar == -1 || oLastChar == -1)
1233 n = min(oLastChar, nLastChar);
1234 if (n >= firstChar) {
1235 GoTo(lineno, firstChar);
1236 PutRange(oldLine, newLine, lineno, firstChar, n);
1239 if (oLastChar < nLastChar) {
1240 int m = max(nLastNonblank, oLastNonblank);
1241 GoTo(lineno, n + 1);
1242 if (InsCharCost(nLastChar - oLastChar)
1244 PutRange(oldLine, newLine, lineno, n + 1, m);
1246 InsStr(&newLine[n + 1], nLastChar - oLastChar);
1248 } else if (oLastChar > nLastChar) {
1249 GoTo(lineno, n + 1);
1250 if (DelCharCost(oLastChar - nLastChar)
1251 > SP->_el_cost + nLastNonblank - (n + 1)) {
1252 if (PutRange(oldLine, newLine, lineno,
1253 n + 1, nLastNonblank))
1254 GoTo(lineno, nLastNonblank + 1);
1255 ClrToEOL(blank, FALSE);
1258 * The delete-char sequence will
1259 * effectively shift in blanks from the
1260 * right margin of the screen. Ensure
1261 * that they are the right color by
1262 * setting the video attributes from
1263 * the last character on the row.
1265 UpdateAttrs(AttrOf(blank));
1266 DelChar(oLastChar - nLastChar);
1272 /* update the code's internal representation */
1273 if (screen_columns > firstChar)
1274 memcpy(oldLine + firstChar,
1275 newLine + firstChar,
1276 (screen_columns - firstChar) * sizeof(NCURSES_CH_T));
1280 ** ClearScreen(blank)
1282 ** Clear the physical screen and put cursor at home
1287 ClearScreen(NCURSES_CH_T blank)
1290 bool fast_clear = (clear_screen || clr_eos || clr_eol);
1292 TR(TRACE_UPDATE, ("ClearScreen() called"));
1294 #if NCURSES_EXT_FUNCS
1296 && !SP->_default_color) {
1297 _nc_do_color((int) COLOR_PAIR(SP->_current_attr), 0, FALSE, _nc_outch);
1298 if (!back_color_erase) {
1306 UpdateAttrs(AttrOf(blank));
1307 TPUTS_TRACE("clear_screen");
1309 SP->_cursrow = SP->_curscol = 0;
1310 position_check(SP->_cursrow, SP->_curscol, "ClearScreen");
1311 } else if (clr_eos) {
1312 SP->_cursrow = SP->_curscol = -1;
1315 UpdateAttrs(AttrOf(blank));
1316 TPUTS_TRACE("clr_eos");
1318 } else if (clr_eol) {
1319 SP->_cursrow = SP->_curscol = -1;
1321 UpdateAttrs(AttrOf(blank));
1322 for (i = 0; i < screen_lines; i++) {
1324 TPUTS_TRACE("clr_eol");
1330 UpdateAttrs(AttrOf(blank));
1331 for (i = 0; i < screen_lines; i++) {
1333 for (j = 0; j < screen_columns; j++)
1334 PutChar(CHREF(blank));
1339 for (i = 0; i < screen_lines; i++) {
1340 for (j = 0; j < screen_columns; j++)
1341 curscr->_line[i].text[j] = blank;
1344 TR(TRACE_UPDATE, ("screen cleared"));
1348 ** InsStr(line, count)
1350 ** Insert the count characters pointed to by line.
1355 InsStr(NCURSES_CH_T * line, int count)
1357 TR(TRACE_UPDATE, ("InsStr(%p,%d) called", line, count));
1359 /* Prefer parm_ich as it has the smallest cost - no need to shift
1360 * the whole line on each character. */
1361 /* The order must match that of InsCharCost. */
1363 TPUTS_TRACE("parm_ich");
1364 tputs(tparm(parm_ich, count), count, _nc_outch);
1366 PutAttrChar(CHREF(*line));
1370 } else if (enter_insert_mode && exit_insert_mode) {
1371 TPUTS_TRACE("enter_insert_mode");
1372 putp(enter_insert_mode);
1374 PutAttrChar(CHREF(*line));
1375 if (insert_padding) {
1376 TPUTS_TRACE("insert_padding");
1377 putp(insert_padding);
1382 TPUTS_TRACE("exit_insert_mode");
1383 putp(exit_insert_mode);
1386 TPUTS_TRACE("insert_character");
1387 putp(insert_character);
1388 PutAttrChar(CHREF(*line));
1389 if (insert_padding) {
1390 TPUTS_TRACE("insert_padding");
1391 putp(insert_padding);
1397 position_check(SP->_cursrow, SP->_curscol, "InsStr");
1403 ** Delete count characters at current position
1412 TR(TRACE_UPDATE, ("DelChar(%d) called, position = (%d,%d)", count,
1413 newscr->_cury, newscr->_curx));
1416 TPUTS_TRACE("parm_dch");
1417 tputs(tparm(parm_dch, count), count, _nc_outch);
1419 for (n = 0; n < count; n++) {
1420 TPUTS_TRACE("delete_character");
1421 putp(delete_character);
1427 ** _nc_outstr(char *str)
1429 ** Emit a string without waiting for update.
1432 NCURSES_EXPORT(void)
1433 _nc_outstr(const char *str)
1440 * Physical-scrolling support
1442 * This code was adapted from Keith Bostic's hardware scrolling
1443 * support for 4.4BSD curses. I (esr) translated it to use terminfo
1444 * capabilities, narrowed the call interface slightly, and cleaned
1445 * up some convoluted tests. I also added support for the memory_above
1446 * memory_below, and non_dest_scroll_region capabilities.
1448 * For this code to work, we must have either
1449 * change_scroll_region and scroll forward/reverse commands, or
1450 * insert and delete line capabilities.
1451 * When the scrolling region has been set, the cursor has to
1452 * be at the last line of the region to make the scroll up
1453 * happen, or on the first line of region to scroll down.
1455 * This code makes one aesthetic decision in the opposite way from
1456 * BSD curses. BSD curses preferred pairs of il/dl operations
1457 * over scrolls, allegedly because il/dl looked faster. We, on
1458 * the other hand, prefer scrolls because (a) they're just as fast
1459 * on many terminals and (b) using them avoids bouncing an
1460 * unchanged bottom section of the screen up and down, which is
1463 * (lav): added more cases, used dl/il when bot==maxy and in csr case.
1465 * I used assumption that capabilities il/il1/dl/dl1 work inside
1466 * changed scroll region not shifting screen contents outside of it.
1467 * If there are any terminals behaving different way, it would be
1468 * necessary to add some conditions to scroll_csr_forward/backward.
1471 /* Try to scroll up assuming given csr (miny, maxy). Returns ERR on failure */
1473 scroll_csr_forward(int n, int top, int bot, int miny, int maxy, NCURSES_CH_T blank)
1477 if (n == 1 && scroll_forward && top == miny && bot == maxy) {
1479 UpdateAttrs(AttrOf(blank));
1480 TPUTS_TRACE("scroll_forward");
1481 tputs(scroll_forward, 0, _nc_outch);
1482 } else if (n == 1 && delete_line && bot == maxy) {
1484 UpdateAttrs(AttrOf(blank));
1485 TPUTS_TRACE("delete_line");
1486 tputs(delete_line, 0, _nc_outch);
1487 } else if (parm_index && top == miny && bot == maxy) {
1489 UpdateAttrs(AttrOf(blank));
1490 TPUTS_TRACE("parm_index");
1491 tputs(tparm(parm_index, n, 0), n, _nc_outch);
1492 } else if (parm_delete_line && bot == maxy) {
1494 UpdateAttrs(AttrOf(blank));
1495 TPUTS_TRACE("parm_delete_line");
1496 tputs(tparm(parm_delete_line, n, 0), n, _nc_outch);
1497 } else if (scroll_forward && top == miny && bot == maxy) {
1499 UpdateAttrs(AttrOf(blank));
1500 for (i = 0; i < n; i++) {
1501 TPUTS_TRACE("scroll_forward");
1502 tputs(scroll_forward, 0, _nc_outch);
1504 } else if (delete_line && bot == maxy) {
1506 UpdateAttrs(AttrOf(blank));
1507 for (i = 0; i < n; i++) {
1508 TPUTS_TRACE("delete_line");
1509 tputs(delete_line, 0, _nc_outch);
1514 #if NCURSES_EXT_FUNCS
1517 for (i = 0; i < n; i++) {
1519 for (j = 0; j < screen_columns; j++)
1520 PutChar(CHREF(blank));
1527 /* Try to scroll down assuming given csr (miny, maxy). Returns ERR on failure */
1530 scroll_csr_backward(int n, int top, int bot, int miny, int maxy,
1535 if (n == 1 && scroll_reverse && top == miny && bot == maxy) {
1537 UpdateAttrs(AttrOf(blank));
1538 TPUTS_TRACE("scroll_reverse");
1539 tputs(scroll_reverse, 0, _nc_outch);
1540 } else if (n == 1 && insert_line && bot == maxy) {
1542 UpdateAttrs(AttrOf(blank));
1543 TPUTS_TRACE("insert_line");
1544 tputs(insert_line, 0, _nc_outch);
1545 } else if (parm_rindex && top == miny && bot == maxy) {
1547 UpdateAttrs(AttrOf(blank));
1548 TPUTS_TRACE("parm_rindex");
1549 tputs(tparm(parm_rindex, n, 0), n, _nc_outch);
1550 } else if (parm_insert_line && bot == maxy) {
1552 UpdateAttrs(AttrOf(blank));
1553 TPUTS_TRACE("parm_insert_line");
1554 tputs(tparm(parm_insert_line, n, 0), n, _nc_outch);
1555 } else if (scroll_reverse && top == miny && bot == maxy) {
1557 UpdateAttrs(AttrOf(blank));
1558 for (i = 0; i < n; i++) {
1559 TPUTS_TRACE("scroll_reverse");
1560 tputs(scroll_reverse, 0, _nc_outch);
1562 } else if (insert_line && bot == maxy) {
1564 UpdateAttrs(AttrOf(blank));
1565 for (i = 0; i < n; i++) {
1566 TPUTS_TRACE("insert_line");
1567 tputs(insert_line, 0, _nc_outch);
1572 #if NCURSES_EXT_FUNCS
1575 for (i = 0; i < n; i++) {
1577 for (j = 0; j < screen_columns; j++)
1578 PutChar(CHREF(blank));
1585 /* scroll by using delete_line at del and insert_line at ins */
1588 scroll_idl(int n, int del, int ins, NCURSES_CH_T blank)
1592 if (!((parm_delete_line || delete_line) && (parm_insert_line || insert_line)))
1596 UpdateAttrs(AttrOf(blank));
1597 if (n == 1 && delete_line) {
1598 TPUTS_TRACE("delete_line");
1599 tputs(delete_line, 0, _nc_outch);
1600 } else if (parm_delete_line) {
1601 TPUTS_TRACE("parm_delete_line");
1602 tputs(tparm(parm_delete_line, n, 0), n, _nc_outch);
1603 } else { /* if (delete_line) */
1604 for (i = 0; i < n; i++) {
1605 TPUTS_TRACE("delete_line");
1606 tputs(delete_line, 0, _nc_outch);
1611 UpdateAttrs(AttrOf(blank));
1612 if (n == 1 && insert_line) {
1613 TPUTS_TRACE("insert_line");
1614 tputs(insert_line, 0, _nc_outch);
1615 } else if (parm_insert_line) {
1616 TPUTS_TRACE("parm_insert_line");
1617 tputs(tparm(parm_insert_line, n, 0), n, _nc_outch);
1618 } else { /* if (insert_line) */
1619 for (i = 0; i < n; i++) {
1620 TPUTS_TRACE("insert_line");
1621 tputs(insert_line, 0, _nc_outch);
1629 _nc_scrolln(int n, int top, int bot, int maxy)
1630 /* scroll region from top to bot by n lines */
1632 NCURSES_CH_T blank = ClrBlank(stdscr);
1634 bool cursor_saved = FALSE;
1637 TR(TRACE_MOVE, ("mvcur_scrolln(%d, %d, %d, %d)", n, top, bot, maxy));
1641 * If we scroll, we might remove a cookie.
1643 if (magic_cookie_glitch > 0) {
1648 if (n > 0) { /* scroll up (forward) */
1650 * Explicitly clear if stuff pushed off top of region might
1651 * be saved by the terminal.
1653 res = scroll_csr_forward(n, top, bot, 0, maxy, blank);
1655 if (res == ERR && change_scroll_region) {
1656 if ((((n == 1 && scroll_forward) || parm_index)
1657 && (SP->_cursrow == bot || SP->_cursrow == bot - 1))
1658 && save_cursor && restore_cursor) {
1659 cursor_saved = TRUE;
1660 TPUTS_TRACE("save_cursor");
1661 tputs(save_cursor, 0, _nc_outch);
1663 TPUTS_TRACE("change_scroll_region");
1664 tputs(tparm(change_scroll_region, top, bot), 0, _nc_outch);
1666 TPUTS_TRACE("restore_cursor");
1667 tputs(restore_cursor, 0, _nc_outch);
1669 SP->_cursrow = SP->_curscol = -1;
1672 res = scroll_csr_forward(n, top, bot, top, bot, blank);
1674 TPUTS_TRACE("change_scroll_region");
1675 tputs(tparm(change_scroll_region, 0, maxy), 0, _nc_outch);
1676 SP->_cursrow = SP->_curscol = -1;
1679 if (res == ERR && _nc_idlok)
1680 res = scroll_idl(n, top, bot - n + 1, blank);
1683 * Clear the newly shifted-in text.
1686 && (non_dest_scroll_region || (memory_below && bot == maxy))) {
1687 NCURSES_CH_T blank2 = NewChar(BLANK_TEXT);
1688 if (bot == maxy && clr_eos) {
1692 for (i = 0; i < n; i++) {
1694 ClrToEOL(blank2, FALSE);
1699 } else { /* (n < 0) - scroll down (backward) */
1700 res = scroll_csr_backward(-n, top, bot, 0, maxy, blank);
1702 if (res == ERR && change_scroll_region) {
1703 if (top != 0 && (SP->_cursrow == top || SP->_cursrow == top - 1)
1704 && save_cursor && restore_cursor) {
1705 cursor_saved = TRUE;
1706 TPUTS_TRACE("save_cursor");
1707 tputs(save_cursor, 0, _nc_outch);
1709 TPUTS_TRACE("change_scroll_region");
1710 tputs(tparm(change_scroll_region, top, bot), 0, _nc_outch);
1712 TPUTS_TRACE("restore_cursor");
1713 tputs(restore_cursor, 0, _nc_outch);
1715 SP->_cursrow = SP->_curscol = -1;
1718 res = scroll_csr_backward(-n, top, bot, top, bot, blank);
1720 TPUTS_TRACE("change_scroll_region");
1721 tputs(tparm(change_scroll_region, 0, maxy), 0, _nc_outch);
1722 SP->_cursrow = SP->_curscol = -1;
1725 if (res == ERR && _nc_idlok)
1726 res = scroll_idl(-n, bot + n + 1, top, blank);
1729 * Clear the newly shifted-in text.
1732 && (non_dest_scroll_region || (memory_above && top == 0))) {
1733 NCURSES_CH_T blank2 = NewChar(BLANK_TEXT);
1734 for (i = 0; i < -n; i++) {
1736 ClrToEOL(blank2, FALSE);
1744 _nc_scroll_window(curscr, n, top, bot, blank);
1746 /* shift hash values too - they can be reused */
1747 _nc_scroll_oldhash(n, top, bot);
1752 NCURSES_EXPORT(void)
1753 _nc_screen_resume(void)
1755 /* make sure terminal is in a sane known state */
1756 SP->_current_attr = A_NORMAL;
1757 newscr->_clear = TRUE;
1759 /* reset color pairs and definitions */
1760 if (SP->_coloron || SP->_color_defs)
1763 /* restore user-defined colors, if any */
1764 if (SP->_color_defs < 0) {
1766 SP->_color_defs = -(SP->_color_defs);
1767 for (n = 0; n < SP->_color_defs; ++n) {
1768 if (SP->_color_table[n].init) {
1770 SP->_color_table[n].r,
1771 SP->_color_table[n].g,
1772 SP->_color_table[n].b);
1777 if (exit_attribute_mode)
1778 putp(exit_attribute_mode);
1780 /* turn off attributes */
1781 if (exit_alt_charset_mode)
1782 putp(exit_alt_charset_mode);
1783 if (exit_standout_mode)
1784 putp(exit_standout_mode);
1785 if (exit_underline_mode)
1786 putp(exit_underline_mode);
1788 if (exit_insert_mode)
1789 putp(exit_insert_mode);
1790 if (enter_am_mode && exit_am_mode)
1791 putp(auto_right_margin ? enter_am_mode : exit_am_mode);
1794 NCURSES_EXPORT(void)
1795 _nc_screen_init(void)
1797 _nc_screen_resume();
1800 /* wrap up screen handling */
1801 NCURSES_EXPORT(void)
1802 _nc_screen_wrap(void)
1804 UpdateAttrs(A_NORMAL);
1805 #if NCURSES_EXT_FUNCS
1807 && !SP->_default_color) {
1808 NCURSES_CH_T blank = NewChar(BLANK_TEXT);
1809 SP->_default_color = TRUE;
1810 _nc_do_color(-1, 0, FALSE, _nc_outch);
1811 SP->_default_color = FALSE;
1813 mvcur(SP->_cursrow, SP->_curscol, screen_lines - 1, 0);
1814 SP->_cursrow = screen_lines - 1;
1817 ClrToEOL(blank, TRUE);
1820 if (SP->_color_defs) {
1826 NCURSES_EXPORT(void)
1827 _nc_do_xmc_glitch(attr_t previous)
1829 attr_t chg = XMC_CHANGES(previous ^ SP->_current_attr);
1833 SP->_curscol += magic_cookie_glitch;
1834 if (SP->_curscol >= SP->_columns)
1836 TR(TRACE_UPDATE, ("bumped to %d,%d after cookie", SP->_cursrow, SP->_curscol));
1841 #endif /* USE_XMC_SUPPORT */