diff --git a/ncurses/tty/MKexpanded.sh b/ncurses/tty/MKexpanded.sh
new file mode 100755
index 0000000..bf9acf2
--- /dev/null
+++ b/ncurses/tty/MKexpanded.sh
@@ -0,0 +1,99 @@
+#! /bin/sh
+##############################################################################
+# Copyright (c) 1998-2000,2005 Free Software Foundation, Inc.                #
+#                                                                            #
+# Permission is hereby granted, free of charge, to any person obtaining a    #
+# copy of this software and associated documentation files (the "Software"), #
+# to deal in the Software without restriction, including without limitation  #
+# the rights to use, copy, modify, merge, publish, distribute, distribute    #
+# with modifications, sublicense, and/or sell copies of the Software, and to #
+# permit persons to whom the Software is furnished to do so, subject to the  #
+# following conditions:                                                      #
+#                                                                            #
+# The above copyright notice and this permission notice shall be included in #
+# all copies or substantial portions of the Software.                        #
+#                                                                            #
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
+# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
+# DEALINGS IN THE SOFTWARE.                                                  #
+#                                                                            #
+# Except as contained in this notice, the name(s) of the above copyright     #
+# holders shall not be used in advertising or otherwise to promote the sale, #
+# use or other dealings in this Software without prior written               #
+# authorization.                                                             #
+##############################################################################
+#
+# Author: Thomas E. Dickey <dickey@clark.net> 1997
+#
+# $Id: MKexpanded.sh,v 1.11 2005/01/02 01:06:40 tom Exp $
+#
+# Script to generate 'expanded.c', a dummy source that contains functions
+# corresponding to complex macros used in this library.  By making functions,
+# we simplify analysis and debugging.
+
+if test $# != 0; then
+preprocessor="$1"
+else
+preprocessor="cc -E"
+fi
+shift
+if test $# != 0 ; then
+	preprocessor="$preprocessor $*"
+else
+	preprocessor="$preprocessor -DHAVE_CONFIG_H -I. -I../include"
+fi
+
+TMP=gen$$.c
+trap "rm -f $TMP" 0 1 2 5 15
+
+cat <<EOF
+/* generated by MKexpanded.sh */
+#include <curses.priv.h>
+#include <term.h>
+#if NCURSES_EXPANDED
+EOF
+
+cat >$TMP <<EOF
+#include <ncurses_cfg.h>
+#undef NCURSES_EXPANDED /* this probably is set in ncurses_cfg.h */
+#include <curses.priv.h>
+/* these are names we'd like to see */
+#undef ALL_BUT_COLOR
+#undef PAIR_NUMBER
+#undef TRUE
+#undef FALSE
+/* this is a marker */
+IGNORE
+NCURSES_EXPORT(void) _nc_toggle_attr_on (attr_t *S, attr_t at)
+{
+	toggle_attr_on(*S,at);
+}
+NCURSES_EXPORT(void) _nc_toggle_attr_off (attr_t *S, attr_t at) 
+{
+	toggle_attr_off(*S,at);
+}
+NCURSES_EXPORT(int) _nc_DelCharCost (int count)
+{
+	return DelCharCost(count);
+}
+NCURSES_EXPORT(int) _nc_InsCharCost (int count)
+{
+	return InsCharCost(count);
+}
+NCURSES_EXPORT(void) _nc_UpdateAttrs (NCURSES_CH_T c)
+{
+	UpdateAttrs(c);
+}
+EOF
+
+$preprocessor $TMP 2>/dev/null | sed -e '1,/^IGNORE$/d'
+
+cat <<EOF
+#else /* ! NCURSES_EXPANDED */
+NCURSES_EXPORT(void) _nc_expanded (void) { }
+#endif /* NCURSES_EXPANDED */
+EOF
diff --git a/ncurses/tty/hardscroll.c b/ncurses/tty/hardscroll.c
new file mode 100644
index 0000000..2c40997
--- /dev/null
+++ b/ncurses/tty/hardscroll.c
@@ -0,0 +1,328 @@
+/****************************************************************************
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "Software"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+
+/****************************************************************************
+ *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+ *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Thomas E. Dickey                        1996-on                 *
+ *     and: Alexander V Lukyanov                    1997-1998               *
+ ****************************************************************************/
+
+/******************************************************************************
+
+NAME
+   hardscroll.c -- hardware-scrolling optimization for ncurses
+
+SYNOPSIS
+   void _nc_scroll_optimize(void)
+
+DESCRIPTION
+			OVERVIEW
+
+This algorithm for computes optimum hardware scrolling to transform an
+old screen (curscr) into a new screen (newscr) via vertical line moves.
+
+Because the screen has a `grain' (there are insert/delete/scroll line
+operations but no insert/delete/scroll column operations), it is efficient
+break the update algorithm into two pieces: a first stage that does only line
+moves, optimizing the end product of user-invoked insertions, deletions, and
+scrolls; and a second phase (corresponding to the present doupdate code in
+ncurses) that does only line transformations.
+
+The common case we want hardware scrolling for is to handle line insertions
+and deletions in screen-oriented text-editors.  This two-stage approach will
+accomplish that at a low computation and code-size cost.
+
+			LINE-MOVE COMPUTATION
+
+Now, to a discussion of the line-move computation.
+
+For expository purposes, consider the screen lines to be represented by
+integers 0..23 (with the understanding that the value of 23 may vary).
+Let a new line introduced by insertion, scrolling, or at the bottom of
+the screen following a line delete be given the index -1.
+
+Assume that the real screen starts with lines 0..23.  Now, we have
+the following possible line-oriented operations on the screen:
+
+Insertion: inserts a line at a given screen row, forcing all lines below
+to scroll forward.  The last screen line is lost.  For example, an insertion
+at line 5 would produce: 0..4 -1 5..23.
+
+Deletion: deletes a line at a given screen row, forcing all lines below
+to scroll forward.  The last screen line is made new.  For example, a deletion
+at line 7 would produce: 0..6 8..23 -1.
+
+Scroll up: move a range of lines up 1.  The bottom line of the range
+becomes new.  For example, scrolling up the region from 9 to 14 will
+produce 0..8 10..14 -1 15..23.
+
+Scroll down: move a range of lines down 1.  The top line of the range
+becomes new.  For example, scrolling down the region from 12 to 16 will produce
+0..11 -1 12..15 17..23.
+
+Now, an obvious property of all these operations is that they preserve the
+order of old lines, though not their position in the sequence.
+
+The key trick of this algorithm is that the original line indices described
+above are actually maintained as _line[].oldindex fields in the window
+structure, and stick to each line through scroll and insert/delete operations.
+
+Thus, it is possible at update time to look at the oldnum fields and compute
+an optimal set of il/dl/scroll operations that will take the real screen
+lines to the virtual screen lines.  Once these vertical moves have been done,
+we can hand off to the second stage of the update algorithm, which does line
+transformations.
+
+Note that the move computation does not need to have the full generality
+of a diff algorithm (which it superficially resembles) because lines cannot
+be moved out of order.
+
+			THE ALGORITHM
+
+The scrolling is done in two passes. The first pass is from top to bottom
+scroling hunks UP. The second one is from bottom to top scrolling hunks DOWN.
+Obviously enough, no lines to be scrolled will be destroyed. (lav)
+
+HOW TO TEST THIS:
+
+Use the following production:
+
+hardscroll: hardscroll.c
+	$(CC) -g -DSCROLLDEBUG hardscroll.c -o hardscroll
+
+Then just type scramble vectors and watch.  The following test loads are
+a representative sample of cases:
+
+-----------------------------  CUT HERE ------------------------------------
+# No lines moved
+ 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
+#
+# A scroll up
+ 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 -1
+#
+# A scroll down
+-1  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22
+#
+# An insertion (after line 12)
+ 0  1  2  3  4  5  6  7  8  9 10 11 12 -1 13 14 15 16 17 18 19 20 21 22
+#
+# A simple deletion (line 10)
+ 0  1  2  3  4  5  6  7  8  9  11 12 13 14 15 16 17 18 19 20 21 22 23 -1
+#
+# A more complex case
+-1 -1 -1 -1 -1  3  4  5  6  7  -1 -1  8  9 10 11 12 13 14 15 16 17 -1 -1
+-----------------------------  CUT HERE ------------------------------------
+
+AUTHOR
+    Eric S. Raymond <esr@snark.thyrsus.com>, November 1994
+    New algorithm by Alexander V. Lukyanov <lav@yars.free.net>, Aug 1997
+
+*****************************************************************************/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: hardscroll.c,v 1.42 2008/08/03 23:49:30 tom Exp $")
+
+#if defined(SCROLLDEBUG) || defined(HASHDEBUG)
+
+# undef screen_lines
+# define screen_lines MAXLINES
+NCURSES_EXPORT_VAR(int)
+oldnums[MAXLINES];
+# define OLDNUM(n)	oldnums[n]
+# define _tracef	printf
+# undef TR
+# define TR(n, a)	if (_nc_tracing & (n)) { _tracef a ; putchar('\n'); }
+
+extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing;
+
+#else /* no debug */
+
+/* OLDNUM(n) indicates which line will be shifted to the position n.
+   if OLDNUM(n) == _NEWINDEX, then the line n in new, not shifted from
+   somewhere. */
+NCURSES_EXPORT_VAR(int *)
+_nc_oldnums = 0;		/* obsolete: keep for ABI compat */
+
+# if USE_HASHMAP
+#  define oldnums       SP->_oldnum_list
+#  define OLDNUM(n)	oldnums[n]
+# else				/* !USE_HASHMAP */
+#  define OLDNUM(n)	newscr->_line[n].oldindex
+# endif				/* !USE_HASHMAP */
+
+#define OLDNUM_SIZE     SP->_oldnum_size
+
+#endif /* defined(SCROLLDEBUG) || defined(HASHDEBUG) */
+
+NCURSES_EXPORT(void)
+_nc_scroll_optimize(void)
+/* scroll optimization to transform curscr to newscr */
+{
+    int i;
+    int start, end, shift;
+
+    TR(TRACE_ICALLS, (T_CALLED("_nc_scroll_optimize")));
+
+#if !defined(SCROLLDEBUG) && !defined(HASHDEBUG)
+#if USE_HASHMAP
+    /* get enough storage */
+    if (OLDNUM_SIZE < screen_lines) {
+	int *new_oldnums = typeRealloc(int, screen_lines, oldnums);
+	if (!new_oldnums)
+	    return;
+	oldnums = new_oldnums;
+	OLDNUM_SIZE = screen_lines;
+    }
+    /* calculate the indices */
+    _nc_hash_map();
+#endif
+#endif /* !defined(SCROLLDEBUG) && !defined(HASHDEBUG) */
+
+#ifdef TRACE
+    if (USE_TRACEF(TRACE_UPDATE | TRACE_MOVE)) {
+	_nc_linedump();
+	_nc_unlock_global(tracef);
+    }
+#endif /* TRACE */
+
+    /* pass 1 - from top to bottom scrolling up */
+    for (i = 0; i < screen_lines;) {
+	while (i < screen_lines && (OLDNUM(i) == _NEWINDEX || OLDNUM(i) <= i))
+	    i++;
+	if (i >= screen_lines)
+	    break;
+
+	shift = OLDNUM(i) - i;	/* shift > 0 */
+	start = i;
+
+	i++;
+	while (i < screen_lines && OLDNUM(i) != _NEWINDEX && OLDNUM(i) - i
+	       == shift)
+	    i++;
+	end = i - 1 + shift;
+
+	TR(TRACE_UPDATE | TRACE_MOVE, ("scroll [%d, %d] by %d", start, end, shift));
+#if !defined(SCROLLDEBUG) && !defined(HASHDEBUG)
+	if (_nc_scrolln(shift, start, end, screen_lines - 1) == ERR) {
+	    TR(TRACE_UPDATE | TRACE_MOVE, ("unable to scroll"));
+	    continue;
+	}
+#endif /* !defined(SCROLLDEBUG) && !defined(HASHDEBUG) */
+    }
+
+    /* pass 2 - from bottom to top scrolling down */
+    for (i = screen_lines - 1; i >= 0;) {
+	while (i >= 0 && (OLDNUM(i) == _NEWINDEX || OLDNUM(i) >= i))
+	    i--;
+	if (i < 0)
+	    break;
+
+	shift = OLDNUM(i) - i;	/* shift < 0 */
+	end = i;
+
+	i--;
+	while (i >= 0 && OLDNUM(i) != _NEWINDEX && OLDNUM(i) - i == shift)
+	    i--;
+	start = i + 1 - (-shift);
+
+	TR(TRACE_UPDATE | TRACE_MOVE, ("scroll [%d, %d] by %d", start, end, shift));
+#if !defined(SCROLLDEBUG) && !defined(HASHDEBUG)
+	if (_nc_scrolln(shift, start, end, screen_lines - 1) == ERR) {
+	    TR(TRACE_UPDATE | TRACE_MOVE, ("unable to scroll"));
+	    continue;
+	}
+#endif /* !defined(SCROLLDEBUG) && !defined(HASHDEBUG) */
+    }
+    TR(TRACE_ICALLS, (T_RETURN("")));
+}
+
+#if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG)
+NCURSES_EXPORT(void)
+_nc_linedump(void)
+/* dump the state of the real and virtual oldnum fields */
+{
+    int n;
+    char *buf = 0;
+    size_t want = (screen_lines + 1) * 4;
+
+    if ((buf = typeMalloc(char, want)) != 0) {
+
+	(void) strcpy(buf, "virt");
+	for (n = 0; n < screen_lines; n++)
+	    (void) sprintf(buf + strlen(buf), " %02d", OLDNUM(n));
+	TR(TRACE_UPDATE | TRACE_MOVE, (buf));
+	free(buf);
+    }
+}
+#endif /* defined(TRACE) || defined(SCROLLDEBUG) */
+
+#ifdef SCROLLDEBUG
+
+int
+main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+{
+    char line[BUFSIZ], *st;
+
+#ifdef TRACE
+    _nc_tracing = TRACE_MOVE;
+#endif
+    for (;;) {
+	int n;
+
+	for (n = 0; n < screen_lines; n++)
+	    oldnums[n] = _NEWINDEX;
+
+	/* grab the test vector */
+	if (fgets(line, sizeof(line), stdin) == (char *) NULL)
+	    exit(EXIT_SUCCESS);
+
+	/* parse it */
+	n = 0;
+	if (line[0] == '#') {
+	    (void) fputs(line, stderr);
+	    continue;
+	}
+	st = strtok(line, " ");
+	do {
+	    oldnums[n++] = atoi(st);
+	} while
+	    ((st = strtok((char *) NULL, " ")) != 0);
+
+	/* display it */
+	(void) fputs("Initial input:\n", stderr);
+	_nc_linedump();
+
+	_nc_scroll_optimize();
+    }
+}
+
+#endif /* SCROLLDEBUG */
+
+/* hardscroll.c ends here */
diff --git a/ncurses/tty/hashmap.c b/ncurses/tty/hashmap.c
new file mode 100644
index 0000000..9b60df6
--- /dev/null
+++ b/ncurses/tty/hashmap.c
@@ -0,0 +1,549 @@
+/****************************************************************************
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.                   *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "Software"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+
+/****************************************************************************
+ *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+ *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ ****************************************************************************/
+
+/******************************************************************************
+
+NAME
+   hashmap.c -- fill in scramble vector based on text hashes
+
+SYNOPSIS
+   void _nc_hash_map(void)
+
+DESCRIPTION:
+   This code attempts to recognize pairs of old and new lines in the physical
+and virtual screens.  When a line pair is recognized, the old line index is
+placed in the oldindex member of the virtual screen line, to be used by the
+vertical-motion optimizer portion of the update logic (see hardscroll.c).
+
+   Line pairs are recognized by applying a modified Heckel's algorithm,
+sped up by hashing.  If a line hash is unique in both screens, those
+lines must be a pair. Then if the lines just before or after the pair
+are the same or similar, they are a pair too.
+
+   We don't worry about false pairs produced by hash collisions, on the
+assumption that such cases are rare and will only make the latter stages
+of update less efficient, not introduce errors.
+
+HOW TO TEST THIS:
+
+Use the following production:
+
+hashmap: hashmap.c
+	$(CC) -g -DHASHDEBUG hashmap.c hardscroll.c ../objects/lib_trace.o -o hashmap
+
+AUTHOR
+    Eric S. Raymond <esr@snark.thyrsus.com>, May 1996
+    Bug fixes and improvements by Alexander V. Lukyanov <lav@yars.free.net>, 1997
+
+*****************************************************************************/
+
+#include <curses.priv.h>
+#include <term.h>		/* for back_color_erase */
+
+MODULE_ID("$Id: hashmap.c,v 1.56 2007/10/13 18:47:25 Miroslav.Lichvar Exp $")
+
+#ifdef HASHDEBUG
+
+# define _tracef	printf
+# undef TR
+# define TR(n, a)	if (_nc_tracing & (n)) { _tracef a ; putchar('\n'); }
+# undef screen_lines
+# define screen_lines MAXLINES
+# define TEXTWIDTH	1
+int oldnums[MAXLINES], reallines[MAXLINES];
+static NCURSES_CH_T oldtext[MAXLINES][TEXTWIDTH];
+static NCURSES_CH_T newtext[MAXLINES][TEXTWIDTH];
+# define OLDNUM(n)	oldnums[n]
+# define OLDTEXT(n)	oldtext[n]
+# define NEWTEXT(m)	newtext[m]
+# define PENDING(n)     1
+
+#else /* !HASHDEBUG */
+
+# define OLDNUM(n)	SP->_oldnum_list[n]
+# define OLDTEXT(n)	curscr->_line[n].text
+# define NEWTEXT(m)	newscr->_line[m].text
+# define TEXTWIDTH	(curscr->_maxx+1)
+# define PENDING(n)     (newscr->_line[n].firstchar != _NOCHANGE)
+
+#endif /* !HASHDEBUG */
+
+#define oldhash		(SP->oldhash)
+#define newhash		(SP->newhash)
+#define hashtab		(SP->hashtab)
+#define lines_alloc	(SP->hashtab_len)
+
+#if USE_WIDEC_SUPPORT
+#define HASH_VAL(ch) (ch.chars[0])
+#else
+#define HASH_VAL(ch) (ch)
+#endif
+
+static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT);
+
+static NCURSES_INLINE unsigned long
+hash(NCURSES_CH_T * text)
+{
+    int i;
+    NCURSES_CH_T ch;
+    unsigned long result = 0;
+    for (i = TEXTWIDTH; i > 0; i--) {
+	ch = *text++;
+	result += (result << 5) + HASH_VAL(ch);
+    }
+    return result;
+}
+
+/* approximate update cost */
+static int
+update_cost(NCURSES_CH_T * from, NCURSES_CH_T * to)
+{
+    int cost = 0;
+    int i;
+
+    for (i = TEXTWIDTH; i > 0; i--, from++, to++)
+	if (!(CharEq(*from, *to)))
+	    cost++;
+
+    return cost;
+}
+
+static int
+update_cost_from_blank(NCURSES_CH_T * to)
+{
+    int cost = 0;
+    int i;
+    NCURSES_CH_T blank = blankchar;
+
+    if (back_color_erase)
+	SetPair(blank, GetPair(stdscr->_nc_bkgd));
+
+    for (i = TEXTWIDTH; i > 0; i--, to++)
+	if (!(CharEq(blank, *to)))
+	    cost++;
+
+    return cost;
+}
+
+/*
+ * Returns true when moving line 'from' to line 'to' seems to be cost
+ * effective. 'blank' indicates whether the line 'to' would become blank.
+ */
+static NCURSES_INLINE bool
+cost_effective(const int from, const int to, const bool blank)
+{
+    int new_from;
+
+    if (from == to)
+	return FALSE;
+
+    new_from = OLDNUM(from);
+    if (new_from == _NEWINDEX)
+	new_from = from;
+
+    /*
+     * On the left side of >= is the cost before moving;
+     * on the right side -- cost after moving.
+     */
+    return (((blank ? update_cost_from_blank(NEWTEXT(to))
+	      : update_cost(OLDTEXT(to), NEWTEXT(to)))
+	     + update_cost(OLDTEXT(new_from), NEWTEXT(from)))
+	    >= ((new_from == from ? update_cost_from_blank(NEWTEXT(from))
+		 : update_cost(OLDTEXT(new_from), NEWTEXT(from)))
+		+ update_cost(OLDTEXT(from), NEWTEXT(to)))) ? TRUE : FALSE;
+}
+
+static void
+grow_hunks(void)
+{
+    int start, end, shift;
+    int back_limit, forward_limit;	/* limits for cells to fill */
+    int back_ref_limit, forward_ref_limit;	/* limits for refrences */
+    int i;
+    int next_hunk;
+
+    /*
+     * This is tricky part.  We have unique pairs to use as anchors.
+     * Use these to deduce the presence of spans of identical lines.
+     */
+    back_limit = 0;
+    back_ref_limit = 0;
+
+    i = 0;
+    while (i < screen_lines && OLDNUM(i) == _NEWINDEX)
+	i++;
+    for (; i < screen_lines; i = next_hunk) {
+	start = i;
+	shift = OLDNUM(i) - i;
+
+	/* get forward limit */
+	i = start + 1;
+	while (i < screen_lines && OLDNUM(i) != _NEWINDEX && OLDNUM(i) - i
+	       == shift)
+	    i++;
+	end = i;
+	while (i < screen_lines && OLDNUM(i) == _NEWINDEX)
+	    i++;
+	next_hunk = i;
+	forward_limit = i;
+	if (i >= screen_lines || OLDNUM(i) >= i)
+	    forward_ref_limit = i;
+	else
+	    forward_ref_limit = OLDNUM(i);
+
+	i = start - 1;
+	/* grow back */
+	if (shift < 0)
+	    back_limit = back_ref_limit + (-shift);
+	while (i >= back_limit) {
+	    if (newhash[i] == oldhash[i + shift]
+		|| cost_effective(i + shift, i, shift < 0)) {
+		OLDNUM(i) = i + shift;
+		TR(TRACE_UPDATE | TRACE_MOVE,
+		   ("connected new line %d to old line %d (backward continuation)",
+		    i, i + shift));
+	    } else {
+		TR(TRACE_UPDATE | TRACE_MOVE,
+		   ("not connecting new line %d to old line %d (backward continuation)",
+		    i, i + shift));
+		break;
+	    }
+	    i--;
+	}
+
+	i = end;
+	/* grow forward */
+	if (shift > 0)
+	    forward_limit = forward_ref_limit - shift;
+	while (i < forward_limit) {
+	    if (newhash[i] == oldhash[i + shift]
+		|| cost_effective(i + shift, i, shift > 0)) {
+		OLDNUM(i) = i + shift;
+		TR(TRACE_UPDATE | TRACE_MOVE,
+		   ("connected new line %d to old line %d (forward continuation)",
+		    i, i + shift));
+	    } else {
+		TR(TRACE_UPDATE | TRACE_MOVE,
+		   ("not connecting new line %d to old line %d (forward continuation)",
+		    i, i + shift));
+		break;
+	    }
+	    i++;
+	}
+
+	back_ref_limit = back_limit = i;
+	if (shift > 0)
+	    back_ref_limit += shift;
+    }
+}
+
+NCURSES_EXPORT(void)
+_nc_hash_map(void)
+{
+    HASHMAP *sp;
+    register int i;
+    int start, shift, size;
+
+    if (screen_lines > lines_alloc) {
+	if (hashtab)
+	    free(hashtab);
+	hashtab = typeMalloc(HASHMAP, (screen_lines + 1) * 2);
+	if (!hashtab) {
+	    if (oldhash) {
+		FreeAndNull(oldhash);
+	    }
+	    lines_alloc = 0;
+	    return;
+	}
+	lines_alloc = screen_lines;
+    }
+
+    if (oldhash && newhash) {
+	/* re-hash only changed lines */
+	for (i = 0; i < screen_lines; i++) {
+	    if (PENDING(i))
+		newhash[i] = hash(NEWTEXT(i));
+	}
+    } else {
+	/* re-hash all */
+	if (oldhash == 0)
+	    oldhash = typeCalloc(unsigned long, (unsigned) screen_lines);
+	if (newhash == 0)
+	    newhash = typeCalloc(unsigned long, (unsigned) screen_lines);
+	if (!oldhash || !newhash)
+	    return;		/* malloc failure */
+	for (i = 0; i < screen_lines; i++) {
+	    newhash[i] = hash(NEWTEXT(i));
+	    oldhash[i] = hash(OLDTEXT(i));
+	}
+    }
+
+#ifdef HASH_VERIFY
+    for (i = 0; i < screen_lines; i++) {
+	if (newhash[i] != hash(NEWTEXT(i)))
+	    fprintf(stderr, "error in newhash[%d]\n", i);
+	if (oldhash[i] != hash(OLDTEXT(i)))
+	    fprintf(stderr, "error in oldhash[%d]\n", i);
+    }
+#endif
+
+    /*
+     * Set up and count line-hash values.
+     */
+    memset(hashtab, '\0', sizeof(*hashtab) * (screen_lines + 1) * 2);
+    for (i = 0; i < screen_lines; i++) {
+	unsigned long hashval = oldhash[i];
+
+	for (sp = hashtab; sp->hashval; sp++)
+	    if (sp->hashval == hashval)
+		break;
+	sp->hashval = hashval;	/* in case this is a new entry */
+	sp->oldcount++;
+	sp->oldindex = i;
+    }
+    for (i = 0; i < screen_lines; i++) {
+	unsigned long hashval = newhash[i];
+
+	for (sp = hashtab; sp->hashval; sp++)
+	    if (sp->hashval == hashval)
+		break;
+	sp->hashval = hashval;	/* in case this is a new entry */
+	sp->newcount++;
+	sp->newindex = i;
+
+	OLDNUM(i) = _NEWINDEX;	/* initialize old indices array */
+    }
+
+    /*
+     * Mark line pairs corresponding to unique hash pairs.
+     *
+     * We don't mark lines with offset 0, because it can make fail
+     * extending hunks by cost_effective. Otherwise, it does not
+     * have any side effects.
+     */
+    for (sp = hashtab; sp->hashval; sp++)
+	if (sp->oldcount == 1 && sp->newcount == 1
+	    && sp->oldindex != sp->newindex) {
+	    TR(TRACE_UPDATE | TRACE_MOVE,
+	       ("new line %d is hash-identical to old line %d (unique)",
+		sp->newindex, sp->oldindex));
+	    OLDNUM(sp->newindex) = sp->oldindex;
+	}
+
+    grow_hunks();
+
+    /*
+     * Eliminate bad or impossible shifts -- this includes removing
+     * those hunks which could not grow because of conflicts, as well
+     * those which are to be moved too far, they are likely to destroy
+     * more than carry.
+     */
+    for (i = 0; i < screen_lines;) {
+	while (i < screen_lines && OLDNUM(i) == _NEWINDEX)
+	    i++;
+	if (i >= screen_lines)
+	    break;
+	start = i;
+	shift = OLDNUM(i) - i;
+	i++;
+	while (i < screen_lines && OLDNUM(i) != _NEWINDEX && OLDNUM(i) - i
+	       == shift)
+	    i++;
+	size = i - start;
+	if (size < 3 || size + min(size / 8, 2) < abs(shift)) {
+	    while (start < i) {
+		OLDNUM(start) = _NEWINDEX;
+		start++;
+	    }
+	}
+    }
+
+    /* After clearing invalid hunks, try grow the rest. */
+    grow_hunks();
+}
+
+NCURSES_EXPORT(void)
+_nc_make_oldhash(int i)
+{
+    if (oldhash)
+	oldhash[i] = hash(OLDTEXT(i));
+}
+
+NCURSES_EXPORT(void)
+_nc_scroll_oldhash(int n, int top, int bot)
+{
+    size_t size;
+    int i;
+
+    if (!oldhash)
+	return;
+
+    size = sizeof(*oldhash) * (bot - top + 1 - abs(n));
+    if (n > 0) {
+	memmove(oldhash + top, oldhash + top + n, size);
+	for (i = bot; i > bot - n; i--)
+	    oldhash[i] = hash(OLDTEXT(i));
+    } else {
+	memmove(oldhash + top - n, oldhash + top, size);
+	for (i = top; i < top - n; i++)
+	    oldhash[i] = hash(OLDTEXT(i));
+    }
+}
+
+#ifdef HASHDEBUG
+static void
+usage(void)
+{
+    static const char *table[] =
+    {
+	"hashmap test-driver",
+	"",
+	"#  comment",
+	"l  get initial line number vector",
+	"n  use following letters as text of new lines",
+	"o  use following letters as text of old lines",
+	"d  dump state of test arrays",
+	"h  apply hash mapper and see scroll optimization",
+	"?  this message"
+    };
+    size_t n;
+    for (n = 0; n < sizeof(table) / sizeof(table[0]); n++)
+	fprintf(stderr, "%s\n", table[n]);
+}
+
+int
+main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+{
+    char line[BUFSIZ], *st;
+    int n;
+
+    if (setupterm(NULL, fileno(stdout), (int *) 0) == ERR)
+	return EXIT_FAILURE;
+    (void) _nc_alloc_screen();
+
+    for (n = 0; n < screen_lines; n++) {
+	reallines[n] = n;
+	oldnums[n] = _NEWINDEX;
+	CharOf(oldtext[n][0]) = CharOf(newtext[n][0]) = '.';
+    }
+
+    if (isatty(fileno(stdin)))
+	usage();
+
+#ifdef TRACE
+    _nc_tracing = TRACE_MOVE;
+#endif
+    for (;;) {
+	/* grab a test command */
+	if (fgets(line, sizeof(line), stdin) == (char *) NULL)
+	    break;
+
+	switch (line[0]) {
+	case '#':		/* comment */
+	    (void) fputs(line, stderr);
+	    break;
+
+	case 'l':		/* get initial line number vector */
+	    for (n = 0; n < screen_lines; n++) {
+		reallines[n] = n;
+		oldnums[n] = _NEWINDEX;
+	    }
+	    n = 0;
+	    st = strtok(line, " ");
+	    do {
+		oldnums[n++] = atoi(st);
+	    } while
+		((st = strtok((char *) NULL, " ")) != 0);
+	    break;
+
+	case 'n':		/* use following letters as text of new lines */
+	    for (n = 0; n < screen_lines; n++)
+		CharOf(newtext[n][0]) = '.';
+	    for (n = 0; n < screen_lines; n++)
+		if (line[n + 1] == '\n')
+		    break;
+		else
+		    CharOf(newtext[n][0]) = line[n + 1];
+	    break;
+
+	case 'o':		/* use following letters as text of old lines */
+	    for (n = 0; n < screen_lines; n++)
+		CharOf(oldtext[n][0]) = '.';
+	    for (n = 0; n < screen_lines; n++)
+		if (line[n + 1] == '\n')
+		    break;
+		else
+		    CharOf(oldtext[n][0]) = line[n + 1];
+	    break;
+
+	case 'd':		/* dump state of test arrays */
+#ifdef TRACE
+	    _nc_linedump();
+#endif
+	    (void) fputs("Old lines: [", stdout);
+	    for (n = 0; n < screen_lines; n++)
+		putchar(CharOf(oldtext[n][0]));
+	    putchar(']');
+	    putchar('\n');
+	    (void) fputs("New lines: [", stdout);
+	    for (n = 0; n < screen_lines; n++)
+		putchar(CharOf(newtext[n][0]));
+	    putchar(']');
+	    putchar('\n');
+	    break;
+
+	case 'h':		/* apply hash mapper and see scroll optimization */
+	    _nc_hash_map();
+	    (void) fputs("Result:\n", stderr);
+#ifdef TRACE
+	    _nc_linedump();
+#endif
+	    _nc_scroll_optimize();
+	    (void) fputs("Done.\n", stderr);
+	    break;
+	default:
+	case '?':
+	    usage();
+	    break;
+	}
+    }
+#if NO_LEAKS
+    _nc_free_and_exit(EXIT_SUCCESS);
+#else
+    return EXIT_SUCCESS;
+#endif
+}
+
+#endif /* HASHDEBUG */
+
+/* hashmap.c ends here */
diff --git a/ncurses/tty/lib_mvcur.c b/ncurses/tty/lib_mvcur.c
new file mode 100644
index 0000000..8e66fa3
--- /dev/null
+++ b/ncurses/tty/lib_mvcur.c
@@ -0,0 +1,1249 @@
+/****************************************************************************
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "Software"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+
+/****************************************************************************
+ *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+ *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Thomas E. Dickey                        1996-on                 *
+ ****************************************************************************/
+
+/*
+**	lib_mvcur.c
+**
+**	The routines for moving the physical cursor and scrolling:
+**
+**		void _nc_mvcur_init(void)
+**
+**		void _nc_mvcur_resume(void)
+**
+**		int mvcur(int old_y, int old_x, int new_y, int new_x)
+**
+**		void _nc_mvcur_wrap(void)
+**
+** Comparisons with older movement optimizers:
+**    SVr3 curses mvcur() can't use cursor_to_ll or auto_left_margin.
+**    4.4BSD curses can't use cuu/cud/cuf/cub/hpa/vpa/tab/cbt for local
+** motions.  It doesn't use tactics based on auto_left_margin.  Weirdly
+** enough, it doesn't use its own hardware-scrolling routine to scroll up
+** destination lines for out-of-bounds addresses!
+**    old ncurses optimizer: less accurate cost computations (in fact,
+** it was broken and had to be commented out!).
+**
+** Compile with -DMAIN to build an interactive tester/timer for the movement
+** optimizer.  You can use it to investigate the optimizer's behavior.
+** You can also use it for tuning the formulas used to determine whether
+** or not full optimization is attempted.
+**
+** This code has a nasty tendency to find bugs in terminfo entries, because it
+** exercises the non-cup movement capabilities heavily.  If you think you've
+** found a bug, try deleting subsets of the following capabilities (arranged
+** in decreasing order of suspiciousness): it, tab, cbt, hpa, vpa, cuu, cud,
+** cuf, cub, cuu1, cud1, cuf1, cub1.  It may be that one or more are wrong.
+**
+** Note: you should expect this code to look like a resource hog in a profile.
+** That's because it does a lot of I/O, through the tputs() calls.  The I/O
+** cost swamps the computation overhead (and as machines get faster, this
+** will become even more true).  Comments in the test exerciser at the end
+** go into detail about tuning and how you can gauge the optimizer's
+** effectiveness.
+**/
+
+/****************************************************************************
+ *
+ * Constants and macros for optimizer tuning.
+ *
+ ****************************************************************************/
+
+/*
+ * The average overhead of a full optimization computation in character
+ * transmission times.  If it's too high, the algorithm will be a bit
+ * over-biased toward using cup rather than local motions; if it's too
+ * low, the algorithm may spend more time than is strictly optimal
+ * looking for non-cup motions.  Profile the optimizer using the `t'
+ * command of the exerciser (see below), and round to the nearest integer.
+ *
+ * Yes, I (esr) thought about computing expected overhead dynamically, say
+ * by derivation from a running average of optimizer times.  But the
+ * whole point of this optimization is to *decrease* the frequency of
+ * system calls. :-)
+ */
+#define COMPUTE_OVERHEAD	1	/* I use a 90MHz Pentium @ 9.6Kbps */
+
+/*
+ * LONG_DIST is the distance we consider to be just as costly to move over as a
+ * cup sequence is to emit.  In other words, it's the length of a cup sequence
+ * adjusted for average computation overhead.  The magic number is the length
+ * of "\033[yy;xxH", the typical cup sequence these days.
+ */
+#define LONG_DIST		(8 - COMPUTE_OVERHEAD)
+
+/*
+ * Tell whether a motion is optimizable by local motions.  Needs to be cheap to
+ * compute. In general, all the fast moves go to either the right or left edge
+ * of the screen.  So any motion to a location that is (a) further away than
+ * LONG_DIST and (b) further inward from the right or left edge than LONG_DIST,
+ * we'll consider nonlocal.
+ */
+#define NOT_LOCAL(fy, fx, ty, tx)	((tx > LONG_DIST) \
+ 		 && (tx < screen_columns - 1 - LONG_DIST) \
+		 && (abs(ty-fy) + abs(tx-fx) > LONG_DIST))
+
+/****************************************************************************
+ *
+ * External interfaces
+ *
+ ****************************************************************************/
+
+/*
+ * For this code to work OK, the following components must live in the
+ * screen structure:
+ *
+ *	int		_char_padding;	// cost of character put
+ *	int		_cr_cost;	// cost of (carriage_return)
+ *	int		_cup_cost;	// cost of (cursor_address)
+ *	int		_home_cost;	// cost of (cursor_home)
+ *	int		_ll_cost;	// cost of (cursor_to_ll)
+ *#if USE_HARD_TABS
+ *	int		_ht_cost;	// cost of (tab)
+ *	int		_cbt_cost;	// cost of (back_tab)
+ *#endif USE_HARD_TABS
+ *	int		_cub1_cost;	// cost of (cursor_left)
+ *	int		_cuf1_cost;	// cost of (cursor_right)
+ *	int		_cud1_cost;	// cost of (cursor_down)
+ *	int		_cuu1_cost;	// cost of (cursor_up)
+ *	int		_cub_cost;	// cost of (parm_cursor_left)
+ *	int		_cuf_cost;	// cost of (parm_cursor_right)
+ *	int		_cud_cost;	// cost of (parm_cursor_down)
+ *	int		_cuu_cost;	// cost of (parm_cursor_up)
+ *	int		_hpa_cost;	// cost of (column_address)
+ *	int		_vpa_cost;	// cost of (row_address)
+ *	int		_ech_cost;	// cost of (erase_chars)
+ *	int		_rep_cost;	// cost of (repeat_char)
+ *
+ * The USE_HARD_TABS switch controls whether it is reliable to use tab/backtabs
+ * for local motions.  On many systems, it's not, due to uncertainties about
+ * tab delays and whether or not tabs will be expanded in raw mode.  If you
+ * have parm_right_cursor, tab motions don't win you a lot anyhow.
+ */
+
+#include <curses.priv.h>
+#include <term.h>
+#include <ctype.h>
+
+MODULE_ID("$Id: lib_mvcur.c,v 1.113 2008/08/16 19:30:58 tom Exp $")
+
+#define WANT_CHAR(y, x)	SP->_newscr->_line[y].text[x]	/* desired state */
+#define BAUDRATE	cur_term->_baudrate	/* bits per second */
+
+#if defined(MAIN) || defined(NCURSES_TEST)
+#include <sys/time.h>
+
+static bool profiling = FALSE;
+static float diff;
+#endif /* MAIN */
+
+#define OPT_SIZE 512
+
+static int normalized_cost(const char *const cap, int affcnt);
+
+/****************************************************************************
+ *
+ * Initialization/wrapup (including cost pre-computation)
+ *
+ ****************************************************************************/
+
+#ifdef TRACE
+static int
+trace_cost_of(const char *capname, const char *cap, int affcnt)
+{
+    int result = _nc_msec_cost(cap, affcnt);
+    TR(TRACE_CHARPUT | TRACE_MOVE,
+       ("CostOf %s %d %s", capname, result, _nc_visbuf(cap)));
+    return result;
+}
+#define CostOf(cap,affcnt) trace_cost_of(#cap,cap,affcnt);
+
+static int
+trace_normalized_cost(const char *capname, const char *cap, int affcnt)
+{
+    int result = normalized_cost(cap, affcnt);
+    TR(TRACE_CHARPUT | TRACE_MOVE,
+       ("NormalizedCost %s %d %s", capname, result, _nc_visbuf(cap)));
+    return result;
+}
+#define NormalizedCost(cap,affcnt) trace_normalized_cost(#cap,cap,affcnt);
+
+#else
+
+#define CostOf(cap,affcnt) _nc_msec_cost(cap,affcnt);
+#define NormalizedCost(cap,affcnt) normalized_cost(cap,affcnt);
+
+#endif
+
+NCURSES_EXPORT(int)
+_nc_msec_cost(const char *const cap, int affcnt)
+/* compute the cost of a given operation */
+{
+    if (cap == 0)
+	return (INFINITY);
+    else {
+	const char *cp;
+	float cum_cost = 0.0;
+
+	for (cp = cap; *cp; cp++) {
+	    /* extract padding, either mandatory or required */
+	    if (cp[0] == '$' && cp[1] == '<' && strchr(cp, '>')) {
+		float number = 0.0;
+
+		for (cp += 2; *cp != '>'; cp++) {
+		    if (isdigit(UChar(*cp)))
+			number = number * 10 + (*cp - '0');
+		    else if (*cp == '*')
+			number *= affcnt;
+		    else if (*cp == '.' && (*++cp != '>') && isdigit(UChar(*cp)))
+			number += (*cp - '0') / 10.0;
+		}
+
+#if NCURSES_NO_PADDING
+		if (!GetNoPadding(SP))
+#endif
+		    cum_cost += number * 10;
+	    } else
+		cum_cost += SP->_char_padding;
+	}
+
+	return ((int) cum_cost);
+    }
+}
+
+static int
+normalized_cost(const char *const cap, int affcnt)
+/* compute the effective character-count for an operation (round up) */
+{
+    int cost = _nc_msec_cost(cap, affcnt);
+    if (cost != INFINITY)
+	cost = (cost + SP->_char_padding - 1) / SP->_char_padding;
+    return cost;
+}
+
+static void
+reset_scroll_region(void)
+/* Set the scroll-region to a known state (the default) */
+{
+    if (change_scroll_region) {
+	TPUTS_TRACE("change_scroll_region");
+	putp(TPARM_2(change_scroll_region, 0, screen_lines - 1));
+    }
+}
+
+NCURSES_EXPORT(void)
+_nc_mvcur_resume(void)
+/* what to do at initialization time and after each shellout */
+{
+    /* initialize screen for cursor access */
+    if (enter_ca_mode) {
+	TPUTS_TRACE("enter_ca_mode");
+	putp(enter_ca_mode);
+    }
+
+    /*
+     * Doing this here rather than in _nc_mvcur_wrap() ensures that
+     * ncurses programs will see a reset scroll region even if a
+     * program that messed with it died ungracefully.
+     *
+     * This also undoes the effects of terminal init strings that assume
+     * they know the screen size.  This is useful when you're running
+     * a vt100 emulation through xterm.
+     */
+    reset_scroll_region();
+    SP->_cursrow = SP->_curscol = -1;
+
+    /* restore cursor shape */
+    if (SP->_cursor != -1) {
+	int cursor = SP->_cursor;
+	SP->_cursor = -1;
+	curs_set(cursor);
+    }
+}
+
+NCURSES_EXPORT(void)
+_nc_mvcur_init(void)
+/* initialize the cost structure */
+{
+    if (isatty(fileno(SP->_ofp)))
+	SP->_char_padding = ((BAUDBYTE * 1000 * 10)
+			     / (BAUDRATE > 0 ? BAUDRATE : 9600));
+    else
+	SP->_char_padding = 1;	/* must be nonzero */
+    if (SP->_char_padding <= 0)
+	SP->_char_padding = 1;	/* must be nonzero */
+    TR(TRACE_CHARPUT | TRACE_MOVE, ("char_padding %d msecs", SP->_char_padding));
+
+    /* non-parameterized local-motion strings */
+    SP->_cr_cost = CostOf(carriage_return, 0);
+    SP->_home_cost = CostOf(cursor_home, 0);
+    SP->_ll_cost = CostOf(cursor_to_ll, 0);
+#if USE_HARD_TABS
+    if (getenv("NCURSES_NO_HARD_TABS") == 0) {
+	SP->_ht_cost = CostOf(tab, 0);
+	SP->_cbt_cost = CostOf(back_tab, 0);
+    } else {
+	SP->_ht_cost = INFINITY;
+	SP->_cbt_cost = INFINITY;
+    }
+#endif /* USE_HARD_TABS */
+    SP->_cub1_cost = CostOf(cursor_left, 0);
+    SP->_cuf1_cost = CostOf(cursor_right, 0);
+    SP->_cud1_cost = CostOf(cursor_down, 0);
+    SP->_cuu1_cost = CostOf(cursor_up, 0);
+
+    SP->_smir_cost = CostOf(enter_insert_mode, 0);
+    SP->_rmir_cost = CostOf(exit_insert_mode, 0);
+    SP->_ip_cost = 0;
+    if (insert_padding) {
+	SP->_ip_cost = CostOf(insert_padding, 0);
+    }
+
+    /*
+     * Assumption: if the terminal has memory_relative addressing, the
+     * initialization strings or smcup will set single-page mode so we
+     * can treat it like absolute screen addressing.  This seems to be true
+     * for all cursor_mem_address terminal types in the terminfo database.
+     */
+    SP->_address_cursor = cursor_address ? cursor_address : cursor_mem_address;
+
+    /*
+     * Parametrized local-motion strings.  This static cost computation
+     * depends on the following assumptions:
+     *
+     * (1) They never have * padding.  In the entire master terminfo database
+     *     as of March 1995, only the obsolete Zenith Z-100 pc violates this.
+     *     (Proportional padding is found mainly in insert, delete and scroll
+     *     capabilities).
+     *
+     * (2) The average case of cup has two two-digit parameters.  Strictly,
+     *     the average case for a 24 * 80 screen has ((10*10*(1 + 1)) +
+     *     (14*10*(1 + 2)) + (10*70*(2 + 1)) + (14*70*4)) / (24*80) = 3.458
+     *     digits of parameters.  On a 25x80 screen the average is 3.6197.
+     *     On larger screens the value gets much closer to 4.
+     *
+     * (3) The average case of cub/cuf/hpa/ech/rep has 2 digits of parameters
+     *     (strictly, (((10 * 1) + (70 * 2)) / 80) = 1.8750).
+     *
+     * (4) The average case of cud/cuu/vpa has 2 digits of parameters
+     *     (strictly, (((10 * 1) + (14 * 2)) / 24) = 1.5833).
+     *
+     * All these averages depend on the assumption that all parameter values
+     * are equally probable.
+     */
+    SP->_cup_cost = CostOf(TPARM_2(SP->_address_cursor, 23, 23), 1);
+    SP->_cub_cost = CostOf(TPARM_1(parm_left_cursor, 23), 1);
+    SP->_cuf_cost = CostOf(TPARM_1(parm_right_cursor, 23), 1);
+    SP->_cud_cost = CostOf(TPARM_1(parm_down_cursor, 23), 1);
+    SP->_cuu_cost = CostOf(TPARM_1(parm_up_cursor, 23), 1);
+    SP->_hpa_cost = CostOf(TPARM_1(column_address, 23), 1);
+    SP->_vpa_cost = CostOf(TPARM_1(row_address, 23), 1);
+
+    /* non-parameterized screen-update strings */
+    SP->_ed_cost = NormalizedCost(clr_eos, 1);
+    SP->_el_cost = NormalizedCost(clr_eol, 1);
+    SP->_el1_cost = NormalizedCost(clr_bol, 1);
+    SP->_dch1_cost = NormalizedCost(delete_character, 1);
+    SP->_ich1_cost = NormalizedCost(insert_character, 1);
+
+    /*
+     * If this is a bce-terminal, we want to bias the choice so we use clr_eol
+     * rather than spaces at the end of a line.
+     */
+    if (back_color_erase)
+	SP->_el_cost = 0;
+
+    /* parameterized screen-update strings */
+    SP->_dch_cost = NormalizedCost(TPARM_1(parm_dch, 23), 1);
+    SP->_ich_cost = NormalizedCost(TPARM_1(parm_ich, 23), 1);
+    SP->_ech_cost = NormalizedCost(TPARM_1(erase_chars, 23), 1);
+    SP->_rep_cost = NormalizedCost(TPARM_2(repeat_char, ' ', 23), 1);
+
+    SP->_cup_ch_cost = NormalizedCost(TPARM_2(SP->_address_cursor, 23, 23), 1);
+    SP->_hpa_ch_cost = NormalizedCost(TPARM_1(column_address, 23), 1);
+    SP->_cuf_ch_cost = NormalizedCost(TPARM_1(parm_right_cursor, 23), 1);
+    SP->_inline_cost = min(SP->_cup_ch_cost,
+			   min(SP->_hpa_ch_cost,
+			       SP->_cuf_ch_cost));
+
+    /*
+     * If save_cursor is used within enter_ca_mode, we should not use it for
+     * scrolling optimization, since the corresponding restore_cursor is not
+     * nested on the various terminals (vt100, xterm, etc.) which use this
+     * feature.
+     */
+    if (save_cursor != 0
+	&& enter_ca_mode != 0
+	&& strstr(enter_ca_mode, save_cursor) != 0) {
+	T(("...suppressed sc/rc capability due to conflict with smcup/rmcup"));
+	save_cursor = 0;
+	restore_cursor = 0;
+    }
+
+    /*
+     * A different, possibly better way to arrange this would be to set
+     * SP->_endwin = TRUE at window initialization time and let this be
+     * called by doupdate's return-from-shellout code.
+     */
+    _nc_mvcur_resume();
+}
+
+NCURSES_EXPORT(void)
+_nc_mvcur_wrap(void)
+/* wrap up cursor-addressing mode */
+{
+    /* leave cursor at screen bottom */
+    mvcur(-1, -1, screen_lines - 1, 0);
+
+    /* set cursor to normal mode */
+    if (SP->_cursor != -1) {
+	int cursor = SP->_cursor;
+	curs_set(1);
+	SP->_cursor = cursor;
+    }
+
+    if (exit_ca_mode) {
+	TPUTS_TRACE("exit_ca_mode");
+	putp(exit_ca_mode);
+    }
+    /*
+     * Reset terminal's tab counter.  There's a long-time bug that
+     * if you exit a "curses" program such as vi or more, tab
+     * forward, and then backspace, the cursor doesn't go to the
+     * right place.  The problem is that the kernel counts the
+     * escape sequences that reset things as column positions.
+     * Utter a \r to reset this invisibly.
+     */
+    _nc_outch('\r');
+}
+
+/****************************************************************************
+ *
+ * Optimized cursor movement
+ *
+ ****************************************************************************/
+
+/*
+ * Perform repeated-append, returning cost
+ */
+static NCURSES_INLINE int
+repeated_append(string_desc * target, int total, int num, int repeat, const char *src)
+{
+    size_t need = repeat * strlen(src);
+
+    if (need < target->s_size) {
+	while (repeat-- > 0) {
+	    if (_nc_safe_strcat(target, src)) {
+		total += num;
+	    } else {
+		total = INFINITY;
+		break;
+	    }
+	}
+    } else {
+	total = INFINITY;
+    }
+    return total;
+}
+
+#ifndef NO_OPTIMIZE
+#define NEXTTAB(fr)	(fr + init_tabs - (fr % init_tabs))
+
+/*
+ * Assume back_tab (CBT) does not wrap backwards at the left margin, return
+ * a negative value at that point to simplify the loop.
+ */
+#define LASTTAB(fr)	((fr > 0) ? ((fr - 1) / init_tabs) * init_tabs : -1)
+
+static int
+relative_move(string_desc * target, int from_y, int from_x, int to_y, int
+	      to_x, bool ovw)
+/* move via local motions (cuu/cuu1/cud/cud1/cub1/cub/cuf1/cuf/vpa/hpa) */
+{
+    string_desc save;
+    int n, vcost = 0, hcost = 0;
+
+    (void) _nc_str_copy(&save, target);
+
+    if (to_y != from_y) {
+	vcost = INFINITY;
+
+	if (row_address != 0
+	    && _nc_safe_strcat(target, TPARM_1(row_address, to_y))) {
+	    vcost = SP->_vpa_cost;
+	}
+
+	if (to_y > from_y) {
+	    n = (to_y - from_y);
+
+	    if (parm_down_cursor
+		&& SP->_cud_cost < vcost
+		&& _nc_safe_strcat(_nc_str_copy(target, &save),
+				   TPARM_1(parm_down_cursor, n))) {
+		vcost = SP->_cud_cost;
+	    }
+
+	    if (cursor_down
+		&& (*cursor_down != '\n' || SP->_nl)
+		&& (n * SP->_cud1_cost < vcost)) {
+		vcost = repeated_append(_nc_str_copy(target, &save), 0,
+					SP->_cud1_cost, n, cursor_down);
+	    }
+	} else {		/* (to_y < from_y) */
+	    n = (from_y - to_y);
+
+	    if (parm_up_cursor
+		&& SP->_cuu_cost < vcost
+		&& _nc_safe_strcat(_nc_str_copy(target, &save),
+				   TPARM_1(parm_up_cursor, n))) {
+		vcost = SP->_cuu_cost;
+	    }
+
+	    if (cursor_up && (n * SP->_cuu1_cost < vcost)) {
+		vcost = repeated_append(_nc_str_copy(target, &save), 0,
+					SP->_cuu1_cost, n, cursor_up);
+	    }
+	}
+
+	if (vcost == INFINITY)
+	    return (INFINITY);
+    }
+
+    save = *target;
+
+    if (to_x != from_x) {
+	char str[OPT_SIZE];
+	string_desc check;
+
+	hcost = INFINITY;
+
+	if (column_address
+	    && _nc_safe_strcat(_nc_str_copy(target, &save),
+			       TPARM_1(column_address, to_x))) {
+	    hcost = SP->_hpa_cost;
+	}
+
+	if (to_x > from_x) {
+	    n = to_x - from_x;
+
+	    if (parm_right_cursor
+		&& SP->_cuf_cost < hcost
+		&& _nc_safe_strcat(_nc_str_copy(target, &save),
+				   TPARM_1(parm_right_cursor, n))) {
+		hcost = SP->_cuf_cost;
+	    }
+
+	    if (cursor_right) {
+		int lhcost = 0;
+
+		(void) _nc_str_init(&check, str, sizeof(str));
+
+#if USE_HARD_TABS
+		/* use hard tabs, if we have them, to do as much as possible */
+		if (init_tabs > 0 && tab) {
+		    int nxt, fr;
+
+		    for (fr = from_x; (nxt = NEXTTAB(fr)) <= to_x; fr = nxt) {
+			lhcost = repeated_append(&check, lhcost,
+						 SP->_ht_cost, 1, tab);
+			if (lhcost == INFINITY)
+			    break;
+		    }
+
+		    n = to_x - fr;
+		    from_x = fr;
+		}
+#endif /* USE_HARD_TABS */
+
+		if (n <= 0 || n >= (int) check.s_size)
+		    ovw = FALSE;
+#if BSD_TPUTS
+		/*
+		 * If we're allowing BSD-style padding in tputs, don't generate
+		 * a string with a leading digit.  Otherwise, that will be
+		 * interpreted as a padding value rather than sent to the
+		 * screen.
+		 */
+		if (ovw
+		    && n > 0
+		    && n < (int) check.s_size
+		    && vcost == 0
+		    && str[0] == '\0') {
+		    int wanted = CharOf(WANT_CHAR(to_y, from_x));
+		    if (is8bits(wanted) && isdigit(wanted))
+			ovw = FALSE;
+		}
+#endif
+		/*
+		 * If we have no attribute changes, overwrite is cheaper.
+		 * Note: must suppress this by passing in ovw = FALSE whenever
+		 * WANT_CHAR would return invalid data.  In particular, this
+		 * is true between the time a hardware scroll has been done
+		 * and the time the structure WANT_CHAR would access has been
+		 * updated.
+		 */
+		if (ovw) {
+		    int i;
+
+		    for (i = 0; i < n; i++) {
+			NCURSES_CH_T ch = WANT_CHAR(to_y, from_x + i);
+			if (!SameAttrOf(ch, SCREEN_ATTRS(SP))
+#if USE_WIDEC_SUPPORT
+			    || !Charable(ch)
+#endif
+			    ) {
+			    ovw = FALSE;
+			    break;
+			}
+		    }
+		}
+		if (ovw) {
+		    int i;
+
+		    for (i = 0; i < n; i++)
+			*check.s_tail++ = (char) CharOf(WANT_CHAR(to_y,
+								  from_x + i));
+		    *check.s_tail = '\0';
+		    check.s_size -= n;
+		    lhcost += n * SP->_char_padding;
+		} else {
+		    lhcost = repeated_append(&check, lhcost, SP->_cuf1_cost,
+					     n, cursor_right);
+		}
+
+		if (lhcost < hcost
+		    && _nc_safe_strcat(_nc_str_copy(target, &save), str)) {
+		    hcost = lhcost;
+		}
+	    }
+	} else {		/* (to_x < from_x) */
+	    n = from_x - to_x;
+
+	    if (parm_left_cursor
+		&& SP->_cub_cost < hcost
+		&& _nc_safe_strcat(_nc_str_copy(target, &save),
+				   TPARM_1(parm_left_cursor, n))) {
+		hcost = SP->_cub_cost;
+	    }
+
+	    if (cursor_left) {
+		int lhcost = 0;
+
+		(void) _nc_str_init(&check, str, sizeof(str));
+
+#if USE_HARD_TABS
+		if (init_tabs > 0 && back_tab) {
+		    int nxt, fr;
+
+		    for (fr = from_x; (nxt = LASTTAB(fr)) >= to_x; fr = nxt) {
+			lhcost = repeated_append(&check, lhcost,
+						 SP->_cbt_cost, 1, back_tab);
+			if (lhcost == INFINITY)
+			    break;
+		    }
+
+		    n = fr - to_x;
+		}
+#endif /* USE_HARD_TABS */
+
+		lhcost = repeated_append(&check, lhcost, SP->_cub1_cost, n, cursor_left);
+
+		if (lhcost < hcost
+		    && _nc_safe_strcat(_nc_str_copy(target, &save), str)) {
+		    hcost = lhcost;
+		}
+	    }
+	}
+
+	if (hcost == INFINITY)
+	    return (INFINITY);
+    }
+
+    return (vcost + hcost);
+}
+#endif /* !NO_OPTIMIZE */
+
+/*
+ * With the machinery set up above, it's conceivable that
+ * onscreen_mvcur could be modified into a recursive function that does
+ * an alpha-beta search of motion space, as though it were a chess
+ * move tree, with the weight function being boolean and the search
+ * depth equated to length of string.  However, this would jack up the
+ * computation cost a lot, especially on terminals without a cup
+ * capability constraining the search tree depth.  So we settle for
+ * the simpler method below.
+ */
+
+static NCURSES_INLINE int
+onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
+/* onscreen move from (yold, xold) to (ynew, xnew) */
+{
+    string_desc result;
+    char buffer[OPT_SIZE];
+    int tactic = 0, newcost, usecost = INFINITY;
+    int t5_cr_cost;
+
+#if defined(MAIN) || defined(NCURSES_TEST)
+    struct timeval before, after;
+
+    gettimeofday(&before, NULL);
+#endif /* MAIN */
+
+#define NullResult _nc_str_null(&result, sizeof(buffer))
+#define InitResult _nc_str_init(&result, buffer, sizeof(buffer))
+
+    /* tactic #0: use direct cursor addressing */
+    if (_nc_safe_strcpy(InitResult, TPARM_2(SP->_address_cursor, ynew, xnew))) {
+	tactic = 0;
+	usecost = SP->_cup_cost;
+
+#if defined(TRACE) || defined(NCURSES_TEST)
+	if (!(_nc_optimize_enable & OPTIMIZE_MVCUR))
+	    goto nonlocal;
+#endif /* TRACE */
+
+	/*
+	 * We may be able to tell in advance that the full optimization
+	 * will probably not be worth its overhead.  Also, don't try to
+	 * use local movement if the current attribute is anything but
+	 * A_NORMAL...there are just too many ways this can screw up
+	 * (like, say, local-movement \n getting mapped to some obscure
+	 * character because A_ALTCHARSET is on).
+	 */
+	if (yold == -1 || xold == -1 || NOT_LOCAL(yold, xold, ynew, xnew)) {
+#if defined(MAIN) || defined(NCURSES_TEST)
+	    if (!profiling) {
+		(void) fputs("nonlocal\n", stderr);
+		goto nonlocal;	/* always run the optimizer if profiling */
+	    }
+#else
+	    goto nonlocal;
+#endif /* MAIN */
+	}
+    }
+#ifndef NO_OPTIMIZE
+    /* tactic #1: use local movement */
+    if (yold != -1 && xold != -1
+	&& ((newcost = relative_move(NullResult, yold, xold, ynew, xnew,
+				     ovw)) != INFINITY)
+	&& newcost < usecost) {
+	tactic = 1;
+	usecost = newcost;
+    }
+
+    /* tactic #2: use carriage-return + local movement */
+    if (yold != -1 && carriage_return
+	&& ((newcost = relative_move(NullResult, yold, 0, ynew, xnew, ovw))
+	    != INFINITY)
+	&& SP->_cr_cost + newcost < usecost) {
+	tactic = 2;
+	usecost = SP->_cr_cost + newcost;
+    }
+
+    /* tactic #3: use home-cursor + local movement */
+    if (cursor_home
+	&& ((newcost = relative_move(NullResult, 0, 0, ynew, xnew, ovw)) != INFINITY)
+	&& SP->_home_cost + newcost < usecost) {
+	tactic = 3;
+	usecost = SP->_home_cost + newcost;
+    }
+
+    /* tactic #4: use home-down + local movement */
+    if (cursor_to_ll
+	&& ((newcost = relative_move(NullResult, screen_lines - 1, 0, ynew,
+				     xnew, ovw)) != INFINITY)
+	&& SP->_ll_cost + newcost < usecost) {
+	tactic = 4;
+	usecost = SP->_ll_cost + newcost;
+    }
+
+    /*
+     * tactic #5: use left margin for wrap to right-hand side,
+     * unless strange wrap behavior indicated by xenl might hose us.
+     */
+    t5_cr_cost = (xold > 0 ? SP->_cr_cost : 0);
+    if (auto_left_margin && !eat_newline_glitch
+	&& yold > 0 && cursor_left
+	&& ((newcost = relative_move(NullResult, yold - 1, screen_columns -
+				     1, ynew, xnew, ovw)) != INFINITY)
+	&& t5_cr_cost + SP->_cub1_cost + newcost < usecost) {
+	tactic = 5;
+	usecost = t5_cr_cost + SP->_cub1_cost + newcost;
+    }
+
+    /*
+     * These cases are ordered by estimated relative frequency.
+     */
+    if (tactic)
+	InitResult;
+    switch (tactic) {
+    case 1:
+	(void) relative_move(&result, yold, xold, ynew, xnew, ovw);
+	break;
+    case 2:
+	(void) _nc_safe_strcpy(&result, carriage_return);
+	(void) relative_move(&result, yold, 0, ynew, xnew, ovw);
+	break;
+    case 3:
+	(void) _nc_safe_strcpy(&result, cursor_home);
+	(void) relative_move(&result, 0, 0, ynew, xnew, ovw);
+	break;
+    case 4:
+	(void) _nc_safe_strcpy(&result, cursor_to_ll);
+	(void) relative_move(&result, screen_lines - 1, 0, ynew, xnew, ovw);
+	break;
+    case 5:
+	if (xold > 0)
+	    (void) _nc_safe_strcat(&result, carriage_return);
+	(void) _nc_safe_strcat(&result, cursor_left);
+	(void) relative_move(&result, yold - 1, screen_columns - 1, ynew,
+			     xnew, ovw);
+	break;
+    }
+#endif /* !NO_OPTIMIZE */
+
+  nonlocal:
+#if defined(MAIN) || defined(NCURSES_TEST)
+    gettimeofday(&after, NULL);
+    diff = after.tv_usec - before.tv_usec
+	+ (after.tv_sec - before.tv_sec) * 1000000;
+    if (!profiling)
+	(void) fprintf(stderr,
+		       "onscreen: %d microsec, %f 28.8Kbps char-equivalents\n",
+		       (int) diff, diff / 288);
+#endif /* MAIN */
+
+    if (usecost != INFINITY) {
+	TPUTS_TRACE("mvcur");
+	tputs(buffer, 1, _nc_outch);
+	SP->_cursrow = ynew;
+	SP->_curscol = xnew;
+	return (OK);
+    } else
+	return (ERR);
+}
+
+NCURSES_EXPORT(int)
+mvcur(int yold, int xold, int ynew, int xnew)
+/* optimized cursor move from (yold, xold) to (ynew, xnew) */
+{
+    NCURSES_CH_T oldattr;
+    int code;
+
+    TR(TRACE_CALLS | TRACE_MOVE, (T_CALLED("mvcur(%d,%d,%d,%d)"),
+				  yold, xold, ynew, xnew));
+
+    if (SP == 0) {
+	code = ERR;
+    } else if (yold == ynew && xold == xnew) {
+	code = OK;
+    } else {
+
+	/*
+	 * Most work here is rounding for terminal boundaries getting the
+	 * column position implied by wraparound or the lack thereof and
+	 * rolling up the screen to get ynew on the screen.
+	 */
+	if (xnew >= screen_columns) {
+	    ynew += xnew / screen_columns;
+	    xnew %= screen_columns;
+	}
+
+	/*
+	 * Force restore even if msgr is on when we're in an alternate
+	 * character set -- these have a strong tendency to screw up the CR &
+	 * LF used for local character motions!
+	 */
+	oldattr = SCREEN_ATTRS(SP);
+	if ((AttrOf(oldattr) & A_ALTCHARSET)
+	    || (AttrOf(oldattr) && !move_standout_mode)) {
+	    TR(TRACE_CHARPUT, ("turning off (%#lx) %s before move",
+			       (unsigned long) AttrOf(oldattr),
+			       _traceattr(AttrOf(oldattr))));
+	    (void) VIDATTR(A_NORMAL, 0);
+	}
+
+	if (xold >= screen_columns) {
+	    int l;
+
+	    if (SP->_nl) {
+		l = (xold + 1) / screen_columns;
+		yold += l;
+		if (yold >= screen_lines)
+		    l -= (yold - screen_lines - 1);
+
+		if (l > 0) {
+		    if (carriage_return) {
+			TPUTS_TRACE("carriage_return");
+			putp(carriage_return);
+		    } else
+			_nc_outch('\r');
+		    xold = 0;
+
+		    while (l > 0) {
+			if (newline) {
+			    TPUTS_TRACE("newline");
+			    putp(newline);
+			} else
+			    _nc_outch('\n');
+			l--;
+		    }
+		}
+	    } else {
+		/*
+		 * If caller set nonl(), we cannot really use newlines to
+		 * position to the next row.
+		 */
+		xold = -1;
+		yold = -1;
+	    }
+	}
+
+	if (yold > screen_lines - 1)
+	    yold = screen_lines - 1;
+	if (ynew > screen_lines - 1)
+	    ynew = screen_lines - 1;
+
+	/* destination location is on screen now */
+	code = onscreen_mvcur(yold, xold, ynew, xnew, TRUE);
+
+	/*
+	 * Restore attributes if we disabled them before moving.
+	 */
+	if (!SameAttrOf(oldattr, SCREEN_ATTRS(SP))) {
+	    TR(TRACE_CHARPUT, ("turning on (%#lx) %s after move",
+			       (unsigned long) AttrOf(oldattr),
+			       _traceattr(AttrOf(oldattr))));
+	    (void) VIDATTR(AttrOf(oldattr), GetPair(oldattr));
+	}
+    }
+    returnCode(code);
+}
+
+#if defined(TRACE) || defined(NCURSES_TEST)
+NCURSES_EXPORT_VAR(int) _nc_optimize_enable = OPTIMIZE_ALL;
+#endif
+
+#if defined(MAIN) || defined(NCURSES_TEST)
+/****************************************************************************
+ *
+ * Movement optimizer test code
+ *
+ ****************************************************************************/
+
+#include <tic.h>
+#include <dump_entry.h>
+#include <time.h>
+
+NCURSES_EXPORT_VAR(const char *) _nc_progname = "mvcur";
+
+static unsigned long xmits;
+
+/* these override lib_tputs.c */
+NCURSES_EXPORT(int)
+tputs(const char *string, int affcnt GCC_UNUSED, int (*outc) (int) GCC_UNUSED)
+/* stub tputs() that dumps sequences in a visible form */
+{
+    if (profiling)
+	xmits += strlen(string);
+    else
+	(void) fputs(_nc_visbuf(string), stdout);
+    return (OK);
+}
+
+NCURSES_EXPORT(int)
+putp(const char *string)
+{
+    return (tputs(string, 1, _nc_outch));
+}
+
+NCURSES_EXPORT(int)
+_nc_outch(int ch)
+{
+    putc(ch, stdout);
+    return OK;
+}
+
+NCURSES_EXPORT(int)
+delay_output(int ms GCC_UNUSED)
+{
+    return OK;
+}
+
+static char tname[PATH_MAX];
+
+static void
+load_term(void)
+{
+    (void) setupterm(tname, STDOUT_FILENO, NULL);
+}
+
+static int
+roll(int n)
+{
+    int i, j;
+
+    i = (RAND_MAX / n) * n;
+    while ((j = rand()) >= i)
+	continue;
+    return (j % n);
+}
+
+int
+main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+{
+    strcpy(tname, getenv("TERM"));
+    load_term();
+    _nc_setupscreen(lines, columns, stdout, FALSE, 0);
+    baudrate();
+
+    _nc_mvcur_init();
+    NC_BUFFERED(FALSE);
+
+    (void) puts("The mvcur tester.  Type ? for help");
+
+    fputs("smcup:", stdout);
+    putchar('\n');
+
+    for (;;) {
+	int fy, fx, ty, tx, n, i;
+	char buf[BUFSIZ], capname[BUFSIZ];
+
+	(void) fputs("> ", stdout);
+	(void) fgets(buf, sizeof(buf), stdin);
+
+	if (buf[0] == '?') {
+	    (void) puts("?                -- display this help message");
+	    (void)
+		puts("fy fx ty tx      -- (4 numbers) display (fy,fx)->(ty,tx) move");
+	    (void) puts("s[croll] n t b m -- display scrolling sequence");
+	    (void)
+		printf("r[eload]         -- reload terminal info for %s\n",
+		       termname());
+	    (void)
+		puts("l[oad] <term>    -- load terminal info for type <term>");
+	    (void) puts("d[elete] <cap>   -- delete named capability");
+	    (void) puts("i[nspect]        -- display terminal capabilities");
+	    (void)
+		puts("c[ost]           -- dump cursor-optimization cost table");
+	    (void) puts("o[optimize]      -- toggle movement optimization");
+	    (void)
+		puts("t[orture] <num>  -- torture-test with <num> random moves");
+	    (void) puts("q[uit]           -- quit the program");
+	} else if (sscanf(buf, "%d %d %d %d", &fy, &fx, &ty, &tx) == 4) {
+	    struct timeval before, after;
+
+	    putchar('"');
+
+	    gettimeofday(&before, NULL);
+	    mvcur(fy, fx, ty, tx);
+	    gettimeofday(&after, NULL);
+
+	    printf("\" (%ld msec)\n",
+		   (long) (after.tv_usec - before.tv_usec
+			   + (after.tv_sec - before.tv_sec)
+			   * 1000000));
+	} else if (sscanf(buf, "s %d %d %d %d", &fy, &fx, &ty, &tx) == 4) {
+	    struct timeval before, after;
+
+	    putchar('"');
+
+	    gettimeofday(&before, NULL);
+	    _nc_scrolln(fy, fx, ty, tx);
+	    gettimeofday(&after, NULL);
+
+	    printf("\" (%ld msec)\n",
+		   (long) (after.tv_usec - before.tv_usec + (after.tv_sec -
+							     before.tv_sec)
+			   * 1000000));
+	} else if (buf[0] == 'r') {
+	    (void) strcpy(tname, termname());
+	    load_term();
+	} else if (sscanf(buf, "l %s", tname) == 1) {
+	    load_term();
+	} else if (sscanf(buf, "d %s", capname) == 1) {
+	    struct name_table_entry const *np = _nc_find_entry(capname,
+							       _nc_get_hash_table(FALSE));
+
+	    if (np == NULL)
+		(void) printf("No such capability as \"%s\"\n", capname);
+	    else {
+		switch (np->nte_type) {
+		case BOOLEAN:
+		    cur_term->type.Booleans[np->nte_index] = FALSE;
+		    (void)
+			printf("Boolean capability `%s' (%d) turned off.\n",
+			       np->nte_name, np->nte_index);
+		    break;
+
+		case NUMBER:
+		    cur_term->type.Numbers[np->nte_index] = ABSENT_NUMERIC;
+		    (void) printf("Number capability `%s' (%d) set to -1.\n",
+				  np->nte_name, np->nte_index);
+		    break;
+
+		case STRING:
+		    cur_term->type.Strings[np->nte_index] = ABSENT_STRING;
+		    (void) printf("String capability `%s' (%d) deleted.\n",
+				  np->nte_name, np->nte_index);
+		    break;
+		}
+	    }
+	} else if (buf[0] == 'i') {
+	    dump_init((char *) NULL, F_TERMINFO, S_TERMINFO, 70, 0, FALSE);
+	    dump_entry(&cur_term->type, FALSE, TRUE, 0, 0);
+	    putchar('\n');
+	} else if (buf[0] == 'o') {
+	    if (_nc_optimize_enable & OPTIMIZE_MVCUR) {
+		_nc_optimize_enable &= ~OPTIMIZE_MVCUR;
+		(void) puts("Optimization is now off.");
+	    } else {
+		_nc_optimize_enable |= OPTIMIZE_MVCUR;
+		(void) puts("Optimization is now on.");
+	    }
+	}
+	/*
+	 * You can use the `t' test to profile and tune the movement
+	 * optimizer.  Use iteration values in three digits or more.
+	 * At above 5000 iterations the profile timing averages are stable
+	 * to within a millisecond or three.
+	 *
+	 * The `overhead' field of the report will help you pick a
+	 * COMPUTE_OVERHEAD figure appropriate for your processor and
+	 * expected line speed.  The `total estimated time' is
+	 * computation time plus a character-transmission time
+	 * estimate computed from the number of transmits and the baud
+	 * rate.
+	 *
+	 * Use this together with the `o' command to get a read on the
+	 * optimizer's effectiveness.  Compare the total estimated times
+	 * for `t' runs of the same length in both optimized and un-optimized
+	 * modes.  As long as the optimized times are less, the optimizer
+	 * is winning.
+	 */
+	else if (sscanf(buf, "t %d", &n) == 1) {
+	    float cumtime = 0.0, perchar;
+	    int speeds[] =
+	    {2400, 9600, 14400, 19200, 28800, 38400, 0};
+
+	    srand((unsigned) (getpid() + time((time_t *) 0)));
+	    profiling = TRUE;
+	    xmits = 0;
+	    for (i = 0; i < n; i++) {
+		/*
+		 * This does a move test between two random locations,
+		 * Random moves probably short-change the optimizer,
+		 * which will work better on the short moves probably
+		 * typical of doupdate()'s usage pattern.  Still,
+		 * until we have better data...
+		 */
+#ifdef FIND_COREDUMP
+		int from_y = roll(lines);
+		int to_y = roll(lines);
+		int from_x = roll(columns);
+		int to_x = roll(columns);
+
+		printf("(%d,%d) -> (%d,%d)\n", from_y, from_x, to_y, to_x);
+		mvcur(from_y, from_x, to_y, to_x);
+#else
+		mvcur(roll(lines), roll(columns), roll(lines), roll(columns));
+#endif /* FIND_COREDUMP */
+		if (diff)
+		    cumtime += diff;
+	    }
+	    profiling = FALSE;
+
+	    /*
+	     * Average milliseconds per character optimization time.
+	     * This is the key figure to watch when tuning the optimizer.
+	     */
+	    perchar = cumtime / n;
+
+	    (void) printf("%d moves (%ld chars) in %d msec, %f msec each:\n",
+			  n, xmits, (int) cumtime, perchar);
+
+	    for (i = 0; speeds[i]; i++) {
+		/*
+		 * Total estimated time for the moves, computation and
+		 * transmission both. Transmission time is an estimate
+		 * assuming 9 bits/char, 8 bits + 1 stop bit.
+		 */
+		float totalest = cumtime + xmits * 9 * 1e6 / speeds[i];
+
+		/*
+		 * Per-character optimization overhead in character transmits
+		 * at the current speed.  Round this to the nearest integer
+		 * to figure COMPUTE_OVERHEAD for the speed.
+		 */
+		float overhead = speeds[i] * perchar / 1e6;
+
+		(void)
+		    printf("%6d bps: %3.2f char-xmits overhead; total estimated time %15.2f\n",
+			   speeds[i], overhead, totalest);
+	    }
+	} else if (buf[0] == 'c') {
+	    (void) printf("char padding: %d\n", SP->_char_padding);
+	    (void) printf("cr cost: %d\n", SP->_cr_cost);
+	    (void) printf("cup cost: %d\n", SP->_cup_cost);
+	    (void) printf("home cost: %d\n", SP->_home_cost);
+	    (void) printf("ll cost: %d\n", SP->_ll_cost);
+#if USE_HARD_TABS
+	    (void) printf("ht cost: %d\n", SP->_ht_cost);
+	    (void) printf("cbt cost: %d\n", SP->_cbt_cost);
+#endif /* USE_HARD_TABS */
+	    (void) printf("cub1 cost: %d\n", SP->_cub1_cost);
+	    (void) printf("cuf1 cost: %d\n", SP->_cuf1_cost);
+	    (void) printf("cud1 cost: %d\n", SP->_cud1_cost);
+	    (void) printf("cuu1 cost: %d\n", SP->_cuu1_cost);
+	    (void) printf("cub cost: %d\n", SP->_cub_cost);
+	    (void) printf("cuf cost: %d\n", SP->_cuf_cost);
+	    (void) printf("cud cost: %d\n", SP->_cud_cost);
+	    (void) printf("cuu cost: %d\n", SP->_cuu_cost);
+	    (void) printf("hpa cost: %d\n", SP->_hpa_cost);
+	    (void) printf("vpa cost: %d\n", SP->_vpa_cost);
+	} else if (buf[0] == 'x' || buf[0] == 'q')
+	    break;
+	else
+	    (void) puts("Invalid command.");
+    }
+
+    (void) fputs("rmcup:", stdout);
+    _nc_mvcur_wrap();
+    putchar('\n');
+
+    return (0);
+}
+
+#endif /* MAIN */
+
+/* lib_mvcur.c ends here */
diff --git a/ncurses/tty/lib_tstp.c b/ncurses/tty/lib_tstp.c
new file mode 100644
index 0000000..06c8411
--- /dev/null
+++ b/ncurses/tty/lib_tstp.c
@@ -0,0 +1,389 @@
+/****************************************************************************
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "Software"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+
+/****************************************************************************
+ *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+ *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Thomas E. Dickey                        1995-on                 *
+ ****************************************************************************/
+
+/*
+**	lib_tstp.c
+**
+**	The routine _nc_signal_handler().
+**
+*/
+#include <curses.priv.h>
+
+#include <SigAction.h>
+
+#if SVR4_ACTION && !defined(_POSIX_SOURCE)
+#define _POSIX_SOURCE
+#endif
+
+MODULE_ID("$Id: lib_tstp.c,v 1.37 2008/05/03 16:24:56 tom Exp $")
+
+#if defined(SIGTSTP) && (HAVE_SIGACTION || HAVE_SIGVEC)
+#define USE_SIGTSTP 1
+#else
+#define USE_SIGTSTP 0
+#endif
+
+#ifdef TRACE
+static const char *
+signal_name(int sig)
+{
+    switch (sig) {
+    case SIGALRM:
+	return "SIGALRM";
+#ifdef SIGCONT
+    case SIGCONT:
+	return "SIGCONT";
+#endif
+    case SIGINT:
+	return "SIGINT";
+    case SIGQUIT:
+	return "SIGQUIT";
+    case SIGTERM:
+	return "SIGTERM";
+#ifdef SIGTSTP
+    case SIGTSTP:
+	return "SIGTSTP";
+#endif
+#ifdef SIGTTOU
+    case SIGTTOU:
+	return "SIGTTOU";
+#endif
+#ifdef SIGWINCH
+    case SIGWINCH:
+	return "SIGWINCH";
+#endif
+    default:
+	return "unknown signal";
+    }
+}
+#endif
+
+/*
+ * Note: This code is fragile!  Its problem is that different OSs
+ * handle restart of system calls interrupted by signals differently.
+ * The ncurses code needs signal-call restart to happen -- otherwise,
+ * interrupted wgetch() calls will return FAIL, probably making the
+ * application think the input stream has ended and it should
+ * terminate.  In particular, you know you have this problem if, when
+ * you suspend an ncurses-using lynx with ^Z and resume, it dies
+ * immediately.
+ *
+ * Default behavior of POSIX sigaction(2) is not to restart
+ * interrupted system calls, but Linux's sigaction does it anyway (at
+ * least, on and after the 1.1.47 I (esr) use).  Thus this code works
+ * OK under Linux.  The 4.4BSD sigaction(2) supports a (non-portable)
+ * SA_RESTART flag that forces the right behavior.  Thus, this code
+ * should work OK under BSD/OS, NetBSD, and FreeBSD (let us know if it
+ * does not).
+ *
+ * Stock System Vs (and anything else using a strict-POSIX
+ * sigaction(2) without SA_RESTART) may have a problem.  Possible
+ * solutions:
+ *
+ *    sigvec      restarts by default (SV_INTERRUPT flag to not restart)
+ *    signal      restarts by default in SVr4 (assuming you link with -lucb)
+ *                and BSD, but not SVr3.
+ *    sigset      restarts, but is only available under SVr4/Solaris.
+ *
+ * The signal(3) call is mandated by the ANSI standard, and its
+ * interaction with sigaction(2) is described in the POSIX standard
+ * (3.3.4.2, page 72,line 934).  According to section 8.1, page 191,
+ * however, signal(3) itself is not required by POSIX.1.  And POSIX is
+ * silent on whether it is required to restart signals.
+ *
+ * So.  The present situation is, we use sigaction(2) with no
+ * guarantee of restart anywhere but on Linux and BSD.  We could
+ * switch to signal(3) and collar Linux, BSD, and SVr4.  Any way
+ * we slice it, System V UNIXes older than SVr4 will probably lose
+ * (this may include XENIX).
+ *
+ * This implementation will probably be changed to use signal(3) in
+ * the future.  If nothing else, it's simpler...
+ */
+
+#if USE_SIGTSTP
+static void
+tstp(int dummy GCC_UNUSED)
+{
+    sigset_t mask, omask;
+    sigaction_t act, oact;
+
+#ifdef SIGTTOU
+    int sigttou_blocked;
+#endif
+
+    T(("tstp() called"));
+
+    /*
+     * The user may have changed the prog_mode tty bits, so save them.
+     *
+     * But first try to detect whether we still are in the foreground
+     * process group - if not, an interactive shell may already have
+     * taken ownership of the tty and modified the settings when our
+     * parent was stopped before us, and we would likely pick up the
+     * settings already modified by the shell.
+     */
+    if (SP != 0 && !SP->_endwin)	/* don't do this if we're not in curses */
+#if HAVE_TCGETPGRP
+	if (tcgetpgrp(STDIN_FILENO) == getpgrp())
+#endif
+	    def_prog_mode();
+
+    /*
+     * Block window change and timer signals.  The latter
+     * is because applications use timers to decide when
+     * to repaint the screen.
+     */
+    (void) sigemptyset(&mask);
+    (void) sigaddset(&mask, SIGALRM);
+#if USE_SIGWINCH
+    (void) sigaddset(&mask, SIGWINCH);
+#endif
+    (void) sigprocmask(SIG_BLOCK, &mask, &omask);
+
+#ifdef SIGTTOU
+    sigttou_blocked = sigismember(&omask, SIGTTOU);
+    if (!sigttou_blocked) {
+	(void) sigemptyset(&mask);
+	(void) sigaddset(&mask, SIGTTOU);
+	(void) sigprocmask(SIG_BLOCK, &mask, NULL);
+    }
+#endif
+
+    /*
+     * End window mode, which also resets the terminal state to the
+     * original (pre-curses) modes.
+     */
+    endwin();
+
+    /* Unblock SIGTSTP. */
+    (void) sigemptyset(&mask);
+    (void) sigaddset(&mask, SIGTSTP);
+#ifdef SIGTTOU
+    if (!sigttou_blocked) {
+	/* Unblock this too if it wasn't blocked on entry */
+	(void) sigaddset(&mask, SIGTTOU);
+    }
+#endif
+    (void) sigprocmask(SIG_UNBLOCK, &mask, NULL);
+
+    /* Now we want to resend SIGSTP to this process and suspend it */
+    act.sa_handler = SIG_DFL;
+    sigemptyset(&act.sa_mask);
+    act.sa_flags = 0;
+#ifdef SA_RESTART
+    act.sa_flags |= SA_RESTART;
+#endif /* SA_RESTART */
+    sigaction(SIGTSTP, &act, &oact);
+    kill(getpid(), SIGTSTP);
+
+    /* Process gets suspended...time passes...process resumes */
+
+    T(("SIGCONT received"));
+    sigaction(SIGTSTP, &oact, NULL);
+    flushinp();
+
+    /*
+     * If the user modified the tty state while suspended, he wants
+     * those changes to stick.  So save the new "default" terminal state.
+     */
+    def_shell_mode();
+
+    /*
+     * This relies on the fact that doupdate() will restore the
+     * program-mode tty state, and issue enter_ca_mode if need be.
+     */
+    doupdate();
+
+    /* Reset the signals. */
+    (void) sigprocmask(SIG_SETMASK, &omask, NULL);
+}
+#endif /* USE_SIGTSTP */
+
+static void
+cleanup(int sig)
+{
+    /*
+     * Actually, doing any sort of I/O from within an signal handler is
+     * "unsafe".  But we'll _try_ to clean up the screen and terminal
+     * settings on the way out.
+     */
+    if (!_nc_globals.cleanup_nested++
+	&& (sig == SIGINT
+	    || sig == SIGQUIT)) {
+#if HAVE_SIGACTION || HAVE_SIGVEC
+	sigaction_t act;
+	sigemptyset(&act.sa_mask);
+	act.sa_flags = 0;
+	act.sa_handler = SIG_IGN;
+	if (sigaction(sig, &act, NULL) == 0)
+#else
+	if (signal(sig, SIG_IGN) != SIG_ERR)
+#endif
+	{
+	    SCREEN *scan;
+	    for (each_screen(scan)) {
+		if (scan->_ofp != 0
+		    && isatty(fileno(scan->_ofp))) {
+		    scan->_cleanup = TRUE;
+		    scan->_outch = _nc_outch;
+		}
+		set_term(scan);
+		endwin();
+		if (SP)
+		    SP->_endwin = FALSE;	/* in case we have an atexit! */
+	    }
+	}
+    }
+    exit(EXIT_FAILURE);
+}
+
+#if USE_SIGWINCH
+static void
+sigwinch(int sig GCC_UNUSED)
+{
+    _nc_globals.have_sigwinch = 1;
+}
+#endif /* USE_SIGWINCH */
+
+/*
+ * If the given signal is still in its default state, set it to the given
+ * handler.
+ */
+static int
+CatchIfDefault(int sig, RETSIGTYPE (*handler) (int))
+{
+    int result;
+#if HAVE_SIGACTION || HAVE_SIGVEC
+    sigaction_t old_act;
+    sigaction_t new_act;
+
+    memset(&new_act, 0, sizeof(new_act));
+    sigemptyset(&new_act.sa_mask);
+#ifdef SA_RESTART
+#ifdef SIGWINCH
+    if (sig != SIGWINCH)
+#endif
+	new_act.sa_flags |= SA_RESTART;
+#endif /* SA_RESTART */
+    new_act.sa_handler = handler;
+
+    if (sigaction(sig, NULL, &old_act) == 0
+	&& (old_act.sa_handler == SIG_DFL
+	    || old_act.sa_handler == handler
+#if USE_SIGWINCH
+	    || (sig == SIGWINCH && old_act.sa_handler == SIG_IGN)
+#endif
+	)) {
+	(void) sigaction(sig, &new_act, NULL);
+	result = TRUE;
+    } else {
+	result = FALSE;
+    }
+#else /* !HAVE_SIGACTION */
+    RETSIGTYPE (*ohandler) (int);
+
+    ohandler = signal(sig, SIG_IGN);
+    if (ohandler == SIG_DFL
+	|| ohandler == handler
+#if USE_SIGWINCH
+	|| (sig == SIGWINCH && ohandler == SIG_IGN)
+#endif
+	) {
+	signal(sig, handler);
+	result = TRUE;
+    } else {
+	signal(sig, ohandler);
+	result = FALSE;
+    }
+#endif
+    T(("CatchIfDefault - will %scatch %s",
+       result ? "" : "not ", signal_name(sig)));
+    return result;
+}
+
+/*
+ * This is invoked once at the beginning (e.g., from 'initscr()'), to
+ * initialize the signal catchers, and thereafter when spawning a shell (and
+ * returning) to disable/enable the SIGTSTP (i.e., ^Z) catcher.
+ *
+ * If the application has already set one of the signals, we'll not modify it
+ * (during initialization).
+ *
+ * The XSI document implies that we shouldn't keep the SIGTSTP handler if
+ * the caller later changes its mind, but that doesn't seem correct.
+ */
+NCURSES_EXPORT(void)
+_nc_signal_handler(bool enable)
+{
+    T((T_CALLED("_nc_signal_handler(%d)"), enable));
+#if USE_SIGTSTP			/* Xenix 2.x doesn't have SIGTSTP, for example */
+    {
+	static bool ignore_tstp = FALSE;
+
+	if (!ignore_tstp) {
+	    static sigaction_t new_sigaction, old_sigaction;
+
+	    if (!enable) {
+		new_sigaction.sa_handler = SIG_IGN;
+		sigaction(SIGTSTP, &new_sigaction, &old_sigaction);
+	    } else if (new_sigaction.sa_handler != SIG_DFL) {
+		sigaction(SIGTSTP, &old_sigaction, NULL);
+	    } else if (sigaction(SIGTSTP, NULL, &old_sigaction) == 0
+		       && (old_sigaction.sa_handler == SIG_DFL)) {
+		sigemptyset(&new_sigaction.sa_mask);
+#ifdef SA_RESTART
+		new_sigaction.sa_flags |= SA_RESTART;
+#endif /* SA_RESTART */
+		new_sigaction.sa_handler = tstp;
+		(void) sigaction(SIGTSTP, &new_sigaction, NULL);
+	    } else {
+		ignore_tstp = TRUE;
+	    }
+	}
+    }
+#endif /* !USE_SIGTSTP */
+
+    if (!_nc_globals.init_signals) {
+	if (enable) {
+	    CatchIfDefault(SIGINT, cleanup);
+	    CatchIfDefault(SIGTERM, cleanup);
+#if USE_SIGWINCH
+	    CatchIfDefault(SIGWINCH, sigwinch);
+#endif
+	    _nc_globals.init_signals = TRUE;
+	}
+    }
+    returnVoid;
+}
diff --git a/ncurses/tty/lib_twait.c b/ncurses/tty/lib_twait.c
new file mode 100644
index 0000000..16d12ed
--- /dev/null
+++ b/ncurses/tty/lib_twait.c
@@ -0,0 +1,450 @@
+/****************************************************************************
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "Software"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+
+/****************************************************************************
+ *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+ *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Thomas E. Dickey                        1996-on                 *
+ ****************************************************************************/
+
+/*
+**	lib_twait.c
+**
+**	The routine _nc_timed_wait().
+**
+**	(This file was originally written by Eric Raymond; however except for
+**	comments, none of the original code remains - T.Dickey).
+*/
+
+#include <curses.priv.h>
+
+#if defined __HAIKU__ && defined __BEOS__
+#undef __BEOS__
+#endif
+
+#ifdef __BEOS__
+#undef false
+#undef true
+#include <OS.h>
+#endif
+
+#if USE_FUNC_POLL
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# endif
+#elif HAVE_SELECT
+# if HAVE_SYS_TIME_H && HAVE_SYS_TIME_SELECT
+#  include <sys/time.h>
+# endif
+# if HAVE_SYS_SELECT_H
+#  include <sys/select.h>
+# endif
+#endif
+
+#undef CUR
+
+MODULE_ID("$Id: lib_twait.c,v 1.59 2008/08/30 20:08:19 tom Exp $")
+
+static long
+_nc_gettime(TimeType * t0, bool first)
+{
+    long res;
+
+#if PRECISE_GETTIME
+    TimeType t1;
+    gettimeofday(&t1, (struct timezone *) 0);
+    if (first) {
+	*t0 = t1;
+	res = 0;
+    } else {
+	/* .tv_sec and .tv_usec are unsigned, be careful when subtracting */
+	if (t0->tv_usec > t1.tv_usec) {
+	    t1.tv_usec += 1000000;	/* Convert 1s in 1e6 microsecs */
+	    t1.tv_sec--;
+	}
+	res = (t1.tv_sec - t0->tv_sec) * 1000
+	    + (t1.tv_usec - t0->tv_usec) / 1000;
+    }
+#else
+    time_t t1 = time((time_t *) 0);
+    if (first) {
+	*t0 = t1;
+    }
+    res = (t1 - *t0) * 1000;
+#endif
+    TR(TRACE_IEVENT, ("%s time: %ld msec", first ? "get" : "elapsed", res));
+    return res;
+}
+
+#ifdef NCURSES_WGETCH_EVENTS
+NCURSES_EXPORT(int)
+_nc_eventlist_timeout(_nc_eventlist * evl)
+{
+    int event_delay = -1;
+    int n;
+
+    if (evl != 0) {
+
+	for (n = 0; n < evl->count; ++n) {
+	    _nc_event *ev = evl->events[n];
+
+	    if (ev->type == _NC_EVENT_TIMEOUT_MSEC) {
+		event_delay = ev->data.timeout_msec;
+		if (event_delay < 0)
+		    event_delay = INT_MAX;	/* FIXME Is this defined? */
+	    }
+	}
+    }
+    return event_delay;
+}
+#endif /* NCURSES_WGETCH_EVENTS */
+
+/*
+ * Wait a specified number of milliseconds, returning nonzero if the timer
+ * didn't expire before there is activity on the specified file descriptors.
+ * The file-descriptors are specified by the mode:
+ *	0 - none (absolute time)
+ *	1 - ncurses' normal input-descriptor
+ *	2 - mouse descriptor, if any
+ *	3 - either input or mouse.
+ *
+ * Experimental:  if NCURSES_WGETCH_EVENTS is defined, (mode & 4) determines
+ * whether to pay attention to evl argument.  If set, the smallest of
+ * millisecond and of timeout of evl is taken.
+ *
+ * We return a mask that corresponds to the mode (e.g., 2 for mouse activity).
+ *
+ * If the milliseconds given are -1, the wait blocks until activity on the
+ * descriptors.
+ */
+NCURSES_EXPORT(int)
+_nc_timed_wait(SCREEN *sp,
+	       int mode,
+	       int milliseconds,
+	       int *timeleft
+	       EVENTLIST_2nd(_nc_eventlist * evl))
+{
+    int fd;
+    int count;
+    int result = 0;
+    TimeType t0;
+
+#ifdef NCURSES_WGETCH_EVENTS
+    int timeout_is_event = 0;
+    int n;
+#endif
+
+#if USE_FUNC_POLL
+#define MIN_FDS 2
+    struct pollfd fd_list[MIN_FDS];
+    struct pollfd *fds = fd_list;
+#elif defined(__BEOS__)
+#elif HAVE_SELECT
+    fd_set set;
+#endif
+
+    long starttime, returntime;
+
+    TR(TRACE_IEVENT, ("start twait: %d milliseconds, mode: %d",
+		      milliseconds, mode));
+
+#ifdef NCURSES_WGETCH_EVENTS
+    if (mode & 4) {
+	int event_delay = _nc_eventlist_timeout(evl);
+
+	if (event_delay >= 0
+	    && (milliseconds >= event_delay || milliseconds < 0)) {
+	    milliseconds = event_delay;
+	    timeout_is_event = 1;
+	}
+    }
+#endif
+
+#if PRECISE_GETTIME && HAVE_NANOSLEEP
+  retry:
+#endif
+    starttime = _nc_gettime(&t0, TRUE);
+
+    count = 0;
+
+#ifdef NCURSES_WGETCH_EVENTS
+    if ((mode & 4) && evl)
+	evl->result_flags = 0;
+#endif
+
+#if USE_FUNC_POLL
+    memset(fd_list, 0, sizeof(fd_list));
+
+#ifdef NCURSES_WGETCH_EVENTS
+    if ((mode & 4) && evl)
+	fds = typeMalloc(struct pollfd, MIN_FDS + evl->count);
+#endif
+
+    if (mode & 1) {
+	fds[count].fd = sp->_ifd;
+	fds[count].events = POLLIN;
+	count++;
+    }
+    if ((mode & 2)
+	&& (fd = sp->_mouse_fd) >= 0) {
+	fds[count].fd = fd;
+	fds[count].events = POLLIN;
+	count++;
+    }
+#ifdef NCURSES_WGETCH_EVENTS
+    if ((mode & 4) && evl) {
+	for (n = 0; n < evl->count; ++n) {
+	    _nc_event *ev = evl->events[n];
+
+	    if (ev->type == _NC_EVENT_FILE
+		&& (ev->data.fev.flags & _NC_EVENT_FILE_READABLE)) {
+		fds[count].fd = ev->data.fev.fd;
+		fds[count].events = POLLIN;
+		count++;
+	    }
+	}
+    }
+#endif
+
+    result = poll(fds, (unsigned) count, milliseconds);
+
+#ifdef NCURSES_WGETCH_EVENTS
+    if ((mode & 4) && evl) {
+	int c;
+
+	if (!result)
+	    count = 0;
+
+	for (n = 0; n < evl->count; ++n) {
+	    _nc_event *ev = evl->events[n];
+
+	    if (ev->type == _NC_EVENT_FILE
+		&& (ev->data.fev.flags & _NC_EVENT_FILE_READABLE)) {
+		ev->data.fev.result = 0;
+		for (c = 0; c < count; c++)
+		    if (fds[c].fd == ev->data.fev.fd
+			&& fds[c].revents & POLLIN) {
+			ev->data.fev.result |= _NC_EVENT_FILE_READABLE;
+			evl->result_flags |= _NC_EVENT_FILE_READABLE;
+		    }
+	    } else if (ev->type == _NC_EVENT_TIMEOUT_MSEC
+		       && !result && timeout_is_event) {
+		evl->result_flags |= _NC_EVENT_TIMEOUT_MSEC;
+	    }
+	}
+    }
+
+    if (fds != fd_list)
+	free((char *) fds);
+
+#endif
+
+#elif defined(__BEOS__)
+    /*
+     * BeOS's select() is declared in socket.h, so the configure script does
+     * not see it.  That's just as well, since that function works only for
+     * sockets.  This (using snooze and ioctl) was distilled from Be's patch
+     * for ncurses which uses a separate thread to simulate select().
+     *
+     * FIXME: the return values from the ioctl aren't very clear if we get
+     * interrupted.
+     *
+     * FIXME: this assumes mode&1 if milliseconds < 0 (see lib_getch.c).
+     */
+    result = 0;
+    if (mode & 1) {
+	int step = (milliseconds < 0) ? 0 : 5000;
+	bigtime_t d;
+	bigtime_t useconds = milliseconds * 1000;
+	int n, howmany;
+
+	if (useconds <= 0)	/* we're here to go _through_ the loop */
+	    useconds = 1;
+
+	for (d = 0; d < useconds; d += step) {
+	    n = 0;
+	    howmany = ioctl(0, 'ichr', &n);
+	    if (howmany >= 0 && n > 0) {
+		result = 1;
+		break;
+	    }
+	    if (useconds > 1 && step > 0) {
+		snooze(step);
+		milliseconds -= (step / 1000);
+		if (milliseconds <= 0) {
+		    milliseconds = 0;
+		    break;
+		}
+	    }
+	}
+    } else if (milliseconds > 0) {
+	snooze(milliseconds * 1000);
+	milliseconds = 0;
+    }
+#elif HAVE_SELECT
+    /*
+     * select() modifies the fd_set arguments; do this in the
+     * loop.
+     */
+    FD_ZERO(&set);
+
+    if (mode & 1) {
+	FD_SET(sp->_ifd, &set);
+	count = sp->_ifd + 1;
+    }
+    if ((mode & 2)
+	&& (fd = sp->_mouse_fd) >= 0) {
+	FD_SET(fd, &set);
+	count = max(fd, count) + 1;
+    }
+#ifdef NCURSES_WGETCH_EVENTS
+    if ((mode & 4) && evl) {
+	for (n = 0; n < evl->count; ++n) {
+	    _nc_event *ev = evl->events[n];
+
+	    if (ev->type == _NC_EVENT_FILE
+		&& (ev->data.fev.flags & _NC_EVENT_FILE_READABLE)) {
+		FD_SET(ev->data.fev.fd, &set);
+		count = max(ev->data.fev.fd + 1, count);
+	    }
+	}
+    }
+#endif
+
+    if (milliseconds >= 0) {
+	struct timeval ntimeout;
+	ntimeout.tv_sec = milliseconds / 1000;
+	ntimeout.tv_usec = (milliseconds % 1000) * 1000;
+	result = select(count, &set, NULL, NULL, &ntimeout);
+    } else {
+	result = select(count, &set, NULL, NULL, NULL);
+    }
+
+#ifdef NCURSES_WGETCH_EVENTS
+    if ((mode & 4) && evl) {
+	evl->result_flags = 0;
+	for (n = 0; n < evl->count; ++n) {
+	    _nc_event *ev = evl->events[n];
+
+	    if (ev->type == _NC_EVENT_FILE
+		&& (ev->data.fev.flags & _NC_EVENT_FILE_READABLE)) {
+		ev->data.fev.result = 0;
+		if (FD_ISSET(ev->data.fev.fd, &set)) {
+		    ev->data.fev.result |= _NC_EVENT_FILE_READABLE;
+		    evl->result_flags |= _NC_EVENT_FILE_READABLE;
+		}
+	    } else if (ev->type == _NC_EVENT_TIMEOUT_MSEC
+		       && !result && timeout_is_event)
+		evl->result_flags |= _NC_EVENT_TIMEOUT_MSEC;
+	}
+    }
+#endif
+
+#endif /* USE_FUNC_POLL, etc */
+
+    returntime = _nc_gettime(&t0, FALSE);
+
+    if (milliseconds >= 0)
+	milliseconds -= (returntime - starttime);
+
+#ifdef NCURSES_WGETCH_EVENTS
+    if (evl) {
+	evl->result_flags = 0;
+	for (n = 0; n < evl->count; ++n) {
+	    _nc_event *ev = evl->events[n];
+
+	    if (ev->type == _NC_EVENT_TIMEOUT_MSEC) {
+		long diff = (returntime - starttime);
+		if (ev->data.timeout_msec <= diff)
+		    ev->data.timeout_msec = 0;
+		else
+		    ev->data.timeout_msec -= diff;
+	    }
+
+	}
+    }
+#endif
+
+#if PRECISE_GETTIME && HAVE_NANOSLEEP
+    /*
+     * If the timeout hasn't expired, and we've gotten no data,
+     * this is probably a system where 'select()' needs to be left
+     * alone so that it can complete.  Make this process sleep,
+     * then come back for more.
+     */
+    if (result == 0 && milliseconds > 100) {
+	napms(100);		/* FIXME: this won't be right if I recur! */
+	milliseconds -= 100;
+	goto retry;
+    }
+#endif
+
+    /* return approximate time left in milliseconds */
+    if (timeleft)
+	*timeleft = milliseconds;
+
+    TR(TRACE_IEVENT, ("end twait: returned %d (%d), remaining time %d msec",
+		      result, errno, milliseconds));
+
+    /*
+     * Both 'poll()' and 'select()' return the number of file descriptors
+     * that are active.  Translate this back to the mask that denotes which
+     * file-descriptors, so that we don't need all of this system-specific
+     * code everywhere.
+     */
+    if (result != 0) {
+	if (result > 0) {
+	    result = 0;
+#if USE_FUNC_POLL
+	    for (count = 0; count < MIN_FDS; count++) {
+		if ((mode & (1 << count))
+		    && (fds[count].revents & POLLIN)) {
+		    result |= (1 << count);
+		}
+	    }
+#elif defined(__BEOS__)
+	    result = 1;		/* redundant, but simple */
+#elif HAVE_SELECT
+	    if ((mode & 2)
+		&& (fd = sp->_mouse_fd) >= 0
+		&& FD_ISSET(fd, &set))
+		result |= 2;
+	    if ((mode & 1)
+		&& FD_ISSET(sp->_ifd, &set))
+		result |= 1;
+#endif
+	} else
+	    result = 0;
+    }
+#ifdef NCURSES_WGETCH_EVENTS
+    if ((mode & 4) && evl && evl->result_flags)
+	result |= 4;
+#endif
+
+    return (result);
+}
diff --git a/ncurses/tty/lib_vidattr.c b/ncurses/tty/lib_vidattr.c
new file mode 100644
index 0000000..ac2a74f
--- /dev/null
+++ b/ncurses/tty/lib_vidattr.c
@@ -0,0 +1,338 @@
+/****************************************************************************
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.              *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "Software"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+
+/****************************************************************************
+ *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+ *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Thomas E. Dickey                        1996 on                 *
+ ****************************************************************************/
+
+/*
+ *	vidputs(newmode, outc)
+ *
+ *	newmode is taken to be the logical 'or' of the symbols in curses.h
+ *	representing graphic renditions.  The terminal is set to be in all of
+ *	the given modes, if possible.
+ *
+ *	if the new attribute is normal
+ *		if exit-alt-char-set exists
+ *			emit it
+ *		emit exit-attribute-mode
+ *	else if set-attributes exists
+ *		use it to set exactly what you want
+ *	else
+ *		if exit-attribute-mode exists
+ *			turn off everything
+ *		else
+ *			turn off those which can be turned off and aren't in
+ *			newmode.
+ *		turn on each mode which should be on and isn't, one by one
+ *
+ *	NOTE that this algorithm won't achieve the desired mix of attributes
+ *	in some cases, but those are probably just those cases in which it is
+ *	actually impossible, anyway, so...
+ *
+ * 	NOTE that we cannot assume that there's no interaction between color
+ *	and other attribute resets.  So each time we reset color (or other
+ *	attributes) we'll have to be prepared to restore the other.
+ */
+
+#include <curses.priv.h>
+#include <term.h>
+
+MODULE_ID("$Id: lib_vidattr.c,v 1.49 2007/06/30 21:58:04 tom Exp $")
+
+#define doPut(mode) TPUTS_TRACE(#mode); tputs(mode, 1, outc)
+
+#define TurnOn(mask,mode) \
+	if ((turn_on & mask) && mode) { doPut(mode); }
+
+#define TurnOff(mask,mode) \
+	if ((turn_off & mask) && mode) { doPut(mode); turn_off &= ~mask; }
+
+	/* if there is no current screen, assume we *can* do color */
+#define SetColorsIf(why,old_attr) \
+	if (can_color && (why)) { \
+		int old_pair = PAIR_NUMBER(old_attr); \
+		TR(TRACE_ATTRS, ("old pair = %d -- new pair = %d", old_pair, pair)); \
+		if ((pair != old_pair) \
+		 || (fix_pair0 && (pair == 0)) \
+		 || (reverse ^ ((old_attr & A_REVERSE) != 0))) { \
+			_nc_do_color(old_pair, pair, reverse, outc); \
+		} \
+	}
+
+#define PreviousAttr _nc_prescreen.previous_attr
+
+NCURSES_EXPORT(int)
+vidputs(chtype newmode, int (*outc) (int))
+{
+    attr_t turn_on, turn_off;
+    int pair;
+    bool reverse = FALSE;
+    bool can_color = (SP == 0 || SP->_coloron);
+#if NCURSES_EXT_FUNCS
+    bool fix_pair0 = (SP != 0 && SP->_coloron && !SP->_default_color);
+#else
+#define fix_pair0 FALSE
+#endif
+
+    newmode &= A_ATTRIBUTES;
+    T((T_CALLED("vidputs(%s)"), _traceattr(newmode)));
+
+    /* this allows us to go on whether or not newterm() has been called */
+    if (SP)
+	PreviousAttr = AttrOf(SCREEN_ATTRS(SP));
+
+    TR(TRACE_ATTRS, ("previous attribute was %s", _traceattr(PreviousAttr)));
+
+    if ((SP != 0)
+	&& (magic_cookie_glitch > 0)) {
+#if USE_XMC_SUPPORT
+	static const chtype table[] =
+	{
+	    A_STANDOUT,
+	    A_UNDERLINE,
+	    A_REVERSE,
+	    A_BLINK,
+	    A_DIM,
+	    A_BOLD,
+	    A_INVIS,
+	    A_PROTECT,
+	};
+	unsigned n;
+	int used = 0;
+	int limit = (max_attributes <= 0) ? 1 : max_attributes;
+	chtype retain = 0;
+
+	/*
+	 * Limit the number of attribute bits set in the newmode according to
+	 * the terminfo max_attributes value.
+	 */
+	for (n = 0; n < SIZEOF(table); ++n) {
+	    if ((table[n] & SP->_ok_attributes) == 0) {
+		newmode &= ~table[n];
+	    } else if ((table[n] & newmode) != 0) {
+		if (used++ >= limit) {
+		    newmode &= ~table[n];
+		    if (newmode == retain)
+			break;
+		} else {
+		    retain = newmode;
+		}
+	    }
+	}
+#else
+	newmode &= ~(SP->_xmc_suppress);
+#endif
+	TR(TRACE_ATTRS, ("suppressed attribute is %s", _traceattr(newmode)));
+    }
+
+    /*
+     * If we have a terminal that cannot combine color with video
+     * attributes, use the colors in preference.
+     */
+    if (((newmode & A_COLOR) != 0
+	 || fix_pair0)
+	&& (no_color_video > 0)) {
+	/*
+	 * If we had chosen the A_xxx definitions to correspond to the
+	 * no_color_video mask, we could simply shift it up and mask off the
+	 * attributes.  But we did not (actually copied Solaris' definitions).
+	 * However, this is still simpler/faster than a lookup table.
+	 *
+	 * The 63 corresponds to A_STANDOUT, A_UNDERLINE, A_REVERSE, A_BLINK,
+	 * A_DIM, A_BOLD which are 1:1 with no_color_video.  The bits that
+	 * correspond to A_INVIS, A_PROTECT (192) must be shifted up 1 and
+	 * A_ALTCHARSET (256) down 2 to line up.  We use the NCURSES_BITS
+	 * macro so this will work properly for the wide-character layout.
+	 */
+	unsigned value = no_color_video;
+	attr_t mask = NCURSES_BITS((value & 63)
+				   | ((value & 192) << 1)
+				   | ((value & 256) >> 2), 8);
+
+	if ((mask & A_REVERSE) != 0
+	    && (newmode & A_REVERSE) != 0) {
+	    reverse = TRUE;
+	    mask &= ~A_REVERSE;
+	}
+	newmode &= ~mask;
+    }
+
+    if (newmode == PreviousAttr)
+	returnCode(OK);
+
+    pair = PAIR_NUMBER(newmode);
+
+    if (reverse) {
+	newmode &= ~A_REVERSE;
+    }
+
+    turn_off = (~newmode & PreviousAttr) & ALL_BUT_COLOR;
+    turn_on = (newmode & ~PreviousAttr) & ALL_BUT_COLOR;
+
+    SetColorsIf(((pair == 0) && !fix_pair0), PreviousAttr);
+
+    if (newmode == A_NORMAL) {
+	if ((PreviousAttr & A_ALTCHARSET) && exit_alt_charset_mode) {
+	    doPut(exit_alt_charset_mode);
+	    PreviousAttr &= ~A_ALTCHARSET;
+	}
+	if (PreviousAttr) {
+	    if (exit_attribute_mode) {
+		doPut(exit_attribute_mode);
+	    } else {
+		if (!SP || SP->_use_rmul) {
+		    TurnOff(A_UNDERLINE, exit_underline_mode);
+		}
+		if (!SP || SP->_use_rmso) {
+		    TurnOff(A_STANDOUT, exit_standout_mode);
+		}
+	    }
+	    PreviousAttr &= ALL_BUT_COLOR;
+	}
+
+	SetColorsIf((pair != 0) || fix_pair0, PreviousAttr);
+    } else if (set_attributes) {
+	if (turn_on || turn_off) {
+	    TPUTS_TRACE("set_attributes");
+	    tputs(tparm(set_attributes,
+			(newmode & A_STANDOUT) != 0,
+			(newmode & A_UNDERLINE) != 0,
+			(newmode & A_REVERSE) != 0,
+			(newmode & A_BLINK) != 0,
+			(newmode & A_DIM) != 0,
+			(newmode & A_BOLD) != 0,
+			(newmode & A_INVIS) != 0,
+			(newmode & A_PROTECT) != 0,
+			(newmode & A_ALTCHARSET) != 0), 1, outc);
+	    PreviousAttr &= ALL_BUT_COLOR;
+	}
+	SetColorsIf((pair != 0) || fix_pair0, PreviousAttr);
+    } else {
+
+	TR(TRACE_ATTRS, ("turning %s off", _traceattr(turn_off)));
+
+	TurnOff(A_ALTCHARSET, exit_alt_charset_mode);
+
+	if (!SP || SP->_use_rmul) {
+	    TurnOff(A_UNDERLINE, exit_underline_mode);
+	}
+
+	if (!SP || SP->_use_rmso) {
+	    TurnOff(A_STANDOUT, exit_standout_mode);
+	}
+
+	if (turn_off && exit_attribute_mode) {
+	    doPut(exit_attribute_mode);
+	    turn_on |= (newmode & ALL_BUT_COLOR);
+	    PreviousAttr &= ALL_BUT_COLOR;
+	}
+	SetColorsIf((pair != 0) || fix_pair0, PreviousAttr);
+
+	TR(TRACE_ATTRS, ("turning %s on", _traceattr(turn_on)));
+	/* *INDENT-OFF* */
+	TurnOn(A_ALTCHARSET,	enter_alt_charset_mode);
+	TurnOn(A_BLINK,		enter_blink_mode);
+	TurnOn(A_BOLD,		enter_bold_mode);
+	TurnOn(A_DIM,		enter_dim_mode);
+	TurnOn(A_REVERSE,	enter_reverse_mode);
+	TurnOn(A_STANDOUT,	enter_standout_mode);
+	TurnOn(A_PROTECT,	enter_protected_mode);
+	TurnOn(A_INVIS,		enter_secure_mode);
+	TurnOn(A_UNDERLINE,	enter_underline_mode);
+#if USE_WIDEC_SUPPORT
+	TurnOn(A_HORIZONTAL,	enter_horizontal_hl_mode);
+	TurnOn(A_LEFT,		enter_left_hl_mode);
+	TurnOn(A_LOW,		enter_low_hl_mode);
+	TurnOn(A_RIGHT,		enter_right_hl_mode);
+	TurnOn(A_TOP,		enter_top_hl_mode);
+	TurnOn(A_VERTICAL,	enter_vertical_hl_mode);
+#endif
+	/* *INDENT-ON* */
+
+    }
+
+    if (reverse)
+	newmode |= A_REVERSE;
+
+    if (SP)
+	SetAttr(SCREEN_ATTRS(SP), newmode);
+    else
+	PreviousAttr = newmode;
+
+    returnCode(OK);
+}
+
+NCURSES_EXPORT(int)
+vidattr(chtype newmode)
+{
+    T((T_CALLED("vidattr(%s)"), _traceattr(newmode)));
+
+    returnCode(vidputs(newmode, _nc_outch));
+}
+
+NCURSES_EXPORT(chtype)
+termattrs(void)
+{
+    chtype attrs = A_NORMAL;
+
+    T((T_CALLED("termattrs()")));
+    if (enter_alt_charset_mode)
+	attrs |= A_ALTCHARSET;
+
+    if (enter_blink_mode)
+	attrs |= A_BLINK;
+
+    if (enter_bold_mode)
+	attrs |= A_BOLD;
+
+    if (enter_dim_mode)
+	attrs |= A_DIM;
+
+    if (enter_reverse_mode)
+	attrs |= A_REVERSE;
+
+    if (enter_standout_mode)
+	attrs |= A_STANDOUT;
+
+    if (enter_protected_mode)
+	attrs |= A_PROTECT;
+
+    if (enter_secure_mode)
+	attrs |= A_INVIS;
+
+    if (enter_underline_mode)
+	attrs |= A_UNDERLINE;
+
+    if (SP->_coloron)
+	attrs |= A_COLOR;
+
+    returnChar(attrs);
+}
diff --git a/ncurses/tty/tty_display.h b/ncurses/tty/tty_display.h
new file mode 100644
index 0000000..4c45a08
--- /dev/null
+++ b/ncurses/tty/tty_display.h
@@ -0,0 +1,140 @@
+/****************************************************************************
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "Software"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ************************************************************************** */
+
+#ifndef TTY_DISPLAY_H
+#define TTY_DISPLAY_H 1
+
+/*
+ * $Id: tty_display.h,v 1.6 2005/01/01 23:41:12 tom Exp $
+ */
+extern NCURSES_EXPORT(bool) _nc_tty_beep (void);
+extern NCURSES_EXPORT(bool) _nc_tty_check_resize (void);
+extern NCURSES_EXPORT(bool) _nc_tty_cursor (int);
+extern NCURSES_EXPORT(bool) _nc_tty_flash (void);
+extern NCURSES_EXPORT(bool) _nc_tty_init_color (int,int,int,int);
+extern NCURSES_EXPORT(bool) _nc_tty_init_pair (int,int,int);
+extern NCURSES_EXPORT(bool) _nc_tty_slk_hide (bool);
+extern NCURSES_EXPORT(bool) _nc_tty_slk_update (int,const char *);
+extern NCURSES_EXPORT(bool) _nc_tty_start_color (void);
+extern NCURSES_EXPORT(void) _nc_tty_display_resume (void);
+extern NCURSES_EXPORT(void) _nc_tty_display_suspend (void);
+extern NCURSES_EXPORT(void) _nc_tty_dispose (void);	/* frees SP->_term */
+extern NCURSES_EXPORT(void) _nc_tty_switch_to (void);
+extern NCURSES_EXPORT(void) _nc_tty_update (void);
+
+struct tty_display_data {
+	int             _fifohold;      /* set if breakout marked           */
+	unsigned long   _current_attr;  /* terminal attribute current set   */
+	int             _cursrow;       /* physical cursor row (-1=unknown) */
+	int             _curscol;       /* physical cursor column           */
+
+	/* cursor movement costs; units are 10ths of milliseconds */
+	int             _char_padding;  /* cost of character put            */
+	int             _cr_cost;       /* cost of (carriage_return)        */
+	int             _cup_cost;      /* cost of (cursor_address)         */
+	int             _home_cost;     /* cost of (cursor_home)            */
+	int             _ll_cost;       /* cost of (cursor_to_ll)           */
+#if USE_HARD_TABS
+	int             _ht_cost;       /* cost of (tab)                    */
+	int             _cbt_cost;      /* cost of (backtab)                */
+#endif /* USE_HARD_TABS */
+	int             _cub1_cost;     /* cost of (cursor_left)            */
+	int             _cuf1_cost;     /* cost of (cursor_right)           */
+	int             _cud1_cost;     /* cost of (cursor_down)            */
+	int             _cuu1_cost;     /* cost of (cursor_up)              */
+	int             _cub_cost;      /* cost of (parm_cursor_left)       */
+	int             _cuf_cost;      /* cost of (parm_cursor_right)      */
+	int             _cud_cost;      /* cost of (parm_cursor_down)       */
+	int             _cuu_cost;      /* cost of (parm_cursor_up)         */
+	int             _hpa_cost;      /* cost of (column_address)         */
+	int             _vpa_cost;      /* cost of (row_address)            */
+	/* used in lib_doupdate.c, must be chars */
+	int             _ed_cost;       /* cost of (clr_eos)                */
+	int             _el_cost;       /* cost of (clr_eol)                */
+	int             _el1_cost;      /* cost of (clr_bol)                */
+	int             _dch1_cost;     /* cost of (delete_character)       */
+	int             _ich1_cost;     /* cost of (insert_character)       */
+	int             _dch_cost;      /* cost of (parm_dch)               */
+	int             _ich_cost;      /* cost of (parm_ich)               */
+	int             _ech_cost;      /* cost of (erase_chars)            */
+	int             _rep_cost;      /* cost of (repeat_char)            */
+	int             _hpa_ch_cost;   /* cost of (column_address)         */
+	int             _cup_ch_cost;   /* cost of (cursor_address)         */
+	int             _smir_cost;	/* cost of (enter_insert_mode)      */
+	int             _rmir_cost;	/* cost of (exit_insert_mode)       */
+	int             _ip_cost;       /* cost of (insert_padding)         */
+	/* used in lib_mvcur.c */
+	char *          _address_cursor;
+	int             _carriage_return_length;
+	int             _cursor_home_length;
+	int             _cursor_to_ll_length;
+
+	chtype          _xmc_suppress;  /* attributes to suppress if xmc     */
+	chtype          _xmc_triggers;  /* attributes to process if xmc      */
+
+	bool            _sig_winch;
+};
+
+
+#define DelCharCost(count) \
+		((parm_dch != 0) \
+		? D->_dch_cost \
+		: ((delete_character != 0) \
+			? (D->_dch1_cost * count) \
+			: INFINITY))
+
+#define InsCharCost(count) \
+		((parm_ich != 0) \
+		? D->_ich_cost \
+		: ((enter_insert_mode && exit_insert_mode) \
+		  ? D->_smir_cost + D->_rmir_cost + (D->_ip_cost * count) \
+		  : ((insert_character != 0) \
+		    ? ((D->_ich1_cost + D->_ip_cost) * count) \
+		    : INFINITY)))
+
+#if USE_XMC_SUPPORT
+#define UpdateAttrs(c)	if (!SameAttrOf(D->_current_attr, AttrOf(c))) { \
+				attr_t chg = D->_current_attr; \
+				vidattr(AttrOf(c)); \
+				if (magic_cookie_glitch > 0 \
+				 && XMC_CHANGES((chg ^ D->_current_attr))) { \
+					T(("%s @%d before glitch %d,%d", \
+						__FILE__, __LINE__, \
+						D->_cursrow, \
+						D->_curscol)); \
+					_nc_do_xmc_glitch(chg); \
+				} \
+			}
+#else
+#define UpdateAttrs(c)	if (!SameAttrOf(D->_current_attr, AttrOf(c))) \
+				vidattr(AttrOf(c));
+#endif
+
+#define XMC_CHANGES(c) ((c) & D->_xmc_suppress)
+
+#endif /* TTY_DISPLAY_H */
diff --git a/ncurses/tty/tty_input.h b/ncurses/tty/tty_input.h
new file mode 100644
index 0000000..e520793
--- /dev/null
+++ b/ncurses/tty/tty_input.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+ * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "Software"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+
+/*
+ * $Id: tty_input.h,v 1.2 2000/12/10 02:26:51 tom Exp $
+ */
+
+#ifndef TTY_INPUT_H
+#define TTY_INPUT_H 1
+
+extern NCURSES_EXPORT(bool) _nc_tty_mouse_mask (mmask_t);
+extern NCURSES_EXPORT(bool) _nc_tty_pending (void);
+extern NCURSES_EXPORT(int)  _nc_tty_next_event (int);
+extern NCURSES_EXPORT(void) _nc_tty_flags_changed (void);
+extern NCURSES_EXPORT(void) _nc_tty_flush (void);
+extern NCURSES_EXPORT(void) _nc_tty_input_resume (void);
+extern NCURSES_EXPORT(void) _nc_tty_input_suspend (void);
+
+struct tty_input_data {
+	int             _ifd;           /* input file ptr for screen        */
+	int             _keypad_xmit;   /* current terminal state           */
+	int             _meta_on;       /* current terminal state           */
+
+	/*
+	 * These are the data that support the mouse interface.
+	 */
+	bool            (*_mouse_event) (SCREEN *);
+	bool            (*_mouse_inline)(SCREEN *);
+	bool            (*_mouse_parse) (int);
+	void            (*_mouse_resume)(SCREEN *);
+	void            (*_mouse_wrap)  (SCREEN *);
+	int             _mouse_fd;      /* file-descriptor, if any */
+	int             mousetype;
+};
+
+#endif /* TTY_INPUT_H */
diff --git a/ncurses/tty/tty_update.c b/ncurses/tty/tty_update.c
new file mode 100644
index 0000000..6a3a0c8
--- /dev/null
+++ b/ncurses/tty/tty_update.c
@@ -0,0 +1,1976 @@
+/****************************************************************************
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "Software"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+
+/****************************************************************************
+ *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+ *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Thomas E. Dickey                        1996-on                 *
+ ****************************************************************************/
+
+/*-----------------------------------------------------------------
+ *
+ *	lib_doupdate.c
+ *
+ * 	The routine doupdate() and its dependents.
+ * 	All physical output is concentrated here (except _nc_outch()
+  *	in lib_tputs.c).
+ *
+ *-----------------------------------------------------------------*/
+
+#include <curses.priv.h>
+
+#if defined __HAIKU__ && defined __BEOS__
+#undef __BEOS__
+#endif
+
+#ifdef __BEOS__
+#undef false
+#undef true
+#include <OS.h>
+#endif
+
+#if defined(TRACE) && HAVE_SYS_TIMES_H && HAVE_TIMES
+#define USE_TRACE_TIMES 1
+#else
+#define USE_TRACE_TIMES 0
+#endif
+
+#if HAVE_SYS_TIME_H && HAVE_SYS_TIME_SELECT
+#include <sys/time.h>
+#endif
+
+#if USE_TRACE_TIMES
+#include <sys/times.h>
+#endif
+
+#if USE_FUNC_POLL
+#elif HAVE_SELECT
+#if HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#endif
+#endif
+
+#include <ctype.h>
+#include <term.h>
+
+MODULE_ID("$Id: tty_update.c,v 1.246 2008/08/30 20:08:19 tom Exp $")
+
+/*
+ * This define controls the line-breakout optimization.  Every once in a
+ * while during screen refresh, we want to check for input and abort the
+ * update if there's some waiting.  CHECK_INTERVAL controls the number of
+ * changed lines to be emitted between input checks.
+ *
+ * Note: Input-check-and-abort is no longer done if the screen is being
+ * updated from scratch.  This is a feature, not a bug.
+ */
+#define CHECK_INTERVAL	5
+
+#define FILL_BCE() (SP->_coloron && !SP->_default_color && !back_color_erase)
+
+static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT);
+static NCURSES_CH_T normal = NewChar(BLANK_TEXT);
+
+/*
+ * Enable checking to see if doupdate and friends are tracking the true
+ * cursor position correctly.  NOTE: this is a debugging hack which will
+ * work ONLY on ANSI-compatible terminals!
+ */
+/* #define POSITION_DEBUG */
+
+static NCURSES_INLINE NCURSES_CH_T ClrBlank(WINDOW *win);
+static int ClrBottom(int total);
+static void ClearScreen(NCURSES_CH_T blank);
+static void ClrUpdate(void);
+static void DelChar(int count);
+static void InsStr(NCURSES_CH_T * line, int count);
+static void TransformLine(int const lineno);
+
+#ifdef POSITION_DEBUG
+/****************************************************************************
+ *
+ * Debugging code.  Only works on ANSI-standard terminals.
+ *
+ ****************************************************************************/
+
+static void
+position_check(int expected_y, int expected_x, char *legend)
+/* check to see if the real cursor position matches the virtual */
+{
+    char buf[20];
+    char *s;
+    int y, x;
+
+    if (!_nc_tracing || (expected_y < 0 && expected_x < 0))
+	return;
+
+    _nc_flush();
+    memset(buf, '\0', sizeof(buf));
+    putp("\033[6n");		/* only works on ANSI-compatibles */
+    _nc_flush();
+    *(s = buf) = 0;
+    do {
+	int ask = sizeof(buf) - 1 - (s - buf);
+	int got = read(0, s, ask);
+	if (got == 0)
+	    break;
+	s += got;
+    } while (strchr(buf, 'R') == 0);
+    _tracef("probe returned %s", _nc_visbuf(buf));
+
+    /* try to interpret as a position report */
+    if (sscanf(buf, "\033[%d;%dR", &y, &x) != 2) {
+	_tracef("position probe failed in %s", legend);
+    } else {
+	if (expected_x < 0)
+	    expected_x = x - 1;
+	if (expected_y < 0)
+	    expected_y = y - 1;
+	if (y - 1 != expected_y || x - 1 != expected_x) {
+	    beep();
+	    tputs(tparm("\033[%d;%dH", expected_y + 1, expected_x + 1), 1, _nc_outch);
+	    _tracef("position seen (%d, %d) doesn't match expected one (%d, %d) in %s",
+		    y - 1, x - 1, expected_y, expected_x, legend);
+	} else {
+	    _tracef("position matches OK in %s", legend);
+	}
+    }
+}
+#else
+#define position_check(expected_y, expected_x, legend)	/* nothing */
+#endif /* POSITION_DEBUG */
+
+/****************************************************************************
+ *
+ * Optimized update code
+ *
+ ****************************************************************************/
+
+static NCURSES_INLINE void
+GoTo(int const row, int const col)
+{
+    TR(TRACE_MOVE, ("GoTo(%d, %d) from (%d, %d)",
+		    row, col, SP->_cursrow, SP->_curscol));
+
+    position_check(SP->_cursrow, SP->_curscol, "GoTo");
+
+    mvcur(SP->_cursrow, SP->_curscol, row, col);
+    position_check(SP->_cursrow, SP->_curscol, "GoTo2");
+}
+
+static NCURSES_INLINE void
+PutAttrChar(CARG_CH_T ch)
+{
+    int chlen = 1;
+    NCURSES_CH_T my_ch;
+    PUTC_DATA;
+    NCURSES_CH_T tilde;
+    NCURSES_CH_T attr = CHDEREF(ch);
+
+    TR(TRACE_CHARPUT, ("PutAttrChar(%s) at (%d, %d)",
+		       _tracech_t(ch),
+		       SP->_cursrow, SP->_curscol));
+#if USE_WIDEC_SUPPORT
+    /*
+     * If this is not a valid character, there is nothing more to do.
+     */
+    if (isWidecExt(CHDEREF(ch))) {
+	TR(TRACE_CHARPUT, ("...skip"));
+	return;
+    }
+    /*
+     * Determine the number of character cells which the 'ch' value will use
+     * on the screen.  It should be at least one.
+     */
+    if ((chlen = wcwidth(CharOf(CHDEREF(ch)))) <= 0) {
+	static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
+
+	/*
+	 * If the character falls into any of these special cases, do
+	 * not force the result to a blank:
+	 *
+	 * a) it is printable (this works around a bug in wcwidth()).
+	 * b) use_legacy_coding() has been called to modify the treatment
+	 *    of codes 128-255.
+	 * c) the acs_map[] has been initialized to allow codes 0-31
+	 *    to be rendered.  This supports Linux console's "PC"
+	 *    characters.  Codes 128-255 are allowed though this is
+	 *    not checked.
+	 */
+	if (is8bits(CharOf(CHDEREF(ch)))
+	    && (isprint(CharOf(CHDEREF(ch)))
+		|| (SP->_legacy_coding > 0 && CharOf(CHDEREF(ch)) >= 160)
+		|| (SP->_legacy_coding > 1 && CharOf(CHDEREF(ch)) >= 128)
+		|| (AttrOf(attr) & A_ALTCHARSET
+		    && ((CharOfD(ch) < ACS_LEN
+			 && SP->_acs_map != 0
+			 && SP->_acs_map[CharOfD(ch)] != 0)
+			|| (CharOfD(ch) >= 128))))) {
+	    ;
+	} else {
+	    ch = CHREF(blank);
+	    TR(TRACE_CHARPUT, ("forced to blank"));
+	}
+	chlen = 1;
+    }
+#endif
+
+    if ((AttrOf(attr) & A_ALTCHARSET)
+	&& SP->_acs_map != 0
+	&& CharOfD(ch) < ACS_LEN) {
+	my_ch = CHDEREF(ch);	/* work around const param */
+#if USE_WIDEC_SUPPORT
+	/*
+	 * This is crude & ugly, but works most of the time.  It checks if the
+	 * acs_chars string specified that we have a mapping for this
+	 * character, and uses the wide-character mapping when we expect the
+	 * normal one to be broken (by mis-design ;-).
+	 */
+	if (SP->_screen_acs_fix
+	    && SP->_screen_acs_map[CharOf(my_ch)]) {
+	    RemAttr(attr, A_ALTCHARSET);
+	    my_ch = _nc_wacs[CharOf(my_ch)];
+	}
+#endif
+	/*
+	 * If we (still) have alternate character set, it is the normal 8bit
+	 * flavor.  The _screen_acs_map[] array tells if the character was
+	 * really in acs_chars, needed because of the way wide/normal line
+	 * drawing flavors are integrated.
+	 */
+	if (AttrOf(attr) & A_ALTCHARSET) {
+	    int j = CharOfD(ch);
+	    chtype temp = UChar(SP->_acs_map[j]);
+
+	    if (!(SP->_screen_acs_map[j])) {
+		RemAttr(attr, A_ALTCHARSET);
+		if (temp == 0)
+		    temp = ' ';
+	    }
+	    if (temp != 0)
+		SetChar(my_ch, temp, AttrOf(attr));
+	}
+	ch = CHREF(my_ch);
+    }
+    if (tilde_glitch && (CharOfD(ch) == L('~'))) {
+	SetChar(tilde, L('`'), AttrOf(attr));
+	ch = CHREF(tilde);
+    }
+
+    UpdateAttrs(attr);
+#if !USE_WIDEC_SUPPORT
+    /* FIXME - we do this special case for signal handling, should see how to
+     * make it work for wide characters.
+     */
+    if (SP->_outch != 0) {
+	SP->_outch(UChar(ch));
+    } else
+#endif
+    {
+	PUTC(CHDEREF(ch), SP->_ofp);	/* macro's fastest... */
+	COUNT_OUTCHARS(1);
+    }
+    SP->_curscol += chlen;
+    if (char_padding) {
+	TPUTS_TRACE("char_padding");
+	putp(char_padding);
+    }
+}
+
+static bool
+check_pending(void)
+/* check for pending input */
+{
+    bool have_pending = FALSE;
+
+    /*
+     * Only carry out this check when the flag is zero, otherwise we'll
+     * have the refreshing slow down drastically (or stop) if there's an
+     * unread character available.
+     */
+    if (SP->_fifohold != 0)
+	return FALSE;
+
+    if (SP->_checkfd >= 0) {
+#if USE_FUNC_POLL
+	struct pollfd fds[1];
+	fds[0].fd = SP->_checkfd;
+	fds[0].events = POLLIN;
+	if (poll(fds, 1, 0) > 0) {
+	    have_pending = TRUE;
+	}
+#elif defined(__BEOS__)
+	/*
+	 * BeOS's select() is declared in socket.h, so the configure script does
+	 * not see it.  That's just as well, since that function works only for
+	 * sockets.  This (using snooze and ioctl) was distilled from Be's patch
+	 * for ncurses which uses a separate thread to simulate select().
+	 *
+	 * FIXME: the return values from the ioctl aren't very clear if we get
+	 * interrupted.
+	 */
+	int n = 0;
+	int howmany = ioctl(0, 'ichr', &n);
+	if (howmany >= 0 && n > 0) {
+	    have_pending = TRUE;
+	}
+#elif HAVE_SELECT
+	fd_set fdset;
+	struct timeval ktimeout;
+
+	ktimeout.tv_sec =
+	    ktimeout.tv_usec = 0;
+
+	FD_ZERO(&fdset);
+	FD_SET(SP->_checkfd, &fdset);
+	if (select(SP->_checkfd + 1, &fdset, NULL, NULL, &ktimeout) != 0) {
+	    have_pending = TRUE;
+	}
+#endif
+    }
+    if (have_pending) {
+	SP->_fifohold = 5;
+	_nc_flush();
+    }
+    return FALSE;
+}
+
+/* put char at lower right corner */
+static void
+PutCharLR(const ARG_CH_T ch)
+{
+    if (!auto_right_margin) {
+	/* we can put the char directly */
+	PutAttrChar(ch);
+    } else if (enter_am_mode && exit_am_mode) {
+	/* we can suppress automargin */
+	TPUTS_TRACE("exit_am_mode");
+	putp(exit_am_mode);
+
+	PutAttrChar(ch);
+	SP->_curscol--;
+	position_check(SP->_cursrow, SP->_curscol, "exit_am_mode");
+
+	TPUTS_TRACE("enter_am_mode");
+	putp(enter_am_mode);
+    } else if ((enter_insert_mode && exit_insert_mode)
+	       || insert_character || parm_ich) {
+	GoTo(screen_lines - 1, screen_columns - 2);
+	PutAttrChar(ch);
+	GoTo(screen_lines - 1, screen_columns - 2);
+	InsStr(newscr->_line[screen_lines - 1].text + screen_columns - 2, 1);
+    }
+}
+
+/*
+ * Wrap the cursor position, i.e., advance to the beginning of the next line.
+ */
+static void
+wrap_cursor(void)
+{
+    if (eat_newline_glitch) {
+	/*
+	 * xenl can manifest two different ways.  The vt100 way is that, when
+	 * you'd expect the cursor to wrap, it stays hung at the right margin
+	 * (on top of the character just emitted) and doesn't wrap until the
+	 * *next* graphic char is emitted.  The c100 way is to ignore LF
+	 * received just after an am wrap.
+	 *
+	 * An aggressive way to handle this would be to emit CR/LF after the
+	 * char and then assume the wrap is done, you're on the first position
+	 * of the next line, and the terminal out of its weird state.  Here
+	 * it's safe to just tell the code that the cursor is in hyperspace and
+	 * let the next mvcur() call straighten things out.
+	 */
+	SP->_curscol = -1;
+	SP->_cursrow = -1;
+    } else if (auto_right_margin) {
+	SP->_curscol = 0;
+	SP->_cursrow++;
+	/*
+	 * We've actually moved - but may have to work around problems with
+	 * video attributes not working.
+	 */
+	if (!move_standout_mode && AttrOf(SCREEN_ATTRS(SP))) {
+	    TR(TRACE_CHARPUT, ("turning off (%#lx) %s before wrapping",
+			       (unsigned long) AttrOf(SCREEN_ATTRS(SP)),
+			       _traceattr(AttrOf(SCREEN_ATTRS(SP)))));
+	    (void) VIDATTR(A_NORMAL, 0);
+	}
+    } else {
+	SP->_curscol--;
+    }
+    position_check(SP->_cursrow, SP->_curscol, "wrap_cursor");
+}
+
+static NCURSES_INLINE void
+PutChar(const ARG_CH_T ch)
+/* insert character, handling automargin stuff */
+{
+    if (SP->_cursrow == screen_lines - 1 && SP->_curscol == screen_columns - 1)
+	PutCharLR(ch);
+    else
+	PutAttrChar(ch);
+
+    if (SP->_curscol >= screen_columns)
+	wrap_cursor();
+
+    position_check(SP->_cursrow, SP->_curscol, "PutChar");
+}
+
+/*
+ * Check whether the given character can be output by clearing commands.  This
+ * includes test for being a space and not including any 'bad' attributes, such
+ * as A_REVERSE.  All attribute flags which don't affect appearance of a space
+ * or can be output by clearing (A_COLOR in case of bce-terminal) are excluded.
+ */
+static NCURSES_INLINE bool
+can_clear_with(ARG_CH_T ch)
+{
+    if (!back_color_erase && SP->_coloron) {
+#if NCURSES_EXT_FUNCS
+	int pair;
+
+	if (!SP->_default_color)
+	    return FALSE;
+	if (SP->_default_fg != C_MASK || SP->_default_bg != C_MASK)
+	    return FALSE;
+	if ((pair = GetPair(CHDEREF(ch))) != 0) {
+	    short fg, bg;
+	    pair_content(pair, &fg, &bg);
+	    if (fg != C_MASK || bg != C_MASK)
+		return FALSE;
+	}
+#else
+	if (AttrOfD(ch) & A_COLOR)
+	    return FALSE;
+#endif
+    }
+    return (ISBLANK(CHDEREF(ch)) &&
+	    (AttrOfD(ch) & ~(NONBLANK_ATTR | A_COLOR)) == BLANK_ATTR);
+}
+
+/*
+ * Issue a given span of characters from an array.
+ * Must be functionally equivalent to:
+ *	for (i = 0; i < num; i++)
+ *	    PutChar(ntext[i]);
+ * but can leave the cursor positioned at the middle of the interval.
+ *
+ * Returns: 0 - cursor is at the end of interval
+ *	    1 - cursor is somewhere in the middle
+ *
+ * This code is optimized using ech and rep.
+ */
+static int
+EmitRange(const NCURSES_CH_T * ntext, int num)
+{
+    int i;
+
+    TR(TRACE_CHARPUT, ("EmitRange %d:%s", num, _nc_viscbuf(ntext, num)));
+
+    if (erase_chars || repeat_char) {
+	while (num > 0) {
+	    int runcount;
+	    NCURSES_CH_T ntext0;
+
+	    while (num > 1 && !CharEq(ntext[0], ntext[1])) {
+		PutChar(CHREF(ntext[0]));
+		ntext++;
+		num--;
+	    }
+	    ntext0 = ntext[0];
+	    if (num == 1) {
+		PutChar(CHREF(ntext0));
+		return 0;
+	    }
+	    runcount = 2;
+
+	    while (runcount < num && CharEq(ntext[runcount], ntext0))
+		runcount++;
+
+	    /*
+	     * The cost expression in the middle isn't exactly right.
+	     * _cup_ch_cost is an upper bound on the cost for moving to the
+	     * end of the erased area, but not the cost itself (which we
+	     * can't compute without emitting the move).  This may result
+	     * in erase_chars not getting used in some situations for
+	     * which it would be marginally advantageous.
+	     */
+	    if (erase_chars
+		&& runcount > SP->_ech_cost + SP->_cup_ch_cost
+		&& can_clear_with(CHREF(ntext0))) {
+		UpdateAttrs(ntext0);
+		putp(TPARM_1(erase_chars, runcount));
+
+		/*
+		 * If this is the last part of the given interval,
+		 * don't bother moving cursor, since it can be the
+		 * last update on the line.
+		 */
+		if (runcount < num) {
+		    GoTo(SP->_cursrow, SP->_curscol + runcount);
+		} else {
+		    return 1;	/* cursor stays in the middle */
+		}
+	    } else if (repeat_char && runcount > SP->_rep_cost) {
+		bool wrap_possible = (SP->_curscol + runcount >= screen_columns);
+		int rep_count = runcount;
+
+		if (wrap_possible)
+		    rep_count--;
+
+		UpdateAttrs(ntext0);
+		tputs(TPARM_2(repeat_char, CharOf(ntext0), rep_count),
+		      rep_count, _nc_outch);
+		SP->_curscol += rep_count;
+
+		if (wrap_possible)
+		    PutChar(CHREF(ntext0));
+	    } else {
+		for (i = 0; i < runcount; i++)
+		    PutChar(CHREF(ntext[i]));
+	    }
+	    ntext += runcount;
+	    num -= runcount;
+	}
+	return 0;
+    }
+
+    for (i = 0; i < num; i++)
+	PutChar(CHREF(ntext[i]));
+    return 0;
+}
+
+/*
+ * Output the line in the given range [first .. last]
+ *
+ * If there's a run of identical characters that's long enough to justify
+ * cursor movement, use that also.
+ *
+ * Returns: same as EmitRange
+ */
+static int
+PutRange(const NCURSES_CH_T * otext,
+	 const NCURSES_CH_T * ntext,
+	 int row,
+	 int first, int last)
+{
+    int i, j, same;
+
+    TR(TRACE_CHARPUT, ("PutRange(%p, %p, %d, %d, %d)",
+		       otext, ntext, row, first, last));
+
+    if (otext != ntext
+	&& (last - first + 1) > SP->_inline_cost) {
+	for (j = first, same = 0; j <= last; j++) {
+	    if (!same && isWidecExt(otext[j]))
+		continue;
+	    if (CharEq(otext[j], ntext[j])) {
+		same++;
+	    } else {
+		if (same > SP->_inline_cost) {
+		    EmitRange(ntext + first, j - same - first);
+		    GoTo(row, first = j);
+		}
+		same = 0;
+	    }
+	}
+	i = EmitRange(ntext + first, j - same - first);
+	/*
+	 * Always return 1 for the next GoTo() after a PutRange() if we found
+	 * identical characters at end of interval
+	 */
+	return (same == 0 ? i : 1);
+    }
+    return EmitRange(ntext + first, last - first + 1);
+}
+
+/* leave unbracketed here so 'indent' works */
+#define MARK_NOCHANGE(win,row) \
+		win->_line[row].firstchar = _NOCHANGE; \
+		win->_line[row].lastchar = _NOCHANGE; \
+		if_USE_SCROLL_HINTS(win->_line[row].oldindex = row)
+
+NCURSES_EXPORT(int)
+doupdate(void)
+{
+    int i;
+    int nonempty;
+#if USE_TRACE_TIMES
+    struct tms before, after;
+#endif /* USE_TRACE_TIMES */
+
+    T((T_CALLED("doupdate()")));
+
+    if (curscr == 0
+	|| newscr == 0)
+	returnCode(ERR);
+
+#ifdef TRACE
+    if (USE_TRACEF(TRACE_UPDATE)) {
+	if (curscr->_clear)
+	    _tracef("curscr is clear");
+	else
+	    _tracedump("curscr", curscr);
+	_tracedump("newscr", newscr);
+	_nc_unlock_global(tracef);
+    }
+#endif /* TRACE */
+
+    _nc_signal_handler(FALSE);
+
+    if (SP->_fifohold)
+	SP->_fifohold--;
+
+#if USE_SIZECHANGE
+    if (SP->_endwin || _nc_handle_sigwinch(SP)) {
+	/*
+	 * This is a transparent extension:  XSI does not address it,
+	 * and applications need not know that ncurses can do it.
+	 *
+	 * Check if the terminal size has changed while curses was off
+	 * (this can happen in an xterm, for example), and resize the
+	 * ncurses data structures accordingly.
+	 */
+	_nc_update_screensize(SP);
+    }
+#endif
+
+    if (SP->_endwin) {
+
+	T(("coming back from shell mode"));
+	reset_prog_mode();
+
+	_nc_mvcur_resume();
+	_nc_screen_resume();
+	SP->_mouse_resume(SP);
+
+	SP->_endwin = FALSE;
+    }
+#if USE_TRACE_TIMES
+    /* zero the metering machinery */
+    RESET_OUTCHARS();
+    (void) times(&before);
+#endif /* USE_TRACE_TIMES */
+
+    /*
+     * This is the support for magic-cookie terminals.  The theory:  we scan
+     * the virtual screen looking for attribute turnons.  Where we find one,
+     * check to make sure it's realizable by seeing if the required number of
+     * un-attributed blanks are present before and after the attributed range;
+     * try to shift the range boundaries over blanks (not changing the screen
+     * display) so this becomes true.  If it is, shift the beginning attribute
+     * change appropriately (the end one, if we've gotten this far, is
+     * guaranteed room for its cookie).  If not, nuke the added attributes out
+     * of the span.
+     */
+#if USE_XMC_SUPPORT
+    if (magic_cookie_glitch > 0) {
+	int j, k;
+	attr_t rattr = A_NORMAL;
+
+	for (i = 0; i < screen_lines; i++) {
+	    for (j = 0; j < screen_columns; j++) {
+		bool failed = FALSE;
+		NCURSES_CH_T *thisline = newscr->_line[i].text;
+		attr_t thisattr = AttrOf(thisline[j]) & SP->_xmc_triggers;
+		attr_t turnon = thisattr & ~rattr;
+
+		/* is an attribute turned on here? */
+		if (turnon == 0) {
+		    rattr = thisattr;
+		    continue;
+		}
+
+		TR(TRACE_ATTRS, ("At (%d, %d): from %s...", i, j, _traceattr(rattr)));
+		TR(TRACE_ATTRS, ("...to %s", _traceattr(turnon)));
+
+		/*
+		 * If the attribute change location is a blank with a "safe"
+		 * attribute, undo the attribute turnon.  This may ensure
+		 * there's enough room to set the attribute before the first
+		 * non-blank in the run.
+		 */
+#define SAFE(a)	(!((a) & SP->_xmc_triggers))
+		if (ISBLANK(thisline[j]) && SAFE(turnon)) {
+		    RemAttr(thisline[j], turnon);
+		    continue;
+		}
+
+		/* check that there's enough room at start of span */
+		for (k = 1; k <= magic_cookie_glitch; k++) {
+		    if (j - k < 0
+			|| !ISBLANK(thisline[j - k])
+			|| !SAFE(AttrOf(thisline[j - k]))) {
+			failed = TRUE;
+			TR(TRACE_ATTRS, ("No room at start in %d,%d%s%s",
+					 i, j - k,
+					 (ISBLANK(thisline[j - k])
+					  ? ""
+					  : ":nonblank"),
+					 (SAFE(AttrOf(thisline[j - k]))
+					  ? ""
+					  : ":unsafe")));
+			break;
+		    }
+		}
+		if (!failed) {
+		    bool end_onscreen = FALSE;
+		    int m, n = j;
+
+		    /* find end of span, if it's onscreen */
+		    for (m = i; m < screen_lines; m++) {
+			for (; n < screen_columns; n++) {
+			    attr_t testattr = AttrOf(newscr->_line[m].text[n]);
+			    if ((testattr & SP->_xmc_triggers) == rattr) {
+				end_onscreen = TRUE;
+				TR(TRACE_ATTRS,
+				   ("Range attributed with %s ends at (%d, %d)",
+				    _traceattr(turnon), m, n));
+				goto foundit;
+			    }
+			}
+			n = 0;
+		    }
+		    TR(TRACE_ATTRS,
+		       ("Range attributed with %s ends offscreen",
+			_traceattr(turnon)));
+		  foundit:;
+
+		    if (end_onscreen) {
+			NCURSES_CH_T *lastline = newscr->_line[m].text;
+
+			/*
+			 * If there are safely-attributed blanks at the end of
+			 * the range, shorten the range.  This will help ensure
+			 * that there is enough room at end of span.
+			 */
+			while (n >= 0
+			       && ISBLANK(lastline[n])
+			       && SAFE(AttrOf(lastline[n]))) {
+			    RemAttr(lastline[n--], turnon);
+			}
+
+			/* check that there's enough room at end of span */
+			for (k = 1; k <= magic_cookie_glitch; k++) {
+			    if (n + k >= screen_columns
+				|| !ISBLANK(lastline[n + k])
+				|| !SAFE(AttrOf(lastline[n + k]))) {
+				failed = TRUE;
+				TR(TRACE_ATTRS,
+				   ("No room at end in %d,%d%s%s",
+				    i, j - k,
+				    (ISBLANK(lastline[n + k])
+				     ? ""
+				     : ":nonblank"),
+				    (SAFE(AttrOf(lastline[n + k]))
+				     ? ""
+				     : ":unsafe")));
+				break;
+			    }
+			}
+		    }
+		}
+
+		if (failed) {
+		    int p, q = j;
+
+		    TR(TRACE_ATTRS,
+		       ("Clearing %s beginning at (%d, %d)",
+			_traceattr(turnon), i, j));
+
+		    /* turn off new attributes over span */
+		    for (p = i; p < screen_lines; p++) {
+			for (; q < screen_columns; q++) {
+			    attr_t testattr = AttrOf(newscr->_line[p].text[q]);
+			    if ((testattr & SP->_xmc_triggers) == rattr)
+				goto foundend;
+			    RemAttr(newscr->_line[p].text[q], turnon);
+			}
+			q = 0;
+		    }
+		  foundend:;
+		} else {
+		    TR(TRACE_ATTRS,
+		       ("Cookie space for %s found before (%d, %d)",
+			_traceattr(turnon), i, j));
+
+		    /*
+		     * Back up the start of range so there's room for cookies
+		     * before the first nonblank character.
+		     */
+		    for (k = 1; k <= magic_cookie_glitch; k++)
+			AddAttr(thisline[j - k], turnon);
+		}
+
+		rattr = thisattr;
+	    }
+	}
+
+#ifdef TRACE
+	/* show altered highlights after magic-cookie check */
+	if (USE_TRACEF(TRACE_UPDATE)) {
+	    _tracef("After magic-cookie check...");
+	    _tracedump("newscr", newscr);
+	    _nc_unlock_global(tracef);
+	}
+#endif /* TRACE */
+    }
+#endif /* USE_XMC_SUPPORT */
+
+    nonempty = 0;
+    if (curscr->_clear || newscr->_clear) {	/* force refresh ? */
+	ClrUpdate();
+	curscr->_clear = FALSE;	/* reset flag */
+	newscr->_clear = FALSE;	/* reset flag */
+    } else {
+	int changedlines = CHECK_INTERVAL;
+
+	if (check_pending())
+	    goto cleanup;
+
+	nonempty = min(screen_lines, newscr->_maxy + 1);
+
+	if (SP->_scrolling) {
+	    _nc_scroll_optimize();
+	}
+
+	nonempty = ClrBottom(nonempty);
+
+	TR(TRACE_UPDATE, ("Transforming lines, nonempty %d", nonempty));
+	for (i = 0; i < nonempty; i++) {
+	    /*
+	     * Here is our line-breakout optimization.
+	     */
+	    if (changedlines == CHECK_INTERVAL) {
+		if (check_pending())
+		    goto cleanup;
+		changedlines = 0;
+	    }
+
+	    /*
+	     * newscr->line[i].firstchar is normally set
+	     * by wnoutrefresh.  curscr->line[i].firstchar
+	     * is normally set by _nc_scroll_window in the
+	     * vertical-movement optimization code,
+	     */
+	    if (newscr->_line[i].firstchar != _NOCHANGE
+		|| curscr->_line[i].firstchar != _NOCHANGE) {
+		TransformLine(i);
+		changedlines++;
+	    }
+
+	    /* mark line changed successfully */
+	    if (i <= newscr->_maxy) {
+		MARK_NOCHANGE(newscr, i);
+	    }
+	    if (i <= curscr->_maxy) {
+		MARK_NOCHANGE(curscr, i);
+	    }
+	}
+    }
+
+    /* put everything back in sync */
+    for (i = nonempty; i <= newscr->_maxy; i++) {
+	MARK_NOCHANGE(newscr, i);
+    }
+    for (i = nonempty; i <= curscr->_maxy; i++) {
+	MARK_NOCHANGE(curscr, i);
+    }
+
+    if (!newscr->_leaveok) {
+	curscr->_curx = newscr->_curx;
+	curscr->_cury = newscr->_cury;
+
+	GoTo(curscr->_cury, curscr->_curx);
+    }
+
+  cleanup:
+    /*
+     * We would like to keep the physical screen in normal mode in case we get
+     * other processes writing to the screen.  This goal cannot be met for
+     * magic cookies since it interferes with attributes that may propagate
+     * past the current position.
+     */
+#if USE_XMC_SUPPORT
+    if (magic_cookie_glitch != 0)
+#endif
+	UpdateAttrs(normal);
+
+    _nc_flush();
+    WINDOW_ATTRS(curscr) = WINDOW_ATTRS(newscr);
+
+#if USE_TRACE_TIMES
+    (void) times(&after);
+    TR(TRACE_TIMES,
+       ("Update cost: %ld chars, %ld clocks system time, %ld clocks user time",
+	_nc_outchars,
+	(long) (after.tms_stime - before.tms_stime),
+	(long) (after.tms_utime - before.tms_utime)));
+#endif /* USE_TRACE_TIMES */
+
+    _nc_signal_handler(TRUE);
+
+    returnCode(OK);
+}
+
+/*
+ *	ClrBlank(win)
+ *
+ *	Returns the attributed character that corresponds to the "cleared"
+ *	screen.  If the terminal has the back-color-erase feature, this will be
+ *	colored according to the wbkgd() call.
+ *
+ *	We treat 'curscr' specially because it isn't supposed to be set directly
+ *	in the wbkgd() call.  Assume 'stdscr' for this case.
+ */
+#define BCE_ATTRS (A_NORMAL|A_COLOR)
+#define BCE_BKGD(win) (((win) == curscr ? stdscr : (win))->_nc_bkgd)
+
+static NCURSES_INLINE NCURSES_CH_T
+ClrBlank(WINDOW *win)
+{
+    NCURSES_CH_T blank = blankchar;
+    if (back_color_erase)
+	AddAttr(blank, (AttrOf(BCE_BKGD(win)) & BCE_ATTRS));
+    return blank;
+}
+
+/*
+**	ClrUpdate()
+**
+**	Update by clearing and redrawing the entire screen.
+**
+*/
+
+static void
+ClrUpdate(void)
+{
+    int i;
+    NCURSES_CH_T blank = ClrBlank(stdscr);
+    int nonempty = min(screen_lines, newscr->_maxy + 1);
+
+    TR(TRACE_UPDATE, (T_CALLED("ClrUpdate")));
+
+    ClearScreen(blank);
+
+    TR(TRACE_UPDATE, ("updating screen from scratch"));
+
+    nonempty = ClrBottom(nonempty);
+
+    for (i = 0; i < nonempty; i++)
+	TransformLine(i);
+
+    TR(TRACE_UPDATE, (T_RETURN("")));
+}
+
+/*
+**	ClrToEOL(blank)
+**
+**	Clear to end of current line, starting at the cursor position
+*/
+
+static void
+ClrToEOL(NCURSES_CH_T blank, bool needclear)
+{
+    int j;
+
+    if (curscr != 0
+	&& SP->_cursrow >= 0) {
+	for (j = SP->_curscol; j < screen_columns; j++) {
+	    if (j >= 0) {
+		NCURSES_CH_T *cp = &(curscr->_line[SP->_cursrow].text[j]);
+
+		if (!CharEq(*cp, blank)) {
+		    *cp = blank;
+		    needclear = TRUE;
+		}
+	    }
+	}
+    } else {
+	needclear = TRUE;
+    }
+
+    if (needclear) {
+	UpdateAttrs(blank);
+	TPUTS_TRACE("clr_eol");
+	if (clr_eol && SP->_el_cost <= (screen_columns - SP->_curscol)) {
+	    putp(clr_eol);
+	} else {
+	    int count = (screen_columns - SP->_curscol);
+	    while (count-- > 0)
+		PutChar(CHREF(blank));
+	}
+    }
+}
+
+/*
+**	ClrToEOS(blank)
+**
+**	Clear to end of screen, starting at the cursor position
+*/
+
+static void
+ClrToEOS(NCURSES_CH_T blank)
+{
+    int row, col;
+
+    row = SP->_cursrow;
+    col = SP->_curscol;
+
+    UpdateAttrs(blank);
+    TPUTS_TRACE("clr_eos");
+    tputs(clr_eos, screen_lines - row, _nc_outch);
+
+    while (col < screen_columns)
+	curscr->_line[row].text[col++] = blank;
+
+    for (row++; row < screen_lines; row++) {
+	for (col = 0; col < screen_columns; col++)
+	    curscr->_line[row].text[col] = blank;
+    }
+}
+
+/*
+ *	ClrBottom(total)
+ *
+ *	Test if clearing the end of the screen would satisfy part of the
+ *	screen-update.  Do this by scanning backwards through the lines in the
+ *	screen, checking if each is blank, and one or more are changed.
+ */
+static int
+ClrBottom(int total)
+{
+    int row;
+    int col;
+    int top = total;
+    int last = min(screen_columns, newscr->_maxx + 1);
+    NCURSES_CH_T blank = newscr->_line[total - 1].text[last - 1];
+    bool ok;
+
+    if (clr_eos && can_clear_with(CHREF(blank))) {
+
+	for (row = total - 1; row >= 0; row--) {
+	    for (col = 0, ok = TRUE; ok && col < last; col++) {
+		ok = (CharEq(newscr->_line[row].text[col], blank));
+	    }
+	    if (!ok)
+		break;
+
+	    for (col = 0; ok && col < last; col++) {
+		ok = (CharEq(curscr->_line[row].text[col], blank));
+	    }
+	    if (!ok)
+		top = row;
+	}
+
+	/* don't use clr_eos for just one line if clr_eol available */
+	if (top < total) {
+	    GoTo(top, 0);
+	    ClrToEOS(blank);
+	    if (SP->oldhash && SP->newhash) {
+		for (row = top; row < screen_lines; row++)
+		    SP->oldhash[row] = SP->newhash[row];
+	    }
+	}
+    }
+    return top;
+}
+
+#if USE_XMC_SUPPORT
+#if USE_WIDEC_SUPPORT
+#define check_xmc_transition(a, b) \
+    ((((a)->attr ^ (b)->attr) & ~((a)->attr) & SP->_xmc_triggers) != 0)
+#define xmc_turn_on(a,b) check_xmc_transition(&(a), &(b))
+#else
+#define xmc_turn_on(a,b) ((((a)^(b)) & ~(a) & SP->_xmc_triggers) != 0)
+#endif
+
+#define xmc_new(r,c) newscr->_line[r].text[c]
+#define xmc_turn_off(a,b) xmc_turn_on(b,a)
+#endif /* USE_XMC_SUPPORT */
+
+/*
+**	TransformLine(lineno)
+**
+**	Transform the given line in curscr to the one in newscr, using
+**	Insert/Delete Character if _nc_idcok && has_ic().
+**
+**		firstChar = position of first different character in line
+**		oLastChar = position of last different character in old line
+**		nLastChar = position of last different character in new line
+**
+**		move to firstChar
+**		overwrite chars up to min(oLastChar, nLastChar)
+**		if oLastChar < nLastChar
+**			insert newLine[oLastChar+1..nLastChar]
+**		else
+**			delete oLastChar - nLastChar spaces
+*/
+
+static void
+TransformLine(int const lineno)
+{
+    int firstChar, oLastChar, nLastChar;
+    NCURSES_CH_T *newLine = newscr->_line[lineno].text;
+    NCURSES_CH_T *oldLine = curscr->_line[lineno].text;
+    int n;
+    bool attrchanged = FALSE;
+
+    TR(TRACE_UPDATE, (T_CALLED("TransformLine(%d)"), lineno));
+
+    /* copy new hash value to old one */
+    if (SP->oldhash && SP->newhash)
+	SP->oldhash[lineno] = SP->newhash[lineno];
+
+    /*
+     * If we have colors, there is the possibility of having two color pairs
+     * that display as the same colors.  For instance, Lynx does this.  Check
+     * for this case, and update the old line with the new line's colors when
+     * they are equivalent.
+     */
+    if (SP->_coloron) {
+	int oldPair;
+	int newPair;
+
+	for (n = 0; n < screen_columns; n++) {
+	    if (!CharEq(newLine[n], oldLine[n])) {
+		oldPair = GetPair(oldLine[n]);
+		newPair = GetPair(newLine[n]);
+		if (oldPair != newPair
+		    && unColor(oldLine[n]) == unColor(newLine[n])) {
+		    if (oldPair < COLOR_PAIRS
+			&& newPair < COLOR_PAIRS
+			&& SP->_color_pairs[oldPair] == SP->_color_pairs[newPair]) {
+			SetPair(oldLine[n], GetPair(newLine[n]));
+		    }
+		}
+	    }
+	}
+    }
+
+    if (ceol_standout_glitch && clr_eol) {
+	firstChar = 0;
+	while (firstChar < screen_columns) {
+	    if (!SameAttrOf(newLine[firstChar], oldLine[firstChar])) {
+		attrchanged = TRUE;
+		break;
+	    }
+	    firstChar++;
+	}
+    }
+
+    firstChar = 0;
+
+    if (attrchanged) {		/* we may have to disregard the whole line */
+	GoTo(lineno, firstChar);
+	ClrToEOL(ClrBlank(curscr), FALSE);
+	PutRange(oldLine, newLine, lineno, 0, (screen_columns - 1));
+#if USE_XMC_SUPPORT
+
+	/*
+	 * This is a very simple loop to paint characters which may have the
+	 * magic cookie glitch embedded.  It doesn't know much about video
+	 * attributes which are continued from one line to the next.  It
+	 * assumes that we have filtered out requests for attribute changes
+	 * that do not get mapped to blank positions.
+	 *
+	 * FIXME: we are not keeping track of where we put the cookies, so this
+	 * will work properly only once, since we may overwrite a cookie in a
+	 * following operation.
+	 */
+    } else if (magic_cookie_glitch > 0) {
+	GoTo(lineno, firstChar);
+	for (n = 0; n < screen_columns; n++) {
+	    int m = n + magic_cookie_glitch;
+
+	    /* check for turn-on:
+	     * If we are writing an attributed blank, where the
+	     * previous cell is not attributed.
+	     */
+	    if (ISBLANK(newLine[n])
+		&& ((n > 0
+		     && xmc_turn_on(newLine[n - 1], newLine[n]))
+		    || (n == 0
+			&& lineno > 0
+			&& xmc_turn_on(xmc_new(lineno - 1, screen_columns - 1),
+				       newLine[n])))) {
+		n = m;
+	    }
+
+	    PutChar(CHREF(newLine[n]));
+
+	    /* check for turn-off:
+	     * If we are writing an attributed non-blank, where the
+	     * next cell is blank, and not attributed.
+	     */
+	    if (!ISBLANK(newLine[n])
+		&& ((n + 1 < screen_columns
+		     && xmc_turn_off(newLine[n], newLine[n + 1]))
+		    || (n + 1 >= screen_columns
+			&& lineno + 1 < screen_lines
+			&& xmc_turn_off(newLine[n], xmc_new(lineno + 1, 0))))) {
+		n = m;
+	    }
+
+	}
+#endif
+    } else {
+	NCURSES_CH_T blank;
+
+	/* it may be cheap to clear leading whitespace with clr_bol */
+	blank = newLine[0];
+	if (clr_bol && can_clear_with(CHREF(blank))) {
+	    int oFirstChar, nFirstChar;
+
+	    for (oFirstChar = 0; oFirstChar < screen_columns; oFirstChar++)
+		if (!CharEq(oldLine[oFirstChar], blank))
+		    break;
+	    for (nFirstChar = 0; nFirstChar < screen_columns; nFirstChar++)
+		if (!CharEq(newLine[nFirstChar], blank))
+		    break;
+
+	    if (nFirstChar == oFirstChar) {
+		firstChar = nFirstChar;
+		/* find the first differing character */
+		while (firstChar < screen_columns
+		       && CharEq(newLine[firstChar], oldLine[firstChar]))
+		    firstChar++;
+	    } else if (oFirstChar > nFirstChar) {
+		firstChar = nFirstChar;
+	    } else {		/* oFirstChar < nFirstChar */
+		firstChar = oFirstChar;
+		if (SP->_el1_cost < nFirstChar - oFirstChar) {
+		    if (nFirstChar >= screen_columns
+			&& SP->_el_cost <= SP->_el1_cost) {
+			GoTo(lineno, 0);
+			UpdateAttrs(blank);
+			TPUTS_TRACE("clr_eol");
+			putp(clr_eol);
+		    } else {
+			GoTo(lineno, nFirstChar - 1);
+			UpdateAttrs(blank);
+			TPUTS_TRACE("clr_bol");
+			putp(clr_bol);
+		    }
+
+		    while (firstChar < nFirstChar)
+			oldLine[firstChar++] = blank;
+		}
+	    }
+	} else {
+	    /* find the first differing character */
+	    while (firstChar < screen_columns
+		   && CharEq(newLine[firstChar], oldLine[firstChar]))
+		firstChar++;
+	}
+	/* if there wasn't one, we're done */
+	if (firstChar >= screen_columns) {
+	    TR(TRACE_UPDATE, (T_RETURN("")));
+	    return;
+	}
+
+	blank = newLine[screen_columns - 1];
+
+	if (!can_clear_with(CHREF(blank))) {
+	    /* find the last differing character */
+	    nLastChar = screen_columns - 1;
+
+	    while (nLastChar > firstChar
+		   && CharEq(newLine[nLastChar], oldLine[nLastChar]))
+		nLastChar--;
+
+	    if (nLastChar >= firstChar) {
+		GoTo(lineno, firstChar);
+		PutRange(oldLine, newLine, lineno, firstChar, nLastChar);
+		memcpy(oldLine + firstChar,
+		       newLine + firstChar,
+		       (nLastChar - firstChar + 1) * sizeof(NCURSES_CH_T));
+	    }
+	    TR(TRACE_UPDATE, (T_RETURN("")));
+	    return;
+	}
+
+	/* find last non-blank character on old line */
+	oLastChar = screen_columns - 1;
+	while (oLastChar > firstChar && CharEq(oldLine[oLastChar], blank))
+	    oLastChar--;
+
+	/* find last non-blank character on new line */
+	nLastChar = screen_columns - 1;
+	while (nLastChar > firstChar && CharEq(newLine[nLastChar], blank))
+	    nLastChar--;
+
+	if ((nLastChar == firstChar)
+	    && (SP->_el_cost < (oLastChar - nLastChar))) {
+	    GoTo(lineno, firstChar);
+	    if (!CharEq(newLine[firstChar], blank))
+		PutChar(CHREF(newLine[firstChar]));
+	    ClrToEOL(blank, FALSE);
+	} else if ((nLastChar != oLastChar)
+		   && (!CharEq(newLine[nLastChar], oldLine[oLastChar])
+		       || !(_nc_idcok && has_ic()))) {
+	    GoTo(lineno, firstChar);
+	    if ((oLastChar - nLastChar) > SP->_el_cost) {
+		if (PutRange(oldLine, newLine, lineno, firstChar, nLastChar))
+		    GoTo(lineno, nLastChar + 1);
+		ClrToEOL(blank, FALSE);
+	    } else {
+		n = max(nLastChar, oLastChar);
+		PutRange(oldLine, newLine, lineno, firstChar, n);
+	    }
+	} else {
+	    int nLastNonblank = nLastChar;
+	    int oLastNonblank = oLastChar;
+
+	    /* find the last characters that really differ */
+	    /* can be -1 if no characters differ */
+	    while (CharEq(newLine[nLastChar], oldLine[oLastChar])) {
+		/* don't split a wide char */
+		if (isWidecExt(newLine[nLastChar]) &&
+		    !CharEq(newLine[nLastChar - 1], oldLine[oLastChar - 1]))
+		    break;
+		nLastChar--;
+		oLastChar--;
+		if (nLastChar == -1 || oLastChar == -1)
+		    break;
+	    }
+
+	    n = min(oLastChar, nLastChar);
+	    if (n >= firstChar) {
+		GoTo(lineno, firstChar);
+		PutRange(oldLine, newLine, lineno, firstChar, n);
+	    }
+
+	    if (oLastChar < nLastChar) {
+		int m = max(nLastNonblank, oLastNonblank);
+#if USE_WIDEC_SUPPORT
+		while (isWidecExt(newLine[n + 1]) && n) {
+		    --n;
+		    --oLastChar;
+		}
+#endif
+		GoTo(lineno, n + 1);
+		if ((nLastChar < nLastNonblank)
+		    || InsCharCost(nLastChar - oLastChar) > (m - n)) {
+		    PutRange(oldLine, newLine, lineno, n + 1, m);
+		} else {
+		    InsStr(&newLine[n + 1], nLastChar - oLastChar);
+		}
+	    } else if (oLastChar > nLastChar) {
+		GoTo(lineno, n + 1);
+		if (DelCharCost(oLastChar - nLastChar)
+		    > SP->_el_cost + nLastNonblank - (n + 1)) {
+		    if (PutRange(oldLine, newLine, lineno,
+				 n + 1, nLastNonblank))
+			GoTo(lineno, nLastNonblank + 1);
+		    ClrToEOL(blank, FALSE);
+		} else {
+		    /*
+		     * The delete-char sequence will
+		     * effectively shift in blanks from the
+		     * right margin of the screen.  Ensure
+		     * that they are the right color by
+		     * setting the video attributes from
+		     * the last character on the row.
+		     */
+		    UpdateAttrs(blank);
+		    DelChar(oLastChar - nLastChar);
+		}
+	    }
+	}
+    }
+
+    /* update the code's internal representation */
+    if (screen_columns > firstChar)
+	memcpy(oldLine + firstChar,
+	       newLine + firstChar,
+	       (screen_columns - firstChar) * sizeof(NCURSES_CH_T));
+    TR(TRACE_UPDATE, (T_RETURN("")));
+    return;
+}
+
+/*
+**	ClearScreen(blank)
+**
+**	Clear the physical screen and put cursor at home
+**
+*/
+
+static void
+ClearScreen(NCURSES_CH_T blank)
+{
+    int i, j;
+    bool fast_clear = (clear_screen || clr_eos || clr_eol);
+
+    TR(TRACE_UPDATE, ("ClearScreen() called"));
+
+#if NCURSES_EXT_FUNCS
+    if (SP->_coloron
+	&& !SP->_default_color) {
+	_nc_do_color(GET_SCREEN_PAIR(SP), 0, FALSE, _nc_outch);
+	if (!back_color_erase) {
+	    fast_clear = FALSE;
+	}
+    }
+#endif
+
+    if (fast_clear) {
+	if (clear_screen) {
+	    UpdateAttrs(blank);
+	    TPUTS_TRACE("clear_screen");
+	    putp(clear_screen);
+	    SP->_cursrow = SP->_curscol = 0;
+	    position_check(SP->_cursrow, SP->_curscol, "ClearScreen");
+	} else if (clr_eos) {
+	    SP->_cursrow = SP->_curscol = -1;
+	    GoTo(0, 0);
+
+	    UpdateAttrs(blank);
+	    TPUTS_TRACE("clr_eos");
+	    tputs(clr_eos, screen_lines, _nc_outch);
+	} else if (clr_eol) {
+	    SP->_cursrow = SP->_curscol = -1;
+
+	    UpdateAttrs(blank);
+	    for (i = 0; i < screen_lines; i++) {
+		GoTo(i, 0);
+		TPUTS_TRACE("clr_eol");
+		putp(clr_eol);
+	    }
+	    GoTo(0, 0);
+	}
+    } else {
+	UpdateAttrs(blank);
+	for (i = 0; i < screen_lines; i++) {
+	    GoTo(i, 0);
+	    for (j = 0; j < screen_columns; j++)
+		PutChar(CHREF(blank));
+	}
+	GoTo(0, 0);
+    }
+
+    for (i = 0; i < screen_lines; i++) {
+	for (j = 0; j < screen_columns; j++)
+	    curscr->_line[i].text[j] = blank;
+    }
+
+    TR(TRACE_UPDATE, ("screen cleared"));
+}
+
+/*
+**	InsStr(line, count)
+**
+**	Insert the count characters pointed to by line.
+**
+*/
+
+static void
+InsStr(NCURSES_CH_T * line, int count)
+{
+    TR(TRACE_UPDATE, ("InsStr(%p,%d) called", line, count));
+
+    /* Prefer parm_ich as it has the smallest cost - no need to shift
+     * the whole line on each character. */
+    /* The order must match that of InsCharCost. */
+    if (parm_ich) {
+	TPUTS_TRACE("parm_ich");
+	tputs(TPARM_1(parm_ich, count), count, _nc_outch);
+	while (count) {
+	    PutAttrChar(CHREF(*line));
+	    line++;
+	    count--;
+	}
+    } else if (enter_insert_mode && exit_insert_mode) {
+	TPUTS_TRACE("enter_insert_mode");
+	putp(enter_insert_mode);
+	while (count) {
+	    PutAttrChar(CHREF(*line));
+	    if (insert_padding) {
+		TPUTS_TRACE("insert_padding");
+		putp(insert_padding);
+	    }
+	    line++;
+	    count--;
+	}
+	TPUTS_TRACE("exit_insert_mode");
+	putp(exit_insert_mode);
+    } else {
+	while (count) {
+	    TPUTS_TRACE("insert_character");
+	    putp(insert_character);
+	    PutAttrChar(CHREF(*line));
+	    if (insert_padding) {
+		TPUTS_TRACE("insert_padding");
+		putp(insert_padding);
+	    }
+	    line++;
+	    count--;
+	}
+    }
+    position_check(SP->_cursrow, SP->_curscol, "InsStr");
+}
+
+/*
+**	DelChar(count)
+**
+**	Delete count characters at current position
+**
+*/
+
+static void
+DelChar(int count)
+{
+    int n;
+
+    TR(TRACE_UPDATE, ("DelChar(%d) called, position = (%ld,%ld)",
+		      count,
+		      (long) newscr->_cury,
+		      (long) newscr->_curx));
+
+    if (parm_dch) {
+	TPUTS_TRACE("parm_dch");
+	tputs(TPARM_1(parm_dch, count), count, _nc_outch);
+    } else {
+	for (n = 0; n < count; n++) {
+	    TPUTS_TRACE("delete_character");
+	    putp(delete_character);
+	}
+    }
+}
+
+/*
+ * Physical-scrolling support
+ *
+ * This code was adapted from Keith Bostic's hardware scrolling
+ * support for 4.4BSD curses.  I (esr) translated it to use terminfo
+ * capabilities, narrowed the call interface slightly, and cleaned
+ * up some convoluted tests.  I also added support for the memory_above
+ * memory_below, and non_dest_scroll_region capabilities.
+ *
+ * For this code to work, we must have either
+ * change_scroll_region and scroll forward/reverse commands, or
+ * insert and delete line capabilities.
+ * When the scrolling region has been set, the cursor has to
+ * be at the last line of the region to make the scroll up
+ * happen, or on the first line of region to scroll down.
+ *
+ * This code makes one aesthetic decision in the opposite way from
+ * BSD curses.  BSD curses preferred pairs of il/dl operations
+ * over scrolls, allegedly because il/dl looked faster.  We, on
+ * the other hand, prefer scrolls because (a) they're just as fast
+ * on many terminals and (b) using them avoids bouncing an
+ * unchanged bottom section of the screen up and down, which is
+ * visually nasty.
+ *
+ * (lav): added more cases, used dl/il when bot==maxy and in csr case.
+ *
+ * I used assumption that capabilities il/il1/dl/dl1 work inside
+ * changed scroll region not shifting screen contents outside of it.
+ * If there are any terminals behaving different way, it would be
+ * necessary to add some conditions to scroll_csr_forward/backward.
+ */
+
+/* Try to scroll up assuming given csr (miny, maxy). Returns ERR on failure */
+static int
+scroll_csr_forward(int n, int top, int bot, int miny, int maxy, NCURSES_CH_T blank)
+{
+    int i;
+
+    if (n == 1 && scroll_forward && top == miny && bot == maxy) {
+	GoTo(bot, 0);
+	UpdateAttrs(blank);
+	TPUTS_TRACE("scroll_forward");
+	putp(scroll_forward);
+    } else if (n == 1 && delete_line && bot == maxy) {
+	GoTo(top, 0);
+	UpdateAttrs(blank);
+	TPUTS_TRACE("delete_line");
+	putp(delete_line);
+    } else if (parm_index && top == miny && bot == maxy) {
+	GoTo(bot, 0);
+	UpdateAttrs(blank);
+	TPUTS_TRACE("parm_index");
+	tputs(TPARM_2(parm_index, n, 0), n, _nc_outch);
+    } else if (parm_delete_line && bot == maxy) {
+	GoTo(top, 0);
+	UpdateAttrs(blank);
+	TPUTS_TRACE("parm_delete_line");
+	tputs(TPARM_2(parm_delete_line, n, 0), n, _nc_outch);
+    } else if (scroll_forward && top == miny && bot == maxy) {
+	GoTo(bot, 0);
+	UpdateAttrs(blank);
+	for (i = 0; i < n; i++) {
+	    TPUTS_TRACE("scroll_forward");
+	    putp(scroll_forward);
+	}
+    } else if (delete_line && bot == maxy) {
+	GoTo(top, 0);
+	UpdateAttrs(blank);
+	for (i = 0; i < n; i++) {
+	    TPUTS_TRACE("delete_line");
+	    putp(delete_line);
+	}
+    } else
+	return ERR;
+
+#if NCURSES_EXT_FUNCS
+    if (FILL_BCE()) {
+	int j;
+	for (i = 0; i < n; i++) {
+	    GoTo(bot - i, 0);
+	    for (j = 0; j < screen_columns; j++)
+		PutChar(CHREF(blank));
+	}
+    }
+#endif
+    return OK;
+}
+
+/* Try to scroll down assuming given csr (miny, maxy). Returns ERR on failure */
+/* n > 0 */
+static int
+scroll_csr_backward(int n, int top, int bot, int miny, int maxy,
+		    NCURSES_CH_T blank)
+{
+    int i;
+
+    if (n == 1 && scroll_reverse && top == miny && bot == maxy) {
+	GoTo(top, 0);
+	UpdateAttrs(blank);
+	TPUTS_TRACE("scroll_reverse");
+	putp(scroll_reverse);
+    } else if (n == 1 && insert_line && bot == maxy) {
+	GoTo(top, 0);
+	UpdateAttrs(blank);
+	TPUTS_TRACE("insert_line");
+	putp(insert_line);
+    } else if (parm_rindex && top == miny && bot == maxy) {
+	GoTo(top, 0);
+	UpdateAttrs(blank);
+	TPUTS_TRACE("parm_rindex");
+	tputs(TPARM_2(parm_rindex, n, 0), n, _nc_outch);
+    } else if (parm_insert_line && bot == maxy) {
+	GoTo(top, 0);
+	UpdateAttrs(blank);
+	TPUTS_TRACE("parm_insert_line");
+	tputs(TPARM_2(parm_insert_line, n, 0), n, _nc_outch);
+    } else if (scroll_reverse && top == miny && bot == maxy) {
+	GoTo(top, 0);
+	UpdateAttrs(blank);
+	for (i = 0; i < n; i++) {
+	    TPUTS_TRACE("scroll_reverse");
+	    putp(scroll_reverse);
+	}
+    } else if (insert_line && bot == maxy) {
+	GoTo(top, 0);
+	UpdateAttrs(blank);
+	for (i = 0; i < n; i++) {
+	    TPUTS_TRACE("insert_line");
+	    putp(insert_line);
+	}
+    } else
+	return ERR;
+
+#if NCURSES_EXT_FUNCS
+    if (FILL_BCE()) {
+	int j;
+	for (i = 0; i < n; i++) {
+	    GoTo(top + i, 0);
+	    for (j = 0; j < screen_columns; j++)
+		PutChar(CHREF(blank));
+	}
+    }
+#endif
+    return OK;
+}
+
+/* scroll by using delete_line at del and insert_line at ins */
+/* n > 0 */
+static int
+scroll_idl(int n, int del, int ins, NCURSES_CH_T blank)
+{
+    int i;
+
+    if (!((parm_delete_line || delete_line) && (parm_insert_line || insert_line)))
+	return ERR;
+
+    GoTo(del, 0);
+    UpdateAttrs(blank);
+    if (n == 1 && delete_line) {
+	TPUTS_TRACE("delete_line");
+	putp(delete_line);
+    } else if (parm_delete_line) {
+	TPUTS_TRACE("parm_delete_line");
+	tputs(TPARM_2(parm_delete_line, n, 0), n, _nc_outch);
+    } else {			/* if (delete_line) */
+	for (i = 0; i < n; i++) {
+	    TPUTS_TRACE("delete_line");
+	    putp(delete_line);
+	}
+    }
+
+    GoTo(ins, 0);
+    UpdateAttrs(blank);
+    if (n == 1 && insert_line) {
+	TPUTS_TRACE("insert_line");
+	putp(insert_line);
+    } else if (parm_insert_line) {
+	TPUTS_TRACE("parm_insert_line");
+	tputs(TPARM_2(parm_insert_line, n, 0), n, _nc_outch);
+    } else {			/* if (insert_line) */
+	for (i = 0; i < n; i++) {
+	    TPUTS_TRACE("insert_line");
+	    putp(insert_line);
+	}
+    }
+
+    return OK;
+}
+
+/*
+ * Note:  some terminals require the cursor to be within the scrolling margins
+ * before setting them.  Generally, the cursor must be at the appropriate end
+ * of the scrolling margins when issuing an indexing operation (it is not
+ * apparent whether it must also be at the left margin; we do this just to be
+ * safe).  To make the related cursor movement a little faster, we use the
+ * save/restore cursor capabilities if the terminal has them.
+ */
+NCURSES_EXPORT(int)
+_nc_scrolln(int n, int top, int bot, int maxy)
+/* scroll region from top to bot by n lines */
+{
+    NCURSES_CH_T blank = ClrBlank(stdscr);
+    int i;
+    bool cursor_saved = FALSE;
+    int res;
+
+    TR(TRACE_MOVE, ("mvcur_scrolln(%d, %d, %d, %d)", n, top, bot, maxy));
+
+#if USE_XMC_SUPPORT
+    /*
+     * If we scroll, we might remove a cookie.
+     */
+    if (magic_cookie_glitch > 0) {
+	return (ERR);
+    }
+#endif
+
+    if (n > 0) {		/* scroll up (forward) */
+	/*
+	 * Explicitly clear if stuff pushed off top of region might
+	 * be saved by the terminal.
+	 */
+	res = scroll_csr_forward(n, top, bot, 0, maxy, blank);
+
+	if (res == ERR && change_scroll_region) {
+	    if ((((n == 1 && scroll_forward) || parm_index)
+		 && (SP->_cursrow == bot || SP->_cursrow == bot - 1))
+		&& save_cursor && restore_cursor) {
+		cursor_saved = TRUE;
+		TPUTS_TRACE("save_cursor");
+		putp(save_cursor);
+	    }
+	    TPUTS_TRACE("change_scroll_region");
+	    putp(TPARM_2(change_scroll_region, top, bot));
+	    if (cursor_saved) {
+		TPUTS_TRACE("restore_cursor");
+		putp(restore_cursor);
+	    } else {
+		SP->_cursrow = SP->_curscol = -1;
+	    }
+
+	    res = scroll_csr_forward(n, top, bot, top, bot, blank);
+
+	    TPUTS_TRACE("change_scroll_region");
+	    putp(TPARM_2(change_scroll_region, 0, maxy));
+	    SP->_cursrow = SP->_curscol = -1;
+	}
+
+	if (res == ERR && _nc_idlok)
+	    res = scroll_idl(n, top, bot - n + 1, blank);
+
+	/*
+	 * Clear the newly shifted-in text.
+	 */
+	if (res != ERR
+	    && (non_dest_scroll_region || (memory_below && bot == maxy))) {
+	    static const NCURSES_CH_T blank2 = NewChar(BLANK_TEXT);
+	    if (bot == maxy && clr_eos) {
+		GoTo(bot - n + 1, 0);
+		ClrToEOS(blank2);
+	    } else {
+		for (i = 0; i < n; i++) {
+		    GoTo(bot - i, 0);
+		    ClrToEOL(blank2, FALSE);
+		}
+	    }
+	}
+
+    } else {			/* (n < 0) - scroll down (backward) */
+	res = scroll_csr_backward(-n, top, bot, 0, maxy, blank);
+
+	if (res == ERR && change_scroll_region) {
+	    if (top != 0 && (SP->_cursrow == top || SP->_cursrow == top - 1)
+		&& save_cursor && restore_cursor) {
+		cursor_saved = TRUE;
+		TPUTS_TRACE("save_cursor");
+		putp(save_cursor);
+	    }
+	    TPUTS_TRACE("change_scroll_region");
+	    putp(TPARM_2(change_scroll_region, top, bot));
+	    if (cursor_saved) {
+		TPUTS_TRACE("restore_cursor");
+		putp(restore_cursor);
+	    } else {
+		SP->_cursrow = SP->_curscol = -1;
+	    }
+
+	    res = scroll_csr_backward(-n, top, bot, top, bot, blank);
+
+	    TPUTS_TRACE("change_scroll_region");
+	    putp(TPARM_2(change_scroll_region, 0, maxy));
+	    SP->_cursrow = SP->_curscol = -1;
+	}
+
+	if (res == ERR && _nc_idlok)
+	    res = scroll_idl(-n, bot + n + 1, top, blank);
+
+	/*
+	 * Clear the newly shifted-in text.
+	 */
+	if (res != ERR
+	    && (non_dest_scroll_region || (memory_above && top == 0))) {
+	    static const NCURSES_CH_T blank2 = NewChar(BLANK_TEXT);
+	    for (i = 0; i < -n; i++) {
+		GoTo(i + top, 0);
+		ClrToEOL(blank2, FALSE);
+	    }
+	}
+    }
+
+    if (res == ERR)
+	return (ERR);
+
+    _nc_scroll_window(curscr, n, top, bot, blank);
+
+    /* shift hash values too - they can be reused */
+    _nc_scroll_oldhash(n, top, bot);
+
+    return (OK);
+}
+
+NCURSES_EXPORT(void)
+_nc_screen_resume(void)
+{
+    /* make sure terminal is in a sane known state */
+    SetAttr(SCREEN_ATTRS(SP), A_NORMAL);
+    newscr->_clear = TRUE;
+
+    /* reset color pairs and definitions */
+    if (SP->_coloron || SP->_color_defs)
+	_nc_reset_colors();
+
+    /* restore user-defined colors, if any */
+    if (SP->_color_defs < 0) {
+	int n;
+	SP->_color_defs = -(SP->_color_defs);
+	for (n = 0; n < SP->_color_defs; ++n) {
+	    if (SP->_color_table[n].init) {
+		init_color(n,
+			   SP->_color_table[n].r,
+			   SP->_color_table[n].g,
+			   SP->_color_table[n].b);
+	    }
+	}
+    }
+
+    if (exit_attribute_mode)
+	putp(exit_attribute_mode);
+    else {
+	/* turn off attributes */
+	if (exit_alt_charset_mode)
+	    putp(exit_alt_charset_mode);
+	if (exit_standout_mode)
+	    putp(exit_standout_mode);
+	if (exit_underline_mode)
+	    putp(exit_underline_mode);
+    }
+    if (exit_insert_mode)
+	putp(exit_insert_mode);
+    if (enter_am_mode && exit_am_mode)
+	putp(auto_right_margin ? enter_am_mode : exit_am_mode);
+}
+
+NCURSES_EXPORT(void)
+_nc_screen_init(void)
+{
+    _nc_screen_resume();
+}
+
+/* wrap up screen handling */
+NCURSES_EXPORT(void)
+_nc_screen_wrap(void)
+{
+    UpdateAttrs(normal);
+#if NCURSES_EXT_FUNCS
+    if (SP->_coloron
+	&& !SP->_default_color) {
+	static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
+	SP->_default_color = TRUE;
+	_nc_do_color(-1, 0, FALSE, _nc_outch);
+	SP->_default_color = FALSE;
+
+	mvcur(SP->_cursrow, SP->_curscol, screen_lines - 1, 0);
+
+	ClrToEOL(blank, TRUE);
+    }
+#endif
+    if (SP->_color_defs) {
+	_nc_reset_colors();
+    }
+}
+
+#if USE_XMC_SUPPORT
+NCURSES_EXPORT(void)
+_nc_do_xmc_glitch(attr_t previous)
+{
+    attr_t chg = XMC_CHANGES(previous ^ AttrOf(SCREEN_ATTRS(SP)));
+
+    while (chg != 0) {
+	if (chg & 1) {
+	    SP->_curscol += magic_cookie_glitch;
+	    if (SP->_curscol >= SP->_columns)
+		wrap_cursor();
+	    TR(TRACE_UPDATE, ("bumped to %d,%d after cookie", SP->_cursrow, SP->_curscol));
+	}
+	chg >>= 1;
+    }
+}
+#endif /* USE_XMC_SUPPORT */
