summaryrefslogtreecommitdiff
path: root/lib/libcurses
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libcurses')
-rw-r--r--lib/libcurses/EXAMPLES/ex1.c112
-rw-r--r--lib/libcurses/MKkeyname.awk31
-rw-r--r--lib/libcurses/MKkeys.awk1
-rw-r--r--lib/libcurses/Makefile57
-rw-r--r--lib/libcurses/PSD.doc/Makefile39
-rw-r--r--lib/libcurses/PSD.doc/Master54
-rw-r--r--lib/libcurses/PSD.doc/appen.A77
-rw-r--r--lib/libcurses/PSD.doc/appen.B201
-rw-r--r--lib/libcurses/PSD.doc/appen.C127
-rw-r--r--lib/libcurses/PSD.doc/c_macros70
-rw-r--r--lib/libcurses/PSD.doc/doc.I349
-rw-r--r--lib/libcurses/PSD.doc/doc.II142
-rw-r--r--lib/libcurses/PSD.doc/doc.III343
-rw-r--r--lib/libcurses/PSD.doc/doc.IV110
-rw-r--r--lib/libcurses/PSD.doc/ex1.c102
-rw-r--r--lib/libcurses/PSD.doc/ex2.c210
-rw-r--r--lib/libcurses/PSD.doc/fns.doc799
-rw-r--r--lib/libcurses/PSD.doc/intro.0106
-rw-r--r--lib/libcurses/PSD.doc/intro.1249
-rw-r--r--lib/libcurses/PSD.doc/intro.277
-rw-r--r--lib/libcurses/PSD.doc/intro.3228
-rw-r--r--lib/libcurses/PSD.doc/intro.469
-rw-r--r--lib/libcurses/PSD.doc/intro.587
-rw-r--r--lib/libcurses/PSD.doc/intro.644
-rw-r--r--lib/libcurses/PSD.doc/life.c163
-rw-r--r--lib/libcurses/PSD.doc/macros144
-rw-r--r--lib/libcurses/PSD.doc/twinkle1.c157
-rw-r--r--lib/libcurses/PSD.doc/twinkle2.c96
-rw-r--r--lib/libcurses/PSD.doc/win_st.c58
-rw-r--r--lib/libcurses/addbytes.c157
-rw-r--r--lib/libcurses/addch.c66
-rw-r--r--lib/libcurses/addnstr.c62
-rw-r--r--lib/libcurses/box.c78
-rw-r--r--lib/libcurses/clear.c53
-rw-r--r--lib/libcurses/clrtobot.c75
-rw-r--r--lib/libcurses/clrtoeol.c83
-rw-r--r--lib/libcurses/config.h43
-rw-r--r--lib/libcurses/cr_put.c432
-rw-r--r--lib/libcurses/ctrace.c76
-rw-r--r--lib/libcurses/cur_hash.c62
-rw-r--r--lib/libcurses/curs_addch.3146
-rw-r--r--lib/libcurses/curs_addchstr.355
-rw-r--r--lib/libcurses/curs_addstr.348
-rw-r--r--lib/libcurses/curs_attr.3167
-rw-r--r--lib/libcurses/curs_beep.334
-rw-r--r--lib/libcurses/curs_bkgd.360
-rw-r--r--lib/libcurses/curs_border.371
-rw-r--r--lib/libcurses/curs_clear.365
-rw-r--r--lib/libcurses/curs_color.3148
-rw-r--r--lib/libcurses/curs_delch.339
-rw-r--r--lib/libcurses/curs_deleteln.355
-rw-r--r--lib/libcurses/curs_getch.3203
-rw-r--r--lib/libcurses/curs_getstr.366
-rw-r--r--lib/libcurses/curs_getyx.343
-rw-r--r--lib/libcurses/curs_inch.342
-rw-r--r--lib/libcurses/curs_inchstr.355
-rw-r--r--lib/libcurses/curs_initscr.387
-rw-r--r--lib/libcurses/curs_inopts.3183
-rw-r--r--lib/libcurses/curs_insch.339
-rw-r--r--lib/libcurses/curs_insstr.361
-rw-r--r--lib/libcurses/curs_instr.353
-rw-r--r--lib/libcurses/curs_kernel.3123
-rw-r--r--lib/libcurses/curs_mouse.3151
-rw-r--r--lib/libcurses/curs_move.334
-rw-r--r--lib/libcurses/curs_outopts.3134
-rw-r--r--lib/libcurses/curs_overlay.346
-rw-r--r--lib/libcurses/curs_pad.382
-rw-r--r--lib/libcurses/curs_printw.347
-rw-r--r--lib/libcurses/curs_refresh.384
-rw-r--r--lib/libcurses/curs_scanw.348
-rw-r--r--lib/libcurses/curs_scr_dmp.364
-rw-r--r--lib/libcurses/curs_scroll.349
-rw-r--r--lib/libcurses/curs_slk.391
-rw-r--r--lib/libcurses/curs_termattrs.378
-rw-r--r--lib/libcurses/curs_touch.364
-rw-r--r--lib/libcurses/curs_util.385
-rw-r--r--lib/libcurses/curs_window.3123
-rw-r--r--lib/libcurses/curses.3805
-rw-r--r--lib/libcurses/curses.c74
-rw-r--r--lib/libcurses/curses.h1509
-rw-r--r--lib/libcurses/curses.priv.h270
-rw-r--r--lib/libcurses/delch.c63
-rw-r--r--lib/libcurses/deleteln.c82
-rw-r--r--lib/libcurses/delwin.c80
-rw-r--r--lib/libcurses/erase.c72
-rw-r--r--lib/libcurses/fullname.c60
-rw-r--r--lib/libcurses/getch.c75
-rw-r--r--lib/libcurses/getstr.c57
-rw-r--r--lib/libcurses/hardscroll.c420
-rw-r--r--lib/libcurses/id_subwins.c65
-rw-r--r--lib/libcurses/idlok.c54
-rw-r--r--lib/libcurses/initscr.c95
-rw-r--r--lib/libcurses/insch.c74
-rw-r--r--lib/libcurses/insertln.c82
-rw-r--r--lib/libcurses/keys.list150
-rw-r--r--lib/libcurses/lib_acs.c113
-rw-r--r--lib/libcurses/lib_addch.c287
-rw-r--r--lib/libcurses/lib_addstr.c88
-rw-r--r--lib/libcurses/lib_beep.c79
-rw-r--r--lib/libcurses/lib_bkgd.c41
-rw-r--r--lib/libcurses/lib_box.c146
-rw-r--r--lib/libcurses/lib_clear.c40
-rw-r--r--lib/libcurses/lib_clrbot.c72
-rw-r--r--lib/libcurses/lib_clreol.c70
-rw-r--r--lib/libcurses/lib_color.c325
-rw-r--r--lib/libcurses/lib_data.c64
-rw-r--r--lib/libcurses/lib_delch.c56
-rw-r--r--lib/libcurses/lib_delwin.c53
-rw-r--r--lib/libcurses/lib_doupdate.c840
-rw-r--r--lib/libcurses/lib_endwin.c55
-rw-r--r--lib/libcurses/lib_erase.c66
-rw-r--r--lib/libcurses/lib_getch.c329
-rw-r--r--lib/libcurses/lib_getstr.c131
-rw-r--r--lib/libcurses/lib_inchstr.c43
-rw-r--r--lib/libcurses/lib_initscr.c75
-rw-r--r--lib/libcurses/lib_insch.c54
-rw-r--r--lib/libcurses/lib_insdel.c51
-rw-r--r--lib/libcurses/lib_insstr.c61
-rw-r--r--lib/libcurses/lib_instr.c44
-rw-r--r--lib/libcurses/lib_isendwin.c37
-rw-r--r--lib/libcurses/lib_kernel.c309
-rw-r--r--lib/libcurses/lib_longname.c53
-rw-r--r--lib/libcurses/lib_mouse.c580
-rw-r--r--lib/libcurses/lib_move.c48
-rw-r--r--lib/libcurses/lib_mvcur.c1389
-rw-r--r--lib/libcurses/lib_mvwin.c55
-rw-r--r--lib/libcurses/lib_newterm.c189
-rw-r--r--lib/libcurses/lib_newwin.c193
-rw-r--r--lib/libcurses/lib_options.c364
-rw-r--r--lib/libcurses/lib_overlay.c135
-rw-r--r--lib/libcurses/lib_pad.c258
-rw-r--r--lib/libcurses/lib_printw.c93
-rw-r--r--lib/libcurses/lib_raw.c322
-rw-r--r--lib/libcurses/lib_refresh.c141
-rw-r--r--lib/libcurses/lib_resize.c152
-rw-r--r--lib/libcurses/lib_scanw.c88
-rw-r--r--lib/libcurses/lib_screen.c171
-rw-r--r--lib/libcurses/lib_scroll.c110
-rw-r--r--lib/libcurses/lib_scrreg.c47
-rw-r--r--lib/libcurses/lib_set_term.c141
-rw-r--r--lib/libcurses/lib_slk.c328
-rw-r--r--lib/libcurses/lib_touch.c64
-rw-r--r--lib/libcurses/lib_tstp.c252
-rw-r--r--lib/libcurses/lib_twait.c118
-rw-r--r--lib/libcurses/lib_unctrl.c47
-rw-r--r--lib/libcurses/lib_vidattr.c275
-rw-r--r--lib/libcurses/lib_window.c173
-rw-r--r--lib/libcurses/longname.c56
-rw-r--r--lib/libcurses/move.c62
-rw-r--r--lib/libcurses/mvwin.c77
-rw-r--r--lib/libcurses/newwin.c244
-rw-r--r--lib/libcurses/overlay.c82
-rw-r--r--lib/libcurses/overwrite.c76
-rw-r--r--lib/libcurses/printw.c200
-rw-r--r--lib/libcurses/putchar.c49
-rw-r--r--lib/libcurses/refresh.c827
-rw-r--r--lib/libcurses/scanw.c175
-rw-r--r--lib/libcurses/scroll.c71
-rw-r--r--lib/libcurses/setterm.c232
-rw-r--r--lib/libcurses/shlib_version2
-rw-r--r--lib/libcurses/standout.c67
-rw-r--r--lib/libcurses/toucholap.c77
-rw-r--r--lib/libcurses/touchwin.c120
-rw-r--r--lib/libcurses/tscroll.c139
-rw-r--r--lib/libcurses/tstp.c124
-rw-r--r--lib/libcurses/tty.c281
-rw-r--r--lib/libcurses/unctrl.c107
-rw-r--r--lib/libcurses/unctrl.h45
168 files changed, 15130 insertions, 9897 deletions
diff --git a/lib/libcurses/EXAMPLES/ex1.c b/lib/libcurses/EXAMPLES/ex1.c
deleted file mode 100644
index 76da41b4d9b..00000000000
--- a/lib/libcurses/EXAMPLES/ex1.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1992, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)ex1.c 8.1 (Berkeley) 6/4/93";
-#endif /* not lint */
-#include <sys/types.h>
-#include <curses.h>
-#include <stdio.h>
-#include <signal.h>
-
-
-#define YSIZE 10
-#define XSIZE 20
-
-int quit();
-
-main()
-{
- int i, j, c;
- size_t len;
- char id[100];
- FILE *fp;
- char *s;
-
- initscr(); /* Always call initscr() first */
- signal(SIGINT, quit); /* Make sure wou have a 'cleanup' fn */
- crmode(); /* We want cbreak mode */
- noecho(); /* We want to have control of chars */
- delwin(stdscr); /* Create our own stdscr */
- stdscr = newwin(YSIZE, XSIZE, 10, 35);
- flushok(stdscr, TRUE); /* Enable flushing of stdout */
- scrollok(stdscr, TRUE); /* Enable scrolling */
- erase(); /* Initially, clear the screen */
-
- standout();
- move(0,0);
- while (1) {
- c = getchar();
- switch(c) {
- case 'q': /* Quit on 'q' */
- quit();
- break;
- case 's': /* Go into standout mode on 's' */
- standout();
- break;
- case 'e': /* Exit standout mode on 'e' */
- standend();
- break;
- case 'r': /* Force a refresh on 'r' */
- wrefresh(curscr);
- break;
- default: /* By default output the character */
- addch(c);
- refresh();
- }
- }
-}
-
-
-int
-quit()
-{
- erase(); /* Terminate by erasing the screen */
- refresh();
- endwin(); /* Always end with endwin() */
- delwin(curscr); /* Return storage */
- delwin(stdscr);
- putchar('\n');
- exit(0);
-}
-
-
-
-
diff --git a/lib/libcurses/MKkeyname.awk b/lib/libcurses/MKkeyname.awk
new file mode 100644
index 00000000000..4d03ae95e23
--- /dev/null
+++ b/lib/libcurses/MKkeyname.awk
@@ -0,0 +1,31 @@
+
+BEGIN {
+ print ""
+ print "#include <stdlib.h>"
+ print "#include \"curses.h\""
+ print "#include \"term.h\""
+ print ""
+ print "struct kn {"
+ print "\tchar *name;"
+ print "\tint code;"
+ print "};"
+ print ""
+ print "const struct kn key_names[] = {"
+}
+
+{printf "\t{\"%s\", %s,},\n", $1, $2;}
+
+END {
+ print "};"
+ print ""
+ print "const char *keyname(int c)"
+ print "{"
+ print "int i, size = sizeof(key_names)/sizeof(struct kn);"
+ print ""
+ print "\tfor (i = 0; i < size; i++) {"
+ print "\t\tif (key_names[i].code == c) return key_names[i].name;"
+ print "\t}"
+ print "\treturn NULL;"
+ print "}"
+ print ""
+}
diff --git a/lib/libcurses/MKkeys.awk b/lib/libcurses/MKkeys.awk
new file mode 100644
index 00000000000..669c455ef54
--- /dev/null
+++ b/lib/libcurses/MKkeys.awk
@@ -0,0 +1 @@
+{printf "\tadd_to_try(%s, %s);\n", $1, $2;}
diff --git a/lib/libcurses/Makefile b/lib/libcurses/Makefile
index 408903dbfba..3de99d58687 100644
--- a/lib/libcurses/Makefile
+++ b/lib/libcurses/Makefile
@@ -1,24 +1,45 @@
-# @(#)Makefile 8.2 (Berkeley) 1/2/94
+LIB= curses
+SRCS= hardscroll.c lib_acs.c lib_delch.c lib_insstr.c lib_options.c \
+ lib_set_term.c lib_addch.c lib_delwin.c lib_instr.c lib_overlay.c \
+ lib_slk.c lib_addstr.c lib_doupdate.c lib_isendwin.c lib_pad.c \
+ lib_touch.c lib_beep.c lib_endwin.c lib_kernel.c lib_printw.c \
+ lib_tstp.c lib_bkgd.c lib_erase.c lib_longname.c lib_raw.c \
+ lib_twait.c lib_box.c lib_getch.c lib_mouse.c lib_refresh.c \
+ lib_unctrl.c lib_clear.c lib_getstr.c lib_move.c lib_resize.c \
+ lib_vidattr.c lib_clrbot.c lib_inchstr.c lib_mvcur.c lib_scanw.c \
+ lib_window.c lib_clreol.c lib_initscr.c lib_mvwin.c lib_screen.c \
+ lib_color.c lib_insch.c lib_newterm.c lib_scroll.c lib_data.c \
+ lib_insdel.c lib_keyname.c lib_newwin.c lib_scrreg.c
+CFLAGS+= -I. -I${.CURDIR} -DTERMIOS -DEXTERN_TERMINFO
+LDADD+= -ltermlib
+MAN= curs_addch.3 curs_addchstr.3 curs_addstr.3 curs_attr.3 curs_beep.3 \
+ curs_bkgd.3 curs_border.3 curs_clear.3 curs_color.3 curs_delch.3 \
+ curs_deleteln.3 curs_getch.3 curs_getstr.3 curs_getyx.3 curs_inch.3 \
+ curs_inchstr.3 curs_initscr.3 curs_inopts.3 curs_insch.3 curs_insstr.3 \
+ curs_instr.3 curs_kernel.3 curs_mouse.3 curs_move.3 curs_outopts.3 \
+ curs_overlay.3 curs_pad.3 curs_printw.3 curs_refresh.3 curs_scanw.3 \
+ curs_scr_dmp.3 curs_scroll.3 curs_slk.3 curs_termattrs.3 curs_touch.3 \
+ curs_util.3 curs_window.3 curses.3
+MLINKS+=curses.3 ncurses.3
+CLEANFILES+= lib_keyname.c keys.tries
-CFLAGS+=#-DTFILE=\"/dev/ttyp0\"
-CFLAGS+=-D_CURSES_PRIVATE -I${.CURDIR}
-LIB= curses
-SRCS= addbytes.c addch.c addnstr.c box.c clear.c clrtobot.c clrtoeol.c \
- cr_put.c ctrace.c cur_hash.c curses.c delch.c deleteln.c delwin.c \
- erase.c fullname.c getch.c getstr.c id_subwins.c idlok.c initscr.c \
- insch.c insertln.c longname.c move.c mvwin.c newwin.c overlay.c \
- overwrite.c printw.c putchar.c refresh.c scanw.c scroll.c setterm.c \
- standout.c toucholap.c touchwin.c tscroll.c tstp.c tty.c unctrl.c
-MAN= curses.3
+beforedepend: keys.tries
includes:
- -cd ${.CURDIR}; cmp -s curses.h ${DESTDIR}/usr/include/curses.h > \
- /dev/null 2>&1 || \
- install -c -o ${BINOWN} -g ${BINGRP} -m 444 curses.h \
- ${DESTDIR}/usr/include
+ @cd ${.CURDIR}; for i in unctrl.h; do \
+ cmp -s $$i ${DESTDIR}/usr/include/$$i || \
+ install -c -m 444 -o $(BINOWN) -g $(BINGRP) $$i \
+ ${DESTDIR}/usr/include; done
+ @cd ${.CURDIR}; cmp -s curses.h ${DESTDIR}/usr/include/curses.h || \
+ install -c -m 444 -o $(BINOWN) -g $(BINGRP) curses.h \
+ ${DESTDIR}/usr/include
-.if make(install)
-SUBDIR+= PSD.doc
-.endif
+keys.tries: ${.CURDIR}/keys.list ${.CURDIR}/MKkeys.awk
+ awk -f ${.CURDIR}/MKkeys.awk ${.CURDIR}/keys.list > keys.tries
+
+lib_keyname.c: ${.CURDIR}/keys.list ${.CURDIR}/MKkeyname.awk
+ awk -f ${.CURDIR}/MKkeyname.awk ${.CURDIR}/keys.list > lib_keyname.c
.include <bsd.lib.mk>
+
+lib_options.o lib_options.so lib_options.po lib_options.ln: keys.tries
diff --git a/lib/libcurses/PSD.doc/Makefile b/lib/libcurses/PSD.doc/Makefile
deleted file mode 100644
index 2ab371e08c0..00000000000
--- a/lib/libcurses/PSD.doc/Makefile
+++ /dev/null
@@ -1,39 +0,0 @@
-# @(#)Makefile 8.2 (Berkeley) 5/23/94
-
-DIR= psd/19.curses
-SRCS= Master
-MACROS= -me
-EXTRA= appen.A appen.B appen.C c_macros doc.I doc.II doc.III \
- doc.IV ex1.c ex2.c fns.doc intro.0 intro.1 intro.2 intro.3 \
- intro.4 intro.5 intro.6 life.c macros twinkle1.c twinkle2.c \
- win_st.c
-
-CLEANFILES+=win_st.gr twinkle1.gr twinkle2.gr life.gr intro.2.tbl appen.A.tbl \
- ex1.gr ex2.gr
-
-.SUFFIXES:
-.SUFFIXES: .c .gr
-
-#
-# this section formats C input source into nice troffable (or nroffable)
-# versions. It uses the capabilites of "vgrind", which sets keywords in
-# bold font, and comments in italics.
-#
-
-# Don't re-run vgrind unless you want to patch the output files.
-VFONT= /usr/libexec/vfontedpr
-.c.gr:
- ${VFONT} $*.c | grep -v "^'wh" > $*.gr
-
-paper.ps: ${SRCS}
- soelim ${SRCS} | ${ROFF} > ${.TARGET}
-
-Master: twinkle1.gr ex1.gr ex2.gr fns.doc intro.5 intro.2.tbl intro.0 intro.1 \
- intro.3 intro.4 intro.6 macros c_macros
-
-intro.2.tbl: intro.2
- ${TBL} intro.2 > intro.2.tbl
-
-.include <bsd.doc.mk>
-
-
diff --git a/lib/libcurses/PSD.doc/Master b/lib/libcurses/PSD.doc/Master
deleted file mode 100644
index 12db62b9bfa..00000000000
--- a/lib/libcurses/PSD.doc/Master
+++ /dev/null
@@ -1,54 +0,0 @@
-.\" Copyright (c) 1980, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)Master 8.2 (Berkeley) 5/24/94
-.\"
-.ds Ln Screen Package
-.so macros
-.so c_macros
-.so intro.0
-.pn 3
-.bp
-.so intro.1
-.so intro.2.tbl
-.so intro.3
-.so intro.4
-.so intro.5
-.so intro.6
-.bp
-.so appen.A
-.pn 2
-.oh '\*(Ln''PSD:19-%'
-.eh 'PSD:19-%''\*(Ln'
-.bp
-.bi Contents
-.sp
-.xp
diff --git a/lib/libcurses/PSD.doc/appen.A b/lib/libcurses/PSD.doc/appen.A
deleted file mode 100644
index a40c95d7891..00000000000
--- a/lib/libcurses/PSD.doc/appen.A
+++ /dev/null
@@ -1,77 +0,0 @@
-.\" Copyright (c) 1980, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)appen.A 8.1 (Berkeley) 6/8/93
-.\"
-.ie t .oh '\*(Ln Appendix A''PS1:19-%'
-.eh 'PS1:19-%''\*(Ln Appendix A'
-.el .he ''\fIAppendix A\fR''
-.bp
-.(x
-.ti 0
-.b "Appendix A"
-.)x
-.sh 1 "Examples" 1
-.pp
-Here we present a few examples
-of how to use the package.
-They attempt to be representative,
-though not comprehensive. Further examples can be found in the games section
-of the source tree and in various utilities that use the screen such as
-.i systat(1) .
-.pp
-The following examples are intended to demonstrate
-the basic structure of a program
-using the package. An additional, more comprehensive, program can be found in
-the source code in the
-\fIexamples\fP subdirectory.
-.sh 2 "Simple Character Output"
-.pp
-This program demonstrates how to set up a window and output characters to it.
-Also, it demonstrates how one might control the output to the window. If
-you run this program, you will get a demonstration of the character output
-chracteristics discussed in the above Character Output section.
-.(l I
-.so ex1.gr
-.)l
-.sh 2 "Twinkle"
-.pp
-This is a moderately simple program which prints
-patterns on the screen.
-It switches between patterns of asterisks,
-putting them on one by one in random order,
-and then taking them off in the same fashion.
-It is more efficient to write this
-using only the motion optimization,
-as is demonstrated below.
-.(l I
-.so twinkle1.gr
-.)l
diff --git a/lib/libcurses/PSD.doc/appen.B b/lib/libcurses/PSD.doc/appen.B
deleted file mode 100644
index 0f89fa551bb..00000000000
--- a/lib/libcurses/PSD.doc/appen.B
+++ /dev/null
@@ -1,201 +0,0 @@
-.\" Copyright (c) 1980, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)appen.B 8.1 (Berkeley) 6/8/93
-.\"
-.ie t .oh '\*(Ln Appendix B''PS1:19-%'
-.eh 'PS1:19-%''\*(Ln Appendix B'
-.el .he ''\fIAppendix B\fR''
-.bp
-.(x
-.ti 0
-.b "Appendix B"
-.)x
-.nr $1 0
-.sh 1 "The WINDOW structure"
-.pp
-The WINDOW structure is defined as follows:
-.(l I
-.so win_st.gr
-.)l
-.pp
-.Vn \*_cury \\*
-.(f
-\**
-All variables not normally accessed directly by the user
-are named with an initial
-.Bq \*_
-to avoid conflicts with the user's variables.
-.)f
-and
-.Vn \*_curx
-are the current \*y for the window.
-New characters added to the screen
-are added at this point.
-.Vn \*_maxy
-and
-.Vn \*_maxx
-are the maximum values allowed for
-.Vn \*_cury\*,\*_curx ). (
-.Vn \*_begy
-and
-.Vn \*_begx
-are the starting \*y on the terminal for the window,
-.i i.e. ,
-the window's home.
-.Vn \*_cury ,
-.Vn \*_curx ,
-.Vn \*_maxy ,
-and
-.Vn \*_maxx
-are measured relative to
-.Vn \*_begy\*,\*_begx ), (
-not the terminal's home.
-.pp
-.Vn \*_clear
-tells if a clear-screen sequence is to be generated
-on the next
-.Fn refresh
-call.
-This is only meaningful for screens.
-The initial clear-screen for the first
-.Fn refresh
-call is generated by initially setting clear to be TRUE for
-.Vn curscr ,
-which always generates a clear-screen if set,
-irrelevant of the dimensions of the window involved.
-.Vn \*_leave
-is TRUE if the current \*y and the cursor
-are to be left after the last character changed on the terminal,
-or not moved if there is no change.
-.Vn \*_scroll
-is TRUE
-if scrolling is allowed.
-.pp
-.Vn \*_y
-is a pointer to an array of lines which describe the terminal.
-Thus:
-.(l
-\*_y[i]
-.)l
-.lp
-is a pointer to the
-.Vn i th
-line, and
-.(l
-\*_y[i][j]
-.)l
-.lp
-is the
-.Vn j th
-character on the
-.Vn i th
-line.
-.Vn \*_flags
-can have one or more values
-or'd into it.
-.pp
-For windows that are not subwindows,
-.Vn \*_orig
-is
-NULL .
-For subwindows,
-it points to the main window
-to which the window is subsidiary.
-.Vn \*_nextp
-is a pointer in a circularly linked list
-of all the windows which are subwindows of the same main window,
-plus the main window itself.
-.pp
-.Vn \*_firstch
-and
-.Vn \*_lastch
-are
-.Fn malloc ed
-arrays which contain the index of the
-first and last changed characters
-on the line.
-.Vn \*_ch\*_off
-is the x offset for the window
-in the
-.Vn \*_firstch
-and
-.Vn \*_lastch
-arrays for this window.
-For main windows,
-this is always 0;
-for subwindows
-it is the difference between the starting point of the main window
-and that of the subindow,
-so that change markers can be set relative to the main window.
-This makes these markers global in scope.
-.pp
-All subwindows share the appropriate portions of
-.Vn _y ,
-.Vn _firstch ,
-.Vn _lastch ,
-and
-.Vn _insdel
-with their main window.
-.pp
-.b \*_ENDLINE
-says that the end of the line for this window
-is also the end of a screen.
-.b \*_FULLWIN
-says that this window is a screen.
-.b \*_SCROLLWIN
-indicates that the last character of this screen
-is at the lower right-hand corner of the terminal;
-.i i.e. ,
-if a character was put there,
-the terminal would scroll.
-.b \*_FULLLINE
-says that the width of a line is the same as the width of the terminal.
-If
-.b \*_FLUSH
-is set,
-it says that
-.Fn fflush "" "" stdout
-should be called at the end of each
-.Fn refresh
-.b \*_STANDOUT
-says that all characters added to the screen
-are in standout mode.
-.b \*_INSDEL
-is reserved for future use,
-and is set by
-.Fn idlok .
-.Vn \*_firstch
-is set to
-.b \*_NOCHANGE
-for lines on which there has been no change
-since the last
-.Fn refresh .
diff --git a/lib/libcurses/PSD.doc/appen.C b/lib/libcurses/PSD.doc/appen.C
deleted file mode 100644
index 65bef2bcb98..00000000000
--- a/lib/libcurses/PSD.doc/appen.C
+++ /dev/null
@@ -1,127 +0,0 @@
-.\" Copyright (c) 1980, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)appen.C 8.1 (Berkeley) 6/8/93
-.\"
-.ie t .oh '\*(Ln Appendix A''PS1:19-%'
-.eh 'PS1:19-%''\*(Ln Appendix A'
-.el .he ''\fIAppendix A\fR''
-.bp
-.(x
-.ti 0
-.b "Appendix A"
-.)x
-.sh 1 "Examples" 1
-.pp
-Here we present a few examples
-of how to use the package.
-They attempt to be representative,
-though not comprehensive. Further examples can be found in the games section
-of the source tree and in various utilities that use the screen such as
-.i systat(1) .
-.sh 2 "Screen Updating"
-.pp
-The following examples are intended to demonstrate
-the basic structure of a program
-using the screen updating sections of the package.
-Several of the programs require calculational sections
-which are irrelevant of to the example,
-and are therefore usually not included.
-It is hoped that the data structure definitions
-give enough of an idea to allow understanding
-of what the relevant portions do.
-.sh 3 "Simple Character Output"
-.pp
-This program demonstrates how to set up a window and output characters to it.
-Also, it demonstrates how one might control the output to the window. If
-you run this program, you will get a demonstration of the character output
-chracteristics discussed in the above Character Output section.
-.(l I
-.so t2.gr
-.)l
-.sh 3 "A Small Screen Manipulator"
-.pp
-The next example follows the lines of the previous one but extends then to
-demonstrate the various othe uses of the package. Make sure you understand
-how this program works as it encompasses most of anything you will
-need to do with the package.
-.(l I
-.so t3.gr
-.)l
-.sh 3 "Twinkle"
-.pp
-This is a moderately simple program which prints
-patterns on the screen.
-It switches between patterns of asterisks,
-putting them on one by one in random order,
-and then taking them off in the same fashion.
-It is more efficient to write this
-using only the motion optimization,
-as is demonstrated below.
-.(l I
-.so twinkle1.gr
-.)l
-.sh 3 "Life"
-.pp
-This program fragment models the famous computer pattern game of life
-(Scientific American, May, 1974).
-The calculational routines create a linked list of structures
-defining where each piece is.
-Nothing here claims to be optimal,
-merely demonstrative.
-This code, however,
-is a very good place to use the screen updating routines,
-as it allows them to worry about what the last position looked like,
-so you don't have to.
-It also demonstrates some of the input routines.
-.(l I
-.so life.gr
-.)l
-.sh 2 "Motion optimization"
-.pp
-The following example shows how motion optimization
-is written on its own.
-Programs which flit from one place to another without
-regard for what is already there
-usually do not need the overhead of both space and time
-associated with screen updating.
-They should instead use motion optimization.
-.sh 3 "Twinkle"
-.pp
-The
-.b twinkle
-program
-is a good candidate for simple motion optimization.
-Here is how it could be written
-(only the routines that have been changed are shown):
-.(l
-.so twinkle2.gr
-.)l
diff --git a/lib/libcurses/PSD.doc/c_macros b/lib/libcurses/PSD.doc/c_macros
deleted file mode 100644
index ba6ebbc1922..00000000000
--- a/lib/libcurses/PSD.doc/c_macros
+++ /dev/null
@@ -1,70 +0,0 @@
-.\" Copyright (c) 1980, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)c_macros 8.1 (Berkeley) 6/4/93
-.\"
-'ie t 'ds _ \d\(mi\u
-'el 'ds _ _
-'tr *\(**
-'ps 9p
-'vs 10p
-'ds - \(mi
-'ds /* \\h'\\w' 'u-\\w'/'u'/*
-'bd B 3
-'bd S B 3
-'nr cm 0
-'nf
-'de ()
-'pn 1
-..
-'de +C
-'nr cm 1
-'ft 2
-'ds +K
-'ds -K
-..
-'de -C
-'nr cm 0
-'ft 1
-.ie t 'ds +K \f3
-.el 'ds +K \fI
-'ds -K \fP
-..
-'+C
-'-C
-'am +C
-'ne 3
-..
-'de -F
-'rm =f
-..
-'ft 1
-'lg 0
diff --git a/lib/libcurses/PSD.doc/doc.I b/lib/libcurses/PSD.doc/doc.I
deleted file mode 100644
index 2345aba9b1c..00000000000
--- a/lib/libcurses/PSD.doc/doc.I
+++ /dev/null
@@ -1,349 +0,0 @@
-.\" Copyright (c) 1980, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)doc.I 8.1 (Berkeley) 6/4/93
-.\"
-.Ds
-.Fd addch ch \*m
-char ch;
-.Fd waddch win\*,ch
-WINDOW *win;
-char ch;
-.De
-Add the character
-.Vn ch
-on the window
-at the current \*y.
-If the character is a newline
-(\'\en\')
-the line will be cleared to the end,
-and the current \*y will be changed to the
-beginning off the next line
-if newline mapping is on,
-or to the next line at the same x co-ordinate
-if it is off.
-A return
-(\'\er\')
-will move to the beginning of the line on the window.
-Tabs
-(\'\et\')
-will be expanded into spaces
-in the normal tabstop positions of
-every eight characters.
-\*(Es
-.Ds
-.Fd addstr str \*m
-char *str;
-.Fd waddstr win\*,str
-WINDOW *win;
-char *str;
-.De
-Add the string pointed to by
-.Vn str
-on the window at the current \*y.
-\*(Es
-In this case, it will put on as much as it can.
-.Ds
-.Fd box win\*,vert\*,hor
-WINDOW *win;
-char vert\*,hor;
-.De
-.Pp
-Draws a box around the window using
-.Vn vert
-as the character for drawing the vertical sides, and
-.Vn hor
-for drawing the horizontal lines.
-If scrolling is not allowed,
-and the window encompasses the lower right-hand corner of the terminal,
-the corners are left blank to avoid a scroll.
-.Ds
-.Fd clear "" \*m
-.Fd wclear win
-WINDOW *win;
-.De
-Resets the entire window to blanks.
-If
-.Vn win
-is a screen,
-this sets the clear flag,
-which will cause a clear-screen sequence to be sent
-on the next
-.Fn refresh
-call.
-This also moves the current \*y
-to (0\*,0).
-.Ds
-.Fd clearok scr\*,boolf \*m
-WINDOW *scr;
-bool boolf;
-.De
-Sets the clear flag for the screen
-.Vn scr .
-If
-.Vn boolf
-is TRUE,
-this will force a clear-screen to be printed on the next
-.Fn refresh ,
-or stop it from doing so if
-.Vn boolf
-is FALSE.
-This only works on screens,
-and,
-unlike
-.Fn clear ,
-does not alter the contents of the screen.
-If
-.Vn scr
-is
-.Vn curscr ,
-the next
-.Fn refresh
-call will cause a clear-screen,
-even if the window passed to
-.Fn refresh
-is not a screen.
-.Ds
-.Fd clrtobot "" \*m
-.Fd wclrtobot win
-WINDOW *win;
-.De
-Wipes the window clear from the current \*y to the bottom.
-This does not force a clear-screen sequence on the next refresh
-under any circumstances.
-\*(Nm
-.Ds
-.Fd clrtoeol "" \*m
-.Fd wclrtoeol win
-WINDOW *win;
-.De
-Wipes the window clear from the current \*y to the end of the line.
-\*(Nm
-.Ds
-.Fd delch
-.Fd wdelch win
-WINDOW *win;
-.De
-Delete the character at the current \*y.
-Each character after it on the line shifts to the left,
-and the last character becomes blank.
-.Ds
-.Fd deleteln
-.Fd wdeleteln win
-WINDOW *win;
-.De
-Delete the current line.
-Every line below the current one will move up,
-and the bottom line will become blank.
-The current \*y will remain unchanged.
-.Ds
-.Fd erase "" \*m
-.Fd werase win
-WINDOW *win;
-.De
-Erases the window to blanks without setting the clear flag.
-This is analagous to
-.Fn clear ,
-except that it never causes a clear-screen sequence to be generated
-on a
-.Fn refresh .
-\*(Nm
-.Ds
-.Fd flushok win\*,boolf \*m
-WINDOW *win;
-bool boolf;
-.De
-Normally,
-.Fn refresh
-.Fn fflush 's
-.Vn stdout
-when it is finished.
-.Fn flushok
-allows you to control this.
-if
-.Vn boolf
-is TRUE
-(\c
-.i i.e. ,
-non-zero)
-it will do the
-.Fn fflush ;
-if it is FALSE.
-it will not.
-.Ds
-.Fd idlok win\*,boolf
-WINDOW *win;
-bool boolf;
-.De
-Reserved for future use.
-This will eventually signal to
-.Fn refresh
-that it is all right to use the insert and delete line sequences
-when updating the window.
-.Ds
-.Fd insch c
-char c;
-.Fd winsch win\*,c
-WINDOW *win;
-char c;
-.De
-Insert
-.Vn c
-at the current \*y
-Each character after it shifts to the right,
-and the last character disappears.
-\*(Es
-.Ds
-.Fd insertln
-.Fd winsertln win
-WINDOW *win;
-.De
-Insert a line above the current one.
-Every line below the current line
-will be shifted down,
-and the bottom line will disappear.
-The current line will become blank,
-and the current \*y will remain unchanged.
-.Ds
-.Fd move y\*,x \*m
-int y\*,x;
-.Fd wmove win\*,y\*,x
-WINDOW *win;
-int y\*,x;
-.De
-Change the current \*y of the window to
-.Vn y\*,x ). (
-\*(Es
-.Ds
-.Fd overlay win1\*,win2
-WINDOW *win1\*,*win2;
-.De
-Overlay
-.Vn win1
-on
-.Vn win2 .
-The contents of
-.Vn win1 ,
-insofar as they fit,
-are placed on
-.Vn win2
-at their starting \*y.
-This is done non-destructively,
-i.e., blanks on
-.Vn win1
-leave the contents of the space on
-.Vn win2
-untouched.
-.Ds
-.Fd overwrite win1\*,win2
-WINDOW *win1\*,*win2;
-.De
-Overwrite
-.Vn win1
-on
-.Vn win2 .
-The contents of
-.Vn win1 ,
-insofar as they fit,
-are placed on
-.Vn win2
-at their starting \*y.
-This is done destructively,
-.i i.e. ,
-blanks on
-.Vn win1
-become blank on
-.Vn win2 .
-.Ds
-.Fd printw fmt\*,arg1\*,arg2\*,...
-char *fmt;
-.Fd wprintw win\*,fmt\*,arg1\*,arg2\*,...
-WINDOW *win;
-char *fmt;
-.De
-Performs a
-.Fn printf
-on the window starting at the current \*y.
-It uses
-.Fn addstr
-to add the string on the window.
-It is often advisable to use the field width options of
-.Fn printf
-to avoid leaving things on the window from earlier calls.
-\*(Es
-.Ds
-.Fd refresh "" \*m
-.Fd wrefresh win
-WINDOW *win;
-.De
-Synchronize the terminal screen with the desired window.
-If the window is not a screen,
-only that part covered by it is updated.
-\*(Es
-In this case, it will update whatever it can
-without causing the scroll.
-.sp
-As a special case,
-if
-.Fn wrefresh
-is called with the window
-.Vn curscr
-the screen is cleared
-and repainted as it is currently.
-This is very useful for allowing the redrawing of the screen
-when the user has garbage dumped on his terminal.
-.Ds
-.Fd standout "" \*m
-.Fd wstandout win
-WINDOW *win;
-.Fd standend "" \*m
-.Fd wstandend win
-WINDOW *win;
-.De
-Start and stop putting characters onto
-.i win
-in standout mode.
-.Fn standout
-causes any characters added to the window
-to be put in standout mode on the terminal
-(if it has that capability).
-.Fn standend
-stops this.
-The sequences
-.Vn SO
-and
-.Vn SE
-(or
-.Vn US
-and
-.Vn UE
-if they are not defined)
-are used (see Appendix A).
diff --git a/lib/libcurses/PSD.doc/doc.II b/lib/libcurses/PSD.doc/doc.II
deleted file mode 100644
index 1f6880247bc..00000000000
--- a/lib/libcurses/PSD.doc/doc.II
+++ /dev/null
@@ -1,142 +0,0 @@
-.\" Copyright (c) 1980, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)doc.II 8.1 (Berkeley) 6/4/93
-.\"
-.Ds
-.Fd cbreak "" \*m
-.Fd nocbreak "" \*m
-.Fd crmode "" \*m
-.Fd nocrmode "" \*m
-.De
-Set or unset the terminal to/from cbreak mode.
-The misnamed macros
-.Fn crmode
-and
-.Fn nocrmode
-are retained for backwards compatibility
-with ealier versions of the library.
-.Ds
-.Fd echo "" \*m
-.Fd noecho "" \*m
-.De
-Sets the terminal to echo or not echo characters.
-.Ds
-.Fd getch "" \*m
-.Fd wgetch win
-WINDOW *win;
-.De
-Gets a character from the terminal and (if necessary)
-echos it on the window.
-\*(Es
-Otherwise, the character gotten is returned.
-If
-.i noecho
-has been set, then the window is left unaltered.
-In order to retain control of the terminal,
-it is necessary to have one of
-.i noecho ,
-.i cbreak ,
-or
-.i rawmode
-set.
-If you do not set one,
-whatever routine you call to read characters will set
-.i cbreak
-for you,
-and then reset to the original mode when finished.
-.Ds
-.Fd getstr str \*m
-char *str;
-.Fd wgetstr win\*,str
-WINDOW *win;
-char *str;
-.De
-Get a string through the window
-and put it in the location pointed to by
-.Vn str ,
-which is assumed to be large enough to handle it.
-It sets tty modes if necessary,
-and then calls
-.Fn getch
-(or
-.Fn wgetch ) "" win
-to get the characters needed to fill in the string
-until a newline or EOF is encountered.
-The newline stripped off the string.
-\*(Es
-.Ds
-.Fd \*_putchar c
-char c;
-.De
-Put out a character using the
-.Fn putchar
-macro.
-This function is used to output every character
-that
-.b curses
-generates.
-Thus,
-it can be redefined by the user who wants to do non-standard things
-with the output.
-It is named with an initial \*(lq\*_\*(rq
-because it usually should be invisible to the programmer.
-.Ds
-.Fd raw "" \*m
-.Fd noraw "" \*m
-.De
-Set or unset the terminal to/from raw mode.
-On version 7
-.Un \**
-.(f
-\**
-.Un
-is a trademark of Bell Laboratories.
-.)f
-this also turns of newline mapping
-(see
-.Fn nl ).
-.Ds
-.Fd scanw fmt\*,arg1\*,arg2\*,...
-char *fmt;
-.Fd wscanw win\*,fmt\*,arg1\*,arg2\*,...
-WINDOW *win;
-char *fmt;
-.De
-Perform a
-.Fn scanf
-through the window using
-.Vn fmt .
-It does this using consecutive
-.Fn getch 's
-(or
-.Fn wgetch 's). "" win
-\*(Es
diff --git a/lib/libcurses/PSD.doc/doc.III b/lib/libcurses/PSD.doc/doc.III
deleted file mode 100644
index 7d710d49dbc..00000000000
--- a/lib/libcurses/PSD.doc/doc.III
+++ /dev/null
@@ -1,343 +0,0 @@
-.\" Copyright (c) 1980, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)doc.III 8.1 (Berkeley) 6/4/93
-.\"
-.Ds
-.Fd baudrate "" \*m
-.De
-Returns the output baud rate of the terminal.
-This is a system dependent constant
-(defined in
-.b <sys/tty.h>
-on BSD systems,
-which is included by
-.b <curses.h> ).
-.Ds
-.Fd delwin win
-WINDOW *win;
-.De
-Deletes the window from existence.
-All resources are freed for future use by
-.b calloc (3).
-If a window has a
-.Fn subwin
-allocated window inside of it,
-deleting the outer window
-the subwindow is not affected,
-even though this does invalidate it.
-Therefore,
-subwindows should be deleted before their
-outer windows are.
-.Ds
-.Fd endwin
-.De
-Finish up window routines before exit.
-This restores the terminal to the state it was before
-.Fn initscr
-(or
-.Fn gettmode
-and
-.Fn setterm )
-was called.
-It should always be called before exiting.
-It does not exit.
-This is especially useful for resetting tty stats
-when trapping rubouts via
-.b signal (2).
-.Ds
-.Fd erasechar "" \*m
-.De
-Returns the erase character
-for the terminal,
-.i i.e. ,
-the character used by the user to erase a single character from the input.
-.Ds
-.Fd getcap str "" "char *"
-char *str;
-.De
-Return a pointer to the
-.b termcap
-capability described by
-.Vn str
-(see
-.b termcap (5)
-for details).
-.Ds
-.Fd getyx win\*,y\*,x \*m
-WINDOW *win;
-int y\*,x;
-.De
-Puts the current \*y of
-.Vn win
-in the variables
-.Vn y
-and
-.Vn x .
-Since it is a macro,
-not a function,
-you do not pass the address
-of
-.Vn y
-and
-.Vn x .
-.Ds
-.Fd inch "" \*m
-.Fd winch win \*m
-WINDOW *win;
-.De
-Returns the character at the current \*(y
-on the given window.
-This does not make any changes to the window.
-.Ds
-.Fd initscr
-.De
-Initialize the screen routines.
-This must be called before any of the screen routines are used.
-It initializes the terminal-type data and such,
-and without it none of the routines can operate.
-If standard input is not a tty,
-it sets the specifications to the terminal
-whose name is pointed to by
-.Vn Def\*_term
-(initialy "dumb").
-If the boolean
-.Vn My\*_term
-is true,
-.Vn Def\*_term
-is always used.
-If the system supports the
-.b TIOCGWINSZ
-.Fn ioctl "" "" 2
-call,
-it is used to get the number of lines and columns for the terminal,
-otherwise it is taken from the
-.b termcap
-description.
-.Ds
-.Fd killchar "" \*m
-.De
-Returns the line kill character
-for the terminal,
-.i i.e. ,
-the character used by the user to erase an entire line from the input.
-.Ds
-.Fd leaveok win\*,boolf \*m
-WINDOW *win;
-bool boolf;
-.De
-Sets the boolean flag for leaving the cursor after the last change.
-If
-.Vn boolf
-is TRUE,
-the cursor will be left after the last update on the terminal,
-and the current \*y for
-.Vn win
-will be changed accordingly.
-If it is FALSE,
-it will be moved to the current \*y.
-This flag
-(initialy FALSE)
-retains its value until changed by the user.
-.Ds
-.Fd longname termbuf\*,name
-char *termbuf\*,*name;
-.Fd fullname termbuf\*,name
-char *termbuf\*,*name;
-.De
-.Fn longname
-fills in
-.Vn name
-with the long name of the terminal described by the
-.b termcap
-entry in
-.Vn termbuf .
-It is generally of little use,
-but is nice for telling the user in a readable format what terminal
-we think he has.
-This is available in the global variable
-.Vn ttytype .
-.Vn termbuf
-is usually set via the termlib routine
-.Fn tgetent .
-.Fn fullname
-is the same as
-.Fn longname ,
-except that it gives the fullest name given in the entry,
-which can be quite verbose.
-.Ds
-.Fd mvwin win\*,y\*,x
-WINDOW *win;
-int y, x;
-.De
-Move the home position of the window
-.Vn win
-from its current starting coordinates
-to
-.Vn y\*,x ). (
-If that would put part or all of the window
-off the edge of the terminal screen,
-.Fn mvwin
-returns ERR and does not change anything.
-For subwindows,
-.Fn mvwin
-also returns ERR if you attempt to move it off its main window.
-If you move a main window,
-all subwindows are moved along with it.
-.Ds
-.Fd newwin lines\*,cols\*,begin\*_y\*,begin\*_x "" "WINDOW *"
-int lines\*,cols\*,begin\*_y\*,begin\*_x;
-.De
-Create a new window with
-.Vn lines
-lines and
-.Vn cols
-columns starting at position
-.Vn begin\*_y\*,begin\*_x ). (
-If either
-.Vn lines
-or
-.Vn cols
-is 0 (zero),
-that dimension will be set to
-.Vn "LINES \- begin\*_y" ) (
-or
-.Vn "COLS \- begin\*_x" ) (
-respectively.
-Thus, to get a new window of dimensions
-.Vn LINES
-\(mu
-.Vn COLS ,
-use
-.Fn newwin . "" 0\*,0\*,0\*,0
-.Ds
-.Fd nl "" \*m
-.Fd nonl "" \*m
-.De
-Set or unset the terminal to/from nl mode,
-.i i.e. ,
-start/stop the system from mapping
-.b <RETURN>
-to
-.b <LINE-FEED> .
-If the mapping is not done,
-.Fn refresh
-can do more optimization,
-so it is recommended, but not required, to turn it off.
-.Ds
-.Fd scrollok win\*,boolf \*m
-WINDOW *win;
-bool boolf;
-.De
-Set the scroll flag for the given window.
-If
-.Vn boolf
-is FALSE, scrolling is not allowed.
-This is its default setting.
-.Ds
-.Fd touchline win\*,y\*,startx\*,endx
-WINDOW *win;
-int y\*,startx\*,endx;
-.De
-This function performs a function similar to
-.Fn touchwin
-on a single line.
-It marks the first change for the given line
-to be
-.Vn startx ,
-if it is before the current first change mark,
-and
-the last change mark is set to be
-.Vn endx
-if it is currently less than
-.Vn endx .
-.Ds
-.Fd touchoverlap win1\*,win2
-WINDOW *win1, *win2;
-.De
-Touch the window
-.Vn win2
-in the area which overlaps with
-.Vn win1 .
-If they do not overlap,
-no changes are made.
-.Ds
-.Fd touchwin win
-WINDOW *win;
-.De
-Make it appear that the every location on the window
-has been changed.
-This is usually only needed for refreshes with overlapping windows.
-.Ds
-.Fd subwin win\*,lines\*,cols\*,begin\*_y\*,begin\*_x "" "WINDOW *"
-WINDOW *win;
-int lines\*,cols\*,begin\*_y\*,begin\*_x;
-.De
-Create a new window with
-.Vn lines
-lines and
-.Vn cols
-columns starting at position
-.Vn begin\*_y\*,begin\*_x ) (
-inside the window
-.i win .
-This means that any change made to either window
-in the area covered
-by the subwindow will be made on both windows.
-.Vn begin\*_y\*,begin\*_x
-are specified relative to the overall screen,
-not the relative (0\*,0) of
-.Vn win .
-If either
-.Vn lines
-or
-.Vn cols
-is 0 (zero),
-that dimension will be set to
-.Vn "LINES \- begin\*_y" ) (
-or
-.Vn "COLS \- begin\*_x" ) (
-respectively.
-.Ds
-.Fd unctrl ch \*m
-char ch;
-.De
-This is actually a debug function for the library,
-but it is of general usefulness.
-It returns a string which is a representation of
-.Vn ch .
-Control characters become their upper-case equivalents preceded by a "^".
-Other letters stay just as they are.
-To use
-.Fn unctrl ,
-you may have to have
-.b #include\ <unctrl.h>
-in your file.
diff --git a/lib/libcurses/PSD.doc/doc.IV b/lib/libcurses/PSD.doc/doc.IV
deleted file mode 100644
index 717a9863abb..00000000000
--- a/lib/libcurses/PSD.doc/doc.IV
+++ /dev/null
@@ -1,110 +0,0 @@
-.\" Copyright (c) 1980, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)doc.IV 8.1 (Berkeley) 6/4/93
-.\"
-.Ds
-.Fd gettmode
-.De
-Get the tty stats.
-This is normally called by
-.Fn initscr .
-.Ds
-.Fd mvcur lasty\*,lastx\*,newy\*,newx
-int lasty\*,lastx\*,newy\*,newx;
-.De
-Moves the terminal's cursor from
-.Vn lasty\*,lastx ) (
-to
-.Vn newy\*,newx ) (
-in an approximation of optimal fashion.
-This routine uses the functions borrowed from
-.i ex
-version 2.6.
-It is possible to use this optimization
-without the benefit of the screen routines.
-With the screen routines, this should not be called by the user.
-.Fn move
-and
-.Fn refresh
-should be used to move the cursor position,
-so that the routines know what's going on.
-.Ds
-.Fd scroll win
-WINDOW *win;
-.De
-Scroll the window upward one line.
-This is normally not used by the user.
-.Ds
-.Fd savetty "" \*m
-.Fd resetty "" \*m
-.De
-.Fn savetty
-saves the current tty characteristic flags.
-.Fn resetty
-restores them to what
-.Fn savetty
-stored.
-These functions are performed automatically by
-.Fn initscr
-and
-.Fn endwin .
-.Ds
-.Fd setterm name
-char *name;
-.De
-Set the terminal characteristics to be those of the terminal named
-.Vn name ,
-getting the terminal size from the
-.b TIOCGWINSZ
-.Fn ioctl "" "" 2
-if it exists,
-otherwise from the environment.
-This is normally called by
-.Fn initscr .
-.Ds
-.Fd tstp
-.De
-If the new
-.b tty (4)
-driver is in use,
-this function
-will save the current tty state
-and then put the process to sleep.
-When the process gets restarted,
-it restores the tty state
-and then calls
-.Fn wrefresh "" "" curscr
-to redraw the screen.
-.Fn initscr
-sets the signal
-SIGTSTP
-to trap to this routine.
diff --git a/lib/libcurses/PSD.doc/ex1.c b/lib/libcurses/PSD.doc/ex1.c
deleted file mode 100644
index 02ed9b936bd..00000000000
--- a/lib/libcurses/PSD.doc/ex1.c
+++ /dev/null
@@ -1,102 +0,0 @@
-.\" Copyright (c) 1992, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)ex1.c 8.1 (Berkeley) 6/8/93
-.\"
-#include <sys/types.h>
-#include <curses.h>
-#include <stdio.h>
-#include <signal.h>
-
-
-#define YSIZE 10
-#define XSIZE 20
-
-int quit();
-
-main()
-{
- int i, j, c;
- size_t len;
- char id[100];
- FILE *fp;
- char *s;
-
- initscr(); /* Always call initscr() first */
- signal(SIGINT, quit); /* Make sure wou have a 'cleanup' fn */
- crmode(); /* We want cbreak mode */
- noecho(); /* We want to have control of chars */
- delwin(stdscr); /* Create our own stdscr */
- stdscr = newwin(YSIZE, XSIZE, 10, 35);
- flushok(stdscr, TRUE); /* Enable flushing of stdout */
- scrollok(stdscr, TRUE); /* Enable scrolling */
- erase(); /* Initially, clear the screen */
-
- standout();
- move(0,0);
- while (1) {
- c = getchar();
- switch(c) {
- case 'q': /* Quit on 'q' */
- quit();
- break;
- case 's': /* Go into standout mode on 's' */
- standout();
- break;
- case 'e': /* Exit standout mode on 'e' */
- standend();
- break;
- case 'r': /* Force a refresh on 'r' */
- wrefresh(curscr);
- break;
- default: /* By default output the character */
- addch(c);
- refresh();
- }
- }
-}
-
-
-int
-quit()
-{
- erase(); /* Terminate by erasing the screen */
- refresh();
- endwin(); /* Always end with endwin() */
- delwin(curscr); /* Return storage */
- delwin(stdscr);
- putchar('\n');
- exit(0);
-}
-
-
-
-
diff --git a/lib/libcurses/PSD.doc/ex2.c b/lib/libcurses/PSD.doc/ex2.c
deleted file mode 100644
index 13e8f2990b9..00000000000
--- a/lib/libcurses/PSD.doc/ex2.c
+++ /dev/null
@@ -1,210 +0,0 @@
-.\" Copyright (c) 1992, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)ex2.c 8.1 (Berkeley) 6/8/93
-.\"
-#include <curses.h>
-#include <stdio.h>
-#include <signal.h>
-
-#define YSIZE LINES
-#define XSIZE COLS
-
-static int quit();
-
-/*
- * This program fills the screen up with characters and the allows the user to
- * manipulate the text on the screen using some basic commands.
- * Nothing fancy, just a demonstration of the elementary features of the
- * curses(3) package.
- */
-main()
-{
- int i, j, c, n, d = 0;
- char id[100];
- int hh = 0;
- int curx, cury, base, arg;
-
- initscr();
- signal(SIGINT, quit);
- crmode();
- noecho();
- nonl();
- delwin(stdscr);
- stdscr = newwin(YSIZE, XSIZE, 0, 0);
- flushok(stdscr, TRUE);
- scrollok(stdscr, TRUE);
- erase();
- refresh();
-
- move(0,0);
- refresh();
- for (i = 0; i < YSIZE + 2; i++) {
- sprintf(id, "%d: ", i);
- addstr(id);
- for (j = 0; j < XSIZE - strlen(id); j++)
- addch('0' + (i % 10));
- }
- c = getchar();
- base = 2;
- curx = cury = 0;
- move(0, 0);
- refresh();
-
- /*
- * The screen manipulator has the following commands:
- * 'D' - clear to the end of the current line.
- * 'B' - clear to the bottom of the screen.
- * 'E' - erase the screen.
- * 's' - enter standout mode.
- * 'e' - exit standout mode.
- * 'd' n - delete n lines below cursor line.
- * 'i' n - insert n lines below cursor line.
- * 'q' - quit.
- * 'f' - move cursor one position to the right.
- * 'b' - move cursor one position to the left.
- * 'n' - move cursor one line down.
- * 'p' - move cursor one line up.
- * 'h' - home cusor.
- * 'l' - force refresh.
- * 'r' - simulate a carriage return.
- *
- * All other characters are ignored.
- */
- for(;;) {
- switch(c = getchar()) {
- case 'D':
- clrtoeol();
- refresh();
- continue;
- case 'B':
- clrtobot();
- refresh();
- continue;
- case 'E':
- erase();
- refresh();
- continue;
- case 's':
- standout();
- continue;
- case 'e':
- standend();
- continue;
- case 'd':
- arg = getchar() - '0';
- for (i = 0; i < arg; i++)
- deleteln();
- refresh();
- continue;
- case 'i':
- arg = getchar() - '0';
- for (i = 0; i < arg; i++)
- insertln();
- refresh();
- continue;
- case 'q':
- quit();
- case 'f':
- if (curx < XSIZE - 1)
- curx++;
- else {
- cury++;
- curx = 0;
- }
- break;
- case 'b':
- if (curx == 0) {
- cury--;
- curx = XSIZE - 1;
- } else
- curx--;
- break;
- case 'n':
- cury++;
- break;
- case 'p':
- cury--;
- break;
- case 'h':
- curx = cury = 0;
- break;
- case 'l':
- wrefresh(curscr);
- continue;
- case 'r': /* return */
- {
- int x, y;
- getyx(stdscr, y, x);
- move(y+1, 0);
- insertln();
- move(y, x);
- clrtoeol();
- refresh();
- continue;
- }
- default:
- continue;
- }
-
- if (cury < 0) {
- base--;
- move(0, 0);
- insertln();
- sprintf(id, "%d: ", base);
- addstr(id);
- for (j = 0; j < XSIZE - strlen(id) - 2; j++)
- addch('0' + (base % 10));
- cury++;
- } else if (cury >= YSIZE) {
- move(0, 0);
- deleteln();
- move(YSIZE - 1, 0);
- sprintf(id, "%d: ", base + YSIZE);
- addstr(id);
- for (j = 0; j < XSIZE - strlen(id) - 2; j++)
- addch('0' + ((base + YSIZE) % 10));
- cury--;
- base++;
- }
- move(cury, curx);
- refresh();
- }
-}
-
-int
-quit()
-{
- erase();
- refresh();
- endwin();
- exit(0);
-}
diff --git a/lib/libcurses/PSD.doc/fns.doc b/lib/libcurses/PSD.doc/fns.doc
deleted file mode 100644
index 0fa89abd3f7..00000000000
--- a/lib/libcurses/PSD.doc/fns.doc
+++ /dev/null
@@ -1,799 +0,0 @@
-.\" Copyright (c) 1992, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)fns.doc 8.2 (Berkeley) 6/1/94
-.\"
-.Ds
-.Fn addch "char ch" \(dg
-.De
-Add the character
-.Vn ch
-on the window
-at the current \*y.
-If the character is a newline
-(\'\en\')
-the line will be cleared to the end,
-and the current \*y will be changed to the
-beginning off the next line
-if newline mapping is on,
-or to the next line at the same x co-ordinate
-if it is off.
-A return
-(\'\er\')
-will move to the beginning of the line on the window.
-Tabs
-(\'\et\')
-will be expanded into spaces
-in the normal tabstop positions of
-every eight characters.
-\*(Es
-.Ds
-.Fn addstr "char *str" \(dg
-.De
-Add the string pointed to by
-.Vn str
-on the window at the current \*y.
-\*(Es
-In this case, it will put on as much as it can.
-.Ds
-.Fn baudrate "" \(dg
-.De
-Returns the output baud rate of the terminal.
-This is a system dependent constant
-(defined in
-.b <sys/tty.h>
-on BSD systems,
-which is included by
-.b <curses.h> ).
-.Ds
-.Fn box "WINDOW win" "char vert" "char hor"
-.De
-.Pp
-Draws a box around the window using
-.Vn vert
-as the character for drawing the vertical sides, and
-.Vn hor
-for drawing the horizontal lines.
-If scrolling is not allowed,
-and the window encompasses the lower right-hand corner of the terminal,
-the corners are left blank to avoid a scroll.
-.Ds
-.Fn cbreak "" \(dg
-.De
-Set or the terminal to cbreak mode.
-.Ds
-.Fn clear "" \(dg
-.De
-Resets the entire window to blanks.
-If
-.Vn win
-is a screen,
-this sets the clear flag,
-which will cause a clear-screen sequence to be sent
-on the next
-.Fn refresh
-call.
-This also moves the current \*y
-to (0\*,0).
-.Ds
-.Fn clearok "WINDOW *scr" "int boolf" \(dg
-.De
-Sets the clear flag for the screen
-.Vn scr .
-If
-.Vn boolf
-is non-zero,
-this will force a clear-screen to be printed on the next
-.Fn refresh ,
-or stop it from doing so if
-.Vn boolf
-is 0.
-This only works on screens,
-and,
-unlike
-.Fn clear ,
-does not alter the contents of the screen.
-If
-.Vn scr
-is
-.Vn curscr ,
-the next
-.Fn refresh
-call will cause a clear-screen,
-even if the window passed to
-.Fn refresh
-is not a screen.
-.Ds
-.Fn clrtobot "" \(dg
-.De
-Wipes the window clear from the current \*y to the bottom.
-This does not force a clear-screen sequence on the next refresh
-under any circumstances.
-\*(Nm
-.Ds
-.Fn clrtoeol "" \(dg
-.De
-Wipes the window clear from the current \*y to the end of the line.
-\*(Nm
-.Ds
-.Fn crmode "" \(dg
-.De
-Identical to
-.Fn cbreak .
-The misnamed macro
-.Fn crmode
-and
-.Fn nocrmode
-is retained for backwards compatibility
-with ealier versions of the library.
-.Ds
-.Fn delch ""
-.De
-Delete the character at the current \*y.
-Each character after it on the line shifts to the left,
-and the last character becomes blank.
-.Ds
-.Fn deleteln ""
-.De
-Delete the current line.
-Every line below the current one will move up,
-and the bottom line will become blank.
-The current \*y will remain unchanged.
-.Ds
-.Fn delwin "WINDOW *win"
-.De
-Deletes the window from existence.
-All resources are freed for future use by
-.b calloc (3).
-If a window has a
-.Fn subwin
-allocated window inside of it,
-deleting the outer window
-the subwindow is not affected,
-even though this does invalidate it.
-Therefore,
-subwindows should be deleted before their
-outer windows are.
-.Ds
-.Fn echo "" \(dg
-.De
-Sets the terminal to echo characters.
-.Ds
-.Fn endwin ""
-.De
-Finish up window routines before exit.
-This restores the terminal to the state it was before
-.Fn initscr
-(or
-.Fn gettmode
-and
-.Fn setterm )
-was called.
-It should always be called before exiting and before the final calls to
-.Fn delwin .
-It does not exit.
-This is especially useful for resetting tty stats
-when trapping rubouts via
-.b signal (2).
-.Ds
-.Fn erase "" \(dg
-.De
-Erases the window to blanks without setting the clear flag.
-This is analagous to
-.Fn clear ,
-except that it never causes a clear-screen sequence to be generated
-on a
-.Fn refresh .
-\*(Nm
-.Ds
-.Fn erasechar "" \(dg
-.De
-Returns the erase character
-for the terminal,
-.i i.e. ,
-the character used by the user to erase a single character from the input.
-.Ds
-.Fn flushok "WINDOW *win" "int boolf"
-.De
-Normally,
-.Fn refresh
-.Fn fflush 's
-.Vn stdout
-when it is finished.
-.Fn flushok
-allows you to control this.
-if
-.Vn boolf
-is non-zero
-(\c
-.i i.e. ,
-non-zero)
-it will do the
-.Fn fflush ,
-otherwise it will not.
-.Ds
-.Fn getch "" \(dg
-.De
-Gets a character from the terminal and (if necessary)
-echos it on the window.
-\*(Es
-Otherwise, the character gotten is returned.
-If
-.i noecho
-has been set, then the window is left unaltered.
-In order to retain control of the terminal,
-it is necessary to have one of
-.i noecho ,
-.i cbreak ,
-or
-.i rawmode
-set.
-If you do not set one,
-whatever routine you call to read characters will set
-.i cbreak
-for you,
-and then reset to the original mode when finished.
-.Ds
-.Fn getstr "char *str" \(dg
-.De
-Get a string through the window
-and put it in the location pointed to by
-.Vn str ,
-which is assumed to be large enough to handle it.
-It sets tty modes if necessary,
-and then calls
-.Fn getch
-(or
-.Fn wgetch )
-to get the characters needed to fill in the string
-until a newline or EOF is encountered.
-The newline stripped off the string.
-\*(Es
-.Ds
-.Fn gettmode ""
-.De
-Get the tty stats.
-This is normally called by
-.Fn initscr .
-.Ds
-.Fn getyx "WINDOW *win" "int y" "int x"
-.De
-Puts the current \*y of
-.Vn win
-in the variables
-.Vn y
-and
-.Vn x .
-Since it is a macro,
-not a function,
-you do not pass the address
-of
-.Vn y
-and
-.Vn x .
-.Ds
-.Fn idlok "WINDOW *win" "int boolf"
-.De
-Reserved for future use.
-This will eventually signal to
-.Fn refresh
-that it is all right to use the insert and delete line sequences
-when updating the window.
-.ne 1i
-.Ds
-.Fn inch "" \(dg
-.De
-Returns the character at the current position on the given window.
-This does not make any changes to the window.
-.Ds
-.Fn initscr ""
-.De
-Initialize the screen routines.
-This must be called before any of the screen routines are used.
-It initializes the terminal-type data and such,
-and without it none of the routines can operate.
-If standard input is not a tty,
-it sets the specifications to the terminal
-whose name is pointed to by
-.Vn Def\*_term
-(initially "dumb").
-If the boolean
-.Vn My\*_term
-is non-zero,
-.Vn Def\*_term
-is always used.
-If the system supports the
-.b TIOCGWINSZ
-.i ioctl(2)
-call,
-it is used to get the number of lines and columns for the terminal,
-otherwise it is taken from the
-.b termcap
-description.
-.Ds
-.Fn insch "char c"
-.De
-Insert
-.Vn c
-at the current \*y
-Each character after it shifts to the right,
-and the last character disappears.
-\*(Es
-.Ds
-.Fn insertln ""
-.De
-Insert a line above the current one.
-Every line below the current line
-will be shifted down,
-and the bottom line will disappear.
-The current line will become blank,
-and the current \*y will remain unchanged.
-.Ds
-.Fn killchar "" \(dg
-.De
-Returns the line kill character
-for the terminal,
-.i i.e. ,
-the character used by the user to erase an entire line from the input.
-.Ds
-.Fn leaveok "WINDOW *win" "int boolf" \(dg
-.De
-Sets the boolean flag for leaving the cursor after the last change.
-If
-.Vn boolf
-is non-zero,
-the cursor will be left after the last update on the terminal,
-and the current \*y for
-.Vn win
-will be changed accordingly.
-If
-.Vn boolf
- is 0 the cursor will be moved to the current \*y.
-This flag
-(initially 0)
-retains its value until changed by the user.
-.Ds
-.Fn move "int y" "int x"
-.De
-Change the current \*y of the window to
-.Vn y\*,x ). (
-\*(Es
-.Ds
-.Fn mvcur "int lasty" "int lastx" "int newy" "int newx"
-.De
-Moves the terminal's cursor from
-.Vn lasty\*,lastx ) (
-to
-.Vn newy\*,newx ) (
-in an approximation of optimal fashion.
-This routine uses the functions borrowed from
-.i ex
-version 2.6.
-It is possible to use this optimization
-without the benefit of the screen routines.
-With the screen routines, this should not be called by the user.
-.Fn move
-and
-.Fn refresh
-should be used to move the cursor position,
-so that the routines know what's going on.
-.Ds
-.Fn mvprintw "int y" "int x" "const char *fmt" "..."
-.De
-Equivalent to:
-.(l
-move(y, x);
-printw(fmt, ...);
-.)l
-.Ds
-.Fn mvscanw "int y" "int x" "const char *fmt" "..."
-.De
-Equivalent to:
-.(l
-move(y, x);
-scanw(fmt, ...);
-.)l
-.Ds
-.Fn mvwin "WINDOW *win" "int y" "int x"
-.De
-Move the home position of the window
-.Vn win
-from its current starting coordinates
-to
-.Vn y\*,x ). (
-If that would put part or all of the window
-off the edge of the terminal screen,
-.Fn mvwin
-returns ERR and does not change anything.
-For subwindows,
-.Fn mvwin
-also returns ERR if you attempt to move it off its main window.
-If you move a main window,
-all subwindows are moved along with it.
-.Ds
-.Fn mvwprintw "WINDOW *win" "int y" "int x" "const char *fmt" "..."
-.De
-Equivalent to:
-.(l
-wmove(win, y, x);
-printw(fmt, ...);
-.)l
-.Ds
-.Fn mvwscanw "WINDOW *win" "int y" "int x" "const char *fmt" "..."
-.De
-Equivalent to:
-.(l
-wmove(win, y, x);
-scanw(fmt, ...);
-.)l
-.Ds
-.Ft "WINDOW *"
-.Fn newwin "int lines" "int cols" "int begin_y" "int begin_x"
-.De
-Create a new window with
-.Vn lines
-lines and
-.Vn cols
-columns starting at position
-.Vn begin\*_y\*,begin\*_x ). (
-If either
-.Vn lines
-or
-.Vn cols
-is 0 (zero),
-that dimension will be set to
-.Vn "LINES \- begin\*_y" ) (
-or
-.Vn "COLS \- begin\*_x" ) (
-respectively.
-Thus, to get a new window of dimensions
-.Vn LINES
-\(mu
-.Vn COLS ,
-use
-.Fn newwin 0 0 0 0 .
-.Ds
-.Fn nl "" \(dg
-.De
-Set the terminal to nl mode,
-.i i.e. ,
-start/stop the system from mapping
-.b <RETURN>
-to
-.b <LINE-FEED> .
-If the mapping is not done,
-.Fn refresh
-can do more optimization,
-so it is recommended, but not required, to turn it off.
-.Ds
-.Fn nocbreak "" \(dg
-.De
-Unset the terminal from cbreak mode.
-.Ds
-.Fn nocrmode "" \(dg
-.De
-Identical to
-.Fn nocbreak .
-The misnamed macro
-.Fn nocrmode
-is retained for backwards compatibility
-with ealier versions of the library.
-.Ds
-.Fn noecho "" \(dg
-.De
-Turn echoing of characters off.
-.Ds
-.Fn nonl "" \(dg
-.De
-Unset the terminal to from nl mode. See
-.Fn nl .
-.ne 1i
-.Ds
-.Fn noraw "" \(dg
-.De
-Unset the terminal from raw mode. See
-.Fn raw .
-.Ds
-.Fn overlay "WINDOW *win1" "WINDOW *win2"
-.De
-Overlay
-.Vn win1
-on
-.Vn win2 .
-The contents of
-.Vn win1 ,
-insofar as they fit,
-are placed on
-.Vn win2
-at their starting \*y.
-This is done non-destructively,
-i.e., blanks on
-.Vn win1
-leave the contents of the space on
-.Vn win2
-untouched. Note that all non-blank characters are overwritten
-destructively in the overlay.
-.Ds
-.Fn overwrite "WINDOW *win1" "WINDOW *win2"
-.De
-Overwrite
-.Vn win1
-on
-.Vn win2 .
-The contents of
-.Vn win1 ,
-insofar as they fit,
-are placed on
-.Vn win2
-at their starting \*y.
-This is done destructively,
-.i i.e. ,
-blanks on
-.Vn win1
-become blank on
-.Vn win2 .
-.Ds
-.Fn printw "char *fmt" "..."
-.De
-Performs a
-.Fn printf
-on the window starting at the current \*y.
-It uses
-.Fn addstr
-to add the string on the window.
-It is often advisable to use the field width options of
-.Fn printf
-to avoid leaving things on the window from earlier calls.
-\*(Es
-.Ds
-.Fn raw "" \(dg
-.De
-Set the terminal to raw mode.
-On version 7
-.Un \**
-.(f
-\**
-.Un
-is a trademark of Unix System Laboratories.
-.)f
-this also turns off newline mapping
-(see
-.Fn nl ).
-.Ds
-.Fn refresh "" \(dg
-.De
-Synchronize the terminal screen with the desired window.
-If the window is not a screen,
-only that part covered by it is updated.
-\*(Es
-In this case, it will update whatever it can
-without causing the scroll.
-.sp
-As a special case,
-if
-.Fn wrefresh
-is called with the window
-.Vn curscr
-the screen is cleared
-and repainted as it is currently.
-This is very useful for allowing the redrawing of the screen
-when the user has garbage dumped on his terminal.
-.Ds
-.Fn resetty "" \(dg
-.De
-.Fn resetty
-restores them to what
-.Fn savetty
-stored.
-These functions are performed automatically by
-.Fn initscr
-and
-.Fn endwin .
-This function should not be used by the user.
-.Ds
-.Fn savetty "" \(dg
-.De
-.Fn savetty
-saves the current tty characteristic flags. See
-.Fn resetty .
-This function should not be used by the user.
-.Ds
-.Fn scanw "char *fmt" "..."
-.De
-Perform a
-.Fn scanf
-through the window using
-.Vn fmt .
-It does this using consecutive calls to
-.Fn getch
-(or
-.Fn wgetch ).
-\*(Es
-.ne 1i
-.Ds
-.Fn scroll "WINDOW *win"
-.De
-Scroll the window upward one line.
-This is normally not used by the user.
-.Ds
-.Fn scrollok "WINDOW *win" "int boolf" \(dg
-.De
-Set the scroll flag for the given window.
-If
-.Vn boolf
-is 0, scrolling is not allowed.
-This is its default setting.
-.Ds
-.Fn standend "" \(dg
-.De
-End standout mode initiated by
-.Fn standout .
-.Ds
-.Fn standout "" \(dg
-.De
-Causes any characters added to the window
-to be put in standout mode on the terminal
-(if it has that capability).
-.Ds
-.Ft "WINDOW *"
-.Fn subwin "WINDOW *win" "int lines" "int cols" "int begin_y" "int begin_x"
-.De
-Create a new window with
-.Vn lines
-lines and
-.Vn cols
-columns starting at position
-.Vn begin\*_y\*,begin\*_x ) (
-inside the window
-.i win .
-This means that any change made to either window
-in the area covered
-by the subwindow will be made on both windows.
-.Vn begin\*_y\*,begin\*_x
-are specified relative to the overall screen,
-not the relative (0\*,0) of
-.Vn win .
-If either
-.Vn lines
-or
-.Vn cols
-is 0 (zero),
-that dimension will be set to
-.Vn "LINES \- begin\*_y" ) (
-or
-.Vn "COLS \- begin\*_x" ) (
-respectively.
-.Ds
-.Fn touchline "WINDOW *win" "int y" "int startx" "int endx"
-.De
-This function performs a function similar to
-.Fn touchwin
-on a single line.
-It marks the first change for the given line
-to be
-.Vn startx ,
-if it is before the current first change mark,
-and
-the last change mark is set to be
-.Vn endx
-if it is currently less than
-.Vn endx .
-.Ds
-.Fn touchoverlap "WINDOW *win1" "WINDOW *win2"
-.De
-Touch the window
-.Vn win2
-in the area which overlaps with
-.Vn win1 .
-If they do not overlap,
-no changes are made.
-.Ds
-.Fn touchwin "WINDOW *win"
-.De
-Make it appear that the every location on the window
-has been changed.
-This is usually only needed for refreshes with overlapping windows.
-.Ds
-.Fn tstp
-.De
-This function
-will save the current tty state
-and then put the process to sleep.
-When the process gets restarted,
-it restores the saved tty state
-and then calls
-.Fn wrefresh "curscr"
-to redraw the screen.
-.Fn Initscr
-sets the signal
-SIGTSTP
-to trap to this routine.
-.Ds
-.Fn unctrl "char *ch" \(dg
-.De
-Returns a string which is an ASCII representation of
-.Vn ch .
-Characters are 8 bits long.
-.Ds
-.Fn unctrllen "char *ch" \(dg
-.De
-Returns the length of the ASCII representation of
-.Vn ch .
-.ne 1i
-.Ds
-.Fn vwprintw "WINDOW *win" "const char *fmt" "va_list ap"
-.De
-Identical to
-.Fn printw
-except that it takes both a window specification and a pointer to a variable
-length argument list.
-.Ds
-.Fn vwscanw "WINDOW *win" "const char *fmt" "va_list ap"
-.De
-Identical to
-.Fn scanw
-except that it takes both a window specification and a pointer to a variable
-length argument list.
-.Ds
-.Fn waddbytes "WINDOW *win" "char *str" "int len"
-.De
-This function is the low level character output function.
-.Vn Len
-characters of the string
-.Vn str
-are output to the current \*y position of the window specified by
-.Vn win.
-.sp 2
-.pp
-\fIThe following functions differ from the standard functions only in their
-specification of a window, rather than the use of the default
-.Vn stdscr.\fP
-.Ds
-.Fn waddch "WINDOW *win" "char ch"
-.Fn waddstr "WINDOW *win" "char *str"
-.Fn wclear "WINDOW *win"
-.Fn wclrtobot "WINDOW *win"
-.Fn wclrtoeol "WINDOW *win"
-.Fn wdelch "WINDOW *win"
-.Fn wdeleteln "WINDOW *win"
-.Fn werase "WINDOW *win"
-.Fn wgetch "WINDOW *win"
-.Fn wgetstr "WINDOW *win" "char *str"
-.Fn winch "WINDOW *win" \(dg
-.Fn winsch "WINDOW *win" "char c"
-.Fn winsertln "WINDOW *win"
-.Fn wmove "WINDOW *win" "int y" int x"
-.Fn wprintw "WINDOW *win" "char *fmt" "..."
-.Fn wrefresh "WINDOW *win"
-.Fn wscanw "WINDOW *win" "char *fmt" "..."
-.Fn wstandend "WINDOW *win"
-.Fn wstandout "WINDOW *win"
-.Dg
diff --git a/lib/libcurses/PSD.doc/intro.0 b/lib/libcurses/PSD.doc/intro.0
deleted file mode 100644
index c95b49d4782..00000000000
--- a/lib/libcurses/PSD.doc/intro.0
+++ /dev/null
@@ -1,106 +0,0 @@
-.\" Copyright (c) 1980, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)intro.0 8.1 (Berkeley) 6/4/93
-.\"
-.tp
-.(l C
-.ps 12
-.ft B
-Screen Updating and Cursor Movement Optimization:
-.fl
-A Library Package
-.ft
-.ps
-.sp
-.i "Kenneth C. R. C. Arnold"
-.i "Elan Amir"
-.sp
-Computer Science Division
-Department of Electrical Engineering and Computer Science
-University of California, Berkeley
-Berkeley, California 94720
-.sp 3
-.bi ABSTRACT
-.sp 2
-.)l
-.(q
-.pp
-This document describes a package of C library functions
-which allow the user to:
-.ie t .ip \ \ \ \(bu
-.el .ip 1)
-update a screen with reasonable optimization,
-.ie t .ip \ \ \ \(bu
-.el .ip 2)
-get input from the terminal
-in a screen-oriented fashion,
-and
-.ie t .ip \ \ \ \(bu
-.el .ip 3)
-independent from the above, move the cursor optimally
-from one point to another.
-.pp
-These routines all use the
-\*(tc \*(db to describe the capabilities of the terminal.
-.)q
-.b Acknowledgements
-.pp
-This package would not exist
-without the work of Bill Joy,
-who,
-in writing his editor,
-created the capability to generally describe terminals,
-wrote the routines which read this \*(db,
-and, most importantly,
-those which implement optimal cursor movement,
-which routines I have simply lifted nearly intact.
-Doug Merritt and Kurt Shoens also were extremely important,
-as were both willing to waste time listening to me rant and rave.
-The help and/or support of
-Ken Abrams,
-Alan Char,
-Mark Horton,
-and
-Joe Kalash,
-was, and is,
-also greatly appreciated.
-.i "Ken Arnold 16 April 1986"
-.pp
-The help and/or support of Kirk McKusick and Keith Bostic (public vi!)
-was invaluable in bringing the package ``into the 90's'', which now
-includes completely new data structures and screen refresh optimization
-routines.
-.i "Elan Amir 29 December 1992"
-
-
-
-
diff --git a/lib/libcurses/PSD.doc/intro.1 b/lib/libcurses/PSD.doc/intro.1
deleted file mode 100644
index a86d7571ade..00000000000
--- a/lib/libcurses/PSD.doc/intro.1
+++ /dev/null
@@ -1,249 +0,0 @@
-.\" Copyright (c) 1980, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)intro.1 8.1 (Berkeley) 6/4/93
-.\"
-.bp
-.sh 1 Overview
-.pp
-In making available the generalized terminal descriptions in \*(tc,
-much information was made available to the programmer,
-but little work was taken out of one's hands.
-The purpose of this package is to allow the C programmer
-to do the most common type of terminal dependent functions,
-those of movement optimization and optimal screen updating,
-without doing any of the dirty work,
-and with nearly as much ease as is necessary to simply print
-or read things.
-.sh 2 "Terminology"
-.pp
-In this document, the following terminology is used:
-.de Ip
-.sp
-.in 5n
-.ti 0n
-.b "\\$1" :
-..
-.Ip window
-An internal representation
-containing an image of what a section of the terminal screen may look like
-at some point in time.
-This subsection can either encompass the entire terminal screen,
-or any smaller portion down to a single character within that screen.
-.Ip terminal
-Sometimes called
-.b terminal
-.b screen .
-The package's idea of what the terminal's screen currently looks like,
-.i i.e. ,
-what the user sees now.
-This is a special
-.i screen :
-.Ip screen
-This is a subset of windows which are as large as the terminal screen,
-.i i.e. ,
-they start at the upper left hand corner
-and encompass the lower right hand corner.
-One of these,
-.Vn stdscr ,
-is automatically provided for the programmer.
-.rm Ip
-.sh 2 "Compiling Applications"
-.pp
-In order to use the library,
-it is necessary to have certain types and variables defined.
-Therefore, the programmer must have a line:
-.(l
-.b "#include <curses.h>"
-.)l
-at the top of the program source.
-Compilations should have the following form:
-.(l
-.ie t \fBcc\fR [ \fIflags\fR ] file ... \fB\-lcurses \-ltermcap\fR
-.el \fIcc\fR [ flags ] file ... \fI\-lcurses \-ltermcap\fR
-.)l
-.sh 2 "Screen Updating"
-.pp
-In order to update the screen optimally,
-it is necessary for the routines to know what the screen currently looks like
-and what the programmer wants it to look like next.
-For this purpose,
-a data type
-(structure)
-named
-.Vn WINDOW
-is defined
-which describes a window image to the routines,
-including its starting position on the screen
-(the \*y of the upper left hand corner)
-and its size.
-One of these
-(called
-.Vn curscr
-for
-.i "current screen" )
-is a screen image of what the terminal currently looks like.
-Another screen
-(called
-.Vn stdscr ,
-for
-.i "standard screen" )
-is provided
-by default
-to make changes on.
-.pp
-A window is a purely internal representation.
-It is used to build and store
-a potential image of a portion of the terminal.
-It doesn't bear any necessary relation
-to what is really on the terminal screen.
-It is more like an array of characters on which to make changes.
-.pp
-When one has a window which describes
-what some part the terminal should look like,
-the routine
-.Fn refresh
-(or
-.Fn wrefresh
-if the window is not
-.Vn stdscr )
-is called.
-.Fn Refresh
-makes the terminal,
-in the area covered by the window,
-look like that window.
-Note, therefore, that changing something on a window
-.i does
-.bi not
-.i "change the terminal" .
-Actual updates to the terminal screen
-are made only by calling
-.Fn refresh
-or
-.Fn wrefresh .
-This allows the programmer to maintain several different ideas
-of what a portion of the terminal screen should look like.
-Also, changes can be made to windows in any order,
-without regard to motion efficiency.
-Then, at will,
-the programmer can effectively say
-.q "make it look like this" ,
-and the package will execute the changes in an optimal way.
-.sh 2 "Naming Conventions"
-.pp
-As hinted above,
-the routines can use several windows,
-but two are always available:
-.Vn curscr ,
-which is the image of what the terminal looks like at present,
-and
-.Vn stdscr ,
-which is the image of what the programmer wants the terminal to look like next.
-The user should not access
-.Vn curscr
-directly.
-Changes should be made to
-the appropriate screen,
-and then the routine
-.Fn refresh
-(or
-.Fn wrefresh )
-should be called.
-.pp
-Many functions are set up to deal with
-.Vn stdscr
-as a default screen.
-For example, to add a character to
-.Vn stdscr ,
-one calls
-.Fn addch
-with the desired character.
-If a different window is to be used,
-the routine
-.Fn waddch
-(for
-.b w indow-specific
-.Fn addch )
-is provided\**.
-.(f
-\**
-Actually,
-.Fn addch
-is really a
-.q #define
-macro with arguments,
-as are most of the "functions" which act upon
-.Vn stdscr .
-.)f
-This convention of prepending function names with a
-.Bq w
-when they are to be applied to specific windows
-is consistent.
-The only routines which do
-.i not
-do this are those
-to which a window must always be specified.
-.pp
-In order to move the current \*y from one point to another,
-the routines
-.Fn move
-and
-.Fn wmove
-are provided.
-However,
-it is often desirable to first move and then perform some I/O operation.
-In order to avoid clumsiness,
-most I/O routines can be preceded by the prefix
-.Bq mv
-and the desired \*y can then be added to the arguments to the function.
-For example,
-the calls
-.(l
-move(y\*,x);
-addch(ch);
-.)l
-can be replaced by
-.(l
-mvaddch(y\*,x\*,ch);
-.)l
-and
-.(l
-wmove(win\*,y\*,x);
-waddch(win\*,ch);
-.)l
-can be replaced by
-.(l
-mvwaddch(win\*,y\*,x\*,ch);
-.)l
-Note that the window description pointer
-.Vn win ) (
-comes before the added \*y.
-If a window pointer is needed, it is always the first parameter passed.
diff --git a/lib/libcurses/PSD.doc/intro.2 b/lib/libcurses/PSD.doc/intro.2
deleted file mode 100644
index d98c0c76198..00000000000
--- a/lib/libcurses/PSD.doc/intro.2
+++ /dev/null
@@ -1,77 +0,0 @@
-.\" Copyright (c) 1980, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)intro.2 8.1 (Berkeley) 6/4/93
-.\"
-.sh 1 Variables
-.pp
-Many variables which are used to describe the terminal environment
-are available to the programmer. They are:
-.(b
-.TS
-expand;
-lw(6m) lw(8n) lw(50n).
-type name description
-_
-WINDOW * curscr T{
-.fi
-current version of the screen (terminal screen).
-T}
-WINDOW * stdscr T{
-standard screen. Most updates are usually done here.
-T}
-char * Def\*_term T{
-default terminal type if type cannot be determined
-T}
-bool My\*_term T{
-use the terminal specification in \fIDef\*_term\fR as terminal,
-irrelevant of real terminal type
-T}
-char * ttytype T{
-full name of the current terminal.
-T}
-int LINES T{
-number of lines on the terminal
-T}
-int COLS T{
-number of columns on the terminal
-T}
-int ERR T{
-error flag returned by routines on a fail.
-T}
-int OK T{
-flag returned by routines upon success.
-T}
-.TE
-.fi
-.ev
-.)b
-.lp
diff --git a/lib/libcurses/PSD.doc/intro.3 b/lib/libcurses/PSD.doc/intro.3
deleted file mode 100644
index d0ba9a2ab7b..00000000000
--- a/lib/libcurses/PSD.doc/intro.3
+++ /dev/null
@@ -1,228 +0,0 @@
-.\" Copyright (c) 1980, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)intro.3 8.1 (Berkeley) 6/4/93
-.\"
-.sh 1 Usage
-.pp
-This is a description of how to actually use the screen package.
-For simplicity, we assume all updating, reading, etc.
-is applied to
-.Vn stdscr ,
-although a different window can of course be specified.
-.sh 2 "Initialization"
-.pp
-In order to use the screen package,
-the routines must know about terminal characteristics,
-and the space for
-.Vn curscr
-and
-.Vn stdscr
-must be allocated.
-These functions are performed by
-.Fn initscr .
-Since it must allocate space for the windows,
-it can overflow core when attempting to do so.
-On this rather rare occasion,
-.Fn initscr
-returns ERR.
-.Fn Initscr
-must
-.bi always
-be called before any of the routines which affect windows are used.
-If it is not,
-the program will core dump as soon as either
-.Vn curscr
-or
-.Vn stdscr
-are referenced.
-However, it is usually best to wait to call it
-until after you are sure you will need it,
-like after checking for startup errors.
-Terminal status changing routines
-like
-.Fn nl
-and
-.Fn cbreak
-should be called after
-.Fn initscr .
-.pp
-After the initial window allocation done by
-.Fn initscr ,
-specific window characteristics can be set.
-Scrolling can be enabled by calling
-.Fn scrollok .
-If you want the cursor to be left after the last change, use
-.Fn leaveok .
-If this isn't done,
-.Fn refresh
-will move the cursor to the window's current \*y after updating it.
-Additional windows can be created by using the functions
-.Fn newwin
-and
-.Fn subwin .
-.Fn Delwin
-allows you to delete an exisiting window.
-The variables
-.Vn LINES
-and
-.Vn COLS
-control the size of the terminal. They are initially implicitly set by
-.Fn initscr ,
-but can be altered explicitly by the user followed by a call to
-.Fn initscr .
-Note that any call to
-.Fn initscr ,
-will always delete any existing
-.Vn stdscr
-and/or
-.Vn curscr
-before creating new ones so this change is best done before the initial call to
-.Fn initscr .
-.pp
-.sh 2 "Output"
-.pp
-The basic functions
-used to change what will go on a window are
-.Fn addch
-and
-.Fn move .
-.Fn Addch
-adds a character at the current \*y,
-returning ERR if it would cause the window to illegally scroll,
-.i i.e. ,
-printing a character in the lower right-hand corner
-of a terminal which automatically scrolls
-if scrolling is not allowed.
-.Fn Move
-changes the current \*y to whatever you want them to be.
-It returns ERR if you try to move off the window.
-As mentioned above, you can combine the two into
-.Fn mvaddch
-to do both things in one call.
-.pp
-The other output functions
-(such as
-.Fn addstr
-and
-.Fn printw )
-all call
-.Fn addch
-to add characters to the window.
-.pp
-After a change has been made to the window,
-you must call
-.Fn refresh .
-when you want the portion of the terminal covered by the window
-to reflect the change.
-In order to optimize finding changes,
-.Fn refresh
-assumes that any part of the window not changed
-since the last
-.Fn refresh
-of that window has not been changed on the terminal,
-.i i.e. ,
-that you have not refreshed a portion of the terminal
-with an overlapping window.
-If this is not the case,
-the routines
-.Fn touchwin ,
-.Fn touchline ,
-and
-.Fn touchoverlap
-are provided to make it look like a desired part of window has been changed,
-thus forcing
-.Fn refresh
-to check that whole subsection of the terminal for changes.
-.pp
-If you call
-.Fn wrefresh
-with
-.Vn curscr ,
-it will make the screen look like the image of
-.Vn curscr .
-This is useful for implementing a command
-which would redraw the screen in case it got messed up.
-.sh 2 Input
-.pp
-Input is essentially a mirror image of output.
-The complementary function to
-.Fn addch
-is
-.Fn getch
-which,
-if echo is set,
-will call
-.Fn addch
-to echo the character.
-Since the screen package needs to know what is on the terminal at all times,
-if characters are to be echoed,
-the tty must be in raw or cbreak mode.
-If it is not,
-.Fn getch
-sets it to be cbreak,
-and then reads in the character.
-.sh 2 "Termination"
-.pp
-In order to perform certain optimizations,
-and,
-on some terminals,
-to work at all,
-some things must be done
-before the screen routines start up.
-These functions are performed in
-.Fn getttmode
-and
-.Fn setterm ,
-which are called by
-.Fn initscr .
-In order to clean up after the routines,
-the routine
-.Fn endwin
-is provided.
-It restores tty modes to what they were
-when
-.Fn initscr
-was first called.
-The terminal state module uses the variable
-.Vn curses_termios
-to save the original terminal state which is then restored upon a call to
-.Fn endwin .
-Thus,
-anytime after the call to initscr,
-.Fn endwin
-should be called before exiting. Note however, that
-.Fn endwin
-should always be called
-.b before
-the final calls to
-.Fn delwin ,
-which free the storage of the windows.
diff --git a/lib/libcurses/PSD.doc/intro.4 b/lib/libcurses/PSD.doc/intro.4
deleted file mode 100644
index 9e529822c5d..00000000000
--- a/lib/libcurses/PSD.doc/intro.4
+++ /dev/null
@@ -1,69 +0,0 @@
-.\" Copyright (c) 1980, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)intro.4 8.1 (Berkeley) 6/4/93
-.\"
-.sh 1 "Cursor Movement Optimizations"
-.pp
-One of the most difficult things to do properly is motion optimization.
-After using
-.Fn gettmode
-and
-.Fn setterm
-to get the terminal descriptions,
-the function
-.Fn mvcur
-deals with this task.
-It usage is simple:
-simply tell it where you are now and where you want to go.
-For example
-.(l
-mvcur(0\*,0\*,LINES/2\*,COLS/2);
-.)l
-.lp
-would move the cursor from the home position (0\*,0)
-to the middle of the screen.
-If you wish to force absolute addressing,
-you can use the function
-.Fn tgoto
-from the
-.b termlib (7)
-routines,
-or you can tell
-.Fn mvcur
-that you are impossibly far away,
-For example,
-to absolutely address the lower left hand corner of the screen
-from anywhere
-just claim that you are in the upper right hand corner:
-.(l
-mvcur(0\*,COLS\-1\*,LINES\-1\*,0);
-.)l
diff --git a/lib/libcurses/PSD.doc/intro.5 b/lib/libcurses/PSD.doc/intro.5
deleted file mode 100644
index d0f96575b4b..00000000000
--- a/lib/libcurses/PSD.doc/intro.5
+++ /dev/null
@@ -1,87 +0,0 @@
-.\" Copyright (c) 1980, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)intro.5 8.1 (Berkeley) 6/4/93
-.\"
-.sh 1 "Character Output and Scrolling"
-.pp
-The character output policy deals with the following problems. First,
-where is the location of the cursor after a character is printed, and
-secondly, when does the screen scroll if scrolling is enabled.
-.pp
-In the normal case the characters are output as expected, with the cursor
-occupying the position of the next character to be output. However, when the
-cursor is on the last column of the line, the cursor will remain on that
-position after the last character on the line is output and will only assume
-the position on the next line when the next character (the first on the next
-line) is output.
-.pp
-Likewise, if scrolling is enabled, a scroll will be invoked only when the
-first character on he first line past the bottom line of the window is
-output. If scrolling is not enabled the chracters will to be output to the
-bottom right corner of the window which is the cursor location.
-.pp
-This policy allows consistent behavior of the cursor at the boundary
-conditions. Furthermore, it prevents a scroll from happening before it is
-actually needed (the old package used to scroll when the bottom right position
-was output a character). As a precendent, it models the
-.i xterm
-character output conventions.
-.sh 1 "Terminal State Handling"
-.pp
-The variable
-.Vn curses_termios
-contains the terminal state of the terminal. Certain historical routines
-return information:
-.Fn baudrate ,
-.Fn erasechar ,
-.Fn killchar ,
-and
-.Fn ospeed .
-These routines are obsolete and exist only for backward compatibility. If
-you wish to use the information in the
-.Vn curses_termios
-structure, you should use the
-\fItsetattr\fP(3)
-routines.
-.sh 1 "Subwindows"
-.pp
-Subwindows are windows which do not have an independent text structure,
-.i i.e. ,
-they are windows whose text is a subset of the text of a larger window: the
-.i parent
-window. One consequence of this is that changes to either the parent or the
-child window are destructive to the other,
-.i i.e. ,
-a change to the subwindow is also a change to the parent window and a change
-to the parent window in the region defined by the subwindow is implicitly a
-change to the subwindow as well.
-Apart from this detail, subwindows function like any other window.
diff --git a/lib/libcurses/PSD.doc/intro.6 b/lib/libcurses/PSD.doc/intro.6
deleted file mode 100644
index 7c4560dc33a..00000000000
--- a/lib/libcurses/PSD.doc/intro.6
+++ /dev/null
@@ -1,44 +0,0 @@
-.\" Copyright (c) 1980, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)intro.6 8.1 (Berkeley) 6/4/93
-.\"
-.sh 1 "The Functions"
-.pp
-In the following definitions,
-.q \*m
-means that the
-.q function
-is really a
-.q #define
-macro with arguments.
-.ta 11m 17m 25m 33m 41m 49m 57m 65m 73m
-.so fns.doc
diff --git a/lib/libcurses/PSD.doc/life.c b/lib/libcurses/PSD.doc/life.c
deleted file mode 100644
index 72febba29ae..00000000000
--- a/lib/libcurses/PSD.doc/life.c
+++ /dev/null
@@ -1,163 +0,0 @@
-.\" Copyright (c) 1980, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)life.c 8.1 (Berkeley) 6/8/93
-.\"
-# include <curses.h>
-# include <signal.h>
-
-/*
- * Run a life game. This is a demonstration program for
- * the Screen Updating section of the -lcurses cursor package.
- */
-
-typedef struct lst_st { /* linked list element */
- int y, x; /* (y, x) position of piece */
- struct lst_st *next, *last; /* doubly linked */
-} LIST;
-
-LIST *Head; /* head of linked list */
-
-int die();
-
-main(ac, av)
-int ac;
-char *av[];
-{
- evalargs(ac, av); /* evaluate arguments */
-
- initscr(); /* initialize screen package */
- signal(SIGINT, die); /* set to restore tty stats */
- cbreak(); /* set for char-by-char */
- noecho(); /* input */
- nonl(); /* for optimization */
-
- getstart(); /* get starting position */
- for (;;) {
- prboard(); /* print out current board */
- update(); /* update board position */
- }
-}
-
-/*
- * This is the routine which is called when rubout is hit.
- * It resets the tty stats to their original values. This
- * is the normal way of leaving the program.
- */
-die()
-{
- signal(SIGINT, SIG_IGN); /* ignore rubouts */
- mvcur(0, COLS - 1, LINES - 1, 0); /* go to bottom of screen */
- endwin(); /* set terminal to good state */
- exit(0);
-}
-
-/*
- * Get the starting position from the user. They keys u, i, o, j, l,
- * m, ,, and . are used for moving their relative directions from the
- * k key. Thus, u move diagonally up to the left, , moves directly down,
- * etc. x places a piece at the current position, " " takes it away.
- * The input can also be from a file. The list is built after the
- * board setup is ready.
- */
-getstart()
-{
- reg char c;
- reg int x, y;
- auto char buf[100];
-
- box(stdscr, '|', '_'); /* box in the screen */
- move(1, 1); /* move to upper left corner */
-
- for (;;) {
- refresh(); /* print current position */
- if ((c = getch()) == 'q')
- break;
- switch (c) {
- case 'u':
- case 'i':
- case 'o':
- case 'j':
- case 'l':
- case 'm':
- case ',':
- case '.':
- adjustyx(c);
- break;
- case 'f':
- mvaddstr(0, 0, "File name: ");
- getstr(buf);
- readfile(buf);
- break;
- case 'x':
- addch('X');
- break;
- case ' ':
- addch(' ');
- break;
- }
- }
-
- if (Head != NULL) /* start new list */
- dellist(Head);
- Head = malloc(sizeof (LIST));
-
- /*
- * loop through the screen looking for 'x's, and add a list
- * element for each one
- */
- for (y = 1; y < LINES - 1; y++)
- for (x = 1; x < COLS - 1; x++) {
- move(y, x);
- if (inch() == 'x')
- addlist(y, x);
- }
-}
-
-/*
- * Print out the current board position from the linked list
- */
-prboard() {
-
- reg LIST *hp;
-
- erase(); /* clear out last position */
- box(stdscr, '|', '_'); /* box in the screen */
-
- /*
- * go through the list adding each piece to the newly
- * blank board
- */
- for (hp = Head; hp; hp = hp->next)
- mvaddch(hp->y, hp->x, 'X');
-
- refresh();
-}
diff --git a/lib/libcurses/PSD.doc/macros b/lib/libcurses/PSD.doc/macros
deleted file mode 100644
index b7f3abf793e..00000000000
--- a/lib/libcurses/PSD.doc/macros
+++ /dev/null
@@ -1,144 +0,0 @@
-.\" Copyright (c) 1980, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)macros 8.1 (Berkeley) 8/14/93
-.\"
-.\" this is the uncommented version. The commented one is in "macros.coms"
-.ie t .ds _ \d\(mi\u
-.el .ds _ _
-.ds , ,\
-.ds y (y\*,x) co-ordinates
-.ds db database
-.ie n .ds f \fI
-.el .ds f \fB
-.ds tc \*ftermcap\fP(5)
-.ds Es This returns ERR if it would cause the screen to scroll illegally.
-.ds Nm This has no associated \*(lq\fBmv\fP\*(rq command.
-.ie t .ds m \fB\s-2\(dg\s+2\fP
-.el .ds m [*]
-.\" .hy WINDOW
-.\".he ''\*(Ln''
-.\".fo ''\- % \-''
-.oh '\*(Ln''PS1:19-%'
-.eh 'PS1:19-%''\*(Ln'
-.de Un
-.b
-\s-2\\$2UNIX\\$1\s+2
-.ft
-..
-.de Ds
-.sp
-.lp
-.ev 1
-.nf
-.ft I
-.in 0
-.di Df
-..
-.de De
-.di
-.Df
-.ne \n(dn+2
-.ev
-.ip
-..
-.de Dg
-.di
-.Df
-.ne \n(dn+2
-.ev
-..
-.de Fd
-.br
-\&\\$4
-.fi
-.b
-\&\\$1(\\$2)
-.ft
-\&\\$3
-.br
-.nf
-..
-.de Vn
-\&\\$3\c
-.i "\\$1" \\$2
-..
-.de Bq
-.ie t \&\*(lq\fB\\$1\fP\*(rq
-.el \&\*(lq\fI\\$1\fP\*(rq
-..
-.de $0
-.(x
-.in \\n(Xs
-\\*($n \\$1
-.)x
-..
-.de $1
-.nr Xs 0
-..
-.de $2
-.nr Xs 3
-..
-.de $3
-.nr Xs 6
-..
-.de Fn
-.if \\n(.$==0 .tm error
-.nr ll 0
-.nr dg 0
-.ft R
-.if '\\$\\n(.$'.' .nr ll 1
-.if '\\$\\n(.$',' .nr ll 1
-.if '\\$\\n(.$')' .nr ll 1
-.if '\\$\\n(.$').' .nr ll 1
-.if '\\$\\n(.$';' .nr ll 1
-.if '\\$\\n(.$':' .nr ll 1
-.if '\\$\\n(.$'\'s' .nr ll 1
-.if '\\$\\n(.$'\(dg' .nr ll 1
-.\" .if '\\$\\n(.$'' .nr ll 1
-.nr al \\n(.$-\\n(ll
-.ds ot \f(CB\\$1\fP(
-.if \\n(al>1 .as ot \fI\\$2\fP
-.if \\n(al>2 .as ot ", \fI\\$3\fP
-.if \\n(al>3 .as ot ", \fI\\$4\fP
-.if \\n(al>4 .as ot ", \fI\\$5\fP
-.if \\n(al>5 .as ot ", \fI\\$6\fP
-.if \\n(al>6 .as ot ", \fI\\$7\fP
-.if \\n(al>7 .as ot ", \fI\\$8\fP
-.if \\n(al>8 .as ot ", \fI\\$9\fP
-.as ot )
-.if \\n(.$>1 \{\
-. if \\n(ll==0 .as ot ;
-. if '\\$\\n(.$'\(dg' .as ot ;
-.\}
-.if \\n(ll==1 .as ot \\$\\n(.$
-\\*(ot
-..
diff --git a/lib/libcurses/PSD.doc/twinkle1.c b/lib/libcurses/PSD.doc/twinkle1.c
deleted file mode 100644
index 7d3d00db203..00000000000
--- a/lib/libcurses/PSD.doc/twinkle1.c
+++ /dev/null
@@ -1,157 +0,0 @@
-.\" Copyright (c) 1980, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)twinkle1.c 8.1 (Berkeley) 6/8/93
-.\"
-# include <curses.h>
-# include <signal.h>
-
-/*
- * the idea for this program was a product of the imagination of
- * Kurt Schoens. Not responsible for minds lost or stolen.
- */
-
-# define NCOLS 80
-# define NLINES 24
-# define MAXPATTERNS 4
-
-typedef struct {
- int y, x;
-} LOCS;
-
-LOCS Layout[NCOLS * NLINES]; /* current board layout */
-
-int Pattern, /* current pattern number */
- Numstars; /* number of stars in pattern */
-
-char *getenv();
-
-int die();
-
-main()
-{
- srand(getpid()); /* initialize random sequence */
-
- initscr();
- signal(SIGINT, die);
- noecho();
- nonl();
- leaveok(stdscr, TRUE);
- scrollok(stdscr, FALSE);
-
- for (;;) {
- makeboard(); /* make the board setup */
- puton('*'); /* put on '*'s */
- puton(' '); /* cover up with ' 's */
- }
-}
-
-/*
- * On program exit, move the cursor to the lower left corner by
- * direct addressing, since current location is not guaranteed.
- * We lie and say we used to be at the upper right corner to guarantee
- * absolute addressing.
- */
-die()
-{
- signal(SIGINT, SIG_IGN);
- mvcur(0, COLS - 1, LINES - 1, 0);
- endwin();
- exit(0);
-}
-
-
-/*
- * Make the current board setup. It picks a random pattern and
- * calls ison() to determine if the character is on that pattern
- * or not.
- */
-makeboard()
-{
- reg int y, x;
- reg LOCS *lp;
-
- Pattern = rand() % MAXPATTERNS;
- lp = Layout;
- for (y = 0; y < NLINES; y++)
- for (x = 0; x < NCOLS; x++)
- if (ison(y, x)) {
- lp->y = y;
- lp->x = x;
- lp++;
- }
- Numstars = lp - Layout;
-}
-
-/*
- * Return TRUE if (y, x) is on the current pattern.
- */
-ison(y, x)
-reg int y, x; {
-
- switch (Pattern) {
- case 0: /* alternating lines */
- return !(y & 01);
- case 1: /* box */
- if (x >= LINES && y >= NCOLS)
- return FALSE;
- if (y < 3 || y >= NLINES - 3)
- return TRUE;
- return (x < 3 || x >= NCOLS - 3);
- case 2: /* holy pattern! */
- return ((x + y) & 01);
- case 3: /* bar across center */
- return (y >= 9 && y <= 15);
- }
- /* NOTREACHED */
-}
-
-puton(ch)
-reg char ch;
-{
- reg LOCS *lp;
- reg int r;
- reg LOCS *end;
- LOCS temp;
-
- end = &Layout[Numstars];
- for (lp = Layout; lp < end; lp++) {
- r = rand() % Numstars;
- temp = *lp;
- *lp = Layout[r];
- Layout[r] = temp;
- }
-
- for (lp = Layout; lp < end; lp++) {
- mvaddch(lp->y, lp->x, ch);
- refresh();
- }
-}
diff --git a/lib/libcurses/PSD.doc/twinkle2.c b/lib/libcurses/PSD.doc/twinkle2.c
deleted file mode 100644
index 0a25590fcde..00000000000
--- a/lib/libcurses/PSD.doc/twinkle2.c
+++ /dev/null
@@ -1,96 +0,0 @@
-.\" Copyright (c) 1980, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)twinkle2.c 8.1 (Berkeley) 6/8/93
-.\"
-extern int _putchar();
-
-main()
-{
- reg char *sp;
-
- srand(getpid()); /* initialize random sequence */
-
- if (isatty(0)) {
- gettmode();
- if ((sp = getenv("TERM")) != NULL)
- setterm(sp);
- signal(SIGINT, die);
- }
- else {
- printf("Need a terminal on %d\n", _tty_ch);
- exit(1);
- }
- _puts(TI);
- _puts(VS);
-
- noecho();
- nonl();
- tputs(CL, NLINES, _putchar);
- for (;;) {
- makeboard(); /* make the board setup */
- puton('*'); /* put on '*'s */
- puton(' '); /* cover up with ' 's */
- }
-}
-
-puton(ch)
-char ch;
-{
- reg LOCS *lp;
- reg int r;
- reg LOCS *end;
- LOCS temp;
- static int lasty, lastx;
-
- end = &Layout[Numstars];
- for (lp = Layout; lp < end; lp++) {
- r = rand() % Numstars;
- temp = *lp;
- *lp = Layout[r];
- Layout[r] = temp;
- }
-
- for (lp = Layout; lp < end; lp++)
- /* prevent scrolling */
- if (!AM || (lp->y < NLINES - 1 || lp->x < NCOLS - 1)) {
- mvcur(lasty, lastx, lp->y, lp->x);
- putchar(ch);
- lasty = lp->y;
- if ((lastx = lp->x + 1) >= NCOLS)
- if (AM) {
- lastx = 0;
- lasty++;
- }
- else
- lastx = NCOLS - 1;
- }
-}
diff --git a/lib/libcurses/PSD.doc/win_st.c b/lib/libcurses/PSD.doc/win_st.c
deleted file mode 100644
index 7790f6ca632..00000000000
--- a/lib/libcurses/PSD.doc/win_st.c
+++ /dev/null
@@ -1,58 +0,0 @@
-.\" Copyright (c) 1980, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)win_st.c 8.1 (Berkeley) 6/8/93
-.\"
-# define WINDOW struct _win_st
-
-struct _win_st {
- short _cury, _curx;
- short _maxy, _maxx;
- short _begy, _begx;
- short _flags;
- short _ch_off;
- bool _clear;
- bool _leave;
- bool _scroll;
- char **_y;
- short *_firstch;
- short *_lastch;
- struct _win_st *_nextp, *_orig;
-};
-
-# define _ENDLINE 001
-# define _FULLWIN 002
-# define _SCROLLWIN 004
-# define _FLUSH 010
-# define _FULLLINE 020
-# define _IDLINE 040
-# define _STANDOUT 0200
-# define _NOCHANGE -1
diff --git a/lib/libcurses/addbytes.c b/lib/libcurses/addbytes.c
deleted file mode 100644
index 6dd8bf959b5..00000000000
--- a/lib/libcurses/addbytes.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (c) 1987, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)addbytes.c 8.4 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include "curses.h"
-
-#define SYNCH_IN {y = win->cury; x = win->curx;}
-#define SYNCH_OUT {win->cury = y; win->curx = x;}
-
-/*
- * waddbytes --
- * Add the character to the current position in the given window.
- */
-int
-__waddbytes(win, bytes, count, so)
- register WINDOW *win;
- register const char *bytes;
- register int count;
- int so;
-{
- static char blanks[] = " ";
- register int c, newx, x, y;
- char stand;
- __LINE *lp;
-
- SYNCH_IN;
-
-#ifdef DEBUG
- __CTRACE("ADDBYTES('%c') at (%d, %d)\n", c, y, x);
-#endif
- while (count--) {
- c = *bytes++;
- switch (c) {
- case '\t':
- SYNCH_OUT;
- if (waddbytes(win, blanks, 8 - (x % 8)) == ERR)
- return (ERR);
- SYNCH_IN;
- break;
-
- default:
-#ifdef DEBUG
- __CTRACE("ADDBYTES(%0.2o, %d, %d)\n", win, y, x);
-#endif
-
- lp = win->lines[y];
- if (lp->flags & __ISPASTEOL) {
- lp->flags &= ~__ISPASTEOL;
-newline: if (y == win->maxy - 1) {
- if (win->flags & __SCROLLOK) {
- SYNCH_OUT;
- scroll(win);
- SYNCH_IN;
- lp = win->lines[y];
- x = 0;
- } else
- return (ERR);
- } else {
- y++;
- lp = win->lines[y];
- x = 0;
- }
- if (c == '\n')
- break;
- }
-
- stand = '\0';
- if (win->flags & __WSTANDOUT || so)
- stand |= __STANDOUT;
-#ifdef DEBUG
- __CTRACE("ADDBYTES: 1: y = %d, x = %d, firstch = %d, lastch = %d\n",
- y, x, *win->lines[y]->firstchp, *win->lines[y]->lastchp);
-#endif
- if (lp->line[x].ch != c ||
- !(lp->line[x].attr & stand)) {
- newx = x + win->ch_off;
- if (!(lp->flags & __ISDIRTY)) {
- lp->flags |= __ISDIRTY;
- *lp->firstchp = *lp->lastchp = newx;
- }
- else if (newx < *lp->firstchp)
- *lp->firstchp = newx;
- else if (newx > *lp->lastchp)
- *lp->lastchp = newx;
-#ifdef DEBUG
- __CTRACE("ADDBYTES: change gives f/l: %d/%d [%d/%d]\n",
- *lp->firstchp, *lp->lastchp,
- *lp->firstchp - win->ch_off,
- *lp->lastchp - win->ch_off);
-#endif
- }
- lp->line[x].ch = c;
- if (stand)
- lp->line[x].attr |= __STANDOUT;
- else
- lp->line[x].attr &= ~__STANDOUT;
- if (x == win->maxx - 1)
- lp->flags |= __ISPASTEOL;
- else
- x++;
-#ifdef DEBUG
- __CTRACE("ADDBYTES: 2: y = %d, x = %d, firstch = %d, lastch = %d\n",
- y, x, *win->lines[y]->firstchp, *win->lines[y]->lastchp);
-#endif
- break;
- case '\n':
- SYNCH_OUT;
- wclrtoeol(win);
- SYNCH_IN;
- if (!NONL)
- x = 0;
- goto newline;
- case '\r':
- x = 0;
- break;
- case '\b':
- if (--x < 0)
- x = 0;
- break;
- }
- }
- SYNCH_OUT;
- return (OK);
-}
diff --git a/lib/libcurses/addch.c b/lib/libcurses/addch.c
deleted file mode 100644
index d5f30014c02..00000000000
--- a/lib/libcurses/addch.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)addch.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include "curses.h"
-
-/*
- * waddch --
- * Add the character to the current position in the given window.
- *
- */
-int
-waddch(win, ch)
- WINDOW *win;
- int ch;
-{
- __LDATA buf;
-
- buf.ch = ch;
- buf.attr = 0;
- return (__waddch(win, &buf));
-}
-
-int
-__waddch(win, dp)
- WINDOW *win;
- __LDATA *dp;
-{
- char buf[2];
-
- buf[0] = dp->ch;
- return (__waddbytes(win, buf, 1, dp->attr & __STANDOUT));
-}
diff --git a/lib/libcurses/addnstr.c b/lib/libcurses/addnstr.c
deleted file mode 100644
index 92a6e681a54..00000000000
--- a/lib/libcurses/addnstr.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)addnstr.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include <string.h>
-
-#include "curses.h"
-
-/*
- * waddnstr --
- * Add a string (at most n characters) to the given window
- * starting at (_cury, _curx). If n is negative, add the
- * entire string.
- */
-int
-waddnstr(win, s, n)
- WINDOW *win;
- const char *s;
- int n;
-{
- size_t len;
- const char *p;
-
- if (n > 0)
- for (p = s, len = 0; n-- && *p++; ++len);
- else
- len = strlen(s);
- return (waddbytes(win, s, len));
-}
diff --git a/lib/libcurses/box.c b/lib/libcurses/box.c
deleted file mode 100644
index 191e37cfd82..00000000000
--- a/lib/libcurses/box.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)box.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include "curses.h"
-
-/*
- * box --
- * Draw a box around the given window with "vert" as the vertical
- * delimiting char, and "hor", as the horizontal one.
- */
-int
-box(win, vert, hor)
- register WINDOW *win;
- int vert, hor;
-{
- register int endy, endx, i;
- register __LDATA *fp, *lp;
-
- endx = win->maxx;
- endy = win->maxy - 1;
- fp = win->lines[0]->line;
- lp = win->lines[endy]->line;
- for (i = 0; i < endx; i++) {
- fp[i].ch = lp[i].ch = hor;
- fp[i].attr &= ~__STANDOUT;
- lp[i].attr &= ~__STANDOUT;
- }
- endx--;
- for (i = 0; i <= endy; i++) {
- win->lines[i]->line[0].ch = vert;
- win->lines[i]->line[endx].ch = vert;
- win->lines[i]->line[0].attr &= ~__STANDOUT;
- win->lines[i]->line[endx].attr &= ~__STANDOUT;
- }
- if (!(win->flags & __SCROLLOK) && (win->flags & __SCROLLWIN)) {
- fp[0].ch = fp[endx].ch = lp[0].ch = lp[endx].ch = ' ';
- fp[0].attr &= ~__STANDOUT;
- fp[endx].attr &= ~__STANDOUT;
- lp[0].attr &= ~__STANDOUT;
- lp[endx].attr &= ~__STANDOUT;
- }
- __touchwin(win);
- return (OK);
-}
diff --git a/lib/libcurses/clear.c b/lib/libcurses/clear.c
deleted file mode 100644
index 54c0b30d3cf..00000000000
--- a/lib/libcurses/clear.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)clear.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include "curses.h"
-
-/*
- * wclear --
- * Clear the window.
- */
-int
-wclear(win)
- register WINDOW *win;
-{
- if (werase(win) == OK) {
- win->flags |= __CLEAROK;
- return (OK);
- }
- return (ERR);
-}
diff --git a/lib/libcurses/clrtobot.c b/lib/libcurses/clrtobot.c
deleted file mode 100644
index 81ee6a4603a..00000000000
--- a/lib/libcurses/clrtobot.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)clrtobot.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include "curses.h"
-
-/*
- * wclrtobot --
- * Erase everything on the window.
- */
-int
-wclrtobot(win)
- register WINDOW *win;
-{
- register int minx, startx, starty, y;
- register __LDATA *sp, *end, *maxx;
-
- if (win->lines[win->cury]->flags & __ISPASTEOL) {
- starty = win->cury + 1;
- startx = 0;
- } else {
- starty = win->cury;
- startx = win->curx;
- }
- for (y = starty; y < win->maxy; y++) {
- minx = -1;
- end = &win->lines[y]->line[win->maxx];
- for (sp = &win->lines[y]->line[startx]; sp < end; sp++)
- if (sp->ch != ' ' || sp->attr != 0) {
- maxx = sp;
- if (minx == -1)
- minx = sp - win->lines[y]->line;
- sp->ch = ' ';
- sp->attr = 0;
- }
- if (minx != -1)
- __touchline(win, y, minx, maxx - win->lines[y]->line,
- 0);
- startx = 0;
- }
- return (OK);
-}
diff --git a/lib/libcurses/clrtoeol.c b/lib/libcurses/clrtoeol.c
deleted file mode 100644
index 44fc190fee3..00000000000
--- a/lib/libcurses/clrtoeol.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)clrtoeol.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include "curses.h"
-
-/*
- * wclrtoeol --
- * Clear up to the end of line.
- */
-int
-wclrtoeol(win)
- register WINDOW *win;
-{
- register int minx, x, y;
- register __LDATA *end, *maxx, *sp;
-
- y = win->cury;
- x = win->curx;
- if (win->lines[y]->flags & __ISPASTEOL) {
- if (y < win->maxy - 1) {
- y++;
- x = 0;
- } else
- return (OK);
- }
- end = &win->lines[y]->line[win->maxx];
- minx = -1;
- maxx = &win->lines[y]->line[x];
- for (sp = maxx; sp < end; sp++)
- if (sp->ch != ' ' || sp->attr != 0) {
- maxx = sp;
- if (minx == -1)
- minx = sp - win->lines[y]->line;
- sp->ch = ' ';
- sp->attr = 0;
- }
-#ifdef DEBUG
- __CTRACE("CLRTOEOL: minx = %d, maxx = %d, firstch = %d, lastch = %d\n",
- minx, maxx - win->lines[y]->line, *win->lines[y]->firstchp,
- *win->lines[y]->lastchp);
-#endif
- /* Update firstch and lastch for the line. */
- return (__touchline(win, y, x, win->maxx - 1, 0));
-}
-
-
-
-
-
diff --git a/lib/libcurses/config.h b/lib/libcurses/config.h
new file mode 100644
index 00000000000..e9b3a016aa9
--- /dev/null
+++ b/lib/libcurses/config.h
@@ -0,0 +1,43 @@
+/* generated by configure-script
+ * On host: OpenBSD gandalf.sigmasoft.com 1.2 OpenBSD 1.2 (GANDALF) #1: Sun Apr 28 03:30:40 PDT 1996 tholo@gandalf.sigmasoft.com:/usr/src/sys/arch/i386/compile/GANDALF i386
+ */
+#ifndef NC_CONFIG_H
+#define NC_CONFIG_H
+
+#define CC_HAS_INLINE_FUNCS 1
+#define HAVE_DIRENT_H 1
+#define HAVE_EXTERN_ERRNO 1
+#define HAVE_EXTERN_SYS_ERRLIST 1
+#define HAVE_FCNTL_H 1
+#define HAVE_FORM_H 1
+#define HAVE_GETTIMEOFDAY 1
+#define HAVE_GETTTYNAM 1
+#define HAVE_LIMITS_H 1
+#define HAVE_MEMCCPY 1
+#define HAVE_MENU_H 1
+#define HAVE_PANEL_H 1
+#define HAVE_REGEXP_H 1
+#define HAVE_REGEX_H 1
+#define HAVE_SETBUFFER 1
+#define HAVE_SETVBUF 1
+#define HAVE_SIGACTION 1
+#define HAVE_STRDUP 1
+#define HAVE_STRERROR 1
+#define HAVE_SYS_IOCTL_H 1
+#define HAVE_SYS_PARAM_H 1
+#define HAVE_SYS_SELECT_H 1
+#define HAVE_SYS_TIME_H 1
+#define HAVE_TERMIOS_H 1
+#define HAVE_TTYENT_H 1
+#define HAVE_UNISTD_H 1
+#define HAVE_USLEEP 1
+#define HAVE_VSSCANF 1
+#define STDC_HEADERS 1
+
+ /* The C compiler may not treat these properly, but C++ has to */
+#ifdef __cplusplus
+#undef const
+#undef inline
+#endif
+
+#endif /* NC_CONFIG_H */
diff --git a/lib/libcurses/cr_put.c b/lib/libcurses/cr_put.c
deleted file mode 100644
index ada2df5ca1e..00000000000
--- a/lib/libcurses/cr_put.c
+++ /dev/null
@@ -1,432 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)cr_put.c 8.3 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include <string.h>
-
-#include "curses.h"
-
-#define HARDTABS 8
-
-/*
- * Terminal driving and line formatting routines. Basic motion optimizations
- * are done here as well as formatting lines (printing of control characters,
- * line numbering and the like).
- */
-
-/* Stub function for the users. */
-int
-mvcur(ly, lx, y, x)
- int ly, lx, y, x;
-{
- return (__mvcur(ly, lx, y, x, 0));
-}
-
-static void fgoto __P((int));
-static int plod __P((int, int));
-static void plodput __P((int));
-static int tabcol __P((int, int));
-
-static int outcol, outline, destcol, destline;
-
-/*
- * Sync the position of the output cursor. 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 destline on the screen.
- */
-int
-__mvcur(ly, lx, y, x, in_refresh)
- int ly, lx, y, x, in_refresh;
-{
-#ifdef DEBUG
- __CTRACE("mvcur: moving cursor from (%d, %d) to (%d, %d)\n",
- ly, lx, y, x);
-#endif
- destcol = x;
- destline = y;
- outcol = lx;
- outline = ly;
- fgoto(in_refresh);
- return (OK);
-}
-
-static void
-fgoto(in_refresh)
- int in_refresh;
-{
- register int c, l;
- register char *cgp;
-
- if (destcol >= COLS) {
- destline += destcol / COLS;
- destcol %= COLS;
- }
- if (outcol >= COLS) {
- l = (outcol + 1) / COLS;
- outline += l;
- outcol %= COLS;
- if (AM == 0) {
- while (l > 0) {
- if (__pfast)
- if (CR)
- tputs(CR, 0, __cputchar);
- else
- putchar('\r');
- if (NL)
- tputs(NL, 0, __cputchar);
- else
- putchar('\n');
- l--;
- }
- outcol = 0;
- }
- if (outline > LINES - 1) {
- destline -= outline - (LINES - 1);
- outline = LINES - 1;
- }
- }
- if (destline >= LINES) {
- l = destline;
- destline = LINES - 1;
- if (outline < LINES - 1) {
- c = destcol;
- if (__pfast == 0 && !CA)
- destcol = 0;
- fgoto(in_refresh);
- destcol = c;
- }
- while (l >= LINES) {
- /* The following linefeed (or simulation thereof) is
- * supposed to scroll up the screen, since we are on
- * the bottom line. We make the assumption that
- * linefeed will scroll. If ns is in the capability
- * list this won't work. We should probably have an
- * sc capability but sf will generally take the place
- * if it works.
- *
- * Superbee glitch: in the middle of the screen have
- * to use esc B (down) because linefeed screws up in
- * "Efficient Paging" (what a joke) mode (which is
- * essential in some SB's because CRLF mode puts
- * garbage in at end of memory), but you must use
- * linefeed to scroll since down arrow won't go past
- * memory end. I turned this off after recieving Paul
- * Eggert's Superbee description which wins better.
- */
- if (NL /* && !XB */ && __pfast)
- tputs(NL, 0, __cputchar);
- else
- putchar('\n');
- l--;
- if (__pfast == 0)
- outcol = 0;
- }
- }
- if (destline < outline && !(CA || UP))
- destline = outline;
- if (CA) {
- cgp = tgoto(CM, destcol, destline);
-
- /*
- * Need this condition due to inconsistent behavior
- * of backspace on the last column.
- */
- if (outcol != COLS - 1 && plod(strlen(cgp), in_refresh) > 0)
- plod(0, in_refresh);
- else
- tputs(cgp, 0, __cputchar);
- } else
- plod(0, in_refresh);
- outline = destline;
- outcol = destcol;
-}
-/*
- * Move (slowly) to destination.
- * Hard thing here is using home cursor on really deficient terminals.
- * Otherwise just use cursor motions, hacking use of tabs and overtabbing
- * and backspace.
- */
-
-static int plodcnt, plodflg;
-
-static void
-plodput(c)
- int c;
-{
- if (plodflg)
- --plodcnt;
- else
- putchar(c);
-}
-
-static int
-plod(cnt, in_refresh)
- int cnt, in_refresh;
-{
- register int i, j, k, soutcol, soutline;
-
- plodcnt = plodflg = cnt;
- soutcol = outcol;
- soutline = outline;
- /*
- * Consider homing and moving down/right from there, vs. moving
- * directly with local motions to the right spot.
- */
- if (HO) {
- /*
- * i is the cost to home and tab/space to the right to get to
- * the proper column. This assumes ND space costs 1 char. So
- * i + destcol is cost of motion with home.
- */
- if (GT)
- i = (destcol / HARDTABS) + (destcol % HARDTABS);
- else
- i = destcol;
-
- /* j is cost to move locally without homing. */
- if (destcol >= outcol) { /* if motion is to the right */
- j = destcol / HARDTABS - outcol / HARDTABS;
- if (GT && j)
- j += destcol % HARDTABS;
- else
- j = destcol - outcol;
- } else
- /* leftward motion only works if we can backspace. */
- if (outcol - destcol <= i && (BS || BC))
- /* Cheaper to backspace. */
- i = j = outcol - destcol;
- else
- /* Impossibly expensive. */
- j = i + 1;
-
- /* k is the absolute value of vertical distance. */
- k = outline - destline;
- if (k < 0)
- k = -k;
- j += k;
-
- /* Decision. We may not have a choice if no UP. */
- if (i + destline < j || (!UP && destline < outline)) {
- /*
- * Cheaper to home. Do it now and pretend it's a
- * regular local motion.
- */
- tputs(HO, 0, plodput);
- outcol = outline = 0;
- } else if (LL) {
- /*
- * Quickly consider homing down and moving from there.
- * Assume cost of LL is 2.
- */
- k = (LINES - 1) - destline;
- if (i + k + 2 < j && (k <= 0 || UP)) {
- tputs(LL, 0, plodput);
- outcol = 0;
- outline = LINES - 1;
- }
- }
- } else
- /* No home and no up means it's impossible. */
- if (!UP && destline < outline)
- return (-1);
- if (GT)
- i = destcol % HARDTABS + destcol / HARDTABS;
- else
- i = destcol;
-#ifdef notdef
- if (BT && outcol > destcol &&
- (j = (((outcol+7) & ~7) - destcol - 1) >> 3)) {
- j *= (k = strlen(BT));
- if ((k += (destcol&7)) > 4)
- j += 8 - (destcol&7);
- else
- j += k;
- }
- else
-#endif
- j = outcol - destcol;
-
- /*
- * If we will later need a \n which will turn into a \r\n by the
- * system or the terminal, then don't bother to try to \r.
- */
- if ((NONL || !__pfast) && outline < destline)
- goto dontcr;
-
- /*
- * If the terminal will do a \r\n and there isn't room for it, then
- * we can't afford a \r.
- */
- if (NC && outline >= destline)
- goto dontcr;
-
- /*
- * If it will be cheaper, or if we can't back up, then send a return
- * preliminarily.
- */
- if (j > i + 1 || outcol > destcol && !BS && !BC) {
- /*
- * BUG: this doesn't take the (possibly long) length of CR
- * into account.
- */
- if (CR)
- tputs(CR, 0, plodput);
- else
- plodput('\r');
- if (NC) {
- if (NL)
- tputs(NL, 0, plodput);
- else
- plodput('\n');
- outline++;
- }
- outcol = 0;
- }
-
-dontcr: while (outline < destline) {
- outline++;
- if (NL)
- tputs(NL, 0, plodput);
- else
- plodput('\n');
- if (plodcnt < 0)
- goto out;
- if (NONL || __pfast == 0)
- outcol = 0;
- }
- if (BT)
- k = strlen(BT);
- while (outcol > destcol) {
- if (plodcnt < 0)
- goto out;
-#ifdef notdef
- if (BT && outcol - destcol > k + 4) {
- tputs(BT, 0, plodput);
- outcol--;
- outcol &= ~7;
- continue;
- }
-#endif
- outcol--;
- if (BC)
- tputs(BC, 0, plodput);
- else
- plodput('\b');
- }
- while (outline > destline) {
- outline--;
- tputs(UP, 0, plodput);
- if (plodcnt < 0)
- goto out;
- }
- if (GT && destcol - outcol > 1) {
- for (;;) {
- i = tabcol(outcol, HARDTABS);
- if (i > destcol)
- break;
- if (TA)
- tputs(TA, 0, plodput);
- else
- plodput('\t');
- outcol = i;
- }
- if (destcol - outcol > 4 && i < COLS && (BC || BS)) {
- if (TA)
- tputs(TA, 0, plodput);
- else
- plodput('\t');
- outcol = i;
- while (outcol > destcol) {
- outcol--;
- if (BC)
- tputs(BC, 0, plodput);
- else
- plodput('\b');
- }
- }
- }
- while (outcol < destcol) {
- /*
- * Move one char to the right. We don't use ND space because
- * it's better to just print the char we are moving over.
- */
- if (in_refresh)
- if (plodflg) /* Avoid a complex calculation. */
- plodcnt--;
- else {
- i = curscr->lines[outline]->line[outcol].ch;
- if ((curscr->lines[outline]->line[outcol].attr
- & __STANDOUT) ==
- (curscr->flags & __WSTANDOUT))
- putchar(i);
- else
- goto nondes;
- }
- else
-nondes: if (ND)
- tputs(ND, 0, plodput);
- else
- plodput(' ');
- outcol++;
- if (plodcnt < 0)
- goto out;
- }
-
-out: if (plodflg) {
- outcol = soutcol;
- outline = soutline;
- }
- return (plodcnt);
-}
-
-/*
- * Return the column number that results from being in column col and
- * hitting a tab, where tabs are set every ts columns. Work right for
- * the case where col > COLS, even if ts does not divide COLS.
- */
-static int
-tabcol(col, ts)
- int col, ts;
-{
- int offset;
-
- if (col >= COLS) {
- offset = COLS * (col / COLS);
- col -= offset;
- } else
- offset = 0;
- return (col + ts - (col % ts) + offset);
-}
diff --git a/lib/libcurses/ctrace.c b/lib/libcurses/ctrace.c
deleted file mode 100644
index 4f53906cc5e..00000000000
--- a/lib/libcurses/ctrace.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*-
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)ctrace.c 8.2 (Berkeley) 10/5/93";
-#endif /* not lint */
-
-#ifdef DEBUG
-#include <stdio.h>
-
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#ifndef TFILE
-#define TFILE "__curses.out"
-#endif
-
-static FILE *tracefp; /* Curses debugging file descriptor. */
-
-void
-#ifdef __STDC__
-__CTRACE(const char *fmt, ...)
-#else
-__CTRACE(fmt, va_alist)
- char *fmt;
- va_dcl
-#endif
-{
- va_list ap;
-#ifdef __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- if (tracefp == NULL)
- tracefp = fopen(TFILE, "w");
- if (tracefp == NULL)
- return;
- (void)vfprintf(tracefp, fmt, ap);
- va_end(ap);
- (void)fflush(tracefp);
-}
-#endif
diff --git a/lib/libcurses/cur_hash.c b/lib/libcurses/cur_hash.c
deleted file mode 100644
index ed47fe37333..00000000000
--- a/lib/libcurses/cur_hash.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)cur_hash.c 8.1 (Berkeley) 6/4/93";
-#endif /* not lint */
-
-#include <sys/types.h>
-
-
-/*
- * __hash() is "hashpjw" from the Dragon Book, Aho, Sethi & Ullman, p.436.
- */
-u_int
-__hash(s, len)
- char *s;
- int len;
-{
- register u_int h, g, i;
-
- h = 0;
- i = 0;
- while (i < len) {
- h = (h << 4) + s[i];
- if (g = h & 0xf0000000) {
- h = h ^ (g >> 24);
- h = h ^ g;
- }
- i++;
- }
- return h;
-}
diff --git a/lib/libcurses/curs_addch.3 b/lib/libcurses/curs_addch.3
new file mode 100644
index 00000000000..e32eba1ef1b
--- /dev/null
+++ b/lib/libcurses/curs_addch.3
@@ -0,0 +1,146 @@
+'\" t
+.TH curs_addch 3X ""
+.SH NAME
+\fBaddch\fR, \fBwaddch\fR, \fBmvaddch\fR, \fBmvwaddch\fR,
+\fBechochar\fR, \fBwechochar\fR - add a character (with attributes) to a
+\fBcurses\fR window, then advance the cursor
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint addch(chtype ch);\fR
+.br
+\fBint waddch(WINDOW *win, chtype ch);\fR
+.br
+\fBint mvaddch(int y, int x, chtype ch);\fR
+.br
+\fBint mvwaddch(WINDOW *win, int y, int x, chtype ch);\fR
+.br
+\fBint echochar(chtype ch);\fR
+.br
+\fBint wechochar(WINDOW *win, chtype ch);\fR
+.br
+.SH DESCRIPTION
+The \fBaddch\fR, \fBwaddch\fR, \fBmvaddch\fR and \fBmvwaddch\fR routines put
+the character \fIch\fR into the given window at its current window position,
+which is then advanced. They are analogous to \fBputchar\fR in \fBstdio\fR(3).
+If the advance is at the right margin, the cursor automatically wraps to the
+beginning of the next line. At the bottom of the current scrolling region, if
+\fBscrollok\fR is enabled, the scrolling region is scrolled up one line.
+
+If \fIch\fR is a tab, newline, or backspace, the cursor is moved appropriately
+within the window. Backspace moves the cursor one character left; at the left
+edge of a window it does nothing. Newline does a \fBclrtoeol\fR, then moves
+the cursor to the window left margin on the next line, scrolling the window if
+on the last line). Tabs are considered to be at every eighth column.
+
+If \fIch\fR is any control character other than tab, newline, or backspace, it
+is drawn in \fB^\fR\fIX\fR notation. Calling \fBwinch\fR after adding a
+control character does not return the character itself, but instead returns
+the ^-representation of the control character. (To emit control characters
+literally, use \fBechochar\fR.)
+
+Video attributes can be combined with a character argument passed to
+\fBaddch\fR or related functions by logical-ORing them into the character.
+(Thus, text, including attributes, can be copied from one place to another
+using \fBinch\fR and \fBaddch\fR.). See the \fBcurs_attr\fR(3X) page for
+values of predefined video attribute constants that can be usefully ORed
+into characters.
+
+The \fBechochar\fR and \fBwechochar\fR routines are equivalent to a call to
+\fBaddch\fR followed by a call to \fBrefresh\fR, or a call to \fBwaddch\fR
+followed by a call to \fBwrefresh\fR. The knowledge that only a single
+character is being output is used and, for non-control characters, a
+considerable performance gain may be seen by using these routines instead of
+their equivalents.
+.SS Line Graphics
+The following variables may be used to add line drawing characters to the
+screen with routines of the \fBaddch\fR family. The default character listed
+below is used if the \fBacsc\fR capability doesn't define a terminal-specific
+replacement for it (but see the EXTENSIONS section below). The names are
+taken from VT100 nomenclature.
+
+.TS
+l l l
+_ _ _
+l l l.
+\fIName\fR \fIDefault\fR \fIDescription\fR
+ACS_ULCORNER + upper left-hand corner
+ACS_LLCORNER + lower left-hand corner
+ACS_URCORNER + upper right-hand corner
+ACS_LRCORNER + lower right-hand corner
+ACS_RTEE + right tee
+ACS_LTEE + left tee
+ACS_BTEE + bottom tee
+ACS_TTEE + top tee
+ACS_HLINE - horizontal line
+ACS_VLINE | vertical line
+ACS_PLUS + plus
+ACS_S1 - scan line 1
+ACS_S9 \&_ scan line 9
+ACS_DIAMOND + diamond
+ACS_CKBOARD : checker board (stipple)
+ACS_DEGREE ' degree symbol
+ACS_PLMINUS # plus/minus
+ACS_BULLET o bullet
+ACS_LARROW < arrow pointing left
+ACS_RARROW > arrow pointing right
+ACS_DARROW v arrow pointing down
+ACS_UARROW ^ arrow pointing up
+ACS_BOARD # board of squares
+ACS_LANTERN # lantern symbol
+ACS_BLOCK # solid square block
+ACS_S3 - scan line 3
+ACS_S7 - scan line 7
+ACS_LEQUAL < less-than-or-equal-to
+ACS_GEQUAL > greater-than-or-equal-to
+ACS_PI * greek pi
+ACS_NEQUAL ! not-equal
+ACS_STERLING f pound-sterling symbol
+.TE
+
+.SH RETURN VALUE
+All routines return the integer \fBERR\fR upon failure and \fBOK\fR on success
+(the SVr4 manuals specify only "an integer value other than \fBERR\fR") upon
+successful completion, unless otherwise noted in the preceding routine
+descriptions.
+.SH NOTES
+Note that \fBaddch\fR, \fBmvaddch\fR, \fBmvwaddch\fR, and
+\fBechochar\fR may be macros.
+.SH EXTENSIONS
+The following extended \fBcurses\fR features are available only on PC-clone
+consoles and compatible terminals obeying the ANSI.SYS de-facto standard for
+terminal control sequences. They are not part of XSI curses.
+
+The attribute A_ALTCHARSET actually forces literal display of PC ROM characters
+including the high-half graphics. Your console driver may still capture or
+translate a few (such as ESC) but this feature should give you access to the
+card-suit characters, up and down-arrow, and most others in the range 0-32.
+(In a terminfo entry designed for use with \fBncurses\fR, the high-half
+characters are obtained using this attribute with an \fBacsc\fR string in
+which the second of each pair is a high-half character.)
+
+Giving \fBwechochar\fR an argument with its high bit set will produce the
+corresponding high-half ASCII graphic (SVr4 curses also has this feature but
+does not document it). A control-character argument, however, will not
+typically produce the corresponding graphic; characters such as CR, NL, FF and
+TAB are typically interpreted by the console driver itself, and ESC will be
+interpreted as the leader of a control sequence.
+.SH PORTABILITY
+All these functions are described in the XSI Curses standard, Issue 4.
+The defaults specified for forms-drawing characters apply in the POSIX locale.
+
+The seven ACS symbols starting with \fBACS_S3\fR were not documented in
+any publicly released System V. However, many publicly available terminfos
+include \fBacsc\fR strings in which their key characters (pryz{|}) are
+embedded, and a second-hand list of their character descriptions has come
+to light. The ACS-prefixed names for them were invented for \fBncurses\fR(3X).
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_attr\fR(3X), \fBcurs_clear\fR(3X),
+\fBcurs_inch\fR(3X), \fBcurs_outopts\fR(3X), \fBcurs_refresh\fR(3X),
+\fBputc\fR(3S).
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_addchstr.3 b/lib/libcurses/curs_addchstr.3
new file mode 100644
index 00000000000..fd5600dd2e1
--- /dev/null
+++ b/lib/libcurses/curs_addchstr.3
@@ -0,0 +1,55 @@
+.TH curs_addchstr 3X ""
+.SH NAME
+\fBaddchstr\fR, \fBaddchnstr\fR, \fBwaddchstr\fR,
+\fBwaddchnstr\fR, \fBmvaddchstr\fR, \fBmvaddchnstr\fR, \fBmvwaddchstr\fR,
+\fBmvwaddchnstr\fR - add a string of characters (and attributes) to a
+\fBcurses\fR window
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint addchstr(const chtype *chstr);\fR
+.br
+\fBint addchnstr(const chtype *chstr, int n);\fR
+.br
+\fBint waddchstr(WINDOW *win, const chtype *chstr);\fR
+.br
+\fBint waddchnstr(WINDOW *win, const chtype *chstr, int n);\fR
+.br
+\fBint mvaddchstr(int y, int x, const chtype *chstr);\fR
+.br
+\fBint mvaddchnstr(int y, int x, const chtype *chstr, int n);\fR
+.br
+\fBint mvwaddchstr(WINDOW *win, int y, int x, const chtype *chstr);\fR
+.br
+\fBint mvwaddchnstr(WINDOW *win, int y, int x, const chtype *chstr, int n);\fR
+.SH DESCRIPTION
+These routines copy \fIchstr\fR into the window image structure at and after
+the current cursor position. The four routines with \fIn\fR as the last
+argument copy at most \fIn\fR elements, but no more than will fit on the line.
+If \fBn\fR=\fB-1\fR then the whole string is copied, to the maximum number of
+characters that will fit on the line.
+
+The window cursor is \fInot\fR advanced, and these routines work faster than
+\fBwaddnstr\fR. On the other hand, they don't perform any kind of checking
+(such as for the newline, backspace, or carriage return characters), they don't
+advance the current cursor position, they don't expand other control characters
+to ^-escapes, and they truncate the string if it crosses the right margin,
+rather then wrapping it around to the new line.
+
+.SH RETURN VALUES
+All routines return the integer \fBERR\fR upon failure and \fBOK\fR on success
+(the SVr4 manuals specify only "an integer value other than \fBERR\fR") upon
+successful completion, unless otherwise noted in the preceding routine
+descriptions.
+.SH NOTES
+Note that all routines except \fBwaddchnstr\fR may be macros.
+.SH PORTABILITY
+All these entry points are described in the XSI Curses standard, Issue 4.
+.SH SEE ALSO
+\fBcurses\fR(3X).
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_addstr.3 b/lib/libcurses/curs_addstr.3
new file mode 100644
index 00000000000..3859a34b8b4
--- /dev/null
+++ b/lib/libcurses/curs_addstr.3
@@ -0,0 +1,48 @@
+.TH curs_addstr 3X ""
+.SH NAME
+\fBaddstr\fR, \fBaddnstr\fR, \fBwaddstr\fR, \fBwaddnstr\fR,
+\fBmvaddstr\fR, \fBmvaddnstr\fR, \fBmvwaddstr\fR, \fBmvwaddnstr\fR - add a
+string of characters to a \fBcurses\fR window and advance cursor
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint addstr(const char *str);\fR
+.br
+\fBint addnstr(const char *str, int n);\fR
+.br
+\fBint waddstr(WINDOW *win, const char *str);\fR
+.br
+\fBint waddnstr(WINDOW *win, const char *str, int n);\fR
+.br
+\fBint mvaddstr(int y, int x, const char *str);\fR
+.br
+\fBint mvaddnstr(int y, int x, const char *str, int n);\fR
+.br
+\fBint mvwaddstr(WINDOW *win, int y, int x, const char *str);\fR
+.br
+\fBint mvwaddnstr(WINDOW *win, int y, int x, const char *str, int n);\fR
+.SH DESCRIPTION
+These routines write the characters of the (null-terminated) character string
+\fIstr\fR on the given window. It is similar to calling \fBwaddch\fR once for
+each character in the string. The four routines with \fIn\fR as the last
+argument write at most \fIn\fR characters. If \fIn\fR is -1, then the
+entire string will be added.
+.SH RETURN VALUE
+All routines return the integer \fBERR\fR upon failure and \fBOK\fR on success
+(the SVr4 manuals specify only "an integer value other than \fBERR\fR") upon
+successful completion.
+.SH NOTES
+Note that all of these routines except \fBwaddstr\fR and \fBwaddnstr\fR may be
+macros.
+.SH PORTABILITY
+All these entry points are described in the XSI Curses standard, Issue 4. The
+XSI errors EILSEQ and EOVERFLOW, associated with extended-level conformance,
+are not yet detected.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_addch\fR(3X).
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_attr.3 b/lib/libcurses/curs_attr.3
new file mode 100644
index 00000000000..d08df520173
--- /dev/null
+++ b/lib/libcurses/curs_attr.3
@@ -0,0 +1,167 @@
+.TH curs_attr 3X ""
+.SH NAME
+\fBattroff\fR, \fBwattroff\fR, \fBattron\fR, \fBwattron\fR,
+\fBattrset\fR, \fBwattrset\fR, \fBstandend\fR, \fBwstandend\fR, \fBstandout\fR,
+\fBwstandout\fR - \fBcurses\fR character and window attribute control routines
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+.br
+\fBint attroff(int attrs);\fR
+.br
+\fBint wattroff(WINDOW *win, int attrs);\fR
+.br
+\fBint attron(int attrs);\fR
+.br
+\fBint wattron(WINDOW *win, int attrs);\fR
+.br
+\fBint attrset(int attrs);\fR
+.br
+\fBint wattrset(WINDOW *win, int attrs);\fR
+.br
+\fBint standend(void);\fR
+.br
+\fBint wstandend(WINDOW *win);\fR
+.br
+\fBint standout(void);\fR
+.br
+\fBint wstandout(WINDOW *win);\fR
+.br
+\fBattr_t attr_get(void);\fR
+.br
+\fBattr_t wattr_get(WINDOW *);\fR
+.br
+\fBint attr_off(attr_t attrs);\fR
+.br
+\fBint wattr_off(WINDOW *, attr_t attrs);\fR
+.br
+\fBint attr_on(attr_t attrs);\fR
+.br
+\fBint wattr_on(WINDOW *, attr_t attrs);\fR
+.br
+\fBint attr_set(attr_t attrs);\fR
+.br
+\fBint wattr_set(WINDOW *, attr_t attrs);\fR
+.br
+\fBint chgat(int n, attr_t attr, short color, const void *opts)\fR
+.br
+\fBint wchgat(WINDOW *, int n, attr_t attr,
+ short color, const void *opts)\fR
+.br
+\fBint mvchgat(int y, int x, int n, attr_t attr,
+ short color, const void *opts)\fR
+.br
+\fBint mvwchgat(WINDOW *, int y, int x, int n, attr_t attr,
+ short color, const void *opts)\fR
+.br
+.SH DESCRIPTION
+These routines manipulate the current attributes of the named window. The
+current attributes of a window apply to all characters that are written into
+the window with \fBwaddch\fR, \fBwaddstr\fR and \fBwprintw\fR. Attributes are
+a property of the character, and move with the character through any scrolling
+and insert/delete line/character operations. To the extent possible, they are
+displayed as appropriate modifications to the graphic rendition of characters
+put on the screen.
+
+The routine \fBattrset\fR sets the current attributes of the given window to
+\fIattrs\fR. The routine \fBattroff\fR turns off the named attributes without
+turning any other attributes on or off. The routine \fBattron\fR turns on the
+named attributes without affecting any others. The routine \fBstandout\fR is
+the same as \fBattron(A_STANDOUT)\fR. The routine \fBstandend\fR is the same
+as \fBattrset(A_NORMAL)\fR or \fBattrset(0)\fR, that is, it turns off all
+attributes.
+
+The routine \fBwattr_get\fR returns the current attribute for the given
+window; \fBattr_get\fR returns the current attribute for \fBstdscr\fR.
+The remaining \fBattr_\fR* functions operate exactly like the corresponding
+\fBattr\fR* functions, except that they take arguments of type \fBattr_t\fR
+rather than \fBint\fR.
+
+The routine \fBchgat\fR changes the attributes of a given number of characters
+starting at the current cursor location of \fBstdscr\fR. It does not update
+the cursor and does not perform wrapping. A character count of -1 or greater
+than the remaining window width means to change attributes all the way to the
+end of the current line. The \fBwchgat\fR function generalizes this to any
+window; the \fBmvwchgat\fR function does a cursor move before acting. In these
+functions, the color argument is a color-pair index (as in the first argument
+of \fIinit_pair\fR, see \fBcurs_color\fR(3x)). The \fBopts\fR argument is not
+presently used, but is reserved for the future (leave it \fBNULL\fR).
+.SS Attributes
+The following video attributes, defined in \fB<curses.h>\fR, can be passed to
+the routines \fBattron\fR, \fBattroff\fR, and \fBattrset\fR, or OR-ed with the
+characters passed to \fBaddch\fR.
+
+.nf
+\fBA_NORMAL\fR Normal display (no highlight)
+\fBA_STANDOUT\fR Best highlighting mode of the terminal.
+\fBA_UNDERLINE\fR Underlining
+\fBA_REVERSE\fR Reverse video
+\fBA_BLINK\fR Blinking
+\fBA_DIM\fR Half bright
+\fBA_BOLD\fR Extra bright or bold
+\fBA_PROTECT\fR Protected mode
+\fBA_INVIS\fR Invisible or blank mode
+\fBA_ALTCHARSET\fR Alternate character set
+\fBA_CHARTEXT\fR Bit-mask to extract a character
+\fBCOLOR_PAIR(\fR\fIn\fR\fB)\fR Color-pair number \fIn\fR
+.fi
+
+The following macro is the reverse of \fBCOLOR_PAIR(\fR\fIn\fR\fB)\fR:
+
+.DS C
+\fBPAIR_NUMBER(\fIattrs\fR) Returns the pair number associated
+ with the \fBCOLOR_PAIR(\fR\fIn\fR\fB)\fR attribute.
+.DE
+
+The return values of many of these routines are not meaningful (they are
+implemented as macro-expanded assignments and simply return their argument).
+The SVr4 manual page claims (falsely) that these routines always return \fB1\fR.
+
+.SH NOTES
+Note that \fBattroff\fR, \fBwattroff\fR, \fBattron\fR, \fBwattron\fR,
+\fBattrset\fR, \fBwattrset\fR, \fBstandend\fR and \fBstandout\fR may be macros.
+.SH PORTABILITY
+All these functions are supported in the XSI Curses standard, Issue 4. The
+standard defined the dedicated type for highlights, \fBattr_t\fR, which is not
+defined in SVr4 curses. The functions taking \fBattr_t\fR arguments are
+not supported under SVr4.
+
+The XSI Curses standard states that whether the traditional functions
+\fBattron\fR/\fBattroff\fR/\fBattrset\fR can manipulate attributes other than
+\fBA_BLINK\fR, \fBA_BOLD\fR, \fBA_DIM\fR, \fBA_REVERSE\fR, \fBA_STANDOUT\fR, or
+\fBA_UNDERLINE\fR is "unspecified". Under this implementation as well as
+SVr4 curses, these functions correctly manipulate all other highlights
+(specifically, \fBA_ALTCHARSET\fR, \fBA_PROTECT\fR, and \fBA_INVIS\fR).
+
+XSI Curses added the new entry points, \fBattr_get\fR, \fBattr_on\fR,
+\fBattr_off\fR, \fBattr_set\fR, \fBwattr_on\fR, \fBwattr_off\fR,
+\fBwattr_get\fR, \fBwattr_set\fR. These are intended to work with
+a new series of highlight macros prefixed with \fBWA_\fR.
+
+.nf
+\fBWA_NORMAL\fR Normal display (no highlight)
+\fBWA_STANDOUT\fR Best highlighting mode of the terminal.
+\fBWA_UNDERLINE\fR Underlining
+\fBWA_REVERSE\fR Reverse video
+\fBWA_BLINK\fR Blinking
+\fBWA_DIM\fR Half bright
+\fBWA_BOLD\fR Extra bright or bold
+\fBWA_ALTCHARSET\fR Alternate character set
+.fi
+
+The XSI curses standard specifies that each pair of corresponding \fBA_\fR
+and \fBWA_\fR-using functions operates on the same current-highlight
+information.
+
+The XSI standard extended conformance level adds new highlights
+\fBA_HORIZONTAL\fR, \fBA_LEFT\fR, \fBA_LOW\fR, \fBA_RIGHT\fR, \fBA_TOP\fR,
+\fBA_VERTICAL\fR (and corresponding \fBWA_\fR macros for each) which this
+curses does not yet support.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_addch\fR(3X), \fBcurs_addstr\fR(3X),
+\fBcurs_printw\fR(3X)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_beep.3 b/lib/libcurses/curs_beep.3
new file mode 100644
index 00000000000..140f255c762
--- /dev/null
+++ b/lib/libcurses/curs_beep.3
@@ -0,0 +1,34 @@
+.TH curs_beep 3X ""
+.SH NAME
+\fBbeep\fR, \fBflash\fR - \fBcurses\fR bell and screen flash routines
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint beep(void);\fR
+.br
+\fBint flash(void);\fR
+.br
+.SH DESCRIPTION
+The \fBbeep\fR and \fBflash\fR routines are used to alert the terminal user.
+The routine \fBbeep\fR sounds an audible alarm on the terminal, if possible;
+otherwise it flashes the screen (visible bell). The routine \fBflash\fR
+flashes the screen, and if that is not possible, sounds the alert. If neither
+alert is possible, nothing happens. Nearly all terminals have an audible alert
+(bell or beep), but only some can flash the screen.
+.SH RETURN VALUE
+These routines return \fBOK\fR if they succeed in beeping or flashing,
+\fBERR\fR otherwise.
+.SH EXTENSIONS
+SVr4's beep and flash routines always returned \fBOK\fR, so it was not
+possible to tell when the beep or flash failed.
+.SH PORTABILITY
+These functions are defined in the XSI Curses standard, Issue 4. Like SVr4, it
+specifies that they always return \fBOK\fR.
+.SH SEE ALSO
+\fBcurses\fR(3X)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_bkgd.3 b/lib/libcurses/curs_bkgd.3
new file mode 100644
index 00000000000..cc3372c8e47
--- /dev/null
+++ b/lib/libcurses/curs_bkgd.3
@@ -0,0 +1,60 @@
+.TH curs_bkgd 3X ""
+.SH NAME
+\fBbkgdset\fR, \fBwbkgdset\fR, \fBbkgd\fR,
+\fBwbkgd\fR - \fBcurses\fR window background manipulation routines
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBvoid bkgdset(const chtype ch);\fR
+.br
+\fBvoid wbkgdset(WINDOW *win, const chtype ch);\fR
+.br
+\fBint bkgd(const chtype ch);\fR
+.br
+\fBint wbkgd(WINDOW *win, const chtype ch);\fR
+.br
+\fBchtype wgetbkgd(WINDOW *win);\fR
+.br
+.SH DESCRIPTION
+The \fBbkgdset\fR and \fBwbkgdset\fR routines manipulate the
+background of the named window. Background is a \fBchtype\fR
+consisting of any combination of attributes and a character. The
+attribute part of the background is combined (ORed) with all non-blank
+characters that are written into the window with \fBwaddch\fR. Both
+the character and attribute parts of the background are combined with
+the blank characters. The background becomes a property of the
+character and moves with the character through any scrolling and
+insert/delete line/character operations. To the extent possible on a
+particular terminal, the attribute part of the background is displayed
+as the graphic rendition of the character put on the screen.
+
+The \fBbkgd\fR and \fBwbkgd\fR routines combine the new background
+with every position in the window. Background is any combination of
+attributes and a character. Only the attribute part is used to set
+the background of non-blank characters, while both character and
+attributes are used for blank positions. To the extent possible on a
+particular terminal, the attribute part of the background is displayed
+as the graphic rendition of the character put on the screen.
+
+The \fBwgetbkgd\fR function returns the given window's current background
+character/attribute pair.
+.SH RETURN VALUE
+The routines \fBbkgd\fR and \fBwbkgd\fR return the integer \fBOK\fR.
+The SVr4.0 manual says "or a non-negative integer if \fBimmedok\fR is set",
+but this appears to be an error.
+.SH NOTES
+Note that \fBbkgdset\fR and \fBbkgd\fR may be macros.
+.SH PORTABILITY
+These functions are described in the XSI Curses standard, Issue 4. The draft
+does not include \fBconst\fR qualifiers on the arguments. The standard
+specifies that \fBbkgd\fR and \fBwbkgd\fR return \fBERR\fR, on failure. but
+gives no failure conditions. The draft describes the new function
+\fBwgetbkgd\fR, which is not in SVr4.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_addch\fR(3X), \fBcurs_outopts\fR(3X)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_border.3 b/lib/libcurses/curs_border.3
new file mode 100644
index 00000000000..c3d845acfc8
--- /dev/null
+++ b/lib/libcurses/curs_border.3
@@ -0,0 +1,71 @@
+.TH curs_border 3X ""
+.SH NAME
+\fBborder\fR, \fBwborder\fR, \fBbox\fR,
+\fBhline\fR, \fBwhline\fR, \fBvline\fR, \fBwvline\fR - create
+\fBcurses\fR borders, horizontal and vertical lines
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+.br
+\fBint border(chtype ls, chtype rs, chtype ts, chtype bs,
+ chtype tl, chtype tr, chtype bl, chtype br);\fR
+.br
+\fBint wborder(WINDOW *win, chtype ls, chtype rs,
+ chtype ts, chtype bs, chtype tl, chtype tr,
+ chtype bl, chtype br);\fR
+.br
+\fBint box(WINDOW *win, chtype verch, chtype horch);\fR
+.br
+\fBint hline(chtype ch, int n);\fR
+.br
+\fBint whline(WINDOW *win, chtype ch, int n);\fR
+.br
+\fBint vline(chtype ch, int n);\fR
+.br
+\fBint wvline(WINDOW *win, chtype ch, int n);\fR
+.br
+.SH DESCRIPTION
+The \fBborder\fR, \fBwborder\fR and \fBbox\fR routines draw a box around the
+edges of a window. The argument \fIls\fR is a character and attributes used
+for the left side of the border, \fIrs\fR - right side, \fIts\fR - top side,
+\fIbs\fR - bottom side, \fItl\fR - top left-hand corner, \fItr\fR - top
+right-hand corner, \fIbl\fR - bottom left-hand corner, and \fIbr\fR - bottom
+right-hand corner. If any of these arguments is zero, then the following
+default values (defined in \fBcurses.h\fR) are used instead: \fBACS_VLINE\fR,
+\fBACS_VLINE\fR, \fBACS_HLINE\fR, \fBACS_HLINE\fR, \fB\fBACS_ULCORNER\fR,
+\fBACS_URCORNER\fR, \fBACS_BLCORNER\fR, \fBACS_BRCORNER\fR.
+
+\fBbox(\fR\fIwin\fR\gB, \fR\fIverch\fR\fB, \fR\fIhorch\fR\fB)\fR is a shorthand
+for the following call: \fBwborder(\fR\fIwin\fR\fB,\fR \fIverch\fR\fB,\fR
+\fIverch\fR\fB,\fR \fIhorch\fR\fB,\fR \fIhorch\fR\fB, 0, 0, 0, 0)\fR.
+
+The \fBhline\fR and \fBwhline\fR functions draw a horizontal (left to right)
+line using \fIch\fR starting at the current cursor position in the window. The
+current cursor position is not changed. The line is at most \fIn\fR characters
+long, or as many as fit into the window.
+
+The \fBvline\fR and \fBwvline\fR functions draw a vertical (top to bottom) line
+using \fIch\fR starting at the current cursor position in the window. The
+current cursor position is not changed. The line is at most \fIn\fR characters
+long, or as many as fit into the window.
+.SH RETURN VALUE
+All routines return the integer \fBOK\fR. The SVr4.0 manual says "or a
+non-negative integer if \fBimmedok\fR is set", but this appears to be an error.
+.SH NOTES
+The borders generated by these functions are \fIinside\fR borders (this
+is also true of SVr4 curses, though the fact is not documented).
+
+Note that \fBborder\fR and \fBbox\fR may be macros.
+.SH PORTABILITY
+These functions are described in the XSI Curses standard, Issue 4. Additional
+functions \fBmvhline\fR, \fBmvvline\fR, \fBmvwhline\fR, and \fBmvwvline\fR are
+described there which this implementation does not yet support. The standard
+specifies that they return \fBERR\fR on failure, but specifies no error
+conditions.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_outopts\fR(3X).
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_clear.3 b/lib/libcurses/curs_clear.3
new file mode 100644
index 00000000000..1a9efb7ce15
--- /dev/null
+++ b/lib/libcurses/curs_clear.3
@@ -0,0 +1,65 @@
+.TH curs_clear 3X ""
+.SH NAME
+\fBerase\fR, \fBwerase\fR, \fBclear\fR,
+\fBwclear\fR, \fBclrtobot\fR, \fBwclrtobot\fR, \fBclrtoeol\fR,
+\fBwclrtoeol\fR - clear all or part of a \fBcurses\fR window
+.SH SYNOPSIS
+\fB# include <curses.h>\fR
+
+\fBint erase(void);\fR
+.br
+\fBint werase(WINDOW *win);\fR
+.br
+\fBint clear(void);\fR
+.br
+\fBint wclear(WINDOW *win);\fR
+.br
+\fBint clrtobot(void);\fR
+.br
+\fBint wclrtobot(WINDOW *win);\fR
+.br
+\fBint clrtoeol(void);\fR
+.br
+\fBint wclrtoeol(WINDOW *win);\fR
+.br
+.SH DESCRIPTION
+The \fBerase\fR and \fBwerase\fR routines copy blanks to every
+position in the window, clearing the screen.
+
+The \fBclear\fR and \fBwclear\fR routines are like \fBerase\fR and
+\fBwerase\fR, but they also call \fBclearok\fR, so that the screen is
+cleared completely on the next call to \fBwrefresh\fR for that window
+and repainted from scratch.
+
+The \fBclrtobot\fR and \fBwclrtobot\fR routines erase from the cursor to the
+end of screen. That is, they erase all lines below the cursor in the window.
+Also, the current line to the right of the cursor, inclusive, is erased.
+
+The \fBclrtoeol\fR and \fBwclrtoeol\fR routines erase the current line
+to the right of the cursor, inclusive, to the end of the current line.
+
+Blanks created by erasure have the current background rendition (as set
+by \fBwbkgdset\fR) merged into them.
+.SH RETURN VALUE
+All routines return the integer \fBOK\fR. The SVr4.0 manual says "or a
+non-negative integer if \fBimmedok\fR is set", but this appears to be an error.
+.SH NOTES
+Note that \fBerase\fR, \fBwerase\fR, \fBclear\fR, \fBwclear\fR,
+\fBclrtobot\fR, and \fBclrtoeol\fR may be macros.
+.SH PORTABILITY
+These functions are described in the XSI Curses standard, Issue 4. The
+standard specifies that they return \fBERR\fR on failure, but specifies no
+error conditions.
+
+Some historic curses implementations had, as an undocumented feature, the
+ability to do the equivalent of \fBclearok(..., 1)\fR by saying
+\fBtouchwin(stdscr)\fR or \fBclear(stdscr)\fR. This will not work under
+ncurses.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_outopts\fR(3X), \fBcurs_refresh\fR(3X)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_color.3 b/lib/libcurses/curs_color.3
new file mode 100644
index 00000000000..ef015207411
--- /dev/null
+++ b/lib/libcurses/curs_color.3
@@ -0,0 +1,148 @@
+.TH curs_color 3X ""
+.SH NAME
+\fBstart_color\fR, \fBinit_pair\fR,
+\fBinit_color\fR, \fBhas_colors\fR, \fBcan_change_color\fR,
+\fBcolor_content\fR, \fBpair_content\fR - \fBcurses\fR color
+manipulation routines
+.SH SYNOPSIS
+\fB# include <curses.h>\fR
+.br
+\fBint start_color(void);\fR
+.br
+\fBint init_pair(short pair, short f, short b);\fR
+.br
+\fBint init_color(short color, short r, short g, short b);\fR
+.br
+\fBbool has_colors(void);\fR
+.br
+\fBbool can_change_color(void);\fR
+.br
+\fBint color_content(short color, short *r, short *g, short *b);\fR
+.br
+\fBint pair_content(short pair, short *f, short *b);\fR
+.br
+.SH DESCRIPTION
+.SS Overview
+\fBcurses\fR support color attributes on terminals with that capability. To
+use these routines \fBstart_color\fR must be called, usually right after
+\fBinitscr\fR. Colors are always used in pairs (referred to as color-pairs).
+A color-pair consists of a foreground color (for characters) and a background
+color (for the blank field on which the characters are displayed). A
+programmer initializes a color-pair with the routine \fBinit_pair\fR. After it
+has been initialized, \fBCOLOR_PAIR\fR(\fIn\fR), a macro defined in
+\fB<curses.h>\fR, can be used as a new video attribute.
+
+If a terminal is capable of redefining colors, the programmer can use the
+routine \fBinit_color\fR to change the definition of a color. The routines
+\fBhas_colors\fR and \fBcan_change_color\fR return \fBTRUE\fR or \fBFALSE\fR,
+depending on whether the terminal has color capabilities and whether the
+programmer can change the colors. The routine \fBcolor_content\fR allows a
+programmer to extract the amounts of red, green, and blue components in an
+initialized color. The routine \fBpair_content\fR allows a programmer to find
+out how a given color-pair is currently defined.
+.SS Routine Descriptions
+The \fBstart_color\fR routine requires no arguments. It must be
+called if the programmer wants to use colors, and before any other
+color manipulation routine is called. It is good practice to call
+this routine right after \fBinitscr\fR. \fBstart_color\fR initializes
+eight basic colors (black, red, green, yellow, blue, magenta, cyan,
+and white), and two global variables, \fBCOLORS\fR and
+\fBCOLOR_PAIRS\fR (respectively defining the maximum number of colors
+and color-pairs the terminal can support). It also restores the
+colors on the terminal to the values they had when the terminal was
+just turned on.
+
+The \fBinit_pair\fR routine changes the definition of a color-pair. It takes
+three arguments: the number of the color-pair to be changed, the foreground
+color number, and the background color number. The value of the first argument
+must be between \fB1\fR and \fBCOLOR_PAIRS-1\fR. The value of the second and
+third arguments must be between 0 and \fBCOLORS\fR (the 0 color pair is wired
+to white on black and cannot be changed). If the color-pair was previously
+initialized, the screen is refreshed and all occurrences of that color-pair is
+changed to the new definition.
+
+The \fBinit_color\fR routine changes the definition of a color. It takes four
+arguments: the number of the color to be changed followed by three RGB values
+(for the amounts of red, green, and blue components). The value of the first
+argument must be between \fB0\fR and \fBCOLORS\fR. (See the section
+\fBColors\fR for the default color index.) Each of the last three arguments
+must be a value between 0 and 1000. When \fBinit_color\fR is used, all
+occurrences of that color on the screen immediately change to the new
+definition.
+
+The \fBhas_colors\fR routine requires no arguments. It returns \fBTRUE\fR if
+the terminal can manipulate colors; otherwise, it returns \fBFALSE\fR. This
+routine facilitates writing terminal-independent programs. For example, a
+programmer can use it to decide whether to use color or some other video
+attribute.
+
+The \fBcan_change_color\fR routine requires no arguments. It returns
+\fBTRUE\fR if the terminal supports colors and can change their definitions;
+other, it returns \fBFALSE\fR. This routine facilitates writing
+terminal-independent programs.
+
+The \fBcolor_content\fR routine gives programmers a way to find the intensity
+of the red, green, and blue (RGB) components in a color. It requires four
+arguments: the color number, and three addresses of \fBshort\fRs for storing
+the information about the amounts of red, green, and blue components in the
+given color. The value of the first argument must be between 0 and
+\fBCOLORS\fR. The values that are stored at the addresses pointed to by the
+last three arguments are between 0 (no component) and 1000 (maximum amount of
+component).
+
+The \fBpair_content\fR routine allows programmers to find out what colors a
+given color-pair consists of. It requires three arguments: the color-pair
+number, and two addresses of \fBshort\fRs for storing the foreground and the
+background color numbers. The value of the first argument must be between 1
+and \fBCOLOR_PAIRS-1\fR. The values that are stored at the addresses pointed
+to by the second and third arguments are between 0 and \fBCOLORS\fR.
+.SS Colors
+In \fB<curses.h>\fR the following macros are defined. These are the default
+colors. \fBcurses\fR also assumes that \fBCOLOR_BLACK\fR is the default
+background color for all terminals.
+
+.nf
+ \fBCOLOR_BLACK\fR
+ \fBCOLOR_RED\fR
+ \fBCOLOR_GREEN\fR
+ \fBCOLOR_YELLOW\fR
+ \fBCOLOR_BLUE\fR
+ \fBCOLOR_MAGENTA\fR
+ \fBCOLOR_CYAN\fR
+ \fBCOLOR_WHITE\fR
+.fi
+.SH RETURN VALUE
+The routines \fBcan_change_color()\fR and \fBhas_colors()\fR return \fBTRUE\fR
+or \fBFALSE\fR.
+
+All other routines return the integer \fBERR\fR upon failure and an \fBOK\fR
+(SVr4 specifies only "an integer value other than \fBERR\fR") upon successful
+completion.
+.SH NOTES
+Note that setting an implicit background color via a color pair affects only
+character cells that a character write operation explicitly touches. To change
+the background color used when parts of a window are blanked by erasing or
+scrolling operastions, see \fBcurs_bkgd\fR(3x).
+
+Several caveats apply on 386 and 486 machines with VGA-compatible graphics:
+
+COLOR_YELLOW is actually brown. To get yellow, use COLOR_YELLOW combined with
+the \fBA_BOLD\fR attribute.
+
+The A_BLINK attribute should in theory cause the background to go bright. This
+often fails to work, and even some cards for which it mostly works (such as the
+Paradise and compatibles) do the wrong thing when you try to set a bright
+"yellow" background (you get a blinking yellow foreground instead).
+
+Color RGB values are not settable.
+.SH PORTABILITY
+This implementation satisfies XSI Curses's minumum maximums
+for \fBCOLORS\fR and \fBCOLOR_PAIRS\fR.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_initscr\fR(3X), \fBcurs_attr\fR(3X)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_delch.3 b/lib/libcurses/curs_delch.3
new file mode 100644
index 00000000000..d7973a98962
--- /dev/null
+++ b/lib/libcurses/curs_delch.3
@@ -0,0 +1,39 @@
+.TH curs_delch 3X ""
+.SH NAME
+\fBdelch\fR, \fBwdelch\fR, \fBmvdelch\fR, \fBmvwdelch\fR -
+delete character under the cursor in a \fBcurses\fR window
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint delch(void);\fR
+.br
+\fBint wdelch(WINDOW *win);\fR
+.br
+\fBint mvdelch(int y, int x);\fR
+.br
+\fBint mvwdelch(WINDOW *win, int y, int x);\fR
+.br
+.SH DESCRIPTION
+These routines delete the character under the cursor; all characters to the
+right of the cursor on the same line are moved to the left one position and the
+last character on the line is filled with a blank. The cursor position does
+not change (after moving to \fIy\fR, \fIx\fR, if specified). (This does not
+imply use of the hardware delete character feature.)
+.SH RETURN VALUE
+All routines return the integer \fBERR\fR upon failure and an \fBOK\fR (SVr4
+specifies only "an integer value other than \fBERR\fR") upon successful
+completion.
+.SH NOTES
+Note that \fBdelch\fR, \fBmvdelch\fR, and \fBmvwdelch\fR may be macros.
+.SH PORTABILITY
+These functions are described in the XSI Curses standard, Issue 4. The
+standard specifies that they return \fBERR\fR on failure, but specifies no
+error conditions.
+.SH SEE ALSO
+\fBcurses\fR(3X)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_deleteln.3 b/lib/libcurses/curs_deleteln.3
new file mode 100644
index 00000000000..2b4710990aa
--- /dev/null
+++ b/lib/libcurses/curs_deleteln.3
@@ -0,0 +1,55 @@
+.TH curs_deleteln 3X ""
+.SH NAME
+\fBdeleteln\fR, \fBwdeleteln\fR, \fBinsdelln\fR,
+\fBwinsdelln\fR, \fBinsertln\fR, \fBwinsertln\fR - delete and insert
+lines in a \fBcurses\fR window
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint deleteln(void);\fR
+.br
+\fBint wdeleteln(WINDOW *win);\fR
+.br
+\fBint insdelln(int n);\fR
+.br
+\fBint winsdelln(WINDOW *win, int n);\fR
+.br
+\fBint insertln(void);\fR
+.br
+\fBint winsertln(WINDOW *win);\fR
+.br
+.SH DESCRIPTION
+The \fBdeleteln\fR and \fBwdeleteln\fR routines delete the line under the
+cursor in the window; all lines below the current line are moved up one line.
+The bottom line of the window is cleared. The cursor position does not change.
+
+The \fBinsdelln\fR and \fBwinsdelln\fR routines, for positive \fIn\fR, insert
+\fIn\fR lines into the specified window above the current line. The \fIn\fR
+bottom lines are lost. For negative \fIn\fR, delete \fIn\fR lines (starting
+with the one under the cursor), and move the remaining lines up. The bottom
+\fIn\fR lines are cleared. The current cursor position remains the same.
+
+The \fBinsertln\fR and \fBinsertln\fR routines, insert a blank line above the
+current line and the bottom line is lost.
+.SH RETURN VALUE
+All routines return the integer \fBERR\fR upon failure and an \fBOK\fR (SVr4
+specifies only "an integer value other than \fBERR\fR") upon successful
+completion.
+.SH PORTABILITY
+These functions are described in the XSI Curses standard, Issue 4. The
+standard specifies that they return \fBERR\fR on failure, but specifies no
+error conditions.
+.SH NOTES
+Note that all but \fBwinsdelln\fR may be a macros.
+
+These routines do not require a hardware line delete or insert feature in the
+terminal. In fact, they won't use hardware line delete/insert unless
+\fBidlok(..., TRUE)\fR has been set on the current window.
+.SH SEE ALSO
+\fBcurses\fR(3X)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_getch.3 b/lib/libcurses/curs_getch.3
new file mode 100644
index 00000000000..293bcf29fc4
--- /dev/null
+++ b/lib/libcurses/curs_getch.3
@@ -0,0 +1,203 @@
+.TH curs_getch 3X ""
+.SH NAME
+\fBgetch\fR, \fBwgetch\fR, \fBmvgetch\fR,
+\fBmvwgetch\fR, \fBungetch\fR - get (or push back) characters from
+\fBcurses\fR terminal keyboard
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint getch(void);\fR
+.br
+\fBint wgetch(WINDOW *win);\fR
+.br
+\fBint mvgetch(int y, int x);\fR
+.br
+\fBint mvwgetch(WINDOW *win, int y, int x);\fR
+.br
+\fBint ungetch(int ch);\fR
+.br
+.SH DESCRIPTION
+The \fBgetch\fR, \fBwgetch\fR, \fBmvgetch\fR and \fBmvwgetch\fR, routines read
+a character from the window. In no-delay mode, if no input is waiting, the
+value \fBERR\fR is returned. In delay mode, the program waits until the system
+passes text through to the program. Depending on the setting of \fBcbreak\fR,
+this is after one character (cbreak mode), or after the first newline (nocbreak
+mode). In half-delay mode, the program waits until a character is typed or the
+specified timeout has been reached.
+
+If \fBnoecho\fR has been set, then the character will also be echoed into the
+designated window according to the following rules:
+If the character is the current erase character, left arrow, or backspace,
+the cursor is moved one space to the left and that screen position is erased
+as if \fBdelch\fR had been called.
+If the character value is any other \fBKEY_\fR define, the user is alerted
+with a \fBbeep\fR call.
+Otherwise the character is simply output to the screen.
+
+If the window is not a pad, and it has been moved or modified since the last
+call to \fBwrefresh\fR, \fBwrefresh\fR will be called before another character
+is read.
+
+If \fBkeypad\fR is \fBTRUE\fR, and a function key is pressed, the token for
+that function key is returned instead of the raw characters. Possible function
+keys are defined in \fB<curses.h>\fR as macros with values outside the range
+of 8-bit characters whose names begin with \fBKEY_.\fR Thus, a variable
+intended to hold the return value of a function key must be of short size or
+larger.
+
+When a character that could be the beginning of a function key is received
+(which, on modern terminals, means an escape character), \fBcurses\fR sets a
+timer. If the remainder of the sequence does not come in within the designated
+time, the character is passed through; otherwise, the function key value is
+returned. For this reason, many terminals experience a delay between the time
+a user presses the escape key and the escape is returned to the program.
+
+The \fBungetch\fR routine places \fIch\fR back onto the input queue to be
+returned by the next call to \fBwgetch\fR. Note that there is, in effect,
+just one input queue for all windows.
+
+.SS Function Keys
+The following function keys, defined in \fB<curses.h>\fR, might be returned by
+\fBgetch\fR if \fBkeypad\fR has been enabled. Note that not all of these are
+necessarily supported on any particular terminal.
+.nf
+__________________________________________________________________
+\fIName\fR \fIKey\fR \fIname\fR
+__________________________________________________________________
+KEY_BREAK Break key
+KEY_DOWN The four arrow keys ...
+KEY_UP
+KEY_LEFT
+KEY_RIGHT
+KEY_HOME Home key (upward+left arrow)
+KEY_BACKSPACE Backspace
+KEY_F0 Function keys; space for 64 keys is reserved.
+KEY_F(\fIn\fR) For 0 \fI<\fR \fIn\fR \fI<\fR 63
+KEY_DL Delete line
+KEY_IL Insert line
+KEY_DC Delete character
+KEY_IC Insert char or enter insert mode
+KEY_EIC Exit insert char mode
+KEY_CLEAR Clear screen
+KEY_EOS Clear to end of screen
+KEY_EOL Clear to end of line
+KEY_SF Scroll 1 line forward
+KEY_SR Scroll 1 line backward (reverse)
+KEY_NPAGE Next page
+KEY_PPAGE Previous page
+KEY_STAB Set tab
+KEY_CTAB Clear tab
+KEY_CATAB Clear all tabs
+KEY_ENTER Enter or send
+KEY_SRESET Soft (partial) reset
+KEY_RESET Reset or hard reset
+KEY_PRINT Print or copy
+KEY_LL Home down or bottom (lower left). Keypad is
+ arranged like this:
+ \fBA1\fR \fBup\fR \fBA3\fR
+ \fBleft\fR \fBB2\fR \fBright\fR
+ \fBC1\fR \fBdown\fR \fBC3\fR
+KEY_A1 Upper left of keypad
+KEY_A3 Upper right of keypad
+KEY_B2 Center of keypad
+KEY_C1 Lower left of keypad
+KEY_C3 Lower right of keypad
+KEY_BTAB Back tab key
+KEY_BEG Beg(inning) key
+KEY_CANCEL Cancel key
+KEY_CLOSE Close key
+KEY_COMMAND Cmd (command) key
+KEY_COPY Copy key
+KEY_CREATE Create key
+KEY_END End key
+KEY_EXIT Exit key
+KEY_FIND Find key
+KEY_HELP Help key
+KEY_MARK Mark key
+KEY_MESSAGE Message key
+KEY_MOVE Move key
+KEY_NEXT Next object key
+KEY_OPEN Open key
+KEY_OPTIONS Options key
+KEY_PREVIOUS Previous object key
+KEY_REDO Redo key
+KEY_REFERENCE Ref(erence) key
+KEY_REFRESH Refresh key
+KEY_REPLACE Replace key
+KEY_RESTART Restart key
+KEY_RESUME Resume key
+KEY_SAVE Save key
+KEY_SBEG Shifted beginning key
+KEY_SCANCEL Shifted cancel key
+KEY_SCOMMAND Shifted command key
+KEY_SCOPY Shifted copy key
+KEY_SCREATE Shifted create key
+KEY_SDC Shifted delete char key
+KEY_SDL Shifted delete line key
+KEY_SELECT Select key
+KEY_SEND Shifted end key
+KEY_SEOL Shifted clear line key
+KEY_SEXIT Shifted exit key
+KEY_SFIND Shifted find key
+KEY_SHELP Shifted help key
+KEY_SHOME Shifted home key
+KEY_SIC Shifted input key
+KEY_SLEFT Shifted left arrow key
+KEY_SMESSAGE Shifted message key
+KEY_SMOVE Shifted move key
+KEY_SNEXT Shifted next key
+KEY_SOPTIONS Shifted options key
+KEY_SPREVIOUS Shifted prev key
+KEY_SPRINT Shifted print key
+KEY_SREDO Shifted redo key
+KEY_SREPLACE Shifted replace key
+KEY_SRIGHT Shifted right arrow
+KEY_SRSUME Shifted resume key
+KEY_SSAVE Shifted save key
+KEY_SSUSPEND Shifted suspend key
+KEY_SUNDO Shifted undo key
+KEY_SUSPEND Suspend key
+KEY_UNDO Undo key
+.fi
+
+.SH RETURN VALUE
+All routines return the integer \fBERR\fR upon failure and an integer value
+other than \fBERR\fR" (\fBOK\fR in the case of ungetch()) upon successful
+completion.
+.SH NOTES
+Use of the escape key by a programmer for a single character function is
+discouraged, as it will cause a delay of up to one second while the
+keypad code looks for a following function-key sequence.
+
+When using \fBgetch\fR, \fBwgetch\fR, \fBmvgetch\fR, or
+\fBmvwgetch\fR, nocbreak mode (\fBnocbreak\fR) and echo mode
+(\fBecho\fR) should not be used at the same time. Depending on the
+state of the tty driver when each character is typed, the program may
+produce undesirable results.
+
+Note that \fBgetch\fR, \fBmvgetch\fR, and \fBmvwgetch\fR may be macros.
+
+Historically, the set of keypad macros was largely defined by the extremely
+function-key-rich keyboard of the AT&T 7300, aka 3B1, aka Safari 4. Modern
+personal computers usually have only a small subset of these. IBM PC-style
+consoles typically support little more than \fBKEY_UP\fR, \fBKEY_DOWN\fR,
+\fBKEY_LEFT\fR, \fBKEY_RIGHT\fR, \fBKEY_HOME\fR, \fBKEY_END\fR,
+\fBKEY_NPAGE\fR, \fBKEY_PPAGE\fR, and function keys 1 through 12. The Ins key
+is usually mapped to \fBKEY_IC\fR.
+.SH PORTABILITY
+These functions are described in the XSI Curses standard, Issue 4. They read
+single-byte characters only. The standard specifies that they return \fBERR\fR
+on failure, but specifies no error conditions.
+
+The echo behavior of these functions on input of \fBKEY_\fR or backspace
+characters was not specified. This description is adopted from the XSI
+Curses standard.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_inopts\fR(3X), \fBcurs_move\fR(3X),
+\fBcurs_refresh\fR(3X).
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_getstr.3 b/lib/libcurses/curs_getstr.3
new file mode 100644
index 00000000000..95845739807
--- /dev/null
+++ b/lib/libcurses/curs_getstr.3
@@ -0,0 +1,66 @@
+.TH curs_getstr 3X ""
+.SH NAME
+\fBgetstr\fR, \fBwgetstr\fR, \fBmvgetstr\fR,
+\fBmvwgetstr\fR, \fBwgetnstr\fR - accept character strings from
+\fBcurses\fR terminal keyboard
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint getstr(char *str);\fR
+.br
+\fBint wgetstr(WINDOW *win, char *str);\fR
+.br
+\fBint mvgetstr(int y, int x, char *str);\fR
+.br
+\fBint mvwgetstr(WINDOW *win, int y, int x, char *str);\fR
+.br
+\fBint wgetnstr(WINDOW *win, char *str, int n);\fR
+.br
+.SH DESCRIPTION
+The function \fBgetstr\fR is equivalent to a series of calls to \fBgetch\fR,
+until a newline or carriage return is received (the terminating character is
+not included in the returned string). The resulting value is placed in the
+area pointed to by the character pointer \fIstr\fR.
+
+\fBwgetnstr\fR reads at most \fIn\fR characters, thus preventing a possible
+overflow of the input buffer. Any attempt to enter more characters (other
+than the terminating newline or carriage return) causes a beep. Function
+keys also cause a beep and are ignored.
+
+The user's erase and kill characters are interpreted. If keypad
+mode is on for the window, \fBKEY_LEFT\fR and \fBKEY_BACKSPACE\fR
+are both considered equivalent to the user's kill character.
+
+Characters input are echoed only if \fBecho\fR is currently on. In that case,
+backspace is echoed as deletion of the previous character (typically a left
+motion).
+.SH RETURN VALUE
+All routines return the integer \fBERR\fR upon failure and an \fBOK\fR (SVr4
+specifies only "an integer value other than \fBERR\fR") upon successful
+completion.
+.SH NOTES
+Note that \fBgetstr\fR, \fBmvgetstr\fR, and \fBmvwgetstr\fR may be macros.
+.SH PORTABILITY
+These functions are described in the XSI Curses standard, Issue 4. They read
+single-byte characters only. The standard specifies that they return \fBERR\fR
+on failure, but the single error condition \fBEOVERFLOW\fR associated with
+extended-level conformance is not yet returned (the XSI curses support for
+multi-byte characters is not yet present).
+
+SVr3 and early SVr4 curses implementations did not reject function keys;
+the SVr4.0 documentation claimed that "special keys" (such as function
+keys, "home" key, "clear" key, \fIetc\fR.) are interpreted" without
+giving details. It lied. In fact, the `character' value appended to the
+string by those implementations was predictable but not useful
+(being, in fact, the low-order eight bits of the key's KEY_ value).
+
+The functions \fBgetnstr\fR, \fBmvgetnstr\fR, and \fBmvwgetnstr\fR were
+present but not documented in SVr4.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_getch\fR(3X).
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_getyx.3 b/lib/libcurses/curs_getyx.3
new file mode 100644
index 00000000000..58a3a52e8eb
--- /dev/null
+++ b/lib/libcurses/curs_getyx.3
@@ -0,0 +1,43 @@
+.TH curs_getyx 3X ""
+.SH NAME
+\fBgetyx\fR, \fBgetparyx\fR, \fBgetbegyx\fR,
+\fBgetmaxyx\fR - get \fBcurses\fR cursor and window coordinates
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBvoid getyx(WINDOW *win, int y, int x);\fR
+.br
+\fBvoid getparyx(WINDOW *win, int y, int x);\fR
+.br
+\fBvoid getbegyx(WINDOW *win, int y, int x);\fR
+.br
+\fBvoid getmaxyx(WINDOW *win, int y, int x);\fR
+.br
+.SH DESCRIPTION
+The \fBgetyx\fR macro places the current cursor position of the given window in
+the two integer variables \fIy\fR and \fIx\fR.
+
+If \fIwin\fR is a subwindow, the \fBgetparyx\fR macro places the beginning
+coordinates of the subwindow relative to the parent window into two integer
+variables \fIy\fR and \fIx\fR. Otherwise, \fB-1\fR is placed into \fIy\fR and
+\fIx\fR.
+
+Like \fBgetyx\fR, the \fBgetbegyx\fR and \fBgetmaxyx\fR macros store
+the current beginning coordinates and size of the specified window.
+.SH RETURN VALUE
+The return values of these macros are undefined (\fIi\fR.\fIe\fR.,
+they should not be used as the right-hand side of assignment
+statements).
+.SH NOTES
+All of these interfaces are macros and that "\fB&\fR" is not
+necessary before the variables \fIy\fR and \fIx\fR.
+.SH PORTABILITY
+These functions are described in the XSI Curses standard, Issue 4.
+.SH SEE ALSO
+\fBcurses\fR(3X)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_inch.3 b/lib/libcurses/curs_inch.3
new file mode 100644
index 00000000000..688a12c415a
--- /dev/null
+++ b/lib/libcurses/curs_inch.3
@@ -0,0 +1,42 @@
+.TH curs_inch 3X ""
+.SH NAME
+\fBinch\fR, \fBwinch\fR, \fBmvinch\fR, \fBmvwinch\fR
+- get a character and attributes from a \fBcurses\fR window
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBchtype inch(void);\fR
+.br
+\fBchtype winch(WINDOW *win);\fR
+.br
+\fBchtype mvinch(int y, int x);\fR
+.br
+\fBchtype mvwinch(WINDOW *win, int y, int x);\fR
+.br
+.SH DESCRIPTION
+These routines return the character, of type \fBchtype\fR, at the current
+position in the named window. If any attributes are set for that position,
+their values are OR-ed into the value returned. Constants defined in
+\fB<curses.h>\fR can be used with the \fB&\fR (logical AND) operator to
+extract the character or attributes alone.
+
+.SS Attributes
+The following bit-masks may be AND-ed with characters returned by \fBwinch\fR.
+
+.nf
+\fBA_CHARTEXT\fR Bit-mask to extract character
+\fBA_ATTRIBUTES\fR Bit-mask to extract attributes
+\fBA_COLOR\fR Bit-mask to extract color-pair field information
+.fi
+.SH NOTES
+Note that all of these routines may be macros.
+.SH PORTABILITY
+These functions are described in the XSI Curses standard, Issue 4.
+.SH SEE ALSO
+\fBcurses\fR(3X).
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_inchstr.3 b/lib/libcurses/curs_inchstr.3
new file mode 100644
index 00000000000..75c02b2fdb5
--- /dev/null
+++ b/lib/libcurses/curs_inchstr.3
@@ -0,0 +1,55 @@
+.TH curs_inchstr 3X ""
+.SH NAME
+\fBinchstr\fR, \fBinchnstr\fR, \fBwinchstr\fR,
+\fBwinchnstr\fR, \fBmvinchstr\fR, \fBmvinchnstr\fR, \fBmvwinchstr\fR,
+\fBmvwinchnstr\fR - get a string of characters (and attributes) from a
+\fBcurses\fR window
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint inchstr(chtype *chstr);\fR
+.br
+\fBint inchnstr(chtype *chstr, int n);\fR
+.br
+\fBint winchstr(WINDOW *win, chtype *chstr);\fR
+.br
+\fBint winchnstr(WINDOW *win, chtype *chstr, int n);\fR
+.br
+\fBint mvinchstr(int y, int x, chtype *chstr);\fR
+.br
+\fBint mvinchnstr(int y, int x, chtype *chstr, int n);\fR
+.br
+\fBint mvwinchstr(WINDOW *win, int y, int x, chtype *chstr);\fR
+.br
+\fBint mvwinchnstr(WINDOW *win, int y, int x, chtype *chstr, int n);\fR
+.br
+.SH DESCRIPTION
+These routines return a NULL-terminated array of \fBchtype\fR quantities,
+starting at the current cursor position in the named window and ending at the
+right margin of the window. The four functions with \fIn\fR as
+the last argument, return a leading substring at most \fIn\fR characters long
+(exclusive of the trailing (chtype)0).
+Constants defined in \fB<curses.h>\fR can be used with the \fB&\fR (logical
+AND) operator to extract the character or the attribute alone from any position
+in the \fIchstr\fR [see curs_inch(3X)].
+.SH RETURN VALUE
+All routines return the integer \fBERR\fR upon failure and an integer value
+other than \fBERR\fR upon successful completion (the number of characters
+retrieved, exclusive of the trailing 0).
+.SH NOTES
+Note that all routines except \fBwinchnstr\fR may be macros. SVr4 does not
+document whether the result string is 0-terminated; it does not document
+whether a length limit argument includes any trailing 0; and it does not
+document the meaning of the return value.
+.SH PORTABILITY
+These functions are described in the XSI Curses standard, Issue 4. It is no
+more specific than the SVr4 documentation on the trailing 0. It does specify
+that the successful return of the functions is \fBOK\fR.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_inch\fR(3X).
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_initscr.3 b/lib/libcurses/curs_initscr.3
new file mode 100644
index 00000000000..0ede098dc19
--- /dev/null
+++ b/lib/libcurses/curs_initscr.3
@@ -0,0 +1,87 @@
+.TH curs_initscr 3X ""
+.SH NAME
+\fBinitscr\fR, \fBnewterm\fR, \fBendwin\fR,
+\fBisendwin\fR, \fBset_term\fR, \fBdelscreen\fR - \fBcurses\fR screen
+initialization and manipulation routines
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBWINDOW *initscr(void);\fR
+.br
+\fBint endwin(void);\fR
+.br
+\fBint isendwin(void);\fR
+.br
+\fBSCREEN *newterm(const char *type, FILE *outfd, FILE *infd);\fR
+.br
+\fBSCREEN *set_term(SCREEN *new);\fR
+.br
+\fBvoid delscreen(SCREEN* sp);\fR
+.br
+.SH DESCRIPTION
+\fBinitscr\fR is normally the first \fBcurses\fR routine to call when
+initializing a program. A few special routines sometimes need to be
+called before it; these are \fBslk_init\fR, \fBfilter\fR, \fBripoffline\fR,
+\fBuse_env\fR. For multiple-terminal applications, \fBnewterm\fR may be
+called before \fBinitscr\fR.
+
+The initscr code determines the terminal type and initializes all \fBcurses\fR
+data structures. \fBinitscr\fR also causes the first call to \fBrefresh\fR to
+clear the screen. If errors occur, \fBinitscr\fR writes an appropriate error
+message to standard error and exits; otherwise, a pointer is returned to
+\fBstdscr\fR.
+
+A program that outputs to more than one terminal should use the \fBnewterm\fR
+routine for each terminal instead of \fBinitscr\fR. A program that needs to
+inspect capabilities, so it can continue to run in a line-oriented mode if the
+terminal cannot support a screen-oriented program, would also use
+\fBnewterm\fR. The routine \fBnewterm\fR should be called once for each
+terminal. It returns a variable of type \fBSCREEN *\fR which should be saved
+as a reference to that terminal. The arguments are the \fItype\fR of the
+terminal to be used in place of \fB$TERM\fR, a file pointer for output to the
+terminal, and another file pointer for input from the terminal (if \fItype\fR
+is \fBNULL\fR, \fB$TERM\fR will be used). The program must also call
+\fBendwin\fR for each terminal being used before exiting from \fBcurses\fR.
+If \fBnewterm\fR is called more than once for the same terminal, the first
+terminal referred to must be the last one for which \fBendwin\fR is called.
+
+A program should always call \fBendwin\fR before exiting or escaping from
+\fBcurses\fR mode temporarily. This routine restores tty modes, moves the
+cursor to the lower left-hand corner of the screen and resets the terminal into
+the proper non-visual mode. Calling \fBrefresh\fR or \fBdoupdate\fR after a
+temporary escape causes the program to resume visual mode.
+
+The \fBisendwin\fR routine returns \fBTRUE\fR if \fBendwin\fR has been
+called without any subsequent calls to \fBwrefresh\fR, and \fBFALSE\fR
+otherwise.
+
+The \fBset_term\fR routine is used to switch between different
+terminals. The screen reference \fBnew\fR becomes the new current
+terminal. The previous terminal is returned by the routine. This is
+the only routine which manipulates \fBSCREEN\fR pointers; all other
+routines affect only the current terminal.
+
+The \fBdelscreen\fR routine frees storage associated with the
+\fBSCREEN\fR data structure. The \fBendwin\fR routine does not do
+this, so \fBdelscreen\fR should be called after \fBendwin\fR if a
+particular \fBSCREEN\fR is no longer needed.
+.SH RETURN VALUE
+\fBendwin\fR returns the integer \fBERR\fR upon failure and \fBOK\fR
+upon successful completion.
+
+Routines that return pointers always return \fBNULL\fR on error.
+.SH NOTES
+Note that \fBinitscr\fR and \fBnewterm\fR may be macros.
+.SH PORTABILITY
+These functions are described in the XSI Curses standard, Issue 4. It
+specifies that portable applications must not call \fBinitscr\fR more than
+once.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_kernel\fR(3X), \fBcurs_refresh\fR(3X),
+\fBcurs_slk\fR(3X), \fBcurs_util\fR(3X)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_inopts.3 b/lib/libcurses/curs_inopts.3
new file mode 100644
index 00000000000..aa53b61e57a
--- /dev/null
+++ b/lib/libcurses/curs_inopts.3
@@ -0,0 +1,183 @@
+.TH curs_inopts 3X ""
+.SH NAME
+\fBcbreak\fR, \fBnocbreak\fR, \fBecho\fR,
+\fBnoecho\fR, \fBhalfdelay\fR, \fBintrflush\fR, \fBkeypad\fR,
+\fBmeta\fR, \fBnodelay\fR, \fBnotimeout\fR, \fBraw\fR, \fBnoraw\fR,
+\fBnoqiflush\fR, \fBqiflush\fR, \fBtimeout\fR, \fBwtimeout\fR,
+\fBtypeahead\fR - \fBcurses\fR input options
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint cbreak(void);\fR
+.br
+\fBint nocbreak(void);\fR
+.br
+\fBint echo(void);\fR
+.br
+\fBint noecho(void);\fR
+.br
+\fBint halfdelay(int tenths);\fR
+.br
+\fBint intrflush(WINDOW *win, bool bf);\fR
+.br
+\fBint keypad(WINDOW *win, bool bf);\fR
+.br
+\fBint meta(WINDOW *win, bool bf);\fR
+.br
+\fBint nodelay(WINDOW *win, bool bf);\fR
+.br
+\fBint raw(void);\fR
+.br
+\fBint noraw(void);\fR
+.br
+\fBvoid noqiflush(void);\fR
+.br
+\fBvoid qiflush(void);\fR
+.br
+\fBint notimeout(WINDOW *win, bool bf);\fR
+.br
+\fBvoid timeout(int delay);\fR
+.br
+\fBvoid wtimeout(WINDOW *win, int delay);\fR
+.br
+\fBint typeahead(int fd);\fR
+.br
+.SH DESCRIPTION
+Normally, the tty driver buffers typed characters until a newline or carriage
+return is typed. The \fBcbreak\fR routine disables line buffering and
+erase/kill character-processing (interrupt and flow control characters are
+unaffected), making characters typed by the user immediately available to the
+program. The \fBnocbreak\fR routine returns the terminal to normal (cooked)
+mode.
+
+Initially the terminal may or may not be in \fBcbreak\fR mode, as the mode is
+inherited; therefore, a program should call \fBcbreak\fR or \fBnocbreak\fR
+explicitly. Most interactive programs using \fBcurses\fR set the \fBcbreak\fR
+mode. Note that \fBcbreak\fR overrides \fBraw\fR. [See curs_getch(3X) for a
+discussion of how these routines interact with \fBecho\fR and \fBnoecho\fR.]
+
+The \fBecho\fR and \fBnoecho\fR routines control whether characters typed by
+the user are echoed by \fBgetch\fR as they are typed. Echoing by the tty
+driver is always disabled, but initially \fBgetch\fR is in echo mode, so
+characters typed are echoed. Authors of most interactive programs prefer to do
+their own echoing in a controlled area of the screen, or not to echo at all, so
+they disable echoing by calling \fBnoecho\fR. [See curs_getch(3X) for a
+discussion of how these routines interact with \fBcbreak\fR and
+\fBnocbreak\fR.]
+
+The \fBhalfdelay\fR routine is used for half-delay mode, which is similar to
+\fBcbreak\fR mode in that characters typed by the user are immediately
+available to the program. However, after blocking for \fItenths\fR tenths of
+seconds, ERR is returned if nothing has been typed. The value of \fBtenths\fR
+must be a number between 1 and 255. Use \fBnocbreak\fR to leave half-delay
+mode.
+
+If the \fBintrflush\fR option is enabled, (\fIbf\fR is \fBTRUE\fR), when an
+interrupt key is pressed on the keyboard (interrupt, break, quit) all output in
+the tty driver queue will be flushed, giving the effect of faster response to
+the interrupt, but causing \fBcurses\fR to have the wrong idea of what is on
+the screen. Disabling (\fIbf\fR is \fBFALSE\fR), the option prevents the
+flush. The default for the option is inherited from the tty driver settings.
+The window argument is ignored.
+
+The \fBkeypad\fR option enables the keypad of the user's terminal. If
+enabled (\fIbf\fR is \fBTRUE\fR), the user can press a function key
+(such as an arrow key) and \fBwgetch\fR returns a single value
+representing the function key, as in \fBKEY_LEFT\fR. If disabled
+(\fIbf\fR is \fBFALSE\fR), \fBcurses\fR does not treat function keys
+specially and the program has to interpret the escape sequences
+itself. If the keypad in the terminal can be turned on (made to
+transmit) and off (made to work locally), turning on this option
+causes the terminal keypad to be turned on when \fBwgetch\fR is
+called. The default value for keypad is false.
+
+Initially, whether the terminal returns 7 or 8 significant bits on
+input depends on the control mode of the tty driver [see termio(7)].
+To force 8 bits to be returned, invoke \fBmeta\fR(\fIwin\fR,
+\fBTRUE\fR); this is equivalent, under POSIX, to setting the CS8 flag
+on the terminal. To force 7 bits to be returned, invoke
+\fBmeta\fR(\fIwin\fR, \fBFALSE\fR); this is equivalent, under POSIX,
+to setting the CS8 flag on the terminal. The window argument,
+\fIwin\fR, is always ignored. If the terminfo capabilities \fBsmm\fR
+(meta_on) and \fBrmm\fR (meta_off) are defined for the terminal,
+\fBsmm\fR is sent to the terminal when \fBmeta\fR(\fIwin\fR,
+\fBTRUE\fR) is called and \fBrmm\fR is sent when \fBmeta\fR(\fIwin\fR,
+\fBFALSE\fR) is called.
+
+The \fBnodelay\fR option causes \fBgetch\fR to be a non-blocking call.
+If no input is ready, \fBgetch\fR returns \fBERR\fR. If disabled
+(\fIbf\fR is \fBFALSE\fR), \fBgetch\fR waits until a key is pressed.
+
+While interpreting an input escape sequence, \fBwgetch\fR sets a timer
+while waiting for the next character. If \fBnotimeout(\fR\fIwin\fR,
+\fBTRUE\fR) is called, then \fBwgetch\fR does not set a timer. The
+purpose of the timeout is to differentiate between sequences received
+from a function key and those typed by a user.
+
+The \fBraw\fR and \fBnoraw\fR routines place the terminal into or out of raw
+mode. Raw mode is similar to \fBcbreak\fR mode, in that characters typed are
+immediately passed through to the user program. The differences are that in
+raw mode, the interrupt, quit, suspend, and flow control characters are all
+passed through uninterpreted, instead of generating a signal. The behavior of
+the BREAK key depends on other bits in the tty driver that are not set by
+\fBcurses\fR.
+
+When the \fBnoqiflush\fR routine is used, normal flush of input and
+output queues associated with the \fBINTR\fR, \fBQUIT\fR and
+\fBSUSP\fR characters will not be done [see termio(7)]. When
+\fBqiflush\fR is called, the queues will be flushed when these control
+characters are read. You may want to call \fBnoqiflush()\fR in a signal
+handler if you want output to continue as though the interrupt
+had not occurred, after the handler exits.
+
+The \fBtimeout\fR and \fBwtimeout\fR routines set blocking or
+non-blocking read for a given window. If \fIdelay\fR is negative,
+blocking read is used (\fIi\fR.\fIe\fR., waits indefinitely for
+input). If \fIdelay\fR is zero, then non-blocking read is used
+(\fIi\fR.\fIe\fR., read returns \fBERR\fR if no input is waiting). If
+\fIdelay\fR is positive, then read blocks for \fIdelay\fR
+milliseconds, and returns \fBERR\fR if there is still no input.
+Hence, these routines provide the same functionality as \fBnodelay\fR,
+plus the additional capability of being able to block for only
+\fIdelay\fR milliseconds (where \fIdelay\fR is positive).
+
+The \fBcurses\fR library does ``line-breakout optimization'' by looking for
+typeahead periodically while updating the screen. If input is found,
+and it is coming from a tty, the current update is postponed until
+\fBrefresh\fR or \fBdoupdate\fR is called again. This allows faster
+response to commands typed in advance. Normally, the input FILE
+pointer passed to \fBnewterm\fR, or \fBstdin\fR in the case that
+\fBinitscr\fR was used, will be used to do this typeahead checking.
+The \fBtypeahead\fR routine specifies that the file descriptor
+\fIfd\fR is to be used to check for typeahead instead. If \fIfd\fR is
+-1, then no typeahead checking is done.
+.SH RETURN VALUE
+All routines that return an integer return \fBERR\fR upon failure and OK (SVr4
+specifies only "an integer value other than \fBERR\fR") upon successful
+completion, unless otherwise noted in the preceding routine descriptions.
+.SH PORTABILITY
+These functions are described in the XSI Curses standard, Issue 4.
+
+The curses library obeys the XPG4 standard and the historical practice of the
+AT&T curses implementations, in that the echo bit is cleared when curses
+initializes the terminal state. BSD curses differed from this slightly; it
+left the echo bit on at initialization, but the BSD \fBraw\fR call turned it
+off as a side-effect. For best portability, set echo or noecho explicitly
+just after initialization, even if your program remains in cooked mode.
+.SH NOTES
+Note that \fBecho\fR, \fBnoecho\fR, \fBhalfdelay\fR, \fBintrflush\fR,
+\fBmeta\fR, \fBnodelay\fR, \fBnotimeout\fR, \fBnoqiflush\fR,
+\fBqiflush\fR, \fBtimeout\fR, and \fBwtimeout\fR may be macros.
+
+The \fBnoraw\fR and \fBnocbreak\fR calls follow historical practice in that
+they attempt to restore to normal (`cooked') mode from raw and cbreak modes
+respectively. Mixing raw/noraw and cbreak/nocbreak calls leads to tty driver
+control states that are hard to predict or understand; it is not recommended.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_getch\fR(3X), \fBcurs_initscr\fR(3X), \fBtermio\fR(7)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_insch.3 b/lib/libcurses/curs_insch.3
new file mode 100644
index 00000000000..11f49053095
--- /dev/null
+++ b/lib/libcurses/curs_insch.3
@@ -0,0 +1,39 @@
+.TH curs_insch 3X ""
+.SH NAME
+\fBinsch\fR, \fBwinsch\fR, \fBmvinsch\fR, \fBmvwinsch\fR -
+insert a character before cursor in a \fBcurses\fR window
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint insch(chtype ch);\fR
+.br
+\fBint winsch(WINDOW *win, chtype ch);\fR
+.br
+\fBint mvinsch(int y, int x, chtype ch);\fR
+.br
+\fBint mvwinsch(WINDOW *win, int y, int x, chtype ch);\fR
+.br
+.SH DESCRIPTION
+These routines, insert the character \fIch\fR before the character under the
+cursor. All characters to the right of the cursor are moved one space to the
+right, with the possibility of the rightmost character on the line being lost.
+The insertion operation does not change the cursor position.
+.SH RETURN VALUE
+All routines that return an integer return \fBERR\fR upon failure and OK (SVr4
+specifies only "an integer value other than \fBERR\fR") upon successful
+completion, unless otherwise noted in the preceding routine descriptions.
+.SH NOTES
+These routines do not necessarily imply use of a hardware insert character
+feature.
+
+Note that \fBinsch\fR, \fBmvinsch\fR, and \fBmvwinsch\fR may be macros.
+.SH PORTABILITY
+These functions are described in the XSI Curses standard, Issue 4.
+.SH SEE ALSO
+\fBcurses\fR(3X).
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_insstr.3 b/lib/libcurses/curs_insstr.3
new file mode 100644
index 00000000000..965c16fd4d4
--- /dev/null
+++ b/lib/libcurses/curs_insstr.3
@@ -0,0 +1,61 @@
+.TH curs_insstr 3X ""
+.SH NAME
+\fBinsstr\fR, \fBinsnstr\fR, \fBwinsstr\fR, \fBwinsnstr\fR,
+\fBmvinsstr\fR, \fBmvinsnstr\fR, \fBmvwinsstr\fR, \fBmvwinsnstr\fR - insert
+string before cursor in a \fBcurses\fR window
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+.br
+\fBint insstr(const char *str);\fR
+.br
+\fBint insnstr(const char *str, int n);\fR
+.br
+\fBint winsstr(WINDOW *win, const char *str);\fR
+.br
+\fBint winsnstr(WINDOW *win, const char *str, int n);\fR
+.br
+\fBint mvinsstr(int y, int x, const char *str);\fR
+.br
+\fBint mvinsnstr(int y, int x, const char *str, int n);\fR
+.br
+\fBint mvwinsstr(WINDOW *win, int y, int x, const char *str);\fR
+.br
+\fBint mvwinsnstr(WINDOW *win, int y, int x, const char *str, int n);\fR
+.br
+.SH DESCRIPTION
+These routines insert a character string (as many characters as will fit on the
+line) before the character under the cursor. All characters to the right of
+the cursor are shifted right, with the possibility of the rightmost characters
+on the line being lost. The cursor position does not change (after moving to
+\fIy\fR, \fIx\fR, if specified). The four routines with \fIn\fR as the last
+argument insert a leading substring of at most \fIn\fR characters. If
+\fIn\fR<=0, then the entire string is inserted.
+
+If a character in \fIstr\fR is a tab, newline, carriage return or
+backspace, the cursor is moved appropriately within the window. A
+newline also does a \fBclrtoeol\fR before moving. Tabs are considered
+to be at every eighth column. If a character in \fIstr\fR is another
+control character, it is drawn in the \fB^\fR\fIX\fR notation.
+Calling \fBwinch\fR after adding a control character (and moving to
+it, if necessary) does not return the control character, but instead
+returns a character in the the ^-representation of the control character.
+.SH RETURN VALUE
+All routines that return an integer return \fBERR\fR upon failure and OK (SVr4
+specifies only "an integer value other than \fBERR\fR") upon successful
+completion, unless otherwise noted in the preceding routine descriptions.
+.SH NOTES
+Note that all but \fBwinsnstr\fR may be macros.
+.SH PORTABILITY
+These functions are described in the XSI Curses standard, Issue 4, which adds
+const qualifiers to the arguments. The XSI Curses error conditions
+\fBEILSEQ\fR and \fBEILOVERFLOW\fR associated with extended-level conformance
+are not yet detected (this implementation does not yet support XPG4 multibyte
+characters).
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_clear\fR(3X), \fBcurs_inch\fR(3X).
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_instr.3 b/lib/libcurses/curs_instr.3
new file mode 100644
index 00000000000..e7c681664a5
--- /dev/null
+++ b/lib/libcurses/curs_instr.3
@@ -0,0 +1,53 @@
+.TH curs_instr 3X ""
+.SH NAME
+\fBinstr\fR, \fBinnstr\fR, \fBwinstr\fR, \fBwinnstr\fR,
+\fBmvinstr\fR, \fBmvinnstr\fR, \fBmvwinstr\fR, \fBmvwinnstr\fR - get a string
+of characters from a \fBcurses\fR window
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint instr(char *str);\fR
+.br
+\fBint innstr(char *str, int n);\fR
+.br
+\fBint winstr(WINDOW *win, char *str);\fR
+.br
+\fBint winnstr(WINDOW *win, char *str, int n);\fR
+.br
+\fBint mvinstr(int y, int x, char *str);\fR
+.br
+\fBint mvinnstr(int y, int x, char *str, int n);\fR
+.br
+\fBint mvwinstr(WINDOW *win, int y, int x, char *str);\fR
+.br
+\fBint mvwinnstr(WINDOW *win, int y, int x, char *str, int n);\fR
+.br
+.SH DESCRIPTION
+These routines return a string of characters in \fIstr\fR, extracted starting
+at the current cursor position in the named window and ending at the right
+margin of the window. Attributes are stripped from the characters. The four
+functions with \fIn\fR as the last argument return a leading substring at most
+\fIn\fR characters long (exclusive of the trailing NUL).
+.SH RETURN VALUE
+All routines that return an integer return \fBERR\fR upon failure and OK (SVr4
+specifies only "an integer value other than \fBERR\fR") upon successful
+completion, unless otherwise noted in the preceding routine descriptions.
+.SH NOTES
+Note that all routines except \fBwinnstr\fR may be macros. SVr4 does not
+document whether a length limit includes or excludes the trailing NUL, and
+does not document the meaning of the return values.
+.SH PORTABILITY
+These functions are described in the XSI Curses standard, Issue 4. The
+standard specifies that they always return \fBOK\fR on success. The XSI Curses
+error conditions \fBEILSEQ\fR and \fBEILOVERFLOW\fR associated with
+extebded-level conformance are not yet detected (this implementation does not
+yet support XPG4 multibyte characters).
+.SH SEE ALSO
+\fBcurses\fR(3X).
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
+
diff --git a/lib/libcurses/curs_kernel.3 b/lib/libcurses/curs_kernel.3
new file mode 100644
index 00000000000..7fda81b2560
--- /dev/null
+++ b/lib/libcurses/curs_kernel.3
@@ -0,0 +1,123 @@
+.TH curs_kernel 3X ""
+.SH NAME
+\fBdef_prog_mode\fR, \fBdef_shell_mode\fR,
+\fBreset_prog_mode\fR, \fBreset_shell_mode\fR, \fBresetty\fR,
+\fBsavetty\fR, \fBgetsyx\fR, \fBsetsyx\fR, \fBripoffline\fR,
+\fBcurs_set\fR, \fBnapms\fR - low-level \fBxscurses\fR routines
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint def_prog_mode(void);\fR
+.br
+\fBint def_shell_mode(void);\fR
+.br
+\fBint reset_prog_mode(void);\fR
+.br
+\fBint reset_shell_mode(void);\fR
+.br
+\fBint resetty(void);\fR
+.br
+\fBint savetty(void);\fR
+.br
+\fBvoid getsyx(int y, int x);\fR
+.br
+\fBvoid setsyx(int y, int x);\fR
+.br
+\fBint ripoffline(int line, int (*init)(WINDOW *, int));\fR
+.br
+\fBint curs_set(int visibility);\fR
+.br
+\fBint napms(unsigned int ms);\fR
+.br
+.SH DESCRIPTION
+The following routines give low-level access to various \fBcurses\fR
+capabilities. Theses routines typically are used inside library
+routines.
+
+The \fBdef_prog_mode\fR and \fBdef_shell_mode\fR routines save the
+current terminal modes as the "program" (in \fBcurses\fR) or "shell"
+(not in \fBcurses\fR) state for use by the \fBreset_prog_mode\fR and
+\fBreset_shell_mode\fR routines. This is done automatically by
+\fBinitscr\fR. There is one such save area for each screen context
+allocated by \fBnewterm()\fR.
+
+The \fBreset_prog_mode\fR and \fBreset_shell_mode\fR routines restore
+the terminal to "program" (in \fBcurses\fR) or "shell" (out of
+\fBcurses\fR) state. These are done automatically by \fBendwin\fR
+and, after an \fBendwin\fR, by \fBdoupdate\fR, so they normally are
+not called.
+
+The \fBresetty\fR and \fBsavetty\fR routines save and restore the
+state of the terminal modes. \fBsavetty\fR saves the current state in
+a buffer and \fBresetty\fR restores the state to what it was at the
+last call to \fBsavetty\fR.
+
+The \fBgetsyx\fR routine returns the current coordinates of the virtual screen
+cursor in \fIy\fR and \fIx\fR. If \fBleaveok\fR is currently \fBTRUE\fR, then
+\fB-1\fR,\fB-1\fR is returned. If lines have been removed from the top of the
+screen, using \fBripoffline\fR, \fIy\fR and \fIx\fR include these lines;
+therefore, \fIy\fR and \fIx\fR should be used only as arguments for
+\fBsetsyx\fR.
+
+The \fBsetsyx\fR routine sets the virtual screen cursor to
+\fIy\fR, \fIx\fR. If \fIy\fR and \fIx\fR are both \fB-1\fR, then
+\fBleaveok\fR is set. The two routines \fBgetsyx\fR and \fBsetsyx\fR
+are designed to be used by a library routine, which manipulates
+\fBcurses\fR windows but does not want to change the current position
+of the program's cursor. The library routine would call \fBgetsyx\fR
+at the beginning, do its manipulation of its own windows, do a
+\fBwnoutrefresh\fR on its windows, call \fBsetsyx\fR, and then call
+\fBdoupdate\fR.
+
+The \fBripoffline\fR routine provides access to the same facility that
+\fBslk_init\fR [see curs_slk(3X)] uses to reduce the size of the
+screen. \fBripoffline\fR must be called before \fBinitscr\fR or
+\fBnewterm\fR is called. If \fIline\fR is positive, a line is removed
+from the top of \fBstdscr\fR; if \fIline\fR is negative, a line is
+removed from the bottom. When this is done inside \fBinitscr\fR, the
+routine \fBinit\fR (supplied by the user) is called with two
+arguments: a window pointer to the one-line window that has been
+allocated and an integer with the number of columns in the window.
+Inside this initialization routine, the integer variables \fBLINES\fR
+and \fBCOLS\fR (defined in \fB<curses.h>\fR) are not guaranteed to be
+accurate and \fBwrefresh\fR or \fBdoupdate\fR must not be called. It
+is allowable to call \fBwnoutrefresh\fR during the initialization
+routine.
+
+\fBripoffline\fR can be called up to five times before calling \fBinitscr\fR or
+\fBnewterm\fR.
+
+The \fBcurs_set\fR routine sets the cursor state is set to invisible,
+normal, or very visible for \fBvisibility\fR equal to \fB0\fR,
+\fB1\fR, or \fB2\fR respectively. If the terminal supports the
+\fIvisibility\fR requested, the previous \fIcursor\fR state is
+returned; otherwise, \fBERR\fR is returned.
+
+The \fBnapms\fR routine is used to sleep for \fIms\fR milliseconds.
+.SH RETURN VALUE
+Except for \fBcurs_set\fR, these routines always return \fBOK\fR.
+\fBcurs_set\fR returns the previous cursor state, or \fBERR\fR if the
+requested \fIvisibility\fR is not supported.
+.SH NOTES
+Note that \fBgetsyx\fR is a macro, so \fB&\fR is not necessary before
+the variables \fIy\fR and \fIx\fR.
+
+The SVr4 man pages warn that the return value of \fBcurs_set\fR "is currently
+incorrect". This implementation gets it right, but it may be unwise to count
+on the correctness of the return value anywhere else.
+.SH PORTABILITY
+The functions \fBsetsyx\fR and \fBgetsyx\fR are not described in the XSI
+Curses standard, Issue 4. All other functions are as described in XSI Curses.
+
+The SVr4 documentation describes \fBsetsyx\fR and \fBgetsyx\fR as having return
+type int. This is misleading, as they are macros with no documented semantics
+for the return value.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_initscr\fR(3X), \fBcurs_outopts\fR(3X), \fBcurs_refresh\fR(3X),
+\fBcurs_scr_dump\fR(3X), \fBcurs_slk\fR(3X)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_mouse.3 b/lib/libcurses/curs_mouse.3
new file mode 100644
index 00000000000..4781f99bed8
--- /dev/null
+++ b/lib/libcurses/curs_mouse.3
@@ -0,0 +1,151 @@
+'\" t
+.TH curs_mouse 3X ""
+.SH NAME
+\fBgetmouse\fR, \fBungetmouse\fR,
+\fBmousemask\fR - mouse interface through curses
+.SH SYNOPSIS
+.nf
+\fB#include <curses.h>\fR
+
+\fBtypedef unsigned long mmask_t;
+
+typedef struct
+{
+ short id; \fI/* ID to distinguish multiple devices */\fB
+ int x, y, z; \fI/* event coordinates */\fB
+ mmask_t bstate; \fI/* button state bits */\fB
+}
+MEVENT;\fR
+.fi
+.br
+\fBint getmouse(MEVENT *event);\fR
+.br
+\fBint ungetmouse(MEVENT *event);\fR
+.br
+\fBmmask_t mousemask(mmask_t newmask, mmask_t *oldmask);\fR
+.br
+\fBbool wenclose(WINDOW *win, int y, int x)\fR
+.br
+\fBint mouseinterval(int erval)\fR
+.br
+.SH DESCRIPTION
+These functions provide an interface to mouse events from
+\fBcurses\fR(3x). Mouse events are represented by \fBKEY_MOUSE\fR
+pseudo-key values in the \fBwgetch\fR input stream.
+
+To make mouse events visible, use the \fBmousemask\fR function. This will set
+the mouse events to be reported. By default, no mouse events are reported.
+The function will return a mask to indicate which of the specified mouse events
+can be reported; on complete failure it returns 0. If oldmask is non-NULL,
+this function fills the indicated location with the previous value of the given
+window's mouse event mask.
+
+As a side effect, setting a zero mousemask may turn off the mouse pointer;
+setting a nonzero mask may turn it on. Whether this happens is
+device-dependent.
+
+Here are the mouse event type masks:
+
+.TS
+l l
+_ _
+l l.
+\fIName\fR \fIDescription\fR
+BUTTON1_PRESSED mouse button 1 down
+BUTTON1_RELEASED mouse button 1 up
+BUTTON1_CLICKED mouse button 1 clicked
+BUTTON1_DOUBLE_CLICKED mouse button 1 double clicked
+BUTTON1_TRIPLE_CLICKED mouse button 1 triple clicked
+BUTTON2_PRESSED mouse button 2 down
+BUTTON2_RELEASED mouse button 2 up
+BUTTON2_CLICKED mouse button 2 clicked
+BUTTON2_DOUBLE_CLICKED mouse button 2 double clicked
+BUTTON2_TRIPLE_CLICKED mouse button 2 triple clicked
+BUTTON3_PRESSED mouse button 3 down
+BUTTON3_RELEASED mouse button 3 up
+BUTTON3_CLICKED mouse button 3 clicked
+BUTTON3_DOUBLE_CLICKED mouse button 3 double clicked
+BUTTON3_TRIPLE_CLICKED mouse button 3 triple clicked
+BUTTON4_PRESSED mouse button 4 down
+BUTTON4_RELEASED mouse button 4 up
+BUTTON4_CLICKED mouse button 4 clicked
+BUTTON4_DOUBLE_CLICKED mouse button 4 double clicked
+BUTTON4_TRIPLE_CLICKED mouse button 4 triple clicked
+BUTTON_SHIFT shift was down during button state change
+BUTTON_CTRL control was down during button state change
+BUTTON_ALT alt was down during button state change
+ALL_MOUSE_EVENTS report all button state changes
+REPORT_MOUSE_POSITION report mouse movement
+.TE
+
+Once a class of mouse events have been made visible in a window,
+calling the \fBwgetch\fR function on that window may return
+\fBKEY_MOUSE\fR as an indicator that a mouse event has been queued.
+To read the event data and pop the event off the queue, call
+\fBgetmouse\fR. This function will return \fBOK\fR if a mouse event
+is actually visible in the given window, \fBERR\fR otherwise.
+When \fBgetmouse\fR returns \fBOK\fR, the data deposited as y and
+x in the event structure coordinates will be screen-relative character-cell
+coordinates. The returned state mask will have exactly one bit set to
+indicate the event type.
+
+The \fBungetmouse\fR function behaves analogously to \fBungetch\fR. It pushes
+a \fBKEY_MOUSE\fR event onto the input queue, and associates with that event
+the given state data and screen-relative character-cell coordinates.
+
+The \fBwenclose\fR function tests whether a given pair of screen-relative
+character-cell coordinates is enclosed by a given window, returning TRUE
+if it is and FALSE otherwise. It is useful for determining what subset of
+the screen windows enclose the location of a mouse event.
+
+The \fBmouseinterval\fR function sets the maximum time (in thousands of a
+second) that can elapse between press and release events in order for them to
+be recognized as a click. This function returns the previous interval value.
+The default is one fifth of a second.
+
+Note that mouse events will be ignored when input is in cooked mode, and will
+cause an error beep when cooked mode is being simulated in a window by a
+function such as \fBgetstr\fR that expects a linefeed for input-loop
+termination.
+
+.SH RETURN VALUE
+All routines return the integer \fBERR\fR upon failure or \fBOK\fR
+upon successful completion.
+.SH PORTABILITY
+These calls were designed for \fBcurses\fR(3x), and are not found in SVr4
+curses, 4.4BSD curses, or any other previous version of curses.
+
+The feature macro \fBNCURSES_MOUSE_VERSION\fR is provided so the preprocessor
+can be used to test whether these features are present (its value is 1). NOTE:
+THIS INTERFACE IS EXPERIMENTAL AND IS SUBJECT TO CHANGE WITHOUT NOTICE! If the
+interface is changed, the value of \fBNCURSES_MOUSE_VERSION\fR will be
+incremented.
+
+The order of the \fBMEVENT\fR structure members is not guaranteed.
+Additional fields may be added to the structure in the future.
+
+Under \fBcurses\fR(3x), these calls are implemented using either
+xterm's built-in mouse-tracking API or Alessandro Rubini's gpm server.
+If you are using something other than xterm there is no gpm daemon
+running on your machine, mouse events will not be visible to
+\fBcurses\fR(3x) (and the \fBwmousemask\fR function will always
+return \fB0\fR).
+
+The z member in the event structure is not presently used. It is intended
+for use with touchscreens (which may be pressure-sensitive) or with
+3D-mice/trackballs/power gloves.
+.SH BUGS
+Mouse events under xterm will not in fact be ignored during cooked mode,
+if they have been enabled by \fBwmousemask\fR. Instead, the xterm mouse
+report sequence will appear in the string read.
+
+Mouse events under xterm will not be detected correctly in a window with
+its keypad bit off.
+.SH SEE ALSO
+\fBcurses\fR(3X).
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_move.3 b/lib/libcurses/curs_move.3
new file mode 100644
index 00000000000..7d915ed2843
--- /dev/null
+++ b/lib/libcurses/curs_move.3
@@ -0,0 +1,34 @@
+.TH curs_move 3X ""
+.SH NAME
+\fBmove\fR, \fBwmove\fR - move \fBcurses\fR window cursor
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint move(int y, int x);\fR
+.br
+\fBint wmove(WINDOW *win, int y, int x);\fR
+.br
+.SH DESCRIPTION
+These routines move the cursor associated with the window to line \fIy\fR and
+column \fIx\fR. This routine does not move the physical cursor of the terminal
+until \fBrefresh\fR is called. The position specified is relative to the upper
+left-hand corner of the window, which is (0,0).
+.SH RETURN VALUE
+These routines return \fBERR\fR upon failure and OK (SVr4
+specifies only "an integer value other than \fBERR\fR") upon successful
+completion.
+.SH NOTES
+Note that \fBmove\fR may be a macro.
+.SH PORTABILITY
+These functions are described in the XSI Curses standard, Issue 4. The
+standard specifies that if (y,x) is within a multi-column character, the cursor
+is moved to the first column of that character; however, this implementation
+does not yet support the extended-level XSI multi-byte characters.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_refresh\fR(3X)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_outopts.3 b/lib/libcurses/curs_outopts.3
new file mode 100644
index 00000000000..e69383b4ad4
--- /dev/null
+++ b/lib/libcurses/curs_outopts.3
@@ -0,0 +1,134 @@
+.TH curs_outopts 3X ""
+.SH NAME
+\fBclearok\fR, \fBidlok\fR, \fBidcok immedok\fR,
+\fBleaveok\fR, \fBsetscrreg\fR, \fBwsetscrreg\fR, \fBscrollok\fR,
+\fBnl\fR, \fBnonl\fR - \fBcurses\fR output options
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint clearok(WINDOW *win, bool bf);\fR
+.br
+\fBint idlok(WINDOW *win, bool bf);\fR
+.br
+\fBvoid idcok(WINDOW *win, bool bf);\fR
+.br
+\fBvoid immedok(WINDOW *win, bool bf);\fR
+.br
+\fBint leaveok(WINDOW *win, bool bf);\fR
+.br
+\fBint setscrreg(int top, int bot);\fR
+.br
+\fBint wsetscrreg(WINDOW *win, int top, int bot);\fR
+.br
+\fBint scrollok(WINDOW *win, bool bf);\fR
+.br
+\fBint nl(void);\fR
+.br
+\fBint nonl(void);\fR
+.br
+.SH DESCRIPTION
+These routines set options that change the style of output within
+\fBcurses\fR. All options are initially \fBFALSE\fR, unless otherwise stated.
+It is not necessary to turn these options off before calling \fBendwin\fR.
+
+If \fBclearok\fR is called with \fBTRUE\fR as argument, the next
+call to \fBwrefresh\fR with this window will clear the screen completely and
+redraw the entire screen from scratch. This is useful when the contents of the
+screen are uncertain, or in some cases for a more pleasing visual effect. If
+the \fIwin\fR argument to \fBclearok\fR is the global variable \fBcurscr\fR,
+the next call to \fBwrefresh\fR with any window causes the screen to be cleared
+and repainted from scratch.
+
+If \fBidlok\fR is called with \fBTRUE\fR as argument,
+\fBcurses\fR considers using the hardware insert/delete line feature of
+terminals so equipped. If disabled (\fIbf\fR is \fBFALSE\fR), \fBcurses\fR
+very seldom uses this feature. (The insert/delete character feature is always
+considered.) This option should be enabled only if the application needs
+insert/delete line, for example, for a screen editor. It is disabled by
+default because insert/delete line tends to be visually annoying when used in
+applications where it isn't really needed. If insert/delete line cannot be
+used, \fBcurses\fR redraws the changed portions of all lines.
+
+If \fBidcok\fR is called with \fBTRUE\fR as argument,
+\fBcurses\fR considers using the hardware insert/delete character feature of
+terminals so equipped. This is enabled by default.
+
+If \fBimmedok\fR is called with \fBTRUE as argument\fR, any change
+in the window image, such as the ones caused by \fBwaddch, wclrtobot, wscrl\fR,
+\fIetc\fR., automatically cause a call to \fBwrefresh\fR. However, it may
+degrade the performance considerably, due to repeated calls to \fBwrefresh\fR.
+It is disabled by default.
+
+Normally, the hardware cursor is left at the location of the window cursor
+being refreshed. The \fBleaveok\fR option allows the cursor to be left
+wherever the update happens to leave it. It is useful for applications where
+the cursor is not used, since it reduces the need for cursor motions. If
+possible, the cursor is made invisible when this option is enabled.
+
+The \fBsetscrreg\fR and \fBwsetscrreg\fR routines allow the application
+programmer to set a software scrolling region in a window. \fItop\fR and
+\fIbot\fR are the line numbers of the top and bottom margin of the scrolling
+region. (Line 0 is the top line of the window.) If this option and
+\fBscrollok\fR are enabled, an attempt to move off the bottom margin line
+causes all lines in the scrolling region to scroll one line in the direction
+of the first line. Only the text of the window is scrolled. (Note that this
+has nothing to do with the use of a physical scrolling region capability in the
+terminal, like that in the VT100. If \fBidlok\fR is enabled and the terminal
+has either a scrolling region or insert/delete line capability, they will
+probably be used by the output routines.)
+
+The \fBscrollok\fR option controls what happens when the cursor of a window is
+moved off the edge of the window or scrolling region, either as a result of a
+newline action on the bottom line, or typing the last character of the last
+line. If disabled, (\fIbf\fR is \fBFALSE\fR), the cursor is left on the bottom
+line. If enabled, (\fIbf\fR is \fBTRUE\fR), the window is scrolled up one line
+(Note that in order to get the physical scrolling effect on the terminal, it is
+also necessary to call \fBidlok\fR).
+
+The \fBnl\fR and \fBnonl\fR routines control whether the underlying display
+device translates the return key into newline on input, and whether it
+translates newline into return and line-feed on output (in either case, the
+call \fBaddch('\n')\fR does the equivalent of return and line feed on the
+virtual screen). Initially, these translations do occur. If you disable them
+using \fBnonl\fR, \fBcurses\fR will be able to make better use of the line-feed
+capability, resulting in faster cursor motion. Also, \fBcurses\fR will then be
+able to detect the return key.
+.SH RETURN VALUE
+The functions \fBsetscrreg\fR and \fBwsetscrreg\fR return \fBOK\fR upon success
+and \fBERR\fR upon failure. All other routines that return an integer always
+return \fBOK\fR.
+.SH PORTABILITY
+These functions are described in the XSI Curses standard, Issue 4.
+
+The XSI Curses standard is ambiguous on the question of whether \fBraw\fR()
+should disable the CRLF translations controlled by \fBnl\fR() and \fBnonl\fR().
+BSD curses did turn off these translations; AT&T curses (at least as late as
+SVr1) did not. We choose to do so, on the theory that a programmer requesting
+raw input wants a clean (ideally 8-bit clean) connection that the operating
+system does not mess with.
+
+Some historic curses implementations had, as an undocumented feature, the
+ability to do the equivalent of \fBclearok(..., 1)\fR by saying
+\fBtouchwin(stdscr)\fR or \fBclear(stdscr)\fR. This will not work under
+curses.
+
+Earlier System V curses implementations specified that with \fBscrollok\fR
+enabled, any window modification triggering a scroll also forced a physical
+refresh. XSI Curses does not require this, and \fBcurses\fR avoids doing
+it in order to perform better vertical-motion optimization at \fBwrefresh\fR
+time.
+.SH NOTES
+Note that \fBclearok\fR, \fBleaveok\fR, \fBscrollok\fR, \fBidcok\fR, \fBnl\fR,
+\fBnonl\fR and \fBsetscrreg\fR may be macros.
+
+The \fBimmedok\fR routine is useful for windows that are used as terminal
+emulators.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_addch\fR(3X), \fBcurs_clear\fR(3X),
+\fBcurs_initscr\fR(3X), \fBcurs_scroll\fR(3X), \fBcurs_refresh\fR(3X)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_overlay.3 b/lib/libcurses/curs_overlay.3
new file mode 100644
index 00000000000..0c7b93df37f
--- /dev/null
+++ b/lib/libcurses/curs_overlay.3
@@ -0,0 +1,46 @@
+.TH curs_overlay 3X ""
+.SH NAME
+\fBoverlay\fR, \fBoverwrite\fR, \fBcopywin\fR - overlay and
+manipulate overlapped \fBcurses\fR windows
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint overlay(const WINDOW *srcwin, WINDOW *dstwin);\fR
+.br
+\fBint overwrite(const WINDOW *srcwin, WINDOW *dstwin);\fR
+.br
+\fBint copywin(WINDOW *srcwin, WINDOW *dstwin, int sminrow,
+ int smincol, int dminrow, int dmincol, int dmaxrow,
+ int dmaxcol, int overlay);\fR
+.SH DESCRIPTION
+The \fBoverlay\fR and \fBoverwrite\fR routines overlay \fIsrcwin\fR on
+top of \fIdstwin\fR. \fIscrwin\fR and \fIdstwin\fR are not required
+to be the same size; only text where the two windows overlap is
+copied. The difference is that \fBoverlay\fR is non-destructive
+(blanks are not copied) whereas \fBoverwrite\fR is destructive.
+
+The \fBcopywin\fR routine provides a finer granularity of control over the
+\fBoverlay\fR and \fBoverwrite\fR routines. Like in the \fBprefresh\fR
+routine, a rectangle is specified in the destination window, (\fIdminrow\fR,
+\fIdmincol\fR) and (\fIdmaxrow\fR, \fIdmaxcol\fR), and the upper-left-corner
+coordinates of the source window, (\fIsminrow\fR, \fIsmincol\fR). If the
+argument \fIoverlay\fR is \fBtrue\fR, then copying is non-destructive, as in
+\fBoverlay\fR.
+.SH RETURN VALUE
+Routines that return an integer return \fBERR\fR upon failure, and \fBOK\fR
+(SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
+completion.
+.SH NOTES
+Note that \fBoverlay\fR and \fBoverwrite\fR may be macros.
+.SH PORTABILITY
+The XSI Curses standard, Issue 4 describes these functions (adding the const
+qualifiers). It further specifies their behavior in the presence of characters
+with multi-byte renditions (not yet supported in this implementation).
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_pad\fR(3X), \fBcurs_refresh\fR(3X)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_pad.3 b/lib/libcurses/curs_pad.3
new file mode 100644
index 00000000000..18969c94e3e
--- /dev/null
+++ b/lib/libcurses/curs_pad.3
@@ -0,0 +1,82 @@
+.TH curs_pad 3X ""
+.SH NAME
+\fBnewpad\fR, \fBsubpad\fR, \fBprefresh\fR,
+\fBpnoutrefresh\fR, \fBpechochar\fR - create and display \fBcurses\fR
+pads
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBWINDOW *newpad(int nlines, int ncols);\fR
+.br
+\fBWINDOW *subpad(WINDOW *orig, int nlines, int ncols,
+ int begin_y, int begin_x);\fR
+.br
+\fBint prefresh(WINDOW *pad, int pminrow, int pmincol,
+ int sminrow, int smincol, int smaxrow, int smaxcol);\fR
+.br
+\fBint pnoutrefresh(WINDOW *pad, int pminrow, int pmincol,
+ int sminrow, int smincol, int smaxrow, int smaxcol);\fR
+.br
+\fBint pechochar(WINDOW *pad, chtype ch);\fR
+.SH DESCRIPTION
+The \fBnewpad\fR routine creates and returns a pointer to a new pad data
+structure with the given number of lines, \fInlines\fR, and columns,
+\fIncols\fR. A pad is like a window, except that it is not restricted by the
+screen size, and is not necessarily associated with a particular part of the
+screen. Pads can be used when a large window is needed, and only a part of the
+window will be on the screen at one time. Automatic refreshes of pads
+(\fIe\fR.\fIg\fR., from scrolling or echoing of input) do not occur. It is not
+legal to call \fBwrefresh\fR with a \fIpad\fR as an argument; the routines
+\fBprefresh\fR or \fBpnoutrefresh\fR should be called instead. Note that these
+routines require additional parameters to specify the part of the pad to be
+displayed and the location on the screen to be used for the display.
+
+The \fBsubpad\fR routine creates and returns a pointer to a subwindow within a
+pad with the given number of lines, \fInlines\fR, and columns, \fIncols\fR.
+Unlike \fBsubwin\fR, which uses screen coordinates, the window is at position
+(\fIbegin\fR_\fIx\fR\fB,\fR \fIbegin\fR_\fIy\fR) on the pad. The window is
+made in the middle of the window \fIorig\fR, so that changes made to one window
+affect both windows. During the use of this routine, it will often be
+necessary to call \fBtouchwin\fR or \fBtouchline\fR on \fIorig\fR before
+calling \fBprefresh\fR.
+
+The \fBprefresh\fR and \fBpnoutrefresh\fR routines are analogous to
+\fBwrefresh\fR and \fBwnoutrefresh\fR except that they relate to pads instead
+of windows. The additional parameters are needed to indicate what part of the
+pad and screen are involved. \fIpminrow\fR and \fIpmincol\fR specify the upper
+left-hand corner of the rectangle to be displayed in the pad. \fIsminrow\fR,
+\fIsmincol\fR, \fIsmaxrow\fR, and \fIsmaxcol\fR specify the edges of the
+rectangle to be displayed on the screen. The lower right-hand corner of the
+rectangle to be displayed in the pad is calculated from the screen coordinates,
+since the rectangles must be the same size. Both rectangles must be entirely
+contained within their respective structures. Negative values of
+\fIpminrow\fR, \fIpmincol\fR, \fIsminrow\fR, or \fIsmincol\fR are treated as if
+they were zero.
+
+The \fBpechochar\fR routine is functionally equivalent to a call to \fBaddch\fR
+followed by a call to \fBrefresh\fR, a call to \fBwaddch\fR followed by a call
+to \fBwrefresh\fR, or a call to \fBwaddch\fR followed by a call to
+\fBprefresh.\fR The knowledge that only a single character is being output is
+taken into consideration and, for non-control characters, a considerable
+performance gain might be seen by using these routines instead of their
+equivalents. In the case of \fBpechochar\fR, the last location of the pad on
+the screen is reused for the arguments to \fBprefresh\fR.
+.SH RETURN VALUE
+Routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
+(SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
+completion.
+
+Routines that return pointers return \fBNULL\fR on error, and set \fBerrno\fR
+to \fBENOMEM\fR.
+.SH NOTES
+Note that \fBpechochar\fR may be a macro.
+.SH PORTABILITY
+The XSI Curses standard, Issue 4 describes these functions.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_refresh\fR(3X), \fBcurs_touch\fR(3X), \fBcurs_addch\fR(3X).
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_printw.3 b/lib/libcurses/curs_printw.3
new file mode 100644
index 00000000000..c6db4c099ce
--- /dev/null
+++ b/lib/libcurses/curs_printw.3
@@ -0,0 +1,47 @@
+.TH curs_printw 3X ""
+.SH NAME
+\fBprintw\fR, \fBwprintw\fR, \fBmvprintw\fR,
+\fBmvwprintw\fR, \fBvwprintw\fR - print formatted output in
+\fBcurses\fR windows
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint printw(char *fmt\fR [\fB, arg\fR] \fB...);\fR
+.br
+\fBint wprintw(WINDOW *win, char *fmt\fR [\fB, arg\fR] \fB...);\fR
+.br
+\fBint mvprintw(int y, int x, char *fmt\fR [\fB, arg\fR] \fB...);\fR
+.br
+\fBint mvwprintw(WINDOW *win, int y, int x,
+ \fBchar *fmt\fR [\fB, arg]\fR ...);
+
+\fB#include <varargs.h>\fR
+.br
+\fBint vwprintw(WINDOW *win, char *fmt, varglist);\fR
+.br
+.SH DESCRIPTION
+The \fBprintw\fR, \fBwprintw\fR, \fBmvprintw\fR and \fBmvwprintw\fR
+routines are analogous to \fBprintf\fR [see \fBprintf\fR(3S)]. In
+effect, the string that would be output by \fBprintf\fR is output
+instead as though \fBwaddstr\fR were used on the given window.
+
+The \fBvwprintw\fR routine is analogous to \fBvprintf\fR [see
+\fBprintf\fR(3S)] and performs a \fBwprintw\fR using a variable
+argument list. The third argument is a \fBva_list\fR, a pointer to a
+list of arguments, as defined in \fB<varargs.h>\fR.
+.SH RETURN VALUE
+Routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
+(SVr4 onlyspecifies "an integer value other than \fBERR\fR") upon successful
+completion.
+.SH PORTABILITY
+The XSI Curses standard, Issue 4 describes these functions. The function
+\fBvwprintw\fR is marked TO BE WITHDRAWN, and is to be replaced by a function
+\fBvw_printw\fR using the \fB<stdarg.h>\fR interface.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBprintf\fR(3S), \fBvprintf(3S)\fR
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_refresh.3 b/lib/libcurses/curs_refresh.3
new file mode 100644
index 00000000000..77bae2eeb90
--- /dev/null
+++ b/lib/libcurses/curs_refresh.3
@@ -0,0 +1,84 @@
+.TH curs_refresh 3X ""
+.SH NAME
+\fBrefresh\fR, \fBwrefresh\fR, \fBwnoutrefresh\fR,
+\fBdoupdate\fR, \fBredrawwin\fR, \fBwredrawln\fR - refresh
+\fBcurses\fR windows and lines
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint refresh(void);\fR
+.br
+\fBint wrefresh(WINDOW *win);\fR
+.br
+\fBint wnoutrefresh(WINDOW *win);\fR
+.br
+\fBint doupdate(void);\fR
+.br
+\fBint redrawwin(WINDOW *win);\fR
+.br
+\fBint wredrawln(WINDOW *win, int beg_line, int num_lines);\fR
+.br
+.SH DESCRIPTION
+The \fBrefresh\fR and \fBwrefresh\fR routines (or \fBwnoutrefresh\fR and
+\fBdoupdate\fR) must be called to get actual output to the terminal, as other
+routines merely manipulate data structures. The routine \fBwrefresh\fR copies
+the named window to the physical terminal screen, taking into account what is
+already there in order to do optimizations. The \fBrefresh\fR routine is the
+same, using \fBstdscr\fR as the default window. Unless \fBleaveok\fR has been
+enabled, the physical cursor of the terminal is left at the location of the
+cursor for that window.
+
+The \fBwnoutrefresh\fR and \fBdoupdate\fR routines allow multiple updates with
+more efficiency than \fBwrefresh\fR alone. In addition to all the window
+structures, \fBcurses\fR keeps two data structures representing the terminal
+screen: a physical screen, describing what is actually on the screen, and a
+virtual screen, describing what the programmer wants to have on the screen.
+
+The routine \fBwrefresh\fR works by first calling \fBwnoutrefresh\fR, which
+copies the named window to the virtual screen, and then calling \fBdoupdate\fR,
+which compares the virtual screen to the physical screen and does the actual
+update. If the programmer wishes to output several windows at once, a series
+of calls to \fBwrefresh\fR results in alternating calls to \fBwnoutrefresh\fR
+and \fBdoupdate\fR, causing several bursts of output to the screen. By first
+calling \fBwnoutrefresh\fR for each window, it is then possible to call
+\fBdoupdate\fR once, resulting in only one burst of output, with fewer total
+characters transmitted and less CPU time used. If the \fIwin\fR argument to
+\fBwrefresh\fR is the global variable \fBcurscr\fR, the screen is immediately
+cleared and repainted from scratch.
+
+The phrase "copies the named window to the virtual screen" above is ambiguous.
+What actually happens is that all \fItouched\fR (changed) lines in the window
+are copied to the virtual screen. This affects programs that use overlapping
+windows; it means that if two windows overlap, you can refresh them in either
+order and the overlap region will be modified only when it is explicitly
+changed. (But see the section on \fBPORTABILITY\fR below for a warning about
+exploiting this behavior.)
+
+The \fBwredrawln\fR routine indicates to \fBcurses\fR that some screen lines
+are corrupted and should be thrown away before anything is written over them
+it touches the indicated lines (marking them changed) then does a refresh
+of the window. The routine \fBredrawwin\fR() touches the entire window and then
+refreshes it.
+.SH RETURN VALUE
+Routines that return an integer return \fBERR\fR upon failure, and \fBOK\fR
+(SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
+completion.
+.SH NOTES
+Note that \fBrefresh\fR and \fBredrawwin\fR may be macros.
+.SH PORTABILITY
+The XSI Curses standard, Issue 4 describes these functions.
+
+Whether \fBwnoutrefresh()\fR copies to the virtual screen the entire contents
+of a window or just its changed portions has never been well-documented in
+historic curses versions (including SVr4). It might be unwise to rely on
+either behavior in programs that might have to be linked with other curses
+implementations. Instead, you can do an explicit \fBtouchwin()\fR before the
+\fBwnoutrefresh()\fR call to guarantee an entire-contents copy anywhere.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_outopts\fR(3X)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_scanw.3 b/lib/libcurses/curs_scanw.3
new file mode 100644
index 00000000000..6ce1c0d2f84
--- /dev/null
+++ b/lib/libcurses/curs_scanw.3
@@ -0,0 +1,48 @@
+.TH curs_scanw 3X ""
+.SH NAME
+\fBscanw\fR, \fBwscanw\fR, \fBmvscanw\fR,
+\fBmvwscanw\fR, \fBvwscanw\fR - convert formatted input from a
+\fBcurses\fR widow
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint scanw(char *fmt\fR [\fB, arg\fR] \fB...);\fR
+.br
+\fBint wscanw(WINDOW *win, char *fmt\fR [\fB, arg\fR] \fB...);\fR
+.br
+\fBint mvscanw(int y, int x, char *fmt\fR [\fB, arg\fR] \fB...);\fR
+.br
+\fBint mvwscanw(WINDOW *win, int y, int x,
+ char *fmt\fR [\fB, arg]\fR \fB...);\fR
+.br
+\fBint vwscanw(WINDOW *win, char *fmt, va_list varglist);\fR
+.SH DESCRIPTION
+The \fBscanw\fR, \fBwscanw\fR and \fBmvscanw\fR routines are analogous to
+\fBscanf\fR [see \fBscanf\fR(3S)]. The effect of these routines is as though
+\fBwgetstr\fR were called on the window, and the resulting line used as input
+for \fBsscanf\fR(3). Fields which do not map to a variable in the \fIfmt\fR
+field are lost.
+
+The \fBvwscanw\fR routine is similar to \fBvwprintw\fR in that it performs a
+\fBwscanw\fR using a variable argument list. The third argument is a
+\fIva\fR_\fIlist\fR, a pointer to a list of arguments, as defined in
+\fB<varargs.h>\fR.
+.SH RETURN VALUE
+\fBvwscanw\fR returns \fBERR\fR on failure and an integer equal to the
+number of fields scanned on success.
+
+Applications may use the return value from the \fBscanw\fR, \fBwscanw\fR,
+\fBmvscanw\fR and \fBmvwscanw\fR routines to determine the number of fields
+which were mapped in the call.
+.SH PORTABILITY
+The XSI Curses standard, Issue 4 describes these functions. The function
+\fBvwscanw\fR is marked TO BE WITHDRAWN, and is to be replaced by a function
+\fBvw_scanw\fR using the \fB<stdarg.h>\fR interface.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_getstr\fR, \fBcurs_printw\fR, \fBscanf\fR(3S)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_scr_dmp.3 b/lib/libcurses/curs_scr_dmp.3
new file mode 100644
index 00000000000..c1b89f12059
--- /dev/null
+++ b/lib/libcurses/curs_scr_dmp.3
@@ -0,0 +1,64 @@
+.TH curs_scr_dump 3X ""
+.SH NAME
+\fBscr_dump\fR, \fBscr_restore\fR,
+\fBscr_init\fR, \fBscr_set\fR - read (write) a \fBcurses\fR screen
+from (to) a file
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint scr_dump(const char *filename);\fR
+.br
+\fBint scr_restore(const char *filename);\fR
+.br
+\fBint scr_init(const char *filename);\fR
+.br
+\fBint scr_set(const char *filename);\fR
+.br
+.SH DESCRIPTION
+The \fBscr_dump\fR routine dumps the current contents of the virtual screen
+to the file \fIfilename\fR.
+
+The \fBscr_restore\fR routine sets the virtual screen to the contents
+of \fIfilename\fR, which must have been written using \fBscr_dump\fR. The next
+call to \fBdoupdate\fR restores the screen to the way it looked in the dump
+file.
+
+The \fBscr_init\fR routine reads in the contents of \fIfilename\fR and uses
+them to initialize the \fBcurses\fR data structures about what the terminal
+currently has on its screen. If the data is determined to be valid,
+\fBcurses\fR bases its next update of the screen on this information rather
+than clearing the screen and starting from scratch. \fBscr_init\fR is used
+after \fBinitscr\fR or a \fBsystem\fR [see \fBsystem\fR(BA_LIB)] call to share
+the screen with another process which has done a \fBscr_dump\fR after its
+\fBendwin\fR call. The data is declared invalid if the terminfo capabilities
+\fBrmcup\fR and \fBnrrmc\fR exist; also if the terminal has been written to
+since the preceding \fBscr_dump\fR call.
+
+The \fBscr_set\fR routine is a combination of \fBscr_restore\fR and
+\fBscr_init\fR. It tells the program that the information in \fIfilename\fR is
+what is currently on the screen, and also what the program wants on the screen.
+This can be thought of as a screen inheritance function.
+
+To read (write) a window from (to) a file, use the \fBgetwin\fR and
+\fBputwin\fR routines [see \fBcurs_util\fR(3X)].
+.SH RETURN VALUE
+All routines return the integer \fBERR\fR upon failure and \fBOK\fR
+upon success.
+.SH NOTES
+Note that \fBscr_init\fR, \fBscr_set\fR, and \fBscr_restore\fR may be macros.
+.SH PORTABILITY
+The XSI Curses standard, Issue 4, describes these functions (adding the const
+qualifiers).
+
+The SVr4 docs merely say under \fBscr_init\fR that the dump data is also
+considered invalid "if the time-stamp of the tty is old" but don't define
+"old".
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_initscr\fR(3X), \fBcurs_refresh\fR(3X),
+\fBcurs_util\fR(3X), \fBsystem\fR(3S)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_scroll.3 b/lib/libcurses/curs_scroll.3
new file mode 100644
index 00000000000..0ac518d5b25
--- /dev/null
+++ b/lib/libcurses/curs_scroll.3
@@ -0,0 +1,49 @@
+.TH curs_scroll 3X ""
+.SH NAME
+\fBscroll\fR, \fBsrcl\fR, \fBwscrl\fR - scroll a \fBcurses\fR window
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint scroll(WINDOW *win);\fR
+.br
+\fBint scrl(int n);\fR
+.br
+\fBint wscrl(WINDOW *win, int n);\fR
+.br
+.SH DESCRIPTION
+The \fBscroll\fR routine scrolls the window up one line. This involves moving
+the lines in the window data structure. As an optimization, if the scrolling
+region of the window is the entire screen, the physical screen may be scrolled
+at the same time.
+
+For positive \fIn\fR, the \fBscrl\fR and \fBwscrl\fR routines scroll the
+window up \fIn\fR lines (line \fIi\fR+\fIn\fR becomes \fIi\fR); otherwise
+scroll the window down \fIn\fR lines. This involves moving the lines in the
+window character image structure. The current cursor position is not changed.
+
+For these functions to work, scrolling must be enabled via \fBscrollok\fR.
+.SH RETURN VALUE
+These routines return \fBERR\fR upon failure, and \fBOK\fR (SVr4 only specifies
+"an integer value other than \fBERR\fR") upon successful completion.
+.SH NOTES
+Note that \fBscrl\fR and \fBscroll\fR may be macros.
+
+The SVr4 documentation says that the optimization of physically scrolling
+immediately if the scroll region is the entire screen "is" performed, not
+"may be" performed. This implementation deliberately does not guarantee
+that this will occur, in order to leave open the possibility of smarter
+optimization of multiple scroll actions on the next update.
+
+Neither the SVr4 documentation specifies whether the current attribute or
+current color-pair of blanks generated by the scroll function is zeroed.
+Under this implementation it is.
+.SH PORTABILITY
+The XSI Curses standard, Issue 4 describes these functions.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_outopts\fR(3X)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_slk.3 b/lib/libcurses/curs_slk.3
new file mode 100644
index 00000000000..e735b9f2666
--- /dev/null
+++ b/lib/libcurses/curs_slk.3
@@ -0,0 +1,91 @@
+.TH curs_slk 3X ""
+.SH NAME
+\fBslk_init\fR, \fBslk_set\fR, \fBslk_refresh\fR,
+\fBslk_noutrefresh\fR, \fBslk_label\fR, \fBslk_clear\fR, \fBslk_restore\fR,
+\fBslk_touch\fR, \fBslk_attron\fR, \fBslk_attrset\fR, \fBslk_attroff\fR -
+\fBcurses\fR soft label routines
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint slk_init(int fmt);\fR
+.br
+\fBint slk_set(int labnum, const char *label, int fmt);\fR
+.br
+\fBint slk_refresh(void);\fR
+.br
+\fBint slk_noutrefresh(void);\fR
+.br
+\fBchar *slk_label(int labnum);\fR
+.br
+\fBint slk_clear(void);\fR
+.br
+\fBint slk_restore(void);\fR
+.br
+\fBint slk_touch(void);\fR
+.br
+\fBint slk_attron(attr_t attrs);\fR
+.br
+\fBint slk_attrset(attr_t attrs);\fR
+.br
+\fBint slk_attroff(attr_t attrs);\fR
+.br
+.SH DESCRIPTION
+The slk* functions manipulate the set of soft function-key labels that exist on
+many terminals. For those terminals that do not have soft labels,
+\fBcurses\fR takes over the bottom line of \fBstdscr\fR, reducing the size of
+\fBstdscr\fR and the variable \fBLINES\fR. \fBcurses\fR standardizes on eight
+labels of up to eight characters each.
+
+The \fBslk_init\fR routine must be called before \fBinitscr\fR or \fBnewterm\fR
+is called. If \fBinitscr\fR eventually uses a line from \fBstdscr\fR to
+emulate the soft labels, then \fIfmt\fR determines how the labels are arranged
+on the screen. Setting \fIfmt\fR to \fB0\fR indicates a 3-2-3 arrangement of
+the labels; \fB1\fR indicates a 4-4 arrangement.
+
+The \fBslk_set\fR routine requires \fIlabnum\fR to be a label number,
+from \fB1\fR to \fB8\fR; \fIlabel\fR must be the string to be put on the
+label, up to eight characters in length. A null string or a null
+pointer sets up a blank label. \fIfmt\fR is either \fB0\fR, \fB1\fR,
+or \fB2\fR, indicating whether the label is to be left-justified,
+centered, or right-justified, respectively, within the label.
+
+The \fBslk_refresh\fR and \fBslk_noutrefresh\fR routines correspond to
+the \fBwrefresh\fR and \fBwnoutrefresh\fR routines.
+
+The \fBslk_label\fR routine returns the current label for label number
+\fIlabnum\fR, with leading and trailing blanks stripped.
+
+The \fBslk_clear\fR routine clears the soft labels from the screen.
+
+The \fBslk_restore\fR routine, restores the soft labels to the screen
+after a \fBslk_clear\fR has been performed.
+
+The \fBslk_touch\fR routine forces all the soft labels to be output
+the next time a \fBslk_noutrefresh\fR is performed.
+
+The \fBslk_attron\fR, \fBslk_attrset\fR and \fBslk_attroff\fR routines
+correspond to \fBattron\fR, \fBattrset\fR, and \fBattroff\fR. They
+have an effect only if soft labels are simulated on the bottom line of
+the screen. The default highlight for soft keys is A_STANDOUT (as in
+System V curses, which does not document this fact).
+.SH RETURN VALUE
+These routines return \fBERR\fR upon failure and OK (SVr4 specifies only "an
+integer value other than \fBERR\fR") upon successful completion.
+
+\fBslk_label\fR returns \fBNULL\fR on error.
+.SH NOTES
+Most applications would use \fBslk_noutrefresh\fR because a
+\fBwrefresh\fR is likely to follow soon.
+.SH PORTABILITY
+The XSI Curses standard, Issue 4, describes these functions. It changes the
+argument type of the attribute-manipulation functions \fBslk_attron\fR,
+\fBslk_attroff\fR, \fBslk_attrset\fR to be \fBattr_t\fR, and adds \fBconst\fR
+qualifiers.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_attr\fR(3X), \fBcurs_initscr\fR(3X), \fBcurs_refresh\fR(3X)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_termattrs.3 b/lib/libcurses/curs_termattrs.3
new file mode 100644
index 00000000000..5c65d3c573e
--- /dev/null
+++ b/lib/libcurses/curs_termattrs.3
@@ -0,0 +1,78 @@
+.TH curs_termattrs 3X ""
+.SH NAME
+\fBbaudrate\fR, \fBerasechar\fR, \fBhas_ic\fR,
+\fBhas_il\fR, \fBkillchar\fR, \fBlongname\fR, \fBtermattrs\fR,
+\fBtermname\fR - \fBcurses\fR environment query routines
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBint baudrate(void);\fR
+.br
+\fBchar erasechar(void);\fR
+.br
+\fBint has_ic(void);\fR
+.br
+\fBint has_il(void);\fR
+.br
+\fBchar killchar(void);\fR
+.br
+\fBchar *longname(void);\fR
+.br
+\fBattr_t termattrs(void);\fR
+.br
+\fBchar *termname(void);\fR
+.br
+.SH DESCRIPTION
+The \fBbaudrate\fR routine returns the output speed of the terminal. The
+number returned is in bits per second, for example \fB9600\fR, and is an
+integer.
+
+The \fBerasechar\fR routine returns the user's current erase character.
+
+The \fBhas_ic\fR routine is true if the terminal has insert- and delete-
+character capabilities.
+
+The \fBhas_il\fR routine is true if the terminal has insert- and delete-line
+capabilities, or can simulate them using scrolling regions. This might
+be used to determine if it would be appropriate to turn on physical
+scrolling using \fBscrollok\fR.
+
+The \fBkillchar\fR routine returns the user's current line kill character.
+
+The \fBlongname\fR routine returns a pointer to a static area
+containing a verbose description of the current terminal. The maximum
+length of a verbose description is 128 characters. It is defined only
+after the call to \fBinitscr\fR or \fBnewterm\fR. The area is
+overwritten by each call to \fBnewterm\fR and is not restored by
+\fBset_term\fR, so the value should be saved between calls to
+\fBnewterm\fR if \fBlongname\fR is going to be used with multiple
+terminals.
+
+If a given terminal doesn't support a video attribute that an
+application program is trying to use, \fBcurses\fR may substitute a
+different video attribute for it. The \fBtermattrs\fR function
+returns a logical \fBOR\fR of all video attributes supported by the
+terminal. This information is useful when a \fBcurses\fR program
+needs complete control over the appearance of the screen.
+
+The \fBtermname\fR routine returns the value of the environmental
+variable \fBTERM\fR (truncated to 14 characters).
+.SH RETURN VALUE
+\fBlongname\fR and \fBtermname\fR return \fBNULL\fR on error.
+
+Routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
+(SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
+completion.
+.SH NOTES
+Note that \fBtermattrs\fR may be a macro.
+.SH PORTABILITY
+The XSI Curses standard, Issue 4 describes these functions. It changes the
+return type of \fBtermattrs\fR to the new type \fBattr_t\fR.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_initscr\fR(3X), \fBcurs_outopts\fR(3X)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_touch.3 b/lib/libcurses/curs_touch.3
new file mode 100644
index 00000000000..961ccbe66da
--- /dev/null
+++ b/lib/libcurses/curs_touch.3
@@ -0,0 +1,64 @@
+.TH curs_touch 3X ""
+.SH NAME
+\fBtouchwin\fR, \fBtouchline\fR, \fBuntouchwin\fR,
+\fBwtouchln\fR, \fBis_linetouched\fR, \fBis_wintouched\fR -
+\fBcurses\fR refresh control routines
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+.br
+\fBint touchwin(WINDOW *win);\fR
+.br
+\fBint touchline(WINDOW *win, int start, int count);\fR
+.br
+\fBint untouchwin(WINDOW *win);\fR
+.br
+\fBint wtouchln(WINDOW *win, int y, int n, int changed);\fR
+.br
+\fBint is_linetouched(WINDOW *win, int line);\fR
+.br
+\fBint is_wintouched(WINDOW *win);\fR
+.br
+.SH DESCRIPTION
+The \fBtouchwin\fR and \fBtouchline\fR routines throw away all
+optimization information about which parts of the window have been
+touched, by pretending that the entire window has been drawn on. This
+is sometimes necessary when using overlapping windows, since a change
+to one window affects the other window, but the records of which lines
+have been changed in the other window do not reflect the change. The
+routine \fBtouchline\fR only pretends that \fIcount\fR lines have been
+changed, beginning with line \fIstart\fR.
+
+The \fBuntouchwin\fR routine marks all lines in the window as unchanged since
+the last call to \fBwrefresh\fR.
+
+The \fBwtouchln\fR routine makes \fIn\fR lines in the window, starting
+at line \fIy\fR, look as if they have (\fIchanged\fR\fB=1\fR) or have
+not (\fIchanged\fR\fB=0\fR) been changed since the last call to
+\fBwrefresh\fR.
+
+The \fBis_linetouched\fR and \fBis_wintouched\fR routines return
+\fBTRUE\fR if the specified line/window was modified since the last
+call to \fBwrefresh\fR; otherwise they return \fBFALSE\fR. In
+addition, \fBis_linetouched\fR returns \fBERR\fR if \fIline\fR is not
+valid for the given window.
+.SH RETURN VALUE
+All routines return the integer \fBERR\fR upon failure and an integer value
+other than \fBERR\fR upon successful completion, unless otherwise noted in the
+preceding routine descriptions.
+.SH PORTABILITY
+The XSI Curses standard, Issue 4 describes these functions.
+
+Some historic curses implementations had, as an undocumented feature, the
+ability to do the equivalent of \fBclearok(..., 1)\fR by saying
+\fBtouchwin(stdscr)\fR or \fBclear(stdscr)\fR. This will not work under
+curses.
+.SH NOTES
+Note that all routines except \fBwtouchln\fR may be macros.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_refresh\fR(3X).
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_util.3 b/lib/libcurses/curs_util.3
new file mode 100644
index 00000000000..0d2e0b88b74
--- /dev/null
+++ b/lib/libcurses/curs_util.3
@@ -0,0 +1,85 @@
+.TH curs_util 3X ""
+.SH NAME
+\fBunctrl\fR, \fBkeyname\fR, \fBfilter\fR,
+\fBuse_env\fR, \fBputwin\fR, \fBgetwin\fR, \fBdelay_output\fR,
+\fBflushinp\fR - miscellaneous \fBcurses\fR utility routines
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBchar *unctrl(chtype c);\fR
+.br
+\fBchar *keyname(int c);\fR
+.br
+\fBvoid filter(void);\fR
+.br
+\fBvoid use_env(char bool);\fR
+.br
+\fBint putwin(WINDOW *win, FILE *filep);\fR
+.br
+\fBWINDOW *getwin(FILE *filep);\fR
+.br
+\fBint delay_output(int ms);\fR
+.br
+\fBint flushinp(void);\fR
+.br
+.SH DESCRIPTION
+The \fBunctrl\fR macro expands to a character string which is a printable
+representation of the character \fIc\fR. Control characters are displayed in
+the \fB^\fR\fIX\fR notation. Printing characters are displayed as is.
+
+The \fBkeyname\fR routine returns a character string corresponding to
+the key \fIc\fR.
+
+The \fBfilter\fR routine, if used, must be called before \fBinitscr\fR or
+\fBnewterm\fR are called. The effect is that, during those calls, \fBLINES\fR
+is set to 1; the capabilities \fBclear\fR, \fBcup\fR, \fBcud\fR, \fBcud1\fR,
+\fBcuu1\fR, \fBcuu\fR, \fBvpa\fR are disabled; and the \fBhome\fR string is
+set to the value of \fBcr\fR.
+
+The \fBuse_env\fR routine, if used, is called before \fBinitscr\fR or
+\fBnewterm\fR are called. When called with \fBFALSE\fR as an
+argument, the values of \fBlines\fR and \fBcolumns\fR specified in the
+\fIterminfo\fR database will be used, even if environment variables
+\fBLINES\fR and \fBCOLUMNS\fR (used by default) are set, or if
+\fBcurses\fR is running in a window (in which case default behavior
+would be to use the window size if \fBLINES\fR and \fBCOLUMNS\fR are
+not set).
+
+The \fBputwin\fR routine writes all data associated with window \fIwin\fR into
+the file to which \fIfilep\fR points. This information can be later retrieved
+using the \fBgetwin\fR function.
+
+The \fBgetwin\fR routine reads window related data stored in the file by
+\fBputwin\fR. The routine then creates and initializes a new window using that
+data. It returns a pointer to the new window.
+
+The \fBdelay_output\fR routine inserts an \fIms\fR millisecond pause
+in output. This routine should not be used extensively because
+padding characters are used rather than a CPU pause.
+
+The \fBflushinp\fR routine throws away any typeahead that has been typed by the
+user and has not yet been read by the program.
+.SH RETURN VALUE
+Except for \fBflushinp\fR, routines that return an integer return \fBERR\fR
+upon failure and \fBOK\fR (SVr4 specifies only "an integer value other than
+\fBERR\fR") upon successful completion.
+
+\fBflushinp\fR always returns \fBOK\fR.
+
+Routines that return pointers return \fBNULL\fR on error.
+.SH PORTABILITY
+The XSI Curses standard, Issue 4 describes these functions.
+
+The SVr4 documentation describes the action of \fBfilter\fR only in the vaguest
+terms. The description here is adapted from the XSI Curses standard (which
+erroneously fails to describe the disabling of \fBcuu\fR).
+.SH NOTES
+Note that \fBunctrl\fR is a macro, which is defined in <\fBunctrl.h\fR>.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_initscr\fR(3X), \fBcurs_scr_dump\fR(3X).
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_window.3 b/lib/libcurses/curs_window.3
new file mode 100644
index 00000000000..9bd3facd818
--- /dev/null
+++ b/lib/libcurses/curs_window.3
@@ -0,0 +1,123 @@
+.TH curs_window 3X ""
+.SH NAME
+\fBnewwin\fR, \fBdelwin\fR, \fBmvwin\fR,
+\fBsubwin\fR, \fBderwin\fR, \fBmvderwin\fR, \fBdupwin\fR,
+\fBwsyncup\fR, \fBsyncok\fR, \fBwcursyncup\fR, \fBwsyncdown\fR -
+create \fBcurses\fR windows
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+
+\fBWINDOW *newwin(int nlines, int ncols, int begin_y,\fR
+ \fBintbegin_x);\fR
+.br
+\fBint delwin(WINDOW *win);\fR
+.br
+\fBint mvwin(WINDOW *win, int y, int x);\fR
+.br
+\fBWINDOW *subwin(WINDOW *orig, int nlines, int ncols,
+ int begin_y, int begin_x);\fR
+.br
+\fBWINDOW *derwin(WINDOW *orig, int nlines, int ncols,
+ int begin_y, int begin_x);\fR
+.br
+\fBint mvderwin(WINDOW *win, int par_y, int par_x);\fR
+.br
+\fBWINDOW *dupwin(WINDOW *win);\fR
+.br
+\fBvoid wsyncup(WINDOW *win);\fR
+.br
+\fBint syncok(WINDOW *win, bool bf);\fR
+.br
+\fBvoid wcursyncup(WINDOW *win);\fR
+.br
+\fBvoid wsyncdown(WINDOW *win);\fR
+.br
+.SH DESCRIPTION
+Calling \fBnewwin\fR creates and returns a pointer to a new window with the
+given number of lines and columns. The upper left-hand corner of the window is
+at line \fIbegin\fR_\fIy\fR, column \fIbegin\fR_\fIx\fR. If either
+\fInlines\fR or \fIncols\fR is zero, they default to \fBLINES -\fR
+\fIbegin\fR_\fIy\fR and \fBCOLS -\fR \fIbegin\fR_\fIx\fR. A new full-screen
+window is created by calling \fBnewwin(0,0,0,0)\fR.
+
+Calling \fBdelwin\fR deletes the named window, freeing all memory
+associated with it (it does not actually erase the window's screen
+image). Subwindows must be deleted before the main window can be
+deleted.
+
+Calling \fBmvwin\fR moves the window so that the upper left-hand
+corner is at position (\fIx\fR, \fIy\fR). If the move would cause the
+window to be off the screen, it is an error and the window is not
+moved. Moving subwindows is allowed, but should be avoided.
+
+Calling \fBsubwin\fR creates and returns a pointer to a new window
+with the given number of lines, \fInlines\fR, and columns,
+\fIncols\fR. The window is at position (\fIbegin\fR_\fIy\fR,
+\fIbegin\fR_\fIx\fR) on the screen. (This position is relative to the
+screen, and not to the window \fIorig\fR.) The window is made in the
+middle of the window \fIorig\fR, so that changes made to one window
+will affect both windows. The subwindow shares memory with the window
+\fIorig\fR. When using this routine, it is necessary to call
+\fBtouchwin\fR or \fBtouchline\fR on \fIorig\fR before calling
+\fBwrefresh\fR on the subwindow.
+
+Calling \fBderwin\fR is the same as calling \fBsubwin,\fR except that
+\fIbegin\fR_\fIy\fR and \fIbegin\fR_\fIx\fR are relative to the origin
+of the window \fIorig\fR rather than the screen. There is no
+difference between the subwindows and the derived windows.
+
+Calling \fBmvderwin\fR moves a derived window (or subwindow)
+inside its parent window. The screen-relative parameters of the
+window are not changed. This routine is used to display different
+parts of the parent window at the same physical position on the
+screen.
+
+Calling \fBdupwin\fR creates an exact duplicate of the window \fIwin\fR.
+
+Calling \fBwsyncup\fR touches all locations in ancestors of \fIwin\fR that are
+changed in \fIwin\fR. If \fBsyncok\fR is called with second argument
+\fBTRUE\fR then \fBwsyncup\fR is called automatically whenever there is a
+change in the window.
+
+The \fBwsyncdown\fR routine touches each location in \fIwin\fR that has been
+touched in any of its ancestor windows. This routine is called by
+\fBwrefresh\fR, so it should almost never be necessary to call it manually.
+
+The routine \fBwcursyncup\fR updates the current cursor position of all the
+ancestors of the window to reflect the current cursor position of the
+window.
+.SH RETURN VALUE
+Routines that return an integer return the integer \fBERR\fR upon failure and
+\fBOK\fR (SVr4 only specifies "an integer value other than \fBERR\fR") upon
+successful completion.
+
+\fBdelwin\fR returns the integer \fBERR\fR upon failure and \fBOK\fR
+upon successful completion.
+
+Routines that return pointers return \fBNULL\fR on error.
+.SH NOTES
+If many small changes are made to the window, the \fBwsyncup\fR option could
+degrade performance.
+
+Note that \fBsyncok\fR may be a macro.
+.SH BUGS
+The subwindow functions (\fIsubwin\fR, \fIderwin\fR, \fImvderwin\fR,
+\fBwsyncup\fR, \fBwsyncdown\fR, \fBwcursyncup\fR, \fBsyncok\fR) are flaky,
+incompletely implemented, and not well tested.
+
+The System V curses documentation is very unclear about what \fBwsyncup\fR
+and \fBwsyncdown\fR actually do. It seems to imply that they are only
+supposed to touch exactly those lines that are affected by ancestor changes.
+The language here, and the behavior of the \fBcurses\fR implementation,
+is patterned on the XPG4 curses standard. The weaker XPG4 spec may result
+in slower updates.
+.SH PORTABILITY
+The XSI Curses standard, Issue 4 describes these functions.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBcurs_refresh\fR(3X), \fBcurs_touch\fR(3X)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curses.3 b/lib/libcurses/curses.3
index ea0093b61ad..a47086d4871 100644
--- a/lib/libcurses/curses.3
+++ b/lib/libcurses/curses.3
@@ -1,197 +1,608 @@
-.\" Copyright (c) 1985, 1991, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)curses.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd June 4, 1993
-.Dt CURSES 3
-.Os BSD 4
-.Sh NAME
-.Nm curses
-.Nd screen functions with ``optimal'' cursor motion
-.Sh SYNOPSIS
-.Nm cc
-.Op Ar flags
-.Ar files
-.Fl lcurses ltermcap
-.Op Ar libraries
-.Sh DESCRIPTION
-These routines give the user a method of updating screens with reasonable
-optimization. They keep an image of the current screen,
-and the user sets up an image of a new one. Then the
-.Fn refresh
-tells the routines to make the current screen look like the new one.
-In order to initialize the routines, the routine
-.Fn initscr
-must be called before any of the other routines that deal with windows and
-screens are used. The routine
-.Fn endwin
-should be called before exiting.
-.Sh SEE ALSO
-.Xr ioctl 2 ,
-.Xr getenv 3 ,
-.Xr tty 4 ,
-.Xr termcap 5
-.Rs
-.%T Screen Updating and Cursor Movement Optimization: A Library Package
-.%A Ken Arnold
-.Re
-.Sh AUTHOR
-.An Ken Arnold
-.Sh FUNCTIONS
-.Bl -column "subwin(win,lines,cols,begin_y,begin_x) "
-.It addch(ch) add a character to
-.Em stdscr
-.It addstr(str) add a string to
-.Em stdscr
-.It box(win,vert,hor) draw a box around a window
-.It cbreak() set cbreak mode
-.It clear() clear
-.Em stdscr
-.It clearok(scr,boolf) set clear flag for
-.Em scr
-.It clrtobot() clear to bottom on
-.Em stdscr
-.It clrtoeol() clear to end of line on
-.Em stdscr
-.It delch() delete a character
-.It deleteln() delete a line
-.It delwin(win) delete
-.Em stdscr
-.It echo() set echo mode
-.It endwin() end window modes
-.It erase() erase
-.Em stdscr
-.It flusok(win,boolf) set flush-on-refresh flag for
-.Em win
-.It getch() get a char through
-.Em stdscr
-.It getcap(name) get terminal capability
-.Em name
-.It getstr(str) get a string through
-.Em stdscr
-.It gettmode() get tty modes
-.It getyx(win,y,x) get (y,x) co-ordinates
-.It inch() get char at current (y,x) co-ordinates
-.It initscr() initialize screens
-.It insch(c) insert a char
-.It insertln() insert a line
-.It leaveok(win,boolf) set leave flag for
-.Em stdscr
-.It longname(termbuf,name) get long name from
-.Em termbuf
-.It move(y,x) move to (y,x) on
-.Em stdscr
-.It mvcur(lasty,lastx,newy,newx) actually move cursor
-.It newwin(lines,cols,begin_y,begin_x)\ create a new window
-.It nl() set newline mapping
-.It nocbreak() unset cbreak mode
-.It noecho() unset echo mode
-.It nonl() unset newline mapping
-.It noraw() unset raw mode
-.It overlay(win1,win2) overlay win1 on win2
-.It overwrite(win1,win2) overwrite win1 on top of win2
-.It printw(fmt,arg1,arg2,...) printf on
-.Em stdscr
-.It raw() set raw mode
-.It refresh() make current screen look like
-.Em stdscr
-.It resetty() reset tty flags to stored value
-.It savetty() stored current tty flags
-.It scanw(fmt,arg1,arg2,...) scanf through
-.Em stdscr
-.It scroll(win) scroll
-.Em win
-one line
-.It scrollok(win,boolf) set scroll flag
-.It setterm(name) set term variables for name
-.It standend() end standout mode
-.It standout() start standout mode
-.It subwin(win,lines,cols,begin_y,begin_x)\ create a subwindow
-.It touchline(win,y,sx,ex) mark line
-.Em y
-.Em sx
-through
-.Em sy
-as changed
-.It touchoverlap(win1,win2) mark overlap of
-.Em win1
-on
-.Em win2
-as changed
-.It touchwin(win) \*(lqchange\*(rq all of
-.Em win
-.It unctrl(ch) printable version of
-.Em ch
-.It waddch(win,ch) add char to
-.Em win
-.It waddstr(win,str) add string to
-.Em win
-.It wclear(win) clear
-.Em win
-.It wclrtobot(win) clear to bottom of
-.Em win
-.It wclrtoeol(win) clear to end of line on
-.Em win
-.It wdelch(win) delete char from
-.Em win
-.It wdeleteln(win) delete line from
-.Em win
-.It werase(win) erase
-.Em win
-.It wgetch(win) get a char through
-.Em win
-.It wgetstr(win,str) get a string through
-.Em win
-.It winch(win) get char at current (y,x) in
-.Em win
-.It winsch(win,c) insert char into
-.Em win
-.It winsertln(win) insert line into
-.Em win
-.It wmove(win,y,x) set current (y,x) co-ordinates on
-.Em win
-.It wprintw(win,fmt,arg1,arg2,...)\ printf on
-.Em win
-.It wrefresh(win) make screen look like
-.Em win
-.It wscanw(win,fmt,arg1,arg2,...)\ scanf through
-.Em win
-.It wstandend(win) end standout mode on
-.Em win
-.It wstandout(win) start standout mode on
-.Em win
-.El
-.Sh HISTORY
-The
-.Nm
-package appeared in
-.Bx 4.0 .
+.TH curses 3X ""
+.ds n 5
+.ds d /usr/share/terminfo
+.SH NAME
+\fBcurses\fR - CRT screen handling and optimization package
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+.br
+.SH DESCRIPTION
+The \fBcurses\fR library routines give the user a terminal-independent method
+of updating character screens with reasonable optimization. This
+implementation is ``new curses'' (ncurses) and is the approved replacement for
+4.4BSD classic curses, which is being discontinued.
+
+The \fBcurses\fR routines emulate the \fBcurses\fR(3X) library of System V
+Release 4 UNIX, and the XPG4 curses standard (XSI curses) but the \fBcurses\fR
+library is freely redistributable in source form. Differences from the SVr4
+curses are summarized under the EXTENSIONS and BUGS sections below and
+described in detail in the EXTENSIONS and BUGS sections of individual man
+pages.
+
+A program using these routines must be linked with the \fB-lcurses\fR option.
+
+The \fBcurses\fR package supports: overall screen, window and pad
+manipulation; output to windows and pads; reading terminal input; control over
+terminal and \fBcurses\fR input and output options; environment query
+routines; color manipulation; use of soft label keys; terminfo capabilities;
+and access to low-level terminal-manipulation routines.
+
+To initialize the routines, the routine \fBinitscr\fR or \fBnewterm\fR
+must be called before any of the other routines that deal with windows
+and screens are used. The routine \fBendwin\fR must be called before
+exiting. To get character-at-a-time input without echoing (most
+interactive, screen oriented programs want this), the following
+sequence should be used:
+
+ \fBinitscr(); cbreak(); noecho();\fR
+
+Most programs would additionally use the sequence:
+
+ \fBnonl();\fR
+ \fBintrflush(stdscr, FALSE);\fR
+ \fBkeypad(stdscr, TRUE);\fR
+
+Before a \fBcurses\fR program is run, the tab stops of the terminal
+should be set and its initialization strings, if defined, must be
+output. This can be done by executing the \fBtput init\fR command
+after the shell environment variable \fBTERM\fR has been exported.
+\fBtset(1)\fR is usually responsible for doing this.
+[See \fBterminfo\fR(\*n) for further details.]
+
+The \fBcurses\fR library permits manipulation of data structures,
+called \fIwindows\fR, which can be thought of as two-dimensional
+arrays of characters representing all or part of a CRT screen. A
+default window called \fBstdscr\fR, which is the size of the terminal
+screen, is supplied. Others may be created with \fBnewwin\fR.
+
+Note that \fBcurses\fR does not handle overlapping windows, that's done by
+the \fBpanels(3x)\fR library. This means that you can either use
+\fBstdscr\fR or divide the screen into tiled windows and not using
+\fBstdscr\fR at all. Mixing the two will result in unpredictable, and
+undesired, effects.
+
+Windows are referred to by variables declared as \fBWINDOW *\fR.
+These data structures are manipulated with routines described here and
+elsewhere in the \fBcurses\fR manual pages. Among which the most basic
+routines are \fBmove\fR and \fBaddch\fR. More general versions of
+these routines are included with names beginning with \fBw\fR,
+allowing the user to specify a window. The routines not beginning
+with \fBw\fR affect \fBstdscr\fR.)
+
+After using routines to manipulate a window, \fBrefresh\fR is called,
+telling \fBcurses\fR to make the user's CRT screen look like
+\fBstdscr\fR. The characters in a window are actually of type
+\fBchtype\fR, (character and attribute data) so that other information
+about the character may also be stored with each character.
+
+Special windows called \fIpads\fR may also be manipulated. These are windows
+which are not constrained to the size of the screen and whose contents need not
+be completely displayed. See curs_pad(3X) for more information.
+
+In addition to drawing characters on the screen, video attributes and colors
+may be supported, causing the characters to show up in such modes as
+underlined, in reverse video, or in color on terminals that support such
+display enhancements. Line drawing characters may be specified to be output.
+On input, \fBcurses\fR is also able to translate arrow and function keys that
+transmit escape sequences into single values. The video attributes, line
+drawing characters, and input values use names, defined in \fB<curses.h>\fR,
+such as \fBA_REVERSE\fR, \fBACS_HLINE\fR, and \fBKEY_LEFT\fR.
+
+If the environment variables \fBLINES\fR and \fBCOLUMNS\fR are set, or if the
+program is executing in a window environment, line and column information in
+the environment will override information read by \fIterminfo\fR. This would
+effect a program running in an AT&T 630 layer, for example, where the size of a
+screen is changeable.
+
+If the environment variable \fBTERMINFO\fR is defined, any program using
+\fBcurses\fR checks for a local terminal definition before checking in the
+standard place. For example, if \fBTERM\fR is set to \fBatt4424\fR, then the
+compiled terminal definition is found in
+
+ \fB\*d/a/att4424\fR.
+
+(The \fBa\fR is copied from the first letter of \fBatt4424\fR to avoid
+creation of huge directories.) However, if \fBTERMINFO\fR is set to
+\fB$HOME/myterms\fR, \fBcurses\fR first checks
+
+ \fB$HOME/myterms/a/att4424\fR,
+
+and if that fails, it then checks
+
+ \fB\*d/a/att4424\fR.
+
+This is useful for developing experimental definitions or when write
+permission in \fB\*d\fR is not available.
+
+The integer variables \fBLINES\fR and \fBCOLS\fR are defined in
+\fB<curses.h>\fR and will be filled in by \fBinitscr\fR with the size of the
+screen. The constants \fBTRUE\fR and \fBFALSE\fR have the values \fB1\fR and
+\fB0\fR, respectively.
+
+The \fBcurses\fR routines also define the \fBWINDOW *\fR variable \fBcurscr\fR
+which is used for certain low-level operations like clearing and redrawing a
+screen containing garbage. The \fBcurscr\fR can be used in only a few
+routines.
+
+.SS Routine and Argument Names
+Many \fBcurses\fR routines have two or more versions. The routines prefixed
+with \fBw\fR require a window argument. The routines prefixed with \fBp\fR
+require a pad argument. Those without a prefix generally use \fBstdscr\fR.
+
+The routines prefixed with \fBmv\fR require a \fIy\fR and \fIx\fR
+coordinate to move to before performing the appropriate action. The
+\fBmv\fR routines imply a call to \fBmove\fR before the call to the
+other routine. The coordinate \fIy\fR always refers to the row (of
+the window), and \fIx\fR always refers to the column. The upper
+left-hand corner is always (0,0), not (1,1).
+
+The routines prefixed with \fBmvw\fR take both a window argument and
+\fIx\fR and \fIy\fR coordinates. The window argument is always
+specified before the coordinates.
+
+In each case, \fIwin\fR is the window affected, and \fIpad\fR is the
+pad affected; \fIwin\fR and \fIpad\fR are always pointers to type
+\fBWINDOW\fR.
+
+Option setting routines require a Boolean flag \fIbf\fR with the value
+\fBTRUE\fR or \fBFALSE\fR; \fIbf\fR is always of type \fBbool\fR. The
+variables \fIch\fR and \fIattrs\fR below are always of type
+\fBchtype\fR. The types \fBWINDOW\fR, \fBSCREEN\fR, \fBbool\fR, and
+\fBchtype\fR are defined in \fB<curses.h>\fR. The type \fBTERMINAL\fR
+is defined in \fB<term.h>\fR. All other arguments are integers.
+
+.SS Routine Name Index
+The following table lists each \fBcurses\fR routine and the name of
+the manual page on which it is described. Routines flagged with `*'
+are ncurses-specific, not described by XPG4 or present in SVr4.
+
+.nf
+\fBcurses\fR Routine Name Manual Page Name
+___________________________________________
+addch curs_addch(3X)
+addchnstr curs_addchstr(3X)
+addchstr curs_addchstr(3X)
+addnstr curs_addstr(3X)
+addstr curs_addstr(3X)
+attroff curs_attr(3X)
+attron curs_attr(3X)
+attrset curs_attr(3X)
+baudrate curs_termattrs(3X)
+beep curs_beep(3X)
+bkgd curs_bkgd(3X)
+bkgdset curs_bkgd(3X)
+border curs_border(3X)
+box curs_border(3X)
+can_change_color curs_color(3X)
+cbreak curs_inopts(3X)
+clear curs_clear(3X)
+clearok curs_outopts(3X)
+clrtobot curs_clear(3X)
+clrtoeol curs_clear(3X)
+color_content curs_color(3X)
+copywin curs_overlay(3X)
+curs_set curs_kernel(3X)
+def_prog_mode curs_kernel(3X)
+def_shell_mode curs_kernel(3X)
+del_curterm curs_terminfo(3X)
+delay_output curs_util(3X)
+delch curs_delch(3X)
+deleteln curs_deleteln(3X)
+delscreen curs_initscr(3X)
+delwin curs_window(3X)
+derwin curs_window(3X)
+doupdate curs_refresh(3X)
+dupwin curs_window(3X)
+echo curs_inopts(3X)
+echochar curs_addch(3X)
+endwin curs_initscr(3X)
+erase curs_clear(3X)
+erasechar curs_termattrs(3X)
+filter curs_util(3X)
+flash curs_beep(3X)
+flushinp curs_util(3X)
+getbegyx curs_getyx(3X)
+getch curs_getch(3X)
+getmaxyx curs_getyx(3X)
+getmouse curs_mouse(3X)*
+getparyx curs_getyx(3X)
+getstr curs_getstr(3X)
+getsyx curs_kernel(3X)
+getwin curs_util(3X)
+getyx curs_getyx(3X)
+halfdelay curs_inopts(3X)
+has_colors curs_color(3X)
+has_ic curs_termattrs(3X)
+has_il curs_termattrs(3X)
+hline curs_border(3X)
+idcok curs_outopts(3X)
+idlok curs_outopts(3X)
+immedok curs_outopts(3X)
+inch curs_inch(3X)
+inchnstr curs_inchstr(3X)
+inchstr curs_inchstr(3X)
+init_color curs_color(3X)
+init_pair curs_color(3X)
+initscr curs_initscr(3X)
+innstr curs_instr(3X)
+insch curs_insch(3X)
+insdelln curs_deleteln(3X)
+insertln curs_deleteln(3X)
+insnstr curs_insstr(3X)
+insstr curs_insstr(3X)
+instr curs_instr(3X)
+intrflush curs_inopts(3X)
+is_linetouched curs_touch(3X)
+is_wintouched curs_touch(3X)
+isendwin curs_initscr(3X)
+keyname curs_util(3X)
+keypad curs_inopts(3X)
+killchar curs_termattrs(3X)
+leaveok curs_outopts(3X)
+longname curs_termattrs(3X)
+meta curs_inopts(3X)
+mouseinterval curs_mouse(3X)*
+mousemask curs_mouse(3X)*
+move curs_move(3X)
+mvaddch curs_addch(3X)
+mvaddchnstr curs_addchstr(3X)
+mvaddchstr curs_addchstr(3X)
+mvaddnstr curs_addstr(3X)
+mvaddstr curs_addstr(3X)
+mvcur curs_terminfo(3X)
+mvdelch curs_delch(3X)
+mvderwin curs_window(3X)
+mvgetch curs_getch(3X)
+mvgetstr curs_getstr(3X)
+mvinch curs_inch(3X)
+mvinchnstr curs_inchstr(3X)
+mvinchstr curs_inchstr(3X)
+mvinnstr curs_instr(3X)
+mvinsch curs_insch(3X)
+mvinsnstr curs_insstr(3X)
+mvinsstr curs_insstr(3X)
+mvinstr curs_instr(3X)
+mvprintw curs_printw(3X)
+mvscanw curs_scanw(3X)
+mvwaddch curs_addch(3X)
+mvwaddchnstr curs_addchstr(3X)
+mvwaddchstr curs_addchstr(3X)
+mvwaddnstr curs_addstr(3X)
+mvwaddstr curs_addstr(3X)
+mvwdelch curs_delch(3X)
+mvwgetch curs_getch(3X)
+mvwgetstr curs_getstr(3X)
+mvwin curs_window(3X)
+mvwinch curs_inch(3X)
+mvwinchnstr curs_inchstr(3X)
+mvwinchstr curs_inchstr(3X)
+mvwinnstr curs_instr(3X)
+mvwinsch curs_insch(3X)
+mvwinsnstr curs_insstr(3X)
+mvwinsstr curs_insstr(3X)
+mvwinstr curs_instr(3X)
+mvwprintw curs_printw(3X)
+mvwscanw curs_scanw(3X)
+napms curs_kernel(3X)
+newpad curs_pad(3X)
+newterm curs_initscr(3X)
+newwin curs_window(3X)
+nl curs_outopts(3X)
+nocbreak curs_inopts(3X)
+nodelay curs_inopts(3X)
+noecho curs_inopts(3X)
+nonl curs_outopts(3X)
+noqiflush curs_inopts(3X)
+noraw curs_inopts(3X)
+notimeout curs_inopts(3X)
+overlay curs_overlay(3X)
+overwrite curs_overlay(3X)
+pair_content curs_color(3X)
+pechochar curs_pad(3X)
+pnoutrefresh curs_pad(3X)
+prefresh curs_pad(3X)
+printw curs_printw(3X)
+putp curs_terminfo(3X)
+putwin curs_util(3X)
+qiflush curs_inopts(3X)
+raw curs_inopts(3X)
+redrawwin curs_refresh(3X)
+refresh curs_refresh(3X)
+reset_prog_mode curs_kernel(3X)
+reset_shell_mode curs_kernel(3X)
+resetty curs_kernel(3X)
+restartterm curs_terminfo(3X)
+ripoffline curs_kernel(3X)
+savetty curs_kernel(3X)
+scanw curs_scanw(3X)
+scr_dump curs_scr_dump(3X)
+scr_init curs_scr_dump(3X)
+scr_restore curs_scr_dump(3X)
+scr_set curs_scr_dump(3X)
+scrl curs_scroll(3X)
+scroll curs_scroll(3X)
+scrollok curs_outopts(3X)
+set_curterm curs_terminfo(3X)
+set_term curs_initscr(3X)
+setscrreg curs_outopts(3X)
+setsyx curs_kernel(3X)
+setterm curs_terminfo(3X)
+setupterm curs_terminfo(3X)
+slk_attroff curs_slk(3X)
+slk_attron curs_slk(3X)
+slk_attrset curs_slk(3X)
+slk_clear curs_slk(3X)
+slk_init curs_slk(3X)
+slk_label curs_slk(3X)
+slk_noutrefresh curs_slk(3X)
+slk_refresh curs_slk(3X)
+slk_restore curs_slk(3X)
+slk_set curs_slk(3X)
+slk_touch curs_slk(3X)
+standend curs_attr(3X)
+standout curs_attr(3X)
+start_color curs_color(3X)
+subpad curs_pad(3X)
+subwin curs_window(3X)
+syncok curs_window(3X)
+termattrs curs_termattrs(3X)
+termname curs_termattrs(3X)
+tgetent curs_termcap(3X)
+tgetflag curs_termcap(3X)
+tgetnum curs_termcap(3X)
+tgetstr curs_termcap(3X)
+tgoto curs_termcap(3X)
+tigetflag curs_terminfo(3X)
+tigetnum curs_terminfo(3X)
+tigetstr curs_terminfo(3X)
+timeout curs_inopts(3X)
+touchline curs_touch(3X)
+touchwin curs_touch(3X)
+tparm curs_terminfo(3X)
+tputs curs_termcap(3X)
+tputs curs_terminfo(3X)
+typeahead curs_inopts(3X)
+unctrl curs_util(3X)
+ungetch curs_getch(3X)
+ungetmouse curs_mouse(3X)*
+untouchwin curs_touch(3X)
+use_env curs_util(3X)
+vidattr curs_terminfo(3X)
+vidputs curs_terminfo(3X)
+vline curs_border(3X)
+vwprintw curs_printw(3X)
+vwscanw curs_scanw(3X)
+waddch curs_addch(3X)
+waddchnstr curs_addchstr(3X)
+waddchstr curs_addchstr(3X)
+waddnstr curs_addstr(3X)
+waddstr curs_addstr(3X)
+wattroff curs_attr(3X)
+wattron curs_attr(3X)
+wattrset curs_attr(3X)
+wbkgd curs_bkgd(3X)
+wbkgdset curs_bkgd(3X)
+wborder curs_border(3X)
+wclear curs_clear(3X)
+wclrtobot curs_clear(3X)
+wclrtoeol curs_clear(3X)
+wcursyncup curs_window(3X)
+wdelch curs_delch(3X)
+wdeleteln curs_deleteln(3X)
+wechochar curs_addch(3X)
+wenclose curs_mouse(3X)*
+werase curs_clear(3X)
+wgetch curs_getch(3X)
+wgetnstr curs_getstr(3X)
+wgetstr curs_getstr(3X)
+whline curs_border(3X)
+winch curs_inch(3X)
+winchnstr curs_inchstr(3X)
+winchstr curs_inchstr(3X)
+winnstr curs_instr(3X)
+winsch curs_insch(3X)
+winsdelln curs_deleteln(3X)
+winsertln curs_deleteln(3X)
+winsnstr curs_insstr(3X)
+winsstr curs_insstr(3X)
+winstr curs_instr(3X)
+wmove curs_move(3X)
+wnoutrefresh curs_refresh(3X)
+wprintw curs_printw(3X)
+wredrawln curs_refresh(3X)
+wrefresh curs_refresh(3X)
+wresize curs_resize(3x)*
+wscanw curs_scanw(3X)
+wscrl curs_scroll(3X)
+wsetscrreg curs_outopts(3X)
+wstandend curs_attr(3X)
+wstandout curs_attr(3X)
+wsyncdown curs_window(3X)
+wsyncup curs_window(3X)
+wtimeout curs_inopts(3X)
+wtouchln curs_touch(3X)
+wvline curs_border(3X)
+.fi
+.SH RETURN VALUE
+Routines that return an integer return \fBERR\fR upon failure and an
+integer value other than \fBERR\fR upon successful completion, unless
+otherwise noted in the routine descriptions.
+
+All macros return the value of the \fBw\fR version, except \fBsetscrreg\fR,
+\fBwsetscrreg\fR, \fBgetyx\fR, \fBgetbegyx\fR, \fBgetmaxyx\fR. The return
+values of \fBsetscrreg\fR, \fBwsetscrreg\fR, \fBgetyx\fR, \fBgetbegyx\fR, and
+\fBgetmaxyx\fR are undefined (\fIi\fR.\fIe\fR., these should not be used as the
+right-hand side of assignment statements).
+
+Routines that return pointers return \fBNULL\fR on error.
+.SH SEE ALSO
+\fBterminfo\fR(\*n) and 3X pages whose names begin "curs_" for detailed routine
+descriptions.
+.SH EXTENSIONS
+The \fBcurses\fR library can be compiled with an option (\fB-DTERMCAP_FILE\fR)
+that falls back to the old-style /etc/termcap file if the terminal setup code
+cannot find a terminfo entry corresponding to \fBTERM\fR. Use of this feature
+is not recommended, as it essentially includes an entire termcap compiler in
+the \fBcurses\fR startup code, at significant cost in core and startup cycles.
+
+Compiling with \fB-DTERMCAP_FILE\fR changes the library's initialization
+sequence in a way intended to mimic the behavior of 4.4BSD curses. If there is
+no local or system terminfo entry matching \fBTERM\fR, then the library looks
+for termcap entries in the following places: (1) if \fBTERMINFO\fR is
+undefined, in the file named by \fBTERMCAP_FILE\fR; (2) if \fBTERMINFO\fR is
+defined and begins with a slash, it is interpreted as the name of a termcap
+file to search for \fBTERM\fR; (3) otherwise, if \fBTERMINFO\fR has a leading
+string that looks like a terminal entry name list, and it matches \fBTERM\fR,
+the contents of \fBTERMINFO\fR is interpreted as a termcap; (4) if
+\fBTERMINFO\fR looks like a termcap but doesn't match \fBTERM\fR, the termcap
+file is searched for among the colon-separated paths in the environment
+variable \fBTERMPATHS\fR if that is defined, and in ~/.termcap and the file
+value of \fBTERMCAP_FILE\fR otherwise.
+
+Versions of \fBcurses\fR compiled on PC clones support display of the PC ROM
+characters (including ROM characters 0-31, which stock SVr4 curses cannot
+display). See the EXTENSIONS sections of \fBcurs_addch\fR(3x) and
+\fBcurs_attr\fR(3x).
+.SH PORTABILITY
+The \fBcurses\fR library is intended to be BASE-level conformant with the XSI
+Curses standard. Certain portions of the EXTENDED XSI Curses functionality
+(including color support) are supported. The following EXTENDED XSI Curses
+calls in support of wide (multibyte) characters are not yet implemented:
+\fBaddnwstr\fB,
+\fBaddwstr\fB,
+\fBmvaddnwstr\fB,
+\fBmvwaddnwstr\fB,
+\fBmvaddwstr\fB,
+\fBwaddnwstr\fB,
+\fBwaddwstr\fB,
+\fBadd_wch\fB,
+\fBwadd_wch\fB,
+\fBmvadd_wch\fB,
+\fBmvwadd_wch\fB,
+\fBadd_wchnstr\fB,
+\fBadd_wchstr\fB,
+\fBwadd_wchnstr\fB,
+\fBwadd_wchstr\fB,
+\fBmvadd_wchnstr\fB,
+\fBmvadd_wchstr\fB,
+\fBmvwadd_wchnstr\fB,
+\fBmvwadd_wchstr\fB,
+\fBbkgrndset\fB,
+\fBbkgrnd\fB,
+\fBgetbkgrnd\fB,
+\fBwbkgrnd\fB,
+\fBwbkgrndset\fB,
+\fBwgetbkgrnd\fB,
+\fBborder_set\fB,
+\fBwborder_set\fB,
+\fBbox_set\fB,
+\fBhline_set\fB,
+\fBmvhline_set\fB,
+\fBmvvline_set\fB,
+\fBmvwhline_set\fB,
+\fBmvwvline_set\fB,
+\fBwhline_set\fB,
+\fBvhline_set\fB,
+\fBwvline_set\fB,
+\fBecho_wchar\fB,
+\fBwecho_wchar\fB,
+\fBerasewchar\fB,
+\fBkillwchar\fB,
+\fBget_wch\fB,
+\fBmvget_wch\fB,
+\fBmvwget_ch\fB,
+\fBwget_wch\fB,
+\fBgetwchtype\fB,
+\fBget_wstr\fB,
+\fBgetn_wstr\fB,
+\fBwget_wstr\fB,
+\fBwgetn_wstr\fB,
+\fBmvget_wstr\fB,
+\fBmvgetn_wstr\fB,
+\fBmvwget_wstr\fB,
+\fBmvwgetn_wstr\fB,
+\fBinnwstr\fB,
+\fBinwstr\fB,
+\fBwinnwstr\fB,
+\fBwinwstr\fB,
+\fBmvinnwstr\fB,
+\fBmvinwstr\fB,
+\fBmvwinnwstr\fB,
+\fBmvwinwstr\fB,
+\fBins_nwstr\fB,
+\fBins_wstr\fB,
+\fBmvins_nwstr\fB,
+\fBmvins_wstr\fB,
+\fBmvwins_nwstr\fB,
+\fBmvwins_wstr\fB,
+\fBwins_nwstr\fB,
+\fBwins_wstr\fB,
+\fBins_wch\fB,
+\fBwins_wch\fB,
+\fBmvins_wch\fB,
+\fBmvwins_wch\fB,
+\fBin_wch\fB,
+\fBwin_wch\fB,
+\fBmvin_wch\fB,
+\fBmvwin_wch\fB,
+\fBinwchstr\fB,
+\fBinwchnstr\fB,
+\fBwinwchstr\fB,
+\fBwinwchnstr\fB,
+\fBmvinwchstr\fB,
+\fBmvinwchnstr\fB,
+\fBmvinwchstr\fB,
+\fBmvwinwchnstr\fB.
+.PP
+A small number of local differences (that is, individual differences between
+the XSI Curses and \fBcurses\fR calls) are described in \fBPORTABILITY\fR
+sections of the library man pages.
+.PP
+The terminfo format supported by \fBcurses\fR is binary-compatible with SVr4,
+but not conformant with XSI curses. This is because the XSI Curses drafters,
+in a remarkable fit of braindamage, changed the undocumented SVr4 capability
+\fBgetm\fR from a string to a boolean, changing the binary offsets of all
+capabilities after it in the SVr4 order and making it impossible for any
+SVr4-compatible implementation to be fully conformant.
+.PP
+The routines \fBgetmouse\fR, \fBmousemask\fR, \fBungetmouse\fR,
+\fBmouseinterval\fR, and \fBwenclose\fR relating to mouse interfacing are not
+part of XPG4, nor are they present in SVr4. See the \fBcurs_mouse\fR(3X)
+manual page for details.
+.PP
+The routine \fBwresize\fR is not part of XPG4, nor is it present in SVr4. See
+the \fBcurs_resize\fR(3X) manual page for details.
+.PP
+In historic curses versions, delays embedded in the capabilities \fBcr\fR,
+\fBind\fR, \fBcub1\fR, \fBff\fR and \fBtab\fR activated corresponding delay
+bits in the UNIX tty driver. In this implementation, all padding is done by
+NUL sends. This method is slightly more expensive, but narrows the interface
+to the UNIX kernel significantly and increases the package's portability
+correspondingly.
+.PP
+In the XSI standard and SVr4 manual pages, many entry points have prototype
+arguments of the for \fBchar *const\fR (or \fBcchar_t *const\fR, or \fBwchar_t
+*const\fR, or \fBvoid *const\fR). Depending on one's interpretation of the
+ANSI C standard (see section 3.5.4.1), these declarations are either (a)
+meaningless, or (b) meaningless and illegal. The declaration \fBconst char
+*x\fR is a modifiable pointer to unmodifiable data, but \fBchar *const x\fR' is
+an unmodifiable pointer to modifiable data. Given that C passes arguments by
+value, \fB<type> *const\fR as a formal type is at best dubious. Some compilers
+choke on the prototypes. Therefore, in this implementation, they have been
+changed to \fBconst <type> *\fR globally.
+.SH NOTES
+The header file \fB<curses.h>\fR automatically includes the header files
+\fB<stdio.h>\fR and \fB<unctrl.h>\fR.
+
+If standard output from a \fBcurses\fR program is re-directed to something
+which is not a tty, screen updates will be directed to standard error. This
+was an undocumented feature of AT&T System V Release 3 curses.
+.SH AUTHORS
+Zeyd M. Ben-Halim, Eric S. Raymond. Descends from the original pcurses
+by Pavel Curtis.
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curses.c b/lib/libcurses/curses.c
deleted file mode 100644
index 07cbb5b4afd..00000000000
--- a/lib/libcurses/curses.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)curses.c 8.3 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include "curses.h"
-
-/* Private. */
-int __echoit = 1; /* If stty indicates ECHO. */
-int __pfast;
-int __rawmode = 0; /* If stty indicates RAW mode. */
-int __noqch = 0; /*
- * If terminal doesn't have
- * insert/delete line capabilities
- * for quick change on refresh.
- */
-char AM, BS, CA, DA, EO, HC, IN, MI, MS, NC, NS, OS, PC,
- UL, XB, XN, XT, XS, XX;
-char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
- *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
- *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
- *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
- *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
- *VE, *al, *dl, *sf, *sr,
- *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM,
- *RIGHT_PARM;
-/*
- * Public.
- *
- * XXX
- * UPPERCASE isn't used by libcurses, and is left for backward
- * compatibility only.
- */
-WINDOW *curscr; /* Current screen. */
-WINDOW *stdscr; /* Standard screen. */
-int COLS; /* Columns on the screen. */
-int LINES; /* Lines on the screen. */
-int My_term = 0; /* Use Def_term regardless. */
-char *Def_term = "unknown"; /* Default terminal type. */
-char GT; /* Gtty indicates tabs. */
-char NONL; /* Term can't hack LF doing a CR. */
-char UPPERCASE; /* Terminal is uppercase only. */
diff --git a/lib/libcurses/curses.h b/lib/libcurses/curses.h
index cee7f96e013..95c2c95a5a4 100644
--- a/lib/libcurses/curses.h
+++ b/lib/libcurses/curses.h
@@ -1,341 +1,1202 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+#ifndef __NCURSES_H
+#define __NCURSES_H
+#define CURSES 1
+#define CURSES_H 1
+#define NCURSES_VERSION "1.9.9e"
+
+#ifndef _CHTYPE_T_
+#define _CHTYPE_T_ unsigned long
+typedef _CHTYPE_T_ chtype;
+#endif
+
+#include <stdio.h>
+#include <unctrl.h>
+#include <stdarg.h>
+#ifdef _XOPEN_SOURCE_EXTENDED
+#include <stddef.h> /* we want wchar_t */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+
+/* XSI and SVr4 specify that curses implements 'bool'. However, C++ may also
+ * implement it. If so, we must use the C++ compiler's type to avoid conflict
+ * with other interfaces.
*
- * @(#)curses.h 8.4 (Berkeley) 8/10/94
+ * To simplify use with/without the configuration script, we define the symbols
+ * CXX_BUILTIN_BOOL and CXX_TYPE_OF_BOOL; they're edited by the configure
+ * script.
+ */
+
+#undef TRUE
+#undef FALSE
+#define CXX_BUILTIN_BOOL 1
+#define CXX_TYPE_OF_BOOL char
+
+#if defined(__cplusplus) && CXX_BUILTIN_BOOL
+#define TRUE ((CXX_TYPE_OF_BOOL)true)
+#define FALSE ((CXX_TYPE_OF_BOOL)false)
+#else
+typedef CXX_TYPE_OF_BOOL bool;
+#define TRUE ((bool)1)
+#define FALSE ((bool)0)
+#endif
+
+/*
+ * XSI attributes. In the ncurses implementation, they are identical to the
+ * A_ attributes because attr_t is just an int. The XSI Curses attr_* and
+ * wattr_* entry points are all mapped to attr* and wattr* entry points.
*/
+#define WA_ATTRIBUTES 0xffffff00
+#define WA_NORMAL 0x00000000
+#define WA_STANDOUT 0x00010000
+#define WA_UNDERLINE 0x00020000
+#define WA_REVERSE 0x00040000
+#define WA_BLINK 0x00080000
+#define WA_DIM 0x00100000
+#define WA_BOLD 0x00200000
+#define WA_ALTCHARSET 0x00400000
+#define WA_INVIS 0x00800000
+#define WA_PROTECT 0x01000000
+#define WA_HORIZONTAL 0x02000000 /* XSI Curses attr -- not yet used */
+#define WA_LEFT 0x04000000 /* XSI Curses attr -- not yet used */
+#define WA_LOW 0x08000000 /* XSI Curses attr -- not yet used */
+#define WA_RIGHT 0x10000000 /* XSI Curses attr -- not yet used */
+#define WA_TOP 0x20000000 /* XSI Curses attr -- not yet used */
+#define WA_VERTICAL 0x40000000 /* XSI Curses attr -- not yet used */
+
+/* colors */
+extern int COLORS;
+extern int COLOR_PAIRS;
+extern unsigned char *color_pairs;
-#ifndef _CURSES_H_
-#define _CURSES_H_
+#define COLOR_BLACK 0
+#define COLOR_RED 1
+#define COLOR_GREEN 2
+#define COLOR_YELLOW 3
+#define COLOR_BLUE 4
+#define COLOR_MAGENTA 5
+#define COLOR_CYAN 6
+#define COLOR_WHITE 7
-#include <sys/types.h>
-#include <sys/cdefs.h>
+/* line graphics */
-#include <stdio.h>
+extern chtype acs_map[];
+/* VT100 symbols begin here */
+#define ACS_ULCORNER (acs_map['l']) /* upper left corner */
+#define ACS_LLCORNER (acs_map['m']) /* lower left corner */
+#define ACS_URCORNER (acs_map['k']) /* upper right corner */
+#define ACS_LRCORNER (acs_map['j']) /* lower right corner */
+#define ACS_LTEE (acs_map['t']) /* tee pointing right */
+#define ACS_RTEE (acs_map['u']) /* tee pointing left */
+#define ACS_BTEE (acs_map['v']) /* tee pointing up */
+#define ACS_TTEE (acs_map['w']) /* tee pointing down */
+#define ACS_HLINE (acs_map['q']) /* horizontal line */
+#define ACS_VLINE (acs_map['x']) /* vertical line */
+#define ACS_PLUS (acs_map['n']) /* large plus or crossover */
+#define ACS_S1 (acs_map['o']) /* scan line 1 */
+#define ACS_S9 (acs_map['s']) /* scan line 9 */
+#define ACS_DIAMOND (acs_map['`']) /* diamond */
+#define ACS_CKBOARD (acs_map['a']) /* checker board (stipple) */
+#define ACS_DEGREE (acs_map['f']) /* degree symbol */
+#define ACS_PLMINUS (acs_map['g']) /* plus/minus */
+#define ACS_BULLET (acs_map['~']) /* bullet */
+/* Teletype 5410v1 symbols begin here */
+#define ACS_LARROW (acs_map[',']) /* arrow pointing left */
+#define ACS_RARROW (acs_map['+']) /* arrow pointing right */
+#define ACS_DARROW (acs_map['.']) /* arrow pointing down */
+#define ACS_UARROW (acs_map['-']) /* arrow pointing up */
+#define ACS_BOARD (acs_map['h']) /* board of squares */
+#define ACS_LANTERN (acs_map['I']) /* lantern symbol */
+#define ACS_BLOCK (acs_map['0']) /* solid square block */
/*
- * The following #defines and #includes are present for backward
- * compatibility only. They should not be used in future code.
- *
- * START BACKWARD COMPATIBILITY ONLY.
+ * These aren't documented, but a lot of System Vs have them anyway
+ * (you can spot pprryyzz{{||}} in a lot of AT&T terminfo strings).
+ * The ACS_names may not match AT&T's, our source didn't know them.
*/
-#ifndef _CURSES_PRIVATE
-#define bool char
-#define reg register
+#define ACS_S3 (acs_map['p']) /* scan line 3 */
+#define ACS_S7 (acs_map['r']) /* scan line 7 */
+#define ACS_LEQUAL (acs_map['y']) /* less/equal */
+#define ACS_GEQUAL (acs_map['z']) /* greater/equal */
+#define ACS_PI (acs_map['{']) /* Pi */
+#define ACS_NEQUAL (acs_map['|']) /* not equal */
+#define ACS_STERLING (acs_map['}']) /* UK pound sign */
+
+/*
+ * Line drawing ACS names are of the form ACS_trbl, where t is the top, r
+ * is the right, b is the bottom, and l is the left. t, r, b, and l might
+ * be B (blank), S (single), D (double), or T (thick). The subset defined
+ * here only uses B and S.
+ */
+#define ACS_BSSB ACS_ULCORNER
+#define ACS_SSBB ACS_LLCORNER
+#define ACS_BBSS ACS_URCORNER
+#define ACS_SBBS ACS_LRCORNER
+#define ACS_SBSS ACS_RTEE
+#define ACS_SSSB ACS_LTEE
+#define ACS_SSBS ACS_BTEE
+#define ACS_BSSS ACS_TTEE
+#define ACS_BSBS ACS_HLINE
+#define ACS_SBSB ACS_VLINE
+#define ACS_SSSS ACS_PLUS
-#ifndef TRUE
-#define TRUE (1)
+#if !defined(ERR) || ((ERR) != -1)
+#define ERR (-1)
#endif
-#ifndef FALSE
-#define FALSE (0)
+
+#if !defined(OK) || ((OK) != 0)
+#define OK (0)
#endif
-#define _puts(s) tputs(s, 0, __cputchar)
-#define _putchar(c) __cputchar(c)
-
-/* Old-style terminal modes access. */
-#define baudrate() (cfgetospeed(&__baset))
-#define crmode() cbreak()
-#define erasechar() (__baset.c_cc[VERASE])
-#define killchar() (__baset.c_cc[VKILL])
-#define nocrmode() nocbreak()
-#define ospeed (cfgetospeed(&__baset))
-#endif /* _CURSES_PRIVATE */
-
-extern char GT; /* Gtty indicates tabs. */
-extern char NONL; /* Term can't hack LF doing a CR. */
-extern char UPPERCASE; /* Terminal is uppercase only. */
-
-extern int My_term; /* Use Def_term regardless. */
-extern char *Def_term; /* Default terminal type. */
-
-/* Termcap capabilities. */
-extern char AM, BS, CA, DA, EO, HC, IN, MI, MS, NC, NS, OS,
- PC, UL, XB, XN, XT, XS, XX;
-extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
- *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
- *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
- *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
- *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
- *VE, *al, *dl, *sf, *sr,
- *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM,
- *RIGHT_PARM;
-
-/* END BACKWARD COMPATIBILITY ONLY. */
-
-/* 8-bit ASCII characters. */
-#define unctrl(c) __unctrl[(c) & 0xff]
-#define unctrllen(ch) __unctrllen[(ch) & 0xff]
-
-extern char *__unctrl[256]; /* Control strings. */
-extern char __unctrllen[256]; /* Control strings length. */
+/* values for the _flags member */
+#define _SUBWIN 0x01 /* is this a sub-window? */
+#define _ENDLINE 0x02 /* is the window flush right? */
+#define _FULLWIN 0x04 /* is the window full-screen? */
+#define _SCROLLWIN 0x08 /* bottom edge is at screen bottom? */
+#define _ISPAD 0x10 /* is this window a pad? */
+#define _HASMOVED 0x20 /* has cursor moved since last refresh? */
+#define _NEED_WRAP 0x40 /* cursor wrap pending */
/*
- * A window an array of __LINE structures pointed to by the 'lines' pointer.
- * A line is an array of __LDATA structures pointed to by the 'line' pointer.
- *
- * IMPORTANT: the __LDATA structure must NOT induce any padding, so if new
- * fields are added -- padding fields with *constant values* should ensure
- * that the compiler will not generate any padding when storing an array of
- * __LDATA structures. This is to enable consistent use of memcmp, and memcpy
- * for comparing and copying arrays.
+ * this value is used in the firstchar and lastchar fields to mark
+ * unchanged lines
+ */
+#define _NOCHANGE -1
+
+/*
+ * this value is used in the oldindex field to mark lines created by insertions
+ * and scrolls.
*/
-typedef struct {
- char ch; /* the actual character */
-
-#define __STANDOUT 0x01 /* Added characters are standout. */
- char attr; /* attributes of character */
-} __LDATA;
-
-#define __LDATASIZE (sizeof(__LDATA))
-
-typedef struct {
-#define __ISDIRTY 0x01 /* Line is dirty. */
-#define __ISPASTEOL 0x02 /* Cursor is past end of line */
-#define __FORCEPAINT 0x04 /* Force a repaint of the line */
- unsigned int flags;
- unsigned int hash; /* Hash value for the line. */
- size_t *firstchp, *lastchp; /* First and last chngd columns ptrs */
- size_t firstch, lastch; /* First and last changed columns. */
- __LDATA *line; /* Pointer to the line text. */
-} __LINE;
-
-typedef struct __window { /* Window structure. */
- struct __window *nextp, *orig; /* Subwindows list and parent. */
- size_t begy, begx; /* Window home. */
- size_t cury, curx; /* Current x, y coordinates. */
- size_t maxy, maxx; /* Maximum values for curx, cury. */
- short ch_off; /* x offset for firstch/lastch. */
- __LINE **lines; /* Array of pointers to the lines */
- __LINE *lspace; /* line space (for cleanup) */
- __LDATA *wspace; /* window space (for cleanup) */
-
-#define __ENDLINE 0x001 /* End of screen. */
-#define __FLUSH 0x002 /* Fflush(stdout) after refresh. */
-#define __FULLWIN 0x004 /* Window is a screen. */
-#define __IDLINE 0x008 /* Insert/delete sequences. */
-#define __SCROLLWIN 0x010 /* Last char will scroll window. */
-#define __SCROLLOK 0x020 /* Scrolling ok. */
-#define __CLEAROK 0x040 /* Clear on next refresh. */
-#define __WSTANDOUT 0x080 /* Standout window */
-#define __LEAVEOK 0x100 /* If curser left */
- unsigned int flags;
-} WINDOW;
-
-/* Curses external declarations. */
-extern WINDOW *curscr; /* Current screen. */
-extern WINDOW *stdscr; /* Standard screen. */
-
-extern struct termios __orig_termios; /* Terminal state before curses */
-extern struct termios __baset; /* Our base terminal state */
-extern int __tcaction; /* If terminal hardware set. */
-
-extern int COLS; /* Columns on the screen. */
-extern int LINES; /* Lines on the screen. */
-
-extern char *ttytype; /* Full name of current terminal. */
-
-#define ERR (0) /* Error return. */
-#define OK (1) /* Success return. */
-
-/* Standard screen pseudo functions. */
-#define addbytes(s, n) __waddbytes(stdscr, s, n, 0)
-#define addch(ch) waddch(stdscr, ch)
-#define addnstr(s, n) waddnstr(stdscr, s, n)
-#define addstr(s) __waddbytes(stdscr, s, strlen(s), 0)
-#define clear() wclear(stdscr)
-#define clrtobot() wclrtobot(stdscr)
-#define clrtoeol() wclrtoeol(stdscr)
-#define delch() wdelch(stdscr)
-#define deleteln() wdeleteln(stdscr)
-#define erase() werase(stdscr)
-#define getch() wgetch(stdscr)
-#define getstr(s) wgetstr(stdscr, s)
-#define inch() winch(stdscr)
-#define insch(ch) winsch(stdscr, ch)
-#define insertln() winsertln(stdscr)
-#define move(y, x) wmove(stdscr, y, x)
-#define refresh() wrefresh(stdscr)
-#define standend() wstandend(stdscr)
-#define standout() wstandout(stdscr)
-#define waddbytes(w, s, n) __waddbytes(w, s, n, 0)
-#define waddstr(w, s) __waddbytes(w, s, strlen(s), 0)
-
-/* Standard screen plus movement pseudo functions. */
-#define mvaddbytes(y, x, s, n) mvwaddbytes(stdscr, y, x, s, n)
-#define mvaddch(y, x, ch) mvwaddch(stdscr, y, x, ch)
-#define mvaddnstr(y, x, s, n) mvwaddnstr(stdscr, y, x, s, n)
-#define mvaddstr(y, x, s) mvwaddstr(stdscr, y, x, s)
-#define mvdelch(y, x) mvwdelch(stdscr, y, x)
-#define mvgetch(y, x) mvwgetch(stdscr, y, x)
-#define mvgetstr(y, x, s) mvwgetstr(stdscr, y, x, s)
-#define mvinch(y, x) mvwinch(stdscr, y, x)
-#define mvinsch(y, x, c) mvwinsch(stdscr, y, x, c)
-#define mvwaddbytes(w, y, x, s, n) \
- (wmove(w, y, x) == ERR ? ERR : __waddbytes(w, s, n, 0))
-#define mvwaddch(w, y, x, ch) \
- (wmove(w, y, x) == ERR ? ERR : waddch(w, ch))
-#define mvwaddnstr(w, y, x, s, n) \
- (wmove(w, y, x) == ERR ? ERR : waddnstr(w, s, n))
-#define mvwaddstr(w, y, x, s) \
- (wmove(w, y, x) == ERR ? ERR : __waddbytes(w, s, strlen(s), 0))
-#define mvwdelch(w, y, x) \
- (wmove(w, y, x) == ERR ? ERR : wdelch(w))
-#define mvwgetch(w, y, x) \
- (wmove(w, y, x) == ERR ? ERR : wgetch(w))
-#define mvwgetstr(w, y, x, s) \
- (wmove(w, y, x) == ERR ? ERR : wgetstr(w, s))
-#define mvwinch(w, y, x) \
- (wmove(w, y, x) == ERR ? ERR : winch(w))
-#define mvwinsch(w, y, x, c) \
- (wmove(w, y, x) == ERR ? ERR : winsch(w, c))
-
-/* Psuedo functions. */
-#define clearok(w, bf) \
- ((bf) ? ((w)->flags |= __CLEAROK) : ((w)->flags &= ~__CLEAROK))
-#define flushok(w, bf) \
- ((bf) ? ((w)->flags |= __FLUSH) : ((w)->flags &= ~__FLUSH))
-#define getyx(w, y, x) \
- (y) = (w)->cury, (x) = (w)->curx
-#define leaveok(w, bf) \
- ((bf) ? ((w)->flags |= __LEAVEOK) : ((w)->flags &= ~__LEAVEOK))
-#define scrollok(w, bf) \
- ((bf) ? ((w)->flags |= __SCROLLOK) : ((w)->flags &= ~__SCROLLOK))
-#define winch(w) \
- ((w)->lines[(w)->cury]->line[(w)->curx].ch & 0177)
-
-/* Public function prototypes. */
-__BEGIN_DECLS
-int box __P((WINDOW *, int, int));
-int cbreak __P((void));
-int delwin __P((WINDOW *));
-int echo __P((void));
-int endwin __P((void));
-char *fullname __P((char *, char *));
-char *getcap __P((char *));
-int gettmode __P((void));
-void idlok __P((WINDOW *, int));
-WINDOW *initscr __P((void));
-char *longname __P((char *, char *));
-int mvcur __P((int, int, int, int));
-int mvprintw __P((int, int, const char *, ...));
-int mvscanw __P((int, int, const char *, ...));
-int mvwin __P((WINDOW *, int, int));
-int mvwprintw __P((WINDOW *, int, int, const char *, ...));
-int mvwscanw __P((WINDOW *, int, int, const char *, ...));
-WINDOW *newwin __P((int, int, int, int));
-int nl __P((void));
-int nocbreak __P((void));
-int noecho __P((void));
-int nonl __P((void));
-int noraw __P((void));
-int overlay __P((WINDOW *, WINDOW *));
-int overwrite __P((WINDOW *, WINDOW *));
-int printw __P((const char *, ...));
-int raw __P((void));
-int resetty __P((void));
-int savetty __P((void));
-int scanw __P((const char *, ...));
-int scroll __P((WINDOW *));
-int setterm __P((char *));
-int sscans __P((WINDOW *, const char *, ...));
-WINDOW *subwin __P((WINDOW *, int, int, int, int));
-int suspendwin __P((void));
-int touchline __P((WINDOW *, int, int, int));
-int touchoverlap __P((WINDOW *, WINDOW *));
-int touchwin __P((WINDOW *));
-int vwprintw __P((WINDOW *, const char *, _BSD_VA_LIST_));
-int vwscanw __P((WINDOW *, const char *, _BSD_VA_LIST_));
-int waddch __P((WINDOW *, int));
-int waddnstr __P((WINDOW *, const char *, int));
-int wclear __P((WINDOW *));
-int wclrtobot __P((WINDOW *));
-int wclrtoeol __P((WINDOW *));
-int wdelch __P((WINDOW *));
-int wdeleteln __P((WINDOW *));
-int werase __P((WINDOW *));
-int wgetch __P((WINDOW *));
-int wgetstr __P((WINDOW *, char *));
-int winsch __P((WINDOW *, int));
-int winsertln __P((WINDOW *));
-int wmove __P((WINDOW *, int, int));
-int wprintw __P((WINDOW *, const char *, ...));
-int wrefresh __P((WINDOW *));
-int wscanw __P((WINDOW *, const char *, ...));
-int wstandend __P((WINDOW *));
-int wstandout __P((WINDOW *));
-int vwprintw __P((WINDOW *, const char *, _BSD_VA_LIST_));
-
-/* Private functions that are needed for user programs prototypes. */
-void __cputchar __P((int));
-int __waddbytes __P((WINDOW *, const char *, int, int));
-__END_DECLS
-
-/* Private functions. */
-#ifdef _CURSES_PRIVATE
-void __CTRACE __P((const char *, ...));
-unsigned int __hash __P((char *, int));
-void __id_subwins __P((WINDOW *));
-int __mvcur __P((int, int, int, int, int));
-void __restore_stophandler __P((void));
-void __set_stophandler __P((void));
-void __set_subwin __P((WINDOW *, WINDOW *));
-void __startwin __P((void));
-void __stop_signal_handler __P((int));
-void __swflags __P((WINDOW *));
-int __touchline __P((WINDOW *, int, int, int, int));
-int __touchwin __P((WINDOW *));
-char *__tscroll __P((const char *, int, int));
-int __waddch __P((WINDOW *, __LDATA *));
-
-/* Private #defines. */
-#define min(a,b) (a < b ? a : b)
-#define max(a,b) (a > b ? a : b)
-
-/* Private externs. */
-extern int __echoit;
-extern int __endwin;
-extern int __pfast;
-extern int __rawmode;
-extern int __noqch;
+#define _NEWINDEX -1
+
+typedef struct screen SCREEN;
+typedef struct _win_st WINDOW;
+
+typedef chtype attr_t; /* ...must be at least as wide as chtype */
+
+#ifdef _XOPEN_SOURCE_EXTENDED
+#ifndef _WCHAR_T
+typedef unsigned long wchar_t;
+#endif /* _WCHAR_T */
+#ifndef _WINT_T
+typedef long int wint_t;
+#endif /* _WINT_T */
+
+#define CCHARW_MAX 5
+typedef struct
+{
+ attr_t attr;
+ wchar_t chars[CCHARW_MAX];
+}
+cchar_t;
+#endif /* _XOPEN_SOURCE_EXTENDED */
+
+struct _win_st {
+ short _cury, _curx; /* current cursor position */
+
+ /* window location and size */
+ short _maxy, _maxx; /* maximums of x and y, NOT window size */
+ short _begy, _begx; /* screen coords of upper-left-hand corner */
+
+ short _flags; /* window state flags */
+
+ /* attribute tracking */
+ attr_t _attrs; /* current attribute for non-space character */
+ chtype _bkgd; /* current background char/attribute pair */
+
+ /* option values set by user */
+ bool _notimeout; /* no time out on function-key entry? */
+ bool _clear; /* consider all data in the window invalid? */
+ bool _leaveok; /* OK to not reset cursor on exit? */
+ bool _scroll; /* OK to scroll this window? */
+ bool _idlok; /* OK to use insert/delete line? */
+ bool _idcok; /* OK to use insert/delete char? */
+ bool _immed; /* window in immed mode? (not yet used) */
+ bool _sync; /* window in sync mode? */
+ bool _use_keypad; /* process function keys into KEY_ symbols? */
+ int _delay; /* 0 = nodelay, <0 = blocking, >0 = delay */
+
+ /* the actual line data */
+ struct ldat
+ {
+ chtype *text; /* text of the line */
+ short firstchar; /* first changed character in the line */
+ short lastchar; /* last changed character in the line */
+ short oldindex; /* index of the line at last update */
+ }
+ *_line;
+
+ /* global screen state */
+ short _regtop; /* top line of scrolling region */
+ short _regbottom; /* bottom line of scrolling region */
+
+ /* these are used only if this is a sub-window */
+ int _parx; /* x coordinate of this window in parent */
+ int _pary; /* y coordinate of this window in parent */
+ WINDOW *_parent; /* pointer to parent if a sub-window */
+
+ /* these are used only if this is a pad */
+ struct pdat
+ {
+ short _pad_y, _pad_x;
+ short _pad_top, _pad_left;
+ short _pad_bottom, _pad_right;
+ } _pad;
+};
+
+extern WINDOW *stdscr, *curscr, *newscr;
+
+extern int LINES, COLS, TABSIZE;
+
+/*
+ * This global was an undocumented feature under AIX curses.
+ */
+extern int ESCDELAY; /* ESC expire time in milliseconds */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern char ttytype[]; /* needed for backward compatibility */
+
+/*
+ * GCC (and some other compilers) define '__attribute__'; we're using this
+ * macro to alert the compiler to flag inconsistencies in printf/scanf-like
+ * function calls. Just in case '__attribute__' isn't defined, make a dummy.
+ */
+#if !defined(__GNUC__) && !defined(__attribute__)
+#define __attribute__(p) /* nothing */
#endif
-/* Termcap functions. */
-__BEGIN_DECLS
-int tgetent __P((char *, char *));
-int tgetnum __P((char *));
-int tgetflag __P((char *));
-char *tgetstr __P((char *, char **));
-char *tgoto __P((char *, int, int));
-void tputs __P((char *, int, void (*)(int)));
-__END_DECLS
-
-#endif /* !_CURSES_H_ */
+/*
+ * Function prototypes. This is the complete XSI Curses list of required
+ * functions. Those marked `generated' will have sources generated from the
+ * macro definitions later in this file, in order to satisfy XPG4.2
+ * requirements.
+ */
+
+extern int addch(const chtype); /* generated */
+extern int addchnstr(const chtype *, int); /* generated */
+extern int addchstr(const chtype *); /* generated */
+extern int addnstr(const char *, int); /* generated */
+extern int addstr(const char *); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int addnwstr(const wchar_t *, int); /* missing */
+extern int addwstr(const wchar_t *); /* missing */
+extern int add_wch(const cchar_t *); /* missing */
+extern int add_wchnstr(const cchar_t *, int); /* missing */
+extern int add_wchstr(const cchar_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int attroff(int); /* generated */
+extern int attron(int); /* generated */
+extern int attrset(int); /* generated */
+extern int attr_get(void); /* generated */
+extern int attr_off(int); /* implemented */
+extern int attr_on(int); /* implemented */
+extern int attr_set(int); /* generated */
+extern int baudrate(void); /* implemented */
+extern int beep(void); /* implemented */
+extern int bkgd(chtype); /* generated */
+extern void bkgdset(chtype); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int bkgrndset(const cchar_t *); /* missing */
+extern int bkgrnd(const cchar_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int border(chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int border_set(cchar_t,cchar_t,cchar_t,cchar_t,cchar_t,cchar_t,cchar_t,cchar_t); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int box(WINDOW *, chtype, chtype); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int box_set(WINDOW *, cchar_t, cchar_t); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern bool can_change_color(void); /* implemented */
+extern int cbreak(void); /* implemented */
+extern int chgat(int, attr_t, short, const void *); /* generated */
+extern int clear(void); /* generated */
+extern int clearok(WINDOW *,bool); /* implemented */
+extern int clrtobot(void); /* generated */
+extern int clrtoeol(void); /* generated */
+extern int color_content(short,short*,short*,short*); /* implemented */
+extern int COLOR_PAIR(int); /* generated */
+extern int copywin(const WINDOW*,WINDOW*,int,int,int,int,int,int,int); /* implemented */
+extern int curs_set(int); /* implemented */
+extern int def_prog_mode(void); /* implemented */
+extern int def_shell_mode(void); /* implemented */
+extern int delay_output(float); /* implemented */
+extern int delch(void); /* generated */
+extern void delscreen(SCREEN *); /* implemented */
+extern int delwin(WINDOW *); /* implemented */
+extern int deleteln(void); /* generated */
+extern WINDOW *derwin(WINDOW *,int,int,int,int); /* implemented */
+extern int doupdate(void); /* implemented */
+extern WINDOW *dupwin(WINDOW *); /* implemented */
+extern int echo(void); /* implemented */
+extern int echochar(const chtype); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int echo_wchar(const cchar_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int endwin(void); /* implemented */
+extern char erasechar(void); /* implemented */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int erase_wchar(wchar_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern void filter(void); /* implemented */
+extern int flash(void); /* implemented */
+extern int flushinp(void); /* implemented */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern chtype getbkgd(WINDOW *); /* missing */
+extern int getbkgrnd(cchar_t *); /* missing */
+extern int getcchar(const cchar_t *, wchar_t*, attr_t*, short*, void*); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int getch(void); /* generated */
+extern int getnstr(char *, int); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int getn_wstr(wint_t *, int n); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int getstr(char *); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int get_wch(wint_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern WINDOW *getwin(FILE *); /* not in XPG4 */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int get_wstr(wint_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int halfdelay(int); /* implemented */
+extern int has_colors(void); /* implemented */
+extern int has_ic(void); /* implemented */
+extern int has_il(void); /* implemented */
+extern int hline(chtype, int); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int hline_set(const cchar_t *, int); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int idcok(WINDOW *, bool); /* implemented */
+extern int idlok(WINDOW *, bool); /* implemented */
+extern int immedok(WINDOW *, bool); /* implemented */
+extern chtype inch(void); /* generated */
+extern int inchnstr(chtype *, int); /* generated */
+extern int inchstr(chtype *); /* generated */
+extern WINDOW *initscr(void); /* implemented */
+extern int init_color(short,short,short,short); /* implemented */
+extern int init_pair(short,short,short); /* implemented */
+extern int innstr(char *, int); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int innwstr(wchar_t *, int); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int insch(chtype); /* generated */
+extern int insdelln(int); /* generated */
+extern int insertln(void); /* generated */
+extern int insnstr(const char *, int); /* generated */
+extern int insstr(const char *); /* generated */
+extern int instr(char *); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int ins_nwstr(const wchar_t *, int); /* missing */
+extern int ins_wch(const cchar_t *); /* missing */
+extern int ins_wstr(const wchar_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int intrflush(WINDOW *,bool); /* implemented */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int inwstr(wchar_t *); /* missing */
+extern int in_wch(const cchar_t *); /* missing */
+extern int in_wchstr(const cchar_t *); /* missing */
+extern int in_wchntr(const cchar_t *, int); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int isendwin(void); /* implemented */
+extern int is_linetouched(WINDOW *,int); /* implemented */
+extern int is_wintouched(WINDOW *); /* implemented */
+extern const char *keyname(int); /* implemented */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int key_name(wchar_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int keypad(WINDOW *,bool); /* implemented */
+extern char killchar(void); /* implemented */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int killwchar(wchar_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int leaveok(WINDOW *,bool); /* implemented */
+extern char *longname(void); /* implemented */
+extern int meta(WINDOW *,bool); /* implemented */
+extern int move(int, int); /* generated */
+extern int mvaddch(int, int, const chtype); /* generated */
+extern int mvaddchnstr(int, int, const chtype *, int); /* generated */
+extern int mvaddchstr(int, int, const chtype *); /* generated */
+extern int mvaddnstr(int, int, const char *, int); /* generated */
+extern int mvaddstr(int, int, const char *); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int mvaddnwstr(int, int, const wchar_t *, int); /* missing */
+extern int mvaddwstr(int, int, const wchar_t *); /* missing */
+extern int mvadd_wch(int, int, const cchar_t *); /* missing */
+extern int mvadd_wchnstr(int, int, const cchar_t *, int);/* missing */
+extern int mvadd_wchstr(int, int, const cchar_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int mvchgat(int, int, int, attr_t, short, const void *); /* generated */
+extern int mvcur(int,int,int,int); /* implemented */
+extern int mvdelch(int, int); /* generated */
+extern int mvderwin(WINDOW *, int, int); /* implemented */
+extern int mvgetch(int, int); /* generated */
+extern int mvgetnstr(int, int, char *, int); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int mvgetn_wstr(int, int, wint_t *, int n); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int mvgetstr(int, int, char *); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int mvget_wch(int, int, wint_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int mvget_wstr(int, int, wint_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int mvhline(int, int, chtype, int); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int mvhline_set(int, int, const cchar_t *, int); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern chtype mvinch(int, int); /* generated */
+extern int mvinchnstr(int, int, chtype *, int); /* generated */
+extern int mvinchstr(int, int, chtype *); /* generated */
+extern int mvinnstr(int, int, char *, int); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int mvinnwstr(int, int, wchar_t *, int); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int mvinsch(int, int, chtype); /* generated */
+extern int mvinsnstr(int, int, const char *, int); /* generated */
+extern int mvinsstr(int, int, const char *); /* generated */
+extern int mvinstr(int, int, char *); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int mvins_nwstr(int, int, const wchar_t *, int); /* missing */
+extern int mvins_wch(int, int, const cchar_t *); /* missing */
+extern int mvins_wstr(int, int, const wchar_t *); /* missing */
+extern int mvinwstr(int, int, wchar_t *); /* missing */
+extern int mvin_wch(int, int, const cchar_t *); /* missing */
+extern int mvin_wchstr(int, int, const cchar_t *); /* missing */
+extern int mvin_wchntr(int, int, const cchar_t *, int); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int mvprintw(int,int,const char *,...); /* implemented */
+extern int mvscanw(int,int,const char *,...); /* implemented */
+extern int mvvline(int, int, chtype, int); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int mvvline_set(int, int, const cchar_t *, int); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int mvwaddch(WINDOW *, int, int, const chtype); /* generated */
+extern int mvwaddchnstr(WINDOW *, int, int, const chtype *, int);/* generated */
+extern int mvwaddchstr(WINDOW *, int, int, const chtype *); /* generated */
+extern int mvwaddnstr(WINDOW *, int, int, const char *, int); /* generated */
+extern int mvwaddstr(WINDOW *, int, int, const char *); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int mvwaddnwstr(WINDOW *, int, int, const wchar_t *, int);/* missing */
+extern int mvwaddwstr(WINDOW *, int, int, const wchar_t *); /* missing */
+extern int mvwadd_wch(WINDOW *, int, int, const cchar_t *); /* missing */
+extern int mvwadd_wchnstr(WINDOW *, int, int, const cchar_t *, int); /* missing */
+extern int mvwadd_wchstr(WINDOW *, int, int, const cchar_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int mvwchgat(WINDOW *, int, int, int, attr_t, short, const void *);/* generated */
+extern int mvwdelch(WINDOW *, int, int); /* generated */
+extern int mvwgetch(WINDOW *, int, int); /* generated */
+extern int mvwgetnstr(WINDOW *, int, int, char *, int); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int mvwgetn_wstr(WINDOW *, int, int, wint_t *, int n);/* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int mvwgetstr(WINDOW *, int, int, char *); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int mvwget_wch(WINDOW *, int, int, wint_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int mvwget_wstr(WINDOW *, int, int, wint_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int mvwhline(WINDOW *, int, int, chtype, int); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int mvwhline_set(WINDOW *, int, int, const cchar_t *, int);/* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int mvwin(WINDOW *,int,int); /* implemented */
+extern chtype mvwinch(WINDOW *, int, int); /* generated */
+extern int mvwinchnstr(WINDOW *, int, int, chtype *, int); /* generated */
+extern int mvwinchstr(WINDOW *, int, int, chtype *); /* generated */
+extern int mvwinnstr(WINDOW *, int, int, char *, int); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int mvwinnwstr(WINDOW *, int, int, wchar_t *, int); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int mvwinsch(WINDOW *, int, int, chtype); /* generated */
+extern int mvwinsnstr(WINDOW *, int, int, const char *, int); /* generated */
+extern int mvwinsstr(WINDOW *, int, int, const char *); /* generated */
+extern int mvwinstr(WINDOW *, int, int, char *); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int mvwins_nwstr(WINDOW *, int,int, const wchar_t *,int); /* missing */
+extern int mvwins_wch(WINDOW *, int, int, const cchar_t *); /* missing */
+extern int mvwins_wstr(WINDOW *, int, int, const wchar_t *); /* missing */
+extern int mvwinwstr(WINDOW *, int, int, wchar_t *); /* missing */
+extern int mvwin_wch(WINDOW *, int, int, const cchar_t *); /* missing */
+extern int mvwin_wchnstr(WINDOW *, int,int,const cchar_t *,int); /* missing */
+extern int mvwin_wchstr(WINDOW *, int, int, const cchar_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int mvwprintw(WINDOW*,int,int,const char *,...); /* implemented */
+extern int mvwscanw(WINDOW *,int,int,const char *,...); /* implemented */
+extern int mvwvline(WINDOW *,int, int, chtype, int); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int mvwvline_set(WINDOW *, int,int, const cchar_t *,int); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int napms(int); /* implemented */
+extern WINDOW *newpad(int,int); /* implemented */
+extern SCREEN *newterm(const char *,FILE *,FILE *); /* implemented */
+extern WINDOW *newwin(int,int,int,int); /* implemented */
+extern int nl(void); /* implemented */
+extern int nocbreak(void); /* implemented */
+extern int nodelay(WINDOW *,bool); /* implemented */
+extern int noecho(void); /* implemented */
+extern int nonl(void); /* implemented */
+extern int noqiflush(void); /* implemented */
+extern int noraw(void); /* implemented */
+extern int notimeout(WINDOW *,bool); /* implemented */
+extern int overlay(const WINDOW*,WINDOW *); /* implemented */
+extern int overwrite(const WINDOW*,WINDOW *); /* implemented */
+extern int pair_content(short,short*,short*); /* implemented */
+extern int PAIR_NUMBER(int); /* generated */
+extern int pechochar(WINDOW *, chtype); /* implemented */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int pecho_wchar(WINDOW *, const cchar_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int pnoutrefresh(WINDOW*,int,int,int,int,int,int);/* implemented */
+extern int prefresh(WINDOW *,int,int,int,int,int,int); /* implemented */
+extern int printw(const char *,...); /* implemented */
+extern int putp(const char *); /* implemented */
+extern int putwin(WINDOW *, FILE *); /* implemented */
+extern int qiflush(void); /* implemented */
+extern int raw(void); /* implemented */
+extern int redrawwin(WINDOW *); /* generated */
+extern int refresh(void); /* generated */
+extern int resetty(void); /* implemented */
+extern int reset_prog_mode(void); /* implemented */
+extern int reset_shell_mode(void); /* implemented */
+extern int ripoffline(int line, int (*init)(WINDOW *, int));/* implemented */
+extern int savetty(void); /* implemented */
+extern int scanw(const char *,...); /* implemented */
+extern int scr_dump(const char *); /* implemented */
+extern int scr_init(const char *); /* implemented */
+extern int scrl(int); /* generated */
+extern int scroll(WINDOW *); /* generated */
+extern int scrollok(WINDOW *,bool); /* implemented */
+extern int scr_restore(const char *); /* implemented */
+extern int scr_set(const char *); /* implemented */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int setcchar(cchar_t *, wchar_t *, attr_t, short, const void *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int setscrreg(int,int); /* generated */
+extern SCREEN *set_term(SCREEN *); /* implemented */
+extern int slk_attroff(chtype); /* implemented */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int slk_attr_off(attr_t); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int slk_attron(chtype); /* implemented */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int slk_attr_on(attr_t); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int slk_attrset(chtype); /* implemented */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int slk_attr_set(attr_t); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int slk_clear(void); /* implemented */
+extern int slk_init(int); /* implemented */
+extern char *slk_label(int); /* implemented */
+extern int slk_noutrefresh(void); /* implemented */
+extern int slk_refresh(void); /* implemented */
+extern int slk_restore(void); /* implemented */
+extern int slk_set(int,const char *,int); /* implemented */
+extern int slk_touch(void); /* implemented */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int slk_wset(int, wchar_t *, int); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int standout(void); /* generated */
+extern int standend(void); /* generated */
+extern int start_color(void); /* implemented */
+extern WINDOW *subpad(WINDOW *, int, int, int, int); /* implemented */
+extern WINDOW *subwin(WINDOW *,int,int,int,int); /* implemented */
+extern int syncok(WINDOW *win, bool); /* implemented */
+extern attr_t termattrs(void); /* implemented */
+extern char *termname(void); /* implemented */
+extern int tigetflag(const char *); /* implemented */
+extern int tigetnum(const char *); /* implemented */
+extern char *tigetstr(const char *); /* implemented */
+extern int timeout(int); /* implemented */
+extern int typeahead(int); /* implemented */
+extern int ungetch(int); /* implemented */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int unget_wch(const wchar_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int untouchwin(WINDOW *); /* generated */
+extern int vidattr(chtype); /* implemented */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int vid_attr(attr_t); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int vidputs(chtype, int (*)(int)); /* implemented */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int vid_puts(attr_t, int (*)(int)); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int vline(chtype, int); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int vline_set(const cchar_t *, int); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int vwprintw(WINDOW *,const char *,va_list); /* implemented */
+extern int vw_printw(WINDOW *,const char *,va_list); /* implemented */
+extern int vwscanw(WINDOW *,const char *,va_list); /* implemented */
+extern int vw_scanw(WINDOW *,const char *,va_list); /* implemented */
+extern int waddch(WINDOW *, const chtype); /* implemented */
+extern int waddchnstr(WINDOW *,const chtype *const,int); /* implemented */
+extern int waddchstr(WINDOW *,const chtype *); /* generated */
+extern int waddnstr(WINDOW *,const char *const,int); /* implemented */
+extern int waddstr(WINDOW *,const char *); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int waddwstr(WINDOW *,const wchar_t *); /* missing */
+extern int wadd_wch(WINDOW *,const cchar_t *); /* missing */
+extern int wadd_wchnstr(WINDOW *,const cchar_t *,int); /* missing */
+extern int wadd_wchstr(WINDOW *,const cchar_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int wattron(WINDOW *, int); /* generated */
+extern int wattroff(WINDOW *, int); /* generated */
+extern int wattrset(WINDOW *, int); /* generated */
+extern attr_t wattr_get(WINDOW *); /* generated */
+extern int wattr_on(WINDOW *, const attr_t); /* implemented */
+extern int wattr_off(WINDOW *, const attr_t); /* implemented */
+extern int wattr_set(WINDOW *, attr_t); /* implemented */
+extern int wbkgd(WINDOW *,const chtype); /* implemented */
+extern void wbkgdset(WINDOW *,chtype); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int wbkgrndset(WINDOW *,const cchar_t *); /* missing */
+extern int wbkgrnd(WINDOW *,const cchar_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int wborder(WINDOW *,chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype); /* implemented */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int wborder_set(WINDOW *,cchar_t,cchar_t,cchar_t,cchar_t,cchar_t,cchar_t,cchar_t,cchar_t); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int wchgat(WINDOW *, int, attr_t, short, const void *);/* implemented */
+extern int wclear(WINDOW *); /* implemented */
+extern int wclrtobot(WINDOW *); /* implemented */
+extern int wclrtoeol(WINDOW *); /* implemented */
+extern void wcursyncup(WINDOW *); /* implemented */
+extern int wdelch(WINDOW *); /* implemented */
+extern int wdeleteln(WINDOW *); /* generated */
+extern int wechochar(WINDOW *, const chtype); /* implemented */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int wecho_wchar(WINDOW *, const cchar_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int werase(WINDOW *); /* implemented */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int wgetbkgrnd(WINDOW *, cchar_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int wgetch(WINDOW *); /* implemented */
+extern int wgetnstr(WINDOW *,char *,int); /* implemented */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int wgetn_wstr(WINDOW *,wint_t *, int); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int wgetstr(WINDOW *, char *); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int wget_wch(WINDOW *, wint_t *); /* missing */
+extern int wget_wstr(WINDOW *, wint_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int whline(WINDOW *, chtype, int); /* implemented */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int whline_set(WINDOW *, const cchar_t *, int); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern chtype winch(WINDOW *); /* generated */
+extern int winchnstr(WINDOW *, chtype *, int); /* implemented */
+extern int winchstr(WINDOW *, chtype *); /* generated */
+extern int winnstr(WINDOW *, char *, int); /* implemented */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int winnwstr(WINDOW *, wchar_t *, int); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int winsch(WINDOW *, chtype); /* implemented */
+extern int winsdelln(WINDOW *,int); /* implemented */
+extern int winsertln(WINDOW *); /* generated */
+extern int winsnstr(WINDOW *, const char *,int); /* implemented */
+extern int winsstr(WINDOW *, const char *); /* generated */
+extern int winstr(WINDOW *, char *); /* generated */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int wins_nwstr(WINDOW *, const wchar_t *, int); /* missing */
+extern int wins_wch(WINDOW *, const cchar_t *); /* missing */
+extern int wins_wstr(WINDOW *, const wchar_t *); /* missing */
+extern int winwstr(WINDOW *, wchar_t *); /* missing */
+extern int win_wch(WINDOW *, const cchar_t *); /* missing */
+extern int win_wchnstr(WINDOW *, const cchar_t *, int); /* missing */
+extern int win_wchstr(WINDOW *, const cchar_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int wmove(WINDOW *,int,int); /* implemented */
+extern int wnoutrefresh(WINDOW *); /* implemented */
+extern int wprintw(WINDOW *,const char *,...); /* implemented */
+extern int wredrawln(WINDOW *,int,int); /* implemented */
+extern int wrefresh(WINDOW *); /* implemented */
+extern int wresize(WINDOW *, int, int); /* implemented */
+extern int wscanw(WINDOW *,const char *,...); /* implemented */
+extern int wscrl(WINDOW *,int); /* implemented */
+extern int wsetscrreg(WINDOW *,int,int); /* implemented */
+extern int wstandout(WINDOW *); /* generated */
+extern int wstandend(WINDOW *); /* generated */
+extern void wsyncdown(WINDOW *); /* implemented */
+extern void wsyncup(WINDOW *); /* implemented */
+extern int wtimeout(WINDOW *,int); /* implemented */
+extern int wtouchln(WINDOW *,int,int,int); /* implemented */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern wchar_t wunctrl(cchar_t *); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int wvline(WINDOW *,chtype,int); /* implemented */
+#ifdef _XOPEN_SOURCE_EXTENDED
+extern int wvline_set(WINDOW *, const cchar_t *, int); /* missing */
+#endif /* _XOPEN_SOURCE_EXTENDED */
+
+#ifdef __cplusplus
+}
+#endif
+
+/* attributes */
+#define A_ATTRIBUTES 0xffffff00
+#define A_NORMAL 0x00000000
+#define A_STANDOUT 0x00010000
+#define A_UNDERLINE 0x00020000
+#define A_REVERSE 0x00040000
+#define A_BLINK 0x00080000
+#define A_DIM 0x00100000
+#define A_BOLD 0x00200000
+#define A_ALTCHARSET 0x00400000
+#define A_INVIS 0x00800000
+#define A_PROTECT 0x01000000
+#define A_HORIZONTAL 0x02000000 /* XSI Curses attr -- not yet used */
+#define A_LEFT 0x04000000 /* XSI Curses attr -- not yet used */
+#define A_LOW 0x08000000 /* XSI Curses attr -- not yet used */
+#define A_RIGHT 0x10000000 /* XSI Curses attr -- not yet used */
+#define A_TOP 0x20000000 /* XSI Curses attr -- not yet used */
+#define A_VERTICAL 0x40000000 /* XSI Curses attr -- not yet used */
+#define A_CHARTEXT 0x000000ff
+#define A_COLOR 0x0000ff00
+#define COLOR_PAIR(n) (n << 8)
+#define PAIR_NUMBER(a) ((a & A_COLOR) >> 8)
+
+/*
+ * pseudo functions
+ */
+#define wgetstr(w, s) wgetnstr(w, s, -1)
+#define getnstr(s, n) wgetnstr(stdscr, s, n)
+
+#define setterm(term) setupterm(term, 1, (int *)0)
+
+#define fixterm() reset_prog_mode()
+#define resetterm() reset_shell_mode()
+#define saveterm() def_prog_mode()
+#define crmode() cbreak()
+#define nocrmode() nocbreak()
+#define gettmode()
+
+#define getyx(win,y,x) (y = (win)->_cury, x = (win)->_curx)
+#define getbegyx(win,y,x) (y = (win)->_begy, x = (win)->_begx)
+#define getmaxyx(win,y,x) (y = (win)->_maxy + 1, x = (win)->_maxx + 1)
+#define getparyx(win,y,x) (y = (win)->_pary, x = (win)->_parx)
+#define getsyx(y,x) getyx(stdscr, y, x)
+#define setsyx(y,x) (stdscr->_cury = y, stdscr->_curx = x)
+
+#define wbkgdset(win,ch) ((win)->_bkgd = (ch))
+
+/* It seems older SYSV curses versions define these */
+#define getattrs(win) ((win)->_attrs)
+#define getmaxx(win) ((win)->_maxx + 1)
+#define getmaxy(win) ((win)->_maxy + 1)
+
+#define winch(win) ((win)->_line[(win)->_cury].text[(win)->_curx])
+#define wstandout(win) (wattr_set(win,A_STANDOUT))
+#define wstandend(win) (wattr_set(win,A_NORMAL))
+#define wattr_set(win,at) ((win)->_attrs = (at))
+
+#define wattron(win,at) wattr_on(win, at)
+#define wattroff(win,at) wattr_off(win, at)
+#define wattrset(win,at) wattr_set(win, at)
+
+#define scroll(win) wscrl(win,1)
+
+#define touchwin(win) wtouchln((win), 0, (win)->_maxy + 1, 1)
+#define touchline(win, s, c) wtouchln((win), s, c, 1)
+#define untouchwin(win) wtouchln((win), 0, (win)->_maxy + 1, 0)
+
+#define box(win, v, h) wborder(win, v, v, h, h, 0, 0, 0, 0)
+#define border(ls, rs, ts, bs, tl, tr, bl, br) wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br)
+#define hline(ch, n) whline(stdscr, ch, n)
+#define vline(ch, n) wvline(stdscr, ch, n)
+
+#define winstr(w, s) winnstr(w, s, -1)
+#define winchstr(w, s) winchnstr(w, s, -1)
+#define winsstr(w, s) winsnstr(w, s, -1)
+
+#define redrawwin(w) wredrawln(w, 0, w->_maxy+1)
+#define waddstr(win,str) waddnstr(win,str,-1)
+#define waddchstr(win,str) waddchnstr(win,str,-1)
+
+/*
+ * pseudo functions for standard screen
+ */
+
+#define bkgdset(ch) wbkgdset(stdscr,ch)
+#define bkgd(ch) wbkgd(stdscr,ch)
+#define inch() winch(stdscr)
+#define standout() wstandout(stdscr)
+#define standend() wstandend(stdscr)
+#define attron(at) wattron(stdscr,at)
+#define attroff(at) wattroff(stdscr,at)
+#define attrset(at) wattrset(stdscr,at)
+#define addch(ch) waddch(stdscr,ch)
+#define echochar(c) wechochar(stdscr, c)
+#define getch() wgetch(stdscr)
+#define addstr(str) waddnstr(stdscr,str,-1)
+#define getstr(str) wgetstr(stdscr,str)
+#define move(y, x) wmove(stdscr,y,x)
+#define clear() wclear(stdscr)
+#define erase() werase(stdscr)
+#define clrtobot() wclrtobot(stdscr)
+#define clrtoeol() wclrtoeol(stdscr)
+#define insertln() winsdelln(stdscr, 1)
+#define winsertln(w) winsdelln(w, 1)
+#define deleteln() winsdelln(stdscr, -1)
+#define wdeleteln(w) winsdelln(w, -1)
+#define refresh() wrefresh(stdscr)
+#define insch(c) winsch(stdscr,c)
+#define delch() wdelch(stdscr)
+#define setscrreg(t,b) wsetscrreg(stdscr,t,b)
+#define scrl(n) wscrl(stdscr,n)
+#define timeout(delay) wtimeout(stdscr, delay)
+#define addnstr(str,n) waddnstr(stdscr,str,n)
+#define addchstr(str) waddchstr(stdscr,str)
+#define addchnstr(str,n) waddchnstr(stdscr,str, n)
+#define insdelln(n) winsdelln(stdscr, n)
+#define insstr(s) winsstr(stdscr, s)
+#define insnstr(s,n) winsnstr(stdscr, s, n)
+#define instr(s) winstr(stdscr, s)
+#define innstr(s,n) winnstr(stdscr, s, n)
+#define inchstr(s) winchstr(stdscr, s)
+#define inchnstr(s,n) winchnstr(stdscr, s, n)
+
+/*
+ * mv functions
+ */
+
+#define mvwaddch(win,y,x,ch) (wmove(win,y,x) == ERR ? ERR : waddch(win,ch))
+#define mvwgetch(win,y,x) (wmove(win,y,x) == ERR ? ERR : wgetch(win))
+#define mvwaddchnstr(win,y,x,str,n) (wmove(win,y,x) == ERR ? ERR : waddchnstr(win,str,n))
+#define mvwaddchstr(win,y,x,str) (wmove(win,y,x) == ERR ? ERR : waddchnstr(win,str,-1))
+#define mvwaddnstr(win,y,x,str,n) (wmove(win,y,x) == ERR ? ERR : waddnstr(win,str,n))
+#define mvwaddstr(win,y,x,str) (wmove(win,y,x) == ERR ? ERR : waddnstr(win,str,-1))
+#define mvwgetstr(win,y,x,str) (wmove(win,y,x) == ERR ? ERR : wgetstr(win,str))
+#define mvgetnstr(y,x,str,n) (move(y,x) == ERR ? ERR : wgetnstr(stdscr,str,n))
+#define mvwgetnstr(win,y,x,str,n) (wmove(win,y,x) == ERR ? ERR : wgetnstr(win,str,n))
+#define mvwinch(win,y,x) (wmove(win,y,x) == ERR ? ERR : winch(win))
+#define mvwdelch(win,y,x) (wmove(win,y,x) == ERR ? ERR : wdelch(win))
+#define mvwinsch(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : winsch(win,c))
+#define mvwhline(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : whline(win,c,n))
+#define mvwvline(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : wvline(win,c,n))
+#define mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch)
+#define mvaddchnstr(y,x,str,n) mvwaddchnstr(stdscr,y,x,str,n)
+#define mvaddchstr(y,x,str) mvwaddchstr(stdscr,y,x,str)
+#define mvgetch(y,x) mvwgetch(stdscr,y,x)
+#define mvaddnstr(y,x,str,n) mvwaddnstr(stdscr,y,x,str,n)
+#define mvaddstr(y,x,str) mvwaddstr(stdscr,y,x,str)
+#define mvgetstr(y,x,str) mvwgetstr(stdscr,y,x,str)
+#define mvinch(y,x) mvwinch(stdscr,y,x)
+#define mvdelch(y,x) mvwdelch(stdscr,y,x)
+#define mvinsch(y,x,c) mvwinsch(stdscr,y,x,c)
+#define mvhline(y,x,c,n) mvwhline(stdscr,y,x,c,n)
+#define mvvline(y,x,c,n) mvwvline(stdscr,y,x,c,n)
+#define mvwinsstr(w, y, x, s) (wmove(w,y,x) == ERR ? ERR : winsstr(w,s))
+#define mvwinsnstr(w, y, x, s, n) (wmove(w,y,x) == ERR ? ERR : winsnstr(w,s,n))
+#define mvinsstr(y,x,s) mvwinsstr(stdscr,y,x,s)
+#define mvinsnstr(y,x,s,n) mvwinsnstr(stdscr,y,x,s,n)
+#define mvwinstr(w, y, x, s) (wmove(w,y,x) == ERR ? ERR : winstr(w,s))
+#define mvwinnstr(w, y, x, s, n) (wmove(w,y,x) == ERR ? ERR : winnstr(w,s,n))
+#define mvinstr(y,x,s) mvwinstr(stdscr,y,x,s)
+#define mvinnstr(y,x,s,n) mvwinnstr(stdscr,y,x,s,n)
+#define mvwinchstr(w, y, x, s) (wmove(w,y,x) == ERR ? ERR : winchstr(w,s))
+#define mvwinchnstr(w, y, x, s, n) (wmove(w,y,x) == ERR ? ERR : winchnstr(w,s,n))
+#define mvinchstr(y,x,s) mvwinchstr(stdscr,y,x,s)
+#define mvinchnstr(y,x,s,n) mvwinchnstr(stdscr,y,x,s,n)
+
+/*
+ * XSI curses macros for XPG4 conformance.
+ * The underling functions needed to make these work are:
+ * waddnwstr(), waddchnwstr(), wadd_wch(), wborder_set(), wchgat(),
+ * wecho_wchar(), wgetn_wstr(), wget_wch(), whline_set(), vhline_set(),
+ * winnwstr(), wins_nwstr(), wins_wch(), win_wch(), win_wchnstr().
+ * Except for wchgat(), these are not yet implemented. They will be someday.
+ */
+#define addnwstr(wstr, n) waddnwstr(stdscr, wstr, n)
+#define addwstr(wstr, n) waddnwstr(stdscr, wstr, -1)
+#define mvaddnwstr(y,x,wstr, n) (wmove(stdscr,y,x) == ERR ? ERR : waddnwstr(stdscr, wstr, n))
+#define mvaddwstr(y,x,wstr, n) (wmove(stdscr,y,x) == ERR ? ERR : waddnwstr(stdscr, wstr, -1))
+#define mvwaddnwstr(y,x,win,wstr,n) (wmove(win,y,x) == ERR ? ERR : waddnwstr(stdscr, wstr, n))
+#define mvwaddwstr(y,x,win,wstr,n) (wmove(win,y,x) == ERR ? ERR : waddnwstr(stdscr, wstr, -1))
+#define waddwstr(win, wstr, n) waddnwstr(win, wstr, -1)
+#define add_wch(c) wadd_wch(stsdscr, c)
+#define mvadd_wch(y,x,c) (wmove(stdscr,y,x) == ERR ? ERR : wadd_wch(stsdscr, c))
+#define mvwadd_wch(y,x,win,c) (wmove(win,y,x) == ERR ? ERR : wadd_wch(stsdscr, c))
+#define wattr_get(win) ((win)->_attrs)
+#define attr_get() wattr_get(stdscr)
+#define attr_off(a) wattr_off(stdscr, a)
+#define attr_on(a) wattr_on(stdscr, a)
+#define attr_set(a) wattr_set(stdscr, a)
+#define wgetbkgd(win) ((win)->_bkgd)
+#define box_set(w,v,h) wborder_set(w,v,v,h,h,0,0,0,9)
+#define chgat(n, a, c, o) wchgat(stdscr, n, a, c, o)
+#define mvchgat(y,x, n,a,c, o) (move(y,x)==ERR ? ERR : wchgat(stdscr,n,a,c,o))
+#define mvwchgat(w,y,x,n,a,c,o) (wmove(w,y,x) == ERR ? ERR : wchgat(w,n,a,c,o))
+#define echo_wchar(c) wecho_wchar(stdscr, c)
+#define getn_wstr(t, n) wgetn_wstr(stdscr, t, n)
+#define get_wstr(t) wgetn_wstr(stdscr, t, -1)
+#define mvgetn_wstr(y, x, t, n) (move(y,x)==ERR ? ERR:wgetn_wstr(stdscr,t,n))
+#define mvget_wstr(y, x, t) (move(y,x)==ERR ? ERR:wgetn_wstr(stdscr,t,-1))
+#define mvwgetn_wstr(w,y,x,t,n) (wmove(w,y,x)==ERR ? ERR : wgetn_wstr(w,t,n))
+#define mvwget_wstr(w, y, x, t) (wmove(w,y,x)==ERR ? ERR : wgetn_wstr(w,t,-1))
+#define wget_wstr(w, t) wgetn_wstr(w, t, -1)
+#define get_wch(c) wget_wch(stdscr, c)
+#define mvget_wch(y, x, c) (move(y,x) == ERR ? ERR : wget_wch(stdscr, c))
+#define mvwget_wch(y, x, c) (wmove(w,y,x) == ERR ? ERR : wget_wch(w, n))
+#define hline_set(c, n) whline_set(stdscr, c, n)
+#define mvhline_set(y,x,c,n) (move(y,x)==ERR ? ERR : whline_set(stdscr,c,n))
+#define mvvline_set(y,x,c,n) (move(y,x)==ERR ? ERR : wvline_set(stdscr,c,n))
+#define mvwhline_set(w,y,x,c,n) (wmove(w,y,x)==ERR ? ERR : whline_set(w,c,n))
+#define mvwvline_set(w,y,x,c,n) (wmove(w,y,x)==ERR ? ERR : wvline_set(w,c,n))
+#define vline_set(c, n) vhline_set(stdscr, c, n)
+#define innwstr(c, n) winnwstr(stdscr, c, n)
+#define inwstr(c) winnwstr(stdscr, c, -1)
+#define mvinnwstr(y, x, c, n) (move(y,x)==ERR ? ERR : winnwstr(stdscr, c, n))
+#define mvinwstr(y, x, c) (move(y,x)==ERR ? ERR : winnwstr(stdscr, c,-1))
+#define mvwinnwstr(w,y,x,c,n) (wmove(w,y,x)==ERR ? ERR:winnwstr(stdscr,c,n))
+#define mvwinwstr(w,y,x,c) (wmove(w,y,x)==ERR ? ERR:winnwstr(stdscr,c,-1))
+#define winwstr(w, c) winnwstr(w, c, -1)
+#define ins_nwstr(t, n) wins_nwstr(stdscr, t, n)
+#define ins_wstr(t) wins_nwstr(stdscr, t, -1)
+#define mvins_nwstr(y,x,t,n) (move(y,x)==ERR ? ERR: wins_nwstr(stdscr,t,n))
+#define mvins_wstr(y,x,t) (move(y,x)==ERR ? ERR: wins_nwstr(stdscr,t,-1))
+#define mvwins_nwstr(w,y,x,t,n) (wmove(w,y,x)==ERR?ERR:wins_nwstr(stdscr,t,n))
+#define mvwins_wstr(w,y,x,t) (wmove(w,y,x)==ERR?ERR:wins_nwstr(stdscr,t,-1))
+#define wins_wstr(w, t) wins_nwstr(w, t, -1)
+#define ins_wch(c) wins_wch(stdscr, c)
+#define mvins_wch(y,x,c) (move(y,x) == ERR ? ERR : wins_wch(c))
+#define mwvins_wch(w,y,x,c) (wmove(w,y,x) == ERR ? ERR : wins_wch(c))
+#define in_wch(c) win_wch(stdscr, c)
+#define mvin_wch(y,x,c) (move(y,x) == ERR ? ERR : win_wch(stdscr, c))
+#define mvwin_wch(w,y,x,c) (wmove(w, y,x) == ERR ? ERR : win_wch(w, c))
+#define in_wchnstr(c, n) win_wchnstr(stdscr, c, n)
+#define in_wchstr(c) win_wchnstr(stdscr, c, -1)
+#define mvin_wchnstr(y,x,c,n) (move(y,x)==ERR ? ERR:win_wchnstr(stdscr,c,n))
+#define mvin_wchstr(y, x, c) (move(y,x)==ERR ? ERR:win_wchnstr(stdscr,c,-1))
+#define mvwin_wchnstr(w,y,x,c,n) (wmove(w,y,x)==ERR ? ERR:win_wchnstr(stdscr,c,n))
+#define mvwin_wchstr(w,y,x,c) (wmove(w,y,x)==ERR ? ERR:win_wchnstr(stdscr,c,-1))
+#define win_wchstr(w, c) win_wchnstr(w, c, -1)
+
+
+/*
+ * XSI curses deprecates SVr4 vwprintw/vwscanw, which are supposed to use
+ * varargs.h. It adds new calls vw_printw/vw_scanw, which are supposed to
+ * use POSIX stdarg.h. The ncurses versions of vwprintw/vwscanw already
+ * use stdarg.h, so...
+ */
+#define vw_printw vwprintw
+#define vw_scanw vwscanw
+
+/*
+ * Pseudo-character tokens outside ASCII range. The curses wgetch() function
+ * will return any given one of these only if the corresponding k- capability
+ * is defined in your terminal's terminfo entry.
+ */
+#define KEY_CODE_YES 0400 /* A wchar_t contains a key code */
+#define KEY_MIN 0401 /* Minimum curses key */
+#define KEY_BREAK 0401 /* Break key (unreliable) */
+#define KEY_DOWN 0402 /* Down-arrow */
+#define KEY_UP 0403 /* Up-arrow */
+#define KEY_LEFT 0404 /* Left-arrow */
+#define KEY_RIGHT 0405 /* Right-arrow */
+#define KEY_HOME 0406 /* Home key (upward+left arrow) */
+#define KEY_BACKSPACE 0407 /* Backspace (unreliable) */
+#define KEY_F0 0410 /* Function keys. Space for 64 */
+#define KEY_F(n) (KEY_F0+(n)) /* Value of function key n */
+#define KEY_DL 0510 /* Delete line */
+#define KEY_IL 0511 /* Insert line */
+#define KEY_DC 0512 /* Delete character */
+#define KEY_IC 0513 /* Insert char or enter insert mode */
+#define KEY_EIC 0514 /* Exit insert char mode */
+#define KEY_CLEAR 0515 /* Clear screen */
+#define KEY_EOS 0516 /* Clear to end of screen */
+#define KEY_EOL 0517 /* Clear to end of line */
+#define KEY_SF 0520 /* Scroll 1 line forward */
+#define KEY_SR 0521 /* Scroll 1 line backward (reverse) */
+#define KEY_NPAGE 0522 /* Next page */
+#define KEY_PPAGE 0523 /* Previous page */
+#define KEY_STAB 0524 /* Set tab */
+#define KEY_CTAB 0525 /* Clear tab */
+#define KEY_CATAB 0526 /* Clear all tabs */
+#define KEY_ENTER 0527 /* Enter or send (unreliable) */
+#define KEY_SRESET 0530 /* Soft (partial) reset (unreliable) */
+#define KEY_RESET 0531 /* Reset or hard reset (unreliable) */
+#define KEY_PRINT 0532 /* Print */
+#define KEY_LL 0533 /* Home down or bottom (lower left) */
+
+/* The keypad is arranged like this: */
+/* a1 up a3 */
+/* left b2 right */
+/* c1 down c3 */
+
+#define KEY_A1 0534 /* Upper left of keypad */
+#define KEY_A3 0535 /* Upper right of keypad */
+#define KEY_B2 0536 /* Center of keypad */
+#define KEY_C1 0537 /* Lower left of keypad */
+#define KEY_C3 0540 /* Lower right of keypad */
+#define KEY_BTAB 0541 /* Back tab */
+#define KEY_BEG 0542 /* Beg (beginning) */
+#define KEY_CANCEL 0543 /* Cancel */
+#define KEY_CLOSE 0544 /* Close */
+#define KEY_COMMAND 0545 /* Cmd (command) */
+#define KEY_COPY 0546 /* Copy */
+#define KEY_CREATE 0547 /* Create */
+#define KEY_END 0550 /* End */
+#define KEY_EXIT 0551 /* Exit */
+#define KEY_FIND 0552 /* Find */
+#define KEY_HELP 0553 /* Help */
+#define KEY_MARK 0554 /* Mark */
+#define KEY_MESSAGE 0555 /* Message */
+#define KEY_MOVE 0556 /* Move */
+#define KEY_NEXT 0557 /* Next */
+#define KEY_OPEN 0560 /* Open */
+#define KEY_OPTIONS 0561 /* Options */
+#define KEY_PREVIOUS 0562 /* Prev (previous) */
+#define KEY_REDO 0563 /* Redo */
+#define KEY_REFERENCE 0564 /* Ref (reference) */
+#define KEY_REFRESH 0565 /* Refresh */
+#define KEY_REPLACE 0566 /* Replace */
+#define KEY_RESTART 0567 /* Restart */
+#define KEY_RESUME 0570 /* Resume */
+#define KEY_SAVE 0571 /* Save */
+#define KEY_SBEG 0572 /* Shifted Beg (beginning) */
+#define KEY_SCANCEL 0573 /* Shifted Cancel */
+#define KEY_SCOMMAND 0574 /* Shifted Command */
+#define KEY_SCOPY 0575 /* Shifted Copy */
+#define KEY_SCREATE 0576 /* Shifted Create */
+#define KEY_SDC 0577 /* Shifted Delete char */
+#define KEY_SDL 0600 /* Shifted Delete line */
+#define KEY_SELECT 0601 /* Select */
+#define KEY_SEND 0602 /* Shifted End */
+#define KEY_SEOL 0603 /* Shifted Clear line */
+#define KEY_SEXIT 0604 /* Shifted Dxit */
+#define KEY_SFIND 0605 /* Shifted Find */
+#define KEY_SHELP 0606 /* Shifted Help */
+#define KEY_SHOME 0607 /* Shifted Home */
+#define KEY_SIC 0610 /* Shifted Input */
+#define KEY_SLEFT 0611 /* Shifted Left arrow */
+#define KEY_SMESSAGE 0612 /* Shifted Message */
+#define KEY_SMOVE 0613 /* Shifted Move */
+#define KEY_SNEXT 0614 /* Shifted Next */
+#define KEY_SOPTIONS 0615 /* Shifted Options */
+#define KEY_SPREVIOUS 0616 /* Shifted Prev */
+#define KEY_SPRINT 0617 /* Shifted Print */
+#define KEY_SREDO 0620 /* Shifted Redo */
+#define KEY_SREPLACE 0621 /* Shifted Replace */
+#define KEY_SRIGHT 0622 /* Shifted Right arrow */
+#define KEY_SRSUME 0623 /* Shifted Resume */
+#define KEY_SSAVE 0624 /* Shifted Save */
+#define KEY_SSUSPEND 0625 /* Shifted Suspend */
+#define KEY_SUNDO 0626 /* Shifted Undo */
+#define KEY_SUSPEND 0627 /* Suspend */
+#define KEY_UNDO 0630 /* Undo */
+#define KEY_MOUSE 0631 /* Mouse event has occurred */
+#define KEY_MAX 0777 /* Maximum key value */
+
+/* mouse interface */
+#define NCURSES_MOUSE_VERSION 1
+
+/* event masks */
+#define BUTTON1_RELEASED 000000000001L
+#define BUTTON1_PRESSED 000000000002L
+#define BUTTON1_CLICKED 000000000004L
+#define BUTTON1_DOUBLE_CLICKED 000000000010L
+#define BUTTON1_TRIPLE_CLICKED 000000000020L
+#define BUTTON1_RESERVED_EVENT 000000000040L
+#define BUTTON2_RELEASED 000000000100L
+#define BUTTON2_PRESSED 000000000200L
+#define BUTTON2_CLICKED 000000000400L
+#define BUTTON2_DOUBLE_CLICKED 000000001000L
+#define BUTTON2_TRIPLE_CLICKED 000000002000L
+#define BUTTON2_RESERVED_EVENT 000000004000L
+#define BUTTON3_RELEASED 000000010000L
+#define BUTTON3_PRESSED 000000020000L
+#define BUTTON3_CLICKED 000000040000L
+#define BUTTON3_DOUBLE_CLICKED 000000100000L
+#define BUTTON3_TRIPLE_CLICKED 000000200000L
+#define BUTTON3_RESERVED_EVENT 000000400000L
+#define BUTTON4_RELEASED 000001000000L
+#define BUTTON4_PRESSED 000002000000L
+#define BUTTON4_CLICKED 000004000000L
+#define BUTTON4_DOUBLE_CLICKED 000010000000L
+#define BUTTON4_TRIPLE_CLICKED 000020000000L
+#define BUTTON4_RESERVED_EVENT 000040000000L
+#define BUTTON_CTRL 000100000000L
+#define BUTTON_SHIFT 000200000000L
+#define BUTTON_ALT 000400000000L
+#define ALL_MOUSE_EVENTS 000777777777L
+#define REPORT_MOUSE_POSITION 001000000000L
+
+/* macros to extract single event-bits from masks */
+#define BUTTON_RELEASE(e, x) ((e) & (001 << (6 * ((x) - 1))))
+#define BUTTON_PRESS(e, x) ((e) & (002 << (6 * ((x) - 1))))
+#define BUTTON_CLICK(e, x) ((e) & (004 << (6 * ((x) - 1))))
+#define BUTTON_DOUBLE_CLICK(e, x) ((e) & (010 << (6 * ((x) - 1))))
+#define BUTTON_TRIPLE_CLICK(e, x) ((e) & (020 << (6 * ((x) - 1))))
+#define BUTTON_RESERVED_EVENT(e, x) ((e) & (040 << (6 * ((x) - 1))))
+
+typedef unsigned long mmask_t;
+
+typedef struct
+{
+ short id; /* ID to distinguish multiple devices */
+ int x, y, z; /* event coordinates (character-cell) */
+ mmask_t bstate; /* button state bits */
+}
+MEVENT;
+
+int getmouse(MEVENT *event);
+int ungetmouse(MEVENT *event);
+mmask_t mousemask(mmask_t newmask, mmask_t *oldmask);
+bool wenclose(WINDOW *win, int y, int x);
+int mouseinterval(int);
+
+/* Debugging : use with libncurses_g.a */
+
+extern void _tracef(const char *, ...) __attribute__((format(printf,1,2)));
+extern void _tracedump(char *, WINDOW *);
+extern char *_traceattr(attr_t mode);
+extern char *_tracechar(const unsigned char);
+extern char *_tracemouse(const MEVENT *);
+extern void trace(const unsigned int tracelevel);
+
+/* trace masks */
+#define TRACE_DISABLE 0x00 /* turn off tracing */
+#define TRACE_UPDATE 0x01 /* trace update actions, old & new screens */
+#define TRACE_MOVE 0x02 /* trace cursor moves and scrolls */
+#define TRACE_CHARPUT 0x04 /* trace all character outputs */
+#define TRACE_ORDINARY 0x07 /* trace all update actions */
+#define TRACE_CALLS 0x08 /* trace all curses calls */
+#define TRACE_VIRTPUT 0x10 /* trace virtual character puts */
+#define TRACE_FIFO 0x20 /* also fifo actions by getch() */
+#define TRACE_MAXIMUM 0xff /* maximum trace level */
+
+#ifdef TRACE
+extern bool no_optimize; /* suppress optimization */
+#endif /* TRACE */
+
+#endif /* __NCURSES_H */
diff --git a/lib/libcurses/curses.priv.h b/lib/libcurses/curses.priv.h
new file mode 100644
index 00000000000..a1e023265d1
--- /dev/null
+++ b/lib/libcurses/curses.priv.h
@@ -0,0 +1,270 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+/*
+ * curses.priv.h
+ *
+ * Header file for curses library objects which are private to
+ * the library.
+ *
+ */
+
+#include <config.h>
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#if HAVE_LIMITS_H
+# include <limits.h>
+#elif HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+
+#ifndef PATH_MAX
+# if defined(_POSIX_PATH_MAX)
+# define PATH_MAX _POSIX_PATH_MAX
+# elif defined(MAXPATHLEN)
+# define PATH_MAX MAXPATHLEN
+# else
+# define PATH_MAX 255 /* the Posix minimum pathsize */
+# endif
+#endif
+
+#include <assert.h>
+
+#include <curses.h> /* we'll use -Ipath directive to get the right one! */
+
+/* The terminfo source is assumed to be 7-bit ASCII */
+#define is7bits(c) ((unsigned)(c) < 128)
+
+#ifndef min
+#define min(a,b) ((a) > (b) ? (b) : (a))
+#endif
+
+#ifndef max
+#define max(a,b) ((a) < (b) ? (b) : (a))
+#endif
+
+/* usually in <unistd.h> */
+#ifndef STDOUT_FILENO
+#define STDOUT_FILENO 1
+#endif
+
+#ifndef STDERR_FILENO
+#define STDERR_FILENO 2
+#endif
+
+#ifndef R_OK
+#define R_OK 4 /* Test for read permission. */
+#endif
+#ifndef W_OK
+#define W_OK 2 /* Test for write permission. */
+#endif
+#ifndef X_OK
+#define X_OK 1 /* Test for execute permission. */
+#endif
+#ifndef F_OK
+#define F_OK 0 /* Test for existence. */
+#endif
+
+#define TextOf(c) ((c) & (chtype)A_CHARTEXT)
+#define AttrOf(c) ((c) & (chtype)A_ATTRIBUTES)
+
+#define BLANK (' '|A_NORMAL)
+
+#define CHANGED -1
+
+/*
+ * ht/cbt expansion flakes out randomly under Linux 1.1.47, but only when
+ * we're throwing control codes at the screen at high volume. To see this,
+ * re-enable TABS_OK and run worm for a while. Other systems probably don't
+ * want to define this either due to uncertainties about tab delays and
+ * expansion in raw mode.
+ */
+#undef TABS_OK /* OK to use tab/backtab for local motions? */
+
+#ifdef TRACE
+#define T(a) if (_nc_tracing & TRACE_CALLS) _tracef a
+#define TR(n, a) if (_nc_tracing & (n)) _tracef a
+#define TPUTS_TRACE(s) _nc_tputs_trace = s;
+extern unsigned _nc_tracing;
+extern char *_nc_tputs_trace;
+extern char *_nc_visbuf(const char *);
+#else
+#define T(a)
+#define TR(n, a)
+#define TPUTS_TRACE(s)
+#endif
+
+/* lib_acs.c */
+extern void init_acs(void); /* no prefix, this name is traditional */
+
+/* lib_mvcur.c */
+extern void _nc_mvcur_init(SCREEN *sp);
+extern void _nc_mvcur_wrap(void);
+extern int _nc_mvcur_scrolln(int, int, int, int);
+
+/* lib_mouse.c */
+extern void _nc_mouse_init(SCREEN *);
+extern bool _nc_mouse_event(SCREEN *);
+extern bool _nc_mouse_inline(SCREEN *);
+extern bool _nc_mouse_parse(int);
+extern void _nc_mouse_wrap(SCREEN *);
+extern void _nc_mouse_resume(SCREEN *);
+extern int _nc_max_click_interval;
+
+/* elsewhere ... */
+extern int _nc_keypad(bool flag);
+extern WINDOW *_nc_makenew(int, int, int, int);
+#ifdef EXTERN_TERMINFO
+#define _nc_outch _ti_outc
+#endif
+extern int _nc_outch(int);
+extern chtype _nc_render(WINDOW *, chtype, chtype);
+extern int _nc_waddch_nosync(WINDOW *, const chtype);
+extern void _nc_scroll_optimize(void);
+extern void _nc_scroll_window(WINDOW *, int const, short const, short const);
+extern int _nc_setupscreen(short, short const);
+extern void _nc_backspace(WINDOW *win);
+extern void _nc_outstr(char *str);
+extern void _nc_signal_handler(bool);
+extern void _nc_synchook(WINDOW *win);
+extern int _nc_timed_wait(int fd, int wait, int *timeleft);
+extern void _nc_do_color(int, int (*)(int));
+
+struct try {
+ struct try *child; /* ptr to child. NULL if none */
+ struct try *sibling; /* ptr to sibling. NULL if none */
+ unsigned char ch; /* character at this node */
+ unsigned short value; /* code of string so far. 0 if none. */
+};
+
+/*
+ * Structure for soft labels.
+ */
+
+typedef struct {
+ char dirty; /* all labels have changed */
+ char hidden; /* soft lables are hidden */
+ WINDOW *win;
+ struct slk_ent {
+ char text[9]; /* text for the label */
+ char form_text[9]; /* formatted text (left/center/...) */
+ int x; /* x coordinate of this field */
+ char dirty; /* this label has changed */
+ char visible; /* field is visible */
+ } ent[8];
+} SLK;
+
+#define FIFO_SIZE 32
+
+struct screen {
+ int _ifd; /* input file ptr for screen */
+ FILE *_ofp; /* output file ptr for screen */
+ int _checkfd; /* filedesc for typeahead check */
+#ifdef EXTERN_TERMINFO
+ struct _terminal *_term; /* terminal type information */
+#else
+ struct term *_term; /* terminal type information */
+#endif
+ short _lines; /* screen lines */
+ short _columns; /* screen columns */
+ WINDOW *_curscr; /* current screen */
+ WINDOW *_newscr; /* virtual screen to be updated to */
+ WINDOW *_stdscr; /* screen's full-window context */
+ struct try *_keytry; /* "Try" for use with keypad mode */
+ unsigned int _fifo[FIFO_SIZE]; /* input pushback buffer */
+ signed char _fifohead, /* head of fifo queue */
+ _fifotail, /* tail of fifo queue */
+ _fifopeek; /* where to peek for next char */
+ bool _endwin; /* are we out of window mode? */
+ chtype _current_attr; /* terminal attribute current set */
+ bool _coloron; /* is color enabled? */
+ int _cursor; /* visibility of the cursor */
+ int _cursrow; /* physical cursor row */
+ int _curscol; /* physical cursor column */
+ bool _nl; /* True if NL -> CR/NL is on */
+ bool _raw; /* True if in raw mode */
+ int _cbreak; /* 1 if in cbreak mode */
+ /* > 1 if in halfdelay mode */
+ bool _echo; /* True if echo on */
+ bool _use_meta; /* use the meta key? */
+ SLK *_slk; /* ptr to soft key struct / NULL */
+ int _baudrate; /* used to compute padding */
+
+ /* 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) */
+#ifdef TABS_OK
+ int _ht_cost; /* cost of (tab) */
+ int _cbt_cost; /* cost of (backtab) */
+#endif /* TABS_OK */
+ 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) */
+};
+
+/*
+ * On systems with a broken linker, define 'SP' as a function to force the
+ * linker to pull in the data-only module with 'SP'.
+ */
+#ifndef BROKEN_LINKER
+#define BROKEN_LINKER 0
+#endif
+
+#if BROKEN_LINKER
+#define SP _nc_screen()
+extern SCREEN *_nc_screen(void);
+extern int _nc_alloc_screen(void);
+extern void _nc_set_screen(SCREEN *);
+#else
+extern SCREEN *SP;
+#define _nc_alloc_screen() ((SP = (SCREEN *) calloc(1, sizeof(*SP))) != NULL)
+#define _nc_set_screen(sp) SP = sp
+#endif
+
+/*
+ * We don't want to use the lines or columns capabilities internally,
+ * because if the application is running multiple screens under
+ * X windows, it's quite possible they could all have type xterm
+ * but have different sizes! So...
+ */
+#define screen_lines SP->_lines
+#define screen_columns SP->_columns
+
+extern int _slk_init; /* TRUE if slk_init() called */
+extern int slk_initialize(WINDOW *, int);
+
+#define MAXCOLUMNS 135
+#define MAXLINES 66
+#define UNINITIALISED ((struct try * ) -1)
diff --git a/lib/libcurses/delch.c b/lib/libcurses/delch.c
deleted file mode 100644
index b9cdc3140ed..00000000000
--- a/lib/libcurses/delch.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)delch.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include <string.h>
-
-#include "curses.h"
-
-/*
- * wdelch --
- * Do an insert-char on the line, leaving (cury, curx) unchanged.
- */
-int
-wdelch(win)
- register WINDOW *win;
-{
- register __LDATA *end, *temp1, *temp2;
-
- end = &win->lines[win->cury]->line[win->maxx - 1];
- temp1 = &win->lines[win->cury]->line[win->curx];
- temp2 = temp1 + 1;
- while (temp1 < end) {
- (void)memcpy(temp1, temp2, sizeof(__LDATA));
- temp1++, temp2++;
- }
- temp1->ch = ' ';
- temp1->attr = 0;
- __touchline(win, win->cury, win->curx, win->maxx - 1, 0);
- return (OK);
-}
diff --git a/lib/libcurses/deleteln.c b/lib/libcurses/deleteln.c
deleted file mode 100644
index 4cb08ea3794..00000000000
--- a/lib/libcurses/deleteln.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)deleteln.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include <string.h>
-
-#include "curses.h"
-
-/*
- * wdeleteln --
- * Delete a line from the screen. It leaves (cury, curx) unchanged.
- */
-int
-wdeleteln(win)
- register WINDOW *win;
-{
- register int y, i;
- register __LINE *temp;
-
-#ifdef DEBUG
- __CTRACE("deleteln: (%0.2o)\n", win);
-#endif
- temp = win->lines[win->cury];
- for (y = win->cury; y < win->maxy - 1; y++) {
- win->lines[y]->flags &= ~__ISPASTEOL;
- win->lines[y + 1]->flags &= ~__ISPASTEOL;
- if (win->orig == NULL)
- win->lines[y] = win->lines[y + 1];
- else
- (void) memcpy(win->lines[y]->line,
- win->lines[y + 1]->line,
- win->maxx * __LDATASIZE);
- __touchline(win, y, 0, win->maxx - 1, 0);
- }
-
- if (win->orig == NULL)
- win->lines[y] = temp;
- else
- temp = win->lines[y];
-
- for(i = 0; i < win->maxx; i++) {
- temp->line[i].ch = ' ';
- temp->line[i].attr = 0;
- }
- __touchline(win, y, 0, win->maxx - 1, 0);
- if (win->orig == NULL)
- __id_subwins(win);
- return (OK);
-}
diff --git a/lib/libcurses/delwin.c b/lib/libcurses/delwin.c
deleted file mode 100644
index 7310db8588c..00000000000
--- a/lib/libcurses/delwin.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)delwin.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include <stdlib.h>
-
-#include "curses.h"
-
-/*
- * delwin --
- * Delete a window and release it back to the system.
- */
-int
-delwin(win)
- register WINDOW *win;
-{
-
- register WINDOW *wp, *np;
-
- if (win->orig == NULL) {
- /*
- * If we are the original window, delete the space for all
- * the subwindows, the line space and the window space.
- */
- free(win->lspace);
- free(win->wspace);
- free(win->lines);
- wp = win->nextp;
- while (wp != win) {
- np = wp->nextp;
- delwin(wp);
- wp = np;
- }
- } else {
- /*
- * If we are a subwindow, take ourselves out of the list.
- * NOTE: if we are a subwindow, the minimum list is orig
- * followed by this subwindow, so there are always at least
- * two windows in the list.
- */
- for (wp = win->nextp; wp->nextp != win; wp = wp->nextp)
- continue;
- wp->nextp = win->nextp;
- }
- free(win);
- return (OK);
-}
diff --git a/lib/libcurses/erase.c b/lib/libcurses/erase.c
deleted file mode 100644
index 42ca68a35a6..00000000000
--- a/lib/libcurses/erase.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)erase.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include "curses.h"
-
-/*
- * werase --
- * Erases everything on the window.
- */
-int
-werase(win)
- register WINDOW *win;
-{
-
- register int minx, y;
- register __LDATA *sp, *end, *start, *maxx;
-
-#ifdef DEBUG
- __CTRACE("werase: (%0.2o)\n", win);
-#endif
- for (y = 0; y < win->maxy; y++) {
- minx = -1;
- start = win->lines[y]->line;
- end = &start[win->maxx];
- for (sp = start; sp < end; sp++)
- if (sp->ch != ' ' || sp->attr != 0) {
- maxx = sp;
- if (minx == -1)
- minx = sp - start;
- sp->ch = ' ';
- sp->attr = 0;
- }
- if (minx != -1)
- __touchline(win, y, minx, maxx - win->lines[y]->line,
- 0);
- }
- return (OK);
-}
diff --git a/lib/libcurses/fullname.c b/lib/libcurses/fullname.c
deleted file mode 100644
index 3d05e5d6ef8..00000000000
--- a/lib/libcurses/fullname.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 1981, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)fullname.c 8.1 (Berkeley) 6/4/93";
-#endif /* not lint */
-
-/*
- * fullname --
- * This routine fills in "def" with the full name of the terminal.
- * This is assumed to be the last name in the list of aliases.
- */
-char *
-fullname(bp, def)
- register char *bp, *def;
-{
- register char *cp;
-
- *def = '\0'; /* In case no name. */
-
- while (*bp && *bp != ':') {
- cp = def; /* Start of answer. */
- while (*bp && *bp != ':' && *bp != '|')
- *cp++ = *bp++; /* Copy name over. */
- *cp = '\0'; /* Zero end of name. */
- if (*bp == '|')
- bp++; /* Skip over '|' if that is case. */
- }
- return (def);
-}
diff --git a/lib/libcurses/getch.c b/lib/libcurses/getch.c
deleted file mode 100644
index 6108229708d..00000000000
--- a/lib/libcurses/getch.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)getch.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include "curses.h"
-
-/*
- * wgetch --
- * Read in a character from the window.
- */
-int
-wgetch(win)
- register WINDOW *win;
-{
- register int inp, weset;
-
- if (!(win->flags & __SCROLLOK) && (win->flags & __FULLWIN)
- && win->curx == win->maxx - 1 && win->cury == win->maxy - 1)
- return (ERR);
-#ifdef DEBUG
- __CTRACE("wgetch: __echoit = %d, __rawmode = %d\n",
- __echoit, __rawmode);
-#endif
- if (__echoit && !__rawmode) {
- cbreak();
- weset = 1;
- } else
- weset = 0;
-
- inp = getchar();
-#ifdef DEBUG
- __CTRACE("wgetch got '%s'\n", unctrl(inp));
-#endif
- if (__echoit) {
- mvwaddch(curscr,
- win->cury + win->begy, win->curx + win->begx, inp);
- waddch(win, inp);
- }
- if (weset)
- nocbreak();
- return (inp);
-}
diff --git a/lib/libcurses/getstr.c b/lib/libcurses/getstr.c
deleted file mode 100644
index daf8e61b7fd..00000000000
--- a/lib/libcurses/getstr.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)getstr.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include "curses.h"
-
-/*
- * wgetstr --
- * Get a string starting at (cury, curx).
- */
-int
-wgetstr(win, str)
- register WINDOW *win;
- register char *str;
-{
- while ((*str = wgetch(win)) != ERR && *str != '\n')
- str++;
- if (*str == ERR) {
- *str = '\0';
- return (ERR);
- }
- *str = '\0';
- return (OK);
-}
diff --git a/lib/libcurses/hardscroll.c b/lib/libcurses/hardscroll.c
new file mode 100644
index 00000000000..73d185b199e
--- /dev/null
+++ b/lib/libcurses/hardscroll.c
@@ -0,0 +1,420 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+/******************************************************************************
+
+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
+
+First, mark each line on the real screen that is *not* carried over to the
+virtual screen discarded (that is, with a -1 oldnum index).
+
+Second, optionally run through each virtual line with a non -1 oldnum. If the
+line is sufficiently changed, mark it -1 (we don't want to move it). The exact
+test for "sufficiently changed" is not relevant to the control flow of this
+algorithm. Cases the test should detect are those in which rewriting
+the line from whatever might be on the real screen would be cheaper than the
+move. Blank lines on a terminal with clear-to-eol probably meet this test.
+
+Here is pseudo-code for the remainder of the algorithm:
+
+ repeat
+1: first = 0;
+2: no_hunk_moved = TRUE;
+
+ # on each pass, try to find a movable hunk
+3: while (first < screen_depth)
+
+ # scan for start of hunk
+4: while (oldnum field of first == -1)
+ first++
+
+ # if we have no hunk, quit this pass
+5: if (first >= screen_depth)
+ break;
+
+ # we found a hunk
+6: last = (end of longest continues oldnum range starting here)
+
+7: ofirst = (first line's oldnum, where it was on real screen)
+8: olast = (last line's oldnum, where it was on real screen)
+
+ # figure the hunk's displacement
+9: disp = first - (first virtual line's oldnum field)
+
+ # does the hunk want to move?
+10: if (disp != 0)
+ # is the hunk movable without destroying info?
+11: if (real [ofirst+disp, olast+disp] are all in range or DISCARDED)
+12: if (disp > 0)
+13: scroll real [ofirst, olast+disp] down by disp
+ (mark [ofirst, olast+disp] DISCARDED)
+14: else if (disp < 0)
+15: scroll real [ofirst+disp, olast] up by disp
+ (mark [ofirst+disp, olast] DISCARDED)
+16: no_hunk_moved = FALSE
+
+ # done trying to move this hunk
+17: first = last + 1;
+ end while
+ until
+18: no_hunk_moved; # quit when a complete pass finds no movable hunks
+
+HOW TO TEST THIS:
+
+Use the following production:
+
+hardscroll: hardscroll.c
+ $(CC) -g -DMAINDEBUG 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
+
+*****************************************************************************/
+
+#include "curses.priv.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#if defined(TRACE) || defined(MAINDEBUG)
+static void linedump(void);
+#endif /* defined(TRACE) || defined(MAINDEBUG) */
+
+/* if only this number of lines is carried over, nuke the screen and redraw */
+#define CLEAR_THRESHOLD 3
+
+#ifdef MAINDEBUG
+#define LINES 24
+static int oldnums[LINES], reallines[LINES];
+#define OLDNUM(n) oldnums[n]
+#define REAL(m) reallines[m]
+#undef T
+#define T(x) (void) printf x ; (void) putchar('\n');
+#else
+#include <curses.h>
+#define OLDNUM(n) newscr->_line[n].oldindex
+#define REAL(m) curscr->_line[m].oldindex
+#ifndef _NEWINDEX
+#define _NEWINDEX -1
+#endif /* _NEWINDEX */
+#endif /* MAINDEBUG */
+
+static bool all_discarded(int const top, int const bottom, int const disp)
+/* has the given range of real lines been marked discarded? */
+{
+ int n;
+
+ for (n = top + disp; n <= bottom + disp; n++)
+ if (REAL(n) != _NEWINDEX && !(REAL(n) <= bottom && REAL(n) >= top))
+ return(FALSE);
+
+ return(TRUE);
+}
+
+void _nc_scroll_optimize(void)
+/* scroll optimization to transform curscr to newscr */
+{
+ bool no_hunk_moved; /* no hunk moved on this pass? */
+ int n, new_lines;
+#if defined(TRACE) || defined(MAINDEBUG)
+ int pass = 0;
+#endif /* defined(TRACE) || defined(MAINDEBUG) */
+
+ TR(TRACE_CALLS, ("_nc_scroll_optimize() begins"));
+
+ /* mark any line not carried over with _NEWINDEX */
+ for (n = 0; n < LINES; n++)
+ REAL(n) += (MAXLINES + 1);
+ for (n = 0; n < LINES; n++)
+ if (OLDNUM(n) != _NEWINDEX
+ && REAL(OLDNUM(n)) >= MAXLINES)
+ REAL(OLDNUM(n)) -= (MAXLINES + 1);
+ for (n = new_lines = 0; n < LINES; n++)
+ if (REAL(n) > MAXLINES)
+ {
+ REAL(n) = _NEWINDEX;
+ new_lines++;
+ }
+
+ /*
+ * ^F in vi (which scrolls forward by LINES-2 in the file) exposes
+ * a weakness in this design. Ideally, vertical motion
+ * optimization should cost its actions and then force a
+ * ClrUpdate() and complete redraw if that would be faster than
+ * the scroll. Unfortunately, this would be a serious pain to
+ * arrange; hence, this hack. If there are few enough lines
+ * carried over, don't bother with the scrolling, we just nuke the
+ * screen and redraw the whole thing. Keith Bostic argues that
+ * this will be a win on strictly visual grounds even if the
+ * resulting update is theoretically sub-optimal. Experience
+ * with vi says he's probably right.
+ */
+ if (LINES - new_lines <= CLEAR_THRESHOLD)
+ {
+ T(("too few lines carried over, nuking screen"));
+#ifndef MAINDEBUG
+ clearok(stdscr, TRUE);
+#endif /* MAINDEBUG */
+ return;
+ }
+
+#ifdef TRACE
+ TR(TRACE_UPDATE | TRACE_MOVE, ("After real line marking:"));
+ if (_nc_tracing & (TRACE_UPDATE | TRACE_MOVE))
+ linedump();
+#endif /* TRACE */
+
+ /* time to shuffle lines to do scroll optimization */
+ do {
+ int first; /* first line of current hunk */
+ int last; /* last line of current hunk */
+ int ofirst; /* oldnum index of first line */
+ int olast; /* oldnum index of last line */
+ int disp; /* hunk displacement */
+
+ TR(TRACE_UPDATE | TRACE_MOVE, ("Pass %d:", pass++));
+
+ first = 0; /* start scan at top line */
+ no_hunk_moved = TRUE;
+
+ while (first < LINES)
+ {
+ /* find the beginning of a hunk */
+ while (first < LINES && OLDNUM(first) == _NEWINDEX)
+ first++;
+ if (first >= LINES)
+ break;
+
+ /* find the end of the hunk */
+ for (last = first; last < LINES; last++)
+ if (last == LINES - 1 || OLDNUM(last + 1) != OLDNUM(last) + 1)
+ break;
+
+ /* find the corresponding range on the old screen */
+ ofirst = OLDNUM(first);
+ olast = OLDNUM(last);
+
+ /* compute the hunk's displacement */
+ disp = first - OLDNUM(first);
+
+ TR(TRACE_UPDATE | TRACE_MOVE, ("found hunk: first = %2d, last = %2d, ofirst = %2d, olast = %2d, disp = %2d",
+ first, last, ofirst, olast, disp));
+
+ /* OK, time to try to move the hunk? */
+ if (disp != 0)
+ if (all_discarded(ofirst, olast, disp))
+ {
+ int m;
+
+ if (disp > 0)
+ olast += disp;
+ else /* (disp < 0) */
+ ofirst += disp;
+
+ TR(TRACE_UPDATE | TRACE_MOVE, ("scroll [%d, %d] by %d", ofirst, olast, -disp));
+#ifndef MAINDEBUG
+ (void) _nc_mvcur_scrolln(-disp, ofirst, olast, LINES - 1);
+ _nc_scroll_window(curscr, -disp, ofirst, olast);
+#endif /* MAINDEBUG */
+
+ for (m = ofirst; m <= olast; m++)
+ {
+ REAL(m) = _NEWINDEX;
+#ifndef MAINDEBUG
+ /*
+ * This will tell the second stage of the optimizer
+ * that every line in the hunk on the real screen has
+ * been changed.
+ */
+ curscr->_line[m].firstchar = 0;
+ curscr->_line[m].lastchar = curscr->_maxx;
+#endif /* MAINDEBUG */
+ }
+ for (m = first; m <= last; m++)
+ OLDNUM(m) = _NEWINDEX;
+
+ no_hunk_moved = FALSE;
+ }
+
+ /* OK, done with this hunk */
+ first = last + 1;
+ }
+ } while
+ (!no_hunk_moved);
+}
+
+#if defined(TRACE) || defined(MAINDEBUG)
+static void linedump(void)
+/* dump the state of the real and virtual oldnum fields */
+{
+ int n;
+ char buf[BUFSIZ];
+
+ (void) strcpy(buf, "real");
+ for (n = 0; n < LINES; n++)
+ (void) sprintf(buf + strlen(buf), " %02d", REAL(n));
+ TR(TRACE_UPDATE | TRACE_MOVE, (buf));
+
+ (void) strcpy(buf, "virt");
+ for (n = 0; n < LINES; n++)
+ (void) sprintf(buf + strlen(buf), " %02d", OLDNUM(n));
+ TR(TRACE_UPDATE | TRACE_MOVE, (buf));
+}
+#endif /* defined(TRACE) || defined(MAINDEBUG) */
+
+#ifdef MAINDEBUG
+
+main()
+{
+ char line[BUFSIZ], *st;
+
+ _nc_tracing = TRACE_MOVE;
+ for (;;)
+ {
+ int n;
+
+ for (n = 0; n < LINES; n++)
+ {
+ reallines[n] = n;
+ oldnums[n] = _NEWINDEX;
+ }
+
+ /* grab the test vector */
+ if (fgets(line, sizeof(line), stdin) == (char *)NULL)
+ exit(0);
+
+ /* 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, " "));
+
+ /* display it */
+ (void) fputs("Initial input:\n", stderr);
+ linedump();
+
+ _nc_scroll_optimize();
+ }
+}
+
+#endif /* MAINDEBUG */
+
+/* hardscroll.c ends here */
+
diff --git a/lib/libcurses/id_subwins.c b/lib/libcurses/id_subwins.c
deleted file mode 100644
index 3528348ff46..00000000000
--- a/lib/libcurses/id_subwins.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)id_subwins.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include "curses.h"
-
-/*
- * __id_subwins --
- * Re-sync the pointers to lines for all the subwindows.
- */
-void
-__id_subwins(orig)
- register WINDOW *orig;
-{
- register WINDOW *win;
- register int oy, realy, y;
-
- realy = orig->begy + orig->cury;
- for (win = orig->nextp; win != orig; win = win->nextp) {
- /*
- * If the window ends before our current position, don't need
- * to do anything.
- */
- if (win->begy + win->maxy <= realy)
- continue;
-
- oy = orig->cury;
- for (y = realy - win->begy; y < win->maxy; y++, oy++)
- win->lines[y]->line =
- &orig->lines[oy]->line[win->ch_off];
- }
-}
diff --git a/lib/libcurses/idlok.c b/lib/libcurses/idlok.c
deleted file mode 100644
index 4d3bb592697..00000000000
--- a/lib/libcurses/idlok.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)idlok.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include "curses.h"
-
-/*
- * idlok --
- * Turn on and off using insert/deleteln sequences for the
- * given window.
- */
-void
-idlok(win, bf)
- WINDOW *win;
- int bf;
-{
- if (bf)
- win->flags |= __IDLINE;
- else
- win->flags &= ~__IDLINE;
-}
diff --git a/lib/libcurses/initscr.c b/lib/libcurses/initscr.c
deleted file mode 100644
index 1af8b6f34ea..00000000000
--- a/lib/libcurses/initscr.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)initscr.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include <signal.h>
-#include <stdlib.h>
-
-#include "curses.h"
-
-/*
- * initscr --
- * Initialize the current and standard screen.
- */
-WINDOW *
-initscr()
-{
- register char *sp;
-
-#ifdef DEBUG
- __CTRACE("initscr\n");
-#endif
- __echoit = 1;
- __pfast = __rawmode = __noqch = 0;
-
- if (gettmode() == ERR)
- return (NULL);
-
- /*
- * If My_term is set, or can't find a terminal in the environment,
- * use Def_term.
- */
- if (My_term || (sp = getenv("TERM")) == NULL)
- sp = Def_term;
- if (setterm(sp) == ERR)
- return (NULL);
-
- /* Need either homing or cursor motion for refreshes */
- if (!HO && !CM)
- return (NULL);
-
- if (curscr != NULL)
- delwin(curscr);
- if ((curscr = newwin(LINES, COLS, 0, 0)) == ERR)
- return (NULL);
- clearok(curscr, 1);
-
- if (stdscr != NULL)
- delwin(stdscr);
- if ((stdscr = newwin(LINES, COLS, 0, 0)) == ERR) {
- delwin(curscr);
- return (NULL);
- }
-
- __set_stophandler();
-
-#ifdef DEBUG
- __CTRACE("initscr: LINES = %d, COLS = %d\n", LINES, COLS);
-#endif
- __startwin();
-
- return (stdscr);
-}
diff --git a/lib/libcurses/insch.c b/lib/libcurses/insch.c
deleted file mode 100644
index 36cc0dee894..00000000000
--- a/lib/libcurses/insch.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)insch.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include <string.h>
-
-#include "curses.h"
-
-/*
- * winsch --
- * Do an insert-char on the line, leaving (cury, curx) unchanged.
- */
-int
-winsch(win, ch)
- register WINDOW *win;
- int ch;
-{
-
- register __LDATA *end, *temp1, *temp2;
-
- end = &win->lines[win->cury]->line[win->curx];
- temp1 = &win->lines[win->cury]->line[win->maxx - 1];
- temp2 = temp1 - 1;
- while (temp1 > end) {
- (void)memcpy(temp1, temp2, sizeof(__LDATA));
- temp1--, temp2--;
- }
- temp1->ch = ch;
- temp1->attr &= ~__STANDOUT;
- __touchline(win, win->cury, win->curx, win->maxx - 1, 0);
- if (win->cury == LINES - 1 &&
- (win->lines[LINES - 1]->line[COLS - 1].ch != ' ' ||
- win->lines[LINES -1]->line[COLS - 1].attr != 0))
- if (win->flags & __SCROLLOK) {
- wrefresh(win);
- scroll(win);
- win->cury--;
- } else
- return (ERR);
- return (OK);
-}
diff --git a/lib/libcurses/insertln.c b/lib/libcurses/insertln.c
deleted file mode 100644
index c2179f0f187..00000000000
--- a/lib/libcurses/insertln.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)insertln.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include <string.h>
-
-#include "curses.h"
-
-/*
- * winsertln --
- * Do an insert-line on the window, leaving (cury, curx) unchanged.
- */
-int
-winsertln(win)
- register WINDOW *win;
-{
-
- register int y, i;
- register __LINE *temp;
-
-#ifdef DEBUG
- __CTRACE("insertln: (%0.2o)\n", win);
-#endif
- if (win->orig == NULL)
- temp = win->lines[win->maxy - 1];
- for (y = win->maxy - 1; y > win->cury; --y) {
- win->lines[y]->flags &= ~__ISPASTEOL;
- win->lines[y - 1]->flags &= ~__ISPASTEOL;
- if (win->orig == NULL)
- win->lines[y] = win->lines[y - 1];
- else
- (void)memcpy(win->lines[y]->line,
- win->lines[y - 1]->line,
- win->maxx * __LDATASIZE);
- __touchline(win, y, 0, win->maxx - 1, 0);
- }
- if (win->orig == NULL)
- win->lines[y] = temp;
- else
- temp = win->lines[y];
- for(i = 0; i < win->maxx; i++) {
- temp->line[i].ch = ' ';
- temp->line[i].attr = 0;
- }
- __touchline(win, y, 0, win->maxx - 1, 0);
- if (win->orig == NULL)
- __id_subwins(win);
- return (OK);
-}
diff --git a/lib/libcurses/keys.list b/lib/libcurses/keys.list
new file mode 100644
index 00000000000..f9e3dd657c8
--- /dev/null
+++ b/lib/libcurses/keys.list
@@ -0,0 +1,150 @@
+key_a1 KEY_A1
+key_a3 KEY_A3
+key_b2 KEY_B2
+key_backspace KEY_BACKSPACE
+key_beg KEY_BEG
+key_btab KEY_BTAB
+key_c1 KEY_C1
+key_c3 KEY_C3
+key_cancel KEY_CANCEL
+key_catab KEY_CATAB
+key_clear KEY_CLEAR
+key_close KEY_CLOSE
+key_command KEY_COMMAND
+key_copy KEY_COPY
+key_create KEY_CREATE
+key_ctab KEY_CTAB
+key_dc KEY_DC
+key_dl KEY_DL
+key_down KEY_DOWN
+key_eic KEY_EIC
+key_end KEY_END
+key_enter KEY_ENTER
+key_eol KEY_EOL
+key_eos KEY_EOS
+key_exit KEY_EXIT
+key_f0 KEY_F(0)
+key_f1 KEY_F(1)
+key_f2 KEY_F(2)
+key_f3 KEY_F(3)
+key_f4 KEY_F(4)
+key_f5 KEY_F(5)
+key_f6 KEY_F(6)
+key_f7 KEY_F(7)
+key_f8 KEY_F(8)
+key_f9 KEY_F(9)
+key_f10 KEY_F(10)
+key_f11 KEY_F(11)
+key_f12 KEY_F(12)
+key_f13 KEY_F(13)
+key_f14 KEY_F(14)
+key_f15 KEY_F(15)
+key_f16 KEY_F(16)
+key_f17 KEY_F(17)
+key_f18 KEY_F(18)
+key_f19 KEY_F(19)
+key_f20 KEY_F(20)
+key_f21 KEY_F(21)
+key_f22 KEY_F(22)
+key_f23 KEY_F(23)
+key_f24 KEY_F(24)
+key_f25 KEY_F(25)
+key_f26 KEY_F(26)
+key_f27 KEY_F(27)
+key_f28 KEY_F(28)
+key_f29 KEY_F(29)
+key_f30 KEY_F(30)
+key_f31 KEY_F(31)
+key_f32 KEY_F(32)
+key_f33 KEY_F(33)
+key_f34 KEY_F(34)
+key_f35 KEY_F(35)
+key_f36 KEY_F(36)
+key_f37 KEY_F(37)
+key_f38 KEY_F(38)
+key_f39 KEY_F(39)
+key_f40 KEY_F(40)
+key_f41 KEY_F(41)
+key_f42 KEY_F(42)
+key_f43 KEY_F(43)
+key_f44 KEY_F(44)
+key_f45 KEY_F(45)
+key_f46 KEY_F(46)
+key_f47 KEY_F(47)
+key_f48 KEY_F(48)
+key_f49 KEY_F(49)
+key_f50 KEY_F(50)
+key_f51 KEY_F(51)
+key_f52 KEY_F(52)
+key_f53 KEY_F(53)
+key_f54 KEY_F(54)
+key_f55 KEY_F(55)
+key_f56 KEY_F(56)
+key_f57 KEY_F(57)
+key_f58 KEY_F(58)
+key_f59 KEY_F(59)
+key_f60 KEY_F(60)
+key_f61 KEY_F(61)
+key_f62 KEY_F(62)
+key_f63 KEY_F(63)
+key_find KEY_FIND
+key_help KEY_HELP
+key_home KEY_HOME
+key_ic KEY_IC
+key_il KEY_IL
+key_left KEY_LEFT
+key_ll KEY_LL
+key_mark KEY_MARK
+key_message KEY_MESSAGE
+key_move KEY_MOVE
+key_next KEY_NEXT
+key_npage KEY_NPAGE
+key_open KEY_OPEN
+key_options KEY_OPTIONS
+key_ppage KEY_PPAGE
+key_previous KEY_PREVIOUS
+key_print KEY_PRINT
+key_redo KEY_REDO
+key_reference KEY_REFERENCE
+key_refresh KEY_REFRESH
+key_replace KEY_REPLACE
+key_restart KEY_RESTART
+key_resume KEY_RESUME
+key_right KEY_RIGHT
+key_save KEY_SAVE
+key_sbeg KEY_SBEG
+key_scancel KEY_SCANCEL
+key_scommand KEY_SCOMMAND
+key_scopy KEY_SCOPY
+key_screate KEY_SCREATE
+key_sdc KEY_SDC
+key_sdl KEY_SDL
+key_select KEY_SELECT
+key_send KEY_SEND
+key_seol KEY_SEOL
+key_sexit KEY_SEXIT
+key_sf KEY_SF
+key_sfind KEY_SFIND
+key_shelp KEY_SHELP
+key_shome KEY_SHOME
+key_sic KEY_SIC
+key_sleft KEY_SLEFT
+key_smessage KEY_SMESSAGE
+key_smove KEY_SMOVE
+key_snext KEY_SNEXT
+key_soptions KEY_SOPTIONS
+key_sprevious KEY_SPREVIOUS
+key_sprint KEY_SPRINT
+key_sr KEY_SR
+key_sredo KEY_SREDO
+key_sreplace KEY_SREPLACE
+key_sright KEY_SRIGHT
+key_srsume KEY_SRSUME
+key_ssave KEY_SSAVE
+key_ssuspend KEY_SSUSPEND
+key_stab KEY_STAB
+key_sundo KEY_SUNDO
+key_suspend KEY_SUSPEND
+key_undo KEY_UNDO
+key_up KEY_UP
+key_mouse KEY_MOUSE
diff --git a/lib/libcurses/lib_acs.c b/lib/libcurses/lib_acs.c
new file mode 100644
index 00000000000..ba867d7cc73
--- /dev/null
+++ b/lib/libcurses/lib_acs.c
@@ -0,0 +1,113 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+
+#include "curses.priv.h"
+#include "term.h" /* ena_acs, acs_chars */
+#include <string.h>
+
+chtype acs_map[128];
+
+void init_acs(void)
+{
+ T(("initializing ACS map"));
+
+ /*
+ * Initializations for a UNIX-like multi-terminal environment. Use
+ * ASCII chars and count on the terminfo description to do better.
+ */
+ ACS_ULCORNER = '+'; /* should be upper left corner */
+ ACS_LLCORNER = '+'; /* should be lower left corner */
+ ACS_URCORNER = '+'; /* should be upper right corner */
+ ACS_LRCORNER = '+'; /* should be lower right corner */
+ ACS_RTEE = '+'; /* should be tee pointing left */
+ ACS_LTEE = '+'; /* should be tee pointing right */
+ ACS_BTEE = '+'; /* should be tee pointing up */
+ ACS_TTEE = '+'; /* should be tee pointing down */
+ ACS_HLINE = '-'; /* should be horizontal line */
+ ACS_VLINE = '|'; /* should be vertical line */
+ ACS_PLUS = '+'; /* should be large plus or crossover */
+ ACS_S1 = '~'; /* should be scan line 1 */
+ ACS_S9 = '_'; /* should be scan line 9 */
+ ACS_DIAMOND = '+'; /* should be diamond */
+ ACS_CKBOARD = ':'; /* should be checker board (stipple) */
+ ACS_DEGREE = '\''; /* should be degree symbol */
+ ACS_PLMINUS = '#'; /* should be plus/minus */
+ ACS_BULLET = 'o'; /* should be bullet */
+ ACS_LARROW = '<'; /* should be arrow pointing left */
+ ACS_RARROW = '>'; /* should be arrow pointing right */
+ ACS_DARROW = 'v'; /* should be arrow pointing down */
+ ACS_UARROW = '^'; /* should be arrow pointing up */
+ ACS_BOARD = '#'; /* should be board of squares */
+ ACS_LANTERN = '#'; /* should be lantern symbol */
+ ACS_BLOCK = '#'; /* should be solid square block */
+ /* these defaults were invented for ncurses */
+ ACS_S3 = '-'; /* should be scan line 3 */
+ ACS_S7 = '-'; /* should be scan line 7 */
+ ACS_LEQUAL = '<'; /* should be less-than-or-equal-to */
+ ACS_GEQUAL = '>'; /* should be greater-than-or-equal-to */
+ ACS_PI = '*'; /* should be greek pi */
+ ACS_NEQUAL = '!'; /* should be not-equal */
+ ACS_STERLING = 'f'; /* should be pound-sterling symbol */
+
+#ifdef ena_acs
+ if (ena_acs != NULL)
+ {
+ TPUTS_TRACE("ena_acs");
+ putp(ena_acs);
+ }
+#endif /* ena_acs */
+
+#ifdef acs_chars
+#define ALTCHAR(c) ((chtype)(c) & A_CHARTEXT) | A_ALTCHARSET
+
+ if (acs_chars != NULL) {
+ size_t i = 0;
+ size_t length = strlen(acs_chars);
+
+ while (i < length)
+ switch (acs_chars[i]) {
+ case 'l':case 'm':case 'k':case 'j':
+ case 'u':case 't':case 'v':case 'w':
+ case 'q':case 'x':case 'n':case 'o':
+ case 's':case '`':case 'a':case 'f':
+ case 'g':case '~':case ',':case '+':
+ case '.':case '-':case 'h':case 'I':
+ case '0':case 'p':case 'r':case 'y':
+ case 'z':case '{':case '|':case '}':
+ acs_map[(unsigned int)acs_chars[i]] =
+ ALTCHAR(acs_chars[i+1]);
+ i++;
+ /* FALLTHRU */
+ default:
+ i++;
+ break;
+ }
+ }
+#ifdef TRACE
+ else {
+ T(("acsc not defined, using default mapping"));
+ }
+#endif /* TRACE */
+#endif /* acs_char */
+}
+
diff --git a/lib/libcurses/lib_addch.c b/lib/libcurses/lib_addch.c
new file mode 100644
index 00000000000..005c5bfbd22
--- /dev/null
+++ b/lib/libcurses/lib_addch.c
@@ -0,0 +1,287 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/*
+** lib_addch.c
+**
+** The routines waddch(), wattr_on(), wattr_off(), wchgat().
+**
+*/
+
+#include "curses.priv.h"
+#include <ctype.h>
+#include "unctrl.h"
+
+#define ALL_BUT_COLOR ((chtype)~(A_COLOR))
+
+int wattr_on(WINDOW *win, const attr_t at)
+{
+ T(("wattr_on(%p,%s) current = %s", win, _traceattr(at), _traceattr(win->_attrs)));
+ if (PAIR_NUMBER(at) > 0x00) {
+ win->_attrs = (win->_attrs & ALL_BUT_COLOR) | at ;
+ T(("new attribute is %s", _traceattr(win->_attrs)));
+ } else {
+ win->_attrs |= at;
+ T(("new attribute is %s", _traceattr(win->_attrs)));
+ }
+ return OK;
+}
+
+int wattr_off(WINDOW *win, const attr_t at)
+{
+#define IGNORE_COLOR_OFF FALSE
+
+ T(("wattr_off(%p,%s) current = %s", win, _traceattr(at), _traceattr(win->_attrs)));
+ if (IGNORE_COLOR_OFF == TRUE) {
+ if (PAIR_NUMBER(at) == 0xff) /* turn off color */
+ win->_attrs &= ~at;
+ else /* leave color alone */
+ win->_attrs &= ~(at|ALL_BUT_COLOR);
+ } else {
+ if (PAIR_NUMBER(at) > 0x00) /* turn off color */
+ win->_attrs &= ~at;
+ else /* leave color alone */
+ win->_attrs &= ~(at|ALL_BUT_COLOR);
+ }
+ T(("new attribute is %s", _traceattr(win->_attrs)));
+ return OK;
+}
+
+int wchgat(WINDOW *win, int n, attr_t attr, short color, const void *opts)
+{
+ int i;
+
+ for (i = win->_curx; i <= win->_maxx && (n == -1 || (n-- > 0)); i++)
+ win->_line[win->_cury].text[i]
+ = (win->_line[win->_cury].text[i] & A_CHARTEXT)
+ | attr
+ | COLOR_PAIR(color);
+
+ return OK;
+}
+
+/*
+ * Ugly microtweaking alert. Everything from here to end of module is
+ * likely to be speed-critical -- profiling data sure says it is!
+ * Most of the important screen-painting functions are shells around
+ * waddch(). So we make every effort to reduce function-call overhead
+ * by inlining stuff, even at the cost of making wrapped copies for
+ * export. Also we supply some internal versions that don't call the
+ * window sync hook, for use by string-put functions.
+ */
+
+static __inline chtype render_char(WINDOW *win, chtype oldch, chtype newch)
+/* compute a rendition of the given char correct for the current context */
+{
+ if ((oldch & A_CHARTEXT) == ' ')
+ newch |= win->_bkgd;
+ else if (!(newch & A_ATTRIBUTES))
+ newch |= (win->_bkgd & A_ATTRIBUTES);
+ TR(TRACE_VIRTPUT, ("bkg = %lx -> ch = %lx", win->_bkgd, newch));
+
+ return(newch);
+}
+
+chtype _nc_render(WINDOW *win, chtype oldch, chtype newch)
+/* make render_char() visible while still allowing us to inline it below */
+{
+ return(render_char(win, oldch, newch));
+}
+
+/* actions needed to process a newline within addch_nosync() */
+#define DO_NEWLINE x = 0; \
+ win->_flags &= ~_NEED_WRAP; \
+ y++; \
+ if (y > win->_regbottom) { \
+ y--; \
+ if (win->_scroll) \
+ scroll(win); \
+ }
+
+/* check if position is legal; if not, return error */
+#define CHECK_POSITION(win, x, y) \
+ if (y > win->_maxy || x > win->_maxx || y < 0 || x < 0) { \
+ TR(TRACE_VIRTPUT, ("Alert! Win=%p _curx = %d, _cury = %d " \
+ "(_maxx = %d, _maxy = %d)", win, x, y, \
+ win->_maxx, win->_maxy)); \
+ win->_curx = win->_cury = 0; \
+ win->_flags &= ~_NEED_WRAP; \
+ return(ERR); \
+ }
+
+static __inline
+int waddch_literal(WINDOW *win, chtype ch)
+{
+register int x, y;
+
+ x = win->_curx;
+ y = win->_cury;
+
+ CHECK_POSITION(win, x, y);
+
+ if (win->_flags & _NEED_WRAP) {
+ TR(TRACE_MOVE, ("new char when NEED_WRAP set at %d,%d",y,x));
+ DO_NEWLINE
+ }
+
+ /*
+ * We used to pass in
+ * win->_line[y].text[x]
+ * as a second argument, but the value of the old character
+ * is not relevant here.
+ */
+ ch = render_char(win, 0, ch);
+
+ TR(TRACE_VIRTPUT, ("win attr = %s", _traceattr(win->_attrs)));
+ ch |= win->_attrs;
+
+ if (win->_line[y].text[x] != ch) {
+ if (win->_line[y].firstchar == _NOCHANGE)
+ win->_line[y].firstchar = win->_line[y].lastchar = x;
+ else if (x < win->_line[y].firstchar)
+ win->_line[y].firstchar = x;
+ else if (x > win->_line[y].lastchar)
+ win->_line[y].lastchar = x;
+
+ }
+
+ win->_line[y].text[x++] = ch;
+ TR(TRACE_VIRTPUT, ("(%d, %d) = %s | %s",
+ y, x,
+ _tracechar((unsigned char)(ch & A_CHARTEXT)),
+ _traceattr((ch & (chtype)A_ATTRIBUTES))));
+ if (x > win->_maxx) {
+ TR(TRACE_MOVE, ("NEED_WRAP set at %d,%d",y,x));
+ win->_flags |= _NEED_WRAP;
+ x--;
+ }
+
+ win->_curx = x;
+ win->_cury = y;
+
+ return OK;
+}
+
+static __inline
+int waddch_nosync(WINDOW *win, const chtype c)
+/* the workhorse function -- add a character to the given window */
+{
+register chtype ch = c;
+register int x, y;
+int newx;
+
+ x = win->_curx;
+ y = win->_cury;
+
+ CHECK_POSITION(win, x, y);
+
+ if (ch & A_ALTCHARSET)
+ goto noctrl;
+
+ switch ((int)(ch&A_CHARTEXT)) {
+ case '\t':
+ if (win->_flags & _NEED_WRAP) {
+ x = 0;
+ newx = min(TABSIZE, win->_maxx+1);
+ } else
+ newx = min(x + (TABSIZE-(x%TABSIZE)), win->_maxx+1);
+ while (win->_curx < newx) {
+ if (waddch_literal(win, ' ' | (ch&A_ATTRIBUTES)) == ERR)
+ return(ERR);
+ }
+ return(OK);
+ case '\n':
+ wclrtoeol(win);
+ DO_NEWLINE
+ break;
+ case '\r':
+ x = 0;
+ win->_flags &= ~_NEED_WRAP;
+ break;
+ case '\b':
+ if (win->_flags & _NEED_WRAP)
+ win->_flags &= ~_NEED_WRAP;
+ else if (--x < 0)
+ x = 0;
+ break;
+ default:
+ if (is7bits(ch & A_CHARTEXT) && iscntrl(ch & A_CHARTEXT))
+ return(waddstr(win, unctrl((unsigned char)ch)));
+
+ /* FALLTHRU */
+ noctrl:
+ waddch_literal(win, ch);
+ return(OK);
+ }
+
+ win->_curx = x;
+ win->_cury = y;
+
+ return(OK);
+}
+
+#undef DO_NEWLINE
+
+int _nc_waddch_nosync(WINDOW *win, const chtype c)
+/* export copy of waddch_nosync() so the string-put functions can use it */
+{
+ return(waddch_nosync(win, c));
+}
+
+/*
+ * The versions below call _nc_synhook(). We wanted to avoid this in the
+ * version exported for string puts; they'll call _nc_synchook once at end
+ * of run.
+ */
+
+/* These are actual entry points */
+
+int waddch(WINDOW *win, const chtype ch)
+{
+ TR(TRACE_VIRTPUT, ("waddch(%p, %s | %s) called", win,
+ _tracechar((unsigned char)(ch & A_CHARTEXT)),
+ _traceattr((ch & (chtype)A_ATTRIBUTES))));
+
+ if (waddch_nosync(win, ch) == ERR)
+ return(ERR);
+ else
+ {
+ _nc_synchook(win);
+ TR(TRACE_VIRTPUT, ("waddch() is done"));
+ return(OK);
+ }
+}
+
+int wechochar(WINDOW *win, const chtype ch)
+{
+ TR(TRACE_VIRTPUT, ("wechochar(%p,%s (%s)) called", win,
+ _tracechar((unsigned char)(ch & A_CHARTEXT)),
+ _traceattr((ch & (chtype)A_ATTRIBUTES))));
+
+ if (waddch_literal(win, ch) == ERR)
+ return(ERR);
+ else
+ {
+ _nc_synchook(win);
+ TR(TRACE_VIRTPUT, ("wechochar() is done"));
+ return(OK);
+ }
+}
diff --git a/lib/libcurses/lib_addstr.c b/lib/libcurses/lib_addstr.c
new file mode 100644
index 00000000000..6d98d0464c6
--- /dev/null
+++ b/lib/libcurses/lib_addstr.c
@@ -0,0 +1,88 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/*
+** lib_addstr.c
+*
+** The routines waddnstr(), waddchnstr().
+**
+*/
+
+#include "curses.priv.h"
+#include <string.h>
+
+int
+waddnstr(WINDOW *win, const char *const astr, int n)
+{
+unsigned char *str = (unsigned char *)astr;
+int code = ERR;
+
+ T(("waddnstr(%p,\"%s\",%d) called %s", win, _nc_visbuf(astr), n, _traceattr(win->_attrs)));
+
+ if (str != NULL) {
+
+ TR(TRACE_VIRTPUT, ("str is not null"));
+ code = OK;
+ if (n < 0)
+ n = (int)strlen(astr);
+
+ while((n-- > 0) && (*str != '\0')) {
+ TR(TRACE_VIRTPUT, ("*str = %x", *str));
+ if (_nc_waddch_nosync(win, (chtype)*str++) == ERR) {
+ code = ERR;
+ break;
+ }
+ }
+ }
+ _nc_synchook(win);
+ TR(TRACE_VIRTPUT, ("waddnstr returns %d", code));
+ return code;
+}
+
+int
+waddchnstr(WINDOW *win, const chtype *const astr, int n)
+{
+short oy = win->_cury;
+short ox = win->_curx;
+chtype *str = (chtype *)astr;
+int code = OK;
+
+ T(("waddchnstr(%p,%p,%d) called", win, str, n));
+
+ if (n < 0) {
+ n = 0;
+ while (*str++ != 0)
+ n++;
+ str = (chtype *)astr;
+ }
+
+ while(n-- > 0) {
+ if (_nc_waddch_nosync(win, *str++) == ERR) {
+ code = ERR;
+ break;
+ }
+ }
+
+ win->_curx = ox;
+ win->_cury = oy;
+ _nc_synchook(win);
+ return code;
+}
diff --git a/lib/libcurses/lib_beep.c b/lib/libcurses/lib_beep.c
new file mode 100644
index 00000000000..0beee7c160c
--- /dev/null
+++ b/lib/libcurses/lib_beep.c
@@ -0,0 +1,79 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+/*
+ * beep.c
+ *
+ * Routines beep() and flash()
+ *
+ */
+
+#include "curses.priv.h"
+#include "term.h" /* beep, flash */
+
+/*
+ * beep()
+ *
+ * Sound the current terminal's audible bell if it has one. If not,
+ * flash the screen if possible.
+ *
+ */
+
+int beep(void)
+{
+ T(("beep() called"));
+
+ /* should make sure that we are not in altchar mode */
+ if (bell) {
+ TPUTS_TRACE("bell");
+ return(putp(bell));
+ } else if (flash_screen) {
+ TPUTS_TRACE("flash_screen");
+ return(putp(flash_screen));
+ }
+ else
+ return(ERR);
+}
+
+/*
+ * flash()
+ *
+ * Flash the current terminal's screen if possible. If not,
+ * sound the audible bell if one exists.
+ *
+ */
+
+int flash(void)
+{
+ T(("flash() called"));
+
+ /* should make sure that we are not in altchar mode */
+ if (flash_screen) {
+ TPUTS_TRACE("flash_screen");
+ return(putp(flash_screen));
+ } else if (bell) {
+ TPUTS_TRACE("bell");
+ return(putp(bell));
+ }
+ else
+ return(ERR);
+}
diff --git a/lib/libcurses/lib_bkgd.c b/lib/libcurses/lib_bkgd.c
new file mode 100644
index 00000000000..aa6ff7a7ff1
--- /dev/null
+++ b/lib/libcurses/lib_bkgd.c
@@ -0,0 +1,41 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+#include "curses.priv.h"
+
+int wbkgd(WINDOW *win, const chtype ch)
+{
+int x, y;
+
+ T(("wbkgd(%p, %lx) called", win, ch));
+ wbkgdset(win, ch);
+
+ for (y = 0; y <= win->_maxy; y++)
+ for (x = 0; x <= win->_maxx; x++)
+ if ((win->_line[y].text[x]&A_CHARTEXT) == ' ')
+ win->_line[y].text[x] |= ch;
+ else
+ win->_line[y].text[x] |= (ch&A_ATTRIBUTES);
+ touchwin(win);
+ _nc_synchook(win);
+ return OK;
+}
+
diff --git a/lib/libcurses/lib_box.c b/lib/libcurses/lib_box.c
new file mode 100644
index 00000000000..bf45be33336
--- /dev/null
+++ b/lib/libcurses/lib_box.c
@@ -0,0 +1,146 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+
+/*
+** lib_box.c
+**
+** line drawing routines:
+** wborder()
+** whline()
+** wvline()
+**
+*/
+
+#include "curses.priv.h"
+
+int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts,
+ chtype bs, chtype tl, chtype tr, chtype bl, chtype br)
+{
+short i;
+short endx, endy;
+
+ T(("wborder() called"));
+
+ if (ls == 0) ls = ACS_VLINE;
+ if (rs == 0) rs = ACS_VLINE;
+ if (ts == 0) ts = ACS_HLINE;
+ if (bs == 0) bs = ACS_HLINE;
+ if (tl == 0) tl = ACS_ULCORNER;
+ if (tr == 0) tr = ACS_URCORNER;
+ if (bl == 0) bl = ACS_LLCORNER;
+ if (br == 0) br = ACS_LRCORNER;
+
+ ls |= (win->_attrs ? win->_attrs : (win->_bkgd & A_ATTRIBUTES));
+ rs |= (win->_attrs ? win->_attrs : (win->_bkgd & A_ATTRIBUTES));
+ ts |= (win->_attrs ? win->_attrs : (win->_bkgd & A_ATTRIBUTES));
+ bs |= (win->_attrs ? win->_attrs : (win->_bkgd & A_ATTRIBUTES));
+ tl |= (win->_attrs ? win->_attrs : (win->_bkgd & A_ATTRIBUTES));
+ tr |= (win->_attrs ? win->_attrs : (win->_bkgd & A_ATTRIBUTES));
+ bl |= (win->_attrs ? win->_attrs : (win->_bkgd & A_ATTRIBUTES));
+ br |= (win->_attrs ? win->_attrs : (win->_bkgd & A_ATTRIBUTES));
+
+ T(("using %lx, %lx, %lx, %lx, %lx, %lx, %lx, %lx", ls, rs, ts, bs, tl, tr, bl, br));
+
+ endx = win->_maxx;
+ endy = win->_maxy;
+
+ for (i = 0; i <= endx; i++) {
+ win->_line[0].text[i] = ts;
+ win->_line[endy].text[i] = bs;
+ }
+ win->_line[endy].firstchar = win->_line[0].firstchar = 0;
+ win->_line[endy].lastchar = win->_line[0].lastchar = endx;
+
+ for (i = 0; i <= endy; i++) {
+ win->_line[i].text[0] = ls;
+ win->_line[i].text[endx] = rs;
+ win->_line[i].firstchar = 0;
+ win->_line[i].lastchar = endx;
+ }
+ win->_line[0].text[0] = tl;
+ win->_line[0].text[endx] = tr;
+ win->_line[endy].text[0] = bl;
+ win->_line[endy].text[endx] = br;
+
+ _nc_synchook(win);
+ return OK;
+}
+
+int whline(WINDOW *win, chtype ch, int n)
+{
+short line;
+short start;
+short end;
+
+ T(("whline(%p,%lx,%d) called", win, ch, n));
+
+ line = win->_cury;
+ start = win->_curx;
+ end = start + n - 1;
+ if (end > win->_maxx)
+ end = win->_maxx;
+
+ if (win->_line[line].firstchar == _NOCHANGE || win->_line[line].firstchar > start)
+ win->_line[line].firstchar = start;
+ if (win->_line[line].lastchar == _NOCHANGE || win->_line[line].lastchar < start)
+ win->_line[line].lastchar = end;
+
+ if (ch == 0)
+ ch = ACS_HLINE;
+ while ( end >= start) {
+ win->_line[line].text[end] = ch | win->_attrs;
+ end--;
+ }
+
+ return OK;
+}
+
+int wvline(WINDOW *win, chtype ch, int n)
+{
+short row, col;
+short end;
+
+ T(("wvline(%p,%lx,%d) called", win, ch, n));
+
+ row = win->_cury;
+ col = win->_curx;
+ end = row + n - 1;
+ if (end > win->_maxy)
+ end = win->_maxy;
+
+ if (ch == 0)
+ ch = ACS_VLINE;
+
+ while(end >= row) {
+ win->_line[end].text[col] = ch | win->_attrs;
+ if (win->_line[end].firstchar == _NOCHANGE || win->_line[end].firstchar > col)
+ win->_line[end].firstchar = col;
+ if (win->_line[end].lastchar == _NOCHANGE || win->_line[end].lastchar < col)
+ win->_line[end].lastchar = col;
+ end--;
+ }
+
+ _nc_synchook(win);
+ return OK;
+}
+
diff --git a/lib/libcurses/lib_clear.c b/lib/libcurses/lib_clear.c
new file mode 100644
index 00000000000..6f329139818
--- /dev/null
+++ b/lib/libcurses/lib_clear.c
@@ -0,0 +1,40 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/*
+** lib_clear.c
+**
+** The routine wclear().
+**
+*/
+
+#include "curses.priv.h"
+
+int wclear(WINDOW *win)
+{
+ T(("wclear(%p) called", win));
+
+ werase(win);
+
+ win->_clear = TRUE;
+
+ return OK;
+}
diff --git a/lib/libcurses/lib_clrbot.c b/lib/libcurses/lib_clrbot.c
new file mode 100644
index 00000000000..f7feca7ec5d
--- /dev/null
+++ b/lib/libcurses/lib_clrbot.c
@@ -0,0 +1,72 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/*
+** lib_clrbot.c
+**
+** The routine wclrtobot().
+**
+*/
+
+#include "curses.priv.h"
+
+int wclrtobot(WINDOW *win)
+{
+chtype *ptr, *end, *maxx = NULL;
+short y, startx, minx;
+
+ T(("wclrtobot(%p) called", win));
+
+ startx = win->_curx;
+ if (win->_flags & _NEED_WRAP)
+ startx++;
+
+ T(("clearing from y = %d to y = %d with maxx = %d", win->_cury, win->_maxy, win->_maxx));
+
+ for (y = win->_cury; y <= win->_maxy; y++) {
+ minx = _NOCHANGE;
+ end = &win->_line[y].text[win->_maxx];
+
+ for (ptr = &win->_line[y].text[startx]; ptr <= end; ptr++) {
+ int blank = _nc_render(win, *ptr, BLANK);
+
+ if (*ptr != blank) {
+ maxx = ptr;
+ if (minx == _NOCHANGE)
+ minx = ptr - win->_line[y].text;
+ *ptr = blank;
+ }
+ }
+
+ if (minx != _NOCHANGE) {
+ if (win->_line[y].firstchar > minx
+ || win->_line[y].firstchar == _NOCHANGE)
+ win->_line[y].firstchar = minx;
+
+ if (win->_line[y].lastchar < maxx - win->_line[y].text)
+ win->_line[y].lastchar = maxx - win->_line[y].text;
+ }
+
+ startx = 0;
+ }
+ _nc_synchook(win);
+ return OK;
+}
diff --git a/lib/libcurses/lib_clreol.c b/lib/libcurses/lib_clreol.c
new file mode 100644
index 00000000000..146432ac575
--- /dev/null
+++ b/lib/libcurses/lib_clreol.c
@@ -0,0 +1,70 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+/*
+** lib_clreol.c
+**
+** The routine wclrtoeol().
+**
+*/
+
+#include "curses.priv.h"
+
+int wclrtoeol(WINDOW *win)
+{
+chtype *maxx, *ptr, *end;
+short y, x, minx;
+
+ T(("wclrtoeol(%p) called", win));
+
+ y = win->_cury;
+ x = win->_curx;
+ if (win->_flags & _NEED_WRAP
+ || y > win->_maxy
+ || x > win->_maxx)
+ return ERR;
+
+ end = &win->_line[y].text[win->_maxx];
+ minx = _NOCHANGE;
+ maxx = &win->_line[y].text[x];
+
+ for (ptr = maxx; ptr <= end; ptr++) {
+ int blank = _nc_render(win, win->_line[y].text[x], BLANK);
+
+ if (*ptr != blank) {
+ maxx = ptr;
+ if (minx == _NOCHANGE)
+ minx = ptr - win->_line[y].text;
+ *ptr = blank;
+ }
+ }
+
+ if (minx != _NOCHANGE) {
+ if (win->_line[y].firstchar > minx || win->_line[y].firstchar == _NOCHANGE)
+ win->_line[y].firstchar = minx;
+
+ if (win->_line[y].lastchar < maxx - win->_line[y].text)
+ win->_line[y].lastchar = maxx - win->_line[y].text;
+ }
+ _nc_synchook(win);
+ return(OK);
+}
diff --git a/lib/libcurses/lib_color.c b/lib/libcurses/lib_color.c
new file mode 100644
index 00000000000..b690cb71f33
--- /dev/null
+++ b/lib/libcurses/lib_color.c
@@ -0,0 +1,325 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/* lib_color.c
+ *
+ * Handles color emulation of SYS V curses
+ *
+ */
+
+#include "curses.priv.h"
+#include <stdlib.h>
+#include <string.h>
+#include "term.h"
+
+int COLOR_PAIRS;
+int COLORS;
+unsigned char *color_pairs;
+
+typedef struct
+{
+ short red, green, blue;
+}
+color_t;
+static color_t *color_table;
+
+static const color_t cga_palette[] =
+{
+ /* R G B */
+ {0, 0, 0}, /* COLOR_BLACK */
+ {1000, 0, 0}, /* COLOR_RED */
+ {0, 1000, 0}, /* COLOR_GREEN */
+ {1000, 1000, 0}, /* COLOR_YELLOW */
+ {0, 0, 1000}, /* COLOR_BLUE */
+ {1000, 0, 1000}, /* COLOR_MAGENTA */
+ {0, 1000, 1000}, /* COLOR_CYAN */
+ {1000, 1000, 1000}, /* COLOR_WHITE */
+};
+static const color_t hls_palette[] =
+{
+ /* H L S */
+ {0, 0, 0}, /* COLOR_BLACK */
+ {120, 50, 100}, /* COLOR_RED */
+ {240, 50, 100}, /* COLOR_GREEN */
+ {180, 50, 100}, /* COLOR_YELLOW */
+ {330, 50, 100}, /* COLOR_BLUE */
+ {60, 50, 100}, /* COLOR_MAGENTA */
+ {300, 50, 100}, /* COLOR_CYAN */
+ {0, 50, 100}, /* COLOR_WHITE */
+};
+
+int start_color(void)
+{
+ T(("start_color() called."));
+
+#ifdef orig_pair
+ if (orig_pair != NULL)
+ {
+ TPUTS_TRACE("orig_pair");
+ putp(orig_pair);
+ }
+#endif /* orig_pair */
+#ifdef orig_colors
+ if (orig_colors != NULL)
+ {
+ TPUTS_TRACE("orig_colors");
+ putp(orig_colors);
+ }
+#endif /* orig_colors */
+#if defined(orig_pair) && defined(orig_colors)
+ if (!orig_pair && !orig_colors)
+ return ERR;
+#endif /* defined(orig_pair) && defined(orig_colors) */
+ if (max_pairs != -1)
+ COLOR_PAIRS = max_pairs;
+ else
+ return ERR;
+ color_pairs = calloc((unsigned int)max_pairs, sizeof(char));
+ if (max_colors != -1)
+ COLORS = max_colors;
+ else
+ return ERR;
+ SP->_coloron = 1;
+
+#ifdef hue_lightness_saturation
+ color_table = malloc(sizeof(color_t) * COLORS);
+ if (hue_lightness_saturation)
+ memcpy(color_table, hls_palette, sizeof(color_t) * COLORS);
+ else
+#endif /* hue_lightness_saturation */
+ memcpy(color_table, cga_palette, sizeof(color_t) * COLORS);
+
+ if (orig_colors)
+ {
+ TPUTS_TRACE("orig_colors");
+ putp(orig_colors);
+ }
+
+ T(("started color: COLORS = %d, COLOR_PAIRS = %d", COLORS, COLOR_PAIRS));
+
+ return OK;
+}
+
+#ifdef hue_lightness_saturation
+static void rgb2hls(short r, short g, short b, short *h, short *l, short *s)
+/* convert RGB to HLS system */
+{
+ short min, max, t;
+
+ if ((min = g < r ? g : r) > b) min = b;
+ if ((max = g > r ? g : r) < b) max = b;
+
+ /* calculate lightness */
+ *l = (min + max) / 20;
+
+ if (min == max) /* black, white and all shades of gray */
+ {
+ *h = 0;
+ *s = 0;
+ return;
+ }
+
+ /* calculate saturation */
+ if (*l < 50)
+ *s = ((max - min) * 100) / (max + min);
+ else *s = ((max - min) * 100) / (2000 - max - min);
+
+ /* calculate hue */
+ if (r == max)
+ t = 120 + ((g - b) * 60) / (max - min);
+ else
+ if (g == max)
+ t = 240 + ((b - r) * 60) / (max - min);
+ else
+ t = 360 + ((r - g) * 60) / (max - min);
+
+ *h = t % 360;
+}
+#endif /* hue_lightness_saturation */
+
+int init_pair(short pair, short f, short b)
+{
+ T(("init_pair( %d, %d, %d )", pair, f, b));
+
+ if ((pair < 1) || (pair >= COLOR_PAIRS))
+ return ERR;
+ if ((f < 0) || (f >= COLORS) || (b < 0) || (b >= COLORS))
+ return ERR;
+
+ /*
+ * FIXME: when a pair's content is changed, replace its colors
+ * (if pair was initialized before a screen update is performed
+ * replacing original pair colors with the new ones)
+ */
+
+ color_pairs[pair] = ( (f & 0x0f) | (b & 0x0f) << 4 );
+
+ if (initialize_pair)
+ {
+ const color_t *tp = hue_lightness_saturation ? hls_palette : cga_palette;
+
+ T(("initializing pair: pair = %d, fg=(%d,%d,%d), bg=(%d,%d,%d)\n",
+ pair,
+ tp[f].red, tp[f].green, tp[f].blue,
+ tp[b].red, tp[b].green, tp[b].blue));
+
+ if (initialize_pair)
+ {
+ TPUTS_TRACE("initialize_pair");
+ putp(tparm(initialize_pair,
+ pair,
+ tp[f].red, tp[f].green, tp[f].blue,
+ tp[b].red, tp[b].green, tp[b].blue));
+ }
+ }
+
+ return OK;
+}
+
+int init_color(short color, short r, short g, short b)
+{
+#ifdef initialize_color
+ if (initialize_color == NULL)
+ return ERR;
+#endif /* initialize_color */
+
+ if (color < 0 || color >= COLORS)
+ return ERR;
+#ifdef hue_lightness_saturation
+ if (hue_lightness_saturation == TRUE)
+ if (r < 0 || r > 360 || g < 0 || g > 100 || b < 0 || b > 100)
+ return ERR;
+ if (hue_lightness_saturation == FALSE)
+#endif /* hue_lightness_saturation */
+ if (r < 0 || r > 1000 || g < 0 || g > 1000 || b < 0 || b > 1000)
+ return ERR;
+
+#ifdef hue_lightness_saturation
+ if (hue_lightness_saturation)
+ rgb2hls(r, g, b,
+ &color_table[color].red,
+ &color_table[color].green,
+ &color_table[color].blue);
+ else
+#endif /* hue_lightness_saturation */
+ {
+ color_table[color].red = r;
+ color_table[color].green = g;
+ color_table[color].blue = b;
+ }
+
+#ifdef initialize_color
+ if (initialize_color)
+ {
+ TPUTS_TRACE("initialize_color");
+ putp(tparm(initialize_color, color, r, g, b));
+ }
+#endif /* initialize_color */
+ return OK;
+}
+
+bool can_change_color(void)
+{
+ return (can_change != 0);
+}
+
+int has_colors(void)
+{
+ return ((orig_pair != NULL || orig_colors != NULL)
+ && (max_colors != -1) && (max_pairs != -1)
+ &&
+ (((set_foreground != NULL) && (set_background != NULL))
+ || ((set_a_foreground != NULL) && (set_a_background != NULL))
+ || set_color_pair)
+ );
+}
+
+int color_content(short color, short *r, short *g, short *b)
+{
+ if (color < 0 || color > COLORS)
+ return ERR;
+
+ *r = color_table[color].red;
+ *g = color_table[color].green;
+ *b = color_table[color].blue;
+ return OK;
+}
+
+int pair_content(short pair, short *f, short *b)
+{
+
+ if ((pair < 1) || (pair > COLOR_PAIRS))
+ return ERR;
+ *f = color_pairs[pair] & 0x0f;
+ *b = color_pairs[pair] & 0xf0;
+ *b >>= 4;
+ return OK;
+}
+
+
+void _nc_do_color(int pair, int (*outc)(int))
+{
+ short fg, bg;
+
+ if (pair == 0)
+ {
+ if (orig_pair)
+ {
+ TPUTS_TRACE("orig_pair");
+ tputs(orig_pair, 1, outc);
+ }
+ }
+ else
+ {
+ if (set_color_pair)
+ {
+ TPUTS_TRACE("set_color_pair");
+ tputs(tparm(set_color_pair, pair), 1, outc);
+ }
+ else
+ {
+ pair_content(pair, &fg, &bg);
+
+ T(("setting colors: pair = %d, fg = %d, bg = %d\n", pair, fg, bg));
+
+ if (set_a_foreground)
+ {
+ TPUTS_TRACE("set_a_foreground");
+ tputs(tparm(set_a_foreground, fg), 1, outc);
+ }
+ else
+ {
+ TPUTS_TRACE("set_foreground");
+ tputs(tparm(set_foreground, fg), 1, outc);
+ }
+ if (set_a_background)
+ {
+ TPUTS_TRACE("set_a_background");
+ tputs(tparm(set_a_background, bg), 1, outc);
+ }
+ else
+ {
+ TPUTS_TRACE("set_background");
+ tputs(tparm(set_background, bg), 1, outc);
+ }
+ }
+ }
+}
diff --git a/lib/libcurses/lib_data.c b/lib/libcurses/lib_data.c
new file mode 100644
index 00000000000..b3c962e3c16
--- /dev/null
+++ b/lib/libcurses/lib_data.c
@@ -0,0 +1,64 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/*
+** lib_data.c
+**
+** Common data that may/may not be allocated, but is referenced globally
+**
+*/
+
+#include "curses.priv.h"
+
+#include <stdlib.h>
+
+WINDOW *stdscr, *curscr, *newscr;
+
+/*
+ * The variable 'SP' will be defined as a function on systems that cannot link
+ * data-only modules, since it is used in a lot of places within ncurses and we
+ * cannot guarantee that any application will use any particular function. We
+ * put the WINDOW variables in this module, because it appears that any
+ * application that uses them will also use 'SP'.
+ *
+ * This module intentionally does not reference other ncurses modules, to avoid
+ * module coupling that increases the size of the executable.
+ */
+#if BROKEN_LINKER
+static SCREEN *my_screen;
+
+SCREEN *_nc_screen(void)
+{
+ return my_screen;
+}
+
+int _nc_alloc_screen(void)
+{
+ return ((my_screen = (SCREEN *) calloc(sizeof(*SP), 1)) != NULL);
+}
+
+void _nc_set_screen(SCREEN *sp)
+{
+ my_screen = sp;
+}
+#else
+SCREEN *SP;
+#endif
diff --git a/lib/libcurses/lib_delch.c b/lib/libcurses/lib_delch.c
new file mode 100644
index 00000000000..6f8f37185dd
--- /dev/null
+++ b/lib/libcurses/lib_delch.c
@@ -0,0 +1,56 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/*
+** lib_delch.c
+**
+** The routine wdelch().
+**
+*/
+
+#include "curses.priv.h"
+
+int wdelch(WINDOW *win)
+{
+chtype *temp1, *temp2;
+chtype *end;
+chtype blank = _nc_render(win, ' ', BLANK | win->_attrs);
+
+ T(("wdelch(%p) called", win));
+
+ end = &win->_line[win->_cury].text[win->_maxx];
+ temp2 = &win->_line[win->_cury].text[win->_curx + 1];
+ temp1 = temp2 - 1;
+
+ while (temp1 < end)
+ *temp1++ = *temp2++;
+
+ *temp1 = blank;
+
+ win->_line[win->_cury].lastchar = win->_maxx;
+
+ if (win->_line[win->_cury].firstchar == _NOCHANGE
+ || win->_line[win->_cury].firstchar > win->_curx)
+ win->_line[win->_cury].firstchar = win->_curx;
+
+ _nc_synchook(win);
+ return OK;
+}
diff --git a/lib/libcurses/lib_delwin.c b/lib/libcurses/lib_delwin.c
new file mode 100644
index 00000000000..b3453cad74a
--- /dev/null
+++ b/lib/libcurses/lib_delwin.c
@@ -0,0 +1,53 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/*
+** lib_delwin.c
+**
+** The routine delwin().
+**
+*/
+
+#include "curses.priv.h"
+#include <stdlib.h>
+
+int delwin(WINDOW *win)
+{
+int i;
+
+ T(("delwin(%p) called", win));
+
+ if (win == NULL)
+ return(ERR);
+
+ if (! (win->_flags & _SUBWIN)) {
+ for (i = 0; i <= win->_maxy && win->_line[i].text; i++)
+ free(win->_line[i].text);
+ }
+
+ free(win->_line);
+
+ touchwin((win->_flags & _SUBWIN) ? win->_parent : curscr);
+
+ free(win);
+
+ return(OK);
+}
diff --git a/lib/libcurses/lib_doupdate.c b/lib/libcurses/lib_doupdate.c
new file mode 100644
index 00000000000..3d6f2d79e38
--- /dev/null
+++ b/lib/libcurses/lib_doupdate.c
@@ -0,0 +1,840 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+/*-----------------------------------------------------------------
+ *
+ * lib_doupdate.c
+ *
+ * The routine doupdate() and its dependents. Also _nc_outstr(),
+ * so all physcal output is concentrated here.
+ *
+ *-----------------------------------------------------------------*/
+
+#include "curses.priv.h"
+#include <stdlib.h>
+#include <sys/types.h>
+#if HAVE_SYS_TIME_H && ! SYSTEM_LOOKS_LIKE_SCO
+#include <sys/time.h>
+#endif
+#if HAVE_SYS_SELECT_H
+#include <sys/types.h>
+#include <sys/select.h>
+#endif
+#include <string.h>
+#include "term.h"
+
+/*
+ * 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 6
+
+/*
+ * 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 void ClrUpdate( WINDOW *scr );
+static void TransformLine( int const lineno );
+static void NoIDcTransformLine( int const lineno );
+static void IDcTransformLine( int const lineno );
+static void ClearScreen( void );
+static int InsStr( chtype *line, int count );
+static void DelChar( int count );
+
+#define UpdateAttrs(c) if (curscr->_attrs != AttrOf(c)) { \
+ curscr->_attrs = AttrOf(c); \
+ vidputs(curscr->_attrs, _nc_outch); \
+ }
+
+#ifdef POSITION_DEBUG
+/****************************************************************************
+ *
+ * Debugging code. Only works on ANSI-standard terminals.
+ *
+ ****************************************************************************/
+
+void position_check(int expected_y, int expected_x, char *legend)
+/* check to see if the real cursor position matches the virtual */
+{
+ static char buf[9];
+ int y, x;
+
+ if (_nc_tracing)
+ return;
+
+ memset(buf, '\0', sizeof(buf));
+ (void) write(1, "\033[6n", 4); /* only works on ANSI-compatibles */
+ (void) read(0, (void *)buf, 8);
+ _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 (y - 1 != expected_y || x - 1 != expected_x)
+ _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);
+}
+#endif /* POSITION_DEBUG */
+
+/****************************************************************************
+ *
+ * Optimized update code
+ *
+ ****************************************************************************/
+
+static __inline void GoTo(int const row, int const col)
+{
+ chtype oldattr = SP->_current_attr;
+
+ TR(TRACE_MOVE, ("GoTo(%d, %d) from (%d, %d)",
+ row, col, SP->_cursrow, SP->_curscol));
+
+#ifdef POSITION_DEBUG
+ position_check(SP->_cursrow, SP->_curscol, "GoTo");
+#endif /* POSITION_DEBUG */
+
+ /*
+ * 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!
+ */
+ if ((oldattr & A_ALTCHARSET)
+ || (oldattr && !move_standout_mode))
+ {
+ TR(TRACE_CHARPUT, ("turning off (%lx) %s before move",
+ oldattr, _traceattr(oldattr)));
+ vidattr(A_NORMAL);
+ curscr->_attrs = A_NORMAL;
+ }
+
+ mvcur(SP->_cursrow, SP->_curscol, row, col);
+ SP->_cursrow = row;
+ SP->_curscol = col;
+}
+
+static __inline void PutAttrChar(chtype ch)
+{
+ if (tilde_glitch && (TextOf(ch) == '~'))
+ ch = ('`' | AttrOf(ch));
+
+ TR(TRACE_CHARPUT, ("PutAttrChar(%s, %s) at (%d, %d)",
+ _tracechar((unsigned char)TextOf(ch)),
+ _traceattr(AttrOf(ch)),
+ SP->_cursrow, SP->_curscol));
+ UpdateAttrs(ch);
+ putc((int)TextOf(ch), SP->_ofp);
+ SP->_curscol++;
+ if (char_padding) {
+ TPUTS_TRACE("char_padding");
+ putp(char_padding);
+ }
+}
+
+static bool check_pending(void)
+/* check for pending input */
+{
+ if (SP->_checkfd >= 0) {
+ 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)
+ {
+ fflush(SP->_ofp);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/*
+ * No one supports recursive inline functions. However, gcc is quieter if we
+ * instantiate the recursive part separately.
+ */
+#if CC_HAS_INLINE_FUNCS
+static void callPutChar(chtype const);
+#else
+#define callPutChar(ch) PutChar(ch)
+#endif
+
+static __inline void PutChar(chtype const ch)
+/* insert character, handling automargin stuff */
+{
+ if (!(SP->_cursrow == screen_lines-1 && SP->_curscol == screen_columns-1
+ && auto_right_margin && !eat_newline_glitch))
+ {
+ PutAttrChar(ch); /* normal case */
+ }
+ else if (!auto_right_margin /* maybe we can suppress automargin */
+ || (enter_am_mode && exit_am_mode))
+ {
+ bool old_am = auto_right_margin;
+
+ if (old_am)
+ {
+ TPUTS_TRACE("exit_am_mode");
+ putp(exit_am_mode);
+ }
+ PutAttrChar(ch);
+ if (old_am)
+ {
+ TPUTS_TRACE("enter_am_mode");
+ putp(enter_am_mode);
+ }
+ }
+ else
+ {
+ GoTo(screen_lines-1,screen_columns-2);
+ callPutChar(ch);
+ GoTo(screen_lines-1,screen_columns-2);
+ if (InsStr(newscr->_line[screen_lines-1].text+screen_columns-2,1)==ERR)
+ return;
+ }
+
+ if (SP->_curscol >= screen_columns)
+ {
+ 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++;
+ }
+ else
+ {
+ SP->_curscol--;
+ }
+ }
+#ifdef POSITION_DEBUG
+ position_check(SP->_cursrow, SP->_curscol, "PutChar");
+#endif /* POSITION_DEBUG */
+}
+
+#if CC_HAS_INLINE_FUNCS
+static void callPutChar(chtype const ch)
+{
+ PutChar(ch);
+}
+#endif
+
+int doupdate(void)
+{
+int i;
+
+ T(("doupdate() called"));
+
+#ifdef TRACE
+ if (_nc_tracing & TRACE_UPDATE)
+ {
+ if (curscr->_clear)
+ _tracef("curscr is clear");
+ else
+ _tracedump("curscr", curscr);
+ _tracedump("newscr", newscr);
+ }
+#endif /* TRACE */
+
+ _nc_signal_handler(FALSE);
+
+ if (SP->_endwin == TRUE) {
+ T(("coming back from shell mode"));
+ reset_prog_mode();
+ if (enter_ca_mode)
+ {
+ TPUTS_TRACE("enter_ca_mode");
+ putp(enter_ca_mode);
+ }
+ /*
+ * Undo the effects of terminal init strings that assume
+ * they know the screen size. Useful when you're running
+ * a vt100 emulation through xterm. Note: this may change
+ * the physical cursor location.
+ */
+ if (change_scroll_region)
+ {
+ TPUTS_TRACE("change_scroll_region");
+ putp(tparm(change_scroll_region, 0, screen_lines - 1));
+ }
+ _nc_mouse_resume(SP);
+ newscr->_clear = TRUE;
+ SP->_endwin = FALSE;
+ }
+
+ /*
+ * FIXME: Full support for magic-cookie terminals could go in here.
+ * The theory: we scan the virtual screen looking for attribute
+ * changes. Where we find one, check to make sure it's realizable
+ * by seeing if the required number of un-attributed blanks are
+ * present before or after the change. If not, nuke the attributes
+ * out of the following or preceding cells on the virtual screen,
+ * forward to the next change or backwards to the previous one. If
+ * so, displace the change by the required number of characters.
+ */
+
+ if (curscr->_clear) { /* force refresh ? */
+ T(("clearing and updating curscr"));
+ ClrUpdate(curscr); /* yes, clear all & update */
+ curscr->_clear = FALSE; /* reset flag */
+ } else {
+ if (newscr->_clear) {
+ T(("clearing and updating newscr"));
+ ClrUpdate(newscr);
+ newscr->_clear = FALSE;
+ } else {
+ int changedlines;
+
+ _nc_scroll_optimize();
+
+ T(("Transforming lines"));
+ for (i = changedlines = 0;
+ i < min(screen_lines,newscr->_maxy+1);
+ i++)
+ {
+ /*
+ * 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)
+ {
+ newscr->_line[i].firstchar = _NOCHANGE;
+ newscr->_line[i].lastchar = _NOCHANGE;
+ newscr->_line[i].oldindex = i;
+ }
+ if (i <= curscr->_maxy)
+ {
+ curscr->_line[i].firstchar = _NOCHANGE;
+ curscr->_line[i].lastchar = _NOCHANGE;
+ curscr->_line[i].oldindex = i;
+ }
+
+ /*
+ * Here is our line-breakout optimization.
+ */
+ if ((changedlines % CHECK_INTERVAL) == changedlines-1
+ && check_pending())
+ goto cleanup;
+ }
+ }
+ }
+
+ /* this code won't be executed often */
+ for (i = screen_lines; i <= newscr->_maxy; i++)
+ {
+ newscr->_line[i].firstchar = _NOCHANGE;
+ newscr->_line[i].lastchar = _NOCHANGE;
+ newscr->_line[i].oldindex = i;
+ }
+ for (i = screen_lines; i <= curscr->_maxy; i++)
+ {
+ curscr->_line[i].firstchar = _NOCHANGE;
+ curscr->_line[i].lastchar = _NOCHANGE;
+ curscr->_line[i].oldindex = i;
+ }
+
+ curscr->_curx = newscr->_curx;
+ curscr->_cury = newscr->_cury;
+
+ GoTo(curscr->_cury, curscr->_curx);
+
+ cleanup:
+ if (curscr->_attrs != A_NORMAL)
+ vidattr(curscr->_attrs = A_NORMAL);
+
+ fflush(SP->_ofp);
+
+ _nc_signal_handler(TRUE);
+
+ return OK;
+}
+
+/*
+** ClrUpdate(scr)
+**
+** Update by clearing and redrawing the entire screen.
+**
+*/
+
+static void ClrUpdate(WINDOW *scr)
+{
+int i = 0, j = 0;
+int lastNonBlank;
+
+ T(("ClrUpdate(%p) called", scr));
+ if (back_color_erase) {
+ T(("back_color_erase, turning attributes off"));
+ vidattr(A_NORMAL);
+ }
+ ClearScreen();
+
+ if (scr != curscr) {
+ for (i = 0; i < screen_lines ; i++)
+ for (j = 0; j < screen_columns; j++)
+ curscr->_line[i].text[j] = ' '; /* shouldn't this include the bkgd? */
+ }
+
+ T(("updating screen from scratch"));
+ for (i = 0; i < min(screen_lines, scr->_maxy + 1); i++) {
+ GoTo(i, 0);
+ lastNonBlank = scr->_maxx;
+
+ while (scr->_line[i].text[lastNonBlank] == BLANK && lastNonBlank > 0)
+ lastNonBlank--;
+
+ for (j = 0; j <= min(lastNonBlank, screen_columns); j++) {
+ PutChar(scr->_line[i].text[j]);
+ }
+ }
+
+
+ if (scr != curscr) {
+ for (i = 0; i < screen_lines ; i++)
+ for (j = 0; j < screen_columns; j++)
+ curscr->_line[i].text[j] = scr->_line[i].text[j];
+ }
+}
+
+/*
+** ClrToEOL()
+**
+** Clear to EOL. Deal with background color erase if terminal has this
+** glitch. This code forces the current color and highlight to A_NORMAL
+** before emitting the erase sequence, then restores the current
+** attribute.
+*/
+
+static void ClrToEOL(void)
+{
+int j;
+attr_t oldcolor = 0; /* initialization pacifies -Wall */
+
+ if (back_color_erase) {
+ TPUTS_TRACE("orig_pair");
+ putp(orig_pair);
+ oldcolor = SP->_current_attr & A_COLOR;
+ SP->_current_attr &=~ A_COLOR;
+ }
+ TPUTS_TRACE("clr_eol");
+ putp(clr_eol);
+ if (back_color_erase)
+ vidattr(SP->_current_attr | oldcolor);
+
+ for (j = SP->_curscol; j < screen_columns; j++)
+ curscr->_line[SP->_cursrow].text[j] = ' ';
+}
+
+static void ClrToBOL(void)
+{
+int j;
+attr_t oldcolor = 0; /* initialization pacifies -Wall */
+
+ if (back_color_erase) {
+ TPUTS_TRACE("orig_pair");
+ putp(orig_pair);
+ oldcolor = SP->_current_attr & A_COLOR;
+ SP->_current_attr &=~ A_COLOR;
+ }
+ TPUTS_TRACE("clr_bol");
+ putp(clr_bol);
+ if (back_color_erase)
+ vidattr(SP->_current_attr | oldcolor);
+
+ for (j = 0; j <= SP->_curscol; j++)
+ curscr->_line[SP->_cursrow].text[j] = ' ';
+}
+
+/*
+** TransformLine(lineno)
+**
+** Call either IDcTransformLine or NoIDcTransformLine to do the
+** update, depending upon availability of insert/delete character.
+*/
+
+static void TransformLine(int const lineno)
+{
+
+ T(("TransformLine(%d) called",lineno));
+
+ if ( (insert_character || (enter_insert_mode && exit_insert_mode))
+ && delete_character)
+ IDcTransformLine(lineno);
+ else
+ NoIDcTransformLine(lineno);
+}
+
+
+
+/*
+** NoIDcTransformLine(lineno)
+**
+** Transform the given line in curscr to the one in newscr, without
+** using Insert/Delete Character.
+**
+** firstChar = position of first different character in line
+** lastChar = position of last different character in line
+**
+** overwrite all characters between firstChar and lastChar.
+**
+*/
+
+static void NoIDcTransformLine(int const lineno)
+{
+int firstChar, lastChar;
+chtype *newLine = newscr->_line[lineno].text;
+chtype *oldLine = curscr->_line[lineno].text;
+int k;
+int attrchanged = 0;
+
+ T(("NoIDcTransformLine(%d) called", lineno));
+
+ firstChar = 0;
+ while (firstChar < screen_columns - 1 && newLine[firstChar] == oldLine[firstChar]) {
+ if(ceol_standout_glitch) {
+ if(AttrOf(newLine[firstChar]) != AttrOf(oldLine[firstChar]))
+ attrchanged = 1;
+ }
+ firstChar++;
+ }
+
+ T(("first char at %d is %lx", firstChar, newLine[firstChar]));
+ if (firstChar > screen_columns)
+ return;
+
+ if(ceol_standout_glitch && attrchanged) {
+ firstChar = 0;
+ lastChar = screen_columns - 1;
+ GoTo(lineno, firstChar);
+ if(clr_eol)
+ ClrToEOL();
+ } else {
+ lastChar = screen_columns - 1;
+ while (lastChar > firstChar && newLine[lastChar] == oldLine[lastChar])
+ lastChar--;
+ GoTo(lineno, firstChar);
+ }
+
+ T(("updating chars %d to %d", firstChar, lastChar));
+ for (k = firstChar; k <= lastChar; k++) {
+ PutChar(newLine[k]);
+ oldLine[k] = newLine[k];
+ }
+}
+
+/*
+** IDcTransformLine(lineno)
+**
+** Transform the given line in curscr to the one in newscr, using
+** Insert/Delete Character.
+**
+** 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 IDcTransformLine(int const lineno)
+{
+int firstChar, oLastChar, nLastChar;
+chtype *newLine = newscr->_line[lineno].text;
+chtype *oldLine = curscr->_line[lineno].text;
+int k, n;
+int attrchanged = 0;
+
+ T(("IDcTransformLine(%d) called", lineno));
+
+ if(ceol_standout_glitch && clr_eol) {
+ firstChar = 0;
+ while(firstChar < screen_columns) {
+ if(AttrOf(newLine[firstChar]) != AttrOf(oldLine[firstChar]))
+ attrchanged = 1;
+ firstChar++;
+ }
+ }
+
+ firstChar = 0;
+
+ if (attrchanged) {
+ GoTo(lineno, firstChar);
+ ClrToEOL();
+ for( k = 0 ; k <= (screen_columns-1) ; k++ )
+ PutChar(newLine[k]);
+ } else {
+ while (firstChar < screen_columns &&
+ newLine[firstChar] == oldLine[firstChar])
+ firstChar++;
+
+ if (firstChar >= screen_columns)
+ return;
+
+ if (clr_bol)
+ {
+ int oFirstChar, nFirstChar;
+
+ for (oFirstChar = 0; oFirstChar < screen_columns; oFirstChar++)
+ if (oldLine[oFirstChar] != BLANK)
+ break;
+ for (nFirstChar = 0; nFirstChar < screen_columns; nFirstChar++)
+ if (newLine[nFirstChar] != BLANK)
+ break;
+
+ if (nFirstChar > oFirstChar + (int)strlen(clr_bol))
+ {
+ GoTo(lineno, nFirstChar - 1);
+ ClrToBOL();
+
+ if(nFirstChar == screen_columns)
+ return;
+
+ if (nFirstChar > firstChar)
+ firstChar = nFirstChar;
+ }
+ }
+
+ oLastChar = screen_columns - 1;
+ while (oLastChar > firstChar && oldLine[oLastChar] == BLANK)
+ oLastChar--;
+
+ nLastChar = screen_columns - 1;
+ while (nLastChar > firstChar && newLine[nLastChar] == BLANK)
+ nLastChar--;
+
+ if((nLastChar == firstChar)
+ && clr_eol
+ && (curscr->_attrs == A_NORMAL)) {
+ GoTo(lineno, firstChar);
+ ClrToEOL();
+ if(newLine[firstChar] != BLANK )
+ PutChar(newLine[firstChar]);
+ } else if( newLine[nLastChar] != oldLine[oLastChar] ) {
+ n = max( nLastChar , oLastChar );
+
+ GoTo(lineno, firstChar);
+ for( k=firstChar ; k <= n ; k++ )
+ PutChar(newLine[k]);
+ } else {
+ while (newLine[nLastChar] == oldLine[oLastChar]) {
+ if (nLastChar != 0
+ && oLastChar != 0) {
+ nLastChar--;
+ oLastChar--;
+ } else {
+ break;
+ }
+ }
+
+ n = min(oLastChar, nLastChar);
+ GoTo(lineno, firstChar);
+
+ for (k=firstChar; k <= n; k++)
+ PutChar(newLine[k]);
+
+ if (oLastChar < nLastChar)
+ InsStr(&newLine[k], nLastChar - oLastChar);
+
+ else if (oLastChar > nLastChar ) {
+ /*
+ * 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(newLine[screen_columns-1]);
+ DelChar(oLastChar - nLastChar);
+ }
+ }
+ }
+ for (k = firstChar; k < screen_columns; k++)
+ oldLine[k] = newLine[k];
+}
+
+/*
+** ClearScreen()
+**
+** Clear the physical screen and put cursor at home
+**
+*/
+
+static void ClearScreen(void)
+{
+
+ T(("ClearScreen() called"));
+
+ if (clear_screen) {
+ TPUTS_TRACE("clear_screen");
+ putp(clear_screen);
+ SP->_cursrow = SP->_curscol = 0;
+#ifdef POSITION_DEBUG
+ position_check(SP->_cursrow, SP->_curscol, "ClearScreen");
+#endif /* POSITION_DEBUG */
+ } else if (clr_eos) {
+ SP->_cursrow = SP->_curscol = -1;
+ GoTo(0,0);
+
+ TPUTS_TRACE("clr_eos");
+ putp(clr_eos);
+ } else if (clr_eol) {
+ SP->_cursrow = SP->_curscol = -1;
+
+ while (SP->_cursrow < screen_lines) {
+ GoTo(SP->_cursrow, 0);
+ TPUTS_TRACE("clr_eol");
+ putp(clr_eol);
+ }
+ GoTo(0,0);
+ }
+ T(("screen cleared"));
+}
+
+
+/*
+** InsStr(line, count)
+**
+** Insert the count characters pointed to by line.
+**
+*/
+
+static int InsStr(chtype *line, int count)
+{
+ T(("InsStr(%p,%d) called", line, count));
+
+ if (enter_insert_mode && exit_insert_mode) {
+ TPUTS_TRACE("enter_insert_mode");
+ putp(enter_insert_mode);
+ while (count) {
+ PutAttrChar(*line);
+ line++;
+ count--;
+ }
+ TPUTS_TRACE("exit_insert_mode");
+ putp(exit_insert_mode);
+ return(OK);
+ } else if (parm_ich) {
+ TPUTS_TRACE("parm_ich");
+ tputs(tparm(parm_ich, count), count, _nc_outch);
+ while (count) {
+ PutAttrChar(*line);
+ line++;
+ count--;
+ }
+ return(OK);
+ } else {
+ while (count) {
+ TPUTS_TRACE("insert_character");
+ putp(insert_character);
+ PutAttrChar(*line);
+ if (insert_padding)
+ {
+ TPUTS_TRACE("insert_padding");
+ putp(insert_padding);
+ }
+ line++;
+ count--;
+ }
+ return(OK);
+ }
+}
+
+/*
+** DelChar(count)
+**
+** Delete count characters at current position
+**
+*/
+
+static void DelChar(int count)
+{
+ T(("DelChar(%d) called, position = (%d,%d)", count, newscr->_cury, newscr->_curx));
+
+ if (parm_dch) {
+ TPUTS_TRACE("parm_dch");
+ tputs(tparm(parm_dch, count), count, _nc_outch);
+ } else {
+ while (count--)
+ {
+ TPUTS_TRACE("delete_character");
+ putp(delete_character);
+ }
+ }
+}
+
+/*
+** _nc_outstr(char *str)
+**
+** Emit a string without waiting for update.
+*/
+
+void _nc_outstr(char *str)
+{
+ FILE *ofp = SP ? SP->_ofp : stdout;
+
+ (void) fputs(str, ofp);
+ (void) fflush(ofp);
+}
diff --git a/lib/libcurses/lib_endwin.c b/lib/libcurses/lib_endwin.c
new file mode 100644
index 00000000000..065b5c7567b
--- /dev/null
+++ b/lib/libcurses/lib_endwin.c
@@ -0,0 +1,55 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+/*
+** lib_endwin.c
+**
+** The routine endwin().
+**
+*/
+
+#include "curses.priv.h"
+#include "term.h"
+
+int
+endwin(void)
+{
+ T(("endwin() called"));
+
+ SP->_endwin = TRUE;
+
+ _nc_mouse_wrap(SP);
+
+ mvcur(-1, -1, screen_lines - 1, 0);
+
+ curs_set(1); /* set cursor to normal mode */
+
+ if (SP->_coloron == TRUE && orig_pair)
+ putp(orig_pair);
+
+ _nc_mvcur_wrap(); /* wrap up cursor addressing */
+
+ if (curscr && (curscr->_attrs != A_NORMAL))
+ vidattr(curscr->_attrs = A_NORMAL);
+
+ return(reset_shell_mode());
+}
diff --git a/lib/libcurses/lib_erase.c b/lib/libcurses/lib_erase.c
new file mode 100644
index 00000000000..1a3ee5c8841
--- /dev/null
+++ b/lib/libcurses/lib_erase.c
@@ -0,0 +1,66 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+/*
+** lib_erase.c
+**
+** The routine werase().
+**
+*/
+
+#include "curses.priv.h"
+
+int werase(WINDOW *win)
+{
+int y;
+chtype *sp, *end, *start, *maxx = NULL;
+short minx;
+
+ T(("werase(%p) called", win));
+
+ for (y = 0; y <= win->_maxy; y++) {
+ minx = _NOCHANGE;
+ start = win->_line[y].text;
+ end = &start[win->_maxx];
+
+ maxx = start;
+ for (sp = start; sp <= end; sp++) {
+ maxx = sp;
+ if (minx == _NOCHANGE)
+ minx = sp - start;
+ *sp = _nc_render(win, *sp, BLANK);
+ }
+
+ if (minx != _NOCHANGE) {
+ if (win->_line[y].firstchar > minx ||
+ win->_line[y].firstchar == _NOCHANGE)
+ win->_line[y].firstchar = minx;
+
+ if (win->_line[y].lastchar < maxx - win->_line[y].text)
+ win->_line[y].lastchar = maxx - win->_line[y].text;
+ }
+ }
+ win->_curx = win->_cury = 0;
+ win->_flags &= ~_NEED_WRAP;
+ _nc_synchook(win);
+ return OK;
+}
diff --git a/lib/libcurses/lib_getch.c b/lib/libcurses/lib_getch.c
new file mode 100644
index 00000000000..12372bc0fc0
--- /dev/null
+++ b/lib/libcurses/lib_getch.c
@@ -0,0 +1,329 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/*
+** lib_getch.c
+**
+** The routine getch().
+**
+*/
+
+#include "curses.priv.h"
+#include <sys/types.h>
+#include <string.h>
+#include <errno.h>
+#if !HAVE_EXTERN_ERRNO
+extern int errno;
+#endif
+
+#define head SP->_fifohead
+#define tail SP->_fifotail
+#define peek SP->_fifopeek
+
+#define h_inc() { head == FIFO_SIZE-1 ? head = 0 : head++; if (head == tail) head = -1, tail = 0;}
+#define h_dec() { head == 0 ? head = FIFO_SIZE-1 : head--; if (head == tail) tail = -1;}
+#define t_inc() { tail == FIFO_SIZE-1 ? tail = 0 : tail++; if (tail == head) tail = -1;}
+#define p_inc() { peek == FIFO_SIZE-1 ? peek = 0 : peek++;}
+
+int ESCDELAY = 1000; /* max interval betw. chars in funkeys, in millisecs */
+
+static int fifo_peek(void)
+{
+ T(("peeking at %d", peek+1));
+ return SP->_fifo[++peek];
+}
+
+#ifdef TRACE
+static __inline void fifo_dump(void)
+{
+int i;
+ T(("head = %d, tail = %d, peek = %d", head, tail, peek));
+ for (i = 0; i < 10; i++)
+ T(("char %d = %s", i, _tracechar(SP->_fifo[i])));
+}
+#endif /* TRACE */
+
+static __inline int fifo_pull(void)
+{
+int ch;
+ ch = SP->_fifo[head];
+ T(("pulling %d from %d", ch, head));
+
+ h_inc();
+#ifdef TRACE
+ if (_nc_tracing & TRACE_FIFO) fifo_dump();
+#endif
+ return ch;
+}
+
+int ungetch(int ch)
+{
+ if (tail == -1)
+ return ERR;
+ if (head == -1) {
+ head = 0;
+ t_inc()
+ } else
+ h_dec();
+
+ SP->_fifo[head] = ch;
+ T(("ungetch ok"));
+#ifdef TRACE
+ if (_nc_tracing & TRACE_FIFO) fifo_dump();
+#endif
+ return OK;
+}
+
+static __inline int fifo_push(void)
+{
+int n;
+unsigned char ch;
+
+ if (tail == -1) return ERR;
+ /* FALLTHRU */
+again:
+ n = read(SP->_ifd, &ch, 1);
+ if (n == -1 && errno == EINTR)
+ goto again;
+ T(("read %d characters", n));
+
+ SP->_fifo[tail] = ch;
+ if (head == -1) head = tail;
+ t_inc();
+ T(("pushed %#x at %d", ch, tail));
+#ifdef TRACE
+ if (_nc_tracing & TRACE_FIFO) fifo_dump();
+#endif
+ return ch;
+}
+
+static __inline void fifo_clear(void)
+{
+int i;
+ for (i = 0; i < FIFO_SIZE; i++)
+ SP->_fifo[i] = 0;
+ head = -1; tail = peek = 0;
+}
+
+static int kgetch(WINDOW *);
+
+void _nc_backspace(WINDOW *win)
+{
+ if (win->_curx == 0)
+ {
+ beep();
+ return;
+ }
+
+ mvwaddstr(curscr, win->_begy + win->_cury, win->_begx + win->_curx, "\b \b");
+ waddstr(win, "\b \b");
+
+ /*
+ * This used to do the equivalent of _nc_outstr("\b \b"), which
+ * would fail on terminals with a non-backspace cursor_left
+ * character.
+ */
+ mvcur(win->_begy + win->_cury, win->_begx + win->_curx,
+ win->_begy + win->_cury, win->_begx + win->_curx - 1);
+ _nc_outstr(" ");
+ mvcur(win->_begy + win->_cury, win->_begx + win->_curx,
+ win->_begy + win->_cury, win->_begx + win->_curx - 1);
+ SP->_curscol--;
+}
+
+int
+wgetch(WINDOW *win)
+{
+bool setHere = FALSE; /* cbreak mode was set here */
+int ch;
+
+ T(("wgetch(%p) called", win));
+
+ /* this should be eliminated */
+ if (! win->_scroll && (SP->_echo) && (win->_flags & _FULLWIN)
+ && win->_curx == win->_maxx && win->_cury == win->_maxy)
+ return(ERR);
+
+ if ((is_wintouched(win) || (win->_flags & _HASMOVED)) && !(win->_flags & _ISPAD))
+ wrefresh(win);
+
+ if (SP->_echo && ! (SP->_raw || SP->_cbreak)) {
+ cbreak();
+ setHere = TRUE;
+ }
+
+ if (!win->_notimeout && (win->_delay >= 0 || SP->_cbreak > 1)) {
+ int delay;
+
+ T(("timed delay in wgetch()"));
+ if (SP->_cbreak > 1)
+ delay = (SP->_cbreak-1) * 100;
+ else
+ delay = win->_delay;
+
+ T(("delay is %d microseconds", delay));
+
+ if (head == -1) /* fifo is empty */
+ if (_nc_timed_wait(SP->_ifd, delay, NULL) == 0)
+ return ERR;
+ /* else go on to read data available */
+ }
+
+ /*
+ * Give the mouse interface a chance to pick up an event.
+ * If no mouse event, check for keyboard input.
+ */
+ if (_nc_mouse_event(SP))
+ ch = KEY_MOUSE;
+ else if (win->_use_keypad) {
+ /*
+ * This is tricky. We only want to get special-key
+ * events one at a time. But we want to accumulate
+ * mouse events until either (a) the mouse logic tells
+ * us it's picked up a complete gesture, or (b)
+ * there's a detectable time lapse after one.
+ *
+ * Note: if the mouse code starts failing to compose
+ * press/release events into clicks, you should probably
+ * increase _nc_max_click_interval.
+ */
+ int runcount = 0;
+
+ do {
+ ch = kgetch(win);
+ if (ch == KEY_MOUSE)
+ {
+ ++runcount;
+ if (_nc_mouse_inline(SP))
+ break;
+ }
+ } while
+ (ch == KEY_MOUSE
+ && (_nc_timed_wait(SP->_ifd, _nc_max_click_interval, NULL)
+ || !_nc_mouse_parse(runcount)));
+ if (runcount > 0 && ch != KEY_MOUSE)
+ {
+ /* mouse event sequence ended by keystroke, push it */
+ ungetch(ch);
+ ch = KEY_MOUSE;
+ }
+ } else {
+ if (head == -1)
+ fifo_push();
+ ch = fifo_pull();
+ }
+
+ /* Strip 8th-bit if so desired. We do this only for characters that
+ * are in the range 128-255, to provide compatibility with terminals
+ * that display only 7-bit characters. Note that 'ch' may be a
+ * function key at this point, so we mustn't strip _those_.
+ */
+ if ((ch < KEY_MIN) && (ch & 0x80))
+ if (!SP->_use_meta)
+ ch &= 0x7f;
+
+ if (!(win->_flags & _ISPAD) && SP->_echo) {
+ /* there must be a simpler way of doing this */
+ if (ch == erasechar() || ch == KEY_BACKSPACE || ch == KEY_LEFT)
+ _nc_backspace(win);
+ else if (ch < KEY_MIN) {
+ mvwaddch(curscr,
+ win->_begy + win->_cury,
+ win->_begx + win->_curx,
+ (chtype)(ch | win->_attrs));
+ waddch(win, (chtype)(ch | win->_attrs));
+ }
+ else
+ beep();
+ }
+ if (setHere)
+ nocbreak();
+
+ T(("wgetch returning : 0x%x = %s",
+ ch,
+ (ch > KEY_MIN) ? keyname(ch) : unctrl(ch)));
+
+ return(ch);
+}
+
+
+/*
+** int
+** kgetch()
+**
+** Get an input character, but take care of keypad sequences, returning
+** an appropriate code when one matches the input. After each character
+** is received, set an alarm call based on ESCDELAY. If no more of the
+** sequence is received by the time the alarm goes off, pass through
+** the sequence gotten so far.
+**
+*/
+
+static int
+kgetch(WINDOW *win)
+{
+struct try *ptr;
+int ch = 0;
+int timeleft = ESCDELAY;
+
+ TR(TRACE_FIFO, ("kgetch(%p) called", win));
+
+ ptr = SP->_keytry;
+
+ if (head == -1) {
+ ch = fifo_push();
+ peek = 0;
+ while (ptr != NULL) {
+ TR(TRACE_FIFO, ("ch: %s", _tracechar((unsigned char)ch)));
+ while ((ptr != NULL) && (ptr->ch != (unsigned char)ch))
+ ptr = ptr->sibling;
+#ifdef TRACE
+ if (ptr == NULL)
+ {TR(TRACE_FIFO, ("ptr is null"));}
+ else
+ TR(TRACE_FIFO, ("ptr=%p, ch=%d, value=%d",
+ ptr, ptr->ch, ptr->value));
+#endif /* TRACE */
+
+ if (ptr != NULL)
+ if (ptr->value != 0) { /* sequence terminated */
+ TR(TRACE_FIFO, ("end of sequence"));
+ fifo_clear();
+ return(ptr->value);
+ } else { /* go back for another character */
+ ptr = ptr->child;
+ TR(TRACE_FIFO, ("going back for more"));
+ } else
+ break;
+
+ TR(TRACE_FIFO, ("waiting for rest of sequence"));
+ if (_nc_timed_wait(SP->_ifd, timeleft, &timeleft) < 1) {
+ TR(TRACE_FIFO, ("ran out of time"));
+ return(fifo_pull());
+ } else {
+ TR(TRACE_FIFO, ("got more!"));
+ fifo_push();
+ ch = fifo_peek();
+ }
+ }
+ }
+ return(fifo_pull());
+}
diff --git a/lib/libcurses/lib_getstr.c b/lib/libcurses/lib_getstr.c
new file mode 100644
index 00000000000..5f4dbcd2b7c
--- /dev/null
+++ b/lib/libcurses/lib_getstr.c
@@ -0,0 +1,131 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+/*
+** lib_getstr.c
+**
+** The routine wgetstr().
+**
+*/
+
+#include "curses.priv.h"
+#include "unctrl.h"
+#include <string.h>
+
+int wgetnstr(WINDOW *win, char *str, int maxlen)
+{
+bool oldnl, oldecho, oldraw, oldcbreak, oldkeypad;
+char erasec;
+char killc;
+char *oldstr;
+int ch;
+
+ T(("wgetnstr(%p,%p, %d) called", win, str, maxlen));
+
+ oldnl = SP->_nl;
+ oldecho = SP->_echo;
+ oldraw = SP->_raw;
+ oldcbreak = SP->_cbreak;
+ oldkeypad = win->_use_keypad;
+ nl();
+ noecho();
+ noraw();
+ cbreak();
+ keypad(win, TRUE);
+
+ erasec = erasechar();
+ killc = killchar();
+
+ oldstr = str;
+
+ if (is_wintouched(win) || (win->_flags & _HASMOVED))
+ wrefresh(win);
+
+ while ((ch = wgetch(win)) != ERR) {
+ /*
+ * Some terminals (the Wyse-50 is the most common) generate
+ * a \n from the down-arrow key. With this logic, it's the
+ * user's choice whether to set kcud=\n for wgetch();
+ * terminating *getstr() with \n should work either way.
+ */
+ if (ch == '\n' || ch == '\r' || ch == KEY_DOWN)
+ break;
+ if (ch == erasec || ch == KEY_LEFT || ch == KEY_BACKSPACE) {
+ if (str > oldstr) {
+ str--;
+ if (oldecho == TRUE)
+ _nc_backspace(win);
+ }
+ } else if (ch == killc) {
+ while (str > oldstr) {
+ str--;
+ if (oldecho == TRUE)
+ _nc_backspace(win);
+ }
+ } else if (ch >= KEY_MIN
+ || (maxlen >= 0 && str - oldstr >= maxlen)) {
+ beep();
+ } else {
+ if (oldecho == TRUE) {
+ char *glyph = unctrl(ch);
+
+ mvwaddstr(curscr, win->_begy + win->_cury,
+ win->_begx + win->_curx, glyph);
+ waddstr(win, glyph);
+ _nc_outstr(glyph);
+ SP->_curscol += strlen(glyph);
+ }
+ *str++ = ch;
+ }
+ }
+
+ win->_curx = 0;
+ win->_flags &= ~_NEED_WRAP;
+ if (win->_cury < win->_maxy)
+ win->_cury++;
+ wrefresh(win);
+
+ if (oldnl == FALSE)
+ nonl();
+
+ if (oldecho == TRUE)
+ echo();
+
+ if (oldraw == TRUE)
+ raw();
+
+ if (oldcbreak == FALSE)
+ nocbreak();
+
+ if (oldkeypad == FALSE)
+ keypad(win, FALSE);
+
+ if (ch == ERR) {
+ *str = '\0';
+ return ERR;
+ }
+ *str = '\0';
+
+ T(("wgetnstr returns \"%s\"", _nc_visbuf(oldstr)));
+
+ return(OK);
+}
diff --git a/lib/libcurses/lib_inchstr.c b/lib/libcurses/lib_inchstr.c
new file mode 100644
index 00000000000..2dc64bff0d6
--- /dev/null
+++ b/lib/libcurses/lib_inchstr.c
@@ -0,0 +1,43 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+/*
+** lib_inchstr.c
+**
+** The routine winchnstr().
+**
+*/
+
+#include "curses.priv.h"
+
+int winchnstr(WINDOW *win, chtype *str, int n)
+{
+ int i;
+
+ T(("winchnstr(%p,'%p',%d) called", win, str, n));
+
+ for (i = 0; (n < 0 || (i < n)) && (win->_curx + i <= win->_maxx); i++)
+ str[i] = win->_line[win->_cury].text[win->_curx + i];
+ str[i] = (chtype)0;
+
+ return(i);
+}
diff --git a/lib/libcurses/lib_initscr.c b/lib/libcurses/lib_initscr.c
new file mode 100644
index 00000000000..b9c6fcaaad9
--- /dev/null
+++ b/lib/libcurses/lib_initscr.c
@@ -0,0 +1,75 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/*
+** lib_initscr.c
+**
+** The routines initscr(), and termname().
+**
+*/
+
+#include "curses.priv.h"
+#include <stdlib.h>
+#include <string.h>
+
+WINDOW *initscr(void)
+{
+char *name = getenv("TERM");
+
+ if (name == 0)
+ name = "unknown";
+ if (newterm(name, stdout, stdin) == NULL) {
+ fprintf(stderr, "Error opening terminal: %s.\n", name);
+ exit(1);
+ }
+
+ /* allow user to set maximum escape delay from the environment */
+ if ((name = getenv("ESCDELAY")))
+ ESCDELAY = atoi(getenv("ESCDELAY"));
+
+ def_shell_mode();
+
+ /* follow the XPG4 requirement to turn echo off at this point */
+ noecho();
+
+#ifdef _XOPEN_SOURCE_EXTENDED
+ /* for extended XPG4 conformance requires cbreak() at this point */
+ cbreak();
+#endif /* _XOPEN_SOURCE_EXTENDED */
+
+ def_prog_mode();
+ return(stdscr);
+}
+
+char *termname(void)
+{
+char *term = getenv("TERM");
+static char ret[15];
+
+ T(("termname() called"));
+
+ if (term == (char *)NULL)
+ return(char *)NULL;
+ else {
+ (void) strncpy(ret, term, sizeof(ret) - 1);
+ return(ret);
+ }
+}
diff --git a/lib/libcurses/lib_insch.c b/lib/libcurses/lib_insch.c
new file mode 100644
index 00000000000..b2f13744e5b
--- /dev/null
+++ b/lib/libcurses/lib_insch.c
@@ -0,0 +1,54 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+
+/*
+** lib_insch.c
+**
+** The routine winsch().
+**
+*/
+
+#include "curses.priv.h"
+
+int winsch(WINDOW *win, chtype c)
+{
+chtype *temp1, *temp2;
+chtype *end;
+
+ T(("winsch(%p,'%lx') called", win, c));
+
+ end = &win->_line[win->_cury].text[win->_curx];
+ temp1 = &win->_line[win->_cury].text[win->_maxx];
+ temp2 = temp1 - 1;
+
+ while (temp1 > end)
+ *temp1-- = *temp2--;
+
+ *temp1 = _nc_render(win, c, c | win->_attrs);
+
+ win->_line[win->_cury].lastchar = win->_maxx;
+ if (win->_line[win->_cury].firstchar == _NOCHANGE
+ || win->_line[win->_cury].firstchar > win->_curx)
+ win->_line[win->_cury].firstchar = win->_curx;
+ return OK;
+}
diff --git a/lib/libcurses/lib_insdel.c b/lib/libcurses/lib_insdel.c
new file mode 100644
index 00000000000..a6e6a86c78b
--- /dev/null
+++ b/lib/libcurses/lib_insdel.c
@@ -0,0 +1,51 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+
+/*
+** lib_insdel.c
+**
+** The routine winsdelln(win, n).
+** positive n insert n lines above current line
+** negative n delete n lines starting from current line
+**
+*/
+
+#include "curses.priv.h"
+#include <stdlib.h>
+
+int
+winsdelln(WINDOW *win, int n)
+{
+ T(("winsdel(%p,%d) called", win, n));
+
+ if (n == 0)
+ return OK;
+
+ _nc_scroll_window(win, -n, win->_cury, win->_maxy);
+ touchline(win, win->_cury, win->_maxy - win->_cury + 1);
+
+ _nc_synchook(win);
+ return OK;
+}
+
+
diff --git a/lib/libcurses/lib_insstr.c b/lib/libcurses/lib_insstr.c
new file mode 100644
index 00000000000..1d1d867ecc8
--- /dev/null
+++ b/lib/libcurses/lib_insstr.c
@@ -0,0 +1,61 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+
+/*
+** lib_insstr.c
+**
+** The routine winsnstr().
+**
+*/
+
+#include "curses.priv.h"
+#include <ctype.h>
+
+int winsnstr(WINDOW *win, const char *str, int n)
+{
+short oy = win->_cury;
+short ox = win->_curx;
+char *cp;
+
+ T(("winsstr(%p,'%s',%d) called", win, str, n));
+
+ for (cp = (char *)str; *cp && (n <= 0 || (cp - str) < n); cp++) {
+ if (*cp == '\n' || *cp == '\r' || *cp == '\t' || *cp == '\b')
+ _nc_waddch_nosync(win, (chtype)(*cp));
+ else if (is7bits(*cp) && iscntrl(*cp)) {
+ winsch(win, ' ' + (chtype)(*cp));
+ winsch(win, '^');
+ win->_curx += 2;
+ } else {
+ winsch(win, (chtype)(*cp));
+ win->_curx++;
+ }
+ if (win->_curx > win->_maxx)
+ win->_curx = win->_maxx;
+ }
+
+ win->_curx = ox;
+ win->_cury = oy;
+ _nc_synchook(win);
+ return OK;
+}
diff --git a/lib/libcurses/lib_instr.c b/lib/libcurses/lib_instr.c
new file mode 100644
index 00000000000..e1ef5272fd9
--- /dev/null
+++ b/lib/libcurses/lib_instr.c
@@ -0,0 +1,44 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+/*
+** lib_instr.c
+**
+** The routine winnstr().
+**
+*/
+
+#include "curses.priv.h"
+
+int winnstr(WINDOW *win, char *str, int n)
+{
+ int i;
+
+ T(("winnstr(%p,'%p',%d) called", win, str, n));
+
+ for (i = 0; (n < 0 || (i < n)) && (win->_curx + i <= win->_maxx); i++)
+ str[i] = win->_line[win->_cury].text[win->_curx + i] & A_CHARTEXT;
+ str[i] = '\0';
+
+ return(i);
+}
+
diff --git a/lib/libcurses/lib_isendwin.c b/lib/libcurses/lib_isendwin.c
new file mode 100644
index 00000000000..bfd991e3cfb
--- /dev/null
+++ b/lib/libcurses/lib_isendwin.c
@@ -0,0 +1,37 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+/*
+** lib_endwin.c
+**
+** The routine endwin().
+**
+*/
+
+#include "curses.priv.h"
+
+int isendwin(void)
+{
+ if (SP == NULL)
+ return FALSE;
+ return SP->_endwin;
+}
diff --git a/lib/libcurses/lib_kernel.c b/lib/libcurses/lib_kernel.c
new file mode 100644
index 00000000000..622c549acea
--- /dev/null
+++ b/lib/libcurses/lib_kernel.c
@@ -0,0 +1,309 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+/*
+ * lib_kernel.c
+ *
+ * Misc. low-level routines:
+ * napms()
+ * reset_prog_mode()
+ * reset_shell_mode()
+ * baudrate()
+ * delay_output()
+ * erasechar()
+ * killchar()
+ * flushinp()
+ * savetty()
+ * resetty()
+ *
+ *
+ */
+
+#include "curses.priv.h"
+#include "term.h" /* cur_term, pad_char */
+#include <errno.h>
+#if !HAVE_EXTERN_ERRNO
+extern int errno;
+#endif
+
+int napms(int ms)
+{
+ T(("napms(%d) called", ms));
+
+ usleep(1000*(unsigned)ms);
+ return OK;
+}
+
+#ifndef EXTERN_TERMINFO
+int reset_prog_mode(void)
+{
+ T(("reset_prog_mode() called"));
+
+#ifdef TERMIOS
+ tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Nttyb);
+#else
+ stty(cur_term->Filedes, &cur_term->Nttyb);
+#endif
+ if (SP && stdscr && stdscr->_use_keypad)
+ _nc_keypad(TRUE);
+
+ return OK;
+}
+
+
+int reset_shell_mode(void)
+{
+ T(("reset_shell_mode() called"));
+
+ if (SP)
+ {
+ fflush(SP->_ofp);
+ _nc_keypad(FALSE);
+ }
+
+#ifdef TERMIOS
+ tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Ottyb);
+#else
+ stty(cur_term->Filedes, &cur_term->Ottyb);
+#endif
+ return OK;
+}
+#endif /* EXTERN_TERMINFO */
+
+int delay_output(float ms)
+{
+ T(("delay_output(%f) called", ms));
+
+ if (SP == 0 || SP->_baudrate == ERR)
+ return(ERR);
+#ifdef no_pad_char
+ else if (no_pad_char)
+ _nc_timed_wait(0, (int)ms, (int *)NULL);
+#endif /* no_pad_char */
+ else {
+ register int nullcount;
+ char null = '\0';
+
+#ifdef pad_char
+ if (pad_char)
+ null = pad_char[0];
+#endif /* pad_char */
+
+ for (nullcount = ms * 1000 / SP->_baudrate; nullcount > 0; nullcount--)
+ putc(null, SP->_ofp);
+ (void) fflush(SP->_ofp);
+ }
+
+ return OK;
+}
+
+/*
+ * erasechar()
+ *
+ * Return erase character as given in cur_term->Ottyb.
+ *
+ */
+
+char
+erasechar(void)
+{
+ T(("erasechar() called"));
+
+#ifdef TERMIOS
+ return(cur_term->Ottyb.c_cc[VERASE]);
+#else
+ return(cur_term->Ottyb.sg_erase);
+#endif
+
+}
+
+
+
+/*
+ * killchar()
+ *
+ * Return kill character as given in cur_term->Ottyb.
+ *
+ */
+
+char
+killchar(void)
+{
+ T(("killchar() called"));
+
+#ifdef TERMIOS
+ return(cur_term->Ottyb.c_cc[VKILL]);
+#else
+ return(cur_term->Ottyb.sg_kill);
+#endif
+}
+
+
+
+/*
+ * flushinp()
+ *
+ * Flush any input on cur_term->Filedes
+ *
+ */
+
+int flushinp(void)
+{
+ T(("flushinp() called"));
+
+#ifdef TERMIOS
+ tcflush(cur_term->Filedes, TCIFLUSH);
+#else
+ errno = 0;
+ do {
+ ioctl(cur_term->Filedes, TIOCFLUSH, 0);
+ } while
+ (errno == EINTR);
+#endif
+ if (SP) {
+ SP->_fifohead = -1;
+ SP->_fifotail = 0;
+ SP->_fifopeek = 0;
+ }
+ return OK;
+
+}
+
+
+
+/*
+ * int
+ * baudrate()
+ *
+ * Returns the current terminal's baud rate.
+ *
+ */
+
+struct speed {
+ speed_t s;
+ int sp;
+};
+
+static struct speed const speeds[] = {
+ {B0, 0},
+ {B50, 50},
+ {B75, 75},
+ {B110, 110},
+ {B134, 134},
+ {B150, 150},
+ {B200, 200},
+ {B300, 300},
+ {B600, 600},
+ {B1200, 1200},
+ {B1800, 1800},
+ {B2400, 2400},
+ {B4800, 4800},
+ {B9600, 9600},
+#define MAX_BAUD B9600
+#ifdef B19200
+#undef MAX_BAUD
+#define MAX_BAUD B19200
+ {B19200, 19200},
+#else
+#ifdef EXTA
+#define MAX_BAUD EXTA
+ {EXTA, 19200},
+#endif
+#endif
+#ifdef B38400
+#undef MAX_BAUD
+#define MAX_BAUD B38400
+ {B38400, 38400},
+#else
+#ifdef EXTB
+#define MAX_BAUD EXTB
+ {EXTB, 38400},
+#endif
+#endif
+#ifdef B57600
+#undef MAX_BAUD
+#define MAX_BAUD B57600
+ {B57600, 57600},
+#endif
+#ifdef B115200
+#undef MAX_BAUD
+#define MAX_BAUD B115200
+ {B115200, 115200},
+#endif
+};
+
+int
+baudrate(void)
+{
+int i, ret;
+
+ T(("baudrate() called"));
+
+#ifdef TERMIOS
+ ret = cfgetospeed(&cur_term->Nttyb);
+#else
+ ret = cur_term->Nttyb.sg_ospeed;
+#endif
+ if(ret < 0 || ret > MAX_BAUD)
+ return ERR;
+ SP->_baudrate = ERR;
+ for (i = 0; i < (sizeof(speeds) / sizeof(struct speed)); i++)
+ if (speeds[i].s == ret)
+ {
+ SP->_baudrate = speeds[i].sp;
+ break;
+ }
+ return(SP->_baudrate);
+}
+
+
+/*
+** savetty() and resetty()
+**
+*/
+
+static TTY buf;
+
+int savetty(void)
+{
+ T(("savetty() called"));
+
+#ifdef TERMIOS
+ tcgetattr(cur_term->Filedes, &buf);
+#else
+ gtty(cur_term->Filedes, &buf);
+#endif
+ return OK;
+}
+
+int resetty(void)
+{
+ T(("resetty() called"));
+
+#ifdef TERMIOS
+ tcsetattr(cur_term->Filedes, TCSANOW, &buf);
+#else
+ stty(cur_term->Filedes, &buf);
+#endif
+ return OK;
+}
+
diff --git a/lib/libcurses/lib_longname.c b/lib/libcurses/lib_longname.c
new file mode 100644
index 00000000000..d9883ae3d50
--- /dev/null
+++ b/lib/libcurses/lib_longname.c
@@ -0,0 +1,53 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+/*
+** lib_longname.c
+**
+** The routine longname().
+**
+*/
+
+#ifdef EXTERN_TERMINFO
+#include <term.h>
+#else
+#include "curses.priv.h"
+#endif
+#include <string.h>
+
+char *
+longname(void)
+{
+#ifdef EXTERN_TERMINFO
+ return cur_term->name;
+#else
+char *ptr;
+
+ T(("longname() called"));
+
+ for (ptr = ttytype + strlen(ttytype); ptr > ttytype; ptr--)
+ if (*ptr == '|')
+ return(ptr + 1);
+
+ return(ttytype);
+#endif
+}
diff --git a/lib/libcurses/lib_mouse.c b/lib/libcurses/lib_mouse.c
new file mode 100644
index 00000000000..e8f73f65f36
--- /dev/null
+++ b/lib/libcurses/lib_mouse.c
@@ -0,0 +1,580 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/*
+ * This module is intended to encapsulate ncurses's interface to pointing
+ * devices.
+ *
+ * The first method used is xterm's internal mouse-tracking facility.
+ * The second (not yet implemented) will be Alessandro Rubini's GPM server.
+ *
+ * Notes for implementors of new mouse-interface methods:
+ *
+ * The code is logically split into a lower level that accepts event reports
+ * in a device-dependent format and an upper level that parses mouse gestures
+ * and filters events. The mediating data structure is a circular queue of
+ * MEVENT structures.
+ *
+ * Functionally, the lower level's job is to pick up primitive events and
+ * put them on the circular queue. This can happen in one of two ways:
+ * either (a) _nc_mouse_event() detects a series of incoming mouse reports
+ * and queues them, or (b) code in lib_getch.c detects the kmous prefix in
+ * the keyboard input stream and calls _nc_mouse_inline to queue up a series
+ * of adjacent mouse reports.
+ *
+ * In either case, _nc_mouse_parse() should be called after the series is
+ * accepted to parse the digested mouse reports (low-level MEVENTs) into
+ * a gesture (a high-level or composite MEVENT).
+ *
+ * Don't be too shy about adding new event types or modifiers, if you can find
+ * room for them in the 32-bit mask. The API is written so that users get
+ * feedback on which theoretical event types they won't see when they call
+ * mousemask. There's one bit per button (the RESERVED_EVENT bit) not being
+ * used yet, and a couple of bits open at the high end.
+ */
+
+#include <curses.h>
+#include <string.h>
+#include "term.h"
+#include "curses.priv.h"
+
+#define INVALID_EVENT -1
+
+int _nc_max_click_interval = 166; /* max press/release separation */
+
+static int mousetype;
+#define M_XTERM -1 /* use xterm's mouse tracking? */
+#define M_NONE 0 /* no mouse device */
+#define M_GPM 1 /* use GPM (not yet implemented) */
+
+static mmask_t eventmask; /* current event mask */
+
+/* maintain a circular list of mouse events */
+#define EV_MAX 8 /* size of circular event queue */
+static MEVENT events[EV_MAX]; /* hold the last mouse event seen */
+static MEVENT *eventp = events; /* next free slot in event queue */
+#define NEXT(ep) ((ep == events + EV_MAX - 1) ? events : ep + 1)
+#define PREV(ep) ((ep == events) ? events + EV_MAX - 1 : ep - 1)
+
+void _nc_mouse_init(SCREEN *sp)
+/* initialize the mouse -- called at screen-setup time */
+{
+ int i;
+
+ T(("_nc_mouse_init() called"));
+
+ for (i = 0; i < EV_MAX; i++)
+ events[i].id = INVALID_EVENT;
+
+#ifdef EXTERN_TERMINFO
+ /* we know how to recognize mouse events under xterm */
+ if (!strncmp(cur_term->name, "xterm", 5) && key_mouse)
+ mousetype = M_XTERM;
+#else
+ /* we know how to recognize mouse events under xterm */
+ if (!strncmp(cur_term->type.term_names, "xterm", 5) && key_mouse)
+ mousetype = M_XTERM;
+#endif
+
+ /* GPM: initialize connection to gpm server */
+}
+
+bool _nc_mouse_event(SCREEN *sp)
+/* query to see if there is a pending mouse event */
+{
+ /* xterm: never have to query, mouse events are in the keyboard stream */
+ /* GPM: query server for event, return TRUE if we find one */
+ return(FALSE); /* no event waiting */
+}
+
+bool _nc_mouse_inline(SCREEN *sp)
+/* mouse report received in the keyboard stream -- parse its info */
+{
+ T(("_nc_mouse_inline() called"));
+
+ if (mousetype == M_XTERM)
+ {
+ char kbuf[4];
+ MEVENT *prev;
+
+ /* This code requires that your xterm entry contain the kmous
+ * capability and that it be set to the \E[M documented in the
+ * Xterm Control Sequences reference. This is how we
+ * arrange for mouse events to be reported via a KEY_MOUSE
+ * return value from wgetch(). After this value is received,
+ * _nc_mouse_inline() gets called and is immediately
+ * responsible for parsing the mouse status information
+ * following the prefix.
+ *
+ * The following quotes from the ctrlseqs.ms document in the
+ * X distribution, describing the X mouse tracking feature:
+ *
+ * Parameters for all mouse tracking escape sequences
+ * generated by xterm encode numeric parameters in a single
+ * character as value+040. For example, ! is 1.
+ *
+ * On button press or release, xterm sends ESC [ M CbCxCy.
+ * The low two bits of Cb encode button information: 0=MB1
+ * pressed, 1=MB2 pressed, 2=MB3 pressed, 3=release. The
+ * upper bits encode what modifiers were down when the
+ * button was pressed and are added together. 4=Shift,
+ * 8=Meta, 16=Control. Cx and Cy are the x and y coordinates
+ * of the mouse event. The upper left corner is (1,1).
+ *
+ * (End quote) By the time we get here, we've eaten the
+ * key prefix.
+ */
+ (void) read(sp->_ifd, &kbuf, 3);
+ kbuf[3] = '\0';
+
+#ifdef MOUSEDEBUG
+ T(("_nc_mouse_inline sees the following xterm data: '%s'", kbuf));
+#endif /* MOUSEDEBUG */
+
+ eventp->id = 0; /* there's only one mouse... */
+
+ /* processing code goes here */
+ eventp->bstate = 0;
+ switch (kbuf[0] & 0x3)
+ {
+ case 0x0:
+ eventp->bstate = BUTTON1_PRESSED;
+ break;
+
+ case 0x1:
+ eventp->bstate = BUTTON2_PRESSED;
+ break;
+
+ case 0x2:
+ eventp->bstate = BUTTON3_PRESSED;
+ break;
+
+ case 0x3:
+ /*
+ * Release events aren't reported for individual buttons,
+ * just for the button set as a whole...
+ */
+ eventp->bstate =
+ (BUTTON1_RELEASED |
+ BUTTON2_RELEASED |
+ BUTTON3_RELEASED);
+ /*
+ * ...however, because there are no kinds of mouse events under
+ * xterm that can intervene between press and release, we can
+ * deduce which buttons were actually released by looking at the
+ * previous event.
+ */
+ prev = PREV(eventp);
+ if (!(prev->bstate & BUTTON1_PRESSED))
+ eventp->bstate &=~ BUTTON1_RELEASED;
+ if (!(prev->bstate & BUTTON2_PRESSED))
+ eventp->bstate &=~ BUTTON2_RELEASED;
+ if (!(prev->bstate & BUTTON3_PRESSED))
+ eventp->bstate &=~ BUTTON3_RELEASED;
+ break;
+ }
+
+ if (kbuf[0] & 4) {
+ eventp->bstate |= BUTTON_SHIFT;
+ }
+ if (kbuf[0] & 8) {
+ eventp->bstate |= BUTTON_ALT;
+ }
+ if (kbuf[0] & 16) {
+ eventp->bstate |= BUTTON_CTRL;
+ }
+
+ eventp->x = (kbuf[1] - ' ') - 1;
+ eventp->y = (kbuf[2] - ' ') - 1;
+ T(("_nc_mouse_inline: primitive mouse-event %s has slot %d", _tracemouse(eventp), eventp - events));
+
+ /* bump the next-free pointer into the circular list */
+ eventp = NEXT(eventp);
+ }
+
+ return(FALSE);
+}
+
+static void mouse_activate(bool on)
+{
+ if (mousetype == M_XTERM)
+ {
+ if (on)
+ {
+ TPUTS_TRACE("xterm mouse initialization");
+ putp("\033[?1000h");
+ }
+ else
+ {
+ TPUTS_TRACE("xterm mouse deinitialization");
+ putp("\033[?1000l");
+ }
+ (void) fflush(SP->_ofp);
+ }
+}
+
+/**************************************************************************
+ *
+ * Device-independent code
+ *
+ **************************************************************************/
+
+bool _nc_mouse_parse(int runcount)
+/* parse a run of atomic mouse events into a gesture */
+{
+ MEVENT *ep, *runp, *next, *prev = PREV(eventp);
+ int n;
+ bool merge;
+
+ T(("_nc_mouse_parse() called"));
+ /*
+ * When we enter this routine, the event list next-free pointer
+ * points just past a run of mouse events that we know were separated
+ * in time by less than the critical click interval. The job of this
+ * routine is to collaps this run into a single higher-level event
+ * or gesture.
+ *
+ * We accomplish this in two passes. The first pass merges press/release
+ * pairs into click events. The second merges runs of click events into
+ * double or triple-click events.
+ *
+ * It's possible that the run may not resolve to a single event (for
+ * example, if the user quadruple-clicks). If so, leading events
+ * in the run are ignored.
+ *
+ * Note that this routine is independent of the format of the specific
+ * format of the pointing-device's reports. We can use it to parse
+ * gestures on anything that reports press/release events on a per-
+ * button basis, as long as the device-dependent mouse code puts stuff
+ * on the queue in MEVENT format.
+ */
+ if (runcount == 1)
+ {
+ T(("_nc_mouse_parse: returning simple mouse event %s at slot %d",
+ _tracemouse(prev), prev-events));
+ return(PREV(prev)->bstate & eventmask);
+ }
+
+ /* find the start of the run */
+ runp = eventp;
+ for (n = runcount; n > 0; n--)
+ runp = PREV(runp);
+
+#ifdef MOUSEDEBUG
+ T(("before mouse press/release merge:"));
+ for (ep = events; ep < events + EV_MAX; ep++)
+ T(("mouse event queue slot %d = %s", ep-events, _tracemouse(ep)));
+ T(("_nc_mouse_parse: run starts at %d, ends at %d, count %d",
+ runp-events, ((eventp - events) + (EV_MAX - 1)) % EV_MAX, runcount));
+#endif /* MOUSEDEBUG */
+
+ /* first pass; merge press/release pairs */
+ do {
+ merge = FALSE;
+ for (ep = runp; next = NEXT(ep), next != eventp; ep = next)
+ {
+ if (ep->x == next->x && ep->y == next->y
+ && (ep->bstate & (BUTTON1_PRESSED|BUTTON2_PRESSED|BUTTON3_PRESSED))
+ && (!(ep->bstate & BUTTON1_PRESSED)
+ == !(next->bstate & BUTTON1_RELEASED))
+ && (!(ep->bstate & BUTTON2_PRESSED)
+ == !(next->bstate & BUTTON2_RELEASED))
+ && (!(ep->bstate & BUTTON3_PRESSED)
+ == !(next->bstate & BUTTON3_RELEASED))
+ )
+ {
+ if ((eventmask & BUTTON1_CLICKED)
+ && (ep->bstate & BUTTON1_PRESSED))
+ {
+ ep->bstate &=~ BUTTON1_PRESSED;
+ ep->bstate |= BUTTON1_CLICKED;
+ merge = TRUE;
+ }
+ if ((eventmask & BUTTON2_CLICKED)
+ && (ep->bstate & BUTTON2_PRESSED))
+ {
+ ep->bstate &=~ BUTTON2_PRESSED;
+ ep->bstate |= BUTTON2_CLICKED;
+ merge = TRUE;
+ }
+ if ((eventmask & BUTTON3_CLICKED)
+ && (ep->bstate & BUTTON3_PRESSED))
+ {
+ ep->bstate &=~ BUTTON3_PRESSED;
+ ep->bstate |= BUTTON3_CLICKED;
+ merge = TRUE;
+ }
+ if (merge)
+ next->id = INVALID_EVENT;
+ }
+ }
+ } while
+ (merge);
+
+#ifdef MOUSEDEBUG
+ T(("before mouse click merges:"));
+ for (ep = events; ep < events + EV_MAX; ep++)
+ T(("mouse event queue slot %d = %s", ep-events, _tracemouse(ep)));
+ T(("_nc_mouse_parse: run starts at %d, ends at %d, count %d",
+ runp-events, ((eventp - events) + (EV_MAX - 1)) % EV_MAX, runcount));
+#endif /* MOUSEDEBUG */
+
+ /*
+ * Second pass; merge click runs. At this point, click events are
+ * each followed by one invalid event. We merge click events
+ * forward in the queue.
+ *
+ * NOTE: There is a problem with this design! If the application
+ * allows enough click events to pile up in the circular queue so
+ * they wrap around, it will cheerfully merge the newest forward
+ * into the oldest, creating a bogus doubleclick and confusing
+ * the queue-traversal logic rather badly. Generally this won't
+ * happen, because calling getmouse() marks old events invalid and
+ * ineligible for merges. The true solution to this problem would
+ * be to timestamp each MEVENT and perform the obvious sanity check,
+ * but the timer element would have to have sub-second resolution,
+ * which would get us into portability trouble.
+ */
+ do {
+ MEVENT *follower;
+
+ merge = FALSE;
+ for (ep = runp; next = NEXT(ep), next != eventp; ep = next)
+ if (ep->id != INVALID_EVENT)
+ {
+ if (next->id != INVALID_EVENT)
+ continue;
+ follower = NEXT(next);
+ if (follower->id == INVALID_EVENT)
+ continue;
+
+ /* merge click events forward */
+ if ((ep->bstate &
+ (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED))
+ && (follower->bstate &
+ (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED)))
+ {
+ if ((eventmask & BUTTON1_DOUBLE_CLICKED)
+ && (follower->bstate & BUTTON1_CLICKED))
+ {
+ follower->bstate &=~ BUTTON1_CLICKED;
+ follower->bstate |= BUTTON1_DOUBLE_CLICKED;
+ merge = TRUE;
+ }
+ if ((eventmask & BUTTON2_DOUBLE_CLICKED)
+ && (follower->bstate & BUTTON2_CLICKED))
+ {
+ follower->bstate &=~ BUTTON2_CLICKED;
+ follower->bstate |= BUTTON2_DOUBLE_CLICKED;
+ merge = TRUE;
+ }
+ if ((eventmask & BUTTON3_DOUBLE_CLICKED)
+ && (follower->bstate & BUTTON3_CLICKED))
+ {
+ follower->bstate &=~ BUTTON3_CLICKED;
+ follower->bstate |= BUTTON3_DOUBLE_CLICKED;
+ merge = TRUE;
+ }
+ if (merge)
+ ep->id = INVALID_EVENT;
+ }
+
+ /* merge double-click events forward */
+ if ((ep->bstate &
+ (BUTTON1_DOUBLE_CLICKED
+ | BUTTON2_DOUBLE_CLICKED
+ | BUTTON3_DOUBLE_CLICKED))
+ && (follower->bstate &
+ (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED)))
+ {
+ if ((eventmask & BUTTON1_TRIPLE_CLICKED)
+ && (follower->bstate & BUTTON1_CLICKED))
+ {
+ follower->bstate &=~ BUTTON1_CLICKED;
+ follower->bstate |= BUTTON1_TRIPLE_CLICKED;
+ merge = TRUE;
+ }
+ if ((eventmask & BUTTON2_TRIPLE_CLICKED)
+ && (follower->bstate & BUTTON2_CLICKED))
+ {
+ follower->bstate &=~ BUTTON2_CLICKED;
+ follower->bstate |= BUTTON2_TRIPLE_CLICKED;
+ merge = TRUE;
+ }
+ if ((eventmask & BUTTON3_TRIPLE_CLICKED)
+ && (follower->bstate & BUTTON3_CLICKED))
+ {
+ follower->bstate &=~ BUTTON3_CLICKED;
+ follower->bstate |= BUTTON3_TRIPLE_CLICKED;
+ merge = TRUE;
+ }
+ if (merge)
+ ep->id = INVALID_EVENT;
+ }
+ }
+ } while
+ (merge);
+
+#ifdef MOUSEDEBUG
+ T(("before mouse event queue compaction:"));
+ for (ep = events; ep < events + EV_MAX; ep++)
+ T(("mouse event queue slot %d = %s", ep-events, _tracemouse(ep)));
+ T(("_nc_mouse_parse: uncompacted run starts at %d, ends at %d, count %d",
+ runp-events, ((eventp - events) + (EV_MAX - 1)) % EV_MAX, runcount));
+#endif /* MOUSEDEBUG */
+
+ /*
+ * Now try to throw away trailing events flagged invalid, or that
+ * don't match the current event mask.
+ */
+ for (; runcount; prev = PREV(eventp), runcount--)
+ if (prev->id == INVALID_EVENT || !(prev->bstate & eventmask))
+ eventp = prev;
+
+#ifdef TRACE
+#ifdef MOUSEDEBUG
+ T(("after mouse event queue compaction:"));
+ for (ep = events; ep < events + EV_MAX; ep++)
+ T(("mouse event queue slot %d = %s", ep-events, _tracemouse(ep)));
+ T(("_nc_mouse_parse: compacted run starts at %d, ends at %d, count %d",
+ runp-events, ((eventp - events) + (EV_MAX - 1)) % EV_MAX, runcount));
+#endif /* MOUSEDEBUG */
+ for (ep = runp; ep != eventp; ep = NEXT(ep))
+ if (ep->id != INVALID_EVENT)
+ T(("_nc_mouse_parse: returning composite mouse event %s at slot %d",
+ _tracemouse(ep), ep-events));
+#endif /* TRACE */
+
+ /* after all this, do we have a valid event? */
+ return(PREV(eventp)->id != INVALID_EVENT);
+}
+
+void _nc_mouse_wrap(SCREEN *sp)
+/* release mouse -- called by endwin() before shellout/exit */
+{
+ T(("_nc_mouse_wrap() called"));
+
+ /* xterm: turn off reporting */
+ if (mousetype == M_XTERM && eventmask)
+ {
+ mouse_activate(FALSE);
+ eventmask = 0;
+ }
+
+ /* GPM: pass all mouse events to next client */
+}
+
+void _nc_mouse_resume(SCREEN *sp)
+/* re-connect to mouse -- called by doupdate() after shellout */
+{
+ T(("_nc_mouse_resume() called"));
+
+ /* xterm: re-enable reporting */
+ if (mousetype == M_XTERM && eventmask)
+ mouse_activate(TRUE);
+
+ /* GPM: reclaim our event set */
+}
+
+/**************************************************************************
+ *
+ * Mouse interface entry points for the API
+ *
+ **************************************************************************/
+
+int getmouse(MEVENT *aevent)
+/* grab a copy of the current mouse event */
+{
+ if (mousetype == M_XTERM)
+ {
+ /* compute the current-event pointer */
+ MEVENT *prev = PREV(eventp);
+
+ /* copy the event we find there */
+ *aevent = *prev;
+
+#ifdef MOUSEDEBUG
+ T(("getmouse: returning event %s from slot %d",
+ _tracemouse(prev), prev-events));
+#endif /* MOUSEDEBUG */
+
+ prev->id = INVALID_EVENT; /* so the queue slot becomes free */
+ return(OK);
+ }
+ return(ERR);
+}
+
+int ungetmouse(MEVENT *aevent)
+/* enqueue a synthesized mouse event to be seen by the next wgetch() */
+{
+ /* stick the given event in the next-free slot */
+ *eventp = *aevent;
+
+ /* bump the next-free pointer into the circular list */
+ eventp = NEXT(eventp);
+
+ /* push back the notification event on the keyboard queue */
+ return ungetch(KEY_MOUSE);
+}
+
+mmask_t mousemask(mmask_t newmask, mmask_t *oldmask)
+/* set the mouse event mask */
+{
+ if (oldmask)
+ *oldmask = eventmask;
+
+ if (mousetype == M_XTERM)
+ {
+ eventmask = newmask &
+ (BUTTON_ALT | BUTTON_CTRL | BUTTON_SHIFT
+ | BUTTON1_PRESSED | BUTTON1_RELEASED | BUTTON1_CLICKED
+ | BUTTON1_DOUBLE_CLICKED | BUTTON1_TRIPLE_CLICKED
+ | BUTTON2_PRESSED | BUTTON2_RELEASED | BUTTON2_CLICKED
+ | BUTTON2_DOUBLE_CLICKED | BUTTON2_TRIPLE_CLICKED
+ | BUTTON3_PRESSED | BUTTON3_RELEASED | BUTTON3_CLICKED
+ | BUTTON3_DOUBLE_CLICKED | BUTTON3_TRIPLE_CLICKED);
+
+ mouse_activate(eventmask != 0);
+
+ return(eventmask);
+ }
+
+ return(0);
+}
+
+bool wenclose(WINDOW *win, int y, int x)
+/* check to see if given window encloses given screen location */
+{
+ return
+ (win->_begy <= y && win->_begx <= x
+ && win->_maxx >= x && win->_maxy >= y);
+}
+
+int mouseinterval(int maxclick)
+/* set the maximum mouse interval within which to recognize a click */
+{
+ int oldval = _nc_max_click_interval;
+
+ _nc_max_click_interval = maxclick;
+ return(oldval);
+}
+
+/* lib_mouse.c ends here */
diff --git a/lib/libcurses/lib_move.c b/lib/libcurses/lib_move.c
new file mode 100644
index 00000000000..547aa1762e3
--- /dev/null
+++ b/lib/libcurses/lib_move.c
@@ -0,0 +1,48 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+/*
+** lib_move.c
+**
+** The routine wmove().
+**
+*/
+
+#include "curses.priv.h"
+
+int
+wmove(WINDOW *win, int y, int x)
+{
+ T(("wmove(%p,%d,%d) called", win, y, x));
+
+ if (x >= 0 && x <= win->_maxx &&
+ y >= 0 && y <= win->_maxy)
+ {
+ win->_curx = (short)x;
+ win->_cury = (short)y;
+
+ win->_flags &= ~_NEED_WRAP;
+ win->_flags |= _HASMOVED;
+ return(OK);
+ } else
+ return(ERR);
+}
diff --git a/lib/libcurses/lib_mvcur.c b/lib/libcurses/lib_mvcur.c
new file mode 100644
index 00000000000..b8483e95480
--- /dev/null
+++ b/lib/libcurses/lib_mvcur.c
@@ -0,0 +1,1389 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+/*
+** lib_mvcur.c
+**
+** The routines for moving the physical cursor and scrolling:
+**
+** void _nc_mvcur_init(void), mvcur_wrap(void)
+**
+** int mvcur(int old_y, int old_x, int new_y, int new_x)
+**
+** void _nc_mvcur_wrap(void)
+**
+** int _nc_mvcur_scrolln(int n, int top, int bot, int maxy)
+**
+** 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_lines - 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)
+ *#ifdef TABS_OK
+ * int _ht_cost; // cost of (tab)
+ * int _cbt_cost; // cost of (backtab)
+ *#endif TABS_OK
+ * 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)
+ *
+ * The TABS_OK 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"
+
+#define NLMAPPING SP->_nl /* nl() on? */
+#define RAWFLAG SP->_raw /* raw() on? */
+#define CURRENT_ATTR SP->_current_attr /* current phys attribute */
+#define CURRENT_ROW SP->_cursrow /* phys cursor row */
+#define CURRENT_COLUMN SP->_curscol /* phys cursor column */
+#define REAL_ATTR SP->_current_attr /* phys current attribute */
+#define WANT_CHAR(y, x) SP->_newscr->_line[y].text[x] /* desired state */
+#define BAUDRATE SP->_baudrate /* bits per second */
+
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+#ifdef TRACE
+bool no_optimize; /* suppress optimization */
+#endif /* TRACE */
+
+#ifdef MAIN
+#include <sys/time.h>
+
+static bool profiling = FALSE;
+static float diff;
+#endif /* MAIN */
+
+#define OPT_SIZE 512
+
+static char *address_cursor;
+static int carriage_return_length;
+static int cursor_home_length;
+static int cursor_to_ll_length;
+
+static void save_curs(void);
+static void restore_curs(void);
+
+/****************************************************************************
+ *
+ * Initialization/wrapup (including cost pre-computation)
+ *
+ ****************************************************************************/
+
+#define INFINITY 1000000 /* too high to use */
+
+static int cost(char *cap, int affcnt)
+/* compute the cost of a given operation */
+{
+ if (cap == (char *)NULL)
+ return(INFINITY);
+ else
+ {
+ char *cp;
+ float cum_cost = 0;
+
+ for (cp = cap; *cp; cp++)
+ {
+ /* extract padding, either mandatory or required */
+ if (cp[0] == '$' && cp[1] == '<' && strchr(cp, '>'))
+ {
+ float number = 0;
+
+ for (cp += 2; *cp != '>'; cp++)
+ {
+ if (isdigit(*cp))
+ number = number * 10 + (*cp - '0');
+ else if (*cp == '.')
+ number += (*++cp - 10) / 10.0;
+ else if (*cp == '*')
+ number *= affcnt;
+ }
+
+ cum_cost += number * 10;
+ }
+ else
+ cum_cost += SP->_char_padding;
+ }
+
+ return((int)cum_cost);
+ }
+}
+
+void _nc_mvcur_init(SCREEN *sp)
+/* initialize the cost structure */
+{
+ /*
+ * 9 = 7 bits + 1 parity + 1 stop.
+ */
+ if (BAUDRATE != 0)
+ SP->_char_padding = (9 * 1000 * 10) / BAUDRATE;
+ else
+ SP->_char_padding = 9 * 1000 * 10 / 9600; /* use some default if baudrate == 0 */
+
+ /* non-parameterized local-motion strings */
+ SP->_cr_cost = cost(carriage_return, 0);
+ SP->_home_cost = cost(cursor_home, 0);
+ SP->_ll_cost = cost(cursor_to_ll, 0);
+#ifdef TABS_OK
+ SP->_ht_cost = cost(tab, 0);
+ SP->_cbt_cost = cost(back_tab, 0);
+#endif /* TABS_OK */
+ SP->_cub1_cost = cost(cursor_left, 0);
+ SP->_cuf1_cost = cost(cursor_right, 0);
+ SP->_cud1_cost = cost(cursor_down, 0);
+ SP->_cuu1_cost = cost(cursor_up, 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.
+ */
+ 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 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 = cost(tparm(address_cursor, 23, 23), 1);
+ SP->_cub_cost = cost(tparm(parm_left_cursor, 23), 1);
+ SP->_cuf_cost = cost(tparm(parm_right_cursor, 23), 1);
+ SP->_cud_cost = cost(tparm(parm_down_cursor, 23), 1);
+ SP->_cuu_cost = cost(tparm(parm_up_cursor, 23), 1);
+ SP->_hpa_cost = cost(tparm(column_address, 23), 1);
+ SP->_vpa_cost = cost(tparm(row_address, 23), 1);
+
+ /* initialize screen for cursor access */
+ if (enter_ca_mode)
+ {
+ TPUTS_TRACE("enter_ca_mode");
+ putp(enter_ca_mode);
+ }
+
+ /* pre-compute some capability lengths */
+ carriage_return_length = carriage_return ? strlen(carriage_return) : 0;
+ cursor_home_length = cursor_home ? strlen(cursor_home) : 0;
+ cursor_to_ll_length = cursor_to_ll ? strlen(cursor_to_ll) : 0;
+}
+
+void _nc_mvcur_wrap(void)
+/* wrap up cursor-addressing mode */
+{
+ /* change_scroll_region may trash the cursor location */
+ save_curs();
+ if (change_scroll_region)
+ {
+ TPUTS_TRACE("change_scroll_region");
+ putp(tparm(change_scroll_region, 0, screen_lines - 1));
+ }
+ restore_curs();
+
+ if (exit_ca_mode)
+ {
+ TPUTS_TRACE("exit_ca_mode");
+ putp(exit_ca_mode);
+ }
+}
+
+/****************************************************************************
+ *
+ * Optimized cursor movement
+ *
+ ****************************************************************************/
+
+/*
+ * Perform repeated-append, returning cost
+ */
+static __inline int
+repeated_append (int total, int num, int repeat, char *dst, char *src)
+{
+ register size_t src_len = strlen(src);
+ register size_t dst_len = 0;
+
+ if (dst)
+ dst_len = strlen(dst);
+ if ((dst_len + repeat * src_len) < OPT_SIZE-1) {
+ total += (num * repeat);
+ if (dst) {
+ dst += dst_len;
+ while (repeat-- > 0) {
+ (void) strcpy(dst, src);
+ dst += src_len;
+ }
+ }
+ } else {
+ total = INFINITY;
+ }
+ return total;
+}
+
+#ifndef NO_OPTIMIZE
+#define NEXTTAB(fr) (fr + init_tabs - (fr % init_tabs))
+#define LASTTAB(fr) (fr - init_tabs + (fr % init_tabs))
+
+/* Note: we'd like to inline this for speed, but GNU C barfs on the attempt. */
+
+static int
+relative_move(char *result, 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) */
+{
+ int n, vcost = 0, hcost = 0;
+ bool used_lf = FALSE;
+
+ if (result)
+ result[0] = '\0';
+
+ if (to_y != from_y)
+ {
+ vcost = INFINITY;
+
+ if (row_address)
+ {
+ if (result)
+ (void) strcpy(result, tparm(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)
+ {
+ if (result)
+ (void) strcpy(result, tparm(parm_down_cursor, n));
+ vcost = SP->_cud_cost;
+ }
+
+ if (cursor_down && (n * SP->_cud1_cost < vcost))
+ {
+ if (result)
+ result[0] = '\0';
+ if (cursor_down[0] == '\n')
+ used_lf = TRUE;
+ vcost = repeated_append(vcost, SP->_cud1_cost, n, result, cursor_down);
+ }
+ }
+ else /* (to_y < from_y) */
+ {
+ n = (from_y - to_y);
+
+ if (parm_up_cursor && SP->_cup_cost < vcost)
+ {
+ if (result)
+ (void) strcpy(result, tparm(parm_up_cursor, n));
+ vcost = SP->_cup_cost;
+ }
+
+ if (cursor_up && (n * SP->_cuu1_cost < vcost))
+ {
+ if (result)
+ result[0] = '\0';
+ vcost = repeated_append(vcost, SP->_cuu1_cost, n, result, cursor_up);
+ }
+ }
+
+ if (vcost == INFINITY)
+ return(INFINITY);
+ }
+
+ /*
+ * It may be that we're using a cud1 capability of \n with the
+ * side-effect of taking the cursor to column 0. Deal with this.
+ */
+ if (used_lf && NLMAPPING && !RAWFLAG)
+ from_x = 0;
+
+ if (result)
+ result += strlen(result);
+
+ if (to_x != from_x)
+ {
+ char try[OPT_SIZE];
+
+ hcost = INFINITY;
+
+ if (column_address)
+ {
+ if (result)
+ (void) strcpy(result, tparm(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)
+ {
+ if (result)
+ (void) strcpy(result, tparm(parm_right_cursor, n));
+ hcost = SP->_cuf_cost;
+ }
+
+ if (cursor_right)
+ {
+ int lhcost = 0;
+
+ try[0] = '\0';
+
+#ifdef TABS_OK
+ /* 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(lhcost, SP->_ht_cost, 1, try, tab);
+ if (lhcost == INFINITY)
+ break;
+ }
+
+ n = to_x - fr;
+ from_x = fr;
+ }
+#endif /* TABS_OK */
+
+#if defined(REAL_ATTR) && defined(WANT_CHAR)
+ /*
+ * 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++)
+ if ((WANT_CHAR(to_y, from_x + i) & A_ATTRIBUTES) != CURRENT_ATTR)
+ {
+ ovw = FALSE;
+ break;
+ }
+ }
+ if (ovw)
+ {
+ char *sp;
+ int i;
+
+ sp = try + strlen(try);
+
+ for (i = 0; i < n; i++)
+ *sp++ = WANT_CHAR(to_y, from_x + i);
+ *sp = '\0';
+ lhcost += n * SP->_char_padding;
+ }
+ else
+#endif /* defined(REAL_ATTR) && defined(WANT_CHAR) */
+ {
+ lhcost = repeated_append(lhcost, SP->_cuf1_cost, n, try, cursor_right);
+ }
+
+ if (lhcost < hcost)
+ {
+ if (result)
+ (void) strcpy(result, try);
+ hcost = lhcost;
+ }
+ }
+ }
+ else /* (to_x < from_x) */
+ {
+ n = from_x - to_x;
+
+ if (parm_left_cursor && SP->_cub_cost < hcost)
+ {
+ if (result)
+ (void) strcpy(result, tparm(parm_left_cursor, n));
+ hcost = SP->_cub_cost;
+ }
+
+ if (cursor_left)
+ {
+ int lhcost = 0;
+
+ try[0] = '\0';
+
+#ifdef TABS_OK
+ if (init_tabs > 0 && back_tab)
+ {
+ int nxt, fr;
+
+ for (fr = from_x; (nxt = LASTTAB(fr)) >= to_x; fr = nxt)
+ {
+ lhcost = repeated_append(lhcost, SP->_cbt_cost, 1, try, back_tab);
+ if (lhcost == INFINITY)
+ break;
+ }
+
+ n = to_x - fr;
+ }
+#endif /* TABS_OK */
+
+ lhcost = repeated_append(lhcost, SP->_cub1_cost, n, try, cursor_left);
+
+ if (lhcost < hcost)
+ {
+ if (result)
+ (void) strcpy(result, try);
+ 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 __inline int
+onscreen_mvcur(int yold,int xold,int ynew,int xnew, bool ovw)
+/* onscreen move from (yold, xold) to (ynew, xnew) */
+{
+ char use[OPT_SIZE], *sp;
+ int tactic = 0, newcost, usecost = INFINITY;
+
+#ifdef MAIN
+ struct timeval before, after;
+
+ gettimeofday(&before, NULL);
+#endif /* MAIN */
+
+ /* tactic #0: use direct cursor addressing */
+ sp = tparm(address_cursor, ynew, xnew);
+ if (sp)
+ {
+ tactic = 0;
+ (void) strcpy(use, sp);
+ usecost = SP->_cup_cost;
+
+#ifdef TRACE
+ if (no_optimize)
+ xold = yold = -1;
+#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 ||
+ REAL_ATTR != A_NORMAL || NOT_LOCAL(yold, xold, ynew, xnew))
+ {
+#ifdef MAIN
+ 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(NULL, yold, xold, ynew, xnew, ovw))!=INFINITY)
+ && newcost < usecost)
+ {
+ tactic = 1;
+ usecost = newcost;
+ }
+
+ /* tactic #2: use carriage-return + local movement */
+ if (yold < screen_lines - 1 && xold < screen_columns - 1)
+ {
+ if (carriage_return
+ && ((newcost=relative_move(NULL, 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(NULL, 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(NULL, 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.
+ */
+ if (auto_left_margin && !eat_newline_glitch
+ && yold > 0 && yold < screen_lines - 1 && cursor_left
+ && ((newcost=relative_move(NULL, yold-1, screen_columns-1, ynew, xnew, ovw)) != INFINITY)
+ && SP->_cr_cost + SP->_cub1_cost + newcost + newcost < usecost)
+ {
+ tactic = 5;
+ usecost = SP->_cr_cost + SP->_cub1_cost + newcost;
+ }
+
+ /*
+ * These cases are ordered by estimated relative frequency.
+ */
+ if (tactic)
+ {
+ if (tactic == 1)
+ (void) relative_move(use, yold, xold, ynew, xnew, ovw);
+ else if (tactic == 2)
+ {
+ (void) strcpy(use, carriage_return);
+ (void) relative_move(use + carriage_return_length,
+ yold,0,ynew,xnew, ovw);
+ }
+ else if (tactic == 3)
+ {
+ (void) strcpy(use, cursor_home);
+ (void) relative_move(use + cursor_home_length,
+ 0, 0, ynew, xnew, ovw);
+ }
+ else if (tactic == 4)
+ {
+ (void) strcpy(use, cursor_to_ll);
+ (void) relative_move(use + cursor_to_ll_length,
+ screen_lines-1, 0, ynew, xnew, ovw);
+ }
+ else /* if (tactic == 5) */
+ {
+ use[0] = '\0';
+ if (xold > 0)
+ (void) strcat(use, carriage_return);
+ (void) strcat(use, cursor_left);
+ (void) relative_move(use + strlen(use),
+ yold-1, screen_columns-1, ynew, xnew, ovw);
+ }
+ }
+#endif /* !NO_OPTIMIZE */
+
+#ifdef MAIN
+ gettimeofday(&after, NULL);
+ diff = after.tv_usec - before.tv_usec
+ + (after.tv_sec - before.tv_sec) * 1000000;
+ if (!profiling)
+ (void) fprintf(stderr, "onscreen: %d msec, %f 28.8Kbps char-equivalents\n",
+ (int)diff, diff/288);
+#endif /* MAIN */
+
+ nonlocal:
+ if (usecost != INFINITY)
+ {
+ TPUTS_TRACE("mvcur");
+ tputs(use, 1, _nc_outch);
+ return(OK);
+ }
+ else
+ return(ERR);
+}
+
+int mvcur(int yold, int xold, int ynew, int xnew)
+/* optimized cursor move from (yold, xold) to (ynew, xnew) */
+{
+ TR(TRACE_MOVE, ("mvcur(%d,%d,%d,%d) called", yold, xold, ynew, xnew));
+
+ if (yold == ynew && xold == xnew)
+ return(OK);
+
+ /*
+ * 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;
+ }
+ if (xold >= screen_columns)
+ {
+ int l;
+
+ l = (xold + 1) / screen_columns;
+ yold += l;
+ xold %= screen_columns;
+ if (!auto_right_margin)
+ {
+ while (l > 0) {
+ if (newline)
+ {
+ TPUTS_TRACE("newline");
+ tputs(newline, 0, _nc_outch);
+ }
+ else
+ putchar('\n');
+ l--;
+ }
+ xold = 0;
+ }
+ if (yold > screen_lines - 1)
+ {
+ ynew -= yold - (screen_lines - 1);
+ yold = screen_lines - 1;
+ }
+ }
+
+#ifdef CURSES_OVERRUN /* not used, it takes us out of sync with curscr */
+ /*
+ * The destination line is offscreen. Try to scroll the screen to
+ * bring it onscreen. Note: this is not a documented feature of the
+ * API. It's here for compatibility with archaic curses code, a
+ * feature no one seems to have actually used in a long time.
+ */
+ if (ynew >= screen_lines)
+ {
+ if (mvcur_scrolln((ynew - (screen_lines - 1)), 0, screen_lines - 1, screen_lines - 1) == OK)
+ ynew = screen_lines - 1;
+ else
+ return(ERR);
+ }
+#endif /* CURSES_OVERRUN */
+
+ /* destination location is on screen now */
+ return(onscreen_mvcur(yold, xold, ynew, xnew, TRUE));
+}
+
+/****************************************************************************
+ *
+ * Cursor save_restore
+ *
+ ****************************************************************************/
+
+/* assumption: sc/rc is faster than cursor addressing */
+
+static int oy, ox; /* ugh, mvcur_scrolln() needs to see this */
+
+static void save_curs(void)
+{
+ if (save_cursor && restore_cursor)
+ {
+ TPUTS_TRACE("save_cursor");
+ putp(save_cursor);
+ }
+
+ oy = CURRENT_ROW;
+ ox = CURRENT_COLUMN;
+}
+
+static void restore_curs(void)
+{
+ if (save_cursor && restore_cursor)
+ {
+ TPUTS_TRACE("restore_cursor");
+ putp(restore_cursor);
+ }
+ else
+ onscreen_mvcur(-1, -1, oy, ox, FALSE);
+}
+
+/****************************************************************************
+ *
+ * Physical-scrolling support
+ *
+ ****************************************************************************/
+
+int _nc_mvcur_scrolln(int n, int top, int bot, int maxy)
+/* scroll region from top to bot by n lines */
+{
+ int i;
+
+ TR(TRACE_MOVE, ("mvcur_scrolln(%d, %d, %d, %d)", n, top, bot, maxy));
+
+ save_curs();
+
+ /*
+ * 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
+ * happen.
+ *
+ * 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 modern terminals and (b) using them avoids bouncing an
+ * unchanged bottom section of the screen up and down, which is
+ * visually nasty.
+ */
+ if (n > 0)
+ {
+ /*
+ * Do explicit clear to end of region if it's possible that the
+ * terminal might hold on to stuff we push off the end.
+ */
+ if (non_dest_scroll_region || (memory_below && bot == maxy))
+ {
+ if (bot == maxy && clr_eos)
+ {
+ mvcur(-1, -1, lines - n, 0);
+ TPUTS_TRACE("clr_eos");
+ tputs(clr_eos, n, _nc_outch);
+ }
+ else if (clr_eol)
+ {
+ for (i = 0; i < n; i++)
+ {
+ mvcur(-1, -1, lines - n + i, 0);
+ TPUTS_TRACE("clr_eol");
+ tputs(clr_eol, n, _nc_outch);
+ }
+ }
+ }
+
+ if (change_scroll_region && (scroll_forward || parm_index))
+ {
+ TPUTS_TRACE("change_scroll_region");
+ tputs(tparm(change_scroll_region, top, bot), 0, _nc_outch);
+ onscreen_mvcur(-1, -1, bot, 0, TRUE);
+ if (parm_index != NULL)
+ {
+ TPUTS_TRACE("parm_index");
+ tputs(tparm(parm_index, n, 0), n, _nc_outch);
+ }
+ else
+ for (i = 0; i < n; i++)
+ {
+ TPUTS_TRACE("scroll_forward");
+ tputs(scroll_forward, 0, _nc_outch);
+ }
+ TPUTS_TRACE("change_scroll_region");
+ tputs(tparm(change_scroll_region, 0, maxy), 0, _nc_outch);
+ restore_curs();
+ return(OK);
+ }
+
+ /* Scroll up the block. */
+ if (parm_index && top == 0)
+ {
+ onscreen_mvcur(oy, ox, bot, 0, TRUE);
+ TPUTS_TRACE("parm_index");
+ tputs(tparm(parm_index, n, 0), n, _nc_outch);
+ }
+ else if (parm_delete_line)
+ {
+ onscreen_mvcur(oy, ox, top, 0, TRUE);
+ TPUTS_TRACE("parm_delete_line");
+ tputs(tparm(parm_delete_line, n, 0), n, _nc_outch);
+ }
+ else if (delete_line)
+ {
+ onscreen_mvcur(oy, ox, top, 0, TRUE);
+ for (i = 0; i < n; i++)
+ {
+ TPUTS_TRACE("parm_index");
+ tputs(delete_line, 0, _nc_outch);
+ }
+ }
+ else if (scroll_forward && top == 0)
+ {
+ onscreen_mvcur(oy, ox, bot, 0, TRUE);
+ for (i = 0; i < n; i++)
+ {
+ TPUTS_TRACE("scroll_forward");
+ tputs(scroll_forward, 0, _nc_outch);
+ }
+ }
+ else
+ return(ERR);
+
+ /* Push down the bottom region. */
+ if (parm_insert_line)
+ {
+ onscreen_mvcur(top, 0, bot - n + 1, 0, FALSE);
+ TPUTS_TRACE("parm_insert_line");
+ tputs(tparm(parm_insert_line, n, 0), n, _nc_outch);
+ }
+ else if (insert_line)
+ {
+ onscreen_mvcur(top, 0, bot - n + 1, 0, FALSE);
+ for (i = 0; i < n; i++)
+ {
+ TPUTS_TRACE("insert_line");
+ tputs(insert_line, 0, _nc_outch);
+ }
+ }
+ else
+ return(ERR);
+ restore_curs();
+ }
+ else /* (n < 0) */
+ {
+ /*
+ * Explicitly clear if stuff pushed off top of region might
+ * be saved by the terminal.
+ */
+ if (non_dest_scroll_region || (memory_above && top == 0))
+ for (i = 0; i < n; i++)
+ {
+ mvcur(-1, -1, i, 0);
+ TPUTS_TRACE("clr_eol");
+ tputs(clr_eol, n, _nc_outch);
+ }
+
+ if (change_scroll_region && (scroll_reverse || parm_rindex))
+ {
+ TPUTS_TRACE("change_scroll_region");
+ tputs(tparm(change_scroll_region, top, bot), 0, _nc_outch);
+ onscreen_mvcur(-1, -1, top, 0, TRUE);
+ if (parm_rindex)
+ {
+ TPUTS_TRACE("parm_rindex");
+ tputs(tparm(parm_rindex, -n, 0), -n, _nc_outch);
+ }
+ else
+ for (i = n; i < 0; i++)
+ {
+ TPUTS_TRACE("scroll_reverse");
+ tputs(scroll_reverse, 0, _nc_outch);
+ }
+ TPUTS_TRACE("change_scroll_region");
+ tputs(tparm(change_scroll_region, 0, maxy), 0, _nc_outch);
+ restore_curs();
+ return(OK);
+ }
+
+ /* Preserve the bottom lines. */
+ onscreen_mvcur(oy, ox, bot + n + 1, 0, TRUE);
+ if (parm_rindex && bot == maxy)
+ {
+ TPUTS_TRACE("parm_rindex");
+ tputs(tparm(parm_rindex, -n, 0), -n, _nc_outch);
+ }
+ else if (parm_delete_line)
+ {
+ TPUTS_TRACE("parm_delete_line");
+ tputs(tparm(parm_delete_line, -n, 0), -n, _nc_outch);
+ }
+ else if (delete_line)
+ for (i = n; i < 0; i++)
+ {
+ TPUTS_TRACE("delete_line");
+ tputs(delete_line, 0, _nc_outch);
+ }
+ else if (scroll_reverse && bot == maxy)
+ for (i = n; i < 0; i++)
+ {
+ TPUTS_TRACE("scroll_reverse");
+ tputs(scroll_reverse, 0, _nc_outch);
+ }
+ else
+ return(ERR);
+
+ /* Scroll the block down. */
+ if (parm_insert_line)
+ {
+ onscreen_mvcur(bot + n + 1, 0, top, 0, FALSE);
+ TPUTS_TRACE("parm_insert_line");
+ tputs(tparm(parm_insert_line, -n, 0), -n, _nc_outch);
+ }
+ else if (insert_line)
+ {
+ onscreen_mvcur(bot + n + 1, 0, top, 0, FALSE);
+ for (i = n; i < 0; i++)
+ {
+ TPUTS_TRACE("insert_line");
+ tputs(insert_line, 0, _nc_outch);
+ }
+ }
+ else
+ return(ERR);
+ restore_curs();
+ }
+
+ return(OK);
+}
+
+#ifdef MAIN
+/****************************************************************************
+ *
+ * Movement optimizer test code
+ *
+ ****************************************************************************/
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <string.h>
+#include <stdlib.h>
+#include "tic.h"
+#include "dump_entry.h"
+
+char *_nc_progname = "mvcur";
+
+static unsigned long xmits;
+
+int tputs(const char *string, int affcnt, int (*outc)(int))
+/* stub tputs() that dumps sequences in a visible form */
+{
+ if (profiling)
+ xmits += strlen(string);
+ else
+ (void) fputs(_nc_visbuf(string), stdout);
+ return(OK);
+}
+
+int putp(const char *string)
+{
+ return(tputs(string, 1, _nc_outch));
+}
+
+int _nc_outch(int ch)
+{
+ putc(ch, stdout);
+ return OK;
+}
+
+static char tname[BUFSIZ];
+
+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, char *argv[])
+{
+ (void) strcpy(tname, getenv("TERM"));
+ load_term();
+ _nc_setupscreen(lines, columns);
+ baudrate();
+
+ _nc_mvcur_init(SP);
+#if HAVE_SETVBUF || HAVE_SETBUFFER
+ /*
+ * Undo the effects of our optimization hack, otherwise our interactive
+ * prompts don't flush properly.
+ */
+#if HAVE_SETVBUF
+ (void) setvbuf(SP->_ofp, malloc(BUFSIZ), _IOLBF, BUFSIZ);
+#elif HAVE_SETBUFFER
+ (void) setbuffer(SP->_ofp, malloc(BUFSIZ), BUFSIZ);
+#endif
+#endif /* HAVE_SETVBUF || HAVE_SETBUFFER */
+
+ (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",
+ getenv("TERM"));
+(void) puts("l[oad] <term> -- load terminal info for type <term>");
+(void) puts("nl -- assume NL -> CR/LF when computing (default)");
+(void) puts("nonl -- don't assume NL -> CR/LF when computing");
+(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",
+ 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_mvcur_scrolln(fy, fx, ty, tx);
+ gettimeofday(&after, NULL);
+
+ printf("\" (%ld msec)\n",
+ after.tv_usec - before.tv_usec + (after.tv_sec - before.tv_sec) * 1000000);
+ }
+ else if (buf[0] == 'r')
+ {
+ (void) strcpy(tname, getenv("TERM"));
+ load_term();
+ }
+ else if (sscanf(buf, "l %s", tname) == 1)
+ {
+ load_term();
+ }
+ else if (strncmp(buf, "nl", 2) == 0)
+ {
+ NLMAPPING = TRUE;
+ (void) puts("NL -> CR/LF will be assumed.");
+ }
+ else if (strncmp(buf, "nonl", 4) == 0)
+ {
+ NLMAPPING = FALSE;
+ (void) puts("NL -> CR/LF will not be assumed.");
+ }
+ else if (sscanf(buf, "d %s", capname) == 1)
+ {
+ struct name_table_entry const *np = _nc_find_entry(capname,
+ _nc_info_hash_table);
+
+ 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] = -1;
+ (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] = (char *)NULL;
+ (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);
+ dump_entry(&cur_term->type, NULL);
+ putchar('\n');
+ }
+ else if (buf[0] == 'o')
+ {
+ if (no_optimize)
+ {
+ no_optimize = FALSE;
+ (void) puts("Optimization is now on.");
+ }
+ else
+ {
+ no_optimize = TRUE;
+ (void) puts("Optimization is now off.");
+ }
+ }
+ /*
+ * 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, 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);
+#ifdef TABS_OK
+ (void) printf("ht cost: %d\n", SP->_ht_cost);
+ (void) printf("cbt cost: %d\n", SP->_cbt_cost);
+#endif /* TABS_OK */
+ (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/lib/libcurses/lib_mvwin.c b/lib/libcurses/lib_mvwin.c
new file mode 100644
index 00000000000..f84f6941239
--- /dev/null
+++ b/lib/libcurses/lib_mvwin.c
@@ -0,0 +1,55 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+
+/*
+** lib_mvwin.c
+**
+** The routine mvwin().
+**
+*/
+
+#include "curses.priv.h"
+
+int mvwin(WINDOW *win, int by, int bx)
+{
+ T(("mvwin(%p,%d,%d) called", win, by, bx));
+
+ if (win->_flags & _SUBWIN)
+ return(ERR);
+
+ if (by + win->_maxy > screen_lines - 1
+ || bx + win->_maxx > screen_columns - 1
+ || by < 0
+ || bx < 0)
+ return(ERR);
+
+ /*
+ * Whether or not the window is moved, touch the window's contents so
+ * that a following call to 'wrefresh()' will paint the window at the
+ * new location. This ensures that if the caller has refreshed another
+ * window at the same location, that this one will be displayed.
+ */
+ win->_begy = by;
+ win->_begx = bx;
+ return touchwin(win);
+}
diff --git a/lib/libcurses/lib_newterm.c b/lib/libcurses/lib_newterm.c
new file mode 100644
index 00000000000..b2551b56764
--- /dev/null
+++ b/lib/libcurses/lib_newterm.c
@@ -0,0 +1,189 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+
+/*
+** lib_newterm.c
+**
+** The newterm() function.
+**
+*/
+
+#include "curses.priv.h"
+#include <stdlib.h>
+#include "term.h" /* clear_screen, cup & friends, cur_term */
+
+/* This should moved to TERMINAL */
+static filter_mode = FALSE;
+
+void filter(void)
+{
+ filter_mode = TRUE;
+}
+
+SCREEN * newterm(const char *term, FILE *ofp, FILE *ifp)
+{
+int errret;
+#ifdef TRACE
+char *t = getenv("NCURSES_TRACE");
+
+ if (t)
+ trace(strtol(t, 0, 0));
+#endif
+
+ T(("newterm(\"%s\",%p,%p) called", term, ofp, ifp));
+
+ /* this loads the capability entry, then sets LINES and COLS */
+ if (setupterm(term, fileno(ofp), &errret) != 1)
+ return NULL;
+
+ /* optional optimization hack -- do before any output to ofp */
+#if HAVE_SETVBUF || HAVE_SETBUFFER
+ {
+ /*
+ * If the output file descriptor is connected to a tty
+ * (the typical case) it will probably be line-buffered.
+ * Keith Bostic pointed out that we don't want this; it
+ * hoses people running over networks by forcing out a
+ * bunch of small packets instead of one big one, so
+ * screen updates on ptys look jerky. Restore block
+ * buffering to prevent this minor lossage.
+ *
+ * The buffer size is a compromise. Ideally we'd like a
+ * buffer that can hold the maximum possible update size
+ * (the whole screen plus cup commands to change lines as
+ * it's painted). On a modern 66-line xterm this can
+ * become excessive. So we min it with the amount of data
+ * we think we can get through two Ethernet packets
+ * (maximum packet size - 100 for TCP/IP overhead).
+ *
+ * Why two ethernet packets? It used to be one, on the theory
+ * that said packets define the maximum size of atomic update.
+ * But that's less than the 2000 chars on a 25 x 80 screen, and
+ * we don't want local updates to flicker either. Two packet
+ * lengths will handle up to a 35 x 80 screen.
+ *
+ * The magic '6' is the estimated length of the end-of-line
+ * cup sequence to go to the next line. It's generous. We
+ * used to mess with the buffering in init_mvcur() after cost
+ * computation, but that lost the sequences emitted by init_acs()
+ * in setupscreen().
+ *
+ * "The setvbuf function may be used only after the stream pointed
+ * to by stream as been associated with an open file and before any
+ * other operation is performed on the stream." (ISO 7.9.5.6.)
+ *
+ * Grrrr...
+ */
+ unsigned int bufsiz = min(LINES * (COLS + 6), 2800);
+
+#if HAVE_SETVBUF
+ /*
+ * If your code core-dumps here, you are probably running
+ * some bastard offspring of an SVR3 on which the setvbuffer(3)
+ * arguments are reversed. Autoconf has a test macro for this
+ * but I have too much else to do to figure out how it works.
+ * Send us a patch if you care.
+ */
+ (void) setvbuf(ofp, malloc(bufsiz), _IOFBF, bufsiz);
+#elif HAVE_SETBUFFER
+ (void) setbuffer(ofp, malloc(bufsiz), (int)bufsiz);
+#endif
+ }
+#endif /* HAVE_SETVBUF || HAVE_SETBUFFER */
+
+ /* implement filter mode */
+ if (filter_mode) {
+ LINES = 1;
+
+#ifdef init_tabs
+ if (init_tabs != -1)
+ TABSIZE = init_tabs;
+ else
+#endif /* init_tabs */
+ TABSIZE = 8;
+
+ T(("TABSIZE = %d", TABSIZE));
+
+#ifdef clear_screen
+ clear_screen = (char *)NULL;
+ cursor_down = parm_down_cursor = (char *)NULL;
+ cursor_address = (char *)NULL;
+ cursor_up = parm_up_cursor = (char *)NULL;
+ row_address = (char *)NULL;
+
+ cursor_home = carriage_return;
+#endif /* clear_screen */
+ }
+
+ /* if we must simulate soft labels, grab off the line to be used */
+#ifdef num_labels
+ if (num_labels <= 0)
+#endif /* num_labels */
+ if (_slk_init)
+ ripoffline(-1, slk_initialize);
+
+ /* this actually allocates the screen structure */
+ if (_nc_setupscreen(LINES, COLS) == ERR)
+ return NULL;
+
+#ifdef num_labels
+ /* if the terminal type has real soft labels, set those up */
+ if (_slk_init && num_labels > 0)
+ slk_initialize(stdscr, COLS);
+#endif /* num_labels */
+
+ SP->_ifd = fileno(ifp);
+ SP->_checkfd = fileno(ifp);
+ typeahead(fileno(ifp));
+ SP->_ofp = ofp;
+#ifdef TERMIOS
+ SP->_use_meta = ((cur_term->Ottyb.c_cflag & CSIZE) == CS8 &&
+ !(cur_term->Ottyb.c_iflag & ISTRIP));
+#else
+ SP->_use_meta = FALSE;
+#endif
+ SP->_endwin = FALSE;
+
+ baudrate(); /* sets a field in the SP structure */
+
+ /* compute movement costs so we can do better move optimization */
+ _nc_mvcur_init(SP);
+
+#if 0
+ /* initialize soft labels */
+ if (_slk_init)
+ if (num_labels <= 0)
+ ripoffline(-1, slk_initialize);
+ else
+ slk_initialize(stdscr, COLS);
+#endif
+ _nc_signal_handler(TRUE);
+
+ /* open a connection to the screen's associated mouse, if any */
+ _nc_mouse_init(SP);
+
+ T(("newterm returns %p", SP));
+
+ return(SP);
+}
+
diff --git a/lib/libcurses/lib_newwin.c b/lib/libcurses/lib_newwin.c
new file mode 100644
index 00000000000..0fd8d16db36
--- /dev/null
+++ b/lib/libcurses/lib_newwin.c
@@ -0,0 +1,193 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+
+/*
+** lib_newwin.c
+**
+** The routines newwin(), subwin() and their dependent
+**
+*/
+
+#include "curses.priv.h"
+#include <stdlib.h>
+
+WINDOW * newwin(int num_lines, int num_columns, int begy, int begx)
+{
+WINDOW *win;
+chtype *ptr;
+int i, j;
+
+ T(("newwin(%d,%d,%d,%d) called", num_lines, num_columns, begy, begx));
+
+ if (num_lines == 0)
+ num_lines = screen_lines - begy;
+ if (num_columns == 0)
+ num_columns = screen_columns - begx;
+
+ if (num_columns + begx > SP->_columns || num_lines + begy > SP->_lines)
+ return NULL;
+
+ if ((win = _nc_makenew(num_lines, num_columns, begy, begx)) == NULL)
+ return NULL;
+
+ for (i = 0; i < num_lines; i++) {
+ if ((win->_line[i].text = (chtype *) calloc((unsigned)num_columns, sizeof(chtype))) == NULL) {
+ for (j = 0; j < i; j++)
+ free(win->_line[j].text);
+
+ free(win->_line);
+ free(win);
+
+ return NULL;
+ }
+ else
+ for (ptr = win->_line[i].text; ptr < win->_line[i].text + num_columns; )
+ *ptr++ = ' ';
+ }
+
+ T(("newwin: returned window is %p", win));
+
+ return(win);
+}
+
+WINDOW * derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx)
+{
+WINDOW *win;
+int i;
+
+ T(("derwin(%p, %d,%d,%d,%d) called", orig, num_lines, num_columns, begy, begx));
+
+ /*
+ ** make sure window fits inside the original one
+ */
+ if ( begy < 0 || begx < 0)
+ return NULL;
+ if ( begy + num_lines > orig->_maxy + 1
+ || begx + num_columns > orig->_maxx + 1)
+ return NULL;
+
+ if (num_lines == 0)
+ num_lines = orig->_maxy - begy;
+
+ if (num_columns == 0)
+ num_columns = orig->_maxx - begx;
+
+ if ((win = _nc_makenew(num_lines, num_columns, orig->_begy + begy, orig->_begx + begx)) == NULL)
+ return NULL;
+
+ win->_pary = begy;
+ win->_parx = begx;
+ win->_attrs = orig->_attrs;
+ win->_bkgd = orig->_bkgd;
+
+ for (i = 0; i < num_lines; i++)
+ win->_line[i].text = &orig->_line[begy++].text[begx];
+
+ win->_flags = _SUBWIN;
+ win->_parent = orig;
+
+ T(("derwin: returned window is %p", win));
+
+ return(win);
+}
+
+
+WINDOW *subwin(WINDOW *w, int l, int c, int y, int x)
+{
+ T(("subwin(%p, %d, %d, %d, %d) called", w, l, c, y, x));
+ T(("parent has begy = %d, begx = %d", w->_begy, w->_begx));
+
+ return derwin(w, l, c, y - w->_begy, x - w->_begx);
+}
+
+WINDOW *
+_nc_makenew(int num_lines, int num_columns, int begy, int begx)
+{
+int i;
+WINDOW *win;
+
+ T(("_nc_makenew(%d,%d,%d,%d)", num_lines, num_columns, begy, begx));
+
+ if (num_lines <= 0 || num_columns <= 0)
+ return NULL;
+
+ if ((win = (WINDOW *) calloc(1, sizeof(WINDOW))) == NULL)
+ return NULL;
+
+ if ((win->_line = (struct ldat *) calloc((unsigned)num_lines, sizeof (struct ldat))) == NULL) {
+ free(win);
+ return NULL;
+ }
+
+ win->_curx = 0;
+ win->_cury = 0;
+ win->_maxy = num_lines - 1;
+ win->_maxx = num_columns - 1;
+ win->_begy = begy;
+ win->_begx = begx;
+
+ win->_flags = 0;
+ win->_attrs = A_NORMAL;
+ win->_bkgd = A_NORMAL;
+
+ win->_clear = (num_lines == screen_lines && num_columns == screen_columns);
+ win->_idlok = FALSE;
+ win->_idcok = TRUE;
+ win->_scroll = FALSE;
+ win->_leaveok = FALSE;
+ win->_use_keypad = FALSE;
+ win->_delay = -1;
+ win->_immed = FALSE;
+ win->_sync = 0;
+ win->_parx = -1;
+ win->_pary = -1;
+ win->_parent = (WINDOW *)NULL;
+
+ win->_regtop = 0;
+ win->_regbottom = num_lines - 1;
+
+ win->_pad._pad_y = -1;
+ win->_pad._pad_x = -1;
+ win->_pad._pad_top = -1;
+ win->_pad._pad_bottom = -1;
+ win->_pad._pad_left = -1;
+ win->_pad._pad_right = -1;
+
+ for (i = 0; i < num_lines; i++)
+ {
+ win->_line[i].firstchar = win->_line[i].lastchar = _NOCHANGE;
+ win->_line[i].oldindex = i;
+ }
+
+ if (begx + num_columns == screen_columns) {
+ win->_flags |= _ENDLINE;
+
+ if (begx == 0 && num_lines == screen_lines && begy == 0)
+ win->_flags |= _FULLWIN;
+
+ if (begy + num_lines == screen_lines)
+ win->_flags |= _SCROLLWIN;
+ }
+
+ return(win);
+}
diff --git a/lib/libcurses/lib_options.c b/lib/libcurses/lib_options.c
new file mode 100644
index 00000000000..c2a73db8a7d
--- /dev/null
+++ b/lib/libcurses/lib_options.c
@@ -0,0 +1,364 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+/*
+** lib_options.c
+**
+** The routines to handle option setting.
+**
+*/
+
+#include "curses.priv.h"
+#include <stdlib.h>
+#include "term.h" /* keypad_xmit, keypad_local, meta_on, meta_off */
+ /* cursor_visible,cursor_normal,cursor_invisible */
+
+int has_ic(void)
+{
+ T(("has_ic() called"));
+ return (insert_character || parm_ich)
+ && (delete_character || parm_dch);
+}
+
+int has_il(void)
+{
+ T(("has_il() called"));
+ return (insert_line || parm_insert_line)
+ && (delete_line || parm_delete_line);
+}
+
+int idlok(WINDOW *win, bool flag)
+{
+ T(("idlok(%p,%d) called", win, flag));
+
+ win->_idlok = flag && (has_il() || change_scroll_region);
+ return OK;
+}
+
+
+int idcok(WINDOW *win, bool flag)
+{
+ T(("idcok(%p,%d) called", win, flag));
+
+ win->_idcok = flag && has_ic();
+
+ return OK;
+}
+
+
+int clearok(WINDOW *win, bool flag)
+{
+ T(("clearok(%p,%d) called", win, flag));
+
+ if (win == curscr)
+ newscr->_clear = flag;
+ else
+ win->_clear = flag;
+ return OK;
+}
+
+
+int immedok(WINDOW *win, bool flag)
+{
+ T(("immedok(%p,%d) called", win, flag));
+
+ win->_immed = flag;
+ return OK;
+}
+
+int leaveok(WINDOW *win, bool flag)
+{
+ T(("leaveok(%p,%d) called", win, flag));
+
+ win->_leaveok = flag;
+ if (flag == TRUE)
+ curs_set(0);
+ else
+ curs_set(1);
+ return OK;
+}
+
+
+int scrollok(WINDOW *win, bool flag)
+{
+ T(("scrollok(%p,%d) called", win, flag));
+
+ win->_scroll = flag;
+ return OK;
+}
+
+int halfdelay(int t)
+{
+ T(("halfdelay(%d) called", t));
+
+ if (t < 1 || t > 255)
+ return ERR;
+
+ cbreak();
+ SP->_cbreak = t+1;
+ return OK;
+}
+
+int nodelay(WINDOW *win, bool flag)
+{
+ T(("nodelay(%p,%d) called", win, flag));
+
+ if (flag == TRUE)
+ win->_delay = 0;
+ else win->_delay = -1;
+ return OK;
+}
+
+int notimeout(WINDOW *win, bool f)
+{
+ T(("notimout(%p,%d) called", win, f));
+
+ win->_notimeout = f;
+ return OK;
+}
+
+int wtimeout(WINDOW *win, int delay)
+{
+ T(("wtimeout(%p,%d) called", win, delay));
+
+ win->_delay = delay;
+ return OK;
+}
+
+static void init_keytry(void);
+static void add_to_try(char *, short);
+
+/* Turn the keypad on/off
+ *
+ * Note: we flush the output because changing this mode causes some terminals
+ * to emit different escape sequences for cursor and keypad keys. If we don't
+ * flush, then the next wgetch may get the escape sequence that corresponds to
+ * the terminal state _before_ switching modes.
+ */
+int _nc_keypad(bool flag)
+{
+ if (flag && keypad_xmit)
+ {
+ TPUTS_TRACE("keypad_xmit");
+ putp(keypad_xmit);
+ (void) fflush(SP->_ofp);
+ }
+ else if (! flag && keypad_local)
+ {
+ TPUTS_TRACE("keypad_local");
+ putp(keypad_local);
+ (void) fflush(SP->_ofp);
+ }
+
+ if (SP->_keytry == UNINITIALISED)
+ init_keytry();
+ return OK;
+}
+
+int keypad(WINDOW *win, bool flag)
+{
+ T(("keypad(%p,%d) called", win, flag));
+
+ win->_use_keypad = flag;
+ return (_nc_keypad(flag));
+}
+
+
+int meta(WINDOW *win, bool flag)
+{
+ T(("meta(%p,%d) called", win, flag));
+
+ SP->_use_meta = flag;
+
+ if (flag && meta_on)
+ {
+ TPUTS_TRACE("meta_on");
+ putp(meta_on);
+ }
+ else if (! flag && meta_off)
+ {
+ TPUTS_TRACE("meta_off");
+ putp(meta_off);
+ }
+ return OK;
+}
+
+/* curs_set() moved here to narrow the kernel interface */
+
+int curs_set(int vis)
+{
+int cursor = SP->_cursor;
+
+ T(("curs_set(%d)", vis));
+
+ if (vis < 0 || vis > 2)
+ return ERR;
+
+ switch(vis) {
+ case 2:
+ if (cursor_visible)
+ {
+ TPUTS_TRACE("cursor_visible");
+ putp(cursor_visible);
+ }
+ break;
+ case 1:
+ if (cursor_normal)
+ {
+ TPUTS_TRACE("cursor_normal");
+ putp(cursor_normal);
+ }
+ break;
+ case 0:
+ if (cursor_invisible)
+ {
+ TPUTS_TRACE("cursor_invisible");
+ putp(cursor_invisible);
+ }
+ break;
+ }
+ SP->_cursor = vis;
+ return cursor;
+}
+
+/*
+** init_keytry()
+**
+** Construct the try for the current terminal's keypad keys.
+**
+*/
+
+
+static struct try *newtry;
+
+static void init_keytry(void)
+{
+ newtry = NULL;
+
+#include "keys.tries"
+
+ SP->_keytry = newtry;
+}
+
+
+static void add_to_try(char *str, short code)
+{
+static bool out_of_memory = FALSE;
+struct try *ptr, *savedptr;
+
+ if (! str || out_of_memory)
+ return;
+
+ if (newtry != NULL) {
+ ptr = savedptr = newtry;
+
+ for (;;) {
+ while (ptr->ch != (unsigned char) *str
+ && ptr->sibling != NULL)
+ ptr = ptr->sibling;
+
+ if (ptr->ch == (unsigned char) *str) {
+ if (*(++str)) {
+ if (ptr->child != NULL)
+ ptr = ptr->child;
+ else
+ break;
+ } else {
+ ptr->value = code;
+ return;
+ }
+ } else {
+ if ((ptr->sibling = (struct try *) malloc(sizeof *ptr)) == NULL) {
+ out_of_memory = TRUE;
+ return;
+ }
+
+ savedptr = ptr = ptr->sibling;
+ ptr->child = ptr->sibling = NULL;
+ if (*str == '\200')
+ ptr->ch = '\0';
+ else
+ ptr->ch = (unsigned char) *str;
+ str++;
+ ptr->value = (short) NULL;
+
+ break;
+ }
+ } /* end for (;;) */
+ } else { /* newtry == NULL :: First sequence to be added */
+ savedptr = ptr = newtry = (struct try *) malloc(sizeof *ptr);
+
+ if (ptr == NULL) {
+ out_of_memory = TRUE;
+ return;
+ }
+
+ ptr->child = ptr->sibling = NULL;
+ if (*str == '\200')
+ ptr->ch = '\0';
+ else
+ ptr->ch = (unsigned char) *str;
+ str++;
+ ptr->value = (short) NULL;
+ }
+
+ /* at this point, we are adding to the try. ptr->child == NULL */
+
+ while (*str) {
+ ptr->child = (struct try *) malloc(sizeof *ptr);
+
+ ptr = ptr->child;
+
+ if (ptr == NULL) {
+ out_of_memory = TRUE;
+
+ ptr = savedptr;
+ while (ptr != NULL) {
+ savedptr = ptr->child;
+ free(ptr);
+ ptr = savedptr;
+ }
+
+ return;
+ }
+
+ ptr->child = ptr->sibling = NULL;
+ if (*str == '\200')
+ ptr->ch = '\0';
+ else
+ ptr->ch = (unsigned char) *str;
+ str++;
+ ptr->value = (short) NULL;
+ }
+
+ ptr->value = code;
+ return;
+}
+
+int typeahead(int fd)
+{
+
+ T(("typeahead(%d) called", fd));
+ SP->_checkfd = fd;
+ return OK;
+}
+
diff --git a/lib/libcurses/lib_overlay.c b/lib/libcurses/lib_overlay.c
new file mode 100644
index 00000000000..867c2e178d5
--- /dev/null
+++ b/lib/libcurses/lib_overlay.c
@@ -0,0 +1,135 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+/*
+** lib_overlay.c
+**
+** The routines overlay(), copywin(), and overwrite().
+**
+*/
+
+#include "curses.priv.h"
+
+static void overlap(const WINDOW *const s, WINDOW *const d, int const flag)
+{
+int sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol;
+
+ T(("overlap : sby %d, sbx %d, smy %d, smx %d, dby %d, dbx %d, dmy %d, dmx %d",
+ s->_begy, s->_begx, s->_maxy, s->_maxx,
+ d->_begy, d->_begx, d->_maxy, d->_maxx));
+ sminrow = max(s->_begy, d->_begy) - s->_begy;
+ smincol = max(s->_begx, d->_begx) - s->_begx;
+ dminrow = max(s->_begy, d->_begy) - d->_begy;
+ dmincol = max(s->_begx, d->_begx) - d->_begx;
+ dmaxrow = min(s->_maxy+s->_begy, d->_maxy+d->_begy) - d->_begy;
+ dmaxcol = min(s->_maxx+s->_begx, d->_maxx+d->_begx) - d->_begx;
+
+ copywin(s, d, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol, flag);
+}
+
+/*
+**
+** overlay(win1, win2)
+**
+**
+** overlay() writes the overlapping area of win1 behind win2
+** on win2 non-destructively.
+**
+**/
+
+int overlay(const WINDOW *win1, WINDOW *win2)
+{
+ overlap(win1, win2, TRUE);
+ return OK;
+}
+
+/*
+**
+** overwrite(win1, win2)
+**
+**
+** overwrite() writes the overlapping area of win1 behind win2
+** on win2 destructively.
+**
+**/
+
+int overwrite(const WINDOW *win1, WINDOW *win2)
+{
+ overlap(win1, win2, FALSE);
+ return OK;
+}
+
+int copywin(const WINDOW *src, WINDOW *dst,
+ int sminrow, int smincol,
+ int dminrow, int dmincol, int dmaxrow, int dmaxcol,
+ int over)
+{
+int sx, sy, dx, dy;
+int touched;
+
+ T(("copywin(%p, %p, %d, %d, %d, %d, %d, %d, %d)",
+ src, dst, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol, over));
+
+ /* make sure rectangle exists in source */
+ if ((sminrow + dmaxrow - dminrow) > (src->_maxy + 1) ||
+ (smincol + dmaxcol - dmincol) > (src->_maxx + 1)) {
+ return ERR;
+ }
+
+ T(("rectangle exists in source"));
+
+ /* make sure rectangle fits in destination */
+ if (dmaxrow > dst->_maxy || dmaxcol > dst->_maxx) {
+ return ERR;
+ }
+
+ T(("rectangle fits in destination"));
+
+ for (dy = dminrow, sy = sminrow; dy <= dmaxrow; sy++, dy++) {
+ touched=0;
+ for(dx=dmincol, sx=smincol; dx <= dmaxcol; sx++, dx++)
+ {
+ if (over)
+ {
+ if (((src->_line[sy].text[sx] & A_CHARTEXT)!=' ') &&
+ (dst->_line[dy].text[dx]!=src->_line[sy].text[sx]))
+ {
+ dst->_line[dy].text[dx] = src->_line[sy].text[sx];
+ touched=1;
+ }
+ }
+ else {
+ if (dst->_line[dy].text[dx] != src->_line[sy].text[sx])
+ {
+ dst->_line[dy].text[dx] = src->_line[sy].text[sx];
+ touched=1;
+ }
+ }
+ }
+ if (touched)
+ {
+ touchline(dst,0,getmaxy(dst));
+ }
+ }
+ T(("finished copywin"));
+ return OK;
+}
diff --git a/lib/libcurses/lib_pad.c b/lib/libcurses/lib_pad.c
new file mode 100644
index 00000000000..392305f658d
--- /dev/null
+++ b/lib/libcurses/lib_pad.c
@@ -0,0 +1,258 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+/*
+ * lib_pad.c
+ * newpad -- create a new pad
+ * pnoutrefresh -- refresh a pad, no update
+ * pechochar -- add a char to a pad and refresh
+ */
+
+#include "curses.priv.h"
+
+#include <stdlib.h>
+#include <errno.h>
+
+#if !HAVE_EXTERN_ERRNO
+extern int errno;
+#endif
+
+WINDOW *newpad(int l, int c)
+{
+WINDOW *win;
+chtype *ptr;
+int i, j;
+
+ T(("newpad(%d, %d) called", l, c));
+
+ if (l <= 0 || c <= 0)
+ return NULL;
+
+ if ((win = _nc_makenew(l,c,0,0)) == NULL)
+ return NULL;
+
+ win->_flags |= _ISPAD;
+
+ for (i = 0; i < l; i++) {
+ win->_line[i].oldindex = _NEWINDEX;
+ if ((win->_line[i].text = (chtype *) calloc((size_t)c, sizeof(chtype))) == NULL) {
+ for (j = 0; j < i; j++)
+ free(win->_line[j].text);
+
+ free(win->_line);
+ free(win);
+
+ errno = ENOMEM;
+ return NULL;
+ }
+ else
+ for (ptr = win->_line[i].text; ptr < win->_line[i].text + c; )
+ *ptr++ = ' ';
+ }
+
+ T(("newpad: returned window is %p", win));
+
+ return(win);
+}
+
+WINDOW *subpad(WINDOW *orig, int l, int c, int begy, int begx)
+{
+WINDOW *win;
+
+ T(("subpad(%d, %d) called", l, c));
+
+ if ((win = derwin(orig, l, c, begy, begx)) == NULL)
+ return NULL;
+
+ win->_flags |= _ISPAD;
+
+ T(("subpad: returned window is %p", win));
+
+ return(win);
+}
+
+int prefresh(WINDOW *win, int pminrow, int pmincol,
+ int sminrow, int smincol, int smaxrow, int smaxcol)
+{
+ T(("prefresh() called"));
+ if (pnoutrefresh(win, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol) != ERR
+ && doupdate() != ERR) {
+ return OK;
+ }
+ return ERR;
+}
+
+int pnoutrefresh(WINDOW *win, int pminrow, int pmincol,
+ int sminrow, int smincol, int smaxrow, int smaxcol)
+{
+short i, j;
+short m, n;
+short pmaxrow;
+short pmaxcol;
+short displaced;
+bool wide;
+
+ T(("pnoutrefresh(%p, %d, %d, %d, %d, %d, %d) called",
+ win, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol));
+
+ if (win == 0)
+ return ERR;
+
+ if (!(win->_flags & _ISPAD))
+ return ERR;
+
+ /* negative values are interpreted as zero */
+ if (pminrow < 0) pminrow = 0;
+ if (pmincol < 0) pmincol = 0;
+ if (sminrow < 0) sminrow = 0;
+ if (smincol < 0) smincol = 0;
+
+ if (smaxrow > screen_lines
+ || smaxcol > screen_columns
+ || sminrow > smaxrow
+ || smincol > smaxcol)
+ return ERR;
+
+ pmaxrow = pminrow + smaxrow - sminrow;
+ pmaxcol = pmincol + smaxcol - smincol;
+
+ T((" pminrow + smaxrow - sminrow %d, win->_maxy %d", pmaxrow, win->_maxy));
+ T((" pmincol + smaxcol - smincol %d, win->_maxx %d", pmaxcol, win->_maxx));
+ if ((pmaxrow > win->_maxy)
+ || (pmaxcol > win->_maxx))
+ return ERR;
+
+ T(("pad being refreshed"));
+
+ if (win->_pad._pad_y >= 0) {
+ displaced = pminrow - win->_pad._pad_y
+ -(sminrow - win->_pad._pad_top);
+ T(("pad being shifted by %d line(s)", displaced));
+ } else
+ displaced = 0;
+
+ /*
+ * For pure efficiency, we'd want to transfer scrolling information
+ * from the pad to newscr whenever the window is wide enough that
+ * its update will dominate the cost of the update for the horizontal
+ * band of newscr that it occupies. Unfortunately, this threshold
+ * tends to be complex to estimate, and in any case scrolling the
+ * whole band and rewriting the parts outside win's image would look
+ * really ugly. So. What we do is consider the pad "wide" if it
+ * either (a) occupies the whole width of newscr, or (b) occupies
+ * all but at most one column on either vertical edge of the screen
+ * (this caters to fussy people who put boxes around full-screen
+ * windows). Note that changing this formula will not break any code,
+ * merely change the costs of various update cases.
+ */
+ wide = (sminrow <= 1 && win->_maxx >= (newscr->_maxx - 1));
+
+ for (i = pminrow, m = sminrow; i <= pmaxrow; i++, m++) {
+ register struct ldat *nline = &newscr->_line[m];
+ register struct ldat *oline = &win->_line[i];
+
+ for (j = pmincol, n = smincol; j <= pmaxcol; j++, n++) {
+ if (oline->text[j] != nline->text[n]) {
+ nline->text[n] = oline->text[j];
+
+ if (nline->firstchar == _NOCHANGE)
+ nline->firstchar = nline->lastchar = n;
+ else if (n < nline->firstchar)
+ nline->firstchar = n;
+ else if (n > nline->lastchar)
+ nline->lastchar = n;
+ }
+ }
+
+ if (wide) {
+ int nind = m + displaced;
+ if (oline->oldindex < 0
+ || nind < sminrow
+ || nind > smaxrow)
+ nind = _NEWINDEX;
+
+ nline->oldindex = nind;
+ }
+ oline->firstchar = oline->lastchar = _NOCHANGE;
+ oline->oldindex = i;
+ }
+
+ /*
+ * Clean up debris from scrolling or resizing the pad, so we do not
+ * accidentally pick up the index value during the next call to this
+ * procedure. The only rows that should have an index value are those
+ * that are displayed during this cycle.
+ */
+ for (i = pminrow-1; (i >= 0) && (win->_line[i].oldindex >= 0); i--)
+ win->_line[i].oldindex = _NEWINDEX;
+ for (i = pmaxrow+1; (i <= win->_maxy) && (win->_line[i].oldindex >= 0); i++)
+ win->_line[i].oldindex = _NEWINDEX;
+
+ win->_begx = smincol;
+ win->_begy = sminrow;
+
+ if (win->_clear) {
+ win->_clear = FALSE;
+ newscr->_clear = TRUE;
+ }
+
+ /*
+ * Use the pad's current position, if it will be visible.
+ * If not, don't do anything; it's not an error.
+ */
+ if (win->_leaveok == FALSE
+ && win->_cury >= pminrow
+ && win->_curx >= pmincol
+ && win->_cury <= pmaxrow
+ && win->_curx <= pmaxcol) {
+ newscr->_cury = win->_cury - pminrow + win->_begy;
+ newscr->_curx = win->_curx - pmincol + win->_begx;
+ }
+ win->_flags &= ~_HASMOVED;
+
+ /*
+ * Update our cache of the line-numbers that we displayed from the pad.
+ * We will use this on subsequent calls to this function to derive
+ * values to stuff into 'oldindex[]' -- for scrolling optimization.
+ */
+ win->_pad._pad_y = pminrow;
+ win->_pad._pad_x = pmincol;
+ win->_pad._pad_top = sminrow;
+ win->_pad._pad_left = smincol;
+ win->_pad._pad_bottom = smaxrow;
+ win->_pad._pad_right = smaxcol;
+
+ return OK;
+}
+
+int pechochar(WINDOW *pad, chtype ch)
+{
+ T(("echochar(%p, %lx)", pad, ch));
+
+ if (pad->_flags & _ISPAD)
+ return ERR;
+
+ waddch(curscr, ch);
+ doupdate();
+ return OK;
+}
+
diff --git a/lib/libcurses/lib_printw.c b/lib/libcurses/lib_printw.c
new file mode 100644
index 00000000000..22ad9c7cd8b
--- /dev/null
+++ b/lib/libcurses/lib_printw.c
@@ -0,0 +1,93 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+
+/*
+** lib_printw.c
+**
+** The routines printw(), wprintw() and friends.
+**
+*/
+
+#include "curses.priv.h"
+
+int printw(const char *fmt, ...)
+{
+va_list argp;
+char buf[BUFSIZ];
+
+ T(("printw(\"%s\",...) called", fmt));
+
+ va_start(argp, fmt);
+ vsprintf(buf, fmt, argp);
+ va_end(argp);
+ return(waddstr(stdscr, buf));
+}
+
+
+
+int wprintw(WINDOW *win, const char *fmt, ...)
+{
+va_list argp;
+char buf[BUFSIZ];
+
+ T(("wprintw(%p,\"%s\",...) called", win, fmt));
+
+ va_start(argp, fmt);
+ vsprintf(buf, fmt, argp);
+ va_end(argp);
+ return(waddstr(win, buf));
+}
+
+
+
+int mvprintw(int y, int x, const char *fmt, ...)
+{
+va_list argp;
+char buf[BUFSIZ];
+
+ va_start(argp, fmt);
+ vsprintf(buf, fmt, argp);
+ va_end(argp);
+ return(move(y, x) == OK ? waddstr(stdscr, buf) : ERR);
+}
+
+
+
+int mvwprintw(WINDOW *win, int y, int x, const char *fmt, ...)
+{
+va_list argp;
+char buf[BUFSIZ];
+
+ va_start(argp, fmt);
+ vsprintf(buf, fmt, argp);
+ va_end(argp);
+ return(wmove(win, y, x) == OK ? waddstr(win, buf) : ERR);
+}
+
+int vwprintw(WINDOW *win, const char *fmt, va_list argp)
+{
+char buf[BUFSIZ];
+
+ vsprintf(buf, fmt, argp);
+ return(waddstr(win, buf));
+}
diff --git a/lib/libcurses/lib_raw.c b/lib/libcurses/lib_raw.c
new file mode 100644
index 00000000000..1971f9651bf
--- /dev/null
+++ b/lib/libcurses/lib_raw.c
@@ -0,0 +1,322 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+/*
+ * raw.c
+ *
+ * Routines:
+ * raw()
+ * echo()
+ * nl()
+ * cbreak()
+ * noraw()
+ * noecho()
+ * nonl()
+ * nocbreak()
+ * qiflush()
+ * noqiflush()
+ * intrflush()
+ *
+ */
+
+#include "curses.priv.h"
+#include "term.h" /* cur_term */
+
+/*
+ * COOKED_INPUT defines the collection of input mode bits to be
+ * cleared when entering raw mode, then re-set by noraw().
+ *
+ * We used to clear ISTRIP and INPCK when going to raw mode. Keith
+ * Bostic says that's wrong, because those are hardware bits that the
+ * user has to get right in his/her initial environment -- he says
+ * curses can't do any good by clearing these, and may do harm. In
+ * 1995's world of 8N1 connections over error-correcting modems, all
+ * the parity-check stuff is pretty nearly irrelevant anyway.
+ *
+ * What's supposed to happen when noraw() executes has never been very
+ * well-defined. Yes, it should reset ISIG/ICANON/OPOST (historical
+ * practice is for it to attempt to take the driver back to cooked
+ * mode, rather going to some half-baked cbreak-like intermediate
+ * level).
+ *
+ * We make a design choice here to turn off CR/LF translation a la BSD
+ * when raw() is enabled, on the theory that a programmer requesting
+ * raw() ideally wants an 8-bit data stream that's been messed with as
+ * little as possible. The man pages document this.
+ *
+ * We originally opted for the simplest way to handle noraw(); just set all
+ * the flags we cleared. Unfortunately, having noraw() set IGNCR
+ * turned out to be too painful. So raw() now clears the COOKED_INPUT
+ * flags, but also clears (ICRNL|INLCR|IGNCR) which noraw() doesn't
+ * restore.
+ *
+ * Unfortunately, this means noraw() may still force some COOKED_INPUT
+ * flags on that the user had initially cleared via stty. It'll all
+ * come out in the wash when endwin() restores the user's original
+ * input bits (we hope...)
+ *
+ */
+#define COOKED_INPUT (IXON|IGNBRK|BRKINT|PARMRK)
+
+int raw(void)
+{
+ T(("raw() called"));
+
+ SP->_raw = TRUE;
+ SP->_cbreak = TRUE;
+
+#ifdef TERMIOS
+ cur_term->Nttyb.c_lflag &= ~(ICANON|ISIG|IEXTEN);
+ cur_term->Nttyb.c_iflag &= ~(COOKED_INPUT|ICRNL|INLCR|IGNCR);
+ cur_term->Nttyb.c_oflag &= ~(OPOST);
+ cur_term->Nttyb.c_cc[VMIN] = 1;
+ cur_term->Nttyb.c_cc[VTIME] = 0;
+ if((tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Nttyb)) == -1)
+ return ERR;
+ else
+ return OK;
+#else
+ cur_term->Nttyb.sg_flags |= RAW;
+ stty(cur_term->Filedes, &cur_term->Nttyb);
+ return OK;
+#endif
+}
+
+int cbreak(void)
+{
+ T(("cbreak() called"));
+
+ SP->_cbreak = TRUE;
+
+#ifdef TERMIOS
+ cur_term->Nttyb.c_lflag &= ~ICANON;
+ cur_term->Nttyb.c_lflag |= ISIG;
+ cur_term->Nttyb.c_cc[VMIN] = 1;
+ cur_term->Nttyb.c_cc[VTIME] = 0;
+ if((tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Nttyb)) == -1)
+ return ERR;
+ else
+ return OK;
+#else
+ cur_term->Nttyb.sg_flags |= CBREAK;
+ stty(cur_term->Filedes, &cur_term->Nttyb);
+ return OK;
+#endif
+}
+
+int echo(void)
+{
+ T(("echo() called"));
+
+ SP->_echo = TRUE;
+
+#ifdef TERMIOS
+ cur_term->Nttyb.c_lflag |= ECHO;
+ if((tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Nttyb)) == -1)
+ return ERR;
+ else
+ return OK;
+#else
+ cur_term->Nttyb.sg_flags |= ECHO;
+ stty(cur_term->Filedes, &cur_term->Nttyb);
+ return OK;
+#endif
+}
+
+
+int nl(void)
+{
+ T(("nl() called"));
+
+ SP->_nl = TRUE;
+
+#ifdef TERMIOS
+ /* the code used to set IXON|IXOFF here, Ghod knows why... */
+ cur_term->Nttyb.c_iflag |= ICRNL;
+ cur_term->Nttyb.c_oflag |= OPOST|ONLCR;
+ if((tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Nttyb)) == -1)
+ return ERR;
+ else
+ return OK;
+#else
+ cur_term->Nttyb.sg_flags |= CRMOD;
+ stty(cur_term->Filedes, &cur_term->Nttyb);
+ return OK;
+#endif
+}
+
+
+int qiflush(void)
+{
+ T(("qiflush() called"));
+
+ /*
+ * Note: this implementation may be wrong. See the comment under
+ * intrflush().
+ */
+
+#ifdef TERMIOS
+ cur_term->Nttyb.c_lflag &= ~(NOFLSH);
+ if((tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Nttyb)) == -1)
+ return ERR;
+ else
+ return OK;
+#else
+ return ERR;
+#endif
+}
+
+
+int noraw(void)
+{
+ T(("noraw() called"));
+
+ SP->_raw = FALSE;
+ SP->_cbreak = FALSE;
+
+#ifdef TERMIOS
+ cur_term->Nttyb.c_lflag |= ISIG|ICANON|IEXTEN;
+ cur_term->Nttyb.c_iflag |= COOKED_INPUT;
+ cur_term->Nttyb.c_oflag |= OPOST;
+ if((tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Nttyb)) == -1)
+ return ERR;
+ else
+ return OK;
+#else
+ cur_term->Nttyb.sg_flags &= ~(RAW|CBREAK);
+ stty(cur_term->Filedes, &cur_term->Nttyb);
+ return OK;
+#endif
+
+}
+
+
+int nocbreak(void)
+{
+ T(("nocbreak() called"));
+
+ SP->_cbreak = 0;
+
+#ifdef TERMIOS
+ cur_term->Nttyb.c_lflag |= ICANON;
+ if((tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Nttyb)) == -1)
+ return ERR;
+ else
+ return OK;
+#else
+ cur_term->Nttyb.sg_flags &= ~CBREAK;
+ stty(cur_term->Filedes, &cur_term->Nttyb);
+ return OK;
+#endif
+}
+
+int noecho(void)
+{
+ T(("noecho() called"));
+
+ SP->_echo = FALSE;
+
+#ifdef TERMIOS
+ /*
+ * Turn off ECHONL to avoid having \n still be echoed when
+ * cooked mode is in effect (that is, ICANON is on).
+ */
+ cur_term->Nttyb.c_lflag &= ~(ECHO|ECHONL);
+ if((tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Nttyb)) == -1)
+ return ERR;
+ else
+ return OK;
+#else
+ cur_term->Nttyb.sg_flags &= ~ECHO;
+ stty(cur_term->Filedes, &cur_term->Nttyb);
+ return OK;
+#endif
+}
+
+
+int nonl(void)
+{
+ T(("nonl() called"));
+
+ SP->_nl = FALSE;
+
+#ifdef TERMIOS
+ cur_term->Nttyb.c_iflag &= ~ICRNL;
+ cur_term->Nttyb.c_oflag &= ~ONLCR;
+ if((tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Nttyb)) == -1)
+ return ERR;
+ else
+ return OK;
+#else
+ cur_term->Nttyb.sg_flags &= ~CRMOD;
+ stty(cur_term->Filedes, &cur_term->Nttyb);
+ return OK;
+#endif
+}
+
+int noqiflush(void)
+{
+ T(("noqiflush() called"));
+
+ /*
+ * Note: this implementation may be wrong. See the comment under
+ * intrflush().
+ */
+
+#ifdef TERMIOS
+ cur_term->Nttyb.c_lflag |= NOFLSH;
+ if((tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Nttyb)) == -1)
+ return ERR;
+ else
+ return OK;
+#else
+ return ERR;
+#endif
+}
+
+int intrflush(WINDOW *win, bool flag)
+{
+ T(("intrflush() called"));
+
+ /*
+ * This call does the same thing as the qiflush()/noqiflush()
+ * pair. We know for certain that SVr3 intrflush() tweaks the
+ * NOFLSH bit; on the other hand, the match (in the SVr4 man
+ * pages) between the language describing NOFLSH in termio(7)
+ * and the language describing qiflush()/noqiflush() in
+ * curs_inopts(3x) is too exact to be coincidence.
+ */
+
+#ifdef TERMIOS
+ if (flag)
+ cur_term->Nttyb.c_lflag &= ~(NOFLSH);
+ else
+ cur_term->Nttyb.c_lflag |= (NOFLSH);
+ if((tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Nttyb)) == -1)
+ return ERR;
+ else
+ return OK;
+#else
+ return ERR;
+#endif
+}
+
diff --git a/lib/libcurses/lib_refresh.c b/lib/libcurses/lib_refresh.c
new file mode 100644
index 00000000000..1dfa1a94355
--- /dev/null
+++ b/lib/libcurses/lib_refresh.c
@@ -0,0 +1,141 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+
+/*
+ * lib_refresh.c
+ *
+ * The routines wredrawln(), wrefresh() and wnoutrefresh().
+ *
+ */
+
+#include "curses.priv.h"
+
+int wredrawln(WINDOW *win, int beg, int num)
+{
+ T(("wredrawln(%p,%d,%d) called", win, beg, num));
+ touchline(win, beg, num);
+ wrefresh(win);
+ return OK;
+}
+
+int wrefresh(WINDOW *win)
+{
+ T(("wrefresh(%p) called", win));
+
+ if (win == curscr)
+ curscr->_clear = TRUE;
+ else
+ wnoutrefresh(win);
+ return(doupdate());
+}
+
+int wnoutrefresh(WINDOW *win)
+{
+short i, j;
+short begx = win->_begx;
+short begy = win->_begy;
+short m, n;
+bool wide;
+
+ T(("wnoutrefresh(%p) called", win));
+
+ /*
+ * If 'newscr' has a different background than the window that we're
+ * trying to refresh, we'll have to copy the whole thing.
+ */
+ if (win->_bkgd != newscr->_bkgd) {
+ touchwin(win);
+ newscr->_bkgd = win->_bkgd;
+ }
+
+ /* merge in change information from all subwindows of this window */
+ wsyncdown(win);
+
+ /*
+ * For pure efficiency, we'd want to transfer scrolling information
+ * from the window to newscr whenever the window is wide enough that
+ * its update will dominate the cost of the update for the horizontal
+ * band of newscr that it occupies. Unfortunately, this threshold
+ * tends to be complex to estimate, and in any case scrolling the
+ * whole band and rewriting the parts outside win's image would look
+ * really ugly. So. What we do is consider the window "wide" if it
+ * either (a) occupies the whole width of newscr, or (b) occupies
+ * all but at most one column on either vertical edge of the screen
+ * (this caters to fussy people who put boxes around full-screen
+ * windows). Note that changing this formula will not break any code,
+ * merely change the costs of various update cases.
+ */
+ wide = (begx <= 1 && win->_maxx >= (newscr->_maxx - 1));
+
+ win->_flags &= ~_HASMOVED;
+
+ /*
+ * Microtweaking alert! This double loop is one of the genuine
+ * hot spots in the code. Even gcc doesn't seem to do enough
+ * common-subexpression chunking to make it really tense,
+ * so we'll force the issue.
+ */
+ for (i = 0, m = begy; i <= win->_maxy && m <= newscr->_maxy; i++, m++) {
+ register struct ldat *nline = &newscr->_line[m];
+ register struct ldat *oline = &win->_line[i];
+
+ if (oline->firstchar != _NOCHANGE) {
+
+ for (j = oline->firstchar, n = j + begx; j <= oline->lastchar; j++, n++) {
+ if (oline->text[j] != nline->text[n]) {
+ nline->text[n] = oline->text[j];
+
+ if (nline->firstchar == _NOCHANGE)
+ nline->firstchar = nline->lastchar = n;
+ else if (n < nline->firstchar)
+ nline->firstchar = n;
+ else if (n > nline->lastchar)
+ nline->lastchar = n;
+ }
+ }
+
+ }
+
+ if (wide) {
+ int oind = oline->oldindex;
+
+ nline->oldindex = (oind == _NEWINDEX) ? _NEWINDEX : begy + oind;
+ }
+
+ oline->firstchar = oline->lastchar = _NOCHANGE;
+ oline->oldindex = i;
+ }
+
+ if (win->_clear) {
+ win->_clear = FALSE;
+#if 0
+ newscr->_clear = TRUE;
+#endif
+ }
+
+ if (! win->_leaveok) {
+ newscr->_cury = win->_cury + win->_begy;
+ newscr->_curx = win->_curx + win->_begx;
+ }
+ return(OK);
+}
diff --git a/lib/libcurses/lib_resize.c b/lib/libcurses/lib_resize.c
new file mode 100644
index 00000000000..b1052f042d4
--- /dev/null
+++ b/lib/libcurses/lib_resize.c
@@ -0,0 +1,152 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/*
+ * Note: This code is not part of the SVr4/XSI Curses API!
+ */
+
+#include "curses.priv.h"
+#include <stdlib.h>
+
+int wresize(WINDOW *win, int new_lines, int new_cols)
+{
+ chtype blank = _nc_render(win, ' ', BLANK);
+ register int i, j;
+
+ T(("wresize(win=%p, lines=%d, cols=%d) called", win, new_lines, new_cols));
+
+ if (new_lines <= 0 || new_cols <= 0)
+ return ERR;
+
+ /* window height is different, must mess with the line vector */
+ if (new_lines != win->_maxy+1)
+ {
+ struct ldat *tp;
+
+ /* free old lines no longer used */
+ if (!(win->_flags & _SUBWIN))
+ for (i = new_lines + 1; i <= win->_maxy; i++)
+ free((char *)(win->_line[i].text));
+
+ /* resize the window line vector */
+ if (!(win->_line = realloc(win->_line, sizeof(struct ldat) * new_lines)))
+ return(ERR);
+
+ /* grab new lines for the window if needed */
+ for (tp=&win->_line[i=win->_maxy+1]; tp<&win->_line[new_lines]; i++,tp++)
+ {
+ if (win->_flags & _SUBWIN) /* set up alias pointers */
+ tp->text = &(win->_parent->_line[win->_pary+i].text[win->_parx]);
+ else /* allocate new lines if needed */
+ {
+ if (!(tp->text = (chtype *)malloc(sizeof(chtype) * new_cols)))
+ return(ERR);
+ for (j = 0; j < new_cols; j++)
+ tp->text[j] = blank;
+ }
+
+ tp->firstchar = 0;
+ tp->lastchar = new_cols;
+ tp->oldindex = i;
+ }
+
+ /*
+ * This is kind of nasty. We have to clip the scrolling region to
+ * within the new window size. We also have to assume that if the
+ * bottom of the scrolling region is the last line, the user wants
+ * that bottom to stick to the bottom of the resized window. The
+ * real problem here is that the API doesn't distinguish between
+ * resetting the scroll region to the entire window and setting it
+ * to an explicit scroll region that happens to include the whole
+ * window.
+ */
+ if (win->_regtop > new_lines - 1 || win->_regtop == win->_maxy)
+ win->_regtop = new_lines - 1;
+ if (win->_regbottom > new_lines - 1 || win->_regbottom == win->_maxy)
+ win->_regbottom = new_lines - 1;
+ }
+
+ /* window width is different, resize all old lines */
+ if (new_cols != win->_maxx+1)
+ for (i = 0; i < min(new_lines, win->_maxy+1); i++)
+ {
+ /* if not a subwindow, we have our own storage; resize each line */
+ if (!(win->_flags & _SUBWIN))
+ {
+ win->_line[i].text=realloc(win->_line[i].text,sizeof(chtype)*new_cols);
+ if (win->_line[i].text == (chtype *)NULL)
+ return(ERR);
+ }
+
+ if (new_cols > win->_maxx+1) /* window is growing horizontally */
+ {
+ if (win->_line[i].firstchar == _NOCHANGE)
+ win->_line[i].firstchar = win->_maxx+1;
+ win->_line[i].lastchar = new_cols;
+ for (j = win->_maxx+1; j < new_cols; j++) /* blank-fill ends */
+ win->_line[i].text[j] = blank;
+ }
+ else /* window is shrinking horizontally */
+ {
+ if (win->_line[i].firstchar > win->_maxx+1)
+ win->_line[i].firstchar = _NOCHANGE;
+ else if (win->_line[i].lastchar > new_cols)
+ win->_line[i].lastchar = new_cols;
+ }
+ }
+
+ /* clip the cursor position to within the new size */
+ if (win->_curx > new_cols - 1)
+ win->_curx = new_cols - 1;
+ if (win->_cury > new_lines - 1)
+ win->_cury = new_lines - 1;
+
+ /* whether this is a full-width or full-depth window may have changed */
+ win->_flags &=~ (_ENDLINE|_FULLWIN|_SCROLLWIN);
+ if (win->_begx + new_cols == screen_columns)
+ {
+ win->_flags |= _ENDLINE;
+
+ if (win->_begx == 0 && new_lines == screen_lines && win->_begy == 0)
+ win->_flags |= _FULLWIN;
+
+ if (win->_begy + new_lines == screen_lines)
+ win->_flags |= _SCROLLWIN;
+ }
+
+ /* right margin may have moved, set _NEED_WRAP properly */
+ if ((win->_flags & _NEED_WRAP) && win->_curx != new_cols - 1)
+ {
+ win->_curx++;
+ win->_flags &=~ _NEED_WRAP;
+ }
+ if (!(win->_flags & _NEED_WRAP) && win->_curx == new_cols)
+ {
+ win->_curx--;
+ win->_flags |= _NEED_WRAP;
+ }
+
+ /* finally, update size members */
+ win->_maxy = new_lines - 1;
+ win->_maxx = new_cols - 1;
+
+ return OK;
+}
diff --git a/lib/libcurses/lib_scanw.c b/lib/libcurses/lib_scanw.c
new file mode 100644
index 00000000000..02d1814ba63
--- /dev/null
+++ b/lib/libcurses/lib_scanw.c
@@ -0,0 +1,88 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+
+/*
+** lib_scanw.c
+**
+** The routines scanw(), wscanw() and friends.
+**
+*/
+
+#include "curses.priv.h"
+#include <stdio.h>
+
+#if !HAVE_VSSCANF
+extern int vsscanf(const char *str, const char *format, ...);
+#endif
+
+int vwscanw(WINDOW *win, const char *fmt, va_list argp)
+{
+char buf[BUFSIZ];
+
+ if (wgetstr(win, buf) == ERR)
+ return(ERR);
+
+ return(vsscanf(buf, fmt, argp));
+}
+
+int scanw(const char *fmt, ...)
+{
+va_list ap;
+
+ T(("scanw(\"%s\",...) called", fmt));
+
+ va_start(ap, fmt);
+ return(vwscanw(stdscr, fmt, ap));
+}
+
+int wscanw(WINDOW *win, const char *fmt, ...)
+{
+va_list ap;
+
+ T(("wscanw(%p,\"%s\",...) called", win, fmt));
+
+ va_start(ap, fmt);
+ return(vwscanw(win, fmt, ap));
+}
+
+
+
+int mvscanw(int y, int x, const char *fmt, ...)
+{
+va_list ap;
+
+ va_start(ap, fmt);
+ return(move(y, x) == OK ? vwscanw(stdscr, fmt, ap) : ERR);
+}
+
+
+
+int mvwscanw(WINDOW *win, int y, int x, const char *fmt, ...)
+{
+va_list ap;
+
+ va_start(ap, fmt);
+ return(wmove(win, y, x) == OK ? vwscanw(win, fmt, ap) : ERR);
+}
+
+
diff --git a/lib/libcurses/lib_screen.c b/lib/libcurses/lib_screen.c
new file mode 100644
index 00000000000..73b4e63b14e
--- /dev/null
+++ b/lib/libcurses/lib_screen.c
@@ -0,0 +1,171 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+#include "curses.priv.h"
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <time.h>
+#include "term.h" /* exit_ca_mode, non_rev_rmcup */
+
+static time_t dumptime;
+
+WINDOW *getwin(FILE *filep)
+{
+ WINDOW try, *nwin;
+ int n;
+
+ (void) fread(&try, sizeof(WINDOW), 1, filep);
+ if (ferror(filep))
+ return (WINDOW *)NULL;
+
+ if ((nwin = newwin(try._maxy+1, try._maxx+1, 0, 0)) == (WINDOW *)NULL)
+ return (WINDOW *)NULL;
+
+ /*
+ * We deliberately do not restore the _parx, _pary, or _parent
+ * fields, because the window hierarchy within which they
+ * made sense is probably gone.
+ */
+ nwin->_curx = try._curx;
+ nwin->_cury = try._cury;
+ nwin->_maxy = try._maxy;
+ nwin->_maxx = try._maxx;
+ nwin->_begy = try._begy;
+ nwin->_begx = try._begx;
+ nwin->_flags = try._flags;
+
+ nwin->_attrs = try._attrs;
+ nwin->_bkgd = try._bkgd;
+
+ nwin->_clear = try._clear;
+ nwin->_scroll = try._scroll;
+ nwin->_leaveok = try._leaveok;
+ nwin->_use_keypad = try._use_keypad;
+ nwin->_delay = try._delay;
+ nwin->_immed = try._immed;
+ nwin->_sync = try._sync;
+
+ nwin->_regtop = try._regtop;
+ nwin->_regbottom = try._regbottom;
+
+ for (n = 0; n < nwin->_maxy + 1; n++)
+ {
+ (void) fread(nwin->_line[n].text,
+ sizeof(chtype), (size_t)(nwin->_maxx + 1), filep);
+ if (ferror(filep))
+ {
+ delwin(nwin);
+ return((WINDOW *)NULL);
+ }
+ }
+ touchwin(nwin);
+
+ return nwin;
+}
+
+int putwin(WINDOW *win, FILE *filep)
+{
+ int n;
+
+ (void) fwrite(win, sizeof(WINDOW), 1, filep);
+ if (ferror(filep))
+ return ERR;
+
+ for (n = 0; n < win->_maxy + 1; n++)
+ {
+ (void) fwrite(win->_line[n].text,
+ sizeof(chtype), (size_t)(win->_maxx + 1), filep);
+ if (ferror(filep))
+ return(ERR);
+ }
+
+ return(OK);
+}
+
+int scr_restore(const char *file)
+{
+ FILE *fp;
+
+ if ((fp = fopen(file, "r")) == (FILE *)NULL)
+ return ERR;
+ else
+ {
+ delwin(newscr);
+ newscr = getwin(fp);
+ (void) fclose(fp);
+ return OK;
+ }
+}
+
+int scr_dump(const char *file)
+{
+ FILE *fp;
+
+ if ((fp = fopen(file, "w")) == (FILE *)NULL)
+ return ERR;
+ else
+ {
+ (void) putwin(newscr, fp);
+ (void) fclose(fp);
+ dumptime = time((time_t *)0);
+ return OK;
+ }
+}
+
+int scr_init(const char *file)
+{
+ FILE *fp;
+ struct stat stb;
+
+#ifdef exit_ca_mode
+ if (exit_ca_mode && non_rev_rmcup)
+ return(ERR);
+#endif /* exit_ca_mode */
+
+ if ((fp = fopen(file, "r")) == (FILE *)NULL)
+ return ERR;
+ else if (fstat(STDOUT_FILENO, &stb) || stb.st_mtime > dumptime)
+ return ERR;
+ else
+ {
+ delwin(curscr);
+ curscr = getwin(fp);
+ (void) fclose(fp);
+ return OK;
+ }
+}
+
+int scr_set(const char *file)
+{
+ if (scr_init(file) == ERR)
+ return(ERR);
+ else
+ {
+ delwin(newscr);
+ newscr = dupwin(curscr);
+ return(OK);
+ }
+}
+
+
diff --git a/lib/libcurses/lib_scroll.c b/lib/libcurses/lib_scroll.c
new file mode 100644
index 00000000000..d8350a38344
--- /dev/null
+++ b/lib/libcurses/lib_scroll.c
@@ -0,0 +1,110 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+
+/*
+** lib_scroll.c
+**
+** The routine wscrl(win, n).
+** positive n scroll the window up (ie. move lines down)
+** negative n scroll the window down (ie. move lines up)
+**
+*/
+
+#include "curses.priv.h"
+#include <stdlib.h>
+#include <string.h>
+
+void _nc_scroll_window(WINDOW *win, int const n, short const top, short const bottom)
+{
+int line, j;
+chtype blank = _nc_render(win, ' ', BLANK);
+
+ TR(TRACE_MOVE, ("_nc_scroll_window(%p, %d, %d, %d)", win, n, top,bottom));
+
+ /*
+ * This used to do a line-text pointer-shuffle instead of text copies.
+ * That (a) doesn't work when the window is derived and doesn't have
+ * its own storage, (b) doesn't save you a lot on modern machines
+ * anyway. Your typical memcpy implementations are coded in
+ * assembler using a tight BLT loop; for the size of copies we're
+ * talking here, the total execution time is dominated by the one-time
+ * setup cost. So there is no point in trying to be excessively
+ * clever -- esr.
+ */
+
+ /* shift n lines downwards */
+ if (n < 0) {
+ for (line = bottom; line >= top-n; line--) {
+ memcpy(win->_line[line].text,
+ win->_line[line+n].text,
+ (size_t)(sizeof(chtype) * (win->_maxx+1)));
+ win->_line[line].oldindex = win->_line[line+n].oldindex;
+ }
+ for (line = top; line < top-n; line++) {
+ for (j = 0; j <= win->_maxx; j ++)
+ win->_line[line].text[j] = blank;
+ win->_line[line].oldindex = _NEWINDEX;
+ win->_line[line].firstchar = 0;
+ win->_line[line].lastchar = win->_maxx;
+ }
+ }
+
+ /* shift n lines upwards */
+ if (n > 0) {
+ for (line = top; line <= bottom-n; line++) {
+ memcpy(win->_line[line].text,
+ win->_line[line+n].text,
+ (size_t)(sizeof(chtype) * (win->_maxx+1)));
+ win->_line[line].oldindex = win->_line[line+n].oldindex;
+ }
+ for (line = bottom; line > bottom-n; line--) {
+ for (j = 0; j <= win->_maxx; j ++)
+ win->_line[line].text[j] = blank;
+ win->_line[line].oldindex = _NEWINDEX;
+ win->_line[line].firstchar = 0;
+ win->_line[line].lastchar = win->_maxx;
+ }
+ }
+}
+
+int
+wscrl(WINDOW *win, int n)
+{
+ T(("wscrl(%p,%d) called", win, n));
+
+ if (! win->_scroll)
+ return ERR;
+
+ if (n == 0)
+ return OK;
+
+ if ((n > (win->_regbottom - win->_regtop)) ||
+ (-n > (win->_regbottom - win->_regtop)))
+ return ERR;
+
+ _nc_scroll_window(win, n, win->_regtop, win->_regbottom);
+ touchline(win, win->_regtop, (int)(win->_regbottom - win->_regtop + 1));
+
+ _nc_synchook(win);
+ return OK;
+}
diff --git a/lib/libcurses/lib_scrreg.c b/lib/libcurses/lib_scrreg.c
new file mode 100644
index 00000000000..6a741304dbe
--- /dev/null
+++ b/lib/libcurses/lib_scrreg.c
@@ -0,0 +1,47 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+
+/*
+** lib_scrreg.c
+**
+** The routine wsetscrreg().
+**
+*/
+
+#include "curses.priv.h"
+
+int wsetscrreg(WINDOW *win, int top, int bottom)
+{
+ T(("wsetscrreg(%p,%d,%d) called", win, top, bottom));
+
+ if (top >= 0 && top <= win->_maxy &&
+ bottom >= 0 && bottom <= win->_maxy &&
+ bottom > top)
+ {
+ win->_regtop = (short)top;
+ win->_regbottom = (short)bottom;
+
+ return(OK);
+ } else
+ return(ERR);
+}
diff --git a/lib/libcurses/lib_set_term.c b/lib/libcurses/lib_set_term.c
new file mode 100644
index 00000000000..6df38903072
--- /dev/null
+++ b/lib/libcurses/lib_set_term.c
@@ -0,0 +1,141 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+
+/*
+** lib_set_term.c
+**
+** The routine set_term().
+**
+*/
+
+#include "curses.priv.h"
+#include <stdlib.h>
+#include "term.h" /* cur_term */
+
+struct screen * set_term(struct screen *screen)
+{
+struct screen *oldSP;
+
+ T(("set_term(%p) called", screen));
+
+ oldSP = SP;
+ _nc_set_screen(screen);
+
+ cur_term = SP->_term;
+ curscr = SP->_curscr;
+ newscr = SP->_newscr;
+ stdscr = SP->_stdscr;
+
+ return(oldSP);
+}
+
+void delscreen(SCREEN *sp)
+{
+ free(sp);
+}
+
+struct ripoff_t
+{
+ int line;
+ int (*hook)(WINDOW *, int);
+}
+rippedoff[5], *rsp = rippedoff;
+
+int _nc_setupscreen(short slines, short const scolumns)
+/* OS-independent screen initializations */
+{
+int stolen, topstolen;
+
+ if (!_nc_alloc_screen())
+ return ERR;
+
+ SP->_term = cur_term;
+ SP->_lines = slines;
+ SP->_columns = scolumns;
+ SP->_cursrow = -1;
+ SP->_curscol = -1;
+ SP->_keytry = UNINITIALISED;
+ SP->_nl = TRUE;
+ SP->_raw = FALSE;
+ SP->_cbreak = FALSE;
+ SP->_echo = TRUE;
+ SP->_fifohead = -1;
+ SP->_fifotail = 0;
+ SP->_fifopeek = 0;
+ SP->_endwin = TRUE;
+ SP->_ofp = stdout; /* (may be overridden later) */
+ SP->_coloron = 0;
+
+ init_acs();
+
+ T(("creating newscr"));
+ if ((newscr = newwin(slines, scolumns, 0, 0)) == (WINDOW *)NULL)
+ return ERR;
+
+ T(("creating curscr"));
+ if ((curscr = newwin(slines, scolumns, 0, 0)) == (WINDOW *)NULL)
+ return ERR;
+
+ SP->_newscr = newscr;
+ SP->_curscr = curscr;
+
+ newscr->_clear = TRUE;
+ curscr->_clear = FALSE;
+
+ stolen = topstolen = 0;
+ for (rsp = rippedoff; rsp->line; rsp++) {
+ if (rsp->hook)
+ if (rsp->line < 0)
+ rsp->hook(newwin(1,scolumns, slines-1,0), scolumns);
+ else
+ rsp->hook(newwin(1,scolumns, topstolen++,0), scolumns);
+ --slines;
+ stolen++;
+ }
+
+ T(("creating stdscr"));
+ if ((stdscr = newwin(LINES = slines, scolumns, topstolen, 0)) == NULL)
+ return ERR;
+ SP->_stdscr = stdscr;
+
+ def_shell_mode();
+ def_prog_mode();
+
+ return OK;
+}
+
+int
+ripoffline(int line, int (*init)(WINDOW *, int))
+{
+ if (line == 0)
+ return(OK);
+
+ if (rsp >= rippedoff + sizeof(rippedoff)/sizeof(rippedoff[0]))
+ return(ERR);
+
+ rsp->line = line;
+ rsp->hook = init;
+ rsp++;
+
+ return(OK);
+}
diff --git a/lib/libcurses/lib_slk.c b/lib/libcurses/lib_slk.c
new file mode 100644
index 00000000000..973a3ab6ae3
--- /dev/null
+++ b/lib/libcurses/lib_slk.c
@@ -0,0 +1,328 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/*
+ * lib_slk.c
+ * Soft key routines.
+ */
+
+#include "curses.priv.h"
+#include <string.h>
+#include <stdlib.h>
+#include "term.h" /* num_labels, label_*, plab_norm */
+
+#define MAX_SKEY 8 /* count of soft keys */
+#define MAX_SKEY_LEN 8 /* max length of soft key text */
+
+/*
+ * We'd like to move these into the screen context structure, but cannot,
+ * because slk_init() is called before initscr()/newterm().
+ */
+int _slk_init; /* TRUE if slk_init() called */
+
+static int _slk_format; /* format specified in slk_init() */
+static chtype _slk_attr = A_STANDOUT; /* soft label attribute */
+static int maxlab; /* number of labels */
+static int maxlen; /* maximum length of label */
+
+/*
+ * Fetch the label text.
+ */
+
+char *
+slk_label(int n)
+{
+ T(("slk_label(%d)", n));
+
+ if (SP->_slk == NULL || n < 1 || n > MAX_SKEY)
+ return NULL;
+ return(SP->_slk->ent[n-1].text);
+}
+
+/*
+ * Write the soft labels to the soft-key window.
+ */
+
+static void
+slk_intern_refresh(SLK *slk)
+{
+int i;
+ for (i = 0; i < MAX_SKEY; i++) {
+ if (slk->dirty || slk->ent[i].dirty) {
+ if (slk->ent[i].visible) {
+#ifdef num_labels
+ if (num_labels > 0)
+ {
+ TPUTS_TRACE("plab_norm");
+ putp(tparm(plab_norm, i, slk->win,slk->ent[i].form_text));
+ }
+ else
+#endif /* num_labels */
+ {
+ wmove(slk->win,0,slk->ent[i].x);
+ wattrset(slk->win,_slk_attr);
+ waddstr(slk->win,slk->ent[i].form_text);
+ wattrset(slk->win,A_NORMAL);
+ }
+ }
+ slk->ent[i].dirty = FALSE;
+ }
+ }
+ slk->dirty = FALSE;
+
+#ifdef num_labels
+ if (num_labels > 0)
+ if (slk->hidden)
+ {
+ TPUTS_TRACE("label_off");
+ putp(label_off);
+ }
+ else
+ {
+ TPUTS_TRACE("label_on");
+ putp(label_on);
+ }
+#endif /* num_labels */
+}
+
+/*
+ * Refresh the soft labels.
+ */
+
+int
+slk_noutrefresh(void)
+{
+ T(("slk_noutrefresh()"));
+
+ if (SP->_slk == NULL)
+ return(ERR);
+ if (SP->_slk->hidden)
+ return(OK);
+ slk_intern_refresh(SP->_slk);
+ return(wnoutrefresh(SP->_slk->win));
+}
+
+/*
+ * Refresh the soft labels.
+ */
+
+int
+slk_refresh(void)
+{
+ T(("slk_refresh()"));
+
+ if (SP->_slk == NULL)
+ return(ERR);
+ if (SP->_slk->hidden)
+ return(OK);
+ slk_intern_refresh(SP->_slk);
+ return(wrefresh(SP->_slk->win));
+}
+
+/*
+ * Restore the soft labels on the screen.
+ */
+
+int
+slk_restore(void)
+{
+ T(("slk_restore()"));
+
+ if (SP->_slk == NULL)
+ return(ERR);
+ SP->_slk->hidden = FALSE;
+ SP->_slk->dirty = TRUE;
+ return slk_refresh();
+}
+
+/*
+ * Set soft label text.
+ */
+
+int
+slk_set(int i, const char *astr, int format)
+{
+SLK *slk = SP->_slk;
+size_t len;
+const char *str = astr;
+
+ T(("slk_set(%d, \"%s\", %d)", i, str, format));
+
+ if (slk == NULL || i < 1 || i > maxlab || format < 0 || format > 2)
+ return(ERR);
+ if (str == NULL)
+ str = "";
+ --i;
+ (void) strncpy(slk->ent[i].text, str, (unsigned)maxlen);
+ memset(slk->ent[i].form_text,' ', (unsigned)maxlen);
+ slk->ent[i].text[maxlen] = 0;
+ slk->ent[i].form_text[maxlen] = 0;
+ len = strlen(slk->ent[i].text);
+
+ switch(format) {
+ case 0: /* left-justified */
+ memcpy(slk->ent[i].form_text,
+ slk->ent[i].text,
+ len);
+ break;
+ case 1: /* centered */
+ memcpy(slk->ent[i].form_text+(MAX_SKEY_LEN-len)/2,
+ slk->ent[i].text,
+ len);
+ break;
+ case 2: /* right-justified */
+ memcpy(slk->ent[i].form_text+MAX_SKEY_LEN-len,
+ slk->ent[i].text,
+ len);
+ break;
+ }
+ slk->ent[i].dirty = TRUE;
+ return(OK);
+}
+
+/*
+ * Force the code to believe that the soft keys have been changed.
+ */
+
+int
+slk_touch(void)
+{
+ T(("slk_touch()"));
+
+ if (SP->_slk == NULL)
+ return(ERR);
+ SP->_slk->dirty = TRUE;
+ return(OK);
+}
+
+/*
+ * Remove soft labels from the screen.
+ */
+
+int
+slk_clear(void)
+{
+ T(("slk_clear()"));
+
+ if (SP->_slk == NULL)
+ return(ERR);
+ SP->_slk->hidden = TRUE;
+ werase(SP->_slk->win);
+ return wrefresh(SP->_slk->win);
+}
+
+/*
+ * Initialize soft labels.
+ * Called from newterm()
+ */
+
+int
+slk_initialize(WINDOW *stwin, int cols)
+{
+SLK *slk;
+int i, x;
+
+ T(("slk_initialize()"));
+
+ if ((SP->_slk = slk = (SLK*) calloc(1,sizeof(SLK))) == NULL)
+ return(OK);
+
+#ifdef num_labels
+ maxlab = (num_labels > 0) ? num_labels : MAX_SKEY;
+ maxlen = (num_labels > 0) ? label_width * label_height : MAX_SKEY_LEN;
+#else
+ maxlab = MAX_SKEY;
+ maxlen = MAX_SKEY_LEN;
+#endif /* num_labels */
+
+ for (i = 0; i < MAX_SKEY; i++) {
+ memset(slk->ent[i].form_text, ' ', (unsigned)maxlen);
+ slk->ent[i].visible = i < maxlab;
+ }
+ if (_slk_format == 1) { /* 4-4 */
+ int gap = cols - (MAX_SKEY * MAX_SKEY_LEN) - 6;
+
+ if (gap < 1)
+ gap = 1;
+ for (i = x = 0; i < MAX_SKEY; i++) {
+ slk->ent[i].x = x;
+ x += MAX_SKEY_LEN;
+ x += (i == 3) ? gap : 1;
+ }
+ }
+ else { /* 0 -> 3-2-3 */
+ int gap = (cols - (MAX_SKEY * MAX_SKEY_LEN) - 5) / 2;
+
+ if (gap < 1)
+ gap = 1;
+ for (i = x = 0; i < MAX_SKEY; i++) {
+ slk->ent[i].x = x;
+ x += MAX_SKEY_LEN;
+ x += (i == 2 || i == 4) ? gap : 1;
+ }
+ }
+ slk->dirty = TRUE;
+ if ((slk->win = stwin) == NULL)
+ {
+ free(slk);
+ return(ERR);
+ }
+
+ return(OK);
+}
+
+/*
+ * Initialize soft labels. Called by the user before initscr().
+ */
+
+int
+slk_init(int format)
+{
+ if (format < 0 || format > 1)
+ return(ERR);
+ _slk_format = format;
+ _slk_init = TRUE;
+ return(OK);
+}
+
+/* Functions to manipulate the soft-label attribute */
+
+int
+slk_attrset(attr_t attr)
+{
+ _slk_attr = attr;
+ return(OK);
+}
+
+int
+slk_attron(attr_t attr)
+{
+ _slk_attr |= attr;
+ return(OK);
+}
+
+int
+slk_attroff(attr_t attr)
+{
+ _slk_attr &=~ attr;
+ return(OK);
+}
+
diff --git a/lib/libcurses/lib_touch.c b/lib/libcurses/lib_touch.c
new file mode 100644
index 00000000000..b2b29ac5859
--- /dev/null
+++ b/lib/libcurses/lib_touch.c
@@ -0,0 +1,64 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/*
+** lib_touch.c
+**
+** The routines untouchwin(),
+** wtouchln(),
+** is_linetouched()
+** is_wintouched().
+**
+*/
+
+#include "curses.priv.h"
+
+int is_linetouched(WINDOW *win, int line)
+{
+ if (line > win->_maxy || line < 0)
+ return ERR;
+ if (win->_line[line].firstchar != _NOCHANGE) return TRUE;
+ return FALSE;
+}
+
+int is_wintouched(WINDOW *win)
+{
+int i;
+
+ for (i = 0; i <= win->_maxy; i++)
+ if (win->_line[i].firstchar != _NOCHANGE)
+ return TRUE;
+ return FALSE;
+}
+
+int wtouchln(WINDOW *win, int y, int n, int changed)
+{
+int i;
+
+ T(("wtouchln(%p,%d,%d,%d)", win, y, n, changed));
+
+ for (i = y; i < y+n; i++) {
+ win->_line[i].firstchar = changed ? 0 : _NOCHANGE;
+ win->_line[i].lastchar = changed ? win->_maxx : _NOCHANGE;
+ }
+ return OK;
+}
+
diff --git a/lib/libcurses/lib_tstp.c b/lib/libcurses/lib_tstp.c
new file mode 100644
index 00000000000..73be68af51c
--- /dev/null
+++ b/lib/libcurses/lib_tstp.c
@@ -0,0 +1,252 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+/*
+** lib_tstp.c
+**
+** The routine _nc_signal_handler().
+**
+*/
+
+#include "curses.priv.h"
+
+#include <signal.h>
+#include <stdlib.h>
+
+#if HAVE_SIGACTION
+#if !HAVE_TYPE_SIGACTION
+typedef struct sigaction sigaction_t;
+#endif
+#else
+#include "SigAction.h"
+#endif
+
+#ifdef SVR4_ACTION
+#define _POSIX_SOURCE
+#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...
+ */
+
+#ifdef SIGTSTP
+static void tstp(int dummy)
+{
+ sigset_t mask, omask;
+ sigaction_t act, oact;
+
+ T(("tstp() called"));
+
+ /*
+ * The user may have changed the prog_mode tty bits, so save them.
+ */
+ 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);
+#ifdef SIGWINCH
+ (void)sigaddset(&mask, SIGWINCH);
+#endif
+ (void)sigprocmask(SIG_BLOCK, &mask, &omask);
+
+ /*
+ * 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);
+ (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 /* defined(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 (sig == SIGINT
+ || sig == SIGQUIT) {
+ sigaction_t act;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+ act.sa_handler = SIG_IGN;
+ if (sigaction(sig, &act, (sigaction_t *)0) == 0) {
+ endwin();
+ }
+ }
+ exit(1);
+}
+
+/*
+ * If the given signal is still in its default state, set it to the given
+ * handler.
+ */
+static int CatchIfDefault(int sig, sigaction_t *act)
+{
+ sigaction_t old_act;
+
+#ifdef SA_RESTART
+ act->sa_flags |= SA_RESTART;
+#endif /* SA_RESTART */
+ if (sigaction(sig, (sigaction_t *)0, &old_act) == 0
+ && old_act.sa_handler == SIG_DFL) {
+ (void)sigaction(sig, act, (sigaction_t *)0);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/*
+ * 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.
+ */
+void _nc_signal_handler(bool enable)
+{
+#ifdef SIGTSTP /* Xenix 2.x doesn't have this */
+static sigaction_t act, oact;
+static int ignore;
+
+ if (!ignore)
+ {
+ if (!enable)
+ {
+ act.sa_handler = SIG_IGN;
+ sigaction(SIGTSTP, &act, &oact);
+ }
+ else if (act.sa_handler)
+ {
+ sigaction(SIGTSTP, &oact, NULL);
+ }
+ else /*initialize */
+ {
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+#ifdef SA_RESTART
+ act.sa_flags |= SA_RESTART;
+#endif /* SA_RESTART */
+
+ act.sa_handler = cleanup;
+ CatchIfDefault(SIGINT, &act);
+ CatchIfDefault(SIGTERM, &act);
+
+ act.sa_handler = tstp;
+ if (!CatchIfDefault(SIGTSTP, &act))
+ ignore = TRUE;
+ }
+ }
+#else
+ if (enable)
+ {
+ static sigaction_t act;
+ act.sa_handler = cleanup;
+ CatchIfDefault(SIGINT, &act);
+ CatchIfDefault(SIGTERM, &act);
+ }
+#endif
+}
diff --git a/lib/libcurses/lib_twait.c b/lib/libcurses/lib_twait.c
new file mode 100644
index 00000000000..c9dee4e07be
--- /dev/null
+++ b/lib/libcurses/lib_twait.c
@@ -0,0 +1,118 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/*
+** lib_twait.c
+**
+** The routine _nc_timed_wait().
+**
+*/
+
+#include "curses.priv.h"
+
+#include <sys/types.h> /* some systems can't live without this */
+#include <string.h>
+
+#if HAVE_SYS_TIME_H && ! SYSTEM_LOOKS_LIKE_SCO
+#include <sys/time.h>
+#endif
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#if HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#endif
+
+/*
+ * We want to define GOOD_SELECT if the last argument of select(2) is
+ * modified to indicate time left. The code will deal gracefully with
+ * the other case, this is just an optimization to reduce the number
+ * of system calls per input event.
+ *
+ * In general, expect System-V-like UNIXes to have this behavior and BSD-like
+ * ones to not have it. Check your manual page. If it doesn't explicitly
+ * say the last argument is modified, assume it's not.
+ *
+ * (We'd really like configure to autodetect this, but writing a proper test
+ * turns out to be hard.)
+ */
+#if defined(linux)
+#define GOOD_SELECT
+#endif
+
+#if !HAVE_USLEEP
+int usleep(unsigned int usec)
+{
+struct timeval tval;
+
+ tval.tv_sec = usec / 1000000;
+ tval.tv_usec = usec % 1000000;
+ select(0, NULL, NULL, NULL, &tval);
+
+}
+#endif
+
+int _nc_timed_wait(int fd, int wait, int *timeleft)
+{
+int result;
+struct timeval ntimeout;
+static fd_set set;
+#if !defined(GOOD_SELECT) && HAVE_GETTIMEOFDAY
+struct timeval starttime, returntime;
+
+ gettimeofday(&starttime, NULL);
+#endif
+
+ FD_ZERO(&set);
+ FD_SET(fd, &set);
+
+ /* the units of wait are milliseconds */
+ ntimeout.tv_sec = wait / 1000;
+ ntimeout.tv_usec = (wait % 1000) * 1000;
+
+ T(("start twait: sec = %ld, usec = %ld", ntimeout.tv_sec, ntimeout.tv_usec));
+
+ result = select(fd+1, &set, NULL, NULL, &ntimeout);
+
+#if !defined(GOOD_SELECT) && HAVE_GETTIMEOFDAY
+ gettimeofday(&returntime, NULL);
+ ntimeout.tv_sec -= (returntime.tv_sec - starttime.tv_sec);
+ ntimeout.tv_usec -= (returntime.tv_usec - starttime.tv_usec);
+ if (ntimeout.tv_usec < 0 && ntimeout.tv_sec > 0) {
+ ntimeout.tv_sec--;
+ ntimeout.tv_usec += 1000000;
+ }
+ if (ntimeout.tv_sec < 0)
+ ntimeout.tv_sec = ntimeout.tv_usec = 0;
+#endif
+
+ /* return approximate time left on the ntimeout, in milliseconds */
+ if (timeleft)
+ *timeleft = (ntimeout.tv_sec * 1000) + (ntimeout.tv_usec / 1000);
+
+ T(("end twait: returned %d, sec = %ld, usec = %ld (%d msec)",
+ result, ntimeout.tv_sec, ntimeout.tv_usec,
+ timeleft ? *timeleft : -1));
+
+ return(result);
+}
diff --git a/lib/libcurses/lib_unctrl.c b/lib/libcurses/lib_unctrl.c
new file mode 100644
index 00000000000..2511ecfb0e8
--- /dev/null
+++ b/lib/libcurses/lib_unctrl.c
@@ -0,0 +1,47 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+
+#include <unctrl.h>
+
+char *unctrl(register chtype uch)
+{
+ static char buffer[3] = "^x";
+
+ if ((uch & 0x60) != 0 && uch != 0x7F) {
+ /*
+ * Printable character. Simply return the character as a one-character
+ * string.
+ */
+ buffer[1] = uch;
+ return &buffer[1];
+ }
+ /*
+ * It is a control character. DEL is handled specially (^?). All others
+ * use ^x notation, where x is the character code for the control character
+ * with 0x40 ORed in. (Control-A becomes ^A etc.).
+ */
+ buffer[1] = (uch == 0x7F ? '?' : (uch | 0x40));
+
+ return buffer;
+
+}
diff --git a/lib/libcurses/lib_vidattr.c b/lib/libcurses/lib_vidattr.c
new file mode 100644
index 00000000000..8c6ffc8a35a
--- /dev/null
+++ b/lib/libcurses/lib_vidattr.c
@@ -0,0 +1,275 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/*
+ * vidputs(newmode, outc)
+ *
+ * newmode is taken to be the logical 'or' of the symbols in curses.h
+ * representing graphic renditions. The teminal 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...
+ */
+
+#include "curses.priv.h"
+#include <string.h>
+#include "term.h"
+
+int vidputs(attr_t newmode, int (*outc)(int))
+{
+static attr_t previous_attr;
+attr_t turn_on, turn_off;
+
+ T(("vidputs(%lx) called %s", newmode, _traceattr(newmode)));
+
+ /* this allows us to go on whether or not newterm() has been called */
+ if (SP)
+ previous_attr = SP->_current_attr;
+
+ T(("previous attribute was %s", _traceattr(previous_attr)));
+
+ turn_off = (~newmode & previous_attr) & (chtype)(~A_COLOR);
+ turn_on = (newmode & ~previous_attr) & (chtype)(~A_COLOR);
+
+ if (newmode == previous_attr)
+ return OK;
+ if (newmode == A_NORMAL) {
+ if((previous_attr & A_ALTCHARSET) && exit_alt_charset_mode) {
+ TPUTS_TRACE("exit_alt_charset_mode");
+ tputs(exit_alt_charset_mode, 1, outc);
+ previous_attr &= ~A_ALTCHARSET;
+ }
+ if (previous_attr & A_COLOR) {
+ TPUTS_TRACE("orig_pair");
+ tputs(orig_pair, 1, outc);
+ }
+ if (previous_attr) {
+ TPUTS_TRACE("exit_attribute_mode");
+ tputs(exit_attribute_mode, 1, outc);
+ }
+
+ } 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);
+ /*
+ * Setting attributes in this way tends to unset the
+ * ones (such as color) that weren't specified.
+ */
+ turn_off |= A_COLOR;
+ }
+ } else {
+
+ T(("turning %s off", _traceattr(turn_off)));
+
+ if ((turn_off & A_ALTCHARSET) && exit_alt_charset_mode) {
+ TPUTS_TRACE("exit_alt_charset_mode");
+ tputs(exit_alt_charset_mode, 1, outc);
+ turn_off &= ~A_ALTCHARSET;
+ }
+
+ if ((turn_off & A_UNDERLINE) && exit_underline_mode) {
+ TPUTS_TRACE("exit_underline_mode");
+ tputs(exit_underline_mode, 1, outc);
+ turn_off &= ~A_UNDERLINE;
+ }
+
+ if ((turn_off & A_STANDOUT) && exit_standout_mode) {
+ TPUTS_TRACE("exit_standout_mode");
+ tputs(exit_standout_mode, 1, outc);
+ turn_off &= ~A_STANDOUT;
+ }
+
+ if (turn_off && exit_attribute_mode) {
+ TPUTS_TRACE("exit_attribute_mode");
+ tputs(exit_attribute_mode, 1, outc);
+ turn_on |= (newmode & (chtype)(~A_COLOR));
+ turn_off |= A_COLOR;
+ }
+
+ T(("turning %s on", _traceattr(turn_on)));
+
+ if ((turn_on & A_ALTCHARSET) && enter_alt_charset_mode) {
+ TPUTS_TRACE("enter_alt_charset_mode");
+ tputs(enter_alt_charset_mode, 1, outc);
+ }
+
+ if ((turn_on & A_BLINK) && enter_blink_mode) {
+ TPUTS_TRACE("enter_blink_mode");
+ tputs(enter_blink_mode, 1, outc);
+ }
+
+ if ((turn_on & A_BOLD) && enter_bold_mode) {
+ TPUTS_TRACE("enter_bold_mode");
+ tputs(enter_bold_mode, 1, outc);
+ }
+
+ if ((turn_on & A_DIM) && enter_dim_mode) {
+ TPUTS_TRACE("enter_dim_mode");
+ tputs(enter_dim_mode, 1, outc);
+ }
+
+ if ((turn_on & A_REVERSE) && enter_reverse_mode) {
+ TPUTS_TRACE("enter_reverse_mode");
+ tputs(enter_reverse_mode, 1, outc);
+ }
+
+ if ((turn_on & A_STANDOUT) && enter_standout_mode) {
+ TPUTS_TRACE("enter_standout_mode");
+ tputs(enter_standout_mode, 1, outc);
+ }
+
+ if ((turn_on & A_PROTECT) && enter_protected_mode) {
+ TPUTS_TRACE("enter_protected_mode");
+ tputs(enter_protected_mode, 1, outc);
+ }
+
+ if ((turn_on & A_INVIS) && enter_secure_mode) {
+ TPUTS_TRACE("enter_secure_mode");
+ tputs(enter_secure_mode, 1, outc);
+ }
+
+ if ((turn_on & A_UNDERLINE) && enter_underline_mode) {
+ TPUTS_TRACE("enter_underline_mode");
+ tputs(enter_underline_mode, 1, outc);
+ }
+
+ if ((turn_on & A_HORIZONTAL) && enter_horizontal_hl_mode) {
+ TPUTS_TRACE("enter_horizontal_hl_mode");
+ tputs(enter_horizontal_hl_mode, 1, outc);
+ }
+
+ if ((turn_on & A_LEFT) && enter_left_hl_mode) {
+ TPUTS_TRACE("enter_left_hl_mode");
+ tputs(enter_left_hl_mode, 1, outc);
+ }
+
+ if ((turn_on & A_LOW) && enter_low_hl_mode) {
+ TPUTS_TRACE("enter_low_hl_mode");
+ tputs(enter_low_hl_mode, 1, outc);
+ }
+
+ if ((turn_on & A_RIGHT) && enter_right_hl_mode) {
+ TPUTS_TRACE("enter_right_hl_mode");
+ tputs(enter_right_hl_mode, 1, outc);
+ }
+
+ if ((turn_on & A_TOP) && enter_top_hl_mode) {
+ TPUTS_TRACE("enter_top_hl_mode");
+ tputs(enter_top_hl_mode, 1, outc);
+ }
+
+ if ((turn_on & A_VERTICAL) && enter_vertical_hl_mode) {
+ TPUTS_TRACE("enter_vertical_hl_mode");
+ tputs(enter_vertical_hl_mode, 1, outc);
+ }
+ }
+
+ /* if there is no crrent screen, assume we *can* do color */
+ if (!SP || SP->_coloron) {
+ int pair = PAIR_NUMBER(newmode);
+ int current_pair = PAIR_NUMBER(previous_attr);
+
+ T(("old pair = %d -- new pair = %d", current_pair, pair));
+ if (pair != current_pair || (turn_off && pair)) {
+ _nc_do_color(pair, outc);
+ }
+ }
+
+ if (SP)
+ SP->_current_attr = newmode;
+
+ T(("vidputs finished"));
+ return OK;
+}
+
+#undef vidattr
+
+int vidattr(attr_t newmode)
+{
+
+ T(("vidattr(%lx) called", newmode));
+
+ return(vidputs(newmode, _nc_outch));
+}
+
+attr_t termattrs(void)
+{
+ int attrs = A_NORMAL;
+
+ 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;
+
+ return(attrs);
+}
+
diff --git a/lib/libcurses/lib_window.c b/lib/libcurses/lib_window.c
new file mode 100644
index 00000000000..3e9f58af704
--- /dev/null
+++ b/lib/libcurses/lib_window.c
@@ -0,0 +1,173 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/*
+** lib_window.c
+**
+**
+*/
+
+#include "curses.priv.h"
+#include <string.h>
+
+void _nc_synchook(WINDOW *win)
+/* hook to be called after each window change */
+{
+ if (win->_immed) wrefresh(win);
+ if (win->_sync) wsyncup(win);
+}
+
+int mvderwin(WINDOW *win, int y, int x)
+/* move a derived window */
+{
+ WINDOW *orig = win->_parent;
+ int i;
+
+ if (orig)
+ {
+ if (win->_parx==x && win->_pary==y)
+ return OK;
+ if (x<0 || y<0)
+ return ERR;
+ if ( (x+getmaxx(win) > getmaxx(orig)) ||
+ (y+getmaxy(win) > getmaxy(orig)) )
+ return ERR;
+ }
+ else
+ return ERR;
+ wsyncup(win);
+ win->_parx = x;
+ win->_pary = y;
+ for(i=0;i<getmaxy(win);i++)
+ win->_line[i].text = &(orig->_line[y++].text[x]);
+ return OK;
+}
+
+int syncok(WINDOW *win, bool bf)
+/* enable/disable automatic wsyncup() on each change to window */
+{
+ if (win) {
+ win->_sync = bf;
+ return(OK);
+ } else
+ return(ERR);
+}
+
+void wsyncup(WINDOW *win)
+/* mark changed every cell in win's ancestors that is changed in win */
+{
+ WINDOW *wp;
+
+ if (win->_parent)
+ for (wp = win; wp->_parent; wp = wp->_parent)
+ {
+ int i;
+ WINDOW *pp = wp->_parent;
+
+ for (i = 0; i <= wp->_maxy; i++)
+ {
+ if (pp->_line[wp->_pary + i].firstchar >= 0
+ && pp->_line[wp->_pary + i].firstchar < wp->_line[i].firstchar)
+ wp->_line[i].firstchar = pp->_line[wp->_pary + i].firstchar;
+ if (pp->_line[wp->_pary + i].lastchar > wp->_line[i].lastchar)
+ wp->_line[i].lastchar = pp->_line[wp->_pary + i].lastchar;
+ }
+ }
+}
+
+void wsyncdown(WINDOW *win)
+/* mark changed every cell in win that is changed in any of its ancestors */
+{
+ WINDOW *wp;
+
+ if (win->_parent)
+ for (wp = win; wp->_parent; wp = wp->_parent)
+ {
+ int i;
+ WINDOW *pp = wp->_parent;
+
+ for (i = 0; i <= wp->_maxy; i++)
+ {
+ if (wp->_line[i].firstchar >= 0
+ && wp->_line[i].firstchar < pp->_line[wp->_pary + i].firstchar)
+ pp->_line[wp->_pary + i].firstchar = wp->_line[i].firstchar;
+ if (wp->_line[i].lastchar > pp->_line[wp->_pary + i].lastchar)
+ pp->_line[wp->_pary + i].lastchar = wp->_line[i].lastchar;
+ }
+ }
+}
+
+void wcursyncup(WINDOW *win)
+/* sync the cursor in all derived windows to its value in the base window */
+{
+ WINDOW *wp;
+ for( wp = win; wp && wp->_parent; wp = wp->_parent ) {
+ wmove( wp->_parent, wp->_pary + wp->_cury, wp->_parx + wp->_curx );
+ }
+}
+
+WINDOW *dupwin(WINDOW *win)
+/* make an exact duplicate of the given window */
+{
+WINDOW *nwin;
+size_t linesize;
+int i;
+
+ T(("dupwin(%p) called", win));
+
+ if ((nwin = newwin(win->_maxy + 1, win->_maxx + 1, win->_begy, win->_begx)) == NULL)
+ return NULL;
+
+ nwin->_curx = win->_curx;
+ nwin->_cury = win->_cury;
+ nwin->_maxy = win->_maxy;
+ nwin->_maxx = win->_maxx;
+ nwin->_begy = win->_begy;
+ nwin->_begx = win->_begx;
+
+ nwin->_flags = win->_flags;
+ nwin->_attrs = win->_attrs;
+ nwin->_bkgd = win->_bkgd;
+
+ nwin->_clear = win->_clear;
+ nwin->_scroll = win->_scroll;
+ nwin->_leaveok = win->_leaveok;
+ nwin->_use_keypad = win->_use_keypad;
+ nwin->_delay = win->_delay;
+ nwin->_immed = win->_immed;
+ nwin->_sync = win->_sync;
+ nwin->_parx = win->_parx;
+ nwin->_pary = win->_pary;
+ nwin->_parent = win->_parent;
+
+ nwin->_regtop = win->_regtop;
+ nwin->_regbottom = win->_regbottom;
+
+ linesize = (win->_maxx + 1) * sizeof(chtype);
+ for (i = 0; i <= nwin->_maxy; i++) {
+ memcpy(nwin->_line[i].text, win->_line[i].text, linesize);
+ nwin->_line[i].firstchar = win->_line[i].firstchar;
+ nwin->_line[i].lastchar = win->_line[i].lastchar;
+ }
+
+ return nwin;
+}
+
diff --git a/lib/libcurses/longname.c b/lib/libcurses/longname.c
deleted file mode 100644
index fd54630f161..00000000000
--- a/lib/libcurses/longname.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 1981, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)longname.c 8.1 (Berkeley) 6/4/93";
-#endif /* not lint */
-
-/*
- * longname --
- * Fill in "def" with the long name of the terminal.
- */
-char *
-longname(bp, def)
- register char *bp, *def;
-{
- register char *cp;
-
- while (*bp && *bp != ':' && *bp != '|')
- bp++;
- if (*bp == '|') {
- for (cp = def, ++bp; *bp && *bp != ':' && *bp != '|';)
- *cp++ = *bp++;
- *cp = '\0';
- }
- return (def);
-}
diff --git a/lib/libcurses/move.c b/lib/libcurses/move.c
deleted file mode 100644
index 1e22fb0648d..00000000000
--- a/lib/libcurses/move.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)move.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include "curses.h"
-
-/*
- * wmove --
- * Moves the cursor to the given point.
- */
-int
-wmove(win, y, x)
- register WINDOW *win;
- register int y, x;
-{
-
-#ifdef DEBUG
- __CTRACE("wmove: (%d, %d)\n", y, x);
-#endif
- if (x < 0 || y < 0)
- return (ERR);
- if (x >= win->maxx || y >= win->maxy)
- return (ERR);
- win->curx = x;
- win->lines[win->cury]->flags &= ~__ISPASTEOL;
- win->cury = y;
- win->lines[y]->flags &= ~__ISPASTEOL;
- return (OK);
-}
diff --git a/lib/libcurses/mvwin.c b/lib/libcurses/mvwin.c
deleted file mode 100644
index 1471b27e186..00000000000
--- a/lib/libcurses/mvwin.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)mvwin.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include "curses.h"
-
-/*
- * mvwin --
- * Relocate the starting position of a window.
- */
-int
-mvwin(win, by, bx)
- register WINDOW *win;
- register int by, bx;
-{
- register WINDOW *orig;
- register int dy, dx;
-
- if (by + win->maxy > LINES || bx + win->maxx > COLS)
- return (ERR);
- dy = by - win->begy;
- dx = bx - win->begx;
- orig = win->orig;
- if (orig == NULL) {
- orig = win;
- do {
- win->begy += dy;
- win->begx += dx;
- __swflags(win);
- win = win->nextp;
- } while (win != orig);
- } else {
- if (by < orig->begy || win->maxy + dy > orig->maxy)
- return (ERR);
- if (bx < orig->begx || win->maxx + dx > orig->maxx)
- return (ERR);
- win->begy = by;
- win->begx = bx;
- __swflags(win);
- __set_subwin(orig, win);
- }
- __touchwin(win);
- return (OK);
-}
diff --git a/lib/libcurses/newwin.c b/lib/libcurses/newwin.c
deleted file mode 100644
index 8f09cbf7966..00000000000
--- a/lib/libcurses/newwin.c
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)newwin.c 8.3 (Berkeley) 7/27/94";
-#endif /* not lint */
-
-#include <stdlib.h>
-
-#include "curses.h"
-
-#undef nl /* Don't need it here, and it interferes. */
-
-static WINDOW *__makenew __P((int, int, int, int, int));
-
-void __set_subwin __P((WINDOW *, WINDOW *));
-
-/*
- * newwin --
- * Allocate space for and set up defaults for a new window.
- */
-WINDOW *
-newwin(nl, nc, by, bx)
- register int nl, nc, by, bx;
-{
- register WINDOW *win;
- register __LINE *lp;
- register int i, j;
- register __LDATA *sp;
-
- if (nl == 0)
- nl = LINES - by;
- if (nc == 0)
- nc = COLS - bx;
-
- if ((win = __makenew(nl, nc, by, bx, 0)) == NULL)
- return (NULL);
-
- win->nextp = win;
- win->ch_off = 0;
- win->orig = NULL;
-
-#ifdef DEBUG
- __CTRACE("newwin: win->ch_off = %d\n", win->ch_off);
-#endif
-
- for (i = 0; i < nl; i++) {
- lp = win->lines[i];
- lp->flags = 0;
- for (sp = lp->line, j = 0; j < nc; j++, sp++) {
- sp->ch = ' ';
- sp->attr = 0;
- }
- lp->hash = __hash((char *) lp->line, nc * __LDATASIZE);
- }
- return (win);
-}
-
-WINDOW *
-subwin(orig, nl, nc, by, bx)
- register WINDOW *orig;
- register int by, bx, nl, nc;
-{
- int i;
- __LINE *lp;
- register WINDOW *win;
-
- /* Make sure window fits inside the original one. */
-#ifdef DEBUG
- __CTRACE("subwin: (%0.2o, %d, %d, %d, %d)\n", orig, nl, nc, by, bx);
-#endif
- if (by < orig->begy || bx < orig->begx
- || by + nl > orig->maxy + orig->begy
- || bx + nc > orig->maxx + orig->begx)
- return (NULL);
- if (nl == 0)
- nl = orig->maxy + orig->begy - by;
- if (nc == 0)
- nc = orig->maxx + orig->begx - bx;
- if ((win = __makenew(nl, nc, by, bx, 1)) == NULL)
- return (NULL);
- win->nextp = orig->nextp;
- orig->nextp = win;
- win->orig = orig;
-
- /* Initialize flags here so that refresh can also use __set_subwin. */
- for (lp = win->lspace, i = 0; i < win->maxy; i++, lp++)
- lp->flags = 0;
- __set_subwin(orig, win);
- return (win);
-}
-
-/*
- * This code is shared with mvwin().
- */
-void
-__set_subwin(orig, win)
- register WINDOW *orig, *win;
-{
- int i;
- __LINE *lp, *olp;
-
- win->ch_off = win->begx - orig->begx;
- /* Point line pointers to line space. */
- for (lp = win->lspace, i = 0; i < win->maxy; i++, lp++) {
- win->lines[i] = lp;
- olp = orig->lines[i + win->begy];
- lp->line = &olp->line[win->begx];
- lp->firstchp = &olp->firstch;
- lp->lastchp = &olp->lastch;
- lp->hash = __hash((char *) lp->line, win->maxx * __LDATASIZE);
- }
-
-#ifdef DEBUG
- __CTRACE("__set_subwin: win->ch_off = %d\n", win->ch_off);
-#endif
-}
-
-/*
- * __makenew --
- * Set up a window buffer and returns a pointer to it.
- */
-static WINDOW *
-__makenew(nl, nc, by, bx, sub)
- register int by, bx, nl, nc;
- int sub;
-{
- register WINDOW *win;
- register __LINE *lp;
- int i;
-
-
-#ifdef DEBUG
- __CTRACE("makenew: (%d, %d, %d, %d)\n", nl, nc, by, bx);
-#endif
- if ((win = malloc(sizeof(*win))) == NULL)
- return (NULL);
-#ifdef DEBUG
- __CTRACE("makenew: nl = %d\n", nl);
-#endif
-
- /*
- * Set up line pointer array and line space.
- */
- if ((win->lines = malloc (nl * sizeof(__LINE *))) == NULL) {
- free(win);
- return NULL;
- }
- if ((win->lspace = malloc (nl * sizeof(__LINE))) == NULL) {
- free (win);
- free (win->lines);
- return NULL;
- }
-
- /* Don't allocate window and line space if it's a subwindow */
- if (!sub) {
- /*
- * Allocate window space in one chunk.
- */
- if ((win->wspace =
- malloc(nc * nl * sizeof(__LDATA))) == NULL) {
- free(win->lines);
- free(win->lspace);
- free(win);
- return NULL;
- }
-
- /*
- * Point line pointers to line space, and lines themselves into
- * window space.
- */
- for (lp = win->lspace, i = 0; i < nl; i++, lp++) {
- win->lines[i] = lp;
- lp->line = &win->wspace[i * nc];
- lp->firstchp = &lp->firstch;
- lp->lastchp = &lp->lastch;
- lp->firstch = 0;
- lp->lastch = 0;
- }
- }
-#ifdef DEBUG
- __CTRACE("makenew: nc = %d\n", nc);
-#endif
- win->cury = win->curx = 0;
- win->maxy = nl;
- win->maxx = nc;
-
- win->begy = by;
- win->begx = bx;
- win->flags = 0;
- __swflags(win);
-#ifdef DEBUG
- __CTRACE("makenew: win->flags = %0.2o\n", win->flags);
- __CTRACE("makenew: win->maxy = %d\n", win->maxy);
- __CTRACE("makenew: win->maxx = %d\n", win->maxx);
- __CTRACE("makenew: win->begy = %d\n", win->begy);
- __CTRACE("makenew: win->begx = %d\n", win->begx);
-#endif
- return (win);
-}
-
-void
-__swflags(win)
- register WINDOW *win;
-{
- win->flags &= ~(__ENDLINE | __FULLWIN | __SCROLLWIN | __LEAVEOK);
- if (win->begx + win->maxx == COLS) {
- win->flags |= __ENDLINE;
- if (win->begx == 0 && win->maxy == LINES && win->begy == 0)
- win->flags |= __FULLWIN;
- if (win->begy + win->maxy == LINES)
- win->flags |= __SCROLLWIN;
- }
-}
diff --git a/lib/libcurses/overlay.c b/lib/libcurses/overlay.c
deleted file mode 100644
index 9f35c79e3fb..00000000000
--- a/lib/libcurses/overlay.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)overlay.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include <ctype.h>
-
-#include "curses.h"
-
-/*
- * overlay --
- * Writes win1 on win2 non-destructively.
- */
-int
-overlay(win1, win2)
- register WINDOW *win1, *win2;
-{
-
- register int x, y, y1, y2, endy, endx, starty, startx;
- register __LDATA *sp, *end;
-
-#ifdef DEBUG
- __CTRACE("overlay: (%0.2o, %0.2o);\n", win1, win2);
-#endif
- starty = max(win1->begy, win2->begy);
- startx = max(win1->begx, win2->begx);
- endy = min(win1->maxy + win1->begy, win2->maxy + win2->begx);
- endx = min(win1->maxx + win1->begx, win2->maxx + win2->begx);
-#ifdef DEBUG
- __CTRACE("overlay: from (%d,%d) to (%d,%d)\n",
- starty, startx, endy, endx);
-#endif
- if (starty >= endy || startx >= endx)
- return (OK);
- y1 = starty - win1->begy;
- y2 = starty - win2->begy;
- for (y = starty; y < endy; y++, y1++, y2++) {
- end = &win1->lines[y1]->line[endx - win1->begx];
- x = startx - win2->begx;
- for (sp = &win1->lines[y1]->line[startx - win1->begx];
- sp < end; sp++) {
- if (!isspace(sp->ch)) {
- wmove(win2, y2, x);
- __waddch(win2, sp);
- }
- x++;
- }
- }
- return (OK);
-}
diff --git a/lib/libcurses/overwrite.c b/lib/libcurses/overwrite.c
deleted file mode 100644
index e2d91bd0a8c..00000000000
--- a/lib/libcurses/overwrite.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)overwrite.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include <ctype.h>
-#include <string.h>
-
-#include "curses.h"
-
-/*
- * overwrite --
- * Writes win1 on win2 destructively.
- */
-int
-overwrite(win1, win2)
- register WINDOW *win1, *win2;
-{
- register int x, y, endy, endx, starty, startx;
-
-#ifdef DEBUG
- __CTRACE("overwrite: (%0.2o, %0.2o);\n", win1, win2);
-#endif
- starty = max(win1->begy, win2->begy);
- startx = max(win1->begx, win2->begx);
- endy = min(win1->maxy + win1->begy, win2->maxy + win2->begx);
- endx = min(win1->maxx + win1->begx, win2->maxx + win2->begx);
- if (starty >= endy || startx >= endx)
- return (OK);
-#ifdef DEBUG
- __CTRACE("overwrite: from (%d, %d) to (%d, %d)\n",
- starty, startx, endy, endx);
-#endif
- x = endx - startx;
- for (y = starty; y < endy; y++) {
- (void)memcpy(
- &win2->lines[y - win2->begy]->line[startx - win2->begx],
- &win1->lines[y - win1->begy]->line[startx - win1->begx],
- x * __LDATASIZE);
- __touchline(win2, y, startx - win2->begx, endx - win2->begx,
- 0);
- }
- return (OK);
-}
diff --git a/lib/libcurses/printw.c b/lib/libcurses/printw.c
deleted file mode 100644
index ae6ea49dabf..00000000000
--- a/lib/libcurses/printw.c
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)printw.c 8.3 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include "curses.h"
-
-/*
- * printw and friends.
- *
- * These routines make nonportable assumptions about varargs if __STDC__
- * is not in effect.
- */
-
-static int __winwrite __P((void *, const char *, int));
-
-/*
- * printw --
- * Printf on the standard screen.
- */
-int
-#ifdef __STDC__
-printw(const char *fmt, ...)
-#else
-printw(fmt, va_alist)
- char *fmt;
- va_dcl
-#endif
-{
- va_list ap;
- int ret;
-
-#ifdef __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- ret = vwprintw(stdscr, fmt, ap);
- va_end(ap);
- return (ret);
-}
-
-/*
- * wprintw --
- * Printf on the given window.
- */
-int
-#ifdef __STDC__
-wprintw(WINDOW * win, const char *fmt, ...)
-#else
-wprintw(win, fmt, va_alist)
- WINDOW *win;
- char *fmt;
- va_dcl
-#endif
-{
- va_list ap;
- int ret;
-
-#ifdef __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- ret = vwprintw(win, fmt, ap);
- va_end(ap);
- return (ret);
-}
-
-/*
- * mvprintw, mvwprintw --
- * Implement the mvprintw commands. Due to the variable number of
- * arguments, they cannot be macros. Sigh....
- */
-int
-#ifdef __STDC__
-mvprintw(register int y, register int x, const char *fmt, ...)
-#else
-mvprintw(y, x, fmt, va_alist)
- register int y, x;
- char *fmt;
- va_dcl
-#endif
-{
- va_list ap;
- int ret;
-
-#ifdef __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- if (move(y, x) != OK)
- return (ERR);
- ret = vwprintw(stdscr, fmt, ap);
- va_end(ap);
- return (ret);
-}
-
-int
-#ifdef __STDC__
-mvwprintw(register WINDOW * win, register int y, register int x,
- const char *fmt, ...)
-#else
-mvwprintw(win, y, x, fmt, va_alist)
- register WINDOW *win;
- register int y, x;
- char *fmt;
- va_dcl
-#endif
-{
- va_list ap;
- int ret;
-
-#ifdef __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- if (wmove(win, y, x) != OK)
- return (ERR);
-
- ret = vwprintw(win, fmt, ap);
- va_end(ap);
- return (ret);
-}
-
-/*
- * Internal write-buffer-to-window function.
- */
-static int
-__winwrite(cookie, buf, n)
- void *cookie;
- register const char *buf;
- int n;
-{
- register WINDOW *win;
- register int c;
-
- for (c = n, win = cookie; --c >= 0;)
- if (waddch(win, *buf++) == ERR)
- return (-1);
- return (n);
-}
-
-/*
- * vwprintw --
- * This routine actually executes the printf and adds it to the window.
- */
-int
-vwprintw(win, fmt, ap)
- WINDOW *win;
- const char *fmt;
- va_list ap;
-{
- FILE *f;
-
- if ((f = funopen(win, NULL, __winwrite, NULL, NULL)) == NULL)
- return (ERR);
- (void)vfprintf(f, fmt, ap);
- return (fclose(f) ? ERR : OK);
-}
diff --git a/lib/libcurses/putchar.c b/lib/libcurses/putchar.c
deleted file mode 100644
index 2ed5bb4755c..00000000000
--- a/lib/libcurses/putchar.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)putchar.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include "curses.h"
-
-void
-__cputchar(ch)
- int ch;
-{
-
-#ifdef DEBUG
- __CTRACE("__cputchar: %s\n", unctrl(ch));
-#endif
- (void)putchar(ch);
-}
diff --git a/lib/libcurses/refresh.c b/lib/libcurses/refresh.c
deleted file mode 100644
index 3271bd9101e..00000000000
--- a/lib/libcurses/refresh.c
+++ /dev/null
@@ -1,827 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94";
-#endif /* not lint */
-
-#include <string.h>
-
-#include "curses.h"
-
-static int curwin;
-static short ly, lx;
-
-static void domvcur __P((int, int, int, int));
-static int makech __P((WINDOW *, int));
-static void quickch __P((WINDOW *));
-static void scrolln __P((WINDOW *, int, int, int, int, int));
-
-/*
- * wrefresh --
- * Make the current screen look like "win" over the area coverd by
- * win.
- */
-int
-wrefresh(win)
- register WINDOW *win;
-{
- register __LINE *wlp;
- register int retval;
- register short wy;
- int dnum;
-
- /* Initialize loop parameters. */
- ly = curscr->cury;
- lx = curscr->curx;
- wy = 0;
- curwin = (win == curscr);
-
- if (!curwin)
- for (wy = 0; wy < win->maxy; wy++) {
- wlp = win->lines[wy];
- if (wlp->flags & __ISDIRTY)
- wlp->hash = __hash((char *)wlp->line,
- win->maxx * __LDATASIZE);
- }
-
- if (win->flags & __CLEAROK || curscr->flags & __CLEAROK || curwin) {
- if ((win->flags & __FULLWIN) || curscr->flags & __CLEAROK) {
- tputs(CL, 0, __cputchar);
- ly = 0;
- lx = 0;
- if (!curwin) {
- curscr->flags &= ~__CLEAROK;
- curscr->cury = 0;
- curscr->curx = 0;
- werase(curscr);
- }
- __touchwin(win);
- }
- win->flags &= ~__CLEAROK;
- }
- if (!CA) {
- if (win->curx != 0)
- putchar('\n');
- if (!curwin)
- werase(curscr);
- }
-#ifdef DEBUG
- __CTRACE("wrefresh: (%0.2o): curwin = %d\n", win, curwin);
- __CTRACE("wrefresh: \tfirstch\tlastch\n");
-#endif
-
-#ifndef NOQCH
- if ((win->flags & __FULLWIN) && !curwin) {
- /*
- * Invoke quickch() only if more than a quarter of the lines
- * in the window are dirty.
- */
- for (wy = 0, dnum = 0; wy < win->maxy; wy++)
- if (win->lines[wy]->flags & (__ISDIRTY | __FORCEPAINT))
- dnum++;
- if (!__noqch && dnum > (int) win->maxy / 4)
- quickch(win);
- }
-#endif
-
-#ifdef DEBUG
-{ int i, j;
- __CTRACE("#####################################\n");
- for (i = 0; i < curscr->maxy; i++) {
- __CTRACE("C: %d:", i);
- __CTRACE(" 0x%x \n", curscr->lines[i]->hash);
- for (j = 0; j < curscr->maxx; j++)
- __CTRACE("%c",
- curscr->lines[i]->line[j].ch);
- __CTRACE("\n");
- for (j = 0; j < curscr->maxx; j++)
- __CTRACE("%x",
- curscr->lines[i]->line[j].attr);
- __CTRACE("\n");
- __CTRACE("W: %d:", i);
- __CTRACE(" 0x%x \n", win->lines[i]->hash);
- __CTRACE(" 0x%x ", win->lines[i]->flags);
- for (j = 0; j < win->maxx; j++)
- __CTRACE("%c",
- win->lines[i]->line[j].ch);
- __CTRACE("\n");
- for (j = 0; j < win->maxx; j++)
- __CTRACE("%x",
- win->lines[i]->line[j].attr);
- __CTRACE("\n");
- }
-}
-#endif /* DEBUG */
-
- for (wy = 0; wy < win->maxy; wy++) {
-#ifdef DEBUG
- __CTRACE("%d\t%d\t%d\n",
- wy, *win->lines[wy]->firstchp, *win->lines[wy]->lastchp);
-#endif
- if (!curwin)
- curscr->lines[wy]->hash = win->lines[wy]->hash;
- if (win->lines[wy]->flags & (__ISDIRTY | __FORCEPAINT)) {
- if (makech(win, wy) == ERR)
- return (ERR);
- else {
- if (*win->lines[wy]->firstchp >= win->ch_off)
- *win->lines[wy]->firstchp = win->maxx +
- win->ch_off;
- if (*win->lines[wy]->lastchp < win->maxx +
- win->ch_off)
- *win->lines[wy]->lastchp = win->ch_off;
- if (*win->lines[wy]->lastchp <
- *win->lines[wy]->firstchp) {
-#ifdef DEBUG
- __CTRACE("wrefresh: line %d notdirty \n", wy);
-#endif
- win->lines[wy]->flags &= ~__ISDIRTY;
- }
- }
-
- }
-#ifdef DEBUG
- __CTRACE("\t%d\t%d\n", *win->lines[wy]->firstchp,
- *win->lines[wy]->lastchp);
-#endif
- }
-
-#ifdef DEBUG
- __CTRACE("refresh: ly=%d, lx=%d\n", ly, lx);
-#endif
-
- if (win == curscr)
- domvcur(ly, lx, win->cury, win->curx);
- else {
- if (win->flags & __LEAVEOK) {
- curscr->cury = ly;
- curscr->curx = lx;
- ly -= win->begy;
- lx -= win->begx;
- if (ly >= 0 && ly < win->maxy && lx >= 0 &&
- lx < win->maxx) {
- win->cury = ly;
- win->curx = lx;
- } else
- win->cury = win->curx = 0;
- } else {
- domvcur(ly, lx, win->cury + win->begy,
- win->curx + win->begx);
- curscr->cury = win->cury + win->begy;
- curscr->curx = win->curx + win->begx;
- }
- }
- retval = OK;
-
- (void)fflush(stdout);
- return (retval);
-}
-
-/*
- * makech --
- * Make a change on the screen.
- */
-static int
-makech(win, wy)
- register WINDOW *win;
- int wy;
-{
- static __LDATA blank = {' ', 0};
- __LDATA *nsp, *csp, *cp, *cep;
- u_int force;
- int clsp, nlsp; /* Last space in lines. */
- int lch, wx, y;
- char *ce;
-
- /* Is the cursor still on the end of the last line? */
- if (wy > 0 && win->lines[wy - 1]->flags & __ISPASTEOL) {
- domvcur(ly, lx, ly + 1, 0);
- ly++;
- lx = 0;
- }
- wx = *win->lines[wy]->firstchp - win->ch_off;
- if (wx < 0)
- wx = 0;
- else if (wx >= win->maxx)
- return (OK);
- lch = *win->lines[wy]->lastchp - win->ch_off;
- if (lch < 0)
- return (OK);
- else if (lch >= (int) win->maxx)
- lch = win->maxx - 1;
- y = wy + win->begy;
-
- if (curwin)
- csp = &blank;
- else
- csp = &curscr->lines[wy + win->begy]->line[wx + win->begx];
-
- nsp = &win->lines[wy]->line[wx];
- force = win->lines[wy]->flags & __FORCEPAINT;
- win->lines[wy]->flags &= ~__FORCEPAINT;
- if (CE && !curwin) {
- for (cp = &win->lines[wy]->line[win->maxx - 1];
- cp->ch == ' ' && cp->attr == 0; cp--)
- if (cp <= win->lines[wy]->line)
- break;
- nlsp = cp - win->lines[wy]->line;
- }
- if (!curwin)
- ce = CE;
- else
- ce = NULL;
-
- if (force) {
- if (CM)
- tputs(tgoto(CM, lx, ly), 0, __cputchar);
- else {
- tputs(HO, 0, __cputchar);
- __mvcur(0, 0, ly, lx, 1);
- }
- }
-
- while (wx <= lch) {
- if (!force && memcmp(nsp, csp, sizeof(__LDATA)) == 0) {
- if (wx <= lch) {
- while (wx <= lch &&
- memcmp(nsp, csp, sizeof(__LDATA)) == 0) {
- nsp++;
- if (!curwin)
- ++csp;
- ++wx;
- }
- continue;
- }
- break;
- }
- domvcur(ly, lx, y, wx + win->begx);
-
-#ifdef DEBUG
- __CTRACE("makech: 1: wx = %d, ly= %d, lx = %d, newy = %d, newx = %d, force =%d\n",
- wx, ly, lx, y, wx + win->begx, force);
-#endif
- ly = y;
- lx = wx + win->begx;
- while ((force || memcmp(nsp, csp, sizeof(__LDATA)) != 0)
- && wx <= lch) {
-
- if (ce != NULL &&
- win->maxx + win->begx == curscr->maxx &&
- wx >= nlsp && nsp->ch == ' ' && nsp->attr == 0) {
- /* Check for clear to end-of-line. */
- cep = &curscr->lines[wy]->line[win->maxx - 1];
- while (cep->ch == ' ' && cep->attr == 0)
- if (cep-- <= csp)
- break;
- clsp = cep - curscr->lines[wy]->line -
- win->begx * __LDATASIZE;
-#ifdef DEBUG
- __CTRACE("makech: clsp = %d, nlsp = %d\n", clsp, nlsp);
-#endif
- if ((clsp - nlsp >= strlen(CE)
- && clsp < win->maxx * __LDATASIZE) ||
- wy == win->maxy - 1) {
- if (curscr->flags & __WSTANDOUT) {
- tputs(SE, 0, __cputchar);
- curscr->flags &= ~__WSTANDOUT;
- }
- tputs(CE, 0, __cputchar);
- lx = wx + win->begx;
- while (wx++ <= clsp) {
- csp->ch = ' ';
- csp->attr = 0;
- csp++;
- }
- return (OK);
- }
- ce = NULL;
- }
-
- /*
- * Enter/exit standout mode as appropriate.
- * XXX
- * Should use UC if SO/SE not available.
- */
- if (nsp->attr & __STANDOUT) {
- if (!(curscr->flags & __WSTANDOUT) &&
- SO != NULL && SE != NULL) {
- tputs(SO, 0, __cputchar);
- curscr->flags |= __WSTANDOUT;
- }
- } else
- if (curscr->flags & __WSTANDOUT &&
- SE != NULL) {
- tputs(SE, 0, __cputchar);
- curscr->flags &= ~__WSTANDOUT;
- }
-
- wx++;
- if (wx >= win->maxx && wy == win->maxy - 1 && !curwin)
- if (win->flags & __SCROLLOK) {
- if (curscr->flags & __WSTANDOUT
- && win->flags & __ENDLINE)
- if (!MS) {
- tputs(SE, 0,
- __cputchar);
- curscr->flags &=
- ~__WSTANDOUT;
- }
- if (!(win->flags & __SCROLLWIN)) {
- if (!curwin) {
- csp->attr = nsp->attr;
- putchar(csp->ch = nsp->ch);
- } else
- putchar(nsp->ch);
- }
- if (wx + win->begx < curscr->maxx) {
- domvcur(ly, wx + win->begx,
- win->begy + win->maxy - 1,
- win->begx + win->maxx - 1);
- }
- ly = win->begy + win->maxy - 1;
- lx = win->begx + win->maxx - 1;
- return (OK);
- }
- if (wx < win->maxx || wy < win->maxy - 1 ||
- !(win->flags & __SCROLLWIN)) {
- if (!curwin) {
- csp->attr = nsp->attr;
- putchar(csp->ch = nsp->ch);
- csp++;
- } else
- putchar(nsp->ch);
- }
-#ifdef DEBUG
- __CTRACE("makech: putchar(%c)\n", nsp->ch & 0177);
-#endif
- if (UC && (nsp->attr & __STANDOUT)) {
- putchar('\b');
- tputs(UC, 0, __cputchar);
- }
- nsp++;
-#ifdef DEBUG
- __CTRACE("makech: 2: wx = %d, lx = %d\n", wx, lx);
-#endif
- }
- if (lx == wx + win->begx) /* If no change. */
- break;
- lx = wx + win->begx;
- if (lx >= COLS && AM)
- lx = COLS - 1;
- else if (wx >= win->maxx) {
- domvcur(ly, lx, ly, win->maxx + win->begx - 1);
- lx = win->maxx + win->begx - 1;
- }
-
-#ifdef DEBUG
- __CTRACE("makech: 3: wx = %d, lx = %d\n", wx, lx);
-#endif
- }
-
- /* Don't leave the screen in standout mode. */
- if (curscr->flags & __WSTANDOUT) {
- tputs(SE, 0, __cputchar);
- curscr->flags &= ~__WSTANDOUT;
- }
- return (OK);
-}
-
-/*
- * domvcur --
- * Do a mvcur, leaving standout mode if necessary.
- */
-static void
-domvcur(oy, ox, ny, nx)
- int oy, ox, ny, nx;
-{
- if (curscr->flags & __WSTANDOUT && !MS) {
- tputs(SE, 0, __cputchar);
- curscr->flags &= ~__WSTANDOUT;
- }
-
- __mvcur(oy, ox, ny, nx, 1);
-}
-
-/*
- * Quickch() attempts to detect a pattern in the change of the window
- * in order to optimize the change, e.g., scroll n lines as opposed to
- * repainting the screen line by line.
- */
-
-static void
-quickch(win)
- WINDOW *win;
-{
-#define THRESH (int) win->maxy / 4
-
- register __LINE *clp, *tmp1, *tmp2;
- register int bsize, curs, curw, starts, startw, i, j;
- int n, target, cur_period, bot, top, sc_region;
- __LDATA buf[1024];
- u_int blank_hash;
-
- /*
- * Find how many lines from the top of the screen are unchanged.
- */
- for (top = 0; top < win->maxy; top++)
- if (win->lines[top]->flags & __FORCEPAINT ||
- win->lines[top]->hash != curscr->lines[top]->hash
- || memcmp(win->lines[top]->line,
- curscr->lines[top]->line,
- win->maxx * __LDATASIZE) != 0)
- break;
- else
- win->lines[top]->flags &= ~__ISDIRTY;
- /*
- * Find how many lines from bottom of screen are unchanged.
- */
- for (bot = win->maxy - 1; bot >= 0; bot--)
- if (win->lines[bot]->flags & __FORCEPAINT ||
- win->lines[bot]->hash != curscr->lines[bot]->hash
- || memcmp(win->lines[bot]->line,
- curscr->lines[bot]->line,
- win->maxx * __LDATASIZE) != 0)
- break;
- else
- win->lines[bot]->flags &= ~__ISDIRTY;
-
-#ifdef NO_JERKINESS
- /*
- * If we have a bottom unchanged region return. Scrolling the
- * bottom region up and then back down causes a screen jitter.
- * This will increase the number of characters sent to the screen
- * but it looks better.
- */
- if (bot < win->maxy - 1)
- return;
-#endif /* NO_JERKINESS */
-
- /*
- * Search for the largest block of text not changed.
- * Invariants of the loop:
- * - Startw is the index of the beginning of the examined block in win.
- * - Starts is the index of the beginning of the examined block in
- * curscr.
- * - Curs is the index of one past the end of the exmined block in win.
- * - Curw is the index of one past the end of the exmined block in
- * curscr.
- * - bsize is the current size of the examined block.
- */
- for (bsize = bot - top; bsize >= THRESH; bsize--) {
- for (startw = top; startw <= bot - bsize; startw++)
- for (starts = top; starts <= bot - bsize;
- starts++) {
- for (curw = startw, curs = starts;
- curs < starts + bsize; curw++, curs++)
- if (win->lines[curw]->flags &
- __FORCEPAINT ||
- (win->lines[curw]->hash !=
- curscr->lines[curs]->hash ||
- memcmp(win->lines[curw]->line,
- curscr->lines[curs]->line,
- win->maxx * __LDATASIZE) != 0))
- break;
- if (curs == starts + bsize)
- goto done;
- }
- }
- done:
- /* Did not find anything */
- if (bsize < THRESH)
- return;
-
-#ifdef DEBUG
- __CTRACE("quickch:bsize=%d,starts=%d,startw=%d,curw=%d,curs=%d,top=%d,bot=%d\n",
- bsize, starts, startw, curw, curs, top, bot);
-#endif
-
- /*
- * Make sure that there is no overlap between the bottom and top
- * regions and the middle scrolled block.
- */
- if (bot < curs)
- bot = curs - 1;
- if (top > starts)
- top = starts;
-
- n = startw - starts;
-
-#ifdef DEBUG
- __CTRACE("#####################################\n");
- for (i = 0; i < curscr->maxy; i++) {
- __CTRACE("C: %d:", i);
- __CTRACE(" 0x%x \n", curscr->lines[i]->hash);
- for (j = 0; j < curscr->maxx; j++)
- __CTRACE("%c",
- curscr->lines[i]->line[j].ch);
- __CTRACE("\n");
- for (j = 0; j < curscr->maxx; j++)
- __CTRACE("%x",
- curscr->lines[i]->line[j].attr);
- __CTRACE("\n");
- __CTRACE("W: %d:", i);
- __CTRACE(" 0x%x \n", win->lines[i]->hash);
- __CTRACE(" 0x%x ", win->lines[i]->flags);
- for (j = 0; j < win->maxx; j++)
- __CTRACE("%c",
- win->lines[i]->line[j].ch);
- __CTRACE("\n");
- for (j = 0; j < win->maxx; j++)
- __CTRACE("%x",
- win->lines[i]->line[j].attr);
- __CTRACE("\n");
- }
-#endif
-
- /* So we don't have to call __hash() each time */
- for (i = 0; i < win->maxx; i++) {
- buf[i].ch = ' ';
- buf[i].attr = 0;
- }
- blank_hash = __hash((char *) buf, win->maxx * __LDATASIZE);
-
- /*
- * Perform the rotation to maintain the consistency of curscr.
- * This is hairy since we are doing an *in place* rotation.
- * Invariants of the loop:
- * - I is the index of the current line.
- * - Target is the index of the target of line i.
- * - Tmp1 points to current line (i).
- * - Tmp2 and points to target line (target);
- * - Cur_period is the index of the end of the current period.
- * (see below).
- *
- * There are 2 major issues here that make this rotation non-trivial:
- * 1. Scrolling in a scrolling region bounded by the top
- * and bottom regions determined (whose size is sc_region).
- * 2. As a result of the use of the mod function, there may be a
- * period introduced, i.e., 2 maps to 4, 4 to 6, n-2 to 0, and
- * 0 to 2, which then causes all odd lines not to be rotated.
- * To remedy this, an index of the end ( = beginning) of the
- * current 'period' is kept, cur_period, and when it is reached,
- * the next period is started from cur_period + 1 which is
- * guaranteed not to have been reached since that would mean that
- * all records would have been reached. (think about it...).
- *
- * Lines in the rotation can have 3 attributes which are marked on the
- * line so that curscr is consistent with the visual screen.
- * 1. Not dirty -- lines inside the scrolled block, top region or
- * bottom region.
- * 2. Blank lines -- lines in the differential of the scrolling
- * region adjacent to top and bot regions
- * depending on scrolling direction.
- * 3. Dirty line -- all other lines are marked dirty.
- */
- sc_region = bot - top + 1;
- i = top;
- tmp1 = curscr->lines[top];
- cur_period = top;
- for (j = top; j <= bot; j++) {
- target = (i - top + n + sc_region) % sc_region + top;
- tmp2 = curscr->lines[target];
- curscr->lines[target] = tmp1;
- /* Mark block as clean and blank out scrolled lines. */
- clp = curscr->lines[target];
-#ifdef DEBUG
- __CTRACE("quickch: n=%d startw=%d curw=%d i = %d target=%d ",
- n, startw, curw, i, target);
-#endif
- if ((target >= startw && target < curw) || target < top
- || target > bot) {
-#ifdef DEBUG
- __CTRACE("-- notdirty");
-#endif
- win->lines[target]->flags &= ~__ISDIRTY;
- } else if ((n > 0 && target >= top && target < top + n) ||
- (n < 0 && target <= bot && target > bot + n)) {
- if (clp->hash != blank_hash || memcmp(clp->line,
- buf, win->maxx * __LDATASIZE) !=0) {
- (void)memcpy(clp->line, buf,
- win->maxx * __LDATASIZE);
-#ifdef DEBUG
- __CTRACE("-- blanked out: dirty");
-#endif
- clp->hash = blank_hash;
- __touchline(win, target, 0, win->maxx - 1, 0);
- } else {
- __touchline(win, target, 0, win->maxx - 1, 0);
-#ifdef DEBUG
- __CTRACE(" -- blank line already: dirty");
-#endif
- }
- } else {
-#ifdef DEBUG
- __CTRACE(" -- dirty");
-#endif
- __touchline(win, target, 0, win->maxx - 1, 0);
- }
-#ifdef DEBUG
- __CTRACE("\n");
-#endif
- if (target == cur_period) {
- i = target + 1;
- tmp1 = curscr->lines[i];
- cur_period = i;
- } else {
- tmp1 = tmp2;
- i = target;
- }
- }
-#ifdef DEBUG
- __CTRACE("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n");
- for (i = 0; i < curscr->maxy; i++) {
- __CTRACE("C: %d:", i);
- for (j = 0; j < curscr->maxx; j++)
- __CTRACE("%c",
- curscr->lines[i]->line[j].ch);
- __CTRACE("\n");
- __CTRACE("W: %d:", i);
- for (j = 0; j < win->maxx; j++)
- __CTRACE("%c", win->lines[i]->line[j].ch);
- __CTRACE("\n");
- }
-#endif
- if (n != 0) {
- WINDOW *wp;
- scrolln(win, starts, startw, curs, bot, top);
- /*
- * Need to repoint any subwindow lines to the rotated
- * line structured.
- */
- for (wp = win->nextp; wp != win; wp = wp->nextp)
- __set_subwin(win, wp);
- }
-}
-
-/*
- * scrolln --
- * Scroll n lines, where n is starts - startw.
- */
-static void
-scrolln(win, starts, startw, curs, bot, top)
- WINDOW *win;
- int starts, startw, curs, bot, top;
-{
- int i, oy, ox, n;
-
- oy = curscr->cury;
- ox = curscr->curx;
- n = starts - startw;
-
- /*
- * XXX
- * The initial tests that set __noqch don't let us reach here unless
- * we have either CS + HO + SF/sf/SR/sr, or AL + DL. SF/sf and SR/sr
- * scrolling can only shift the entire scrolling region, not just a
- * part of it, which means that the quickch() routine is going to be
- * sadly disappointed in us if we don't have CS as well.
- *
- * If CS, HO and SF/sf are set, can use the scrolling region. Because
- * the cursor position after CS is undefined, we need HO which gives us
- * the ability to move to somewhere without knowledge of the current
- * location of the cursor. Still call __mvcur() anyway, to update its
- * idea of where the cursor is.
- *
- * When the scrolling region has been set, the cursor has to be at the
- * last line of the region to make the scroll happen.
- *
- * Doing SF/SR or AL/DL appears faster on the screen than either sf/sr
- * or al/dl, and, some terminals have AL/DL, sf/sr, and CS, but not
- * SF/SR. So, if we're scrolling almost all of the screen, try and use
- * AL/DL, otherwise use the scrolling region. The "almost all" is a
- * shameless hack for vi.
- */
- if (n > 0) {
- if (CS != NULL && HO != NULL && (SF != NULL ||
- (AL == NULL || DL == NULL ||
- top > 3 || bot + 3 < win->maxy) && sf != NULL)) {
- tputs(__tscroll(CS, top, bot + 1), 0, __cputchar);
- __mvcur(oy, ox, 0, 0, 1);
- tputs(HO, 0, __cputchar);
- __mvcur(0, 0, bot, 0, 1);
- if (SF != NULL)
- tputs(__tscroll(SF, n, 0), 0, __cputchar);
- else
- for (i = 0; i < n; i++)
- tputs(sf, 0, __cputchar);
- tputs(__tscroll(CS, 0, win->maxy), 0, __cputchar);
- __mvcur(bot, 0, 0, 0, 1);
- tputs(HO, 0, __cputchar);
- __mvcur(0, 0, oy, ox, 1);
- return;
- }
-
- /* Scroll up the block. */
- if (SF != NULL && top == 0) {
- __mvcur(oy, ox, bot, 0, 1);
- tputs(__tscroll(SF, n, 0), 0, __cputchar);
- } else if (DL != NULL) {
- __mvcur(oy, ox, top, 0, 1);
- tputs(__tscroll(DL, n, 0), 0, __cputchar);
- } else if (dl != NULL) {
- __mvcur(oy, ox, top, 0, 1);
- for (i = 0; i < n; i++)
- tputs(dl, 0, __cputchar);
- } else if (sf != NULL && top == 0) {
- __mvcur(oy, ox, bot, 0, 1);
- for (i = 0; i < n; i++)
- tputs(sf, 0, __cputchar);
- } else
- abort();
-
- /* Push down the bottom region. */
- __mvcur(top, 0, bot - n + 1, 0, 1);
- if (AL != NULL)
- tputs(__tscroll(AL, n, 0), 0, __cputchar);
- else if (al != NULL)
- for (i = 0; i < n; i++)
- tputs(al, 0, __cputchar);
- else
- abort();
- __mvcur(bot - n + 1, 0, oy, ox, 1);
- } else {
- /*
- * !!!
- * n < 0
- *
- * If CS, HO and SR/sr are set, can use the scrolling region.
- * See the above comments for details.
- */
- if (CS != NULL && HO != NULL && (SR != NULL ||
- (AL == NULL || DL == NULL ||
- top > 3 || bot + 3 < win->maxy) && sr != NULL)) {
- tputs(__tscroll(CS, top, bot + 1), 0, __cputchar);
- __mvcur(oy, ox, 0, 0, 1);
- tputs(HO, 0, __cputchar);
- __mvcur(0, 0, top, 0, 1);
-
- if (SR != NULL)
- tputs(__tscroll(SR, -n, 0), 0, __cputchar);
- else
- for (i = n; i < 0; i++)
- tputs(sr, 0, __cputchar);
- tputs(__tscroll(CS, 0, win->maxy), 0, __cputchar);
- __mvcur(top, 0, 0, 0, 1);
- tputs(HO, 0, __cputchar);
- __mvcur(0, 0, oy, ox, 1);
- return;
- }
-
- /* Preserve the bottom lines. */
- __mvcur(oy, ox, bot + n + 1, 0, 1);
- if (SR != NULL && bot == win->maxy)
- tputs(__tscroll(SR, -n, 0), 0, __cputchar);
- else if (DL != NULL)
- tputs(__tscroll(DL, -n, 0), 0, __cputchar);
- else if (dl != NULL)
- for (i = n; i < 0; i++)
- tputs(dl, 0, __cputchar);
- else if (sr != NULL && bot == win->maxy)
- for (i = n; i < 0; i++)
- tputs(sr, 0, __cputchar);
- else
- abort();
-
- /* Scroll the block down. */
- __mvcur(bot + n + 1, 0, top, 0, 1);
- if (AL != NULL)
- tputs(__tscroll(AL, -n, 0), 0, __cputchar);
- else if (al != NULL)
- for (i = n; i < 0; i++)
- tputs(al, 0, __cputchar);
- else
- abort();
- __mvcur(top, 0, oy, ox, 1);
- }
-}
diff --git a/lib/libcurses/scanw.c b/lib/libcurses/scanw.c
deleted file mode 100644
index d8d79fd2355..00000000000
--- a/lib/libcurses/scanw.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)scanw.c 8.3 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-/*
- * scanw and friends.
- */
-
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include "curses.h"
-
-/*
- * scanw --
- * Implement a scanf on the standard screen.
- */
-int
-#ifdef __STDC__
-scanw(const char *fmt, ...)
-#else
-scanw(fmt, va_alist)
- char *fmt;
- va_dcl
-#endif
-{
- va_list ap;
- int ret;
-
-#ifdef __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- ret = vwscanw(stdscr, fmt, ap);
- va_end(ap);
- return (ret);
-}
-
-/*
- * wscanw --
- * Implements a scanf on the given window.
- */
-int
-#ifdef __STDC__
-wscanw(WINDOW *win, const char *fmt, ...)
-#else
-wscanw(win, fmt, va_alist)
- WINDOW *win;
- char *fmt;
- va_dcl
-#endif
-{
- va_list ap;
- int ret;
-
-#ifdef __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- ret = vwscanw(win, fmt, ap);
- va_end(ap);
- return (ret);
-}
-
-/*
- * mvscanw, mvwscanw --
- * Implement the mvscanw commands. Due to the variable number of
- * arguments, they cannot be macros. Another sigh....
- */
-int
-#ifdef __STDC__
-mvscanw(register int y, register int x, const char *fmt,...)
-#else
-mvscanw(y, x, fmt, va_alist)
- register int y, x;
- char *fmt;
- va_dcl
-#endif
-{
- va_list ap;
- int ret;
-
- if (move(y, x) != OK)
- return (ERR);
-#ifdef __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- ret = vwscanw(stdscr, fmt, ap);
- va_end(ap);
- return (ret);
-}
-
-int
-#ifdef __STDC__
-mvwscanw(register WINDOW * win, register int y, register int x,
- const char *fmt, ...)
-#else
-mvwscanw(win, y, x, fmt, va_alist)
- register WINDOW *win;
- register int y, x;
- char *fmt;
- va_dcl
-#endif
-{
- va_list ap;
- int ret;
-
- if (move(y, x) != OK)
- return (ERR);
-#ifdef __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- ret = vwscanw(win, fmt, ap);
- va_end(ap);
- return (ret);
-}
-
-/*
- * vwscanw --
- * This routine actually executes the scanf from the window.
- */
-int
-vwscanw(win, fmt, ap)
- WINDOW *win;
- const char *fmt;
- va_list ap;
-{
-
- char buf[1024];
-
- return (wgetstr(win, buf) == OK ?
- vsscanf(buf, fmt, ap) : ERR);
-}
diff --git a/lib/libcurses/scroll.c b/lib/libcurses/scroll.c
deleted file mode 100644
index 8aad91c0285..00000000000
--- a/lib/libcurses/scroll.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)scroll.c 8.3 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include "curses.h"
-
-/*
- * scroll --
- * Scroll the window up a line.
- */
-int
-scroll(win)
- register WINDOW *win;
-{
- register int oy, ox;
-
-#ifdef DEBUG
- __CTRACE("scroll: (%0.2o)\n", win);
-#endif
-
- if (!(win->flags & __SCROLLOK))
- return (ERR);
-
- getyx(win, oy, ox);
- wmove(win, 0, 0);
- wdeleteln(win);
- wmove(win, oy, ox);
-
- if (win == curscr) {
- putchar('\n');
- if (!NONL)
- win->curx = 0;
-#ifdef DEBUG
- __CTRACE("scroll: win == curscr\n");
-#endif
- }
- return (OK);
-}
diff --git a/lib/libcurses/setterm.c b/lib/libcurses/setterm.c
deleted file mode 100644
index 1d134903c11..00000000000
--- a/lib/libcurses/setterm.c
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)setterm.c 8.7 (Berkeley) 7/27/94";
-#endif /* not lint */
-
-#include <sys/ioctl.h> /* TIOCGWINSZ on old systems. */
-
-#include <stdlib.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "curses.h"
-
-static void zap __P((void));
-
-static char *sflags[] = {
- /* am bs da eo hc in mi ms */
- &AM, &BS, &DA, &EO, &HC, &IN, &MI, &MS,
- /* nc ns os ul xb xn xt xs xx */
- &NC, &NS, &OS, &UL, &XB, &XN, &XT, &XS, &XX
- };
-
-static char *_PC,
- **sstrs[] = {
- /* AL bc bt cd ce cl cm cr cs */
- &AL, &BC, &BT, &CD, &CE, &CL, &CM, &CR, &CS,
- /* dc DL dm do ed ei k0 k1 k2 */
- &DC, &DL, &DM, &DO, &ED, &EI, &K0, &K1, &K2,
- /* k3 k4 k5 k6 k7 k8 k9 ho ic */
- &K3, &K4, &K5, &K6, &K7, &K8, &K9, &HO, &IC,
- /* im ip kd ke kh kl kr ks ku */
- &IM, &IP, &KD, &KE, &KH, &KL, &KR, &KS, &KU,
- /* ll ma nd nl pc rc sc se SF */
- &LL, &MA, &ND, &NL, &_PC, &RC, &SC, &SE, &SF,
- /* so SR ta te ti uc ue up us */
- &SO, &SR, &TA, &TE, &TI, &UC, &UE, &UP, &US,
- /* vb vs ve al dl sf sr AL */
- &VB, &VS, &VE, &al, &dl, &sf, &sr, &AL_PARM,
- /* DL UP DO LE */
- &DL_PARM, &UP_PARM, &DOWN_PARM, &LEFT_PARM,
- /* RI */
- &RIGHT_PARM,
- };
-
-static char *aoftspace; /* Address of _tspace for relocation */
-static char tspace[2048]; /* Space for capability strings */
-
-char *ttytype;
-
-int
-setterm(type)
- register char *type;
-{
- static char genbuf[1024];
- static char __ttytype[1024];
- register int unknown;
- struct winsize win;
- char *p;
-
-#ifdef DEBUG
- __CTRACE("setterm: (\"%s\")\nLINES = %d, COLS = %d\n",
- type, LINES, COLS);
-#endif
- if (type[0] == '\0')
- type = "xx";
- unknown = 0;
- if (tgetent(genbuf, type) != 1) {
- unknown++;
- strcpy(genbuf, "xx|dumb:");
- }
-#ifdef DEBUG
- __CTRACE("setterm: tty = %s\n", type);
-#endif
-
- /* Try TIOCGWINSZ, and, if it fails, the termcap entry. */
- if (ioctl(STDERR_FILENO, TIOCGWINSZ, &win) != -1 &&
- win.ws_row != 0 && win.ws_col != 0) {
- LINES = win.ws_row;
- COLS = win.ws_col;
- } else {
- LINES = tgetnum("li");
- COLS = tgetnum("co");
- }
-
- /* POSIX 1003.2 requires that the environment override. */
- if ((p = getenv("LINES")) != NULL)
- LINES = strtol(p, NULL, 10);
- if ((p = getenv("COLUMNS")) != NULL)
- COLS = strtol(p, NULL, 10);
-
- /*
- * Want cols > 4, otherwise things will fail.
- */
- if (COLS <= 4)
- return (ERR);
-
-#ifdef DEBUG
- __CTRACE("setterm: LINES = %d, COLS = %d\n", LINES, COLS);
-#endif
- aoftspace = tspace;
- zap(); /* Get terminal description. */
-
- /* If we can't tab, we can't backtab, either. */
- if (!GT)
- BT = NULL;
-
- /*
- * Test for cursor motion capbility.
- *
- * XXX
- * This is truly stupid -- tgoto returns "OOPS" if it can't
- * do cursor motions.
- */
- if (tgoto(CM, 0, 0)[0] == 'O') {
- CA = 0;
- CM = 0;
- } else
- CA = 1;
-
- PC = _PC ? _PC[0] : 0;
- aoftspace = tspace;
- ttytype = longname(genbuf, __ttytype);
-
- /* If no scrolling commands, no quick change. */
- __noqch =
- (CS == NULL || HO == NULL ||
- SF == NULL && sf == NULL || SR == NULL && sr == NULL) &&
- (AL == NULL && al == NULL || DL == NULL && dl == NULL);
-
- return (unknown ? ERR : OK);
-}
-
-/*
- * zap --
- * Gets all the terminal flags from the termcap database.
- */
-static void
-zap()
-{
- register char *namp, ***sp;
- register char **fp;
- char tmp[3];
-#ifdef DEBUG
- register char *cp;
-#endif
- tmp[2] = '\0';
-
- namp = "ambsdaeohcinmimsncnsosulxbxnxtxsxx";
- fp = sflags;
- do {
- *tmp = *namp;
- *(tmp + 1) = *(namp + 1);
- *(*fp++) = tgetflag(tmp);
-#ifdef DEBUG
- __CTRACE("2.2s = %s\n", namp, *fp[-1] ? "TRUE" : "FALSE");
-#endif
- namp += 2;
-
- } while (*namp);
- namp = "ALbcbtcdceclcmcrcsdcDLdmdoedeik0k1k2k3k4k5k6k7k8k9hoicimipkdkekhklkrkskullmandnlpcrcscseSFsoSRtatetiucueupusvbvsvealdlsfsrALDLUPDOLERI";
- sp = sstrs;
- do {
- *tmp = *namp;
- *(tmp + 1) = *(namp + 1);
- *(*sp++) = tgetstr(tmp, &aoftspace);
-#ifdef DEBUG
- __CTRACE("2.2s = %s", namp, *sp[-1] == NULL ? "NULL\n" : "\"");
- if (*sp[-1] != NULL) {
- for (cp = *sp[-1]; *cp; cp++)
- __CTRACE("%s", unctrl(*cp));
- __CTRACE("\"\n");
- }
-#endif
- namp += 2;
- } while (*namp);
- if (XS)
- SO = SE = NULL;
- else {
- if (tgetnum("sg") > 0)
- SO = NULL;
- if (tgetnum("ug") > 0)
- US = NULL;
- if (!SO && US) {
- SO = US;
- SE = UE;
- }
- }
-}
-
-/*
- * getcap --
- * Return a capability from termcap.
- */
-char *
-getcap(name)
- char *name;
-{
- return (tgetstr(name, &aoftspace));
-}
diff --git a/lib/libcurses/shlib_version b/lib/libcurses/shlib_version
deleted file mode 100644
index c6e3f4d3fc0..00000000000
--- a/lib/libcurses/shlib_version
+++ /dev/null
@@ -1,2 +0,0 @@
-major=2
-minor=1
diff --git a/lib/libcurses/standout.c b/lib/libcurses/standout.c
deleted file mode 100644
index 8851d63d446..00000000000
--- a/lib/libcurses/standout.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)standout.c 8.3 (Berkeley) 8/10/94";
-#endif /* not lint */
-
-#include "curses.h"
-
-/*
- * wstandout
- * Enter standout mode.
- */
-int
-wstandout(win)
- WINDOW *win;
-{
- /*
- * If standout/standend strings, or can underline, set the
- * screen standout bit.
- */
- if (SO != NULL && SE != NULL || UC != NULL)
- win->flags |= __WSTANDOUT;
- return (1);
-}
-
-/*
- * wstandend --
- * Exit standout mode.
- */
-int
-wstandend(win)
- WINDOW *win;
-{
- win->flags &= ~__WSTANDOUT;
- return (1);
-}
diff --git a/lib/libcurses/toucholap.c b/lib/libcurses/toucholap.c
deleted file mode 100644
index 955c204147f..00000000000
--- a/lib/libcurses/toucholap.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)toucholap.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include "curses.h"
-
-/*
- * touchoverlap --
- * Touch, on win2, the part that overlaps with win1.
- */
-int
-touchoverlap(win1, win2)
- register WINDOW *win1, *win2;
-{
- register int y, endy, endx, starty, startx;
-
-#ifdef DEBUG
- __CTRACE("touchoverlap: (%0.2o, %0.2o);\n", win1, win2);
-#endif
- starty = max(win1->begy, win2->begy);
- startx = max(win1->begx, win2->begx);
- endy = min(win1->maxy + win1->begy, win2->maxy + win2->begx);
- endx = min(win1->maxx + win1->begx, win2->maxx + win2->begx);
-#ifdef DEBUG
- __CTRACE("touchoverlap: from (%d,%d) to (%d,%d)\n",
- starty, startx, endy, endx);
- __CTRACE("touchoverlap: win1 (%d,%d) to (%d,%d)\n",
- win1->begy, win1->begx, win1->begy + win1->maxy,
- win1->begx + win1->maxx);
- __CTRACE("touchoverlap: win2 (%d,%d) to (%d,%d)\n",
- win2->begy, win2->begx, win2->begy + win2->maxy,
- win2->begx + win2->maxx);
-#endif
- if (starty >= endy || startx >= endx)
- return (OK);
- starty -= win2->begy;
- startx -= win2->begx;
- endy -= win2->begy;
- endx -= win2->begx;
- for (--endx, y = starty; y < endy; y++)
- __touchline(win2, y, startx, endx, 0);
- return (OK);
-}
-
diff --git a/lib/libcurses/touchwin.c b/lib/libcurses/touchwin.c
deleted file mode 100644
index 36f487e5b8f..00000000000
--- a/lib/libcurses/touchwin.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)touchwin.c 8.2 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include "curses.h"
-
-/*
- * touchline --
- * Touch a given line.
- */
-int
-touchline(win, y, sx, ex)
- WINDOW *win;
- register int y, sx, ex;
-{
- return (__touchline(win, y, sx, ex, 1));
-}
-
-
-/*
- * touchwin --
- * Make it look like the whole window has been changed.
- */
-int
-touchwin(win)
- register WINDOW *win;
-{
- register int y, maxy;
-
-#ifdef DEBUG
- __CTRACE("touchwin: (%0.2o)\n", win);
-#endif
- maxy = win->maxy;
- for (y = 0; y < maxy; y++)
- __touchline(win, y, 0, win->maxx - 1, 1);
- return (OK);
-}
-
-
-int
-__touchwin(win)
- register WINDOW *win;
-{
- register int y, maxy;
-
-#ifdef DEBUG
- __CTRACE("touchwin: (%0.2o)\n", win);
-#endif
- maxy = win->maxy;
- for (y = 0; y < maxy; y++)
- __touchline(win, y, 0, win->maxx - 1, 0);
- return (OK);
-}
-
-int
-__touchline(win, y, sx, ex, force)
- register WINDOW *win;
- register int y, sx, ex;
- int force;
-{
-#ifdef DEBUG
- __CTRACE("touchline: (%0.2o, %d, %d, %d, %d)\n", win, y, sx, ex, force);
- __CTRACE("touchline: first = %d, last = %d\n",
- *win->lines[y]->firstchp, *win->lines[y]->lastchp);
-#endif
- if (force)
- win->lines[y]->flags |= __FORCEPAINT;
- sx += win->ch_off;
- ex += win->ch_off;
- if (!(win->lines[y]->flags & __ISDIRTY)) {
- win->lines[y]->flags |= __ISDIRTY;
- *win->lines[y]->firstchp = sx;
- *win->lines[y]->lastchp = ex;
- } else {
- if (*win->lines[y]->firstchp > sx)
- *win->lines[y]->firstchp = sx;
- if (*win->lines[y]->lastchp < ex)
- *win->lines[y]->lastchp = ex;
- }
-#ifdef DEBUG
- __CTRACE("touchline: first = %d, last = %d\n",
- *win->lines[y]->firstchp, *win->lines[y]->lastchp);
-#endif
- return (OK);
-}
-
-
diff --git a/lib/libcurses/tscroll.c b/lib/libcurses/tscroll.c
deleted file mode 100644
index 359b3969c63..00000000000
--- a/lib/libcurses/tscroll.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/*-
- * Copyright (c) 1992, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)tscroll.c 8.4 (Berkeley) 7/27/94";
-#endif /* not lint */
-
-#include "curses.h"
-
-#define MAXRETURNSIZE 64
-
-/*
- * Routine to perform scrolling. Derived from tgoto.c in tercamp(3)
- * library. Cap is a string containing printf type escapes to allow
- * scrolling. The following escapes are defined for substituting n:
- *
- * %d as in printf
- * %2 like %2d
- * %3 like %3d
- * %. gives %c hacking special case characters
- * %+x like %c but adding x first
- *
- * The codes below affect the state but don't use up a value.
- *
- * %>xy if value > x add y
- * %i increments n
- * %% gives %
- * %B BCD (2 decimal digits encoded in one byte)
- * %D Delta Data (backwards bcd)
- *
- * all other characters are ``self-inserting''.
- */
-char *
-__tscroll(cap, n1, n2)
- const char *cap;
- int n1, n2;
-{
- static char result[MAXRETURNSIZE];
- int c, n;
- char *dp;
-
- if (cap == NULL)
- goto err;
- for (n = n1, dp = result; (c = *cap++) != '\0';) {
- if (c != '%') {
- *dp++ = c;
- continue;
- }
- switch (c = *cap++) {
- case 'n':
- n ^= 0140;
- continue;
- case 'd':
- if (n < 10)
- goto one;
- if (n < 100)
- goto two;
- /* FALLTHROUGH */
- case '3':
- *dp++ = (n / 100) | '0';
- n %= 100;
- /* FALLTHROUGH */
- case '2':
-two: *dp++ = n / 10 | '0';
-one: *dp++ = n % 10 | '0';
- n = n2;
- continue;
- case '>':
- if (n > *cap++)
- n += *cap++;
- else
- cap++;
- continue;
- case '+':
- n += *cap++;
- /* FALLTHROUGH */
- case '.':
- *dp++ = n;
- continue;
- case 'i':
- n++;
- continue;
- case '%':
- *dp++ = c;
- continue;
- case 'B':
- n = (n / 10 << 4) + n % 10;
- continue;
- case 'D':
- n = n - 2 * (n % 16);
- continue;
- /*
- * XXX
- * System V terminfo files have lots of extra gunk.
- * The only one we've seen in scrolling strings is
- * %pN, and it seems to work okay if we ignore it.
- */
- case 'p':
- ++cap;
- continue;
- default:
- goto err;
- }
- }
- *dp = '\0';
- return (result);
-
-err: return("curses: __tscroll failed");
-}
diff --git a/lib/libcurses/tstp.c b/lib/libcurses/tstp.c
deleted file mode 100644
index 07debf42fe1..00000000000
--- a/lib/libcurses/tstp.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 1981, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)tstp.c 8.3 (Berkeley) 5/4/94";
-#endif /* not lint */
-
-#include <errno.h>
-#include <signal.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "curses.h"
-
-/*
- * stop_signal_handler --
- * Handle stop signals.
- */
-void
-__stop_signal_handler(signo)
- int signo;
-{
- struct termios save;
- sigset_t oset, set;
-
- /* Get the current terminal state (which the user may have changed). */
- if (tcgetattr(STDIN_FILENO, &save))
- return;
-
- /*
- * Block window change and timer signals. The latter is because
- * applications use timers to decide when to repaint the screen.
- */
- (void)sigemptyset(&set);
- (void)sigaddset(&set, SIGALRM);
- (void)sigaddset(&set, SIGWINCH);
- (void)sigprocmask(SIG_BLOCK, &set, &oset);
-
- /*
- * End the window, which also resets the terminal state to the
- * original modes.
- */
- endwin();
-
- /* Unblock SIGTSTP. */
- (void)sigemptyset(&set);
- (void)sigaddset(&set, SIGTSTP);
- (void)sigprocmask(SIG_UNBLOCK, &set, NULL);
-
- /* Stop ourselves. */
- __restore_stophandler();
- (void)kill(0, SIGTSTP);
-
- /* Time passes ... */
-
- /* Reset the curses SIGTSTP signal handler. */
- __set_stophandler();
-
- /* save the new "default" terminal state */
- (void)tcgetattr(STDIN_FILENO, &__orig_termios);
-
- /* Reset the terminal state to the mode just before we stopped. */
- (void)tcsetattr(STDIN_FILENO, __tcaction ?
- TCSASOFT | TCSADRAIN : TCSADRAIN, &save);
-
- /* Restart the screen. */
- __startwin();
-
- /* Repaint the screen. */
- wrefresh(curscr);
-
- /* Reset the signals. */
- (void)sigprocmask(SIG_SETMASK, &oset, NULL);
-}
-
-static void (*otstpfn)() = SIG_DFL;
-
-/*
- * Set the TSTP handler.
- */
-void
-__set_stophandler()
-{
- otstpfn = signal(SIGTSTP, __stop_signal_handler);
-}
-
-/*
- * Restore the TSTP handler.
- */
-void
-__restore_stophandler()
-{
- (void)signal(SIGTSTP, otstpfn);
-}
diff --git a/lib/libcurses/tty.c b/lib/libcurses/tty.c
deleted file mode 100644
index d04586d853f..00000000000
--- a/lib/libcurses/tty.c
+++ /dev/null
@@ -1,281 +0,0 @@
-/*-
- * Copyright (c) 1992, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)tty.c 8.5 (Berkeley) 8/13/94";
-#endif /* not lint */
-
-#include <stdlib.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "curses.h"
-
-/*
- * In general, curses should leave tty hardware settings alone (speed, parity,
- * word size). This is most easily done in BSD by using TCSASOFT on all
- * tcsetattr calls. On other systems, it would be better to get and restore
- * those attributes at each change, or at least when stopped and restarted.
- * See also the comments in getterm().
- */
-#ifdef TCSASOFT
-int __tcaction = 1; /* Ignore hardware settings. */
-#else
-int __tcaction = 0;
-#endif
-
-struct termios __orig_termios, __baset;
-static struct termios cbreakt, rawt, *curt;
-static int useraw;
-
-#ifndef OXTABS
-#ifdef XTABS /* SMI uses XTABS. */
-#define OXTABS XTABS
-#else
-#define OXTABS 0
-#endif
-#endif
-
-/*
- * gettmode --
- * Do terminal type initialization.
- */
-int
-gettmode()
-{
- useraw = 0;
-
- if (tcgetattr(STDIN_FILENO, &__orig_termios))
- return (ERR);
-
- __baset = __orig_termios;
- __baset.c_oflag &= ~OXTABS;
-
- GT = 0; /* historical. was used before we wired OXTABS off */
- NONL = (__baset.c_oflag & ONLCR) == 0;
-
- /*
- * XXX
- * System V and SMI systems overload VMIN and VTIME, such that
- * VMIN is the same as the VEOF element, and VTIME is the same
- * as the VEOL element. This means that, if VEOF was ^D, the
- * default VMIN is 4. Majorly stupid.
- */
- cbreakt = __baset;
- cbreakt.c_lflag &= ~ICANON;
- cbreakt.c_cc[VMIN] = 1;
- cbreakt.c_cc[VTIME] = 0;
-
- rawt = cbreakt;
- rawt.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|INLCR|IGNCR|ICRNL|IXON);
- rawt.c_oflag &= ~OPOST;
- rawt.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
-
- /*
- * In general, curses should leave hardware-related settings alone.
- * This includes parity and word size. Older versions set the tty
- * to 8 bits, no parity in raw(), but this is considered to be an
- * artifact of the old tty interface. If it's desired to change
- * parity and word size, the TCSASOFT bit has to be removed from the
- * calls that switch to/from "raw" mode.
- */
- if (!__tcaction) {
- rawt.c_iflag &= ~ISTRIP;
- rawt.c_cflag &= ~(CSIZE|PARENB);
- rawt.c_cflag |= CS8;
- }
-
- curt = &__baset;
- return (tcsetattr(STDIN_FILENO, __tcaction ?
- TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
-}
-
-int
-raw()
-{
- useraw = __pfast = __rawmode = 1;
- curt = &rawt;
- return (tcsetattr(STDIN_FILENO, __tcaction ?
- TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
-}
-
-int
-noraw()
-{
- useraw = __pfast = __rawmode = 0;
- curt = &__baset;
- return (tcsetattr(STDIN_FILENO, __tcaction ?
- TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
-}
-
-int
-cbreak()
-{
-
- __rawmode = 1;
- curt = useraw ? &rawt : &cbreakt;
- return (tcsetattr(STDIN_FILENO, __tcaction ?
- TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
-}
-
-int
-nocbreak()
-{
-
- __rawmode = 0;
- curt = useraw ? &rawt : &__baset;
- return (tcsetattr(STDIN_FILENO, __tcaction ?
- TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
-}
-
-int
-echo()
-{
- rawt.c_lflag |= ECHO;
- cbreakt.c_lflag |= ECHO;
- __baset.c_lflag |= ECHO;
-
- __echoit = 1;
- return (tcsetattr(STDIN_FILENO, __tcaction ?
- TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
-}
-
-int
-noecho()
-{
- rawt.c_lflag &= ~ECHO;
- cbreakt.c_lflag &= ~ECHO;
- __baset.c_lflag &= ~ECHO;
-
- __echoit = 0;
- return (tcsetattr(STDIN_FILENO, __tcaction ?
- TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
-}
-
-int
-nl()
-{
- rawt.c_iflag |= ICRNL;
- rawt.c_oflag |= ONLCR;
- cbreakt.c_iflag |= ICRNL;
- cbreakt.c_oflag |= ONLCR;
- __baset.c_iflag |= ICRNL;
- __baset.c_oflag |= ONLCR;
-
- __pfast = __rawmode;
- return (tcsetattr(STDIN_FILENO, __tcaction ?
- TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
-}
-
-int
-nonl()
-{
- rawt.c_iflag &= ~ICRNL;
- rawt.c_oflag &= ~ONLCR;
- cbreakt.c_iflag &= ~ICRNL;
- cbreakt.c_oflag &= ~ONLCR;
- __baset.c_iflag &= ~ICRNL;
- __baset.c_oflag &= ~ONLCR;
-
- __pfast = 1;
- return (tcsetattr(STDIN_FILENO, __tcaction ?
- TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
-}
-
-void
-__startwin()
-{
- static char *stdbuf;
- static size_t len;
-
- (void)fflush(stdout);
-
- /*
- * Some C libraries default to a 1K buffer when talking to a tty.
- * With a larger screen, especially across a network, we'd like
- * to get it to all flush in a single write. Make it twice as big
- * as just the characters (so that we have room for cursor motions
- * and standout information) but no more than 8K.
- */
- if (stdbuf == NULL) {
- if ((len = LINES * COLS * 2) > 8192)
- len = 8192;
- if ((stdbuf = malloc(len)) == NULL)
- len = 0;
- }
- (void)setvbuf(stdout, stdbuf, _IOFBF, len);
-
- tputs(TI, 0, __cputchar);
- tputs(VS, 0, __cputchar);
-}
-
-int
-endwin()
-{
- __restore_stophandler();
-
- if (curscr != NULL) {
- if (curscr->flags & __WSTANDOUT) {
- tputs(SE, 0, __cputchar);
- curscr->flags &= ~__WSTANDOUT;
- }
- __mvcur(curscr->cury, curscr->cury, curscr->maxy - 1, 0, 0);
- }
-
- (void)tputs(VE, 0, __cputchar);
- (void)tputs(TE, 0, __cputchar);
- (void)fflush(stdout);
- (void)setvbuf(stdout, NULL, _IOLBF, 0);
-
- return (tcsetattr(STDIN_FILENO, __tcaction ?
- TCSASOFT | TCSADRAIN : TCSADRAIN, &__orig_termios) ? ERR : OK);
-}
-
-/*
- * The following routines, savetty and resetty are completely useless and
- * are left in only as stubs. If people actually use them they will almost
- * certainly screw up the state of the world.
- */
-static struct termios savedtty;
-int
-savetty()
-{
- return (tcgetattr(STDIN_FILENO, &savedtty) ? ERR : OK);
-}
-
-int
-resetty()
-{
- return (tcsetattr(STDIN_FILENO, __tcaction ?
- TCSASOFT | TCSADRAIN : TCSADRAIN, &savedtty) ? ERR : OK);
-}
diff --git a/lib/libcurses/unctrl.c b/lib/libcurses/unctrl.c
deleted file mode 100644
index ff52230b2e9..00000000000
--- a/lib/libcurses/unctrl.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 1981, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)unctrl.c 8.1 (Berkeley) 6/4/93";
-#endif /* not lint */
-
-char *__unctrl[256] = {
- "^@", "^A", "^B", "^C", "^D", "^E", "^F", "^G",
- "^H", "^I", "^J", "^K", "^L", "^M", "^N", "^O",
- "^P", "^Q", "^R", "^S", "^T", "^U", "^V", "^W",
- "^X", "^Y", "^Z", "^[", "^\\", "^]", "^~", "^_",
- " ", "!", "\"", "#", "$", "%", "&", "'",
- "(", ")", "*", "+", ",", "-", ".", "/",
- "0", "1", "2", "3", "4", "5", "6", "7",
- "8", "9", ":", ";", "<", "=", ">", "?",
- "@", "A", "B", "C", "D", "E", "F", "G",
- "H", "I", "J", "K", "L", "M", "N", "O",
- "P", "Q", "R", "S", "T", "U", "V", "W",
- "X", "Y", "Z", "[", "\\", "]", "^", "_",
- "`", "a", "b", "c", "d", "e", "f", "g",
- "h", "i", "j", "k", "l", "m", "n", "o",
- "p", "q", "r", "s", "t", "u", "v", "w",
- "x", "y", "z", "{", "|", "}", "~", "^?",
-
- "0x80", "0x81", "0x82", "0x83", "0x84", "0x85", "0x86", "0x87",
- "0x88", "0x89", "0x8a", "0x8b", "0x8c", "0x8d", "0x8e", "0x8f",
- "0x90", "0x91", "0x92", "0x93", "0x94", "0x95", "0x96", "0x97",
- "0x98", "0x99", "0x9a", "0x9b", "0x9c", "0x9d", "0x9e", "0x9f",
- "0xa0", "0xa1", "0xa2", "0xa3", "0xa4", "0xa5", "0xa6", "0xa7",
- "0xa8", "0xa9", "0xaa", "0xab", "0xac", "0xad", "0xae", "0xaf",
- "0xb0", "0xb1", "0xb2", "0xb3", "0xb4", "0xb5", "0xb6", "0xb7",
- "0xb8", "0xb9", "0xba", "0xbb", "0xbc", "0xbd", "0xbe", "0xbf",
- "0xc0", "0xc1", "0xc2", "0xc3", "0xc4", "0xc5", "0xc6", "0xc7",
- "0xc8", "0xc9", "0xca", "0xcb", "0xcc", "0xcd", "0xce", "0xcf",
- "0xd0", "0xd1", "0xd2", "0xd3", "0xd4", "0xd5", "0xd6", "0xd7",
- "0xd8", "0xd9", "0xda", "0xdb", "0xdc", "0xdd", "0xde", "0xdf",
- "0xe0", "0xe1", "0xe2", "0xe3", "0xe4", "0xe5", "0xe6", "0xe7",
- "0xe8", "0xe9", "0xea", "0xeb", "0xec", "0xed", "0xee", "0xef",
- "0xf0", "0xf1", "0xf2", "0xf3", "0xf4", "0xf5", "0xf6", "0xf7",
- "0xf8", "0xf9", "0xfa", "0xfb", "0xfc", "0xfd", "0xfe", "0xff",
-};
-
-char __unctrllen[256] = {
- 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 2,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
-};
diff --git a/lib/libcurses/unctrl.h b/lib/libcurses/unctrl.h
new file mode 100644
index 00000000000..a503aa76a8f
--- /dev/null
+++ b/lib/libcurses/unctrl.h
@@ -0,0 +1,45 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/*
+ * unctrl.h
+ *
+ * Display a printable version of a control character.
+ * Control characters are displayed in caret notation (^x), DELETE is displayed
+ * as ^?. Printable characters are displayed as is.
+ *
+ * The returned pointer points to a static buffer which gets overwritten by
+ * each call. Therefore, you must copy the resulting string to a safe place
+ * before calling unctrl() again.
+ *
+ */
+#ifndef _UNCTRL_H
+#define _UNCTRL_H 1
+#define NCURSES_VERSION "1.9.9e"
+
+#ifndef _CHTYPE_T_
+#define _CHTYPE_T_ unsigned long
+typedef _CHTYPE_T_ chtype;
+#endif
+
+extern char *unctrl(chtype);
+
+#endif /* _UNCTRL_H */