summaryrefslogtreecommitdiffstats
path: root/lib/libncurses
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1994-10-07 08:58:58 +0000
committerache <ache@FreeBSD.org>1994-10-07 08:58:58 +0000
commita80c0624fbd8bd1c784b0b5b7a0fd20b09d317b9 (patch)
tree4a94ca97fb2fc2fdc1fcdd522a66e39c6e763138 /lib/libncurses
downloadFreeBSD-src-a80c0624fbd8bd1c784b0b5b7a0fd20b09d317b9.zip
FreeBSD-src-a80c0624fbd8bd1c784b0b5b7a0fd20b09d317b9.tar.gz
Moved from ports with several enhancements
Diffstat (limited to 'lib/libncurses')
-rw-r--r--lib/libncurses/COPYRIGHT.NEW18
-rw-r--r--lib/libncurses/COPYRIGHT.OLD5
-rw-r--r--lib/libncurses/MKkeyname.awk30
-rw-r--r--lib/libncurses/MKkeys.awk1
-rw-r--r--lib/libncurses/Makefile73
-rw-r--r--lib/libncurses/README39
-rw-r--r--lib/libncurses/TESTS/Makefile37
-rw-r--r--lib/libncurses/TESTS/README22
-rw-r--r--lib/libncurses/TESTS/battle.c705
-rw-r--r--lib/libncurses/TESTS/bs.642
-rw-r--r--lib/libncurses/TESTS/bs.c1119
-rw-r--r--lib/libncurses/TESTS/copy.c39
-rw-r--r--lib/libncurses/TESTS/corner.c16
-rw-r--r--lib/libncurses/TESTS/ensor.c52
-rw-r--r--lib/libncurses/TESTS/firework.c113
-rw-r--r--lib/libncurses/TESTS/gdc.622
-rw-r--r--lib/libncurses/TESTS/gdc.c174
-rw-r--r--lib/libncurses/TESTS/getch.c29
-rw-r--r--lib/libncurses/TESTS/hanoi.c267
-rw-r--r--lib/libncurses/TESTS/knight.c322
-rw-r--r--lib/libncurses/TESTS/ncurses.c1038
-rw-r--r--lib/libncurses/TESTS/newdemo.c350
-rw-r--r--lib/libncurses/TESTS/over.c120
-rw-r--r--lib/libncurses/TESTS/rain.c96
-rw-r--r--lib/libncurses/TESTS/scroll.c30
-rw-r--r--lib/libncurses/TESTS/scroll2.c91
-rw-r--r--lib/libncurses/TESTS/scroll3.c51
-rw-r--r--lib/libncurses/TESTS/test.c27
-rw-r--r--lib/libncurses/TESTS/testcurs.c532
-rw-r--r--lib/libncurses/TESTS/worm.c268
-rw-r--r--lib/libncurses/TESTS/xmas.c1192
-rw-r--r--lib/libncurses/curs_addch.3113
-rw-r--r--lib/libncurses/curs_addchst.350
-rw-r--r--lib/libncurses/curs_addstr.344
-rw-r--r--lib/libncurses/curs_attr.387
-rw-r--r--lib/libncurses/curs_beep.329
-rw-r--r--lib/libncurses/curs_bkgd.350
-rw-r--r--lib/libncurses/curs_border.367
-rw-r--r--lib/libncurses/curs_clear.353
-rw-r--r--lib/libncurses/curs_color.3138
-rw-r--r--lib/libncurses/curs_delch.334
-rw-r--r--lib/libncurses/curs_delln.353
-rw-r--r--lib/libncurses/curs_getch.3188
-rw-r--r--lib/libncurses/curs_getstr.353
-rw-r--r--lib/libncurses/curs_getyx.341
-rw-r--r--lib/libncurses/curs_inch.340
-rw-r--r--lib/libncurses/curs_inchstr.346
-rw-r--r--lib/libncurses/curs_initscr.384
-rw-r--r--lib/libncurses/curs_inopts.3170
-rw-r--r--lib/libncurses/curs_insch.336
-rw-r--r--lib/libncurses/curs_insstr.357
-rw-r--r--lib/libncurses/curs_instr.344
-rw-r--r--lib/libncurses/curs_kernel.3113
-rw-r--r--lib/libncurses/curs_move.328
-rw-r--r--lib/libncurses/curs_outopts.3114
-rw-r--r--lib/libncurses/curs_overlay.341
-rw-r--r--lib/libncurses/curs_pad.375
-rw-r--r--lib/libncurses/curs_printw.342
-rw-r--r--lib/libncurses/curs_refresh.369
-rw-r--r--lib/libncurses/curs_scanw.344
-rw-r--r--lib/libncurses/curs_scr_dmp.356
-rw-r--r--lib/libncurses/curs_scroll.338
-rw-r--r--lib/libncurses/curs_slk.385
-rw-r--r--lib/libncurses/curs_termatt.376
-rw-r--r--lib/libncurses/curs_touch.357
-rw-r--r--lib/libncurses/curs_util.382
-rw-r--r--lib/libncurses/curs_window.3119
-rw-r--r--lib/libncurses/curses.priv.h115
-rw-r--r--lib/libncurses/keys.list149
-rw-r--r--lib/libncurses/lib_acs.c99
-rw-r--r--lib/libncurses/lib_addch.c86
-rw-r--r--lib/libncurses/lib_addstr.c56
-rw-r--r--lib/libncurses/lib_beep.c56
-rw-r--r--lib/libncurses/lib_box.c131
-rw-r--r--lib/libncurses/lib_clear.c24
-rw-r--r--lib/libncurses/lib_clrbot.c53
-rw-r--r--lib/libncurses/lib_clreol.c48
-rw-r--r--lib/libncurses/lib_color.c107
-rw-r--r--lib/libncurses/lib_delch.c38
-rw-r--r--lib/libncurses/lib_deleteln.c48
-rw-r--r--lib/libncurses/lib_delwin.c35
-rw-r--r--lib/libncurses/lib_doupdate.c527
-rw-r--r--lib/libncurses/lib_endwin.c44
-rw-r--r--lib/libncurses/lib_erase.c50
-rw-r--r--lib/libncurses/lib_getch.c217
-rw-r--r--lib/libncurses/lib_getstr.c113
-rw-r--r--lib/libncurses/lib_inchstr.c29
-rw-r--r--lib/libncurses/lib_initscr.c32
-rw-r--r--lib/libncurses/lib_insch.c36
-rw-r--r--lib/libncurses/lib_insdel.c120
-rw-r--r--lib/libncurses/lib_insertln.c49
-rw-r--r--lib/libncurses/lib_insstr.c21
-rw-r--r--lib/libncurses/lib_kernel.c249
-rw-r--r--lib/libncurses/lib_longname.c35
-rw-r--r--lib/libncurses/lib_move.c33
-rw-r--r--lib/libncurses/lib_mvcur.c719
-rw-r--r--lib/libncurses/lib_mvwin.c29
-rw-r--r--lib/libncurses/lib_newterm.c154
-rw-r--r--lib/libncurses/lib_newwin.c177
-rw-r--r--lib/libncurses/lib_options.c229
-rw-r--r--lib/libncurses/lib_overlay.c110
-rw-r--r--lib/libncurses/lib_pad.c142
-rw-r--r--lib/libncurses/lib_printw.c81
-rw-r--r--lib/libncurses/lib_raw.c195
-rw-r--r--lib/libncurses/lib_refresh.c74
-rw-r--r--lib/libncurses/lib_scanw.c72
-rw-r--r--lib/libncurses/lib_screen.c58
-rw-r--r--lib/libncurses/lib_scroll.c120
-rw-r--r--lib/libncurses/lib_scrreg.c32
-rw-r--r--lib/libncurses/lib_set_term.c35
-rw-r--r--lib/libncurses/lib_slk.c272
-rw-r--r--lib/libncurses/lib_touch.c48
-rw-r--r--lib/libncurses/lib_trace.c170
-rw-r--r--lib/libncurses/lib_tstp.c47
-rw-r--r--lib/libncurses/lib_twait.c59
-rw-r--r--lib/libncurses/lib_unctrl.c26
-rw-r--r--lib/libncurses/lib_vidattr.c185
-rw-r--r--lib/libncurses/lib_window.c84
-rw-r--r--lib/libncurses/ncurses.3433
-rw-r--r--lib/libncurses/ncurses.h497
-rw-r--r--lib/libncurses/nterm.h6
-rw-r--r--lib/libncurses/term.5153
-rw-r--r--lib/libncurses/termcap.h32
-rw-r--r--lib/libncurses/terminfo.51656
-rw-r--r--lib/libncurses/unctrl.h21
-rw-r--r--lib/libncurses/version.h3
126 files changed, 17955 insertions, 0 deletions
diff --git a/lib/libncurses/COPYRIGHT.NEW b/lib/libncurses/COPYRIGHT.NEW
new file mode 100644
index 0000000..4a79f1d
--- /dev/null
+++ b/lib/libncurses/COPYRIGHT.NEW
@@ -0,0 +1,18 @@
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992, 1993, 1994 *
+* by Zeyd M. Ben-Halim *
+* zmbenhal@netcom.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 remains in the sources and is reproduced in any *
+* documentation accompanying it or the applications linked with it. *
+* Any other use of ncurses, including incorporating it in another *
+* product is subject to written permission. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
diff --git a/lib/libncurses/COPYRIGHT.OLD b/lib/libncurses/COPYRIGHT.OLD
new file mode 100644
index 0000000..4049db0
--- /dev/null
+++ b/lib/libncurses/COPYRIGHT.OLD
@@ -0,0 +1,5 @@
+
+Pavel Curtis has given up his copyright to the public domain. This mean
+his ORIGINAL sources are in the public domain, not this current release.
+This current release IS copyrighted, see COPYRIGHT.NEW.
+
diff --git a/lib/libncurses/MKkeyname.awk b/lib/libncurses/MKkeyname.awk
new file mode 100644
index 0000000..be51bc8
--- /dev/null
+++ b/lib/libncurses/MKkeyname.awk
@@ -0,0 +1,30 @@
+
+BEGIN {
+ print ""
+ print "#include <stdlib.h>"
+ print "#include <ncurses.h>"
+ print ""
+ print "struct kn {"
+ print "\tchar *name;"
+ print "\tint code;"
+ print "};"
+ print ""
+ print "struct kn key_names[] = {"
+}
+
+{printf "\t{\"%s\", %s,},\n", $1, $2;}
+
+END {
+ print "};"
+ print ""
+ print "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/libncurses/MKkeys.awk b/lib/libncurses/MKkeys.awk
new file mode 100644
index 0000000..669c455
--- /dev/null
+++ b/lib/libncurses/MKkeys.awk
@@ -0,0 +1 @@
+{printf "\tadd_to_try(%s, %s);\n", $1, $2;}
diff --git a/lib/libncurses/Makefile b/lib/libncurses/Makefile
new file mode 100644
index 0000000..a5c2911
--- /dev/null
+++ b/lib/libncurses/Makefile
@@ -0,0 +1,73 @@
+LIB= ncurses
+INCDIR= /usr/include
+CFLAGS+= -Wall -DMYTINFO -DTERMIOS -DGOOD_SELECT -DBSDTABS
+SHARED_LDADD+= -lmytinfo
+SRCS= lib_kernel.c lib_pad.c\
+ lib_unctrl.c lib_raw.c lib_vidattr.c lib_trace.c lib_beep.c \
+ lib_doupdate.c lib_refresh.c lib_initscr.c lib_newwin.c lib_addch.c \
+ lib_addstr.c lib_scroll.c lib_clreol.c lib_touch.c lib_mvcur.c lib_keyname.c\
+ lib_delwin.c lib_endwin.c lib_clrbot.c lib_move.c lib_printw.c \
+ lib_scanw.c lib_erase.c lib_getch.c lib_options.c lib_acs.c lib_slk.c\
+ lib_box.c lib_clear.c lib_delch.c lib_deleteln.c lib_insch.c \
+ lib_insertln.c lib_getstr.c lib_mvwin.c lib_longname.c lib_tstp.c \
+ lib_newterm.c lib_set_term.c lib_overlay.c lib_scrreg.c lib_color.c \
+ lib_insstr.c lib_insdel.c lib_twait.c
+CLEANFILES+= lib_keyname.c ${.CURDIR}/keys.tries
+
+beforedepend: ${.CURDIR}/keys.tries
+
+beforeinstall:
+ @cd ${.CURDIR}; for i in ncurses.h nterm.h unctrl.h termcap.h; do \
+ cmp -s $$i ${DESTDIR}${INCDIR}/$$i || \
+ $(INSTALL) $(COPY) -m 444 -o $(BINOWN) -g $(BINGRP) $$i ${DESTDIR}$(INCDIR); done
+
+${.CURDIR}/keys.tries: keys.list MKkeys.awk
+ awk -f ${.CURDIR}/MKkeys.awk ${.CURDIR}/keys.list > ${.CURDIR}/keys.tries
+
+# in case you don't run make depend
+lib_options.o: ${.CURDIR}/keys.tries
+
+lib_keyname.c: keys.list MKkeyname.awk
+ awk -f ${.CURDIR}/MKkeyname.awk ${.CURDIR}/keys.list > lib_keyname.c
+
+MAN3 = curs_addch.3 \
+ curs_addchst.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_delln.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_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_termatt.3 \
+ curs_touch.3 \
+ curs_util.3 \
+ curs_window.3 \
+ ncurses.3
+
+MAN5 = term.5 terminfo.5
+
+.include <bsd.lib.mk>
diff --git a/lib/libncurses/README b/lib/libncurses/README
new file mode 100644
index 0000000..ad58ccd
--- /dev/null
+++ b/lib/libncurses/README
@@ -0,0 +1,39 @@
+This file is intended to help people interested in working
+on fixing ncurses, enhancing it, or porting it to other
+platforms.
+
+PORTABILITY:
+The file matrix is an attempt and centralizing all portability
+information. The top line contains the different options, down
+the leftside are the operating systems supported. If an option
+is not needed then it should have an entry of NONE. Note the
+use of ':' to terminate each field. If somebody knows awk better
+than me, get in touch.
+
+OS: name of operating system
+ISPOSIX: -DNONPOSIX if <unistd.h> is missing
+POSIX: -DSTRICTPOSIX if _POSIX_SOURCE turns off non-POSIX features.
+ -DSVR4_ACTION if like svr4 you need _POSIX_SOURCE to have sigaction
+TERMINAL: -DNOTERMIOS if you don't have <termios.h> but have <sgtty.h>
+HEADERS: -DBRAINDEAD if system headers don't declare external variables
+TABS: -DBSDTABS if you don't have TABS3 but have OXTABS
+OPT: -DOPT_MVCUR if you want mvcur() to cost its actions or you have a
+ terminal that doesn't have direct cursor addressing.
+SRCDIR: the directory where the terminfo database lives
+CC: ANSI C compiler
+FLAGS: standard compiler flags
+EXTRA: extra flags needed by individual systems
+ Linux: -DBROKEN_TCDRAIN tcdrain() is broken on Linux
+ Sun: -DSUNIOCTL <sys/ioctl.h> conflicts with <termios.h>
+ HP-UX: -D_HPUX_SOURCE so that we get POSIX and XOPEN features.
+ SVR4: -DBROKEN_TIOCGETWINSZ guess what?
+BASE: The directory under which headers and libraries will
+ be installed.
+INSTALL: The name of an intelligent install program. GNU install works.
+
+The awk script in script.src reads matrix and generates all the Config.*
+files.
+
+There are several problems with strict POSIX systems so extra flags
+or #define's maybe needed.
+
diff --git a/lib/libncurses/TESTS/Makefile b/lib/libncurses/TESTS/Makefile
new file mode 100644
index 0000000..9b258df
--- /dev/null
+++ b/lib/libncurses/TESTS/Makefile
@@ -0,0 +1,37 @@
+TESTS = test corner ensor getch ncurses bs gdc hanoi knight rain worm \
+ over scroll2 battle newdemo scroll3 xmas copy firework testcurs \
+ scroll
+
+CLEANFILES += $(TESTS)
+
+LIBS += -lncurses -lmytinfo
+
+all: $(TESTS)
+
+$(TESTS):
+ $(CC) $(CFLAGS) $(LDFLAGS) ${.CURDIR}/$@.c -o $@ $(LIBS)
+
+test: test.c
+corner: corner.c
+ensor: ensor.c
+getch: getch.c
+ncurses: ncurses.c
+bs: bs.c
+gdc: gdc.c
+hanoi: hanoi.c
+knight: knight.c
+rain: rain.c
+worm: worm.c
+over: over.c
+scroll2: scroll2.c
+battle: battle.c
+newdemo: newdemo.c
+scroll3: scroll3.c
+xmas: xmas.c
+copy: copy.c
+firework: firework.c
+testcurs: testcurs.c
+scroll: scroll.c
+
+.include "bsd.prog.mk"
+
diff --git a/lib/libncurses/TESTS/README b/lib/libncurses/TESTS/README
new file mode 100644
index 0000000..7f45243
--- /dev/null
+++ b/lib/libncurses/TESTS/README
@@ -0,0 +1,22 @@
+The programs in this directory are designed to test your newest toy :-)
+Check the sources for any further details.
+
+asc.c - tests the line drawing functions
+attr.c - display attributes available on the terminal
+bs.c - the game of battleship
+battle.c - older version of battleship with different interface
+caps.c - output a list of all capabilites to stderr (redirect to a file
+ or it will screw up the terminal)
+copy.c - test overlay
+gdc.c - Great Digital Clock, gives an example of usng color
+getch.c - tests ketpad() and getch()
+hanoi.c - the game of hanoi, also an example of using color
+knight.c - the game of Knight's Tour
+rain.c - rain drops are falling on my head..
+scroll.c - test scrolling region
+slk.c - test soft labels
+worm.c - worms run all over your screen
+firework.c - multi-colored fireworks
+newdemo.c - a demo from the PDCurses people
+testcurs.c - a test from the PDCurses people
+ This will fail to link on machines that don't have vsscanf().
diff --git a/lib/libncurses/TESTS/battle.c b/lib/libncurses/TESTS/battle.c
new file mode 100644
index 0000000..e7785fc
--- /dev/null
+++ b/lib/libncurses/TESTS/battle.c
@@ -0,0 +1,705 @@
+/*
+ * battle.c - original author: Bruce Holloway
+ * mods by: Chuck A DeGaul
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <time.h>
+#include <signal.h>
+#include <ncurses.h>
+
+#define OTHER 1-turn
+
+char numbers[] = " 0 1 2 3 4 5 6 7 8 9";
+
+char carrier[] = "Aircraft Carrier";
+char battle[] = "Battleship";
+char sub[] = "Submarine";
+char destroy[] = "Destroyer";
+char ptboat[] = "PT Boat";
+
+char name[40];
+char dftname[] = "Stranger";
+
+struct _ships {
+ char *name;
+ char symbol;
+ char length;
+ char start; /* Coordinates - 0,0=0; 10,10=100. */
+ char dir; /* Direction - 0 = right; 1 = down. */
+ char hits; /* How many times has this ship been hit? (-1==sunk) */
+};
+
+struct _ships plyship[] = {
+ { carrier,'A',5,0,0,0 },
+ { battle,'B',4,0,0,0 },
+ { destroy,'D',3,0,0,0 },
+ { sub,'S',3,0,0,0 },
+ { ptboat,'P',2,0,0,0 },
+};
+
+struct _ships cpuship[] = {
+ { carrier,'A',5,0,0,0 },
+ { battle,'B',4,0,0,0 },
+ { destroy,'D',3,0,0,0 },
+ { sub,'S',3,0,0,0 },
+ { ptboat,'P',2,0,0,0 },
+};
+
+char hits[2][100], board[2][100]; /* "Hits" board, and main board. */
+
+int srchstep;
+int cpuhits;
+int cstart, cdir;
+int plywon=0, cpuwon=0; /* How many games has each won? */
+int turn; /* 0=player, 1=computer */
+int huntoffs; /* Offset on search strategy */
+
+int salvo, blitz, ask, seemiss; /* options */
+
+void intro(void);
+void initgame(void);
+int rnd(int);
+void plyplace(struct _ships *);
+int getdir(void);
+void placeship(struct _ships *, int, int);
+int checkplace(struct _ships *, int, int);
+void error(char *);
+void prompt(void);
+char getcoord(void);
+void cpuplace(struct _ships *);
+int awinna(void);
+int plyturn(void);
+int hitship(int);
+int cputurn(void);
+int playagain(void);
+void uninitgame();
+int sgetc(char *);
+int do_options(int, char *[]);
+int scount(int);
+
+int
+main(int argc, char **argv)
+{
+ do_options(argc, argv);
+
+ intro();
+ do {
+ initgame();
+ while(awinna() == -1) {
+ if (!blitz) {
+ if (!salvo) {
+ if (turn)
+ cputurn();
+ else plyturn();
+ } else {
+ register int i;
+
+ i = scount(turn);
+ while (i--) {
+ if (turn)
+ if (cputurn())
+ if (awinna() != -1)
+ i = 0;
+ else
+ if(plyturn())
+ if (awinna() != -1)
+ i = 0;
+ }
+ }
+ } else {
+ while((turn) ? cputurn() : plyturn());
+ }
+ turn = OTHER;
+ }
+ } while(playagain());
+ uninitgame();
+ exit(0);
+}
+
+#define PR addstr
+
+void
+intro()
+{
+char *tmpname;
+
+ srand(time(0L)); /* Kick the random number generator */
+
+ signal(SIGINT,uninitgame);
+ if(signal(SIGQUIT,SIG_IGN) != SIG_IGN) signal(SIGQUIT,uninitgame);
+#if 1
+ /* for some bizzare reason, getlogin or cuserid cause havoc with the terminal */
+ if ((tmpname = getlogin()) != NULL) {
+ strcpy(name, tmpname);
+ } else
+#endif
+ strcpy(name,dftname);
+ name[0] = toupper(name[0]);
+
+ initscr();
+ savetty();
+ nonl();
+ cbreak();
+ noecho();
+ clear();
+ mvaddstr(4,29,"Welcome to Battleship!");
+ move(8,0);
+PR(" \\\n");
+PR(" \\ \\ \\\n");
+PR(" \\ \\ \\ \\ \\_____________\n");
+PR(" \\ \\ \\_____________ \\ \\/ |\n");
+PR(" \\ \\/ \\ \\/ |\n");
+PR(" \\/ \\_____/ |__\n");
+PR(" ________________/ |\n");
+PR(" \\ S.S. Penguin |\n");
+PR(" \\ /\n");
+PR(" \\___________________________________________________/\n");
+ mvaddstr(20,27,"Hit any key to continue..."); refresh();
+ getch();
+}
+
+void
+initgame()
+{
+int i;
+
+ clear();
+ mvaddstr(0,35,"BATTLESHIP");
+ mvaddstr(4,12,"Main Board");
+ mvaddstr(6,0,numbers);
+ move(7,0);
+ for(i=0; i<10; ++i){
+ printw("%c . . . . . . . . . . %c\n",i+'A',i+'A');
+ }
+ mvaddstr(17,0,numbers);
+ mvaddstr(4,55,"Hit/Miss Board");
+ mvaddstr(6,45,numbers);
+ for(i=0; i<10; ++i){
+ mvprintw(7+i,45,"%c . . . . . . . . . . %c",i+'A',i+'A');
+ }
+ mvaddstr(17,45,numbers);
+ for(turn=0; turn<2; ++turn)
+ for(i=0; i<100; ++i){
+ hits[turn][i] = board[turn][i] = 0;
+ }
+ for(turn=0; turn<2; ++turn){
+ for(i=0; i<5; ++i)
+ if (!turn)
+ plyplace(&plyship[i]);
+ else
+ cpuplace(&cpuship[i]);
+ }
+ turn = rnd(2);
+ cstart = cdir = -1;
+ cpuhits = 0;
+ srchstep = 3;
+ huntoffs = rnd(srchstep);
+}
+
+int
+rnd(int n)
+{
+ return(((rand() & 0x7FFF) % n));
+}
+
+void
+plyplace(ss)
+struct _ships *ss;
+{
+int c, d;
+
+ do {
+ prompt();
+ printw("Place your %s (ex.%c%d) ? ",ss->name,rnd(10)+'A',rnd(10));
+ c = getcoord();
+ d = getdir();
+ } while(!checkplace(ss,c,d));
+ placeship(ss,c,d);
+}
+
+int
+getdir()
+{
+
+ prompt();
+ addstr("What direction (0=right, 1=down) ? ");
+ return(sgetc("01")-'0');
+}
+
+void
+placeship(ss,c,d)
+struct _ships *ss;
+int c, d;
+{
+int x, y, l, i;
+
+ for(l=0; l<ss->length; ++l){
+ i = c + l * ((d) ? 10 : 1);
+ board[turn][i] = ss->symbol;
+ x = (i % 10) * 3 + 3;
+ y = (i / 10) + 7;
+ if(!turn) mvaddch(y,x,ss->symbol);
+ }
+ ss->start = c;
+ ss->dir = d;
+ ss->hits = 0;
+}
+
+int
+checkplace(ss,c,d)
+struct _ships *ss;
+int c, d;
+{
+int x, y, l;
+
+ x = c%10; y = c/10;
+ if(((x+ss->length) > 10 && !d) || ((y+ss->length) > 10 && d==1)){
+ if(!turn)
+ switch(rnd(3)){
+ case 0:
+ error("Ship is hanging from the edge of the world");
+ break;
+ case 1:
+ error("Try fitting it on the board");
+ break;
+ case 2:
+ error("Figure I won't find it if you put it there?");
+ break;
+ }
+ return(0);
+ }
+ for(l=0; l<ss->length; ++l){
+ x = c + l * ((d) ? 10 : 1);
+ if(board[turn][x]){
+ if(!turn)
+ switch(rnd(3)){
+ case 0:
+ error("There's already a ship there");
+ break;
+ case 1:
+ error("Collision alert! Aaaaaagh!");
+ break;
+ case 2:
+ error("Er, Admiral, what about the other ship?");
+ break;
+ }
+ return(0);
+ }
+ }
+ return(1);
+}
+
+void
+error(s)
+char *s;
+{
+ prompt();
+ beep();
+ printw("%s -- hit any key to continue --",s);
+ refresh();
+ getch();
+}
+
+void
+prompt(){
+ move(22,0);
+ clrtoeol();
+}
+
+char
+getcoord()
+{
+int ch, x, y;
+
+redo:
+ y = sgetc("ABCDEFGHIJ");
+ do {
+ ch = getch();
+ if (ch == 0x7F || ch == 8) {
+ addstr("\b \b");
+ refresh();
+ goto redo;
+ }
+ } while(ch < '0' || ch > '9');
+ addch(x = ch);
+ refresh();
+ return((y-'A')*10+x-'0');
+}
+
+void
+cpuplace(ss)
+struct _ships *ss;
+{
+int c, d;
+
+ do{
+ c = rnd(100);
+ d = rnd(2);
+ } while(!checkplace(ss,c,d));
+ placeship(ss,c,d);
+}
+
+int
+awinna()
+{
+int i, j;
+struct _ships *ss;
+
+ for (i = 0; i < 2; ++i) {
+ ss = (i) ? cpuship : plyship;
+ for(j=0; j<5; ++j, ++ss)
+ if(ss->length != ss->hits)
+ break;
+ if(j == 5) return(OTHER);
+ }
+ return(-1);
+}
+
+int
+plyturn()
+{
+int c, res;
+char *m;
+
+ prompt();
+ addstr("Where do you want to shoot? ");
+ c = getcoord();
+ if(!(res = hits[turn][c])){
+ hits[turn][c] = res = (board[OTHER][c]) ? 'H' : 'M';
+ mvaddch(7+c/10,48+3*(c%10),(res=='H') ? 'H' : 'o');
+ if(c = hitship(c)){
+ prompt();
+ switch(rnd(3)){
+ case 0:
+ m = "You sank my %s!";
+ break;
+ case 1:
+ m = "I have this sinking feeling about my %s....";
+ break;
+ case 2:
+ m = "Have some mercy for my %s!";
+ break;
+ }
+ move(23,0);
+ clrtoeol();
+ beep();
+ printw(m,cpuship[c-1].name); refresh();
+ return(awinna() == -1);
+ }
+ }
+ prompt();
+ move(23,0); clrtoeol();
+ printw("You %s.",(res=='M')?"missed":"scored a hit"); refresh();
+ return(res == 'H');
+}
+
+int
+hitship(c)
+int c;
+{
+struct _ships *ss;
+int sym, i, j;
+
+ ss = (turn) ? plyship : cpuship;
+ if (!(sym = board[OTHER][c])) return(0);
+ for (i = 0; i < 5; ++i, ++ss)
+ if (ss->symbol == sym) {
+ j = ss->hits;
+ ++j;
+ ss->hits = j;
+ if (j == ss->length)
+ return(i+1);
+ return(0);
+ }
+}
+
+int
+cputurn()
+{
+int c, res, x, y, i, d;
+
+redo:
+ if (cstart == -1){
+ if (cpuhits){
+ for(i=0, c=rnd(100); i<100; ++i, c = (c+1) % 100)
+ if(hits[turn][c] == 'H')
+ break;
+ if(i != 100){
+ cstart = c;
+ cdir = -1;
+ goto fndir;
+ }
+ }
+ do {
+ i = 0;
+ do{
+ while(hits[turn][c=rnd(100)]);
+ x = c % 10; y = c / 10;
+ if(++i == 1000) break;
+ } while(((x+huntoffs) % srchstep) != (y % srchstep));
+ if(i == 1000) --srchstep;
+ } while(i == 1000);
+ }
+ else if(cdir == -1){
+fndir: for(i=0, d=rnd(4); i++ < 4; d = (d+1) % 4){
+ x = cstart%10; y = cstart/10;
+ switch(d){
+ case 0: ++x; break;
+ case 1: ++y; break;
+ case 2: --x; break;
+ case 3: --y; break;
+ }
+ if(x<0 || x>9 || y<0 || y>9) continue;
+ if(hits[turn][c=y*10+x]) continue;
+ cdir = -2;
+ break;
+ }
+ if(i == 4){
+ cstart = -1;
+ goto redo;
+ }
+ }
+ else{
+ x = cstart%10; y = cstart/10;
+ switch(cdir){
+ case 0: ++x; break;
+ case 1: ++y; break;
+ case 2: --x; break;
+ case 3: --y; break;
+ }
+ if(x<0 || x>9 || y<0 || y>9 || hits[turn][y*10+x]){
+ cdir = (cdir+2) % 4;
+ for(;;){
+ switch(cdir){
+ case 0: ++x; break;
+ case 1: ++y; break;
+ case 2: --x; break;
+ case 3: --y; break;
+ }
+ if(x<0 || x>9 || y<0 || y>9){ cstart = -1;
+ goto redo;
+ }
+ if(!hits[turn][y*10+x]) break;
+ }
+ }
+ c = y*10 + x;
+ }
+
+ if (!ask) {
+ res = (board[OTHER][c]) ? 'H' : 'M';
+ move(21,0); clrtoeol();
+ printw("I shoot at %c%d. I %s!",c/10+'A',c%10,(res=='H')?"hit":"miss");
+ } else {
+ for(;;){
+ prompt();
+ printw("I shoot at %c%d. Do I (H)it or (M)iss? ",c/10+'A',c%10);
+ res = sgetc("HM");
+ if((res=='H' && !board[OTHER][c]) || (res=='M' && board[OTHER][c])){
+ error("You lie!");
+ continue;
+ }
+ break;
+ }
+ addch(res);
+ }
+ hits[turn][c] = res;
+ if(res == 'H') {
+ ++cpuhits;
+ if(cstart == -1) cdir = -1;
+ cstart = c;
+ if(cdir == -2) cdir = d;
+ mvaddch(7+(c/10),3+3*(c%10),'*');
+ if (blitz && !ask) {
+ refresh();
+ sleep(1);
+ }
+ }
+ else {
+ if (seemiss) {
+ mvaddch(7+(c/10),3+3*(c%10),' ');
+ } else {
+ if(cdir == -2) cdir = -1;
+ }
+ }
+ if(c=hitship(c)){
+ cstart = -1;
+ cpuhits -= plyship[c-1].length;
+ x = plyship[c-1].start;
+ d = plyship[c-1].dir;
+ y = plyship[c-1].length;
+ for(i=0; i<y; ++i){
+ hits[turn][x] = '*';
+ x += (d) ? 10 : 1;
+ }
+ }
+ if (salvo && !ask) {
+ refresh();
+ sleep(1);
+ }
+ if(awinna() != -1) return(0);
+ return(res == 'H');
+}
+
+int
+playagain()
+{
+int i, x, y, dx, dy, j;
+
+ for(i=0; i<5; ++i){
+ x = cpuship[i].start; y = x/10+7; x = (x % 10) * 3 + 48;
+ dx = (cpuship[i].dir) ? 0 : 3;
+ dy = (cpuship[i].dir) ? 1 : 0;
+ for(j=0; j < cpuship[i].length; ++j){
+ mvaddch(y,x,cpuship[i].symbol);
+ x += dx; y += dy;
+ }
+ }
+
+ if(awinna()) ++cpuwon; else ++plywon;
+ i = 18 + strlen(name);
+ if(plywon >= 10) ++i;
+ if(cpuwon >= 10) ++i;
+ mvprintw(2,(80-i)/2,"%s: %d Computer: %d",name,plywon,cpuwon);
+
+ prompt();
+ printw((awinna()) ? "Want to be humiliated again, %s? "
+ : "Going to give me a chance for revenge, %s? ",name);
+ return(sgetc("YN") == 'Y');
+}
+
+void
+uninitgame(int sig)
+{
+ refresh();
+ endwin();
+ exit(0);
+}
+
+int
+sgetc(s)
+char *s;
+{
+char *s1;
+int ch;
+
+ refresh();
+ for (;;) {
+ ch = toupper(getch());
+ for (s1 = s; *s1 && ch != *s1; ++s1);
+ if (*s1) {
+ addch(ch);
+ refresh();
+ return(ch);
+ }
+ }
+}
+
+/*
+ * I should use getopts() from libc.a, but I'm leary that other UNIX
+ * systems might not have it, although I'd love to use it.
+ */
+
+int
+do_options(c,op)
+int c;
+char *op[];
+{
+register int i;
+
+ if (c > 1) {
+ for (i=1; i<c; i++) {
+ switch(op[i][0]) {
+ default:
+ case '?':
+ fprintf(stderr, "Usage: battle [ -s | -b ] [ -a ] [ -m ]\n");
+ fprintf(stderr, "\tWhere the options are:\n");
+ fprintf(stderr, "\t-s : play a salvo game (mutex with -b)\n");
+ fprintf(stderr, "\t-b : play a blitz game (mutex with -s)\n");
+ fprintf(stderr, "\t-a : computer asks you for hit/miss\n");
+ fprintf(stderr, "\t-m : computer misses are displayed\n");
+ exit(1);
+ break;
+ case '-':
+ switch(op[i][1]) {
+ case 'b':
+ blitz = 1;
+ if (salvo == 1) {
+ fprintf(stderr,
+ "Bad Arg: -b and -s are mutually exclusive\n");
+ exit(1);
+ }
+ break;
+ case 's':
+ salvo = 1;
+ if (blitz == 1) {
+ fprintf(stderr,
+ "Bad Arg: -s and -b are mutually exclusive\n");
+ exit(1);
+ }
+ break;
+ case 'a':
+ ask = 1;
+ break;
+ case 'm':
+ seemiss = 1;
+ break;
+ default:
+ fprintf(stderr,
+ "Bad Arg: type \"%s ?\" for usage message\n", op[0]);
+ exit(1);
+ }
+ }
+ }
+ fprintf(stdout, "Playing optional game (");
+ if (salvo)
+ fprintf(stdout, "salvo, noblitz, ");
+ else if (blitz)
+ fprintf(stdout, "blitz, nosalvo, ");
+ else
+ fprintf(stdout, "noblitz, nosalvo, ");
+
+ if (ask)
+ fprintf(stdout, "ask, ");
+ else
+ fprintf(stdout, "noask, ");
+
+ if (seemiss)
+ fprintf(stdout, "seemiss)\n");
+ else
+ fprintf(stdout, "noseemiss)\n");
+ }
+ else
+ fprintf(stdout,
+ "Playing standard game (no blitz, no slavo, no ask, no seemiss)\n");
+ sleep(2);
+ return(0);
+}
+
+int
+scount(who)
+int who;
+{
+int i, shots;
+struct _ships *sp;
+
+ if (who) {
+ /* count cpu shots */
+ sp = cpuship;
+ } else {
+ /* count player shots */
+ sp = plyship;
+ }
+ for (i=0, shots = 0; i<5; i++, sp++) {
+ /* extra test for machines with unsigned chars! */
+ if (sp->hits == (char) -1 || sp->hits >= sp->length) {
+ continue; /* dead ship */
+ } else {
+ shots++;
+ }
+ }
+ return(shots);
+}
+
diff --git a/lib/libncurses/TESTS/bs.6 b/lib/libncurses/TESTS/bs.6
new file mode 100644
index 0000000..38cfe82
--- /dev/null
+++ b/lib/libncurses/TESTS/bs.6
@@ -0,0 +1,42 @@
+.TH BATTLESHIPS 6 "Aug 23, 1989"
+.SH NAME
+bs \- battleships game
+.SH SYNOPSIS
+battle [ -b | -s ] [ -c ]
+.SH DESCRIPTION
+This program allows you to play the familiar Battleships game against the
+computer on a 10x10 board. The interface is visual and largely
+self-explanatory; you place your ships and pick your shots by moving the
+cursor around the `sea' with the rogue/hack motion keys hjklyubn.
+.PP
+Note that when selecting a ship to place, you must type the capital letter
+(these are, after all, capital ships). During ship placement, the `r' command
+may be used to ignore the current position and randomly place your currently
+selected ship. The `R' command will place all remaining ships randomly. The ^L
+command (form feed, ASCII 12) will force a screen redraw).
+.PP
+The command-line arguments control game modes.
+
+.nf
+ -b selects a `blitz' variant
+ -s selects a `salvo' variant
+ -c permits ships to be placed adjacently
+.fi
+
+The `blitz' variant allows a side to shoot for as long as it continues to
+score hits.
+.PP
+The `salvo' game allows a player one shot per turn for each of his/her ships
+still afloat. This puts a premium scoring hits early and knocking out some
+ships and also makes much harder the situation where you face a superior force
+with only your PT-boat.
+.PP
+Normally, ships must be separated by at least one square of open water. The
+-c option disables this check and allows them to close-pack.
+.PP
+The algorithm the computer uses once it has found a ship to sink is provably
+optimal. The dispersion criterion for the random-fire algorithm may not be.
+.SH AUTHORS
+Originally written by one Bruce Holloway in 1986. Salvo mode added by Chuck A.
+DeGaul (cbosgd!cad). Visual user interface, `closepack' option, code rewrite
+and manual page by Eric S. Raymond <esr@snark.thyrsus.com> August 1989.
diff --git a/lib/libncurses/TESTS/bs.c b/lib/libncurses/TESTS/bs.c
new file mode 100644
index 0000000..8d41830
--- /dev/null
+++ b/lib/libncurses/TESTS/bs.c
@@ -0,0 +1,1119 @@
+/*
+ * bs.c - original author: Bruce Holloway
+ * salvo option by: Chuck A DeGaul
+ * with improved user interface, autoconfiguration and code cleanup
+ * by Eric S. Raymond <esr@snark.thyrsus.com>
+ * v1.2 with color support and minor portability fixes, November 1990
+ */
+
+#include <stdio.h>
+#include <ncurses.h>
+#include <stdlib.h>
+#ifndef NONPOSIX
+#include <unistd.h>
+#endif
+#include <signal.h>
+#include <string.h>
+#include <sys/time.h>
+#include <ctype.h>
+#include <assert.h>
+
+#ifdef SYSV /* aha, must be an AT&T system... */
+#define srand(n) srand48(n)
+#define rand() lrand48()
+extern long lrand48();
+extern void srand48();
+#define bzero(s, n) memset((char *)(s), '\0', n)
+extern char *memset();
+#endif /* SYSV */
+
+
+/*
+ * Constants for tuning the random-fire algorithm. It prefers moves that
+ * diagonal-stripe the board with a stripe separation of srchstep. If
+ * no such preferred moves are found, srchstep is decremented.
+ */
+#define BEGINSTEP 3 /* initial value of srchstep */
+
+/* miscellaneous constants */
+#define SHIPTYPES 5
+#define OTHER (1-turn)
+#define PLAYER 0
+#define COMPUTER 1
+#define MARK_HIT 'H'
+#define MARK_MISS 'o'
+#define CTRLC '\003' /* used as terminate command */
+#define FF '\014' /* used as redraw command */
+
+/* coordinate handling */
+#define BWIDTH 10
+#define BDEPTH 10
+
+/* display symbols */
+#define SHOWHIT '*'
+#define SHOWSPLASH ' '
+#define IS_SHIP(c) isupper(c)
+
+/* how to position us on player board */
+#define PYBASE 3
+#define PXBASE 3
+#define PY(y) (PYBASE + (y))
+#define PX(x) (PXBASE + (x)*3)
+#define pgoto(y, x) move(PY(y), PX(x))
+
+/* how to position us on cpu board */
+#define CYBASE 3
+#define CXBASE 48
+#define CY(y) (CYBASE + (y))
+#define CX(x) (CXBASE + (x)*3)
+#define cgoto(y, x) move(CY(y), CX(x))
+
+#define ONBOARD(x, y) (x >= 0 && x < BWIDTH && y >= 0 && y < BDEPTH)
+
+/* other board locations */
+#define COLWIDTH 80
+#define PROMPTLINE 21 /* prompt line */
+#define SYBASE CYBASE + BDEPTH + 3 /* move key diagram */
+#define SXBASE 63
+#define MYBASE SYBASE - 1 /* diagram caption */
+#define MXBASE 64
+#define HYBASE SYBASE - 1 /* help area */
+#define HXBASE 0
+
+/* this will need to be changed if BWIDTH changes */
+static char numbers[] = " 0 1 2 3 4 5 6 7 8 9";
+
+static char carrier[] = "Aircraft Carrier";
+static char battle[] = "Battleship";
+static char sub[] = "Submarine";
+static char destroy[] = "Destroyer";
+static char ptboat[] = "PT Boat";
+
+static char name[40];
+static char dftname[] = "Stranger";
+
+/* direction constants */
+#define E 0
+#define SE 1
+#define S 2
+#define SW 3
+#define W 4
+#define NW 5
+#define N 6
+#define NE 7
+static int xincr[8] = {1, 1, 0, -1, -1, -1, 0, 1};
+static int yincr[8] = {0, 1, 1, 1, 0, -1, -1, -1};
+
+/* current ship position and direction */
+static int curx = (BWIDTH / 2);
+static int cury = (BDEPTH / 2);
+
+typedef struct
+{
+ char *name; /* name of the ship type */
+ unsigned hits; /* how many times has this ship been hit? */
+ char symbol; /* symbol for game purposes */
+ char length; /* length of ship */
+ char x, y; /* coordinates of ship start point */
+ int dir; /* direction of `bow' */
+ bool placed; /* has it been placed on the board? */
+}
+ship_t;
+
+ship_t plyship[SHIPTYPES] =
+{
+ { carrier, 0, 'A', 5},
+ { battle, 0, 'B', 4},
+ { destroy, 0, 'D', 3},
+ { sub, 0, 'S', 3},
+ { ptboat, 0, 'P', 2},
+};
+
+ship_t cpuship[SHIPTYPES] =
+{
+ { carrier, 0, 'A', 5},
+ { battle, 0, 'B', 4},
+ { destroy, 0, 'D', 3},
+ { sub, 0, 'S', 3},
+ { ptboat, 0, 'P', 2},
+};
+
+/* "Hits" board, and main board. */
+static char hits[2][BWIDTH][BDEPTH], board[2][BWIDTH][BDEPTH];
+
+static int turn; /* 0=player, 1=computer */
+static int plywon=0, cpuwon=0; /* How many games has each won? */
+
+static int salvo, blitz, closepack;
+
+#define PR addstr
+
+static int rnd(int);
+static int checkplace(int, ship_t *, int);
+static int getcoord(int);
+
+static void uninitgame()
+/* end the game, either normally or due to signal */
+{
+ clear();
+ refresh();
+ resetterm();
+ echo();
+ endwin();
+ exit(0);
+}
+
+static void announceopts()
+/* announce which game options are enabled */
+{
+ if (salvo || blitz || closepack) {
+ printw("Playing optional game (");
+ if (salvo)
+ printw("salvo, ");
+ else
+ printw("nosalvo, ");
+ if (blitz)
+ printw("blitz ");
+ else
+ printw("noblitz, ");
+ if (closepack)
+ printw("closepack)");
+ else
+ printw("noclosepack)");
+ }
+ else
+ printw( "Playing standard game (noblitz, nosalvo, noclosepack)");
+
+}
+
+static void intro()
+{
+char *tmpname;
+
+ srand(time(0L)+getpid()); /* Kick the random number generator */
+
+ signal(SIGINT,uninitgame);
+ signal(SIGINT,uninitgame);
+ signal(SIGIOT,uninitgame); /* for assert(3) */
+ if(signal(SIGQUIT,SIG_IGN) != SIG_IGN)
+ signal(SIGQUIT,uninitgame);
+
+ if ((tmpname = getlogin()) != NULL)
+ strcpy(name,tmpname);
+ else
+ strcpy(name,dftname);
+ name[0] = toupper(name[0]);
+
+ initscr();
+ saveterm();
+ nonl();
+ cbreak();
+ noecho();
+
+#ifdef PENGUIN
+ clear();
+ mvaddstr(4,29,"Welcome to Battleship!");
+ move(8,0);
+ PR(" \\\n");
+ PR(" \\ \\ \\\n");
+ PR(" \\ \\ \\ \\ \\_____________\n");
+ PR(" \\ \\ \\_____________ \\ \\/ |\n");
+ PR(" \\ \\/ \\ \\/ |\n");
+ PR(" \\/ \\_____/ |__\n");
+ PR(" ________________/ |\n");
+ PR(" \\ S.S. Penguin |\n");
+ PR(" \\ /\n");
+ PR(" \\___________________________________________________/\n");
+
+ mvaddstr(22,27,"Hit any key to continue..."); refresh();
+ getch();
+#endif /* PENGUIN */
+
+ clear();
+ mvaddstr(0,35,"BATTLESHIPS");
+ move(PROMPTLINE + 2, 0);
+ announceopts();
+
+ mvaddstr(MYBASE, MXBASE, "Aiming keys:");
+ mvaddstr(SYBASE, SXBASE, "y k u 7 8 9");
+ mvaddstr(SYBASE+1, SXBASE, " \\|/ \\|/ ");
+ mvaddstr(SYBASE+2, SXBASE, "h-+-l 4-+-6");
+ mvaddstr(SYBASE+3, SXBASE, " /|\\ /|\\ ");
+ mvaddstr(SYBASE+4, SXBASE, "b j n 1 2 3");
+}
+
+/* VARARGS1 */
+static void prompt(n, f, s)
+/* print a message at the prompt line */
+int n;
+char *f, *s;
+{
+ move(PROMPTLINE + n, 0);
+ clrtoeol();
+ printw(f, s);
+ refresh();
+}
+
+static void error(s)
+char *s;
+{
+ move(PROMPTLINE + 2, 0);
+ clrtoeol();
+ if (s) {
+ addstr(s);
+ beep();
+ }
+}
+
+static void placeship(b, ss, vis)
+int b;
+ship_t *ss;
+int vis;
+{
+int l;
+
+ for(l = 0; l < ss->length; ++l) {
+ int newx = ss->x + l * xincr[ss->dir];
+ int newy = ss->y + l * yincr[ss->dir];
+
+ board[b][newx][newy] = ss->symbol;
+ if (vis) {
+ pgoto(newy, newx);
+ addch((chtype)ss->symbol);
+ }
+ }
+ ss->hits = 0;
+}
+
+static void randomplace(b, ss)
+/* generate a valid random ship placement into px,py */
+int b;
+ship_t *ss;
+{
+register int bwidth = BWIDTH - ss->length;
+register int bdepth = BDEPTH - ss->length;
+
+ do {
+ ss->y = rnd(bdepth);
+ ss->x = rnd(bwidth);
+ ss->dir = rnd(2) ? E : S;
+ } while
+ (!checkplace(b, ss, FALSE));
+}
+
+static void initgame()
+{
+int i, j, unplaced;
+ship_t *ss;
+
+#ifdef A_COLOR
+ start_color();
+
+ init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK);
+ init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK);
+ init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK);
+ init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK);
+ init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK);
+ init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
+ init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK);
+ init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK);
+#endif /* A_COLOR */
+
+ bzero(board, sizeof(char) * BWIDTH * BDEPTH * 2);
+ bzero(hits, sizeof(char) * BWIDTH * BDEPTH * 2);
+ for (i = 0; i < SHIPTYPES; i++) {
+ ss = cpuship + i;
+ ss->x = ss->y = ss->dir = ss->hits = ss->placed = 0;
+ ss = plyship + i;
+ ss->x = ss->y = ss->dir = ss->hits = ss->placed = 0;
+ }
+
+ /* draw empty boards */
+ mvaddstr(PYBASE - 2, PXBASE + 5, "Main Board");
+ mvaddstr(PYBASE - 1, PXBASE - 3,numbers);
+ for(i=0; i < BDEPTH; ++i) {
+ mvaddch(PYBASE + i, PXBASE - 3, i + 'A');
+#ifdef A_COLOR
+ if (has_colors())
+ attron(COLOR_PAIR(COLOR_BLUE));
+#endif /* A_COLOR */
+ addch(' ');
+ for (j = 0; j < BWIDTH; j++)
+ addstr(" . ");
+#ifdef A_COLOR
+ attrset(0);
+#endif /* A_COLOR */
+ addch(' ');
+ addch(i + 'A');
+ }
+ mvaddstr(PYBASE + BDEPTH, PXBASE - 3,numbers);
+ mvaddstr(CYBASE - 2, CXBASE + 7,"Hit/Miss Board");
+ mvaddstr(CYBASE - 1, CXBASE - 3, numbers);
+ for(i=0; i < BDEPTH; ++i) {
+ mvaddch(CYBASE + i, CXBASE - 3, i + 'A');
+#ifdef A_COLOR
+ if (has_colors())
+ attron(COLOR_PAIR(COLOR_BLUE));
+#endif /* A_COLOR */
+ addch(' ');
+ for (j = 0; j < BWIDTH; j++)
+ addstr(" . ");
+#ifdef A_COLOR
+ attrset(0);
+#endif /* A_COLOR */
+ addch(' ');
+ addch(i + 'A');
+ }
+ mvaddstr(CYBASE + BDEPTH,CXBASE - 3,numbers);
+
+ mvprintw(HYBASE, HXBASE,
+ "To position your ships: move the cursor to a spot, then");
+ mvprintw(HYBASE+1,HXBASE,
+ "type the first letter of a ship type to select it, then");
+ mvprintw(HYBASE+2,HXBASE,
+ "type a direction ([hjkl] or [4862]), indicating how the");
+ mvprintw(HYBASE+3,HXBASE,
+ "ship should be pointed. You may also type a ship letter");
+ mvprintw(HYBASE+4,HXBASE,
+ "followed by `r' to position it randomly, or type `R' to");
+ mvprintw(HYBASE+5,HXBASE,
+ "place all remaining ships randomly.");
+
+ /* have the computer place ships */
+ for(ss = cpuship; ss < cpuship + SHIPTYPES; ss++) {
+ randomplace(COMPUTER, ss);
+ placeship(COMPUTER, ss, FALSE);
+ }
+
+ ss = (ship_t *)NULL;
+ do {
+ char c, docked[SHIPTYPES + 2], *cp = docked;
+
+ /* figure which ships still wait to be placed */
+ *cp++ = 'R';
+ for (i = 0; i < SHIPTYPES; i++)
+ if (!plyship[i].placed)
+ *cp++ = plyship[i].symbol;
+ *cp = '\0';
+
+ /* get a command letter */
+ prompt(1, "Type one of [%s] to pick a ship.", docked+1);
+ do {
+ c = getcoord(PLAYER);
+ } while
+ (!strchr(docked, c));
+
+ if (c == 'R')
+ ungetch('R');
+ else
+ {
+ /* map that into the corresponding symbol */
+ for (ss = plyship; ss < plyship + SHIPTYPES; ss++)
+ if (ss->symbol == c)
+ break;
+
+ prompt(1, "Type one of [hjklrR] to place your %s.", ss->name);
+ pgoto(cury, curx);
+ }
+
+ do {
+ c = getch();
+ } while
+ (!strchr("hjklrR", c) || c == FF);
+
+ if (c == FF) {
+ clearok(stdscr, TRUE);
+ refresh();
+ } else if (c == 'r') {
+ prompt(1, "Random-placing your %s", ss->name);
+ randomplace(PLAYER, ss);
+ placeship(PLAYER, ss, TRUE);
+ error((char *)NULL);
+ ss->placed = TRUE;
+ } else if (c == 'R') {
+ prompt(1, "Placing the rest of your fleet at random...");
+ for (ss = plyship; ss < plyship + SHIPTYPES; ss++)
+ if (!ss->placed) {
+ randomplace(PLAYER, ss);
+ placeship(PLAYER, ss, TRUE);
+ ss->placed = TRUE;
+ }
+ error((char *)NULL);
+ } else if (strchr("hjkl8462", c)) {
+ ss->x = curx;
+ ss->y = cury;
+
+ switch(c) {
+ case 'k': case '8': ss->dir = N; break;
+ case 'j': case '2': ss->dir = S; break;
+ case 'h': case '4': ss->dir = W; break;
+ case 'l': case '6': ss->dir = E; break;
+ }
+
+ if (checkplace(PLAYER, ss, TRUE)) {
+ placeship(PLAYER, ss, TRUE);
+ error((char *)NULL);
+ ss->placed = TRUE;
+ }
+ }
+
+ for (unplaced = i = 0; i < SHIPTYPES; i++)
+ unplaced += !plyship[i].placed;
+ } while
+ (unplaced);
+
+ turn = rnd(2);
+
+ mvprintw(HYBASE, HXBASE,
+ "To fire, move the cursor to your chosen aiming point ");
+ mvprintw(HYBASE+1, HXBASE,
+ "and strike any key other than a motion key. ");
+ mvprintw(HYBASE+2, HXBASE,
+ " ");
+ mvprintw(HYBASE+3, HXBASE,
+ " ");
+ mvprintw(HYBASE+4, HXBASE,
+ " ");
+ mvprintw(HYBASE+5, HXBASE,
+ " ");
+
+ prompt(0, "Press any key to start...");
+ getch();
+}
+
+static int rnd(n)
+int n;
+{
+ return(((rand() & 0x7FFF) % n));
+}
+
+static int getcoord(atcpu)
+int atcpu;
+{
+int ny, nx, c;
+
+ if (atcpu)
+ cgoto(cury,curx);
+ else
+ pgoto(cury, curx);
+ refresh();
+ for (;;) {
+ if (atcpu) {
+ mvprintw(CYBASE + BDEPTH+1, CXBASE+11, "(%d, %c)", curx, 'A'+cury);
+ cgoto(cury, curx);
+ } else {
+ mvprintw(PYBASE + BDEPTH+1, PXBASE+11, "(%d, %c)", curx, 'A'+cury);
+ pgoto(cury, curx);
+ }
+
+ switch(c = getch()) {
+ case 'k': case '8': ny = cury+BDEPTH-1; nx = curx; break;
+ case 'j': case '2': ny = cury+1; nx = curx; break;
+ case 'h': case '4': ny = cury; nx = curx+BWIDTH-1; break;
+ case 'l': case '6': ny = cury; nx = curx+1; break;
+ case 'y': case '7': ny = cury+BDEPTH-1; nx = curx+BWIDTH-1; break;
+ case 'b': case '1': ny = cury+1; nx = curx+BWIDTH-1; break;
+ case 'u': case '9': ny = cury+BDEPTH-1; nx = curx+1; break;
+ case 'n': case '3': ny = cury+1; nx = curx+1; break;
+ case FF:
+ nx = curx; ny = cury;
+ clearok(stdscr, TRUE);
+ refresh();
+ break;
+ default:
+ if (atcpu)
+ mvaddstr(CYBASE + BDEPTH + 1, CXBASE + 11, " ");
+ else
+ mvaddstr(PYBASE + BDEPTH + 1, PXBASE + 11, " ");
+ return(c);
+ }
+
+ curx = nx % BWIDTH;
+ cury = ny % BDEPTH;
+ }
+}
+
+static int collidecheck(b, y, x)
+/* is this location on the selected zboard adjacent to a ship? */
+int b;
+int y, x;
+{
+int collide;
+
+ /* anything on the square */
+ if ((collide = IS_SHIP(board[b][x][y])) != 0)
+ return(collide);
+
+ /* anything on the neighbors */
+ if (!closepack) {
+ int i;
+
+ for (i = 0; i < 8; i++) {
+ int xend, yend;
+
+ yend = y + yincr[i];
+ xend = x + xincr[i];
+ if (ONBOARD(xend, yend))
+ collide += IS_SHIP(board[b][xend][yend]);
+ }
+ }
+ return(collide);
+}
+
+static int checkplace(b, ss, vis)
+int b;
+ship_t *ss;
+int vis;
+{
+ int l, xend, yend;
+
+ /* first, check for board edges */
+ xend = ss->x + ss->length * xincr[ss->dir];
+ yend = ss->y + ss->length * yincr[ss->dir];
+ if (!ONBOARD(xend, yend)) {
+ if(vis)
+ switch(rnd(3)) {
+ case 0:
+ error("Ship is hanging from the edge of the world");
+ break;
+ case 1:
+ error("Try fitting it on the board");
+ break;
+ case 2:
+ error("Figure I won't find it if you put it there?");
+ break;
+ }
+ return(0);
+ }
+
+ for(l = 0; l < ss->length; ++l) {
+ if (collidecheck(b, ss->y+l*yincr[ss->dir], ss->x+l*xincr[ss->dir])) {
+ if (vis)
+ switch(rnd(3)) {
+ case 0:
+ error("There's already a ship there");
+ break;
+ case 1:
+ error("Collision alert! Aaaaaagh!");
+ break;
+ case 2:
+ error("Er, Admiral, what about the other ship?");
+ break;
+ }
+ return(0);
+ }
+ }
+ return(1);
+}
+
+static int awinna()
+{
+int i, j;
+ship_t *ss;
+
+ for (i = 0; i < 2; ++i) {
+ ss = (i) ? cpuship : plyship;
+ for (j = 0; j < SHIPTYPES; ++j, ++ss)
+ if (ss->length > ss->hits)
+ break;
+ if (j == SHIPTYPES)
+ return(OTHER);
+ }
+ return(-1);
+}
+
+static ship_t *hitship(x, y)
+/* register a hit on the targeted ship */
+int x, y;
+{
+ ship_t *sb, *ss;
+ char sym;
+ int oldx, oldy;
+
+ getyx(stdscr, oldy, oldx);
+ sb = (turn) ? plyship : cpuship;
+ if(!(sym = board[OTHER][x][y]))
+ return((ship_t *)NULL);
+ for(ss = sb; ss < sb + SHIPTYPES; ++ss)
+ if(ss->symbol == sym)
+ {
+ if (++ss->hits < ss->length) /* still afloat? */
+ return((ship_t *)NULL);
+ else /* sunk! */
+ {
+ int i, j;
+
+ if (!closepack)
+ for (j = -1; j <= 1; j++)
+ {
+ int bx = ss->x + j * xincr[(ss->dir + 2) % 8];
+ int by = ss->y + j * yincr[(ss->dir + 2) % 8];
+
+ for (i = -1; i <= ss->length; ++i)
+ {
+ int x, y;
+
+ x = bx + i * xincr[ss->dir];
+ y = by + i * yincr[ss->dir];
+ if (ONBOARD(x, y))
+ {
+ hits[turn][x][y] = MARK_MISS;
+ if (turn % 2 == PLAYER)
+ {
+ cgoto(y, x);
+#ifdef A_COLOR
+ if (has_colors())
+ attron(COLOR_PAIR(COLOR_GREEN));
+#endif /* A_COLOR */
+ addch(MARK_MISS);
+#ifdef A_COLOR
+ attrset(0);
+#endif /* A_COLOR */
+ }
+ }
+ }
+ }
+
+ for (i = 0; i < ss->length; ++i)
+ {
+ int x = ss->x + i * xincr[ss->dir];
+ int y = ss->y + i * yincr[ss->dir];
+
+ hits[turn][x][y] = ss->symbol;
+ if (turn % 2 == PLAYER)
+ {
+ cgoto(y, x);
+ addch(ss->symbol);
+ }
+ }
+
+ move(oldy, oldx);
+ return(ss);
+ }
+ }
+ move(oldy, oldx);
+ return((ship_t *)NULL);
+}
+
+static int plyturn()
+{
+ship_t *ss;
+bool hit;
+char *m;
+
+ prompt(1, "Where do you want to shoot? ");
+ for (;;) {
+ getcoord(COMPUTER);
+ if (hits[PLAYER][curx][cury]) {
+ prompt(1, "You shelled this spot already! Try again.");
+ beep();
+ } else
+ break;
+ }
+ hit = IS_SHIP(board[COMPUTER][curx][cury]);
+ hits[PLAYER][curx][cury] = hit ? MARK_HIT : MARK_MISS;
+ cgoto(cury, curx);
+#ifdef A_COLOR
+ if (has_colors())
+ if (hit)
+ attron(COLOR_PAIR(COLOR_RED));
+ else
+ attron(COLOR_PAIR(COLOR_GREEN));
+#endif /* A_COLOR */
+ addch((chtype)hits[PLAYER][curx][cury]);
+#ifdef A_COLOR
+ attrset(0);
+#endif /* A_COLOR */
+
+ prompt(1, "You %s.", hit ? "scored a hit" : "missed");
+ if(hit && (ss = hitship(curx, cury))) {
+ switch(rnd(5)) {
+ case 0:
+ m = " You sank my %s!";
+ break;
+ case 1:
+ m = " I have this sinking feeling about my %s....";
+ break;
+ case 2:
+ m = " My %s has gone to Davy Jones's locker!";
+ break;
+ case 3:
+ m = " Glub, glub -- my %s is headed for the bottom!";
+ break;
+ case 4:
+ m = " You'll pick up survivors from my my %s, I hope...!";
+ break;
+ }
+ printw(m, ss->name);
+ beep();
+ return(awinna() == -1);
+ }
+ return(hit);
+}
+
+static int sgetc(s)
+char *s;
+{
+char *s1;
+int ch;
+
+ refresh();
+ for(;;) {
+ ch = getch();
+ if (islower(ch))
+ ch = toupper(ch);
+ if (ch == CTRLC)
+ uninitgame();
+ for (s1=s; *s1 && ch != *s1; ++s1)
+ continue;
+ if (*s1) {
+ addch((chtype)ch);
+ refresh();
+ return(ch);
+ }
+ }
+}
+
+
+static void randomfire(px, py)
+/* random-fire routine -- implements simple diagonal-striping strategy */
+int *px, *py;
+{
+static int turncount = 0;
+static int srchstep = BEGINSTEP;
+static int huntoffs; /* Offset on search strategy */
+int ypossible[BWIDTH * BDEPTH], xpossible[BWIDTH * BDEPTH], nposs;
+int ypreferred[BWIDTH * BDEPTH], xpreferred[BWIDTH * BDEPTH], npref;
+int x, y, i;
+
+ if (turncount++ == 0)
+ huntoffs = rnd(srchstep);
+
+ /* first, list all possible moves */
+ nposs = npref = 0;
+ for (x = 0; x < BWIDTH; x++)
+ for (y = 0; y < BDEPTH; y++)
+ if (!hits[COMPUTER][x][y]) {
+ xpossible[nposs] = x;
+ ypossible[nposs] = y;
+ nposs++;
+ if (((x+huntoffs) % srchstep) != (y % srchstep)) {
+ xpreferred[npref] = x;
+ ypreferred[npref] = y;
+ npref++;
+ }
+ }
+
+ if (npref) {
+ i = rnd(npref);
+
+ *px = xpreferred[i];
+ *py = ypreferred[i];
+ } else if (nposs) {
+ i = rnd(nposs);
+
+ *px = xpossible[i];
+ *py = ypossible[i];
+
+ if (srchstep > 1)
+ --srchstep;
+ } else {
+ error("No moves possible?? Help!");
+ exit(1);
+ /*NOTREACHED*/
+ }
+}
+
+#define S_MISS 0
+#define S_HIT 1
+#define S_SUNK -1
+
+static bool cpufire(x, y)
+/* fire away at given location */
+int x, y;
+{
+bool hit, sunk;
+ship_t *ss;
+
+ hits[COMPUTER][x][y] = (hit = (board[PLAYER][x][y])) ? MARK_HIT : MARK_MISS;
+ mvprintw(PROMPTLINE, 0,
+ "I shoot at %c%d. I %s!", y + 'A', x, hit ? "hit" : "miss");
+ if ((sunk = (hit && (ss = hitship(x, y)))) != 0)
+ printw(" I've sunk your %s", ss->name);
+ clrtoeol();
+
+ pgoto(y, x);
+#ifdef A_COLOR
+ if (has_colors())
+ if (hit)
+ attron(COLOR_PAIR(COLOR_RED));
+ else
+ attron(COLOR_PAIR(COLOR_GREEN));
+#endif /* A_COLOR */
+ addch((chtype)(hit ? SHOWHIT : SHOWSPLASH));
+#ifdef A_COLOR
+ attrset(0);
+#endif /* A_COLOR */
+
+ return(hit ? (sunk ? S_SUNK : S_HIT) : S_MISS);
+}
+
+/*
+ * This code implements a fairly irregular FSM, so please forgive the rampant
+ * unstructuredness below. The five labels are states which need to be held
+ * between computer turns.
+ */
+static bool cputurn()
+{
+#define POSSIBLE(x, y) (ONBOARD(x, y) && !hits[COMPUTER][x][y])
+#define RANDOM_FIRE 0
+#define RANDOM_HIT 1
+#define HUNT_DIRECT 2
+#define FIRST_PASS 3
+#define REVERSE_JUMP 4
+#define SECOND_PASS 5
+ static int next = RANDOM_FIRE;
+ static bool used[4];
+ static ship_t ts;
+ int navail, x, y, d, n, hit = S_MISS;
+
+ switch(next) {
+ case RANDOM_FIRE: /* last shot was random and missed */
+ refire:
+ randomfire(&x, &y);
+ if (!(hit = cpufire(x, y)))
+ next = RANDOM_FIRE;
+ else {
+ ts.x = x; ts.y = y;
+ ts.hits = 1;
+ next = (hit == S_SUNK) ? RANDOM_FIRE : RANDOM_HIT;
+ }
+ break;
+
+ case RANDOM_HIT: /* last shot was random and hit */
+ used[E/2] = used[S/2] = used[W/2] = used[N/2] = FALSE;
+ /* FALLTHROUGH */
+
+ case HUNT_DIRECT: /* last shot hit, we're looking for ship's long axis */
+ for (d = navail = 0; d < 4; d++) {
+ x = ts.x + xincr[d*2]; y = ts.y + yincr[d*2];
+ if (!used[d] && POSSIBLE(x, y))
+ navail++;
+ else
+ used[d] = TRUE;
+ }
+ if (navail == 0) /* no valid places for shots adjacent... */
+ goto refire; /* ...so we must random-fire */
+ else {
+ for (d = 0, n = rnd(navail) + 1; n; n--)
+ while (used[d])
+ d++;
+
+ assert(d <= 4);
+
+ used[d] = FALSE;
+ x = ts.x + xincr[d*2];
+ y = ts.y + yincr[d*2];
+
+ assert(POSSIBLE(x, y));
+
+ if (!(hit = cpufire(x, y)))
+ next = HUNT_DIRECT;
+ else
+ {
+ ts.x = x; ts.y = y; ts.dir = d*2; ts.hits++;
+ next = (hit == S_SUNK) ? RANDOM_FIRE : FIRST_PASS;
+ }
+ }
+ break;
+
+ case FIRST_PASS: /* we have a start and a direction now */
+ x = ts.x + xincr[ts.dir];
+ y = ts.y + yincr[ts.dir];
+ if (POSSIBLE(x, y) && (hit = cpufire(x, y))) {
+ ts.x = x; ts.y = y; ts.hits++;
+ next = (hit == S_SUNK) ? RANDOM_FIRE : FIRST_PASS;
+ }
+ else
+ next = REVERSE_JUMP;
+ break;
+
+ case REVERSE_JUMP: /* nail down the ship's other end */
+ d = ts.dir + 4;
+ x = ts.x + ts.hits * xincr[d];
+ y = ts.y + ts.hits * yincr[d];
+ if (POSSIBLE(x, y) && (hit = cpufire(x, y))) {
+ ts.x = x; ts.y = y; ts.dir = d; ts.hits++;
+ next = (hit == S_SUNK) ? RANDOM_FIRE : SECOND_PASS;
+ }
+ else
+ next = RANDOM_FIRE;
+ break;
+
+ case SECOND_PASS: /* kill squares not caught on first pass */
+ x = ts.x + xincr[ts.dir];
+ y = ts.y + yincr[ts.dir];
+ if (POSSIBLE(x, y) && (hit = cpufire(x, y))) {
+ ts.x = x; ts.y = y; ts.hits++;
+ next = (hit == S_SUNK) ? RANDOM_FIRE: SECOND_PASS;
+ break;
+ } else
+ next = RANDOM_FIRE;
+ break;
+ }
+
+ /* check for continuation and/or winner */
+ if (salvo) {
+ refresh();
+ sleep(1);
+ }
+ if (awinna() != -1)
+ return(FALSE);
+
+#ifdef DEBUG
+ mvprintw(PROMPTLINE + 2, 0, "New state %d, x=%d, y=%d, d=%d",
+ next, x, y, d);
+#endif /* DEBUG */
+ return(hit);
+}
+
+int
+playagain()
+{
+int j;
+ship_t *ss;
+
+ for (ss = cpuship; ss < cpuship + SHIPTYPES; ss++)
+ for(j = 0; j < ss->length; j++) {
+ cgoto(ss->y + j * yincr[ss->dir], ss->x + j * xincr[ss->dir]);
+ addch((chtype)ss->symbol);
+ }
+
+ if (awinna())
+ ++cpuwon;
+ else
+ ++plywon;
+ j = 18 + strlen(name);
+ if(plywon >= 10)
+ ++j;
+ if(cpuwon >= 10)
+ ++j;
+ mvprintw(1,(COLWIDTH-j)/2, "%s: %d Computer: %d",name,plywon,cpuwon);
+
+ prompt(2, (awinna()) ? "Want to be humiliated again, %s [yn]? "
+ : "Going to give me a chance for revenge, %s [yn]? ",name);
+ return(sgetc("YN") == 'Y');
+}
+
+static void do_options(c,op)
+int c;
+char *op[];
+{
+register int i;
+
+ if (c > 1) {
+ for (i=1; i<c; i++) {
+ switch(op[i][0]) {
+ default:
+ case '?':
+ fprintf(stderr, "Usage: battle [-s | -b] [-c]\n");
+ fprintf(stderr, "\tWhere the options are:\n");
+ fprintf(stderr, "\t-s : play a salvo game\n");
+ fprintf(stderr, "\t-b : play a blitz game\n");
+ fprintf(stderr, "\t-c : ships may be adjacent\n");
+ exit(1);
+ break;
+ case '-':
+ switch(op[i][1]) {
+ case 'b':
+ blitz = 1;
+ if (salvo == 1) {
+ fprintf(stderr,
+ "Bad Arg: -b and -s are mutually exclusive\n");
+ exit(1);
+ }
+ break;
+ case 's':
+ salvo = 1;
+ if (blitz == 1)
+ {
+ fprintf(stderr,
+ "Bad Arg: -s and -b are mutually exclusive\n");
+ exit(1);
+ }
+ break;
+ case 'c':
+ closepack = 1;
+ break;
+ default:
+ fprintf(stderr,
+ "Bad arg: type \"%s ?\" for usage message\n", op[0]);
+ exit(1);
+ }
+ }
+ }
+ }
+}
+
+static int scount(who)
+int who;
+{
+register int i, shots;
+register ship_t *sp;
+
+ if (who)
+ sp = cpuship; /* count cpu shots */
+ else
+ sp = plyship; /* count player shots */
+
+ for (i=0, shots = 0; i < SHIPTYPES; i++, sp++) {
+ if (sp->hits >= sp->length)
+ continue; /* dead ship */
+ else
+ shots++;
+ }
+ return(shots);
+}
+
+int
+main(argc, argv)
+int argc;
+char *argv[];
+{
+ do_options(argc, argv);
+
+ intro();
+ do {
+ initgame();
+ while(awinna() == -1) {
+ if (!blitz) {
+ if (!salvo) {
+ if(turn)
+ cputurn();
+ else
+ plyturn();
+ } else {
+ register int i;
+
+ i = scount(turn);
+ while (i--) {
+ if (turn) {
+ if (cputurn() && awinna() != -1)
+ i = 0;
+ } else {
+ if (plyturn() && awinna() != -1)
+ i = 0;
+ }
+ }
+ }
+ } else
+ while(turn ? cputurn() : plyturn())
+ continue;
+ turn = OTHER;
+ }
+ } while (playagain());
+ uninitgame();
+ /*NOTREACHED*/
+}
+
+/* bs.c ends here */
diff --git a/lib/libncurses/TESTS/copy.c b/lib/libncurses/TESTS/copy.c
new file mode 100644
index 0000000..6ded258
--- /dev/null
+++ b/lib/libncurses/TESTS/copy.c
@@ -0,0 +1,39 @@
+#include <ncurses.h>
+
+main()
+{
+WINDOW *win1, *win2;
+int h, i;
+
+ initscr();
+ cbreak();
+ noecho();
+ win1 = newwin(20, 50, 0, 20);
+ for (h = 0; h < 20; h++)
+ for (i = 0; i < 50; i++)
+ mvwaddch(win1, h, i, 'X');
+ wrefresh(win1);
+ getch();
+
+ win2 = newwin(20, 50, 3, 30);
+ for (h = 0; h < 20; h++)
+ for (i = 0; i < 50; i++)
+ mvwaddch(win2, h, i, 'Y');
+ wnoutrefresh(win1);
+ wnoutrefresh(win2);
+ doupdate();
+ getch();
+
+ /* now, remove window 2 and restore the contents of window 1 */
+ i = copywin(win1, win2, 5, 10, 0, 0, 14, 39, 0);
+ wnoutrefresh(win1);
+ wnoutrefresh(win2);
+ printw("copywin returns %d\n", i);
+ wnoutrefresh(stdscr);
+ doupdate();
+
+ getch();
+
+ endwin();
+}
+
diff --git a/lib/libncurses/TESTS/corner.c b/lib/libncurses/TESTS/corner.c
new file mode 100644
index 0000000..2ab38a9
--- /dev/null
+++ b/lib/libncurses/TESTS/corner.c
@@ -0,0 +1,16 @@
+#include <ncurses.h>
+
+int main()
+{
+int i, j;
+
+ initscr();
+
+ for (i = 0; i < LINES; i++) {
+ j = mvaddch(i, COLS - 1, 'A' + i);
+ }
+ refresh();
+ endwin();
+ exit(0);
+}
+
diff --git a/lib/libncurses/TESTS/ensor.c b/lib/libncurses/TESTS/ensor.c
new file mode 100644
index 0000000..7ace038
--- /dev/null
+++ b/lib/libncurses/TESTS/ensor.c
@@ -0,0 +1,52 @@
+#include <ncurses.h>
+
+main()
+{
+ int i;
+ WINDOW *win;
+
+ initscr();
+ noecho();
+ nonl();
+ cbreak();
+
+ scrollok(stdscr, TRUE);
+
+ for (i=0; i<25; i++)
+ printw("This is in the background, this should be left alone!\n");
+
+ refresh();
+ win=newwin(10,50,6,20);
+ scrollok(win,TRUE);
+ wmove(win,0,0);
+ whline(win,0,49);
+ wmove(win,9,0);
+ whline(win,0,49);
+ wrefresh(win);
+ wattrset(win,A_STANDOUT);
+ mvwprintw(win, 0, 14, " Scrolling Demo! ");
+ mvwprintw(win, 9, 14, " Scrolling Demo! ");
+ wattroff(win,A_STANDOUT);
+ wsetscrreg(win, 1,8);
+
+ mvwprintw(win, 0, 5, " DOWN ");
+ wmove(win,1,0);
+ wrefresh(win);
+
+ getch();
+ for (i=0; i<25; i++){ wprintw(win, "This is window line test (%d).\n", i);
+ if (i%2) wattrset(win,A_BOLD); else wattroff(win,A_BOLD);
+ wrefresh(win); }
+
+ mvwprintw(win, 0, 5, " UP ");
+ wrefresh(win);
+ getch();
+ for (i=0; i<25; i++) { wmove(win,1,0); winsertln(win);
+ if (i%2) wattrset(win,A_BOLD); else wattroff(win,A_BOLD);
+ wprintw(win, "Scrolling backwards! (%d)\n", i); wrefresh(win); }
+
+ mvwprintw(win, 0, 5, " DONE "); wrefresh(win);
+
+ endwin();
+}
+
diff --git a/lib/libncurses/TESTS/firework.c b/lib/libncurses/TESTS/firework.c
new file mode 100644
index 0000000..b497584
--- /dev/null
+++ b/lib/libncurses/TESTS/firework.c
@@ -0,0 +1,113 @@
+#include <stdio.h>
+#include <signal.h>
+#include <ncurses.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <time.h>
+
+void explode();
+
+int main()
+{
+int start,end,row,diff,flag,direction,seed;
+
+ initscr();
+ if (has_colors())
+ start_color();
+ seed = time((time_t *)0);
+ srand(seed);
+ cbreak();
+ for (;;) {
+ do {
+ start = rand() % (COLS -3);
+ end = rand() % (COLS - 3);
+ start = (start < 2) ? 2 : start;
+ end = (end < 2) ? 2 : end;
+ direction = (start > end) ? -1 : 1;
+ diff = abs(start-end);
+ } while (diff<2 || diff>=LINES-2);
+ attrset(A_NORMAL);
+ for (row=0;row<diff;row++) {
+ mvprintw(LINES - row,start + (row * direction),
+ (direction < 0) ? "\\" : "/");
+ if (flag++) {
+ refresh();
+ erase();
+ flag = 0;
+ }
+ }
+ if (flag++) {
+ refresh();
+ flag = 0;
+ }
+ seed = time((time_t *)0);
+ srand(seed);
+ explode(LINES-row,start+(diff*direction));
+ erase();
+ refresh();
+ }
+ endwin();
+ exit(0);
+}
+
+void explode(int row, int col)
+{
+ erase();
+ mvprintw(row,col,"-");
+ refresh();
+
+ init_pair(1,get_colour(),COLOR_BLACK);
+ attrset(COLOR_PAIR(1));
+ mvprintw(row-1,col-1," - ");
+ mvprintw(row,col-1,"-+-");
+ mvprintw(row+1,col-1," - ");
+ refresh();
+
+ init_pair(1,get_colour(),COLOR_BLACK);
+ attrset(COLOR_PAIR(1));
+ mvprintw(row-2,col-2," --- ");
+ mvprintw(row-1,col-2,"-+++-");
+ mvprintw(row, col-2,"-+#+-");
+ mvprintw(row+1,col-2,"-+++-");
+ mvprintw(row+2,col-2," --- ");
+ refresh();
+
+ init_pair(1,get_colour(),COLOR_BLACK);
+ attrset(COLOR_PAIR(1));
+ mvprintw(row-2,col-2," +++ ");
+ mvprintw(row-1,col-2,"++#++");
+ mvprintw(row, col-2,"+# #+");
+ mvprintw(row+1,col-2,"++#++");
+ mvprintw(row+2,col-2," +++ ");
+ refresh();
+
+ init_pair(1,get_colour(),COLOR_BLACK);
+ attrset(COLOR_PAIR(1));
+ mvprintw(row-2,col-2," # ");
+ mvprintw(row-1,col-2,"## ##");
+ mvprintw(row, col-2,"# #");
+ mvprintw(row+1,col-2,"## ##");
+ mvprintw(row+2,col-2," # ");
+ refresh();
+
+ init_pair(1,get_colour(),COLOR_BLACK);
+ attrset(COLOR_PAIR(1));
+ mvprintw(row-2,col-2," # # ");
+ mvprintw(row-1,col-2,"# #");
+ mvprintw(row, col-2," ");
+ mvprintw(row+1,col-2,"# #");
+ mvprintw(row+2,col-2," # # ");
+ refresh();
+ return;
+}
+
+int get_colour()
+{
+ int attr;
+ attr = (rand() % 16)+1;
+ if (attr == 1 || attr == 9)
+ attr = COLOR_RED;
+ if (attr > 8)
+ attr |= A_BOLD;
+ return(attr);
+}
diff --git a/lib/libncurses/TESTS/gdc.6 b/lib/libncurses/TESTS/gdc.6
new file mode 100644
index 0000000..7fa60de
--- /dev/null
+++ b/lib/libncurses/TESTS/gdc.6
@@ -0,0 +1,22 @@
+.TH GDC 6
+.SH NAME
+gdc \- grand digital clock (curses)
+.SH SYNOPSIS
+.B gdc
+[-s] [
+.I n
+]
+.SH DESCRIPTION
+.I Gdc
+runs a digital clock made of reverse-video blanks on a curses
+compatible VDU screen. With an optional numeric argument
+.I n
+it stops after
+.I n
+seconds (default never).
+The optional
+.B -s
+flag makes digits scroll as they change. In this curses mode implementation,
+the scrolling option has trouble keeping up.
+.SH AUTHOR
+Amos Shapir, modified for curses by John Lupien.
diff --git a/lib/libncurses/TESTS/gdc.c b/lib/libncurses/TESTS/gdc.c
new file mode 100644
index 0000000..7f80d93
--- /dev/null
+++ b/lib/libncurses/TESTS/gdc.c
@@ -0,0 +1,174 @@
+/*
+ * Grand digital clock for curses compatible terminals
+ * Usage: gdc [-s] [n] -- run for n seconds (default infinity)
+ * Flags: -s: scroll
+ *
+ * modified 10-18-89 for curses (jrl)
+ * 10-18-89 added signal handling
+ */
+
+#include <time.h>
+#include <signal.h>
+#include <ncurses.h>
+#include <stdlib.h>
+#ifndef NONPOSIX
+#include <unistd.h>
+#endif
+
+/* it won't be */
+long now; /* yeah! */
+struct tm *tm;
+
+short disp[11] = {
+ 075557, 011111, 071747, 071717, 055711,
+ 074717, 074757, 071111, 075757, 075717, 002020
+};
+long old[6], next[6], new[6], mask;
+char scrol;
+
+int sigtermed=0;
+
+int hascolor = 0;
+
+void set(int, int);
+void standt(int);
+void movto(int, int);
+
+void sighndl(signo)
+int signo;
+{
+ signal(signo, sighndl);
+ sigtermed=signo;
+}
+
+int
+main(argc, argv)
+int argc;
+char **argv;
+{
+long t, a;
+int i, j, s, k;
+int n = 0;
+
+ signal(SIGINT,sighndl);
+ signal(SIGTERM,sighndl);
+ signal(SIGKILL,sighndl);
+
+ initscr();
+ cbreak();
+ noecho();
+
+ hascolor = has_colors();
+
+ if(hascolor) {
+ start_color();
+ init_pair(1, COLOR_BLACK, COLOR_RED);
+ init_pair(2, COLOR_RED, COLOR_BLACK);
+ attrset(COLOR_PAIR(2));
+ }
+
+ clear();
+ refresh();
+ while(--argc > 0) {
+ if(**++argv == '-')
+ scrol = 1;
+ else
+ n = atoi(*argv);
+ }
+ do {
+ mask = 0;
+ time(&now);
+ tm = localtime(&now);
+ set(tm->tm_sec%10, 0);
+ set(tm->tm_sec/10, 4);
+ set(tm->tm_min%10, 10);
+ set(tm->tm_min/10, 14);
+ set(tm->tm_hour%10, 20);
+ set(tm->tm_hour/10, 24);
+ set(10, 7);
+ set(10, 17);
+ for(k=0; k<6; k++) {
+ if(scrol) {
+ for(i=0; i<5; i++)
+ new[i] = (new[i]&~mask) | (new[i+1]&mask);
+ new[5] = (new[5]&~mask) | (next[k]&mask);
+ } else
+ new[k] = (new[k]&~mask) | (next[k]&mask);
+ next[k] = 0;
+ for(s=1; s>=0; s--) {
+ standt(s);
+ for(i=0; i<6; i++) {
+ if((a = (new[i]^old[i])&(s ? new : old)[i]) != 0) {
+ for(j=0,t=1<<26; t; t>>=1,j++) {
+ if(a&t) {
+ if(!(a&(t<<1))) {
+ movto(i, 2*j);
+ }
+ addstr(" ");
+ }
+ }
+ }
+ if(!s) {
+ old[i] = new[i];
+ }
+ }
+ if(!s) {
+ refresh();
+ }
+ }
+ }
+ movto(6, 0);
+ refresh();
+ sleep(1);
+ if (sigtermed) {
+ standend();
+ clear();
+ refresh();
+ endwin();
+ fprintf(stderr, "gdc terminated by signal %d\n", sigtermed);
+ exit(1);
+ }
+ } while(--n);
+ standend();
+ clear();
+ refresh();
+ endwin();
+ return(0);
+}
+
+void
+set(int t, int n)
+{
+int i, m;
+
+ m = 7<<n;
+ for(i=0; i<5; i++) {
+ next[i] |= ((disp[t]>>(4-i)*3)&07)<<n;
+ mask |= (next[i]^old[i])&m;
+ }
+ if(mask&m)
+ mask |= m;
+}
+
+void
+standt(int on)
+{
+ if (on) {
+ if(hascolor)
+ attron(COLOR_PAIR(1));
+ else
+ attron(A_STANDOUT);
+ } else {
+ if(hascolor)
+ attron(COLOR_PAIR(2));
+ else
+ attroff(A_STANDOUT);
+ }
+}
+
+void
+movto(int line, int col)
+{
+ move(line, col);
+}
+
diff --git a/lib/libncurses/TESTS/getch.c b/lib/libncurses/TESTS/getch.c
new file mode 100644
index 0000000..90a0ee4
--- /dev/null
+++ b/lib/libncurses/TESTS/getch.c
@@ -0,0 +1,29 @@
+#include <ncurses.h>
+
+main()
+ {
+ int c,i;
+ initscr();
+ cbreak();
+ noecho();
+#if 1
+ wtimeout(stdscr,1000);
+#endif
+ scrollok(stdscr,TRUE);
+ for (c='A';c<='Z';c++)
+ for (i=0;i<25;i++)
+ {
+ move(i,i);
+ addch(c);
+ refresh();
+ }
+ move (0,0);
+ while ((c=wgetch(stdscr))!='A')
+ {
+ if (c == EOF) printw(">>wait for keypress<<");
+ else printw(">>%c<<\n",c);
+ refresh();
+ }
+ endwin();
+ }
+
diff --git a/lib/libncurses/TESTS/hanoi.c b/lib/libncurses/TESTS/hanoi.c
new file mode 100644
index 0000000..422d5da
--- /dev/null
+++ b/lib/libncurses/TESTS/hanoi.c
@@ -0,0 +1,267 @@
+/*
+ * Name: Towers of Hanoi.
+ *
+ * Desc:
+ * This is a playable copy of towers of hanoi.
+ * Its sole purpose is to demonstrate my Amiga Curses package.
+ * This program should compile on any system that has Curses.
+ * 'hanoi' will give a manual game with 7 playing pieces.
+ * 'hanoi n' will give a manual game with n playing pieces.
+ * 'hanoi n a' will give an auto solved game with n playing pieces.
+ *
+ * Author: Simon J Raybould (sie@fulcrum.bt.co.uk).
+ *
+ * Date: 05.Nov.90
+ *
+ */
+
+#include <ncurses.h>
+
+#define NPEGS 3 /* This is not configurable !! */
+#define MINTILES 3
+#define MAXTILES 9
+#define DEFAULTTILES 7
+#define TOPLINE 6
+#define BASELINE 16
+#define STATUSLINE (LINES-3)
+#define LEFTPEG 19
+#define MIDPEG 39
+#define RIGHTPEG 59
+
+#define LENTOIND(x) (((x)-1)/2-1)
+#define OTHER(a,b) (3-((a)+(b)))
+
+struct Peg {
+ int Length[MAXTILES];
+ int Count;
+};
+
+struct Peg Pegs[NPEGS];
+int PegPos[] = { LEFTPEG, MIDPEG, RIGHTPEG };
+int TileColour[] = {
+ COLOR_GREEN, /* Length 3 */
+ COLOR_MAGENTA, /* Length 5 */
+ COLOR_RED, /* Length 7 */
+ COLOR_BLUE, /* Length 9 */
+ COLOR_CYAN, /* Length 11 */
+ COLOR_YELLOW, /* Length 13 */
+ COLOR_GREEN, /* Length 15 */
+ COLOR_MAGENTA, /* Length 17 */
+ COLOR_RED, /* Length 19 */
+};
+int NMoves = 0;
+
+void InitTiles(), DisplayTiles(), MakeMove(), AutoMove(), Usage();
+
+int
+main(int argc, char **argv)
+{
+int NTiles, FromCol, ToCol;
+unsigned char AutoFlag = 0;
+
+ switch(argc) {
+ case 1:
+ NTiles = DEFAULTTILES;
+ break;
+ case 2:
+ NTiles = atoi(argv[1]);
+ if (NTiles > MAXTILES || NTiles < MINTILES) {
+ fprintf(stderr, "Range %d to %d\n", MINTILES, MAXTILES);
+ exit(1);
+ }
+ break;
+ case 3:
+ if (strcmp(argv[2], "a")) {
+ Usage();
+ exit(1);
+ }
+ NTiles = atoi(argv[1]);
+ if (NTiles > MAXTILES || NTiles < MINTILES) {
+ fprintf(stderr, "Range %d to %d\n", MINTILES, MAXTILES);
+ exit(1);
+ }
+ AutoFlag = TRUE;
+ break;
+ default:
+ Usage();
+ exit(1);
+ }
+ initscr();
+ if (!has_colors()) {
+ puts("terminal doesn't support color.");
+ exit(1);
+ }
+ traceon();
+ start_color();
+ {
+ int i;
+ for (i = 0; i < 9; i++)
+ init_pair(i+1, COLOR_BLACK, TileColour[i]);
+ }
+ cbreak();
+ if (LINES < 24) {
+ fprintf(stderr, "Min screen length 24 lines\n");
+ endwin();
+ exit(1);
+ }
+ if(AutoFlag)
+ leaveok(stdscr, TRUE); /* Attempt to remove cursor */
+ InitTiles(NTiles);
+ DisplayTiles();
+ if(AutoFlag) {
+ do {
+ noecho();
+ AutoMove(0, 2, NTiles);
+ } while(!Solved(NTiles));
+ sleep(2);
+ } else {
+ for(;;) {
+ if(GetMove(&FromCol, &ToCol))
+ break;
+ if(InvalidMove(FromCol, ToCol)) {
+ mvaddstr(STATUSLINE, 0, "Invalid Move !!");
+ refresh();
+ beep();
+ continue;
+ }
+ MakeMove(FromCol, ToCol);
+ if(Solved(NTiles)) {
+ mvprintw(STATUSLINE, 0, "Well Done !! You did it in %d moves", NMoves);
+ refresh();
+ sleep(5);
+ break;
+ }
+ }
+ }
+ endwin();
+}
+
+int
+InvalidMove(int From, int To)
+{
+ if(From == To)
+ return TRUE;
+ if(!Pegs[From].Count)
+ return TRUE;
+ if(Pegs[To].Count &&
+ Pegs[From].Length[Pegs[From].Count-1] >
+ Pegs[To].Length[Pegs[To].Count-1])
+ return TRUE;
+ return FALSE;
+}
+
+void
+InitTiles(int NTiles)
+{
+int Size, SlotNo;
+
+ for(Size=NTiles*2+1, SlotNo=0; Size>=3; Size-=2)
+ Pegs[0].Length[SlotNo++] = Size;
+
+ Pegs[0].Count = NTiles;
+ Pegs[1].Count = 0;
+ Pegs[2].Count = 0;
+}
+
+#define gc() {noecho();getch();echo();}
+
+void
+DisplayTiles()
+{
+ int Line, Peg, SlotNo;
+ char TileBuf[BUFSIZ];
+
+ erase();
+ mvaddstr(1, 24, "T O W E R S O F H A N O I");
+ mvaddstr(3, 34, "SJR 1990");
+ mvprintw(19, 5, "Moves : %d", NMoves);
+ standout();
+ mvaddstr(BASELINE, 8, " ");
+
+ for(Line=TOPLINE; Line<BASELINE; Line++) {
+ mvaddch(Line, LEFTPEG, ' ');
+ mvaddch(Line, MIDPEG, ' ');
+ mvaddch(Line, RIGHTPEG, ' ');
+ }
+ mvaddch(BASELINE, LEFTPEG, '1');
+ mvaddch(BASELINE, MIDPEG, '2');
+ mvaddch(BASELINE, RIGHTPEG, '3');
+ standend();
+
+ /* Draw tiles */
+ for(Peg=0; Peg<NPEGS; Peg++) {
+ for(SlotNo=0; SlotNo<Pegs[Peg].Count; SlotNo++) {
+ memset(TileBuf, ' ', Pegs[Peg].Length[SlotNo]);
+ TileBuf[Pegs[Peg].Length[SlotNo]] = '\0';
+ attrset(COLOR_PAIR(LENTOIND(Pegs[Peg].Length[SlotNo])));
+ mvaddstr(BASELINE-(SlotNo+1),
+ PegPos[Peg]-Pegs[Peg].Length[SlotNo]/2, TileBuf);
+ }
+ }
+ attrset(A_NORMAL);
+ refresh();
+}
+
+int
+GetMove(int *From, int *To)
+{
+ mvaddstr(STATUSLINE, 0, "Next move ('q' to quit) from ");
+ clrtoeol();
+ refresh();
+ if((*From = getch()) == 'q')
+ return TRUE;
+ *From -= ('0'+1);
+ addstr(" to ");
+ clrtoeol();
+ refresh();
+ if((*To = getch()) == 'q')
+ return TRUE;
+ *To -= ('0'+1);
+ move(STATUSLINE, 0);
+ clrtoeol();
+ refresh();
+ return FALSE;
+}
+
+void
+MakeMove(int From, int To)
+{
+
+ Pegs[From].Count--;
+ Pegs[To].Length[Pegs[To].Count] = Pegs[From].Length[Pegs[From].Count];
+ Pegs[To].Count++;
+ NMoves++;
+ DisplayTiles();
+}
+
+void
+AutoMove(int From, int To, int Num)
+{
+
+ if(Num == 1) {
+ MakeMove(From, To);
+ return;
+ }
+ AutoMove(From, OTHER(From, To), Num-1);
+ MakeMove(From, To);
+ AutoMove(OTHER(From, To), To, Num-1);
+}
+
+int
+Solved(int NumTiles)
+{
+int i;
+
+ for(i = 1; i < NPEGS; i++)
+ if (Pegs[i].Count == NumTiles)
+ return TRUE;
+ return FALSE;
+}
+
+void
+Usage()
+{
+ fprintf(stderr, "Usage: hanoi [<No Of Tiles>] [a]\n");
+ fprintf(stderr, "The 'a' option causes the tower to be solved automatically\n");
+}
+
diff --git a/lib/libncurses/TESTS/knight.c b/lib/libncurses/TESTS/knight.c
new file mode 100644
index 0000000..4b2f989
--- /dev/null
+++ b/lib/libncurses/TESTS/knight.c
@@ -0,0 +1,322 @@
+/* Knights Tour - a brain game */
+
+#include <ncurses.h>
+#include <signal.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+#ifdef __386BSD__
+#define srand48 srandom
+#define lrand48 random
+#endif
+
+short board [64]; /* the squares */
+char row, column; /* input characters */
+int rw,col; /* numeric equivalent of row and column */
+int curow,curcol; /* current row and column integers */
+int rdif, cdif; /* difference between input and current */
+int j; /* index into board */
+
+char script[]={"'_)//,/(-)/__/__(_<_(__),|/|/_///_/_<//_/_)__o__o'______///_(--_(_)___,(_/,_/__(_\0"};
+
+int ypos[] ={1,0,1,2,3,0,1,2,2,3,3,2,2,3,2,2,3,3,3,3,3,2,3,3,2,4,5,5,
+ 4,3,3,2,1,2,3,3,3,2,1,3,3,2,3,3,3,2,1,1,0,1,4,4,4,4,4,4,5,6,7,7,
+ 7,6,6,6,7,7,7,6,6,6,6,7,7,7,6,7,7,6,6,7,7};
+
+int xpos[]={0,1,2,1,0,5,4,3,2,4,6,7,8,8,9,10,10,11,12,13,14,15,15,16,
+ 16,16,15,14,15,17,18,19,20,20,20,21,22,23,24,23,25,26,27,26,28,
+ 13,23,25,27,27,2,3,4,5,6,7,4,3,2,1,0,1,2,5,4,5,6,6,7,8,9,8,9,10,
+ 11,11,12,13,14,14,15};
+
+static char *instructions[] =
+{
+" Knight's Tour is a board game for one player. It is played on",
+"an eight by eight board and is based on the allowable moves that a knight",
+"can make in the game of chess. For those who are unfamiliar with the",
+"game, a knight may move either on a row or a column but not diagonally.",
+"He may move one square in any direction and two squares in a perpendicular",
+"direction >or< two squares in any direction and one square in a",
+"perpendicular direction. He may not, of course, move off the board.",
+"",
+" At the beginning of a game you will be asked to either choose a",
+"starting square or allow the computer to select a random location.",
+"Squares are designated by a letter-number combination where the row is",
+"specified by a letter A-H and the numbers 1-8 define a column. Invalid",
+"entries are ignored and illegal moves produce a beep at the terminal.",
+"",
+" The objective is to visit every square on the board. When you claim",
+"a square a marker is placed on it to show where you've been. You may",
+"not revisit a square that you've landed on before.",
+"",
+" After each move the program checks to see if you have any legal",
+"moves left. If not, the game ends and your squares are counted. If",
+"you've made all the squares you win the game. Otherwise, you are told",
+"the number of squares you did make.",
+"END"
+};
+
+void init(void);
+int play(void);
+void drawboard(void);
+void dosquares(void);
+void getfirst(void);
+void getrc(void);
+void putstars(void);
+int evalmove(void);
+int chkmoves(void);
+int endgame(void);
+int chksqr(int, int);
+void instruct(void);
+void title(int, int);
+
+int
+main ()
+{
+ init ();
+ for (;;)
+ if (!play ()) {
+ endwin ();
+ exit (0);
+ }
+}
+
+void
+init ()
+{
+
+ srand48 (getpid());
+ initscr ();
+ cbreak (); /* immediate char return */
+ noecho (); /* no immediate echo */
+ traceon();
+ title (1,23);
+ traceoff();
+ mvaddstr (23, 25, "Would you like instructions? ");
+ refresh();
+ if ((toupper(getch())) == 'Y')
+ instruct();
+ clear ();
+}
+
+int
+play ()
+{
+ drawboard (); /* clear screen and drawboard */
+ for (j = 0; j < 64; j++) board[j]=0;
+ getfirst (); /* get the starting square */
+ for (;;) {
+ getrc();
+ if (evalmove()) {
+ putstars ();
+ if (!chkmoves())
+ return (endgame ());
+ }
+ else beep();
+ }
+}
+
+void
+drawboard ()
+{
+ erase ();
+ dosquares ();
+ refresh ();
+ mvaddstr (0, 7, "1 2 3 4 5 6 7 8");
+ for (j = 0; j < 8; j++) mvaddch (2*j+2, 3, j + 'A');
+ refresh ();
+ mvaddstr (20, 5, "ROW:");
+ mvaddstr (20, 27, "COLUMN:");
+ mvaddstr (14, 49, "CURRENT ROW");
+ mvaddstr (16, 49, "CURRENT COL");
+ mvaddstr (22, 5, "A - H or Q to quit");
+ mvaddstr (22, 27, "1 - 8 or ESC to cancel row");
+ refresh ();
+ title (1,40);
+}
+
+void
+dosquares ()
+{
+ mvaddstr (1, 6, "-------------------------------");
+ for (j = 1; j < 9; j++){
+ mvaddstr (2*j, 5, "| | | | | | | | |");
+ mvaddstr (2*j+1, 6, "-------------------------------");
+ }
+}
+
+void
+getfirst () /* get first square */
+{
+ mvaddstr (23, 25, "(S)elect or (R)andom "); refresh ();
+ do {
+ row = toupper(getch());
+ } while ((row != 'S') && (row != 'R'));
+ if (row == 'R') {
+ rw = lrand48() % 8;
+ col = lrand48() % 8;
+ j = 8* rw + col;
+ row = rw + 'A';
+ column = col + '1';
+ }
+ else {
+ mvaddstr (23, 25, "Enter starting row and column");
+ refresh ();
+ getrc(); /* get row and column */
+ }
+ putstars ();
+ move (23, 0);
+ clrtobot();
+}
+
+void
+getrc () /* get row and column */
+{
+ noecho ();
+ do {
+ mvaddstr (20, 35, " ");
+ refresh ();
+ do {
+ mvaddch (20, 11, ' ');
+ move (20, 11);
+ refresh ();
+ row=toupper(getch());
+ if (row == 'Q') {
+ endwin ();
+ exit (1);
+ }
+ } while ((row < 'A') || (row > 'H'));
+ addch (row);
+ move (20, 35);
+ refresh ();
+ do {
+ column=getch();
+ if (column == '\033') break;
+ } while ((column < '1') || (column > '8'));
+ if (column != '\033') addch (column);
+ } while (column == '\033');
+ refresh();
+ rw = row - 'A';
+ col= column - '1';
+ j = 8 * rw + col;
+}
+
+void
+putstars () /* place the stars, update board & currents */
+{
+ mvaddch (2*curow+2, 38, ' ');
+ mvaddch (2*rw+2, 38, '<');
+ mvaddch (18, curcol*4+7, ' ');
+ mvaddch (18, col*4+7, '^');
+ curow = rw;
+ curcol= col;
+ mvaddstr (2 * rw + 2, 4*col+6, "***");
+ mvaddch (14, 61, row);
+ mvaddch (16, 61, column);
+ refresh ();
+ board[j] = 1;
+}
+
+int
+evalmove() /* convert row and column to integers */
+ /* and evaluate move */
+{
+ rdif = rw - curow;
+ cdif = col - curcol;
+ rdif = abs(rw - curow);
+ cdif = abs(col - curcol);
+ refresh ();
+ if ((rdif == 1) && (cdif == 2)) if (board [j] == 0) return (1);
+ if ((rdif == 2) && (cdif == 1)) if (board [j] == 0) return (1);
+ return (0);
+}
+
+int
+chkmoves () /* check to see if valid moves are available */
+{
+ if (chksqr(2,1)) return (1);
+ if (chksqr(2,-1)) return (1);
+ if (chksqr(-2,1)) return (1);
+ if (chksqr(-2,-1)) return (1);
+ if (chksqr(1,2)) return (1);
+ if (chksqr(1,-2)) return (1);
+ if (chksqr(-1,2)) return (1);
+ if (chksqr(-1,-2)) return (1);
+ return (0);
+}
+
+int
+endgame () /* check for filled board or not */
+{
+ rw = 0;
+ for (j = 0; j < 64; j++) if (board[j] != 0) rw+=1;
+ if (rw == 64) mvaddstr (20, 20, "Congratulations !! You got 'em all");
+ else mvprintw (20, 20, "You have ended up with %2d squares",rw);
+ mvaddstr (21, 25, "Play again ? (y/n) ");
+ refresh ();
+ if ((row=tolower(getch())) == 'y') return (1);
+ else return (0);
+}
+
+#ifndef abs
+abs(num)
+int num;
+{
+ if (num < 0) return (-num);
+ else return (num);
+}
+#endif
+
+int
+chksqr (int n1, int n2)
+{
+int r1, c1;
+
+ r1 = rw + n1;
+ c1 = col + n2;
+ if ((r1<0) || (r1>7)) return (0);
+ if ((c1<0) || (c1>7)) return (0);
+ if (board[r1*8+c1] == 0) return (1);
+ else return (0);
+}
+
+void
+instruct()
+{
+int i;
+
+ clear ();
+ for (i=0;;i++) {
+ if ((strcmp(instructions[i],"END"))) mvaddstr (i, 0, instructions[i]);
+ else {
+ mvaddstr (23, 25, "Ready to play ? (y/n) ");
+ refresh();
+ if (toupper(getch()) == 'Y') {
+ clear ();
+ return;
+ } else {
+ clear ();
+ refresh ();
+ endwin ();
+ exit (0);
+ }
+ }
+ }
+}
+
+void
+title (y,x)
+int y,x;
+{
+char c;
+
+ j = 0;
+ do {
+ c = script[j];
+ if (c == 0) break ;
+ mvaddch (ypos[j]+y, xpos[j]+x, c);
+ j++;
+ } while (c != 0);
+ refresh ();
+}
+
+
diff --git a/lib/libncurses/TESTS/ncurses.c b/lib/libncurses/TESTS/ncurses.c
new file mode 100644
index 0000000..468cd5d
--- /dev/null
+++ b/lib/libncurses/TESTS/ncurses.c
@@ -0,0 +1,1038 @@
+/****************************************************************************
+
+NAME
+ ncurses.c --- ncurses library exerciser
+
+SYNOPSIS
+ ncurses
+
+DESCRIPTION
+ An interactive test module for the ncurses library.
+
+AUTHOR
+ This software is Copyright (C) 1993 by Eric S. Raymond, all rights reserved.
+It is issued with ncurses under the same terms and conditions as the ncurses
+library source.
+
+***************************************************************************/
+/*LINTLIBRARY */
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <ncurses.h>
+
+#define P(s) printw("%s\n", s)
+#ifndef CTRL
+#define CTRL(x) ((x) & 0x1f)
+#endif
+
+/****************************************************************************
+ *
+ * Character input test
+ *
+ ****************************************************************************/
+
+static void getch_test(void)
+/* test the keypad feature */
+{
+ unsigned int c;
+ int firsttime = 0;
+
+ refresh();
+
+ c = '?';
+ do {
+ if (firsttime++)
+ {
+ printw("Key pressed: %04o ", c);
+ if (c >= KEY_MIN)
+ {
+ (void) addstr(keyname(c));
+ addch('\n');
+ }
+ else if (c > 0x80)
+ {
+ if (isprint(c & ~0x80))
+ (void) printw("M-%c", c);
+ else
+ (void) printw("M-%s", unctrl(c));
+ addstr(" (high-half character)\n");
+ }
+ else
+ {
+ if (isprint(c))
+ (void) printw("%c (ASCII printable character)\n", c);
+ else
+ (void) printw("%s (ASCII control character)\n", unctrl(c));
+ }
+ }
+ if (c == 'x' || c == 'q')
+ break;
+ if (c == '?')
+ addstr("Type any key to see its keypad value, `q' to quit, `?' for help.\n");
+ } while
+ ((c = getch()) != EOF);
+
+ erase();
+ endwin();
+}
+
+static void attr_test(void)
+/* test text attrivutes */
+{
+ refresh();
+
+ mvaddstr(0, 20, "Character attribute test display");
+
+ mvaddstr(2,8,"This is STANDOUT mode: ");
+ attron(A_STANDOUT);
+ addstr("abcde fghij klmno pqrst uvwxy x");
+ attroff(A_STANDOUT);
+
+ mvaddstr(4,8,"This is REVERSE mode: ");
+ attron(A_REVERSE);
+ addstr("abcde fghij klmno pqrst uvwxy x");
+ attroff(A_REVERSE);
+
+ mvaddstr(6,8,"This is BOLD mode: ");
+ attron(A_BOLD);
+ addstr("abcde fghij klmno pqrst uvwxy x");
+ attroff(A_BOLD);
+
+ mvaddstr(8,8,"This is UNDERLINE mode: ");
+ attron(A_UNDERLINE);
+ addstr("abcde fghij klmno pqrst uvwxy x");
+ attroff(A_UNDERLINE);
+
+ mvaddstr(10,8,"This is DIM mode: ");
+ attron(A_DIM);
+ addstr("abcde fghij klmno pqrst uvwxy x");
+ attroff(A_DIM);
+
+ mvaddstr(12,8,"This is BLINK mode: ");
+ attron(A_BLINK);
+ addstr("abcde fghij klmno pqrst uvwxy x");
+ attroff(A_BLINK);
+
+ mvaddstr(14,8,"This is BOLD UNDERLINE BLINK mode: ");
+ attron(A_BOLD|A_BLINK|A_UNDERLINE);
+ addstr("abcde fghij klmno pqrst uvwxy x");
+ attroff(A_BOLD|A_BLINK|A_UNDERLINE);
+
+ attrset(A_NORMAL);
+ mvaddstr(16,8,"This is NORMAL mode: ");
+ addstr("abcde fghij klmno pqrst uvwxy x");
+
+ refresh();
+
+ move(LINES - 1, 0);
+ addstr("Press any key to continue... ");
+ (void) getch();
+
+ erase();
+ endwin();
+}
+
+/****************************************************************************
+ *
+ * Color support tests
+ *
+ ****************************************************************************/
+
+static char *colors[] =
+{
+ "black",
+ "red",
+ "green",
+ "yellow",
+ "blue",
+ "magenta",
+ "cyan",
+ "white"
+};
+
+static void color_test(void)
+/* generate a color test pattern */
+{
+ int i;
+
+ refresh();
+ (void) printw("There are %d color pairs\n", COLOR_PAIRS);
+
+ (void) mvprintw(1, 0,
+ "%dx%d matrix of foreground/background colors, bright *off*\n",
+ COLORS, COLORS);
+ for (i = 0; i < COLORS; i++)
+ mvaddstr(2, (i+1) * 8, colors[i]);
+ for (i = 0; i < COLORS; i++)
+ mvaddstr(3 + i, 0, colors[i]);
+ for (i = 1; i < COLOR_PAIRS; i++)
+ {
+ init_pair(i, i % COLORS, i / COLORS);
+ attron(COLOR_PAIR(i));
+ mvaddstr(3 + (i / COLORS), (i % COLORS + 1) * 8, "Hello");
+ attrset(A_NORMAL);
+ }
+
+ (void) mvprintw(COLORS + 4, 0,
+ "%dx%d matrix of foreground/background colors, bright *on*\n",
+ COLORS, COLORS);
+ for (i = 0; i < COLORS; i++)
+ mvaddstr(5 + COLORS, (i+1) * 8, colors[i]);
+ for (i = 0; i < COLORS; i++)
+ mvaddstr(6 + COLORS + i, 0, colors[i]);
+ for (i = 1; i < COLOR_PAIRS; i++)
+ {
+ init_pair(i, i % COLORS, i / COLORS);
+ attron(COLOR_PAIR(i) | A_BOLD);
+ mvaddstr(6 + COLORS + (i / COLORS), (i % COLORS + 1) * 8, "Hello");
+ attrset(A_NORMAL);
+ }
+
+ move(LINES - 1, 0);
+ addstr("Press any key to continue... ");
+ (void) getch();
+
+ erase();
+ endwin();
+}
+
+static void color_edit(void)
+/* display the color test pattern, without trying to edit colors */
+{
+ int i, c, value = 0, current = 0, field = 0, usebase = 0;
+
+ refresh();
+
+ for (i = 0; i < COLORS; i++)
+ init_pair(i, COLOR_WHITE, i);
+
+ do {
+ short red, green, blue;
+
+ attron(A_BOLD);
+ mvaddstr(0, 20, "Color RGB Value Editing");
+ attroff(A_BOLD);
+
+ for (i = 0; i < COLORS; i++)
+ {
+ mvprintw(2 + i, 0, "%c %-8s:",
+ (i == current ? '>' : ' '),
+ (i < sizeof(colors)/sizeof(colors[0]) ? colors[i] : ""));
+ attrset(COLOR_PAIR(i));
+ addstr(" ");
+ attrset(A_NORMAL);
+
+ /*
+ * Note: this refresh should *not* be necessary! It works around
+ * a bug in attribute handling that apparently causes the A_NORMAL
+ * attribute sets to interfere with the actual emission of the
+ * color setting somehow. This needs to be fixed.
+ */
+ refresh();
+
+ color_content(i, &red, &green, &blue);
+ addstr(" R = ");
+ if (current == i && field == 0) attron(A_STANDOUT);
+ printw("%04d", red);
+ if (current == i && field == 0) attrset(A_NORMAL);
+ addstr(", G = ");
+ if (current == i && field == 1) attron(A_STANDOUT);
+ printw("%04d", green);
+ if (current == i && field == 1) attrset(A_NORMAL);
+ addstr(", B = ");
+ if (current == i && field == 2) attron(A_STANDOUT);
+ printw("%04d", blue);
+ if (current == i && field == 2) attrset(A_NORMAL);
+ attrset(A_NORMAL);
+ addstr(")");
+ }
+
+ mvaddstr(COLORS + 3, 0,
+ "Use up/down to select a color, left/right to change fields.");
+ mvaddstr(COLORS + 4, 0,
+ "Modify field by typing nnn=, nnn-, or nnn+. ? for help.");
+
+ move(2 + current, 0);
+
+ switch (c = getch())
+ {
+ case KEY_UP:
+ current = (current == 0 ? (COLORS - 1) : current - 1);
+ value = 0;
+ break;
+
+ case KEY_DOWN:
+ current = (current == (COLORS - 1) ? 0 : current + 1);
+ value = 0;
+ break;
+
+ case KEY_RIGHT:
+ field = (field == 2 ? 0 : field + 1);
+ value = 0;
+ break;
+
+ case KEY_LEFT:
+ field = (field == 0 ? 2 : field - 1);
+ value = 0;
+ break;
+
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ do {
+ value = value * 10 + (c - '0');
+ c = getch();
+ } while
+ (isdigit(c));
+ if (c != '+' && c != '-' && c != '=')
+ beep();
+ else
+ ungetch(c);
+ break;
+
+ case '+':
+ usebase = 1;
+ goto changeit;
+
+ case '-':
+ value = -value;
+ usebase = 1;
+ goto changeit;
+
+ case '=':
+ usebase = 0;
+ changeit:
+ color_content(current, &red, &green, &blue);
+ if (field == 0)
+ red = red * usebase + value;
+ else if (field == 1)
+ green = green * usebase + value;
+ else if (field == 2)
+ blue = blue * usebase + value;
+ init_color(current, red, green, blue);
+ break;
+
+ case '?':
+ erase();
+ P(" RGB Value Editing Help");
+ P("");
+ P("You are in the RGB value editor. Use the arrow keys to select one of");
+ P("the fields in one of the RGB triples of the current colors; the one");
+ P("currently selected will be reverse-video highlighted.");
+ P("");
+ P("To change a field, enter the digits of the new value; they won't be");
+ P("echoed. Finish by typing `='; the change will take effect instantly.");
+ P("To increment or decrement a value, use the same procedure, but finish");
+ P("with a `+' or `-'.");
+ P("");
+ P("To quit, do `x' or 'q'");
+
+ move(LINES - 1, 0);
+ addstr("Press any key to continue... ");
+ (void) getch();
+ erase();
+ break;
+
+ case 'x':
+ case 'q':
+ break;
+
+ default:
+ beep();
+ break;
+ }
+ } while
+ (c != 'x' && c != 'q');
+
+ erase();
+ endwin();
+}
+
+/****************************************************************************
+ *
+ * Soft-key label test
+ *
+ ****************************************************************************/
+
+static void slk_test(void)
+/* exercise the soft keys */
+{
+ int c, fmt = 1;
+ char buf[9];
+
+ c = CTRL('l');
+ do {
+ switch(c)
+ {
+ case CTRL('l'):
+ erase();
+ attron(A_BOLD);
+ mvaddstr(0, 20, "Soft Key Exerciser");
+ attroff(A_BOLD);
+
+ move(2, 0);
+ P("Available commands are:");
+ P("");
+ P("^L -- refresh screen");
+ P("a -- activate or restore soft keys");
+ P("d -- disable soft keys");
+ P("c -- set centered format for labels");
+ P("l -- set left-justified format for labels");
+ P("r -- set right-justified format for labels");
+ P("[12345678] -- set label; labels are numbered 1 through 8");
+ P("e -- erase stdscr (should not erase labels)");
+ P("s -- test scrolling of shortened screen");
+ P("x, q -- return to main menu");
+ P("");
+ P("Note: if activating the soft keys causes your terminal to");
+ P("scroll up one line, your terminal auto-scrolls when anything");
+ P("is written to the last screen position. The ncurses code");
+ P("does not yet handle this gracefully.");
+ refresh();
+ /* fall through */
+
+ case 'a':
+ slk_restore();
+ break;
+
+ case 'e':
+ wclear(stdscr);
+ break;
+
+ case 's':
+ move(20, 0);
+ while ((c = getch()) != 'Q')
+ addch(c);
+ break;
+
+ case 'd':
+ slk_clear();
+ break;
+
+ case 'l':
+ fmt = 0;
+ break;
+
+ case 'c':
+ fmt = 1;
+ break;
+
+ case 'r':
+ fmt = 2;
+ break;
+
+ case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8':
+ (void) mvaddstr(20, 0, "Please enter the label value: ");
+ wgetnstr(stdscr, buf, 8);
+ slk_set((c - '0'), buf, fmt);
+ slk_refresh();
+ break;
+
+ case 'x':
+ case 'q':
+ goto done;
+
+ default:
+ beep();
+ }
+ } while
+ ((c = getch()) != EOF);
+
+ done:
+ erase();
+ endwin();
+}
+
+/****************************************************************************
+ *
+ * Alternate character-set stuff
+ *
+ ****************************************************************************/
+
+static void acs_display()
+/* display the ACS character set */
+{
+traceon();
+ erase();
+ attron(A_BOLD);
+ mvaddstr(0, 20, "Display of the ACS Character Set");
+ attroff(A_BOLD);
+ refresh();
+
+#define ACSY 5
+ mvaddstr(ACSY + 0, 0, "ACS_ULCORNER: "); addch(ACS_ULCORNER);
+ mvaddstr(ACSY + 1, 0, "ACS_LLCORNER: "); addch(ACS_LLCORNER);
+ mvaddstr(ACSY + 2, 0, "ACS_URCORNER: "); addch(ACS_URCORNER);
+ mvaddstr(ACSY + 3, 0, "ACS_LRCORNER: "); addch(ACS_LRCORNER);
+ mvaddstr(ACSY + 4, 0, "ACS_RTEE: "); addch(ACS_RTEE);
+ mvaddstr(ACSY + 5, 0, "ACS_LTEE: "); addch(ACS_LTEE);
+ mvaddstr(ACSY + 6, 0, "ACS_BTEE: "); addch(ACS_BTEE);
+ mvaddstr(ACSY + 7, 0, "ACS_TTEE: "); addch(ACS_TTEE);
+ mvaddstr(ACSY + 8, 0, "ACS_HLINE: "); addch(ACS_HLINE);
+ mvaddstr(ACSY + 9, 0, "ACS_VLINE: "); addch(ACS_VLINE);
+ mvaddstr(ACSY + 10,0, "ACS_PLUS: "); addch(ACS_PLUS);
+ mvaddstr(ACSY + 11,0, "ACS_S1: "); addch(ACS_S1);
+ mvaddstr(ACSY + 12,0, "ACS_S9: "); addch(ACS_S9);
+
+ mvaddstr(ACSY + 0, 40, "ACS_DIAMOND: "); addch(ACS_DIAMOND);
+ mvaddstr(ACSY + 1, 40, "ACS_CKBOARD: "); addch(ACS_CKBOARD);
+ mvaddstr(ACSY + 2, 40, "ACS_DEGREE: "); addch(ACS_DEGREE);
+ mvaddstr(ACSY + 3, 40, "ACS_PLMINUS: "); addch(ACS_PLMINUS);
+ mvaddstr(ACSY + 4, 40, "ACS_BULLET: "); addch(ACS_BULLET);
+ mvaddstr(ACSY + 5, 40, "ACS_LARROW: "); addch(ACS_LARROW);
+ mvaddstr(ACSY + 6, 40, "ACS_RARROW: "); addch(ACS_RARROW);
+ mvaddstr(ACSY + 7, 40, "ACS_DARROW: "); addch(ACS_DARROW);
+ mvaddstr(ACSY + 8, 40, "ACS_UARROW: "); addch(ACS_UARROW);
+ mvaddstr(ACSY + 9, 40, "ACS_BOARD: "); addch(ACS_BOARD);
+ mvaddstr(ACSY + 10,40, "ACS_LANTERN: "); addch(ACS_LANTERN);
+ mvaddstr(ACSY + 11,40, "ACS_BLOCK: "); addch(ACS_BLOCK);
+
+ move(LINES - 1, 0);
+ addstr("Press any key to continue... ");
+ (void) getch();
+
+ erase();
+ endwin();
+}
+
+/****************************************************************************
+ *
+ * Windows and scrolling tester.
+ *
+ ****************************************************************************/
+
+typedef struct
+{
+ int y, x;
+}
+pair;
+
+static void report(void)
+/* report on the cursor's current position, then restore it */
+{
+ int y, x;
+
+ getyx(stdscr, y, x);
+ move(LINES - 1, COLS - 17);
+ printw("Y = %2d X = %2d", y, x);
+ move(y, x);
+}
+
+static pair *selectcell(uli, ulj, lri, lrj)
+/* arrows keys move cursor, return location at current on non-arrow key */
+int uli, ulj, lri, lrj; /* co-ordinates of corners */
+{
+ static pair res; /* result cell */
+ int si = lri - uli + 1; /* depth of the select area */
+ int sj = lrj - ulj + 1; /* width of the select area */
+ int i = 0, j = 0; /* offsets into the select area */
+
+ for (;;)
+ {
+ move(LINES - 1, COLS - 17);
+ printw("Y = %2d X = %2d", uli + i, ulj + j);
+ move(uli + i, ulj + j);
+
+ switch(getch())
+ {
+ case KEY_UP: i += si - 1; break;
+ case KEY_DOWN: i++; break;
+ case KEY_LEFT: j += sj - 1; break;
+ case KEY_RIGHT: j++; break;
+ default: res.y = uli + i; res.x = ulj + j; return(&res);
+ }
+ i %= si;
+ j %= sj;
+ }
+}
+
+static WINDOW *getwindow(void)
+/* Ask user for a window definition */
+{
+ WINDOW *rwindow, *bwindow;
+ pair ul, lr;
+
+ move(0, 0); clrtoeol();
+ addstr("Use arrows to move cursor, anything else to mark corner 1");
+ refresh();
+ memcpy(&ul, selectcell(1, 0, LINES-1, COLS-1), sizeof(pair));
+ addch(ACS_ULCORNER);
+ move(0, 0); clrtoeol();
+ addstr("Use arrows to move cursor, anything else to mark corner 2");
+ refresh();
+ memcpy(&lr, selectcell(ul.y, ul.x, LINES-1, COLS-1), sizeof(pair));
+
+ rwindow = newwin(lr.y - ul.y + 1, lr.x - ul.x + 1, ul.y, ul.x);
+
+ bwindow = newwin(lr.y - ul.y + 3, lr.x - ul.x + 3, ul.y - 1, ul.x - 1);
+ wborder(bwindow, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE,
+ 0, 0, 0, 0);
+ wrefresh(bwindow);
+ delwin(bwindow);
+
+ scrollok(rwindow, TRUE);
+/* immedok(rwindow); */
+ wrefresh(rwindow);
+
+ return(rwindow);
+}
+
+static void acs_and_scroll()
+/* Demonstrate windows */
+{
+ int c;
+ struct frame
+ {
+ struct frame *next, *last;
+ WINDOW *wind;
+ }
+ *oldw = (struct frame *)NULL, *current = (struct frame *)NULL, *neww;
+
+ refresh();
+ mvaddstr(LINES - 2, 0,
+ "F1 = make new window, F2 = next window, F3 = previous window");
+ mvaddstr(LINES - 1, 0,
+ "All other characters are echoed, windows should scroll.");
+
+ c = KEY_F(1);
+ do {
+ report();
+ if (current)
+ wrefresh(current->wind);
+
+ switch(c)
+ {
+ case KEY_F(1):
+ neww = (struct frame *) malloc(sizeof(struct frame));
+ neww->wind = getwindow();
+ if (oldw == NULL) /* First element, */
+ {
+ neww->next = neww; /* so point it at itself */
+ neww->last = neww;
+ current = neww;
+ }
+ else
+ {
+ neww->last = oldw; oldw->next = neww;
+ neww->next = current; current->last = neww;
+ }
+ oldw = neww;
+ keypad(neww->wind, TRUE);
+ break;
+
+ case KEY_F(2):
+ current = current->next;
+ break;
+
+ case KEY_F(3):
+ current = current->last;
+ break;
+
+ case KEY_F(4): /* undocumented --- use this to test area clears */
+ selectcell(0, 0, LINES - 1, COLS - 1);
+ clrtobot();
+ refresh();
+ break;
+
+ case '\r':
+ c = '\n';
+ /* FALLTHROUGH */
+
+ default:
+ waddch(current->wind, c);
+ break;
+ }
+ report();
+ wrefresh(current->wind);
+ } while
+ ((c = wgetch(current->wind)) != '\004');
+
+ erase();
+ endwin();
+}
+
+/****************************************************************************
+ *
+ * Tests from John Burnell's PDCurses tester
+ *
+ ****************************************************************************/
+
+static void demo_pad(void)
+/* Demonstrate pads. */
+{
+ WINDOW *pad;
+
+ pad = newpad(50,100);
+ mvwaddstr(pad, 5, 2, "This is a new pad");
+ mvwaddstr(pad, 8, 0, "The end of this line should be truncated here:abcd");
+ mvwaddstr(pad,11, 1, "This line should not appear.");
+ wmove(pad, 10, 1);
+ wclrtoeol(pad);
+ mvwaddstr(pad, 10, 1, " Press any key to continue");
+ prefresh(pad,0,0,0,0,10,45);
+ keypad(pad, TRUE);
+ wgetch(pad);
+
+ mvwaddstr(pad, 35, 2, "This is displayed at line 35 in the pad");
+ mvwaddstr(pad, 40, 1, " Press any key to continue");
+ prefresh(pad,30,0,0,0,10,45);
+ keypad(pad, TRUE);
+ wgetch(pad);
+
+ delwin(pad);
+}
+
+static void Continue (WINDOW *win)
+{
+ wmove(win, 10, 1);
+ mvwaddstr(win, 10, 1, " Press any key to continue");
+ wrefresh(win);
+ wgetch(win);
+}
+
+static void input_test(WINDOW *win)
+/* Input test, adapted from John Burnell's PDCurses tester */
+{
+ int w, h, bx, by, sw, sh, i, c,num;
+ char buffer [80];
+ WINDOW *subWin;
+ wclear (win);
+
+ w = win->_maxx;
+ h = win->_maxy;
+ bx = win->_begx;
+ by = win->_begy;
+ sw = w / 3;
+ sh = h / 3;
+ if((subWin = subwin(win, sh, sw, by + h - sh - 2, bx + w - sw - 2)) == NULL)
+ return;
+
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(2,COLOR_CYAN,COLOR_BLUE);
+ wattrset(subWin, COLOR_PAIR(2) | A_BOLD);
+ }
+ else
+ wattrset(subWin, A_BOLD);
+#else
+ wattrset(subWin, A_BOLD);
+#endif
+ box(subWin, ACS_VLINE, ACS_HLINE);
+ wrefresh(win);
+
+ nocbreak();
+ mvwaddstr(win, 2, 1, "Press some keys for 5 seconds");
+ mvwaddstr(win, 1, 1, "Pressing ^C should do nothing");
+ wrefresh(win);
+
+ for (i = 0; i < 5; i++) {
+ werase (subWin);
+ box(subWin, ACS_VLINE, ACS_HLINE);
+ mvwprintw (subWin, 1, 1, "Time = %d", i);
+ wrefresh(subWin);
+ sleep(1);
+ flushinp();
+ }
+
+ delwin (subWin);
+ werase(win);
+ flash();
+ wrefresh(win);
+ sleep(1);
+
+ mvwaddstr(win, 2, 1, "Press a key");
+ wmove(win, 9, 10);
+ wrefresh(win);
+ echo();
+ wgetch(win);
+ flushinp();
+
+ wmove(win, 9, 10);
+ wdelch(win);
+ mvwaddstr(win, 4, 1, "The character should now have been deleted");
+ Continue(win);
+
+ wclear (win);
+ mvwaddstr(win, 2, 1, "Press a function key or an arrow key");
+ wrefresh(win);
+ keypad(win, TRUE);
+ c = wgetch(win);
+
+ nodelay(win, TRUE);
+ wgetch(win);
+ nodelay(win, FALSE);
+
+ refresh();
+ wclear (win);
+ mvwaddstr(win, 3, 2, "The window should have moved");
+ mvwaddstr(win, 4, 2, "This text should have appeared without you pressing a key");
+ mvwprintw(win, 2, 2, "Keycode = %d", c);
+
+#ifdef FOO
+ /*
+ * This test won't be portable until vsscanf() is
+ */
+ mvwaddstr(win, 6, 2, "Enter a number then a string separated by space");
+ echo();
+ mvwscanw(win, 7, 6, "%d %s", &num,buffer);
+ mvwprintw(win, 8, 6, "String: %s Number: %d", buffer,num);
+#endif /* FOO */
+
+ Continue(win);
+}
+
+static void output_test (WINDOW *win)
+{
+ WINDOW *win1;
+ char Buffer [80];
+ chtype ch;
+
+ wclear (win);
+ mvwaddstr(win, 1, 1, "You should now have a screen in the upper left corner, and this text should have wrapped");
+ mvwin(win, 2, 1);
+ Continue(win);
+
+ nl();
+ wclear(win);
+ mvwaddstr(win, 1, 1, "A new window will appear with this text in it");
+ mvwaddstr(win, 8, 1, "Press any key to continue");
+ wrefresh(win);
+ wgetch(win);
+
+ win1 = newwin(10, 50, 15, 25);
+ if(win1 == NULL)
+ { endwin();
+ return;
+ }
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(3,COLOR_BLUE,COLOR_WHITE);
+ wattrset(win1, COLOR_PAIR(3));
+ }
+ else
+ wattrset(win1, A_NORMAL);
+#else
+ wattrset(win1, A_NORMAL);
+#endif
+ wclear (win1);
+ mvwaddstr(win1, 5, 1, "This text should appear; using overlay option");
+ copywin(win, win1,0,0,0,0,10,50,TRUE);
+
+ box(win1,ACS_VLINE,ACS_HLINE);
+ wmove(win1, 8, 26);
+ wrefresh(win1);
+ wgetch(win1);
+
+ wclear(win1);
+ wattron(win1, A_BLINK);
+ mvwaddstr(win1, 4, 1, "This blinking text should appear in only the second window");
+ wattroff(win1, A_BLINK);
+ wrefresh(win1);
+ wgetch(win1);
+ delwin(win1);
+
+ wclear(win);
+ wrefresh(win);
+ mvwaddstr(win, 6, 2, "This line shouldn't appear");
+ mvwaddstr(win, 4, 2, "Only half of the next line is visible");
+ mvwaddstr(win, 5, 2, "Only half of the next line is visible");
+ wmove(win, 6, 1);
+ wclrtobot (win);
+ wmove(win, 5, 20);
+ wclrtoeol (win);
+ mvwaddstr(win, 8, 2, "This line also shouldn't appear");
+ wmove(win, 8, 1);
+ wdeleteln(win);
+ Continue(win);
+ traceoff();
+
+ wmove (win, 5, 9);
+ ch = winch (win);
+
+ wclear(win);
+ wmove (win, 6, 2);
+ waddstr (win, "The next char should be l: ");
+ winsch (win, ch);
+ Continue(win);
+
+ wmove(win, 5, 1);
+ winsertln (win);
+ mvwaddstr(win, 5, 2, "The lines below should have moved down");
+ Continue(win);
+
+#ifdef FOO
+ /*
+ * This test won't be portable until vsscanf() is
+ */
+ wclear(win);
+ wmove(win, 2, 2);
+ wprintw(win, "This is a formatted string in a window: %d %s\n", 42, "is it");
+ mvwaddstr(win, 10, 1, "Enter a string: ");
+ wrefresh(win);
+ echo();
+ wscanw (win, "%s", Buffer);
+
+ wclear(win);
+ mvwaddstr(win, 10, 1, "Enter a string");
+ wrefresh(win);
+ clear();
+ move(0,0);
+ printw("This is a formatted string in stdscr: %d %s\n", 42, "is it");
+ mvaddstr(10, 1, "Enter a string: ");
+ refresh();
+ echo();
+ scanw ("%s", Buffer);
+#endif /* FOO */
+
+ wclear(win);
+ curs_set(2);
+ mvwaddstr(win, 1, 1, "The cursor should appear as a block");
+ Continue(win);
+
+ wclear(win);
+ curs_set(0);
+ mvwaddstr(win, 1, 1, "The cursor should have disappeared");
+ Continue(win);
+
+ wclear(win);
+ curs_set(1);
+ mvwaddstr(win, 1, 1, "The cursor should be an underline");
+ Continue(win);
+}
+
+/****************************************************************************
+ *
+ * Main sequence
+ *
+ ****************************************************************************/
+
+bool do_single_test(const char c)
+/* perform a single specified test */
+{
+ switch (c)
+ {
+ case 'a':
+ getch_test();
+ return(TRUE);
+
+ case 'b':
+ attr_test();
+ return(TRUE);
+
+ case 'c':
+ if (!has_colors())
+ (void) printf("This %s terminal does not support color.\n",
+ getenv("TERM"));
+ else
+ color_test();
+ return(TRUE);
+
+ case 'd':
+ if (!has_colors())
+ (void) printf("This %s terminal does not support color.\n",
+ getenv("TERM"));
+ else if (!can_change_color())
+ (void) printf("This %s terminal has hardwired color values.\n",
+ getenv("TERM"));
+ else
+ color_edit();
+ return(TRUE);
+
+ case 'e':
+ slk_test();
+ return(TRUE);
+
+ case 'f':
+ acs_display();
+ return(TRUE);
+
+ case 'g':
+ acs_and_scroll();
+ return(TRUE);
+
+ case 'p':
+ demo_pad();
+ return(TRUE);
+
+ case 'i':
+ input_test(stdscr);
+ return(TRUE);
+
+ case 'o':
+ output_test(stdscr);
+ return(TRUE);
+
+ case '?':
+ (void) puts("This is the ncurses capability tester.");
+ (void) puts("You may select a test from the main menu by typing the");
+ (void) puts("key letter of the choice (the letter to left of the =)");
+ (void) puts("at the > prompt. The commands `x' or `q' will exit.");
+ return(TRUE);
+ }
+
+ return(FALSE);
+}
+
+int main(const int argc, const char *argv[])
+{
+ char buf[BUFSIZ];
+
+ /* enable debugging */
+ traceon();
+
+ /* tell it we're going to play with soft keys */
+ slk_init(1);
+
+ /* we must initialize the curses data structure only once */
+ initscr();
+
+ /* tests, in general, will want these modes */
+ start_color();
+ cbreak();
+ noecho();
+ scrollok(stdscr, TRUE);
+ keypad(stdscr, TRUE);
+
+ /*
+ * Return to terminal mode, so we're guaranteed of being able to
+ * select terminal commands even if the capabilities are wrong.
+ */
+ endwin();
+
+ (void) puts("Welcome to ncurses. Press ? for help.");
+
+ do {
+ (void) puts("This is the ncurses main menu");
+ (void) puts("a = character input test");
+ (void) puts("b = character attribute test");
+ (void) puts("c = color test pattern");
+ (void) puts("d = edit RGB color values");
+ (void) puts("e = exercise soft keys");
+ (void) puts("f = display ACS characters");
+ (void) puts("g = display windows and scrolling");
+ (void) puts("p = exercise pad features");
+ (void) puts("i = subwindow input test");
+ (void) puts("o = output test");
+ (void) puts("? = get help");
+
+ (void) fputs("> ", stdout);
+ (void) fgets(buf, BUFSIZ, stdin);
+
+ if (do_single_test(buf[0])) {
+ clear();
+ refresh();
+ endwin();
+ continue;
+ }
+ } while
+ (buf[0] != 'q' && buf[0] != 'x');
+
+ exit(0);
+}
+
+/* ncurses.c ends here */
diff --git a/lib/libncurses/TESTS/newdemo.c b/lib/libncurses/TESTS/newdemo.c
new file mode 100644
index 0000000..97c368d
--- /dev/null
+++ b/lib/libncurses/TESTS/newdemo.c
@@ -0,0 +1,350 @@
+/* $Header: c:/curses/demos/RCS/newdemo.c%v 2.0 1992/11/15 03:32:03 MH Rel $
+ *
+ * newdemo.c - A demo program using PDCurses. The program illustrate
+ * the use of colours for text output.
+ */
+
+#include <stdio.h>
+#include <signal.h>
+#include <time.h>
+#include <ncurses.h>
+
+#define delay_output(x)
+
+/*
+ * The Australian map
+ */
+char *AusMap[16] =
+{
+ " A A ",
+ " N.T. AAAAA AAAA ",
+ " AAAAAAAAAAA AAAAAAAA ",
+ " AAAAAAAAAAAAAAAAAAAAAAAAA Qld.",
+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA ",
+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ",
+ " AAAAAAAAAAAAAAAAAAAAAAAAAAAA ",
+ " AAAAAAAAAAAAAAAAAAAAAAAAA N.S.W.",
+ "W.A. AAAAAAAAA AAAAAA Vic.",
+ " AAA S.A. AA",
+ " A Tas.",
+ ""
+};
+
+/*
+ * Funny messages
+ */
+#define NMESSAGES 6
+
+char *messages[] =
+{
+ "Hello from the Land Down Under",
+ "The Land of crocs. and a big Red Rock",
+ "Where the sunflower runs along the highways",
+ "the dusty red roads lead one to loneliness",
+ "Blue sky in the morning and",
+ "freezing nights and twinkling stars",
+ ""
+};
+
+/*
+ * Main driver
+ */
+main()
+{
+WINDOW *win;
+int w, x, y, i, j, c, len;
+time_t t;
+char buffer[80], *message;
+int width, height;
+chtype save[80];
+void trap();
+
+ initscr();
+ start_color();
+ cbreak();
+ signal(SIGINT, trap);
+ width = 48;
+ height = 14; /* Create a drawing window */
+ win = newwin(height, width, (LINES-height)/2, (COLS-width)/2);
+ if(win == NULL)
+ { endwin();
+ return 1;
+ }
+
+ while(1)
+ { init_pair(1,COLOR_WHITE,COLOR_BLUE);
+ wattrset(win, COLOR_PAIR(1));
+ werase(win);
+
+ init_pair(2,COLOR_RED,COLOR_RED);
+ wattrset(win, COLOR_PAIR(2));
+ box(win, ACS_VLINE, ACS_HLINE);
+ wrefresh(win);
+ /* Do ramdom output of a character */
+ wattrset(win, COLOR_PAIR(1));
+ c = 'a';
+ for(i=0; i < 5000; ++i)
+ { x = rand() % (width-2) + 1;
+ y = rand() % (height-2) + 1;
+ mvwaddch(win, y, x, c);
+ wrefresh(win);
+ nodelay(win,TRUE);
+ if (wgetch(win) != ERR)
+ break;
+ if(i == 2000)
+ { c = 'b';
+ init_pair(3,COLOR_CYAN,COLOR_YELLOW);
+ wattron(win, COLOR_PAIR(3));
+ }
+ }
+
+ SubWinTest(win);
+ /* Erase and draw green window */
+ init_pair(4,COLOR_YELLOW,COLOR_GREEN);
+ wattrset(win, COLOR_PAIR(4) | A_BOLD);
+ werase(win);
+ wrefresh(win);
+ /* Draw RED bounding box */
+ wattrset(win, COLOR_PAIR(2));
+ box(win, ' ', ' ');
+ wrefresh(win);
+ /* Display Australia map */
+ wattrset(win, COLOR_PAIR(4) | A_BOLD);
+ i = 0;
+ while(*AusMap[i])
+ { mvwaddstr(win, i+1, 8, AusMap[i]);
+ wrefresh(win);
+ delay_output(100);
+ ++i;
+ }
+
+ init_pair(5,COLOR_BLUE,COLOR_WHITE);
+ wattrset(win, COLOR_PAIR(5) | A_BLINK);
+ mvwaddstr(win, height-2, 6, " PDCurses 2.1 for DOS, OS/2 and Unix");
+ wrefresh(win);
+
+ /* Draw running messages */
+ init_pair(6,COLOR_YELLOW,COLOR_WHITE);
+ wattrset(win, COLOR_PAIR(6));
+ message = messages[0];
+ len = strlen(message);
+ j = 0;
+ i = 2;
+ w = width-2;
+ while(j < NMESSAGES)
+ { strncpy(buffer, message, w - i);
+ buffer[w-i] = 0;
+ mvwaddstr(win, height/2, i, buffer);
+ if(w - i < len)
+ { memset(buffer, ' ', i);
+ strcpy(buffer, message + (w - i));
+ buffer[strlen(buffer)] = ' ';
+ buffer[i-2] = '\0';
+ mvwaddstr(win, height/2, 2, buffer);
+ }
+ wrefresh(win);
+ nodelay(win,TRUE);
+ if (wgetch(win) != ERR)
+ { flushinp();
+ break;
+ }
+ mvwaddch(win, height/2, i, ' ');
+ i = ++i % w;
+ if(i < 2)
+ { message = messages[++j%NMESSAGES];
+ memset(buffer, ' ', w-2);
+ buffer[w-2] = 0;
+ mvwaddstr(win, height/2, 2, buffer);
+ i = 2;
+ }
+ delay_output(300);
+ }
+
+ j = 0;
+ /* Draw running As across in RED */
+ init_pair(7,COLOR_RED,COLOR_GREEN);
+ wattron(win, COLOR_PAIR(7));
+ for(i=2; i < width - 4; ++i)
+ { c = mvwinch(win, 4, i);
+ save[j++] = c;
+ c = c & 0x7f;
+ mvwaddch(win, 4, i, c);
+ }
+ wrefresh(win);
+
+ /* Put a message up wait for a key */
+ i = height-2;
+ wattrset(win, COLOR_PAIR(5));
+ mvwaddstr(win, i, 5, " Type a key to continue or 'Q' to quit ");
+ wrefresh(win);
+
+ if(WaitForUser() == 1)
+ break;
+
+ j = 0; /* Restore the old line */
+ for(i=2; i < width - 4; ++i)
+ mvwaddch(win, 4, i, save[j++]);
+ wrefresh(win);
+
+ BouncingBalls(win);
+ /* Put a message up wait for a key */
+ i = height-2;
+ wattrset(win, COLOR_PAIR(5));
+ mvwaddstr(win, i, 5, " Type a key to continue or 'Q' to quit ");
+ wrefresh(win);
+ if(WaitForUser() == 1)
+ break;
+ }
+exit:
+ endwin();
+ return 0;
+}
+
+/*
+ * Test sub windows
+ */
+SubWinTest(WINDOW *win)
+{
+int w, h, sw, sh, bx, by;
+WINDOW *swin1, *swin2, *swin3;
+
+ w = win->_maxx;
+ h = win->_maxy;
+ bx = win->_begx;
+ by = win->_begy;
+ sw = w / 3;
+ sh = h / 3;
+ if((swin1 = subwin(win, sh, sw, by+3, bx+5)) == NULL)
+ return 1;
+ if((swin2 = subwin(win, sh, sw, by+4, bx+8)) == NULL)
+ return 1;
+ if((swin3 = subwin(win, sh, sw, by+5, bx+11)) == NULL)
+ return 1;
+
+ init_pair(8,COLOR_RED,COLOR_BLUE);
+ wattrset(swin1, COLOR_PAIR(8));
+ werase(swin1);
+ mvwaddstr(swin1, 0, 3, "Sub-window 1");
+ wrefresh(swin1);
+
+ init_pair(8,COLOR_CYAN,COLOR_MAGENTA);
+ wattrset(swin2, COLOR_PAIR(8));
+ werase(swin2);
+ mvwaddstr(swin2, 0, 3, "Sub-window 2");
+ wrefresh(swin2);
+
+ init_pair(8,COLOR_YELLOW,COLOR_GREEN);
+ wattrset(swin3, COLOR_PAIR(8));
+ werase(swin3);
+ mvwaddstr(swin3, 0, 3, "Sub-window 3");
+ wrefresh(swin3);
+
+ delwin(swin1);
+ delwin(swin2);
+ delwin(swin3);
+ WaitForUser();
+ return 0;
+}
+
+/*
+ * Bouncing balls
+ */
+BouncingBalls(WINDOW *win)
+{
+chtype c1, c2, c3;
+int w, h;
+int x1, y1, xd1, yd1;
+int x2, y2, xd2, yd2;
+int x3, y3, xd3, yd3;
+
+ w = win->_maxx;
+ h = win->_maxy;
+ x1 = 2 + rand() % (w - 4);
+ y1 = 2 + rand() % (h - 4);
+ x2 = 2 + rand() % (w - 4);
+ y2 = 2 + rand() % (h - 4);
+ x3 = 2 + rand() % (w - 4);
+ y3 = 2 + rand() % (h - 4);
+ xd1 = 1; yd1 = 1;
+ xd2 = 1; yd2 = 0;
+ xd3 = 0; yd3 = 1;
+ nodelay(win,TRUE);
+ while(wgetch(win) == ERR)
+ { x1 = xd1 > 0 ? ++x1 : --x1;
+ if(x1 <= 1 || x1 >= w - 2)
+ xd1 = xd1 ? 0 : 1;
+ y1 = yd1 > 0 ? ++y1 : --y1;
+ if(y1 <= 1 || y1 >= h - 2)
+ yd1 = yd1 ? 0 : 1;
+
+ x2 = xd2 > 0 ? ++x2 : --x2;
+ if(x2 <= 1 || x2 >= w - 2)
+ xd2 = xd2 ? 0 : 1;
+ y2 = yd2 > 0 ? ++y2 : --y2;
+ if(y2 <= 1 || y2 >= h - 2)
+ yd2 = yd2 ? 0 : 1;
+
+ x3 = xd3 > 0 ? ++x3 : --x3;
+ if(x3 <= 1 || x3 >= w - 2)
+ xd3 = xd3 ? 0 : 1;
+ y3 = yd3 > 0 ? ++y3 : --y3;
+ if(y3 <= 1 || y3 >= h - 2)
+ yd3 = yd3 ? 0 : 1;
+
+ c1 = mvwinch(win, y1, x1);
+ c2 = mvwinch(win, y2, x2);
+ c3 = mvwinch(win, y3, x3);
+
+ init_pair(8,COLOR_RED,COLOR_BLUE);
+ wattrset(win, COLOR_PAIR(8));
+ mvwaddch(win, y1, x1, 'O');
+ init_pair(8,COLOR_BLUE,COLOR_RED);
+ wattrset(win, COLOR_PAIR(8));
+ mvwaddch(win, y2, x2, '*');
+ init_pair(8,COLOR_YELLOW,COLOR_WHITE);
+ wattrset(win, COLOR_PAIR(8));
+ mvwaddch(win, y3, x3, '@');
+ wmove(win, 0, 0);
+ wrefresh(win);
+ mvwaddch(win, y1, x1, c1);
+ mvwaddch(win, y2, x2, c2);
+ mvwaddch(win, y3, x3, c3);
+ delay_output(150);
+ }
+ return 0;
+}
+
+/*
+ * Wait for user
+ */
+int WaitForUser()
+{
+ time_t t;
+ chtype key;
+
+ nodelay(stdscr,TRUE);
+ t = time((time_t *)0);
+ while(1)
+ {
+ if ((key = getch()) != ERR)
+ {
+ if (key == 'q' || key == 'Q')
+ return 1;
+ else
+ return 0;
+ }
+ if (time((time_t *)0) - t > 5)
+ return 0;
+ }
+}
+
+/*
+ * Trap interrupt
+ */
+void trap()
+{
+ endwin();
+ exit(0);
+}
+
+/* End of DEMO.C */
diff --git a/lib/libncurses/TESTS/over.c b/lib/libncurses/TESTS/over.c
new file mode 100644
index 0000000..530e48d
--- /dev/null
+++ b/lib/libncurses/TESTS/over.c
@@ -0,0 +1,120 @@
+/*********************************************************************
+ * [program] overwrite() - Play with overwrite() function to *
+ * attempt pop-up windows. *
+ * ----------------------------------------------------------------- *
+ * [written] 1-Feb-1993 by Neal Ensor (ensor@cs.utk.edu) *
+ * ----------------------------------------------------------------- *
+ * [notes] Originally written on SVR4 UNIX, then recompiled on *
+ * Linux (Slackware 1.1.1, ncurses 1.8.1) *
+ * ----------------------------------------------------------------- *
+ * [problem] On ncurses, the overwrite() function doesn't seem to *
+ * overwrite. Maybe I'm missing something, but this *
+ * program in SVR4 displays three windows, waits for a *
+ * keypress, then removes the top window. With ncurses, *
+ * nothing changes on the display. *
+ *********************************************************************/
+
+# include <ncurses.h> /* ncurses include lives here */
+
+main()
+{
+ /****************************************************************
+ * Declare three little window pointers... *
+ ****************************************************************/
+ WINDOW *win, *win1, *win2;
+
+ /****************************************************************
+ * Set up the screen... *
+ ****************************************************************/
+ initscr();
+ traceon();
+ noecho();
+ nonl();
+ cbreak();
+ refresh();
+
+ /****************************************************************
+ * Draw three overlapping windows. *
+ ****************************************************************/
+ win=newwin(6,45, 6,6);
+ win1=newwin(10,20,5,5);
+ win2=newwin(10,30,7,7);
+
+ /****************************************************************
+ * Box them, and print a hidden message... *
+ ****************************************************************/
+ box(win, 0, 0);
+ box(win1, 0, 0);
+ box(win2, 0, 0);
+ mvwprintw(win1, 6,6, "Hey!");
+ mvwaddch(win, 1, 1, '0');
+ mvwaddch(win1, 1, 1, '1');
+ mvwaddch(win2, 1, 1, '2');
+ wnoutrefresh(win);
+ wnoutrefresh(win1);
+ wnoutrefresh(win2);
+ doupdate();
+
+ /****************************************************************
+ * Await a keypress to show what we've done so far. *
+ ****************************************************************/
+ getch();
+
+ /****************************************************************
+ * Now, overwrite win2 with contents of all lower windows IN *
+ * ORDER from the stdscr up... *
+ ****************************************************************/
+ if (overwrite(stdscr, win2) == ERR)
+ fprintf(stderr, "overwrite(stdscr, win2) failed!\n");
+
+ touchwin(stdscr); wnoutrefresh(stdscr);
+ touchwin(win); wnoutrefresh(win);
+ touchwin(win1); wnoutrefresh(win1);
+ touchwin(win2); wnoutrefresh(win2);
+ doupdate();
+
+ getch();
+ if (overwrite(win, win2) == ERR)
+ fprintf(stderr, "overwrite(win, win2) failed!\n");
+
+ touchwin(stdscr); wnoutrefresh(stdscr);
+ touchwin(win); wnoutrefresh(win);
+ touchwin(win1); wnoutrefresh(win1);
+ touchwin(win2); wnoutrefresh(win2);
+ doupdate();
+
+ getch();
+ if (overwrite(win1, win2) == ERR)
+ fprintf(stderr, "overwrite(win1, win2) failed!\n");
+
+ /****************************************************************
+ * Perform touches, and hidden refreshes on each window. *
+ * ------------------------------------------------------------ *
+ * NOTE: If you replace the wnoutrefresh() call with wrefresh()*
+ * you can see all windows being redrawn untouched. *
+ ****************************************************************/
+ touchwin(stdscr); wnoutrefresh(stdscr);
+ touchwin(win); wnoutrefresh(win);
+ touchwin(win1); wnoutrefresh(win1);
+ touchwin(win2); wnoutrefresh(win2);
+ doupdate();
+
+ /****************************************************************
+ * At this point, win2 should be "destroyed"; having all other *
+ * window contents overwritten onto it. The doupdate() should *
+ * effectively remove it from the screen, leaving the others *
+ * untouched. On SVR4, this happens, but not with ncurses. *
+ * I'd suspect something in overwrite() causes this, as nothing *
+ * appears to be overwritten after the calls, with no errors *
+ * being reported. This was compiled on my Linux from Slackware*
+ * 1.1.1, with ncurses1.8.1 recompiled on it, using the console *
+ * entry from the "new" terminfo from ncurses1.8.1. *
+ ****************************************************************/
+ getch();
+
+ /****************************************************************
+ * Clean up our act and exit. *
+ ****************************************************************/
+ endwin();
+}
+
diff --git a/lib/libncurses/TESTS/rain.c b/lib/libncurses/TESTS/rain.c
new file mode 100644
index 0000000..83951ae
--- /dev/null
+++ b/lib/libncurses/TESTS/rain.c
@@ -0,0 +1,96 @@
+#include <ncurses.h>
+#include <signal.h>
+/* rain 11/3/1980 EPS/CITHEP */
+
+#define cursor(col,row) move(row,col)
+
+float ranf();
+void onsig();
+
+main(argc,argv)
+int argc;
+char *argv[];
+{
+int x, y, j;
+static int xpos[5], ypos[5];
+float r;
+float c;
+
+ for (j=SIGHUP;j<=SIGTERM;j++)
+ if (signal(j,SIG_IGN)!=SIG_IGN) signal(j,onsig);
+
+ initscr();
+ nl();
+ noecho();
+ r = (float)(LINES - 4);
+ c = (float)(COLS - 4);
+ for (j=5;--j>=0;) {
+ xpos[j]=(int)(c* ranf())+2;
+ ypos[j]=(int)(r* ranf())+2;
+ }
+ for (j=0;;) {
+ x=(int)(c*ranf())+2;
+ y=(int)(r*ranf())+2;
+
+ cursor(x,y); addch('.');
+
+ cursor(xpos[j],ypos[j]); addch('o');
+
+ if (j==0) j=4; else --j;
+ cursor(xpos[j],ypos[j]); addch('O');
+
+ if (j==0) j=4; else --j;
+ cursor(xpos[j],ypos[j]-1);
+ addch('-');
+ cursor(xpos[j]-1,ypos[j]);
+ addstr("|.|");
+ cursor(xpos[j],ypos[j]+1);
+ addch('-');
+
+ if (j==0) j=4; else --j;
+ cursor(xpos[j],ypos[j]-2);
+ addch('-');
+ cursor(xpos[j]-1,ypos[j]-1);
+ addstr("/ \\");
+ cursor(xpos[j]-2,ypos[j]);
+ addstr("| O |");
+ cursor(xpos[j]-1,ypos[j]+1);
+ addstr("\\ /");
+ cursor(xpos[j],ypos[j]+2);
+ addch('-');
+
+ if (j==0) j=4; else --j;
+ cursor(xpos[j],ypos[j]-2);
+ addch(' ');
+ cursor(xpos[j]-1,ypos[j]-1);
+ addstr(" ");
+ cursor(xpos[j]-2,ypos[j]);
+ addstr(" ");
+ cursor(xpos[j]-1,ypos[j]+1);
+ addstr(" ");
+ cursor(xpos[j],ypos[j]+2);
+ addch(' ');
+ xpos[j]=x; ypos[j]=y;
+ refresh();
+ }
+}
+
+void
+onsig(n)
+int n;
+{
+ endwin();
+ exit(0);
+}
+
+float
+ranf()
+{
+ float rv;
+ long r = rand();
+
+ r &= 077777;
+ rv =((float)r/32767.);
+ return rv;
+}
+
diff --git a/lib/libncurses/TESTS/scroll.c b/lib/libncurses/TESTS/scroll.c
new file mode 100644
index 0000000..428a064
--- /dev/null
+++ b/lib/libncurses/TESTS/scroll.c
@@ -0,0 +1,30 @@
+#include <ncurses.h>
+
+main()
+{
+int i;
+
+ initscr();
+ noecho();
+ scrollok(stdscr, TRUE);
+ setscrreg(0, 9);
+ mvaddstr(0,0,"aaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
+ mvaddstr(1,0,"bbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
+ mvaddstr(2,0,"ccccccccccccccccccccccccccccc");
+ mvaddstr(3,0,"ddddddddddddddddddddddddddddd");
+ mvaddstr(4,0,"eeeeeeeeeeeeeeeeeeeeeeeeeeeee");
+ mvaddstr(5,0,"fffffffffffffffffffffffffffff");
+ mvaddstr(6,0,"ggggggggggggggggggggggggggggg");
+ mvaddstr(7,0,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
+ mvaddstr(8,0,"iiiiiiiiiiiiiiiiiiiiiiiiiiiii");
+ mvaddstr(9,0,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
+ refresh();
+ for (i = 0; i < 4; i++) {
+ getch();
+ scrl(-1);
+ refresh();
+ }
+ getch();
+ endwin();
+
+}
diff --git a/lib/libncurses/TESTS/scroll2.c b/lib/libncurses/TESTS/scroll2.c
new file mode 100644
index 0000000..53abaa3
--- /dev/null
+++ b/lib/libncurses/TESTS/scroll2.c
@@ -0,0 +1,91 @@
+#include <ncurses.h>
+#define ROWS 20
+#define scroll_window wscrl
+
+main()
+{
+ int i;
+ WINDOW * w;
+
+
+ initscr();
+ cbreak();
+ noecho();
+ w = newwin (ROWS, 35, 2, 25);
+ scrollok(w, TRUE);
+ wsetscrreg(w, 0, ROWS-1);
+
+#ifdef LELE
+ mvaddstr (0, 0, "With my function");
+#else
+ mvaddstr (0, 0, "With the original wscrl");
+#endif
+ refresh();
+
+
+ for (i=0; i<ROWS-1; i++)
+ {
+ mvwprintw (w, i, 0, "Line number %d", i);
+ }
+ mvwaddstr (w, ROWS-1, 0, "Moving one line at a time");
+ wrefresh(w);
+ for (i = 0; i < 4; i++) {
+ getch();
+ scroll_window (w, 1);
+ wrefresh(w);
+ }
+ for (i = 0; i < 4; i++) {
+ getch();
+ scroll_window (w, -1);
+ wrefresh(w);
+ }
+ getch();
+ wclear (w);
+
+
+ for (i=0; i<ROWS-1; i++)
+ {
+ mvwprintw (w, i, 0, "Line number %d", i);
+ }
+ mvwaddstr (w, ROWS-1, 0, "Moving two line at a time");
+#ifndef LELE
+ mvaddstr (0, 30, "** THIS FAILS ON MY MACHINE WITH A BUS ERROR
+**");
+#endif
+
+
+ wrefresh(w);
+ for (i = 0; i < 4; i++) {
+ getch();
+ scroll_window (w, 2);
+ wrefresh(w);
+ }
+ for (i = 0; i < 4; i++) {
+ getch();
+ scroll_window (w, -2);
+ wrefresh(w);
+ }
+ getch();
+ wclear (w);
+ for (i=0; i<ROWS-1; i++)
+ {
+ mvwprintw (w, i, 0, "Line number %d", i);
+ }
+ mvwaddstr (w, ROWS-1, 0, "Moving three line at a time");
+ wrefresh(w);
+ for (i = 0; i < 4; i++) {
+ getch();
+ scroll_window (w, 3);
+ wrefresh(w);
+ }
+ for (i = 0; i < 4; i++) {
+ getch();
+ scroll_window (w, -3);
+ wrefresh(w);
+ }
+ getch();
+
+
+ endwin();
+}
+
diff --git a/lib/libncurses/TESTS/scroll3.c b/lib/libncurses/TESTS/scroll3.c
new file mode 100644
index 0000000..1d63c46
--- /dev/null
+++ b/lib/libncurses/TESTS/scroll3.c
@@ -0,0 +1,51 @@
+#include <ncurses.h>
+
+main(int argc, char **argv)
+{
+ WINDOW *w, *x;
+
+ initscr();
+ w = newwin(0, 0, 0, 0);
+ if (argc > 2)
+ x = newwin(0, 0, 0, 0);
+ scrollok(w, TRUE);
+ if (argc > 2)
+ scrollok(x, TRUE);
+ idlok(w, TRUE);
+ if (argc > 2)
+ idlok(x, TRUE);
+ wmove(w, LINES - 1, 0);
+ waddstr(w, "test 1 in w");
+ wrefresh(w);
+ sleep(1);
+ if (argc == 2 || argc == 4)
+ {
+ waddch(w, '\n');
+ sleep(1);
+ waddch(w, '\n');
+ sleep(1);
+ waddch(w, '\n');
+ sleep(1);
+ beep();
+ wrefresh(w);
+ }
+ sleep(1);
+ if (argc > 2)
+ {
+ wmove(x, LINES - 1, 0);
+ waddstr(x, "test 2 in x");
+ sleep(1);
+ waddch(x, '\n');
+ sleep(1);
+ waddch(x, '\n');
+ sleep(1);
+ waddch(x, '\n');
+ sleep(1);
+ beep();
+ wrefresh(w);
+ sleep(1);
+ }
+ endwin();
+ return 0;
+}
+
diff --git a/lib/libncurses/TESTS/test.c b/lib/libncurses/TESTS/test.c
new file mode 100644
index 0000000..1fc3e6e
--- /dev/null
+++ b/lib/libncurses/TESTS/test.c
@@ -0,0 +1,27 @@
+
+#include <ncurses.h>
+
+main()
+{
+int x, y;
+
+ initscr();
+ cbreak();
+ nodelay(stdscr, TRUE);
+
+ for (y = 0; y < 43; y++)
+ for (x =0; x < 132; x++) {
+ move(y,x);
+ printw("X");
+ refresh();
+ if (!getch()) {
+ beep();
+ sleep(1);
+ }
+ }
+
+ nocbreak();
+ endwin();
+}
+
+
diff --git a/lib/libncurses/TESTS/testcurs.c b/lib/libncurses/TESTS/testcurs.c
new file mode 100644
index 0000000..3c92027
--- /dev/null
+++ b/lib/libncurses/TESTS/testcurs.c
@@ -0,0 +1,532 @@
+/*
+ *
+ * This is a test program for the PDCurses screen package for IBM PC type
+ * machines.
+ * This program was written by John Burnell (johnb@kea.am.dsir.govt.nz)
+ *
+ */
+
+#include <stdio.h>
+#include <ncurses.h>
+
+#ifdef __STDC__
+void inputTest (WINDOW *);
+void scrollTest (WINDOW *);
+void introTest (WINDOW *);
+int initTest (WINDOW **);
+void outputTest (WINDOW *);
+void padTest (WINDOW *);
+void resizeTest (WINDOW *);
+void display_menu(int,int);
+#else
+void inputTest ();
+void scrollTest ();
+void introTest ();
+int initTest ();
+void outputTest ();
+void padTest ();
+void resizeTest ();
+void display_menu();
+#endif
+
+struct commands
+{
+ char *text;
+#ifdef __STDC__
+ void (*function)(WINDOW *);
+#else
+ void (*function)();
+#endif
+};
+typedef struct commands COMMAND;
+#define MAX_OPTIONS 6
+COMMAND command[MAX_OPTIONS] =
+{
+ {"Intro Test",introTest},
+ {"Pad Test",padTest},
+ {"Resize Test",resizeTest},
+ {"Scroll Test",scrollTest},
+ {"Input Test",inputTest},
+ {"Output Test",outputTest}
+};
+
+int width, height;
+
+main()
+{
+WINDOW *win;
+int key,old_option=(-1),new_option=0;
+bool quit=FALSE;
+
+#ifdef PDCDEBUG
+ PDC_debug("testcurs started\n");
+#endif
+ if (!initTest (&win)) {return 1;}
+
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(1,COLOR_WHITE,COLOR_BLUE);
+ wattrset(win, COLOR_PAIR(1));
+ }
+ else
+ wattrset(win, A_REVERSE);
+#else
+ wattrset(win, A_REVERSE);
+#endif
+
+ erase();
+ display_menu(old_option,new_option);
+ while(1)
+ {
+ noecho();
+ keypad(stdscr,TRUE);
+ raw();
+ key = getch();
+ switch(key)
+ {
+ case 10:
+ case 13:
+ case KEY_ENTER:
+ erase();
+ refresh();
+ (*command[new_option].function)(win);
+ erase();
+ display_menu(old_option,new_option);
+ break;
+ case KEY_UP:
+ new_option = (new_option == 0) ? new_option : new_option-1;
+ display_menu(old_option,new_option);
+ break;
+ case KEY_DOWN:
+ new_option = (new_option == MAX_OPTIONS-1) ? new_option : new_option+1;
+ display_menu(old_option,new_option);
+ break;
+ case 'Q':
+ case 'q':
+ quit = TRUE;
+ break;
+ default: break;
+ }
+ if (quit == TRUE)
+ break;
+ }
+
+ delwin (win);
+
+ endwin();
+ return 0;
+}
+#ifdef __STDC__
+void Continue (WINDOW *win)
+#else
+void Continue (win)
+WINDOW *win;
+#endif
+{
+ wmove(win, 10, 1);
+/* wclrtoeol(win);
+*/ mvwaddstr(win, 10, 1, " Press any key to continue");
+ wrefresh(win);
+ raw();
+ wgetch(win);
+}
+#ifdef __STDC_
+int initTest (WINDOW **win)
+#else
+int initTest (win)
+WINDOW **win;
+#endif
+{
+#ifdef PDCDEBUG
+ PDC_debug("initTest called\n");
+#endif
+ initscr();
+#ifdef PDCDEBUG
+ PDC_debug("after initscr()\n");
+#endif
+#ifdef A_COLOR
+ if (has_colors())
+ start_color();
+#endif
+ width = 60;
+ height = 13; /* Create a drawing window */
+ *win = newwin(height, width, (LINES-height)/2, (COLS-width)/2);
+ if(*win == NULL)
+ { endwin();
+ return 1;
+ }
+}
+#ifdef __STDC__
+void introTest (WINDOW *win)
+#else
+void introTest (win)
+WINDOW *win;
+#endif
+{
+ beep ();
+ werase(win);
+
+ box(win, ACS_VLINE, ACS_HLINE);
+ wrefresh(win);
+ cbreak ();
+ mvwaddstr(win, 1, 1, "You should have rectangle in the middle of the screen");
+ mvwaddstr(win, 2, 1, "You should have heard a beep");
+ Continue(win);
+ return;
+}
+#ifdef __STDC__
+void scrollTest (WINDOW *win)
+#else
+void scrollTest (win)
+WINDOW *win;
+#endif
+{
+ int i;
+ int OldX, OldY;
+ char *Message = "The window will now scroll slowly";
+
+ mvwprintw (win, height - 2, 1, Message);
+ wrefresh (win);
+ scrollok(win, TRUE);
+ for (i = 1; i <= height; i++) {
+ usleep (250);
+ scroll(win);
+ wrefresh (win);
+ };
+
+ getmaxyx (win, OldY, OldX);
+ mvwprintw (win, 6, 1, "The top of the window will scroll");
+ wmove (win, 1, 1);
+ wsetscrreg (win, 0, 4);
+ box(win, ACS_VLINE, ACS_HLINE);
+ wrefresh (win);
+ for (i = 1; i <= 5; i++) {
+ usleep (500);
+ scroll(win);
+ wrefresh (win);
+ };
+ wsetscrreg (win, 0, --OldY);
+
+}
+#ifdef __STDC__
+void inputTest (WINDOW *win)
+#else
+void inputTest (win)
+WINDOW *win;
+#endif
+{
+ int w, h, bx, by, sw, sh, i, c,num;
+ char buffer [80];
+ WINDOW *subWin;
+ wclear (win);
+
+ w = win->_maxx;
+ h = win->_maxy;
+ bx = win->_begx;
+ by = win->_begy;
+ sw = w / 3;
+ sh = h / 3;
+ if((subWin = subwin(win, sh, sw, by + h - sh - 2, bx + w - sw - 2)) == NULL)
+ return;
+
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(2,COLOR_CYAN,COLOR_BLUE);
+ wattrset(subWin, COLOR_PAIR(2) | A_BOLD);
+ }
+ else
+ wattrset(subWin, A_BOLD);
+#else
+ wattrset(subWin, A_BOLD);
+#endif
+ box(subWin, ACS_VLINE, ACS_HLINE);
+ wrefresh(win);
+
+ nocbreak();
+ mvwaddstr(win, 2, 1, "Press some keys for 5 seconds");
+ mvwaddstr(win, 1, 1, "Pressing ^C should do nothing");
+ wrefresh(win);
+
+ for (i = 0; i < 5; i++) {
+ werase (subWin);
+ box(subWin, ACS_VLINE, ACS_HLINE);
+ mvwprintw (subWin, 1, 1, "Time = %d", i);
+ wrefresh(subWin);
+ usleep(1000);
+ flushinp();
+ }
+
+ delwin (subWin);
+ werase(win);
+ flash();
+ wrefresh(win);
+ usleep(500);
+
+ mvwaddstr(win, 2, 1, "Press a key, followed by ENTER");
+ wmove(win, 9, 10);
+ wrefresh(win);
+ echo();
+ noraw();
+ wgetch(win);
+ flushinp();
+
+ wmove(win, 9, 10);
+ wdelch(win);
+ mvwaddstr(win, 4, 1, "The character should now have been deleted");
+ Continue(win);
+
+ wclear (win);
+ mvwaddstr(win, 2, 1, "Press a function key or an arrow key");
+ wrefresh(win);
+ keypad(win, TRUE);
+ raw();
+ c = wgetch(win);
+
+ nodelay(win, TRUE);
+ wgetch(win);
+ nodelay(win, FALSE);
+
+ refresh();
+ wclear (win);
+ mvwaddstr(win, 3, 2, "The window should have moved");
+ mvwaddstr(win, 4, 2, "This text should have appeared without you pressing a key");
+ mvwprintw(win, 2, 2, "Keycode = %d", c);
+ mvwaddstr(win, 6, 2, "Enter a number then a string seperated by space");
+ echo();
+ noraw();
+ mvwscanw(win, 7, 6, "%d %s", &num,buffer);
+ mvwprintw(win, 8, 6, "String: %s Number: %d", buffer,num);
+ Continue(win);
+}
+#ifdef __STDC__
+void outputTest (WINDOW *win)
+#else
+void outputTest (win)
+WINDOW *win;
+#endif
+{
+ WINDOW *win1;
+ char Buffer [80];
+ chtype ch;
+
+ traceon();
+ nl ();
+ wclear (win);
+ mvwaddstr(win, 1, 1, "You should now have a screen in the upper left corner, and this text should have wrapped");
+ mvwin(win, 2, 1);
+ Continue(win);
+
+ wclear(win);
+ mvwaddstr(win, 1, 1, "A new window will appear with this text in it");
+ mvwaddstr(win, 8, 1, "Press any key to continue");
+ wrefresh(win);
+ wgetch(win);
+
+ win1 = newwin(10, 50, 15, 25);
+ if(win1 == NULL)
+ { endwin();
+ return;
+ }
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(3,COLOR_BLUE,COLOR_WHITE);
+ wattrset(win1, COLOR_PAIR(3));
+ }
+ else
+ wattrset(win1, A_NORMAL);
+#else
+ wattrset(win1, A_NORMAL);
+#endif
+ wclear (win1);
+ mvwaddstr(win1, 5, 1, "This text should appear; using overlay option");
+ copywin(win, win1,0,0,0,0,10,50,TRUE);
+
+#ifdef UNIX
+ box(win1,ACS_VLINE,ACS_HLINE);
+#else
+ box(win1,0xb3,0xc4);
+#endif
+ wmove(win1, 8, 26);
+ wrefresh(win1);
+ wgetch(win1);
+
+ wclear(win1);
+ wattron(win1, A_BLINK);
+ mvwaddstr(win1, 4, 1, "This blinking text should appear in only the second window");
+ wattroff(win1, A_BLINK);
+ wrefresh(win1);
+ wgetch(win1);
+ delwin(win1);
+
+ wclear(win);
+ wrefresh(win);
+ mvwaddstr(win, 6, 2, "This line shouldn't appear");
+ mvwaddstr(win, 4, 2, "Only half of the next line is visible");
+ mvwaddstr(win, 5, 2, "Only half of the next line is visible");
+ wmove(win, 6, 1);
+ wclrtobot (win);
+ wmove(win, 5, 20);
+ wclrtoeol (win);
+ mvwaddstr(win, 8, 2, "This line also shouldn't appear");
+ wmove(win, 8, 1);
+ wdeleteln(win);
+ Continue(win);
+ traceoff();
+
+ wmove (win, 5, 9);
+ ch = winch (win);
+
+ wclear(win);
+ wmove (win, 6, 2);
+ waddstr (win, "The next char should be l: ");
+ winsch (win, ch);
+ Continue(win);
+
+ wmove(win, 5, 1);
+ winsertln (win);
+ mvwaddstr(win, 5, 2, "The lines below should have moved down");
+ Continue(win);
+
+ wclear(win);
+ wmove(win, 2, 2);
+ wprintw(win, "This is a formatted string in a window: %d %s\n", 42, "is it");
+ mvwaddstr(win, 10, 1, "Enter a string: ");
+ wrefresh(win);
+ noraw();
+ echo();
+ wscanw (win, "%s", Buffer);
+
+ wclear(win);
+ mvwaddstr(win, 10, 1, "Enter a string");
+ wrefresh(win);
+ clear();
+ move(0,0);
+ printw("This is a formatted string in stdscr: %d %s\n", 42, "is it");
+ mvaddstr(10, 1, "Enter a string: ");
+ refresh();
+ noraw();
+ echo();
+ scanw ("%s", Buffer);
+
+ wclear(win);
+ curs_set(2);
+ mvwaddstr(win, 1, 1, "The cursor should appear as a block");
+ Continue(win);
+
+ wclear(win);
+ curs_set(0);
+ mvwaddstr(win, 1, 1, "The cursor should have disappeared");
+ Continue(win);
+
+ wclear(win);
+ curs_set(1);
+ mvwaddstr(win, 1, 1, "The cursor should be an underline");
+ Continue(win);
+}
+
+#ifdef __STDC__
+void resizeTest(WINDOW *dummy)
+#else
+void resizeTest(dummy)
+WINDOW *dummy;
+#endif
+{
+ WINDOW *win1;
+ char Buffer [80];
+ chtype ch;
+
+ savetty ();
+
+ clear();
+ refresh();
+#ifdef __PDCURSES__
+ resize(50);
+#endif
+
+
+ win1 = newwin(11, 50, 14, 25);
+ if(win1 == NULL)
+ { endwin();
+ return;
+ }
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(3,COLOR_BLUE,COLOR_WHITE);
+ wattrset(win1, COLOR_PAIR(3));
+ }
+#endif
+ wclear (win1);
+
+ mvwaddstr(win1, 1, 1, "The screen may now have 50 lines");
+ Continue(win1);
+
+ resetty ();
+
+ wclear (win1);
+ mvwaddstr(win1, 1, 1, "The screen should now be reset");
+ Continue(win1);
+
+ delwin(win1);
+
+ clear();
+ refresh();
+
+}
+#ifdef __STDC__
+void padTest(WINDOW *dummy)
+#else
+void padTest(dummy)
+WINDOW *dummy;
+#endif
+{
+WINDOW *pad;
+
+ pad = newpad(50,100);
+ mvwaddstr(pad, 5, 2, "This is a new pad");
+ mvwaddstr(pad, 8, 0, "The end of this line should be truncated here:abcd");
+ mvwaddstr(pad,11, 1, "This line should not appear.");
+ wmove(pad, 10, 1);
+ wclrtoeol(pad);
+ mvwaddstr(pad, 10, 1, " Press any key to continue");
+ prefresh(pad,0,0,0,0,10,45);
+ keypad(pad, TRUE);
+ raw();
+ wgetch(pad);
+
+ mvwaddstr(pad, 35, 2, "This is displayed at line 35 in the pad");
+ mvwaddstr(pad, 40, 1, " Press any key to continue");
+ prefresh(pad,30,0,0,0,10,45);
+ keypad(pad, TRUE);
+ raw();
+ wgetch(pad);
+
+ delwin(pad);
+}
+
+#ifdef __STDC__
+void display_menu(int old_option,int new_option)
+#else
+void display_menu(old_option,new_option)
+int old_option,new_option;
+#endif
+{
+ register int i;
+
+ attrset(A_NORMAL);
+ mvaddstr(3,20,"PDCurses Test Program");
+
+ for (i=0;i<MAX_OPTIONS;i++)
+ mvaddstr(5+i,25,command[i].text);
+ if (old_option != (-1))
+ mvaddstr(5+old_option,25,command[old_option].text);
+ attrset(A_REVERSE);
+ mvaddstr(5+new_option,25,command[new_option].text);
+ attrset(A_NORMAL);
+ mvaddstr(13,3,"Use Up and Down Arrows to select - Enter to run - Q to quit");
+ refresh();
+}
+
diff --git a/lib/libncurses/TESTS/worm.c b/lib/libncurses/TESTS/worm.c
new file mode 100644
index 0000000..abbe241
--- /dev/null
+++ b/lib/libncurses/TESTS/worm.c
@@ -0,0 +1,268 @@
+/*
+
+ @@@ @@@ @@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@
+ @@@ @@@ @@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@@
+ @@@ @@@ @@@@ @@@@ @@@@ @@@@ @@@ @@@@
+ @@@ @@ @@@ @@@ @@@ @@@ @@@ @@@ @@@
+ @@@ @@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@
+ @@@@ @@@@ @@@@ @@@ @@@ @@@ @@@ @@@ @@@
+ @@@@@@@@@@@@ @@@@ @@@@ @@@ @@@ @@@ @@@
+ @@@@ @@@@ @@@@@@@@@@@@ @@@ @@@ @@@ @@@
+ @@ @@ @@@@@@@@@@ @@@ @@@ @@@ @@@
+
+ Eric P. Scott
+ Caltech High Energy Physics
+ October, 1980
+
+*/
+
+#include <ncurses.h>
+#include <signal.h>
+
+#define cursor(col,row) move(row,col)
+
+int Wrap;
+short *ref[128];
+static char flavor[]={
+ 'O', '*', '#', '$', '%', '0'
+};
+static short xinc[]={
+ 1, 1, 1, 0, -1, -1, -1, 0
+}, yinc[]={
+ -1, 0, 1, 1, 1, 0, -1, -1
+};
+static struct worm {
+ int orientation, head;
+ short *xpos, *ypos;
+} worm[40];
+static char *field;
+static int length=16, number=3, trail=' ';
+static struct options {
+ int nopts;
+ int opts[3];
+} normal[8]={
+ { 3, { 7, 0, 1 } },
+ { 3, { 0, 1, 2 } },
+ { 3, { 1, 2, 3 } },
+ { 3, { 2, 3, 4 } },
+ { 3, { 3, 4, 5 } },
+ { 3, { 4, 5, 6 } },
+ { 3, { 5, 6, 7 } },
+ { 3, { 6, 7, 0 } }
+}, upper[8]={
+ { 1, { 1, 0, 0 } },
+ { 2, { 1, 2, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 2, { 4, 5, 0 } },
+ { 1, { 5, 0, 0 } },
+ { 2, { 1, 5, 0 } }
+}, left[8]={
+ { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 2, { 2, 3, 0 } },
+ { 1, { 3, 0, 0 } },
+ { 2, { 3, 7, 0 } },
+ { 1, { 7, 0, 0 } },
+ { 2, { 7, 0, 0 } }
+}, right[8]={
+ { 1, { 7, 0, 0 } },
+ { 2, { 3, 7, 0 } },
+ { 1, { 3, 0, 0 } },
+ { 2, { 3, 4, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 2, { 6, 7, 0 } }
+}, lower[8]={
+ { 0, { 0, 0, 0 } },
+ { 2, { 0, 1, 0 } },
+ { 1, { 1, 0, 0 } },
+ { 2, { 1, 5, 0 } },
+ { 1, { 5, 0, 0 } },
+ { 2, { 5, 6, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } }
+}, upleft[8]={
+ { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 1, { 3, 0, 0 } },
+ { 2, { 1, 3, 0 } },
+ { 1, { 1, 0, 0 } }
+}, upright[8]={
+ { 2, { 3, 5, 0 } },
+ { 1, { 3, 0, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 1, { 5, 0, 0 } }
+}, lowleft[8]={
+ { 3, { 7, 0, 1 } },
+ { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 1, { 1, 0, 0 } },
+ { 2, { 1, 7, 0 } },
+ { 1, { 7, 0, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } }
+}, lowright[8]={
+ { 0, { 0, 0, 0 } },
+ { 1, { 7, 0, 0 } },
+ { 2, { 5, 7, 0 } },
+ { 1, { 5, 0, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } }
+};
+
+void onsig();
+float ranf();
+
+main(argc,argv)
+int argc;
+char *argv[];
+{
+int x, y;
+int n;
+struct worm *w;
+struct options *op;
+int h;
+short *ip;
+int last, bottom;
+
+ for (x=1;x<argc;x++) {
+ register char *p;
+ p=argv[x];
+ if (*p=='-') p++;
+ switch (*p) {
+ case 'f':
+ field="WORM";
+ break;
+ case 'l':
+ if (++x==argc) goto usage;
+ if ((length=atoi(argv[x]))<2||length>1024) {
+ fprintf(stderr,"%s: Invalid length\n",*argv);
+ exit(1);
+ }
+ break;
+ case 'n':
+ if (++x==argc) goto usage;
+ if ((number=atoi(argv[x]))<1||number>40) {
+ fprintf(stderr,"%s: Invalid number of worms\n",*argv);
+ exit(1);
+ }
+ break;
+ case 't':
+ trail='.';
+ break;
+ default:
+ usage:
+ fprintf(stderr, "usage: %s [-field] [-length #] [-number #] [-trail]\n",*argv);
+ exit(1);
+ break;
+ }
+ }
+
+ signal(SIGINT, onsig);
+ initscr();
+ bottom = LINES-1;
+ last = COLS-1;
+
+ ip=(short *)malloc(LINES*COLS*sizeof (short));
+
+ for (n=0;n<LINES;) {
+ ref[n++]=ip; ip+=COLS;
+ }
+ for (ip=ref[0],n=LINES*COLS;--n>=0;) *ip++=0;
+ ref[bottom][last]=1;
+ for (n=number, w= &worm[0];--n>=0;w++) {
+ w->orientation=w->head=0;
+ if (!(ip=(short *)malloc(length*sizeof (short)))) {
+ fprintf(stderr,"%s: out of memory\n",*argv);
+ exit(1);
+ }
+ w->xpos=ip;
+ for (x=length;--x>=0;) *ip++ = -1;
+ if (!(ip=(short *)malloc(length*sizeof (short)))) {
+ fprintf(stderr,"%s: out of memory\n",*argv);
+ exit(1);
+ }
+ w->ypos=ip;
+ for (y=length;--y>=0;) *ip++ = -1;
+ }
+ if (field) {
+ register char *p;
+ p=field;
+ for (y=bottom;--y>=0;) {
+ for (x=COLS;--x>=0;) {
+ addch(*p++);
+ if (!*p) p=field;
+ }
+ addch('\n');
+ }
+ }
+ refresh();
+
+ for (;;) {
+ for (n=0,w= &worm[0];n<number;n++,w++) {
+ if ((x=w->xpos[h=w->head])<0) {
+ cursor(x=w->xpos[h]=0,y=w->ypos[h]=bottom);
+ addch(flavor[n%6]);
+ ref[y][x]++;
+ }
+ else y=w->ypos[h];
+ if (++h==length) h=0;
+ if (w->xpos[w->head=h]>=0) {
+ register int x1, y1;
+ x1=w->xpos[h]; y1=w->ypos[h];
+ if (--ref[y1][x1]==0) {
+ cursor(x1,y1); addch(trail);
+ }
+ }
+ op= &(x==0 ? (y==0 ? upleft : (y==bottom ? lowleft : left)) :
+ (x==last ? (y==0 ? upright : (y==bottom ? lowright : right)) :
+ (y==0 ? upper : (y==bottom ? lower : normal))))[w->orientation];
+ switch (op->nopts) {
+ case 0:
+ refresh();
+ endwin();
+ exit(0);
+ case 1:
+ w->orientation=op->opts[0];
+ break;
+ default:
+ w->orientation=op->opts[(int)(ranf()*(float)op->nopts)];
+ }
+ cursor(x+=xinc[w->orientation], y+=yinc[w->orientation]);
+ if (!Wrap||x!=last||y!=bottom) addch(flavor[n%6]);
+ ref[w->ypos[h]=y][w->xpos[h]=x]++;
+ }
+ refresh();
+ }
+}
+
+void
+onsig()
+{
+ endwin();
+ exit(0);
+}
+
+float
+ranf()
+{
+float rv;
+long r = rand();
+
+ r &= 077777;
+ rv =((float)r/32767.);
+ return rv;
+}
diff --git a/lib/libncurses/TESTS/xmas.c b/lib/libncurses/TESTS/xmas.c
new file mode 100644
index 0000000..57cc0ea
--- /dev/null
+++ b/lib/libncurses/TESTS/xmas.c
@@ -0,0 +1,1192 @@
+/******************************************************************************/
+/* asciixmas */
+/* December 1989 Larry Bartz Indianapolis, IN */
+/* */
+/* */
+/* I'm dreaming of an ascii character-based monochrome Christmas, */
+/* Just like the one's I used to know! */
+/* Via a full duplex communications channel, */
+/* At 9600 bits per second, */
+/* Even though it's kinda slow. */
+/* */
+/* I'm dreaming of an ascii character-based monochrome Christmas, */
+/* With ev'ry C program I write! */
+/* May your screen be merry and bright! */
+/* And may all your Christmases be amber or green, */
+/* (for reduced eyestrain and improved visibility)! */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* IMPLEMENTATION */
+/* */
+/* Feel free to modify the defined string FROMWHO to reflect you, your */
+/* organization, your site, whatever. */
+/* */
+/* This really looks a lot better if you can turn off your cursor before */
+/* execution. I wanted to do that here but very few termcap entries or */
+/* terminfo definitions have the appropriate string defined. If you know */
+/* the string(s) for the terminal(s) you use or which your site supports, */
+/* you could call asciixmas from within a shell in which you issue the */
+/* string to the terminal. The cursor is distracting but it doesn't really */
+/* ruin the show. */
+/* */
+/* At our site, we invoke this for our users just after login and the */
+/* determination of terminal type. */
+/* */
+/* */
+/* PORTABILITY */
+/* */
+/* I wrote this using only the very simplest curses functions so that it */
+/* might be the most portable. I was personally able to test on five */
+/* different cpu/UNIX combinations. */
+/* */
+/* */
+/* COMPILE */
+/* */
+/* usually this: */
+/* */
+/* cc -O asciixmas.c -lcurses -o asciixmas -s */
+/* */
+/* */
+/* Zilog S8000 models 11, 21, 31, etc with ZEUS variant of SYSTEM III */
+/* maybe other SYSTEM III also: */
+/* */
+/* cc asciixmas.c -lcurses -ltermlib -o asciixmas -s */
+/* */
+/* as above with optional "peephole optimizer" installed: */
+/* */
+/* cc -O asciixmas.c -lcurses -ltermlib -o asciixmas -s */
+/* */
+/* */
+/* Zilog S8000 models 32, 130 with WE32100 chip and SYS V, REL2 */
+/* maybe 3B2 also? */
+/* */
+/* cc -f -O -K sd asciixmas.c -lcurses -o asciixmas -s */
+/* */
+/* */
+/* Pyramid, Sequent, any other "dual universe" types compile and execute */
+/* under either universe. The compile line for the ucb universe (as you */
+/* might expect) is the same as for SYS III UNIX: */
+/* */
+/* cc -O asciixmas.c -lcurses -ltermlib -o asciixmas -s */
+/* */
+/* The above compile will also hold true for other BSD systems. (I hope) */
+/* */
+/* */
+/* */
+/* */
+/* For the Scrooges out there among you who don't want this thing to loop */
+/* forever (or until the user hits a key), insert this into your compile */
+/* line just after "cc" : */
+/* */
+/* -DNOLOOP */
+/* */
+/* like so: */
+/* */
+/* cc -DNOLOOP -O asciixmas.c -lcurses -o asciixmas -s */
+/* */
+/* */
+/* */
+/******************************************************************************/
+
+#include <ncurses.h>
+#include <signal.h>
+
+#define FROMWHO "Mark Hessling - (M.Hessling@gu.edu.au)"
+
+int y_pos, x_pos;
+
+WINDOW
+ *treescrn, *treescrn2,*treescrn3, *treescrn4,*treescrn5, *treescrn6,
+ *treescrn7, *treescrn8,
+ *dotdeer0,
+ *stardeer0,
+ *lildeer0, *lildeer1, *lildeer2, *lildeer3,
+ *middeer0, *middeer1, *middeer2, *middeer3,
+ *bigdeer0, *bigdeer1, *bigdeer2, *bigdeer3, *bigdeer4,
+ *lookdeer0, *lookdeer1, *lookdeer2, *lookdeer3, *lookdeer4,
+ *w_holiday,
+ *w_del_msg;
+
+void main()
+{
+ void done();
+ int loopy;
+
+ initscr();
+ noecho();
+ nonl();
+ refresh();
+ signal(SIGINT,done);
+ signal(SIGTERM,done);
+#if !defined DOS && !defined OS2
+ signal(SIGHUP,done);
+ signal(SIGQUIT,done);
+#endif
+
+
+
+ treescrn = newwin(16,27,3,53);
+ treescrn2 = newwin(16,27,3,53);
+ treescrn3 = newwin(16,27,3,53);
+ treescrn4 = newwin(16,27,3,53);
+ treescrn5 = newwin(16,27,3,53);
+ treescrn6 = newwin(16,27,3,53);
+ treescrn7 = newwin(16,27,3,53);
+ treescrn8 = newwin(16,27,3,53);
+
+ dotdeer0 = newwin(3,71,0,8);
+
+ stardeer0 = newwin(4,56,0,8);
+
+ lildeer0 = newwin(7,53,0,8);
+ lildeer1 = newwin(2,4,0,0);
+ lildeer2 = newwin(2,4,0,0);
+ lildeer3 = newwin(2,4,0,0);
+
+ middeer0 = newwin(15,42,0,8);
+ middeer1 = newwin(3,7,0,0);
+ middeer2 = newwin(3,7,0,0);
+ middeer3 = newwin(3,7,0,0);
+
+ bigdeer0 = newwin(10,23,0,0);
+ bigdeer1 = newwin(10,23,0,0);
+ bigdeer2 = newwin(10,23,0,0);
+ bigdeer3 = newwin(10,23,0,0);
+ bigdeer4 = newwin(10,23,0,0);
+
+ lookdeer0 = newwin(10,25,0,0);
+ lookdeer1 = newwin(10,25,0,0);
+ lookdeer2 = newwin(10,25,0,0);
+ lookdeer3 = newwin(10,25,0,0);
+ lookdeer4 = newwin(10,25,0,0);
+
+ w_holiday = newwin(1,26,3,27);
+
+ w_del_msg = newwin(1,12,23,60);
+
+ mvwaddstr(w_del_msg,0,0,"Hit any key to quit");
+
+ mvwaddstr(w_holiday,0,0,"H A P P Y H O L I D A Y S");
+
+ /* set up the windows for our various reindeer */
+
+ /* lildeer1 */
+ mvwaddch(lildeer1,0,0,(chtype)'V');
+ mvwaddch(lildeer1,1,0,(chtype)'@');
+ mvwaddch(lildeer1,1,1,(chtype)'<');
+ mvwaddch(lildeer1,1,2,(chtype)'>');
+ mvwaddch(lildeer1,1,3,(chtype)'~');
+
+ /* lildeer2 */
+ mvwaddch(lildeer2,0,0,(chtype)'V');
+ mvwaddch(lildeer2,1,0,(chtype)'@');
+ mvwaddch(lildeer2,1,1,(chtype)'|');
+ mvwaddch(lildeer2,1,2,(chtype)'|');
+ mvwaddch(lildeer2,1,3,(chtype)'~');
+
+ /* lildeer3 */
+ mvwaddch(lildeer3,0,0,(chtype)'V');
+ mvwaddch(lildeer3,1,0,(chtype)'@');
+ mvwaddch(lildeer3,1,1,(chtype)'>');
+ mvwaddch(lildeer3,1,2,(chtype)'<');
+ mvwaddch(lildeer2,1,3,(chtype)'~');
+
+
+ /* middeer1 */
+ mvwaddch(middeer1,0,2,(chtype)'y');
+ mvwaddch(middeer1,0,3,(chtype)'y');
+ mvwaddch(middeer1,1,2,(chtype)'0');
+ mvwaddch(middeer1,1,3,(chtype)'(');
+ mvwaddch(middeer1,1,4,(chtype)'=');
+ mvwaddch(middeer1,1,5,(chtype)')');
+ mvwaddch(middeer1,1,6,(chtype)'~');
+ mvwaddch(middeer1,2,3,(chtype)'\\');
+ mvwaddch(middeer1,2,4,(chtype)'/');
+
+ /* middeer2 */
+ mvwaddch(middeer2,0,2,(chtype)'y');
+ mvwaddch(middeer2,0,3,(chtype)'y');
+ mvwaddch(middeer2,1,2,(chtype)'0');
+ mvwaddch(middeer2,1,3,(chtype)'(');
+ mvwaddch(middeer2,1,4,(chtype)'=');
+ mvwaddch(middeer2,1,5,(chtype)')');
+ mvwaddch(middeer2,1,6,(chtype)'~');
+ mvwaddch(middeer2,2,3,(chtype)'|');
+ mvwaddch(middeer2,2,5,(chtype)'|');
+
+ /* middeer3 */
+ mvwaddch(middeer3,0,2,(chtype)'y');
+ mvwaddch(middeer3,0,3,(chtype)'y');
+ mvwaddch(middeer3,1,2,(chtype)'0');
+ mvwaddch(middeer3,1,3,(chtype)'(');
+ mvwaddch(middeer3,1,4,(chtype)'=');
+ mvwaddch(middeer3,1,5,(chtype)')');
+ mvwaddch(middeer3,1,6,(chtype)'~');
+ mvwaddch(middeer3,2,2,(chtype)'/');
+ mvwaddch(middeer3,2,6,(chtype)'\\');
+
+
+ /* bigdeer1 */
+ mvwaddch(bigdeer1,0,17,(chtype)'\\');
+ mvwaddch(bigdeer1,0,18,(chtype)'/');
+ mvwaddch(bigdeer1,0,20,(chtype)'\\');
+ mvwaddch(bigdeer1,0,21,(chtype)'/');
+ mvwaddch(bigdeer1,1,18,(chtype)'\\');
+ mvwaddch(bigdeer1,1,20,(chtype)'/');
+ mvwaddch(bigdeer1,2,19,(chtype)'|');
+ mvwaddch(bigdeer1,2,20,(chtype)'_');
+ mvwaddch(bigdeer1,3,18,(chtype)'/');
+ mvwaddch(bigdeer1,3,19,(chtype)'^');
+ mvwaddch(bigdeer1,3,20,(chtype)'0');
+ mvwaddch(bigdeer1,3,21,(chtype)'\\');
+ mvwaddch(bigdeer1,4,17,(chtype)'/');
+ mvwaddch(bigdeer1,4,18,(chtype)'/');
+ mvwaddch(bigdeer1,4,19,(chtype)'\\');
+ mvwaddch(bigdeer1,4,22,(chtype)'\\');
+ mvwaddstr(bigdeer1,5,7,"^~~~~~~~~// ~~U");
+ mvwaddstr(bigdeer1,6,7,"( \\_____( /");
+ mvwaddstr(bigdeer1,7,8,"( ) /");
+ mvwaddstr(bigdeer1,8,9,"\\\\ /");
+ mvwaddstr(bigdeer1,9,11,"\\>/>");
+
+ /* bigdeer2 */
+ mvwaddch(bigdeer2,0,17,(chtype)'\\');
+ mvwaddch(bigdeer2,0,18,(chtype)'/');
+ mvwaddch(bigdeer2,0,20,(chtype)'\\');
+ mvwaddch(bigdeer2,0,21,(chtype)'/');
+ mvwaddch(bigdeer2,1,18,(chtype)'\\');
+ mvwaddch(bigdeer2,1,20,(chtype)'/');
+ mvwaddch(bigdeer2,2,19,(chtype)'|');
+ mvwaddch(bigdeer2,2,20,(chtype)'_');
+ mvwaddch(bigdeer2,3,18,(chtype)'/');
+ mvwaddch(bigdeer2,3,19,(chtype)'^');
+ mvwaddch(bigdeer2,3,20,(chtype)'0');
+ mvwaddch(bigdeer2,3,21,(chtype)'\\');
+ mvwaddch(bigdeer2,4,17,(chtype)'/');
+ mvwaddch(bigdeer2,4,18,(chtype)'/');
+ mvwaddch(bigdeer2,4,19,(chtype)'\\');
+ mvwaddch(bigdeer2,4,22,(chtype)'\\');
+ mvwaddstr(bigdeer2,5,7,"^~~~~~~~~// ~~U");
+ mvwaddstr(bigdeer2,6,7,"(( )____( /");
+ mvwaddstr(bigdeer2,7,7,"( / |");
+ mvwaddstr(bigdeer2,8,8,"\\/ |");
+ mvwaddstr(bigdeer2,9,9,"|> |>");
+
+ /* bigdeer3 */
+ mvwaddch(bigdeer3,0,17,(chtype)'\\');
+ mvwaddch(bigdeer3,0,18,(chtype)'/');
+ mvwaddch(bigdeer3,0,20,(chtype)'\\');
+ mvwaddch(bigdeer3,0,21,(chtype)'/');
+ mvwaddch(bigdeer3,1,18,(chtype)'\\');
+ mvwaddch(bigdeer3,1,20,(chtype)'/');
+ mvwaddch(bigdeer3,2,19,(chtype)'|');
+ mvwaddch(bigdeer3,2,20,(chtype)'_');
+ mvwaddch(bigdeer3,3,18,(chtype)'/');
+ mvwaddch(bigdeer3,3,19,(chtype)'^');
+ mvwaddch(bigdeer3,3,20,(chtype)'0');
+ mvwaddch(bigdeer3,3,21,(chtype)'\\');
+ mvwaddch(bigdeer3,4,17,(chtype)'/');
+ mvwaddch(bigdeer3,4,18,(chtype)'/');
+ mvwaddch(bigdeer3,4,19,(chtype)'\\');
+ mvwaddch(bigdeer3,4,22,(chtype)'\\');
+ mvwaddstr(bigdeer3,5,7,"^~~~~~~~~// ~~U");
+ mvwaddstr(bigdeer3,6,6,"( ()_____( /");
+ mvwaddstr(bigdeer3,7,6,"/ / /");
+ mvwaddstr(bigdeer3,8,5,"|/ \\");
+ mvwaddstr(bigdeer3,9,5,"/> \\>");
+
+ /* bigdeer4 */
+ mvwaddch(bigdeer4,0,17,(chtype)'\\');
+ mvwaddch(bigdeer4,0,18,(chtype)'/');
+ mvwaddch(bigdeer4,0,20,(chtype)'\\');
+ mvwaddch(bigdeer4,0,21,(chtype)'/');
+ mvwaddch(bigdeer4,1,18,(chtype)'\\');
+ mvwaddch(bigdeer4,1,20,(chtype)'/');
+ mvwaddch(bigdeer4,2,19,(chtype)'|');
+ mvwaddch(bigdeer4,2,20,(chtype)'_');
+ mvwaddch(bigdeer4,3,18,(chtype)'/');
+ mvwaddch(bigdeer4,3,19,(chtype)'^');
+ mvwaddch(bigdeer4,3,20,(chtype)'0');
+ mvwaddch(bigdeer4,3,21,(chtype)'\\');
+ mvwaddch(bigdeer4,4,17,(chtype)'/');
+ mvwaddch(bigdeer4,4,18,(chtype)'/');
+ mvwaddch(bigdeer4,4,19,(chtype)'\\');
+ mvwaddch(bigdeer4,4,22,(chtype)'\\');
+ mvwaddstr(bigdeer4,5,7,"^~~~~~~~~// ~~U");
+ mvwaddstr(bigdeer4,6,6,"( )______( /");
+ mvwaddstr(bigdeer4,7,5,"(/ \\");
+ mvwaddstr(bigdeer4,8,0,"v___= ----^");
+
+
+ /* lookdeer1 */
+ mvwaddstr(lookdeer1,0,16,"\\/ \\/");
+ mvwaddstr(lookdeer1,1,17,"\\Y/ \\Y/");
+ mvwaddstr(lookdeer1,2,19,"\\=/");
+ mvwaddstr(lookdeer1,3,17,"^\\o o/^");
+ mvwaddstr(lookdeer1,4,17,"//( )");
+ mvwaddstr(lookdeer1,5,7,"^~~~~~~~~// \\O/");
+ mvwaddstr(lookdeer1,6,7,"( \\_____( /");
+ mvwaddstr(lookdeer1,7,8,"( ) /");
+ mvwaddstr(lookdeer1,8,9,"\\\\ /");
+ mvwaddstr(lookdeer1,9,11,"\\>/>");
+
+ /* lookdeer2 */
+ mvwaddstr(lookdeer2,0,16,"\\/ \\/");
+ mvwaddstr(lookdeer2,1,17,"\\Y/ \\Y/");
+ mvwaddstr(lookdeer2,2,19,"\\=/");
+ mvwaddstr(lookdeer2,3,17,"^\\o o/^");
+ mvwaddstr(lookdeer2,4,17,"//( )");
+ mvwaddstr(lookdeer2,5,7,"^~~~~~~~~// \\O/");
+ mvwaddstr(lookdeer2,6,7,"(( )____( /");
+ mvwaddstr(lookdeer2,7,7,"( / |");
+ mvwaddstr(lookdeer2,8,8,"\\/ |");
+ mvwaddstr(lookdeer2,9,9,"|> |>");
+
+ /* lookdeer3 */
+ mvwaddstr(lookdeer3,0,16,"\\/ \\/");
+ mvwaddstr(lookdeer3,1,17,"\\Y/ \\Y/");
+ mvwaddstr(lookdeer3,2,19,"\\=/");
+ mvwaddstr(lookdeer3,3,17,"^\\o o/^");
+ mvwaddstr(lookdeer3,4,17,"//( )");
+ mvwaddstr(lookdeer3,5,7,"^~~~~~~~~// \\O/");
+ mvwaddstr(lookdeer3,6,6,"( ()_____( /");
+ mvwaddstr(lookdeer3,7,6,"/ / /");
+ mvwaddstr(lookdeer3,8,5,"|/ \\");
+ mvwaddstr(lookdeer3,9,5,"/> \\>");
+
+ /* lookdeer4 */
+ mvwaddstr(lookdeer4,0,16,"\\/ \\/");
+ mvwaddstr(lookdeer4,1,17,"\\Y/ \\Y/");
+ mvwaddstr(lookdeer4,2,19,"\\=/");
+ mvwaddstr(lookdeer4,3,17,"^\\o o/^");
+ mvwaddstr(lookdeer4,4,17,"//( )");
+ mvwaddstr(lookdeer4,5,7,"^~~~~~~~~// \\O/");
+ mvwaddstr(lookdeer4,6,6,"( )______( /");
+ mvwaddstr(lookdeer4,7,5,"(/ \\");
+ mvwaddstr(lookdeer4,8,0,"v___= ----^");
+
+
+
+ /***********************************************/
+ cbreak();
+ nodelay(stdscr,TRUE);
+ do
+ {
+ clear();
+ werase(treescrn);
+ touchwin(treescrn);
+ werase(treescrn2);
+ touchwin(treescrn2);
+ werase(treescrn8);
+ touchwin(treescrn8);
+ refresh();
+ usleep(1000);
+ boxit();
+ refresh();
+ usleep(1000);
+ seas();
+ refresh();
+ usleep(1000);
+ greet();
+ refresh();
+ usleep(1000);
+ fromwho();
+ refresh();
+ usleep(1000);
+ tree();
+ usleep(1000);
+ balls();
+ usleep(1000);
+ star();
+ usleep(1000);
+ strng1();
+ strng2();
+ strng3();
+ strng4();
+ strng5();
+
+
+ /* set up the windows for our blinking trees */
+ /* **************************************** */
+ /* treescrn3 */
+
+ overlay(treescrn, treescrn3);
+
+ /*balls*/
+ mvwaddch(treescrn3, 4, 18, ' ');
+ mvwaddch(treescrn3, 7, 6, ' ');
+ mvwaddch(treescrn3, 8, 19, ' ');
+ mvwaddch(treescrn3, 11, 22, ' ');
+
+ /*star*/
+ mvwaddch(treescrn3, 0, 12, '*');
+
+ /*strng1*/
+ mvwaddch(treescrn3, 3, 11, ' ');
+
+ /*strng2*/
+ mvwaddch(treescrn3, 5, 13, ' ');
+ mvwaddch(treescrn3, 6, 10, ' ');
+
+ /*strng3*/
+ mvwaddch(treescrn3, 7, 16, ' ');
+ mvwaddch(treescrn3, 7, 14, ' ');
+
+ /*strng4*/
+ mvwaddch(treescrn3, 10, 13, ' ');
+ mvwaddch(treescrn3, 10, 10, ' ');
+ mvwaddch(treescrn3, 11, 8, ' ');
+
+ /*strng5*/
+ mvwaddch(treescrn3, 11, 18, ' ');
+ mvwaddch(treescrn3, 12, 13, ' ');
+
+
+ /* treescrn4 */
+
+ overlay(treescrn, treescrn4);
+
+ /*balls*/
+ mvwaddch(treescrn4, 3, 9, ' ');
+ mvwaddch(treescrn4, 4, 16, ' ');
+ mvwaddch(treescrn4, 7, 6, ' ');
+ mvwaddch(treescrn4, 8, 19, ' ');
+ mvwaddch(treescrn4, 11, 2, ' ');
+ mvwaddch(treescrn4, 12, 23, ' ');
+
+ /*star*/
+ wstandout(treescrn4);
+ mvwaddch(treescrn4, 0, 12, '*');
+ wstandend(treescrn4);
+
+ /*strng1*/
+ mvwaddch(treescrn4, 3, 13, ' ');
+
+ /*strng2*/
+
+ /*strng3*/
+ mvwaddch(treescrn4, 7, 15, ' ');
+ mvwaddch(treescrn4, 8, 11, ' ');
+
+ /*strng4*/
+ mvwaddch(treescrn4, 9, 16, ' ');
+ mvwaddch(treescrn4, 10, 12, ' ');
+ mvwaddch(treescrn4, 11, 8, ' ');
+
+ /*strng5*/
+ mvwaddch(treescrn4, 11, 18, ' ');
+ mvwaddch(treescrn4, 12, 14, ' ');
+
+
+ /* treescrn5 */
+
+ overlay(treescrn, treescrn5);
+
+ /*balls*/
+ mvwaddch(treescrn5, 3, 15, ' ');
+ mvwaddch(treescrn5, 10, 20, ' ');
+ mvwaddch(treescrn5, 12, 1, ' ');
+
+ /*star*/
+ mvwaddch(treescrn5, 0, 12, '*');
+
+ /*strng1*/
+ mvwaddch(treescrn5, 3, 11, ' ');
+
+ /*strng2*/
+ mvwaddch(treescrn5, 5, 12, ' ');
+
+ /*strng3*/
+ mvwaddch(treescrn5, 7, 14, ' ');
+ mvwaddch(treescrn5, 8, 10, ' ');
+
+ /*strng4*/
+ mvwaddch(treescrn5, 9, 15, ' ');
+ mvwaddch(treescrn5, 10, 11, ' ');
+ mvwaddch(treescrn5, 11, 7, ' ');
+
+ /*strng5*/
+ mvwaddch(treescrn5, 11, 17, ' ');
+ mvwaddch(treescrn5, 12, 13, ' ');
+
+ /* treescrn6 */
+
+ overlay(treescrn, treescrn6);
+
+ /*balls*/
+ mvwaddch(treescrn6, 6, 7, ' ');
+ mvwaddch(treescrn6, 7, 18, ' ');
+ mvwaddch(treescrn6, 10, 4, ' ');
+ mvwaddch(treescrn6, 11, 23, ' ');
+
+ /*star*/
+ wstandout(treescrn6);
+ mvwaddch(treescrn6, 0, 12, '*');
+ wstandend(treescrn6);
+
+ /*strng1*/
+
+ /*strng2*/
+ mvwaddch(treescrn6, 5, 11, ' ');
+
+ /*strng3*/
+ mvwaddch(treescrn6, 7, 13, ' ');
+ mvwaddch(treescrn6, 8, 9, ' ');
+
+ /*strng4*/
+ mvwaddch(treescrn6, 9, 14, ' ');
+ mvwaddch(treescrn6, 10, 10, ' ');
+ mvwaddch(treescrn6, 11, 6, ' ');
+
+ /*strng5*/
+ mvwaddch(treescrn6, 11, 16, ' ');
+ mvwaddch(treescrn6, 12, 12, ' ');
+
+ /* treescrn7 */
+
+ overlay(treescrn, treescrn7);
+
+ /*balls*/
+ mvwaddch(treescrn7, 3, 15, ' ');
+ mvwaddch(treescrn7, 6, 7, ' ');
+ mvwaddch(treescrn7, 7, 18, ' ');
+ mvwaddch(treescrn7, 10, 4, ' ');
+ mvwaddch(treescrn7, 11, 22, ' ');
+
+ /*star*/
+ mvwaddch(treescrn7, 0, 12, '*');
+
+ /*strng1*/
+ mvwaddch(treescrn7, 3, 12, ' ');
+
+ /*strng2*/
+ mvwaddch(treescrn7, 5, 13, ' ');
+ mvwaddch(treescrn7, 6, 9, ' ');
+
+ /*strng3*/
+ mvwaddch(treescrn7, 7, 15, ' ');
+ mvwaddch(treescrn7, 8, 11, ' ');
+
+ /*strng4*/
+ mvwaddch(treescrn7, 9, 16, ' ');
+ mvwaddch(treescrn7, 10, 12, ' ');
+ mvwaddch(treescrn7, 11, 8, ' ');
+
+ /*strng5*/
+ mvwaddch(treescrn7, 11, 18, ' ');
+ mvwaddch(treescrn7, 12, 14, ' ');
+
+
+ usleep(1000);
+ reindeer();
+
+ touchwin(w_holiday);
+ wrefresh(w_holiday);
+ wrefresh(w_del_msg);
+
+ usleep(1000);
+ for(loopy = 0;loopy < 100;loopy++)
+ {
+ blinkit();
+ }
+
+#ifdef NOLOOP
+ done();
+#endif
+
+ }
+ while(getch() == (ERR));
+/* while(!typeahead(stdin));*/
+ done();
+}
+
+boxit()
+{
+ int x = 0;
+
+ while(x < 20)
+ {
+ mvaddch(x, 7, '|');
+ ++x;
+ }
+
+ x = 8;
+
+ while(x < 80)
+ {
+ mvaddch(19, x, '_');
+ ++x;
+ }
+
+ x = 0;
+
+ while(x < 80)
+ {
+ mvaddch(22, x, '_');
+ ++x;
+ }
+
+ return( 0 );
+}
+
+seas()
+{
+ mvaddch(4, 1, 'S');
+ mvaddch(6, 1, 'E');
+ mvaddch(8, 1, 'A');
+ mvaddch(10, 1, 'S');
+ mvaddch(12, 1, 'O');
+ mvaddch(14, 1, 'N');
+ mvaddch(16, 1, '`');
+ mvaddch(18, 1, 'S');
+
+ return( 0 );
+}
+
+
+greet()
+{
+ mvaddch(3, 5, 'G');
+ mvaddch(5, 5, 'R');
+ mvaddch(7, 5, 'E');
+ mvaddch(9, 5, 'E');
+ mvaddch(11, 5, 'T');
+ mvaddch(13, 5, 'I');
+ mvaddch(15, 5, 'N');
+ mvaddch(17, 5, 'G');
+ mvaddch(19, 5, 'S');
+
+ return( 0 );
+}
+
+
+fromwho()
+{
+ mvaddstr(21, 13, FROMWHO);
+ return( 0 );
+}
+
+
+del_msg()
+{
+ mvwaddstr(w_del_msg, 0, 0, "Hit any key to quit");
+ wrefresh(w_del_msg);
+
+ refresh();
+
+ return( 0 );
+}
+
+
+tree()
+{
+ mvwaddch(treescrn, 1, 11, (chtype)'/');
+ mvwaddch(treescrn, 2, 11, (chtype)'/');
+ mvwaddch(treescrn, 3, 10, (chtype)'/');
+ mvwaddch(treescrn, 4, 9, (chtype)'/');
+ mvwaddch(treescrn, 5, 9, (chtype)'/');
+ mvwaddch(treescrn, 6, 8, (chtype)'/');
+ mvwaddch(treescrn, 7, 7, (chtype)'/');
+ mvwaddch(treescrn, 8, 6, (chtype)'/');
+ mvwaddch(treescrn, 9, 6, (chtype)'/');
+ mvwaddch(treescrn, 10, 5, (chtype)'/');
+ mvwaddch(treescrn, 11, 3, (chtype)'/');
+ mvwaddch(treescrn, 12, 2, (chtype)'/');
+
+ mvwaddch(treescrn, 1, 13, (chtype)'\\');
+ mvwaddch(treescrn, 2, 13, (chtype)'\\');
+ mvwaddch(treescrn, 3, 14, (chtype)'\\');
+ mvwaddch(treescrn, 4, 15, (chtype)'\\');
+ mvwaddch(treescrn, 5, 15, (chtype)'\\');
+ mvwaddch(treescrn, 6, 16, (chtype)'\\');
+ mvwaddch(treescrn, 7, 17, (chtype)'\\');
+ mvwaddch(treescrn, 8, 18, (chtype)'\\');
+ mvwaddch(treescrn, 9, 18, (chtype)'\\');
+ mvwaddch(treescrn, 10, 19, (chtype)'\\');
+ mvwaddch(treescrn, 11, 21, (chtype)'\\');
+ mvwaddch(treescrn, 12, 22, (chtype)'\\');
+
+ mvwaddch(treescrn, 4, 10, (chtype)'_');
+ mvwaddch(treescrn, 4, 14, (chtype)'_');
+ mvwaddch(treescrn, 8, 7, (chtype)'_');
+ mvwaddch(treescrn, 8, 17, (chtype)'_');
+
+ mvwaddstr(treescrn, 13, 0, "//////////// \\\\\\\\\\\\\\\\\\\\\\\\");
+
+ mvwaddstr(treescrn, 14, 11, "| |");
+ mvwaddstr(treescrn, 15, 11, "|_|");
+
+ wrefresh(treescrn);
+ wrefresh(w_del_msg);
+
+ return( 0 );
+}
+
+
+balls()
+{
+
+ overlay(treescrn, treescrn2);
+
+ mvwaddch(treescrn2, 3, 9, (chtype)'@');
+ mvwaddch(treescrn2, 3, 15, (chtype)'@');
+ mvwaddch(treescrn2, 4, 8, (chtype)'@');
+ mvwaddch(treescrn2, 4, 16, (chtype)'@');
+ mvwaddch(treescrn2, 5, 7, (chtype)'@');
+ mvwaddch(treescrn2, 5, 17, (chtype)'@');
+ mvwaddch(treescrn2, 7, 6, (chtype)'@');
+ mvwaddch(treescrn2, 7, 18, (chtype)'@');
+ mvwaddch(treescrn2, 8, 5, (chtype)'@');
+ mvwaddch(treescrn2, 8, 19, (chtype)'@');
+ mvwaddch(treescrn2, 10, 4, (chtype)'@');
+ mvwaddch(treescrn2, 10, 20, (chtype)'@');
+ mvwaddch(treescrn2, 11, 2, (chtype)'@');
+ mvwaddch(treescrn2, 11, 22, (chtype)'@');
+ mvwaddch(treescrn2, 12, 1, (chtype)'@');
+ mvwaddch(treescrn2, 12, 23, (chtype)'@');
+
+ wrefresh(treescrn2);
+ wrefresh(w_del_msg);
+ return( 0 );
+}
+
+
+star()
+{
+ wstandout(treescrn2);
+ mvwaddch(treescrn2, 0, 12, (chtype)'*');
+ wstandend(treescrn2);
+
+ wrefresh(treescrn2);
+ wrefresh(w_del_msg);
+ return( 0 );
+}
+
+
+strng1()
+{
+ mvwaddch(treescrn2, 3, 13, (chtype)'\'');
+ mvwaddch(treescrn2, 3, 12, (chtype)':');
+ mvwaddch(treescrn2, 3, 11, (chtype)'.');
+
+ wrefresh(treescrn2);
+ wrefresh(w_del_msg);
+ return( 0 );
+}
+
+
+strng2()
+{
+ mvwaddch(treescrn2, 5, 14, (chtype)'\'');
+ mvwaddch(treescrn2, 5, 13, (chtype)':');
+ mvwaddch(treescrn2, 5, 12, (chtype)'.');
+ mvwaddch(treescrn2, 5, 11, (chtype)',');
+ mvwaddch(treescrn2, 6, 10, (chtype)'\'');
+ mvwaddch(treescrn2, 6, 9, (chtype)':');
+
+ wrefresh(treescrn2);
+ wrefresh(w_del_msg);
+ return( 0 );
+}
+
+
+strng3()
+{
+ mvwaddch(treescrn2, 7, 16, (chtype)'\'');
+ mvwaddch(treescrn2, 7, 15, (chtype)':');
+ mvwaddch(treescrn2, 7, 14, (chtype)'.');
+ mvwaddch(treescrn2, 7, 13, (chtype)',');
+ mvwaddch(treescrn2, 8, 12, (chtype)'\'');
+ mvwaddch(treescrn2, 8, 11, (chtype)':');
+ mvwaddch(treescrn2, 8, 10, (chtype)'.');
+ mvwaddch(treescrn2, 8, 9, (chtype)',');
+
+ wrefresh(treescrn2);
+ wrefresh(w_del_msg);
+ return( 0 );
+}
+
+
+strng4()
+{
+ mvwaddch(treescrn2, 9, 17, (chtype)'\'');
+ mvwaddch(treescrn2, 9, 16, (chtype)':');
+ mvwaddch(treescrn2, 9, 15, (chtype)'.');
+ mvwaddch(treescrn2, 9, 14, (chtype)',');
+ mvwaddch(treescrn2, 10, 13, (chtype)'\'');
+ mvwaddch(treescrn2, 10, 12, (chtype)':');
+ mvwaddch(treescrn2, 10, 11, (chtype)'.');
+ mvwaddch(treescrn2, 10, 10, (chtype)',');
+ mvwaddch(treescrn2, 11, 9, (chtype)'\'');
+ mvwaddch(treescrn2, 11, 8, (chtype)':');
+ mvwaddch(treescrn2, 11, 7, (chtype)'.');
+ mvwaddch(treescrn2, 11, 6, (chtype)',');
+ mvwaddch(treescrn2, 12, 5, (chtype)'\'');
+
+ wrefresh(treescrn2);
+ wrefresh(w_del_msg);
+ return( 0 );
+}
+
+
+strng5()
+{
+ mvwaddch(treescrn2, 11, 19, (chtype)'\'');
+ mvwaddch(treescrn2, 11, 18, (chtype)':');
+ mvwaddch(treescrn2, 11, 17, (chtype)'.');
+ mvwaddch(treescrn2, 11, 16, (chtype)',');
+ mvwaddch(treescrn2, 12, 15, (chtype)'\'');
+ mvwaddch(treescrn2, 12, 14, (chtype)':');
+ mvwaddch(treescrn2, 12, 13, (chtype)'.');
+ mvwaddch(treescrn2, 12, 12, (chtype)',');
+
+ /* save a fully lit tree */
+ overlay(treescrn2, treescrn);
+
+ wrefresh(treescrn2);
+ wrefresh(w_del_msg);
+ return( 0 );
+}
+
+
+
+blinkit()
+{
+ static int cycle;
+
+ if(cycle > 4)
+ {
+ cycle = 0;
+ }
+
+
+ touchwin(treescrn8);
+
+ switch(cycle)
+ {
+
+ case 0:
+ overlay(treescrn3, treescrn8);
+ wrefresh(treescrn8);
+ wrefresh(w_del_msg);
+
+ break;
+ case 1:
+ overlay(treescrn4, treescrn8);
+ wrefresh(treescrn8);
+ wrefresh(w_del_msg);
+
+ break;
+ case 2:
+ overlay(treescrn5, treescrn8);
+ wrefresh(treescrn8);
+ wrefresh(w_del_msg);
+
+ break;
+ case 3:
+ overlay(treescrn6, treescrn8);
+ wrefresh(treescrn8);
+ wrefresh(w_del_msg);
+
+ break;
+ case 4:
+ overlay(treescrn7, treescrn8);
+ wrefresh(treescrn8);
+ wrefresh(w_del_msg);
+
+ break;
+ }
+
+ touchwin(treescrn8);
+
+
+
+ /*ALL ON***************************************************/
+
+
+ overlay(treescrn, treescrn8);
+ wrefresh(treescrn8);
+ wrefresh(w_del_msg);
+
+
+ ++cycle;
+ return( 0 );
+}
+
+
+reindeer()
+{
+ int looper;
+
+ y_pos = 0;
+
+
+ for(x_pos = 70; x_pos > 62; x_pos--)
+ {
+ if(x_pos < 62)
+ {
+ y_pos = 1;
+ }
+ for(looper = 0; looper < 4; looper++)
+ {
+ mvwaddch(dotdeer0, y_pos, x_pos, (chtype)'.');
+ wrefresh(dotdeer0);
+ wrefresh(w_del_msg);
+ werase(dotdeer0);
+ wrefresh(dotdeer0);
+ wrefresh(w_del_msg);
+ }
+ }
+
+ y_pos = 2;
+
+ for(; x_pos > 50; x_pos--)
+ {
+
+ for(looper = 0; looper < 4; looper++)
+ {
+
+ if(x_pos < 56)
+ {
+ y_pos = 3;
+
+ mvwaddch(stardeer0, y_pos, x_pos, (chtype)'*');
+ wrefresh(stardeer0);
+ wrefresh(w_del_msg);
+ werase(stardeer0);
+ wrefresh(stardeer0);
+ wrefresh(w_del_msg);
+ }
+ else
+ {
+ mvwaddch(dotdeer0, y_pos, x_pos, (chtype)'*');
+ wrefresh(dotdeer0);
+ wrefresh(w_del_msg);
+ werase(dotdeer0);
+ wrefresh(dotdeer0);
+ wrefresh(w_del_msg);
+ }
+ }
+ }
+
+ x_pos = 58;
+
+ for(y_pos = 2; y_pos < 5; y_pos++)
+ {
+
+ touchwin(lildeer0);
+ wrefresh(lildeer0);
+ wrefresh(w_del_msg);
+
+ for(looper = 0; looper < 4; looper++)
+ {
+ mvwin(lildeer3, y_pos, x_pos);
+ wrefresh(lildeer3);
+ wrefresh(w_del_msg);
+
+ mvwin(lildeer2, y_pos, x_pos);
+ wrefresh(lildeer2);
+ wrefresh(w_del_msg);
+
+ mvwin(lildeer1, y_pos, x_pos);
+ wrefresh(lildeer1);
+ wrefresh(w_del_msg);
+
+ mvwin(lildeer2, y_pos, x_pos);
+ wrefresh(lildeer2);
+ wrefresh(w_del_msg);
+
+ mvwin(lildeer3, y_pos, x_pos);
+ wrefresh(lildeer3);
+ wrefresh(w_del_msg);
+
+ touchwin(lildeer0);
+ wrefresh(lildeer0);
+ wrefresh(w_del_msg);
+
+ x_pos -= 2;
+ }
+ }
+
+
+ x_pos = 35;
+
+ for(y_pos = 5; y_pos < 10; y_pos++)
+ {
+
+ touchwin(middeer0);
+ wrefresh(middeer0);
+ wrefresh(w_del_msg);
+
+ for(looper = 0; looper < 2; looper++)
+ {
+ mvwin(middeer3, y_pos, x_pos);
+ wrefresh(middeer3);
+ wrefresh(w_del_msg);
+
+ mvwin(middeer2, y_pos, x_pos);
+ wrefresh(middeer2);
+ wrefresh(w_del_msg);
+
+ mvwin(middeer1, y_pos, x_pos);
+ wrefresh(middeer1);
+ wrefresh(w_del_msg);
+
+ mvwin(middeer2, y_pos, x_pos);
+ wrefresh(middeer2);
+ wrefresh(w_del_msg);
+
+ mvwin(middeer3, y_pos, x_pos);
+ wrefresh(middeer3);
+ wrefresh(w_del_msg);
+
+ touchwin(middeer0);
+ wrefresh(middeer0);
+ wrefresh(w_del_msg);
+
+ x_pos -= 3;
+ }
+ }
+
+ usleep(2000);
+
+ y_pos = 1;
+
+ for(x_pos = 8; x_pos < 16; x_pos++)
+ {
+
+ mvwin(bigdeer4, y_pos, x_pos);
+ wrefresh(bigdeer4);
+ wrefresh(w_del_msg);
+
+ mvwin(bigdeer3, y_pos, x_pos);
+ wrefresh(bigdeer3);
+ wrefresh(w_del_msg);
+
+ mvwin(bigdeer2, y_pos, x_pos);
+ wrefresh(bigdeer2);
+ wrefresh(w_del_msg);
+
+ mvwin(bigdeer1, y_pos, x_pos);
+ wrefresh(bigdeer1);
+ wrefresh(w_del_msg);
+
+ mvwin(bigdeer2, y_pos, x_pos);
+ wrefresh(bigdeer2);
+ wrefresh(w_del_msg);
+
+ mvwin(bigdeer3, y_pos, x_pos);
+ wrefresh(bigdeer3);
+ wrefresh(w_del_msg);
+
+ mvwin(bigdeer4, y_pos, x_pos);
+ wrefresh(bigdeer4);
+ wrefresh(w_del_msg);
+
+ mvwin(bigdeer0, y_pos, x_pos);
+ wrefresh(bigdeer0);
+ wrefresh(w_del_msg);
+ }
+
+ --x_pos;
+
+ for(looper = 0; looper < 6; looper++)
+ {
+ mvwin(lookdeer4, y_pos, x_pos);
+ wrefresh(lookdeer4);
+ wrefresh(w_del_msg);
+
+ mvwin(lookdeer3, y_pos, x_pos);
+ wrefresh(lookdeer3);
+ wrefresh(w_del_msg);
+
+ mvwin(lookdeer2, y_pos, x_pos);
+ wrefresh(lookdeer2);
+ wrefresh(w_del_msg);
+
+ mvwin(lookdeer1, y_pos, x_pos);
+ wrefresh(lookdeer1);
+ wrefresh(w_del_msg);
+
+ mvwin(lookdeer2, y_pos, x_pos);
+ wrefresh(lookdeer2);
+ wrefresh(w_del_msg);
+
+ mvwin(lookdeer3, y_pos, x_pos);
+ wrefresh(lookdeer3);
+ wrefresh(w_del_msg);
+
+ mvwin(lookdeer4, y_pos, x_pos);
+ wrefresh(lookdeer4);
+ wrefresh(w_del_msg);
+
+ }
+
+ mvwin(lookdeer0, y_pos, x_pos);
+ wrefresh(lookdeer0);
+ wrefresh(w_del_msg);
+
+ for(; y_pos < 10; y_pos++)
+ {
+
+ for(looper = 0; looper < 2; looper++)
+ {
+ mvwin(bigdeer4, y_pos, x_pos);
+ wrefresh(bigdeer4);
+ wrefresh(w_del_msg);
+
+ mvwin(bigdeer3, y_pos, x_pos);
+ wrefresh(bigdeer3);
+ wrefresh(w_del_msg);
+
+ mvwin(bigdeer2, y_pos, x_pos);
+ wrefresh(bigdeer2);
+ wrefresh(w_del_msg);
+
+ mvwin(bigdeer1, y_pos, x_pos);
+ wrefresh(bigdeer1);
+ wrefresh(w_del_msg);
+
+ mvwin(bigdeer2, y_pos, x_pos);
+ wrefresh(bigdeer2);
+ wrefresh(w_del_msg);
+
+ mvwin(bigdeer3, y_pos, x_pos);
+ wrefresh(bigdeer3);
+ wrefresh(w_del_msg);
+
+ mvwin(bigdeer4, y_pos, x_pos);
+ wrefresh(bigdeer4);
+ wrefresh(w_del_msg);
+ }
+ mvwin(bigdeer0, y_pos, x_pos);
+ wrefresh(bigdeer0);
+ wrefresh(w_del_msg);
+ }
+
+ --y_pos;
+
+ mvwin(lookdeer3, y_pos, x_pos);
+ wrefresh(lookdeer3);
+ wrefresh(w_del_msg);
+ return( 0 );
+}
+
+
+
+void done()
+{
+ signal(SIGINT,done);
+ signal(SIGTERM,done);
+#if !defined DOS && !defined OS2
+ signal(SIGHUP,done);
+ signal(SIGQUIT,done);
+#endif
+ clear();
+ refresh();
+ endwin();
+ exit(0);
+}
diff --git a/lib/libncurses/curs_addch.3 b/lib/libncurses/curs_addch.3
new file mode 100644
index 0000000..2d6e643
--- /dev/null
+++ b/lib/libncurses/curs_addch.3
@@ -0,0 +1,113 @@
+.TH curs_addch 3X ""
+.SH NAME
+\fBcurs_addch\fR: \fBaddch\fR, \fBwaddch\fR, \fBmvaddch\fR, \fBmvwaddch\fR,
+\fBechochar\fR, \fBwechochar\fR - add a character (with attributes) to a
+\fBncurses\fR window, then advance the cursor
+.SH SYNOPSIS
+\fB#include <ncurses.h>\fR
+
+\fBaddch(chtype ch);\fR
+.br
+\fBwaddch(WINDOW *win, chtype ch);\fR
+.br
+\fBmvaddch(int y, int x, chtype ch);\fR
+.br
+\fBmvwaddch(WINDOW *win, int y, int x, chtype ch);\fR
+.br
+\fBechochar(chtype ch);\fR
+.br
+\fBwechochar(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 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. A newline also does a \fBclrtoeol\fR before moving. 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 control character, 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 by OR-ing them into the
+parameter. This results in these attributes also being set. (The intent here
+is that text, including attributes, can be copied from one place to another
+using \fBinch\fR and \fBaddch\fR.) [see \fBstandout\fR, predefined video
+attribute constants, on the curs_attr(3X) page].
+
+The \fBechochar\fR and \fBwechochar\fR routines are functionally 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 taken into consideration and, for
+non-control characters, a considerable performance gain might 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. The names are taken from the the 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
+.TE
+
+.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 BUGS
+The ncurses implementation does not yet handle insertion of a character at the
+bottom-rightmost position of the screen correctly. If the terminal has the
+auto_right_margin property, the real screen will be scrolled up one regardless
+of whether scrollok has been enabled for \fBstdscr\fR.
+
+The entry points \fBechochar\fR and \fBwechochar\fR are not yet implemented in
+ncurses 1.8.1.
+.SH NOTES
+Note that \fBaddch\fR, \fBmvaddch\fR, \fBmvwaddch\fR, and
+\fBechochar\fR may be macros.
+.SH SEE ALSO
+\fBncurses\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/libncurses/curs_addchst.3 b/lib/libncurses/curs_addchst.3
new file mode 100644
index 0000000..50ed1a3
--- /dev/null
+++ b/lib/libncurses/curs_addchst.3
@@ -0,0 +1,50 @@
+.TH curs_addchstr 3X ""
+.SH NAME
+\fBcurs_addchstr\fR: \fBaddchstr\fR, \fBaddchnstr\fR, \fBwaddchstr\fR,
+\fBwaddchnstr\fR, \fBmvaddchstr\fR, \fBmvaddchnstr\fR, \fBmvwaddchstr\fR,
+\fBmvwaddchnstr\fR - add string of characters (and attributes) to a
+\fBncurses\fR window
+.SH SYNOPSIS
+\fB#include <ncurses.h>\fR
+
+\fBint addchstr(chtype *chstr);\fR
+.br
+\fBint addchnstr(chtype *chstr, int n);\fR
+.br
+\fBint waddchstr(WINDOW *win, chtype *chstr);\fR
+.br
+\fBint waddchnstr(WINDOW *win, chtype *chstr, int n);\fR
+.br
+\fBint mvaddchstr(int y, int x, chtype *chstr);\fR
+.br
+\fBint mvaddchnstr(int y, int x, chtype *chstr, int n);\fR
+.br
+\fBint mvwaddchstr(WINDOW *win, int y, int x, chtype *chstr);\fR
+.br
+\fBint mvwaddchnstr(WINDOW *win, int y, int x, 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, care must be taken when using them because
+they don't perform any kind of checking (such as for the newline character),
+they don't advance the current cursor position, and they truncate the string if
+it crosses the right margin, rather then wrapping it around to the new line.
+.SH RETURN VALUES
+All these 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 NOTES
+Note that all routines except \fBwaddchnstr\fR may be macros.
+.SH SEE ALSO
+\fBncurses\fR(3X).
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libncurses/curs_addstr.3 b/lib/libncurses/curs_addstr.3
new file mode 100644
index 0000000..ba60b12
--- /dev/null
+++ b/lib/libncurses/curs_addstr.3
@@ -0,0 +1,44 @@
+.TH curs_addstr 3X ""
+.SH NAME
+\fBcurs_addstr\fR: \fBaddstr\fR, \fBaddnstr\fR, \fBwaddstr\fR, \fBwaddnstr\fR,
+\fBmvaddstr\fR, \fBmvaddnstr\fR, \fBmvwaddstr\fR, \fBmvwaddnstr\fR - add a
+string of characters to a \fBncurses\fR window and advance cursor
+.SH SYNOPSIS
+\fB#include <ncurses.h>\fR
+
+\fBint addstr(char *str);\fR
+.br
+\fBint addnstr(char *str, int n);\fR
+.br
+\fBint waddstr(WINDOW *win, char *str);\fR
+.br
+\fBint waddnstr(WINDOW *win, char *str, int n);\fR
+.br
+\fBint mvaddstr(y, int x, char *str);\fR
+.br
+\fBint mvaddnstr(y, int x, char *str, int n);\fR
+.br
+\fBint mvwaddstr(WINDOW *win, int y, int x, char *str);\fR
+.br
+\fBint mvwaddnstr(WINDOW *win, int y, int x, 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 negative, then the
+entire string will be added.
+.SH RETURN VALUE
+All routines return the integer \fBERR\fR upon failure and 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 SEE ALSO
+\fBncurses\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/libncurses/curs_attr.3 b/lib/libncurses/curs_attr.3
new file mode 100644
index 0000000..f0f4f525
--- /dev/null
+++ b/lib/libncurses/curs_attr.3
@@ -0,0 +1,87 @@
+.TH curs_attr 3X ""
+.SH NAME
+\fBcurs_attr\fR: \fBattroff\fR, \fBwattroff\fR, \fBattron\fR, \fBwattron\fR,
+\fBattrset\fR, \fBwattrset\fR, \fBstandend\fR, \fBwstandend\fR, \fBstandout\fR,
+\fBwstandout\fR - \fBncurses\fR character and window attribute control routines
+.SH SYNOPSIS
+\fB#include <ncurses.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
+.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 \fBattrest(0)\fR, that is, it turns off all
+attributes.
+.SS Attributes
+The following video attributes, defined in \fB<ncurses.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_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 these routines are not neaningful (many 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 BUGS
+As of 1.8.2, ncurses attributes still have a tendency to stick on in some
+circumstances where SVr4 curses attributes would turn off.
+.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 SEE ALSO
+\fBncurses\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/libncurses/curs_beep.3 b/lib/libncurses/curs_beep.3
new file mode 100644
index 0000000..5909c51
--- /dev/null
+++ b/lib/libncurses/curs_beep.3
@@ -0,0 +1,29 @@
+.TH curs_beep 3X ""
+.SH NAME
+\fBcurs_beep\fR: \fBbeep\fR, \fBflash\fR - \fBncurses\fR bell and screen flash routines
+.SH SYNOPSIS
+\fB#include <ncurses.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 always return \fBOK\fR.
+.SH CAPABILITIES
+\fBbell\fR, \fBflash_screen\fR.
+.SH SEE ALSO
+\fBncurses\fR(3X)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libncurses/curs_bkgd.3 b/lib/libncurses/curs_bkgd.3
new file mode 100644
index 0000000..d2cd2f1
--- /dev/null
+++ b/lib/libncurses/curs_bkgd.3
@@ -0,0 +1,50 @@
+.TH curs_bkgd 3X ""
+.SH NAME
+\fBcurs_bkgd\fR: \fBbkgdset\fR, \fBwbkgdset\fR, \fBbkgd\fR,
+\fBwbkgd\fR - \fBncurses\fR window background manipulation routines
+.SH SYNOPSIS
+\fB#include <ncurses.h>\fR
+
+\fBvoid bkgdset(chtype ch);\fR
+.br
+\fBvoid wbkgdset(WINDOW *win, chtype ch);\fR
+.br
+\fBint bkgd(chtype ch);\fR
+.br
+\fBint wbkgd(WINDOW *win, chtype ch);\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.
+.SH RETURN VALUE
+\fBbkgd\fR and \fBwbkgd\fR return the integer \fBOK\fR, or a
+non-negative integer, if \fBimmedok\fR is set.
+.SH NOTES
+Note that \fBbkgdset\fR and \fBbkgd\fR may be macros.
+.SH BUGS
+These features and \fBimmedok\fR are not yet implemented in ncurses 1.8.1.
+.SH SEE ALSO
+\fBncurses\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/libncurses/curs_border.3 b/lib/libncurses/curs_border.3
new file mode 100644
index 0000000..23752bf
--- /dev/null
+++ b/lib/libncurses/curs_border.3
@@ -0,0 +1,67 @@
+.TH curs_border 3X ""
+.SH NAME
+\fBcurs_border\fR: \fBborder\fR, \fBwborder\fR, \fBbox\fR,
+\fBhline\fR, \fBwhline\fR, \fBvline\fR, \fBwvline\fR - create
+\fBncurses\fR borders, horizontal and vertical lines
+.SH SYNOPSIS
+\fB#include <ncurses.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 \fBncurses.h\fR) are used instead: \fBACS_VLINE,
+ACS_VLINE, ACS_HLINE, ACS_HLINE, \fBACS_ULCORNER, ACS_URCORNER, ACS_BLCORNER,
+ACS_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 BUGS
+The \fBimmedok\fR function is not yet implemented in ncurses 1.8.1.
+.SH SEE ALSO
+\fBncurses\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/libncurses/curs_clear.3 b/lib/libncurses/curs_clear.3
new file mode 100644
index 0000000..9aeac8d
--- /dev/null
+++ b/lib/libncurses/curs_clear.3
@@ -0,0 +1,53 @@
+.TH curs_clear 3X ""
+.SH NAME
+\fBcurs_clear\fR: \fBerase\fR, \fBwerase\fR, \fBclear\fR,
+\fBwclear\fR, \fBclrtobot\fR, \fBwclrtobot\fR, \fBclrtoeol\fR,
+\fBwclrtoeol\fR - clear all or part of a \fBncurses\fR window
+.SH SYNOPSIS
+\fB# include <ncurses.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.
+.SH RETURN VALUE
+All routines return the integer \fBOK\fR, or a non-negative integer if
+\fBimmedok\fR is set.
+.SH NOTES
+Note that \fBerase\fR, \fBwerase\fR, \fBclear\fR, \fBwclear\fR,
+\fBclrtobot\fR, and \fBclrtoeol\fR may be macros.
+.SH SEE ALSO
+\fBncurses\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/libncurses/curs_color.3 b/lib/libncurses/curs_color.3
new file mode 100644
index 0000000..56f9379
--- /dev/null
+++ b/lib/libncurses/curs_color.3
@@ -0,0 +1,138 @@
+.TH curs_color 3X ""
+.SH NAME
+\fBcurs_color\fR: \fBstart_color\fR, \fBinit_pair\fR,
+\fBinit_color\fR, \fBhas_colors\fR, \fBcan_change_color\fR,
+\fBcolor_content\fR, \fBpair_content\fR - \fBncurses\fR color
+manipulation routines
+.SH SYNOPSIS
+\fB# include <ncurses.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
+\fBncurses\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<ncurses.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<ncurses.h>\fR the following macros are defined. These are the default
+colors. \fBncurses\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
+All routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
+upon successful completion.
+.SH BUGS
+Several caveats apply onn 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 CAPABILITIES
+\fBsetf\fR, \fBsetb\fR, \fBsetaf\fR, \fBsetab\fR. The ncurses library uses
+the second pair by preference, falling back to the first.
+.SH SEE ALSO
+\fBncurses\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
diff --git a/lib/libncurses/curs_delch.3 b/lib/libncurses/curs_delch.3
new file mode 100644
index 0000000..0251445
--- /dev/null
+++ b/lib/libncurses/curs_delch.3
@@ -0,0 +1,34 @@
+.TH curs_delch 3X ""
+.SH NAME
+\fBcurs_delch\fR: \fBdelch\fR, \fBwdelch\fR, \fBmvdelch\fR, \fBmvwdelch\fR -
+delete character under the cursor in a \fBncurses\fR window
+.SH SYNOPSIS
+\fB#include <ncurses.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 integer value
+other than \fBERR\fR upon successful completion.
+.SH NOTES
+Note that \fBdelch\fR, \fBmvdelch\fR, and \fBmvwdelch\fR may be macros.
+.SH SEE ALSO
+\fBncurses\fR(3X)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libncurses/curs_delln.3 b/lib/libncurses/curs_delln.3
new file mode 100644
index 0000000..d8a3c46
--- /dev/null
+++ b/lib/libncurses/curs_delln.3
@@ -0,0 +1,53 @@
+.TH curs_deleteln 3X ""
+.SH NAME
+\fBcurs_deleteln\fR: \fBdeleteln\fR, \fBwdeleteln\fR, \fBinsdelln\fR,
+\fBwinsdelln\fR, \fBinsertln\fR, \fBwinsertln\fR - delete and insert
+lines in a \fBncurses\fR window
+.SH SYNOPSIS
+\fB#include <ncurses.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 integer
+value other than \fBERR\fR upon successful completion.
+.SH BUGS
+All the above should be implemented through \fBwinsdelln\fR() but
+currently only \fBinsdelln\fR() is implemented in terms of it.
+.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
+\fBncurses\fR(3X)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libncurses/curs_getch.3 b/lib/libncurses/curs_getch.3
new file mode 100644
index 0000000..1b16502
--- /dev/null
+++ b/lib/libncurses/curs_getch.3
@@ -0,0 +1,188 @@
+.TH curs_getch 3X ""
+.SH NAME
+\fBcurs_getch\fR: \fBgetch\fR, \fBwgetch\fR, \fBmvgetch\fR,
+\fBmvwgetch\fR, \fBungetch\fR - get (or push back) characters from
+\fBncurses\fR terminal keyboard
+.SH SYNOPSIS
+\fB#include <ncurses.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. Unless \fBnoecho\fR has been set, the
+character will also be echoed into the designated window.
+
+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<ncurses.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), \fBncurses\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<ncurses.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 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 CAPABILITIES
+All of the key_* capabilities; also \fBkeypad_local\fR and \fBkeypad_xmit\fR.
+.SH SEE ALSO
+\fBncurses\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/libncurses/curs_getstr.3 b/lib/libncurses/curs_getstr.3
new file mode 100644
index 0000000..1151ae0
--- /dev/null
+++ b/lib/libncurses/curs_getstr.3
@@ -0,0 +1,53 @@
+.TH curs_getstr 3X ""
+.SH NAME
+\fBcurs_getstr\fR: \fBgetstr\fR, \fBwgetstr\fR, \fBmvgetstr\fR,
+\fBmvwgetstr\fR, \fBwgetnstr\fR - accept character strings from
+\fBncurses\fR terminal keyboard
+.SH SYNOPSIS
+\fB#include <ncurses.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.
+
+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.
+.SH RETURN VALUE
+All routines return the integer \fBERR\fR upon failure and an integer value
+other than \fBERR\fR upon successful completion.
+.SH BUGS
+When the window is in keypad mode and the user types any special key
+other than those named above, the `character' value appended to the
+string by the ncurses implementation is predictable but not useful
+(being, in fact, the low-order eight bits of the key's KEY_ value).
+
+The SVr4.0 documentation claims that "special keys (such as function
+keys, "home" key, "clear" key, \fIetc\fR.) are interpreted" without
+giving details. It lies. The actual behavior is like that of ncurses.
+.SH NOTES
+Note that \fBgetstr\fR, \fBmvgetstr\fR, and \fBmvwgetstr\fR may be macros.
+.SH SEE ALSO
+\fBncurses\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/libncurses/curs_getyx.3 b/lib/libncurses/curs_getyx.3
new file mode 100644
index 0000000..42fb006
--- /dev/null
+++ b/lib/libncurses/curs_getyx.3
@@ -0,0 +1,41 @@
+.TH curs_getyx 3X ""
+.SH NAME
+\fBcurs_getyx\fR: \fBgetyx\fR, \fBgetparyx\fR, \fBgetbegyx\fR,
+\fBgetmaxyx\fR - get \fBncurses\fR cursor and window coordinates
+.SH SYNOPSIS
+\fB#include <ncurses.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 cursor position of the 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 SEE ALSO
+\fBncurses\fR(3X)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libncurses/curs_inch.3 b/lib/libncurses/curs_inch.3
new file mode 100644
index 0000000..2026739
--- /dev/null
+++ b/lib/libncurses/curs_inch.3
@@ -0,0 +1,40 @@
+.TH curs_inch 3X ""
+.SH NAME
+\fBcurs_inch\fR: \fBinch\fR, \fBwinch\fR, \fBmvinch\fR, \fBmvwinch\fR
+- get a character and attributes from a \fBncurses\fR window
+.SH SYNOPSIS
+\fB#include <ncurses.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<ncurses.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 SEE ALSO
+\fBncurses\fR(3X).
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libncurses/curs_inchstr.3 b/lib/libncurses/curs_inchstr.3
new file mode 100644
index 0000000..0ee8c1f
--- /dev/null
+++ b/lib/libncurses/curs_inchstr.3
@@ -0,0 +1,46 @@
+.TH curs_inchstr 3X ""
+.SH NAME
+\fBcurs_inchstr\fR: \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
+\fBncurses\fR window
+.SH SYNOPSIS
+\fB#include <ncurses.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.
+Constants defined in \fB<ncurses.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.
+.SH NOTES
+Note that all routines except \fBwinchnstr\fR may be macros.
+.SH SEE ALSO
+\fBncurses\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/libncurses/curs_initscr.3 b/lib/libncurses/curs_initscr.3
new file mode 100644
index 0000000..9badf74
--- /dev/null
+++ b/lib/libncurses/curs_initscr.3
@@ -0,0 +1,84 @@
+.TH curs_initscr 3X ""
+.SH NAME
+\fBcurs_initscr\fR: \fBinitscr\fR, \fBnewterm\fR, \fBendwin\fR,
+\fBisendwin\fR, \fBset_term\fR, \fBdelscreen\fR - \fBncurses\fR screen
+initialization and manipulation routines
+.SH SYNOPSIS
+\fB#include <ncurses.h>\fR
+
+\fBWINDOW *initscr(void);\fR
+.br
+\fBint endwin(void);\fR
+.br
+\fBint isendwin(void);\fR
+.br
+\fBSCREEN *newterm(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 \fBncurses\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, or in order to test
+for the presence of given capabilities, \fBnewterm\fR may be called before
+\fBinitscr\fR.
+
+The initscr code determines the terminal type and initializes all \fBncurses\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 ncurses. 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
+\fBncurses\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 SEE ALSO
+\fBncurses\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/libncurses/curs_inopts.3 b/lib/libncurses/curs_inopts.3
new file mode 100644
index 0000000..c237210
--- /dev/null
+++ b/lib/libncurses/curs_inopts.3
@@ -0,0 +1,170 @@
+.TH curs_inopts 3X ""
+.SH NAME
+\fBcurs_inopts\fR: \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 - \fBncurses\fR input options
+.SH SYNOPSIS
+\fB#include <ncurses.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 notimeout(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
+\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 \fBncurses\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 \fBncurses\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), \fBncurses\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). To force 7 bits to be returned, invoke
+\fBmeta\fR(\fIwin\fR, \fBFALSE\fR). 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.
+
+With the \fBraw\fR and \fBnoraw\fR routines, the terminal is placed
+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
+\fBncurses\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.
+
+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).
+
+\fBncurses\fR 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 an
+integer value other than \fBERR\fR upon successful completion, unless otherwise
+noted in the preceding routine descriptions.
+.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.
+.SH BUGS
+The entry points \fBintrflush\fR, \fBqiflush\fR, \fBnoqiflush\fR, and
+\fBtypeahead\fR are not yet implemented in ncurses 1.8.1. The ncurses
+code does not do typeahead checking during input as SVr4 curses does.
+.SH SEE ALSO
+\fBncurses\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/libncurses/curs_insch.3 b/lib/libncurses/curs_insch.3
new file mode 100644
index 0000000..a332230
--- /dev/null
+++ b/lib/libncurses/curs_insch.3
@@ -0,0 +1,36 @@
+.TH curs_insch 3X ""
+.SH NAME
+\fBcurs_insch\fR: \fBinsch\fR, \fBwinsch\fR, \fBmvinsch\fR, \fBmvwinsch\fR -
+insert a character before cursor in a \fBncurses\fR window
+.SH SYNOPSIS
+\fB#include <ncurses.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 return the integer \fBERR\fR upon failure and an integer value
+other than \fBERR\fR upon successful completion.
+.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 SEE ALSO
+\fBncurses\fR(3X).
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libncurses/curs_insstr.3 b/lib/libncurses/curs_insstr.3
new file mode 100644
index 0000000..85cad11
--- /dev/null
+++ b/lib/libncurses/curs_insstr.3
@@ -0,0 +1,57 @@
+.TH curs_insstr 3X ""
+.SH NAME
+\fBcurs_instr\fR: \fBinsstr\fR, \fBinsnstr\fR, \fBwinsstr\fR, \fBwinsnstr\fR,
+\fBmvinsstr\fR, \fBmvinsnstr\fR, \fBmvwinsstr\fR, \fBmvwinsnstr\fR - insert
+string before cursor a \fBncurses\fR window
+.SH SYNOPSIS
+\fB#include <ncurses.h>\fR
+.br
+\fBint insstr(char *str);\fR
+.br
+\fBint insnstr(char *str, int n);\fR
+.br
+\fBint winsstr(WINDOW *win, char *str);\fR
+.br
+\fBint winsnstr(WINDOW *win, char *str, int n);\fR
+.br
+\fBint mvinsstr(int y, int x, char *str);\fR
+.br
+\fBint mvinsnstr(int y, int x, char *str, int n);\fR
+.br
+\fBint mvwinsstr(WINDOW *win, int y, int x, char *str);\fR
+.br
+\fBint mvwinsnstr(WINDOW *win, int y, int x, 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 return the integer \fBERR\fR upon failure and an integer value
+other than \fBERR\fR upon successful completion.
+.SH BUGS
+Entry points for these functions are n ncurses.h but they are not
+implemented as of ncurses 1.8.5.
+.SH NOTES
+Note that all but \fBwinsnstr\fR may be macros.
+.SH SEE ALSO
+\fBncurses\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/libncurses/curs_instr.3 b/lib/libncurses/curs_instr.3
new file mode 100644
index 0000000..f109afe
--- /dev/null
+++ b/lib/libncurses/curs_instr.3
@@ -0,0 +1,44 @@
+.TH curs_instr 3X ""
+.SH NAME
+\fBcurs_instr\fR: \fBinstr\fR, \fBinnstr\fR, \fBwinstr\fR, \fBwinnstr\fR,
+\fBmvinstr\fR, \fBmvinnstr\fR, \fBmvwinstr\fR, \fBmvwinnstr\fR - get a string
+of characters from a \fBncurses\fR window
+.SH SYNOPSIS
+\fB#include <ncurses.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.
+.SH RETURN VALUE
+All routines return the integer \fBERR\fR upon failure and an integer value
+other than \fBERR\fR upon successful completion.
+.SH NOTES
+Note that all routines except \fBwinnstr\fR may be macros.
+.SH SEE ALSO
+\fBncurses\fR(3X).
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
+
diff --git a/lib/libncurses/curs_kernel.3 b/lib/libncurses/curs_kernel.3
new file mode 100644
index 0000000..24084f6
--- /dev/null
+++ b/lib/libncurses/curs_kernel.3
@@ -0,0 +1,113 @@
+.TH curs_kernel 3X ""
+.SH NAME
+\fBcurs_kernel\fR: \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 \fBncurses\fR routines
+.SH SYNOPSIS
+\fB#include <ncurses.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
+\fBint getsyx(int y, int x);\fR
+.br
+\fBint 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(int ms);\fR
+.br
+.SH DESCRIPTION
+The following routines give low-level access to various \fBncurses\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 \fBncurses\fR) or "shell"
+(not in \fBncurses\fR) state for use by the \fBreset_prog_mode\fR and
+\fBreset_shell_mode\fR routines. This is done automatically by
+\fBinitscr\fR.
+
+The \fBreset_prog_mode\fR and \fBreset_shell_mode\fR routines restore
+the terminal to "program" (in \fBncurses\fR) or "shell" (out of
+\fBncurses\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.
+
+With the \fBgetsyx\fR routine, the current coordinates of the virtual
+screen cursor are returned 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.
+
+With the \fBsetsyx\fR routine, the virtual screen cursor is set 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
+\fBncurses\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<ncurses.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.
+.SH BUGS
+The return value of curs_set is currently incorrect.
+.SH SEE ALSO
+\fBncurses\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/libncurses/curs_move.3 b/lib/libncurses/curs_move.3
new file mode 100644
index 0000000..f7bdfd3
--- /dev/null
+++ b/lib/libncurses/curs_move.3
@@ -0,0 +1,28 @@
+.TH curs_move 3X ""
+.SH NAME
+\fBcurs_move\fR: \fBmove\fR, \fBwmove\fR - move \fBncurses\fR window cursor
+.SH SYNOPSIS
+\fB#include <ncurses.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 the integer \fBERR\fR upon failure and an integer value
+other than \fBERR\fR upon successful completion.
+.SH NOTES
+Note that \fBmove\fR may be a macro.
+.SH SEE ALSO
+\fBncurses\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/libncurses/curs_outopts.3 b/lib/libncurses/curs_outopts.3
new file mode 100644
index 0000000..ccf800d
--- /dev/null
+++ b/lib/libncurses/curs_outopts.3
@@ -0,0 +1,114 @@
+.TH curs_outopts 3X ""
+.SH NAME
+\fBcurs_outopts\fR: \fBclearok\fR, \fBidlok\fR, \fBidcok immedok\fR,
+\fBleaveok\fR, \fBsetscrreg\fR, \fBwsetscrreg\fR, \fBscrollok\fR,
+\fBnl\fR, \fBnonl\fR - \fBncurses\fR output options
+.SH SYNOPSIS
+\fB#include <ncurses.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
+\fBncurses\fR. All options are initially \fBFALSE\fR, unless otherwise stated.
+It is not necessary to turn these options off before calling \fBendwin\fR.
+
+With the \fBclearok\fR routine, if enabled (\fIbf\fR is \fBTRUE\fR), 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.
+
+With the \fBidlok\fR routine, if enabled (\fIbf\fR is \fBTRUE\fR),
+\fBncurses\fR considers using the hardware insert/delete line feature of
+terminals so equipped. If disabled (\fIbf\fR is \fBFALSE\fR), \fBncurses\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, \fBncurses\fR redraws the changed portions of all lines.
+
+With the \fBidcok\fR routine, if enabled (\fIbf\fR is \fBTRUE\fR),
+\fBncurses\fR considers using the hardware insert/delete character feature of
+terminals so equipped. This is enabled by default.
+
+With the \fBimmedok\fR routine, if enabled (\fIbf\fR is \fBTRUE)\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 up one 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), \fBwrefresh\fR is called on the
+window, and the physical terminal and window are 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 newline is translated into
+carriage return and linefeed on output, and whether return is translated into
+newline on input. Initially, the translations do occur. By disabling these
+translations using \fBnonl\fR, \fBncurses\fR is able to make better use of the
+linefeed capability, resulting in faster cursor motion.
+.SH RETURN VALUE
+\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 BUGS
+The entry points \fBidcok\fR, \fBimmedok\fR are not yet implemented in
+ncurses 1.8.1.
+.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
+\fBncurses\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/libncurses/curs_overlay.3 b/lib/libncurses/curs_overlay.3
new file mode 100644
index 0000000..bc9723a3
--- /dev/null
+++ b/lib/libncurses/curs_overlay.3
@@ -0,0 +1,41 @@
+.TH curs_overlay 3X ""
+.SH NAME
+\fBcurs_overlay\fR: \fBoverlay\fR, \fBoverwrite\fR, \fBcopywin\fR - overlay and
+manipulate overlapped \fBncurses\fR windows
+.SH SYNOPSIS
+\fB#include <ncurses.h>\fR
+
+\fBint overlay(WINDOW *srcwin, WINDOW *dstwin);\fR
+.br
+\fBint overwrite(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 an integer
+value other than \fBERR\fR upon successful completion.
+.SH NOTES
+Note that \fBoverlay\fR and \fBoverwrite\fR may be macros.
+.SH SEE ALSO
+\fBncurses\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/libncurses/curs_pad.3 b/lib/libncurses/curs_pad.3
new file mode 100644
index 0000000..726630f
--- /dev/null
+++ b/lib/libncurses/curs_pad.3
@@ -0,0 +1,75 @@
+.TH curs_pad 3X ""
+.SH NAME
+\fBcurs_pad\fR: \fBnewpad\fR, \fBsubpad\fR, \fBprefresh\fR,
+\fBpnoutrefresh\fR, \fBpechochar\fR - create and display \fBncurses\fR
+pads
+.SH SYNOPSIS
+\fB#include <ncurses.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
+\fBint prefresh(WINDOW *pad, int pminrow, int pmincol,
+ int sminrow, int smincol, int smaxrow, int smaxcol);\fR
+\fBint pnoutrefresh(WINDOW *pad, int pminrow, int pmincol,
+ int sminrow, int smincol, int smaxrow, int smaxcol);\fR
+\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 an integer
+value other than \fBERR\fR upon successful completion.
+
+Routines that return pointers return \fBNULL\fR on error.
+.SH NOTES
+Note that \fBpechochar\fR may be a macro.
+.SH SEE ALSO
+\fBncurses\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/libncurses/curs_printw.3 b/lib/libncurses/curs_printw.3
new file mode 100644
index 0000000..b58dba4
--- /dev/null
+++ b/lib/libncurses/curs_printw.3
@@ -0,0 +1,42 @@
+.TH curs_printw 3X ""
+.SH NAME
+\fBcurs_printw\fR: \fBprintw\fR, \fBwprintw\fR, \fBmvprintw\fR,
+\fBmvwprintw\fR, \fBvwprintw\fR - print formatted output in
+\fBncurses\fR windows
+.SH SYNOPSIS
+\fB#include <ncurses.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
+All routines return the integer \fBERR\fR upon failure and an integer value
+other than \fBERR\fR upon successful completion.
+.SH SEE ALSO
+\fBncurses\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/libncurses/curs_refresh.3 b/lib/libncurses/curs_refresh.3
new file mode 100644
index 0000000..3445d75
--- /dev/null
+++ b/lib/libncurses/curs_refresh.3
@@ -0,0 +1,69 @@
+.TH curs_refresh 3X ""
+.SH NAME
+\fBcurs_refresh\fR: \fBrefresh\fR, \fBwrefresh\fR, \fBwnoutrefresh\fR,
+\fBdoupdate\fR, \fBredrawwin\fR, \fBwredrawln\fR - refresh
+\fBncurses\fR windows and lines
+.SH SYNOPSIS
+\fB#include <ncurses.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, \fBncurses\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 \fBredrawwin\fR routine indicates to \fBncurses\fR that some screen lines
+are corrupted and should be thrown away before anything is written over them.
+These routines could be used for programs such as editors, which want a command
+to redraw some part of the screen or the entire screen. The routine
+\fBredrawln\fR is preferred over \fBredrawwin\fR where a noisy communication
+line exists and redrawing the entire window could be subject to even more
+communication noise. Just redrawing several lines offers the possibility that
+they would show up unblemished.
+.SH RETURN VALUE
+All routines return the integer \fBERR\fR upon failure and an integer value
+other than \fBERR\fR upon successful completion.
+.SH NOTES
+Note that \fBrefresh\fR and \fBredrawwin\fR may be macros.
+.SH SEE ALSO
+\fBncurses\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/libncurses/curs_scanw.3 b/lib/libncurses/curs_scanw.3
new file mode 100644
index 0000000..15efca3
--- /dev/null
+++ b/lib/libncurses/curs_scanw.3
@@ -0,0 +1,44 @@
+.TH curs_scanw 3X ""
+.SH NAME
+\fBcurs_scanw\fR: \fBscanw\fR, \fBwscanw\fR, \fBmvscanw\fR,
+\fBmvwscanw\fR, \fBvwscanw\fR - convert formatted input from a
+\fBncurses\fR widow
+.SH SYNOPSIS
+\fB#include <ncurses.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 SEE ALSO
+\fBncurses\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/libncurses/curs_scr_dmp.3 b/lib/libncurses/curs_scr_dmp.3
new file mode 100644
index 0000000..2572f98
--- /dev/null
+++ b/lib/libncurses/curs_scr_dmp.3
@@ -0,0 +1,56 @@
+.TH curs_scr_dump 3X ""
+.SH NAME
+\fBcurs_scr_dump\fR: \fBscr_dump\fR, \fBscr_restore\fR,
+\fBscr_init\fR, \fBscr_set\fR - read (write) a \fBncurses\fR screen
+from (to) a file
+.SH SYNOPSIS
+\fB#include <ncurses.h>\fR
+
+\fBint scr_dump(char *filename);\fR
+.br
+\fBint scr_restore(char *filename);\fR
+.br
+\fBint scr_init(char *filename);\fR
+.br
+\fBint scr_set(char *filename);\fR
+.br
+.SH DESCRIPTION
+The \fBscr_dump\fR routine dumps the current contents of the virtual screen
+to the file \fIfilename\fR.
+
+With the \fBscr_restore\fR routine, the virtual screen is set 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.
+
+With the \fBscr_init\fR routine, the contents of \fIfilename\fR are read in and
+used to initialize the \fBncurses\fR data structures about what the terminal
+currently has on its screen. If the data is determined to be valid,
+\fBncurses\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 time-stamp of the tty
+is old or the terminfo capabilities \fBrmcup\fR and \fBnrrmc\fR exist.
+
+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 SEE ALSO
+\fBncurses\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/libncurses/curs_scroll.3 b/lib/libncurses/curs_scroll.3
new file mode 100644
index 0000000..9836032
--- /dev/null
+++ b/lib/libncurses/curs_scroll.3
@@ -0,0 +1,38 @@
+.TH curs_scroll 3X ""
+.SH NAME
+\fBcurs_scroll\fR: \fBscroll\fR, \fBsrcl\fR, \fBwscrl\fR - scroll a
+\fBncurses\fR window
+.SH SYNOPSIS
+\fB#include <ncurses.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 is scrolled at
+the same time.
+
+With the \fBscrl\fR and \fBwscrl\fR routines, for positive \fIn\fR 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
+All routines return the integer \fBERR\fR upon failure and an integer value
+other than \fBERR\fR upon successful completion.
+.SH NOTES
+Note that \fBscrl\fR and \fBscroll\fR may be macros.
+.SH SEE ALSO
+\fBncurses\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/libncurses/curs_slk.3 b/lib/libncurses/curs_slk.3
new file mode 100644
index 0000000..b674159
--- /dev/null
+++ b/lib/libncurses/curs_slk.3
@@ -0,0 +1,85 @@
+.TH curs_slk 3X ""
+.SH NAME
+\fBcurs_slk\fR: \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 -
+\fBncurses\fR soft label routines
+.SH SYNOPSIS
+\fB#include <ncurses.h>\fR
+
+\fBint slk_init(int fmt);\fR
+.br
+\fBint slk_set(int labnum, 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(chtype attrs);\fR
+.br
+\fBint slk_attrset(chtype attrs);\fR
+.br
+\fBint slk_attroff(chtype 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,
+\fBncurses\fR takes over the bottom line of \fBstdscr\fR, reducing the size of
+\fBstdscr\fR and the variable \fBLINES\fR. \fBncurses\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.
+
+With the \fBslk_set\fR routine, \fIlabnum\fR is the label number, from \fB1\fR
+to \fB8\fR. \fIlabel\fR is 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.
+.SH RETURN VALUE
+Routines that return an integer return \fBERR\fR upon failure and 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 SEE ALSO
+\fBncurses\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/libncurses/curs_termatt.3 b/lib/libncurses/curs_termatt.3
new file mode 100644
index 0000000..fab073e
--- /dev/null
+++ b/lib/libncurses/curs_termatt.3
@@ -0,0 +1,76 @@
+.TH curs_termattrs 3X ""
+.SH NAME
+\fBcurs_termattrs\fR: \fBbaudrate\fR, \fBerasechar\fR, \fBhas_ic\fR,
+\fBhas_il\fR, \fBkillchar\fR, \fBlongname\fR, \fBtermattrs\fR,
+\fBtermname\fR - \fBncurses\fR environment query routines
+.SH SYNOPSIS
+\fB#include <ncurses.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
+\fBchtype 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, \fBncurses\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 \fBncurses\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 an integer
+value other than \fBERR\fR upon successful completion.
+.SH BUGS
+The \fBtermattr\fR entry point is not implemented in ncurses 1.8.1.
+.SH NOTES
+Note that \fBtermattrs\fR may be a macro.
+.SH SEE ALSO
+\fBncurses\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/libncurses/curs_touch.3 b/lib/libncurses/curs_touch.3
new file mode 100644
index 0000000..8fe73b8
--- /dev/null
+++ b/lib/libncurses/curs_touch.3
@@ -0,0 +1,57 @@
+.TH curs_touch 3X ""
+.SH NAME
+\fBcurs_touch\fR: \fBtouchwin\fR, \fBtouchline\fR, \fBuntouchwin\fR,
+\fBwtouchln\fR, \fBis_linetouched\fR, \fBis_wintouched\fR -
+\fBncurses\fR refresh control routines
+.SH SYNOPSIS
+\fB#include <ncurses.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 NOTES
+Note that all routines except \fBwtouchln\fR may be macros.
+.SH SEE ALSO
+\fBncurses\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/libncurses/curs_util.3 b/lib/libncurses/curs_util.3
new file mode 100644
index 0000000..70e8d1a
--- /dev/null
+++ b/lib/libncurses/curs_util.3
@@ -0,0 +1,82 @@
+.TH curs_util 3X ""
+.SH NAME
+\fBcurs_util\fR: \fBunctrl\fR, \fBkeyname\fR, \fBfilter\fR,
+\fBuse_env\fR, \fBputwin\fR, \fBgetwin\fR, \fBdelay_output\fR,
+\fBflushinp\fR - miscellaneous \fBncurses\fR utility routines
+.SH SYNOPSIS
+\fB#include <ncurses.h>\fR
+
+\fBchar *unctrl(chtype c);\fR
+.br
+\fBchar *keyname(int c);\fR
+.br
+\fBint 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. It makes \fBncurses\fR think that there is a
+one-line screen. \fBncurses\fR does not use any terminal capabilities
+that assume that they know on what line of the screen the cursor is
+positioned.
+
+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
+\fBncurses\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 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 BUGS
+The \fBfilter\fR and \fBdelay_output\fR entry points are not yet
+supported in ncurses 1.8.1.
+.SH NOTES
+Note that \fBunctrl\fR is a macro, which is defined in <\fBunctrl.h\fR>.
+.SH SEE ALSO
+\fBncurses\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/libncurses/curs_window.3 b/lib/libncurses/curs_window.3
new file mode 100644
index 0000000..919c2f7
--- /dev/null
+++ b/lib/libncurses/curs_window.3
@@ -0,0 +1,119 @@
+.TH curs_window 3X ""
+.SH NAME
+\fBcurs_window\fR: \fBnewwin\fR, \fBdelwin\fR, \fBmvwin\fR,
+\fBsubwin\fR, \fBderwin\fR, \fBmvderwin\fR, \fBdupwin\fR,
+\fBwsyncup\fR, \fBsyncok\fR, \fBwcursyncup\fR, \fBwsyncdown\fR -
+create \fBncurses\fR windows
+.SH SYNOPSIS
+\fB#include <ncurses.h>\fR
+
+\fBWINDOW *newwin(int nlines, int ncols, int begin_y,\fR
+ \fBintbegin_x);\fR
+
+\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
+\fBWINDOW *derwin(WINDOW *orig, int nlines, int ncols,
+ int begin_y, int begin_x);\fR
+\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
+The \fBnewwin\fR routine 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.
+
+The \fBdelwin\fR routine 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.
+
+The \fBmvwin\fR routine 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.
+
+The \fBsubwin\fR routine 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.
+
+The \fBderwin\fR routine is the same as \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.
+
+The \fBmvderwin\fR routine 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.
+
+The \fBdupwin\fR routine creates an exact duplicate of the window \fIwin\fR.
+
+Each \fBncurses\fR window maintains two data structures: the character
+image structure and the status structure. The character image
+structure is shared among all windows in the window hierarchy
+(\fIi\fR.\fIe\fR., the window with all subwindows). The status
+structure, which contains information about individual line changes in
+the window, is private to each window. The routine \fBwrefresh\fR
+uses the status data structure when performing screen updating. Since
+status structures are not shared, changes made to one window in the
+hierarchy may not be properly reflected on the screen.
+
+The routine \fBwsyncup\fR causes the changes in the status structure
+of a window to be reflected in the status structures of its ancestors.
+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 routine \fBwcursyncup\fR updates the current cursor position of all the
+ancestors of the window to reflect the current cursor position of the
+window.
+
+The routine \fBwsyncdown\fR updates the status structure of the window
+to reflect the changes in the status structures of its ancestors.
+Applications seldom call this routine because it is called
+automatically by \fBwrefresh\fR.
+.SH RETURN VALUE
+Routines that return an integer return the integer \fBERR\fR upon failure and
+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 SEE ALSO
+\fBncurses\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/libncurses/curses.priv.h b/lib/libncurses/curses.priv.h
new file mode 100644
index 0000000..604fe7b6
--- /dev/null
+++ b/lib/libncurses/curses.priv.h
@@ -0,0 +1,115 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+ * curses.priv.h
+ *
+ * Header file for curses library objects which are private to
+ * the library.
+ *
+ */
+
+#include "version.h"
+
+#ifndef __GNUC__
+#define inline
+#endif
+
+#ifndef NOACTION
+#include <unistd.h>
+typedef struct sigaction sigaction_t;
+#else
+#include "SigAction.h"
+#endif
+
+#include <ncurses.h>
+
+#define min(a,b) ((a) > (b) ? (b) : (a))
+#define max(a,b) ((a) < (b) ? (b) : (a))
+
+#define FG(n) ((n) & 0x0f)
+#define BG(n) (((n) & 0xf0) >> 4)
+
+#define CHANGED -1
+
+extern WINDOW *newscr;
+extern int _coloron;
+extern int _isendwin;
+
+#ifdef TRACE
+#define T(a) if (_tracing) _tracef a
+extern int _tracing;
+#else
+#define T(a)
+#endif
+
+extern int _outc(char);
+extern void init_acs(void);
+extern void tstp(int);
+extern WINDOW *makenew(int, int, int, int);
+extern int timed_wait(int fd, int wait, int *timeleft);
+
+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 {
+ FILE *_ifp; /* input file ptr for this terminal */
+ FILE *_ofp; /* output file ptr for this terminal */
+#ifdef MYTINFO
+ struct _terminal *_term;
+#else
+ struct term *_term; /* used by terminfo stuff */
+#endif
+ WINDOW *_curscr; /* windows specific to a given terminal */
+ WINDOW *_newscr;
+ struct try *_keytry; /* "Try" for use with keypad mode */
+ unsigned int _fifo[FIFO_SIZE]; /* Buffer for pushed back characters */
+ signed char _fifohead,
+ _fifotail,
+ _fifopeek;
+ int _cursrow; /* Row and column of physical cursor */
+ int _curscol;
+ 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 _nlmapping; /* True if terminal is really doing */
+ /* NL mapping (fn of raw and nl) */
+ SLK *_slk; /* ptr to soft key struct / NULL */
+ int _costs[9]; /* costs of cursor movements for mvcur */
+ int _costinit; /* flag wether costs[] is initialized */
+};
+
+extern struct screen *SP;
+
+extern int _slk_format; /* format specified in slk_init() */
+
+#define MAXCOLUMNS 135
+#define MAXLINES 66
+#define UNINITIALISED ((struct try * ) -1)
diff --git a/lib/libncurses/keys.list b/lib/libncurses/keys.list
new file mode 100644
index 0000000..e766f32
--- /dev/null
+++ b/lib/libncurses/keys.list
@@ -0,0 +1,149 @@
+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
diff --git a/lib/libncurses/lib_acs.c b/lib/libncurses/lib_acs.c
new file mode 100644
index 0000000..70fd6d2
--- /dev/null
+++ b/lib/libncurses/lib_acs.c
@@ -0,0 +1,99 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+
+#include "curses.priv.h"
+#include <nterm.h>
+#include <string.h>
+
+/* line graphics */
+
+
+chtype acs_map[128];
+
+void init_acs()
+{
+
+/*
+ ACS_ULCORNER (acs_map['l'])
+ ACS_LLCORNER (acs_map['m'])
+ ACS_URCORNER (acs_map['k'])
+ ACS_LRCORNER (acs_map['j'])
+ ACS_RTEE (acs_map['u'])
+ ACS_LTEE (acs_map['t'])
+ ACS_BTEE (acs_map['v'])
+ ACS_TTEE (acs_map['w'])
+ ACS_HLINE (acs_map['q'])
+ ACS_VLINE (acs_map['x'])
+ ACS_PLUS (acs_map['n'])
+ ACS_S1 (acs_map['o']) scan line 1
+ ACS_S9 (acs_map['s']) scan line 9
+ ACS_DIAMOND (acs_map['`']) diamond
+ ACS_CKBOARD (acs_map['a']) checker board (stipple)
+ ACS_DEGREE (acs_map['f']) degree symbol
+ ACS_PLMINUS (acs_map['g']) plus/minus
+ ACS_BULLET (acs_map['~']) bullet
+ ACS_LARROW (acs_map[',']) arrow pointing left
+ ACS_RARROW (acs_map['+']) arrow pointing right
+ ACS_DARROW (acs_map['.']) arrow pointing down
+ ACS_UARROW (acs_map['-']) arrow pointing up
+ ACS_BOARD (acs_map['h']) board of squares
+ ACS_LANTERN (acs_map['I']) lantern symbol
+ ACS_BLOCK (acs_map['0']) solid square block
+*/
+
+ T(("initializing ACS map"));
+
+ acs_map['l'] = acs_map['m'] = acs_map['k'] = acs_map['j'] =
+ acs_map['u'] = acs_map['t'] = acs_map['v'] = acs_map['w'] = (chtype)'+' & A_CHARTEXT;
+ acs_map['q'] = (chtype)'-' & A_CHARTEXT;
+ acs_map['x'] = (chtype)'|' & A_CHARTEXT;
+ acs_map['n'] = (chtype)'+' & A_CHARTEXT;
+ acs_map['o'] = (chtype)'~' & A_CHARTEXT;
+ acs_map['s'] = (chtype)'_' & A_CHARTEXT;
+ acs_map['`'] = (chtype)'+' & A_CHARTEXT;
+ acs_map['a'] = (chtype)':' & A_CHARTEXT;
+ acs_map['f'] = (chtype)'\'' & A_CHARTEXT;
+ acs_map['g'] = (chtype)'#' & A_CHARTEXT;
+ acs_map['~'] = (chtype)'o' & A_CHARTEXT;
+ acs_map[','] = (chtype)'<' & A_CHARTEXT;
+ acs_map['+'] = (chtype)'>' & A_CHARTEXT;
+ acs_map['.'] = (chtype)'v' & A_CHARTEXT;
+ acs_map['-'] = (chtype)'^' & A_CHARTEXT;
+ acs_map['h'] = (chtype)'#' & A_CHARTEXT;
+ acs_map['I'] = (chtype)'#' & A_CHARTEXT;
+ acs_map['0'] = (chtype)'#' & A_CHARTEXT;
+
+ if (ena_acs != NULL)
+ tputs(ena_acs, 1, _outc);
+
+ if (acs_chars != NULL) {
+ int i = 0;
+ int 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':
+ acs_map[(unsigned int)(unsigned char)acs_chars[i]] =
+ (acs_chars[++i] & A_CHARTEXT) | A_ALTCHARSET;
+ default:
+ i++;
+ break;
+ }
+ }
+#ifdef TRACE
+ else {
+ if (_tracing)
+ _tracef("acsc not defined, using default mapping");
+ }
+#endif
+}
+
diff --git a/lib/libncurses/lib_addch.c b/lib/libncurses/lib_addch.c
new file mode 100644
index 0000000..50c4ae7
--- /dev/null
+++ b/lib/libncurses/lib_addch.c
@@ -0,0 +1,86 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_addch.c
+**
+** The routine waddch().
+**
+*/
+
+#include "curses.priv.h"
+#include "unctrl.h"
+
+int
+waddch(WINDOW *win, chtype c)
+{
+int x, y;
+int newx;
+chtype ch = c;
+
+#if 0
+ /* enabling this causes tons of tracing output
+ and slow ncurses down to a crawl */
+ T(("waddch(%x,%c (%x)) called", win, ch&A_CHARTEXT, ch));
+#endif
+
+ x = win->_curx;
+ y = win->_cury;
+
+ if (y > win->_maxy || x > win->_maxx || y < 0 || x < 0)
+ return(ERR);
+
+ switch (ch&A_CHARTEXT) {
+ case '\t':
+ for (newx = x + (8 - (x & 07)); x < newx; x++)
+ if (waddch(win, ' ') == ERR)
+ return(ERR);
+ return(OK);
+ case '\n':
+ wclrtoeol(win);
+ x = 0;
+ goto newline;
+ case '\r':
+ x = 0;
+ break;
+ case '\b':
+ if (--x < 0)
+ x = 0;
+ break;
+ default:
+ if (ch < ' ')
+ return(waddstr(win, unctrl(ch)));
+
+ ch |= win->_attrs;
+
+ if (win->_line[y][x] != ch) {
+ if (win->_firstchar[y] == _NOCHANGE)
+ win->_firstchar[y] = win->_lastchar[y] = x;
+ else if (x < win->_firstchar[y])
+ win->_firstchar[y] = x;
+ else if (x > win->_lastchar[y])
+ win->_lastchar[y] = x;
+
+ }
+
+ win->_line[y][x++] = ch;
+ if (x > win->_maxx) {
+ x = 0;
+newline:
+ y++;
+ if (y > win->_regbottom) {
+ y--;
+ if (win->_scroll)
+ scroll(win);
+ }
+ }
+ break;
+ }
+
+ win->_curx = x;
+ win->_cury = y;
+
+ return(OK);
+}
diff --git a/lib/libncurses/lib_addstr.c b/lib/libncurses/lib_addstr.c
new file mode 100644
index 0000000..007598c
--- /dev/null
+++ b/lib/libncurses/lib_addstr.c
@@ -0,0 +1,56 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_addstr.c
+*
+** The routines waddnstr(), waddchnstr().
+**
+*/
+
+#include "curses.priv.h"
+
+int
+waddnstr(WINDOW *win, char *str, int n)
+{
+ T(("waddnstr(%x,%s,%d) called", win, str, n));
+
+ if (str == NULL)
+ return ERR;
+
+ if (n < 0) {
+ while (*str != '\0') {
+ if (waddch(win, (unsigned char)*str++) == ERR)
+ return(ERR);
+ }
+ return OK;
+ }
+
+ while((n-- > 0) && (*str != '\0')) {
+ if (waddch(win, (unsigned char)*str++) == ERR)
+ return ERR;
+ }
+ return OK;
+}
+
+int
+waddchnstr(WINDOW *win, chtype *str, int n)
+{
+ T(("waddchnstr(%x,%x,%d) called", win, str, n));
+
+ if (n < 0) {
+ while (*str) {
+ if (waddch(win, *str++) == ERR)
+ return(ERR);
+ }
+ return OK;
+ }
+
+ while(n-- > 0) {
+ if (waddch(win, *str++) == ERR)
+ return ERR;
+ }
+ return OK;
+}
diff --git a/lib/libncurses/lib_beep.c b/lib/libncurses/lib_beep.c
new file mode 100644
index 0000000..7837ac1
--- /dev/null
+++ b/lib/libncurses/lib_beep.c
@@ -0,0 +1,56 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+ * beep.c
+ *
+ * Routines beep() and flash()
+ *
+ */
+
+#include "curses.priv.h"
+#include <nterm.h>
+
+/*
+ * beep()
+ *
+ * Sound the current terminal's audible bell if it has one. If not,
+ * flash the screen if possible.
+ *
+ */
+
+int beep()
+{
+ T(("beep() called"));
+
+ /* should make sure that we are not in altchar mode */
+ if (bell)
+ return(tputs(bell, 1, _outc));
+ else if (flash_screen)
+ return(tputs(flash_screen, 1, _outc));
+ else
+ return(ERR);
+}
+
+/*
+ * flash()
+ *
+ * Flash the current terminal's screen if possible. If not,
+ * sound the audible bell if one exists.
+ *
+ */
+
+int flash()
+{
+ T(("flash() called"));
+
+ /* should make sure that we are not in altchar mode */
+ if (flash_screen)
+ return(tputs(flash_screen, 1, _outc));
+ else if (bell)
+ return(tputs(bell, 1, _outc));
+ else
+ return(ERR);
+}
diff --git a/lib/libncurses/lib_box.c b/lib/libncurses/lib_box.c
new file mode 100644
index 0000000..ca4e032
--- /dev/null
+++ b/lib/libncurses/lib_box.c
@@ -0,0 +1,131 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** 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)
+{
+int i;
+int 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;
+ rs |= win->_attrs;
+ ts |= win->_attrs;
+ bs |= win->_attrs;
+ tl |= win->_attrs;
+ tr |= win->_attrs;
+ bl |= win->_attrs;
+ br |= win->_attrs;
+
+ T(("using %x, %x, %x, %x, %x, %x, %x, %x", ls, rs, ts, bs, tl, tr, bl, br));
+
+ endx = win->_maxx;
+ endy = win->_maxy;
+
+ for (i = 0; i <= endx; i++) {
+ win->_line[0][i] = ts;
+ win->_line[endy][i] = bs;
+ }
+ win->_firstchar[endy] = win->_firstchar[0] = 0;
+ win->_lastchar[endy] = win->_lastchar[0] = endx;
+
+ for (i = 0; i <= endy; i++) {
+ win->_line[i][0] = ls;
+ win->_line[i][endx] = rs;
+ win->_firstchar[i] = 0;
+ win->_lastchar[i] = endx;
+ }
+ win->_line[0][0] = tl;
+ win->_line[0][endx] = tr;
+ win->_line[endy][0] = bl;
+ win->_line[endy][endx] = br;
+
+#if 0
+ if (! win->_scroll && (win->_flags & _SCROLLWIN))
+ fp[0] = fp[endx] = lp[0] = lp[endx] = ' ';
+#endif
+
+ return OK;
+}
+
+int whline(WINDOW *win, chtype ch, int n)
+{
+int line;
+int start;
+int end;
+
+ T(("whline(%x,%x,%d) called", win, ch, n));
+
+ line = win->_cury;
+ start = win->_curx;
+ end = start + n - 1;
+ if (end > win->_maxx)
+ end = win->_maxx;
+
+ if (win->_firstchar[line] == _NOCHANGE || win->_firstchar[line] > start)
+ win->_firstchar[line] = start;
+ if (win->_lastchar[line] == _NOCHANGE || win->_lastchar[line] < start)
+ win->_lastchar[line] = end;
+
+ if (ch == 0)
+ ch = ACS_HLINE;
+ while ( end >= start) {
+ win->_line[line][end] = ch | win->_attrs;
+ end--;
+ }
+
+ return OK;
+}
+
+int wvline(WINDOW *win, chtype ch, int n)
+{
+int row, col;
+int end;
+
+ T(("wvline(%x,%x,%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][col] = ch | win->_attrs;
+ if (win->_firstchar[end] == _NOCHANGE || win->_firstchar[end] > col)
+ win->_firstchar[end] = col;
+ if (win->_lastchar[end] == _NOCHANGE || win->_lastchar[end] < col)
+ win->_lastchar[end] = col;
+ end--;
+ }
+
+ return OK;
+}
+
diff --git a/lib/libncurses/lib_clear.c b/lib/libncurses/lib_clear.c
new file mode 100644
index 0000000..c82db9b
--- /dev/null
+++ b/lib/libncurses/lib_clear.c
@@ -0,0 +1,24 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_clear.c
+**
+** The routine wclear().
+**
+*/
+
+#include "curses.priv.h"
+
+int wclear(WINDOW *win)
+{
+ T(("wclear(%x) called", win));
+
+ werase(win);
+
+ win->_clear = TRUE;
+
+ return OK;
+}
diff --git a/lib/libncurses/lib_clrbot.c b/lib/libncurses/lib_clrbot.c
new file mode 100644
index 0000000..fa48db8
--- /dev/null
+++ b/lib/libncurses/lib_clrbot.c
@@ -0,0 +1,53 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_clrbot.c
+**
+** The routine wclrtobot().
+**
+*/
+
+#include "curses.priv.h"
+
+#define BLANK ' '|A_NORMAL
+
+int wclrtobot(WINDOW *win)
+{
+chtype *ptr, *end, *maxx = NULL;
+int y, startx, minx;
+
+ T(("wclrtobot(%x) called", win));
+
+ startx = win->_curx;
+
+ 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][win->_maxx];
+
+ for (ptr = &win->_line[y][startx]; ptr <= end; ptr++) {
+ if (*ptr != BLANK) {
+ maxx = ptr;
+ if (minx == _NOCHANGE)
+ minx = ptr - win->_line[y];
+ *ptr = BLANK;
+ }
+ }
+
+ if (minx != _NOCHANGE) {
+ if (win->_firstchar[y] > minx
+ || win->_firstchar[y] == _NOCHANGE)
+ win->_firstchar[y] = minx;
+
+ if (win->_lastchar[y] < maxx - win->_line[y])
+ win->_lastchar[y] = maxx - win->_line[y];
+ }
+
+ startx = 0;
+ }
+ return OK;
+}
diff --git a/lib/libncurses/lib_clreol.c b/lib/libncurses/lib_clreol.c
new file mode 100644
index 0000000..a22d6b2
--- /dev/null
+++ b/lib/libncurses/lib_clreol.c
@@ -0,0 +1,48 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_clreol.c
+**
+** The routine wclrtoeol().
+**
+*/
+
+#include "curses.priv.h"
+
+#define BLANK ' '|A_NORMAL
+
+int wclrtoeol(WINDOW *win)
+{
+chtype *maxx, *ptr, *end;
+int y, x, minx;
+
+ T(("wclrtoeol(%x) called", win));
+
+ y = win->_cury;
+ x = win->_curx;
+
+ end = &win->_line[y][win->_maxx];
+ minx = _NOCHANGE;
+ maxx = &win->_line[y][x];
+
+ for (ptr = maxx; ptr <= end; ptr++) {
+ if (*ptr != BLANK) {
+ maxx = ptr;
+ if (minx == _NOCHANGE)
+ minx = ptr - win->_line[y];
+ *ptr = BLANK;
+ }
+ }
+
+ if (minx != _NOCHANGE) {
+ if (win->_firstchar[y] > minx || win->_firstchar[y] == _NOCHANGE)
+ win->_firstchar[y] = minx;
+
+ if (win->_lastchar[y] < maxx - win->_line[y])
+ win->_lastchar[y] = maxx - win->_line[y];
+ }
+ return(OK);
+}
diff --git a/lib/libncurses/lib_color.c b/lib/libncurses/lib_color.c
new file mode 100644
index 0000000..8ba3ad9
--- /dev/null
+++ b/lib/libncurses/lib_color.c
@@ -0,0 +1,107 @@
+/* This work is copyrighted. See COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/* lib_color.c
+ *
+ * Handles color emulation of SYS V curses
+ *
+ */
+
+#include "curses.priv.h"
+#include <nterm.h>
+
+int COLOR_PAIRS;
+int COLORS;
+unsigned char color_pairs[64];
+
+int _coloron = 0;
+
+int start_color()
+{
+ T(("start_color() called."));
+
+ if (orig_pair != NULL)
+ tputs(orig_pair, 1, _outc);
+ else return ERR;
+ if (max_pairs != -1)
+ COLOR_PAIRS = max_pairs;
+ else return ERR;
+ if (max_colors != -1)
+ COLORS = max_colors;
+ else return ERR;
+ _coloron = 1;
+
+ T(("started color: COLORS = %d, COLOR_PAIRS = %d", COLORS, COLOR_PAIRS));
+
+ return OK;
+}
+
+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;
+
+ /* still to do:
+ 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 );
+
+ return color_pairs[pair];
+}
+
+int init_color(short color, short r, short g, short b)
+{
+ if (initialize_color != NULL) {
+ if (color < 0 || color >= COLORS)
+ return ERR;
+ 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)
+ if (r < 0 || r > 1000 || g < 0 || g > 1000 || b < 0 || b > 1000)
+ return ERR;
+
+ tputs(tparm(initialize_color, color, r, g, b), 1, _outc);
+ return OK;
+ }
+
+ return ERR;
+}
+
+bool can_change_color()
+{
+ return can_change;
+}
+
+int has_colors()
+{
+ return ((orig_pair != NULL) && (max_colors != -1) && (max_pairs != -1)
+ &&
+ (((set_foreground != NULL) && (set_background != NULL)) ||
+ ((set_a_foreground != NULL) && (set_a_background != NULL)))
+ );
+}
+
+int color_content(short color, short *r, short *g, short *b)
+{
+ return ERR;
+}
+
+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;
+}
+
diff --git a/lib/libncurses/lib_delch.c b/lib/libncurses/lib_delch.c
new file mode 100644
index 0000000..5c62acb
--- /dev/null
+++ b/lib/libncurses/lib_delch.c
@@ -0,0 +1,38 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_delch.c
+**
+** The routine wdelch().
+**
+*/
+
+#include "curses.priv.h"
+#include <nterm.h>
+
+int wdelch(WINDOW *win)
+{
+chtype *temp1, *temp2;
+chtype *end;
+
+ T(("wdelch(%x) called", win));
+
+ end = &win->_line[win->_cury][win->_maxx];
+ temp2 = &win->_line[win->_cury][win->_curx + 1];
+ temp1 = temp2 - 1;
+
+ while (temp1 < end)
+ *temp1++ = *temp2++;
+
+ *temp1 = ' ' | win->_attrs;
+
+ win->_lastchar[win->_cury] = win->_maxx;
+
+ if (win->_firstchar[win->_cury] == _NOCHANGE
+ || win->_firstchar[win->_cury] > win->_curx)
+ win->_firstchar[win->_cury] = win->_curx;
+ return OK;
+}
diff --git a/lib/libncurses/lib_deleteln.c b/lib/libncurses/lib_deleteln.c
new file mode 100644
index 0000000..d218eb4
--- /dev/null
+++ b/lib/libncurses/lib_deleteln.c
@@ -0,0 +1,48 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_deleteln.c
+**
+** The routine wdeleteln().
+**
+*/
+
+#include "curses.priv.h"
+#include <nterm.h>
+
+int wdeleteln(WINDOW *win)
+{
+chtype *end, *temp;
+int y, touched = 0;
+
+ T(("wdeleteln(%x) called", win));
+
+ temp = win->_line[win->_cury];
+
+ if (win->_idlok && (delete_line != NULL)) {
+ putp(delete_line);
+ touched = 1;
+ }
+
+ for (y = win->_cury; y < win->_regbottom; y++) {
+ win->_line[y] = win->_line[y+1];
+
+ if (!touched) {
+ win->_firstchar[y] = 0;
+ win->_lastchar[y] = win->_maxx;
+ }
+ }
+
+ win->_line[win->_regbottom] = temp;
+ if (!touched) {
+ win->_firstchar[win->_regbottom] = 0;
+ win->_lastchar[win->_regbottom] = win->_maxx;
+ }
+
+ for (end = &(temp[win->_maxx]); temp <= end; )
+ *temp++ = ' ' | win->_attrs;
+ return OK;
+}
diff --git a/lib/libncurses/lib_delwin.c b/lib/libncurses/lib_delwin.c
new file mode 100644
index 0000000..e84e216
--- /dev/null
+++ b/lib/libncurses/lib_delwin.c
@@ -0,0 +1,35 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_delwin.c
+**
+** The routine delwin().
+**
+*/
+
+#include <stdlib.h>
+#include "curses.priv.h"
+
+int delwin(WINDOW *win)
+{
+int i;
+
+ T(("delwin(%x) called", win));
+
+ if (! (win->_flags & _SUBWIN)) {
+ for (i = 0; i < win->_maxy && win->_line[i]; i++)
+ free(win->_line[i]);
+ }
+
+ free(win->_firstchar);
+ free(win->_lastchar);
+ free(win->_line);
+ free(win);
+
+ touchwin(curscr);
+
+ return(OK);
+}
diff --git a/lib/libncurses/lib_doupdate.c b/lib/libncurses/lib_doupdate.c
new file mode 100644
index 0000000..f85d099
--- /dev/null
+++ b/lib/libncurses/lib_doupdate.c
@@ -0,0 +1,527 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*-----------------------------------------------------------------
+ *
+ * lib_doupdate.c
+ *
+ * The routine doupdate() and its dependents
+ *
+ *-----------------------------------------------------------------*/
+
+#include <stdlib.h>
+#include <string.h>
+#include "curses.priv.h"
+#include <nterm.h>
+#ifdef SVR4_ACTION
+#define _POSIX_SOURCE
+#endif
+#include <signal.h>
+
+static void ClrUpdate( WINDOW *scr );
+static void TransformLine( int lineno );
+static void NoIDcTransformLine( int lineno );
+static void IDcTransformLine( int lineno );
+static void ClearScreen( void );
+static void InsStr( chtype *line, int count );
+static void DelChar( int count );
+
+static inline void PutAttrChar(chtype ch)
+{
+ if (curscr->_attrs != (ch & (chtype)A_ATTRIBUTES)) {
+ curscr->_attrs = ch & (chtype)A_ATTRIBUTES;
+ vidputs(curscr->_attrs, _outc);
+ }
+ putc(ch & A_CHARTEXT, SP->_ofp);
+}
+
+static int LRCORNER = FALSE;
+
+static inline void PutChar(chtype ch)
+{
+ T(("puttin %x", ch));
+ if (LRCORNER == TRUE) {
+ if (SP->_curscol == columns-2) {
+ PutAttrChar(newscr->_line[lines-1][columns-2]);
+ SP->_curscol++;
+ return;
+ } else if (SP->_curscol == columns-1) {
+ int i = lines;
+ int j = columns -1;
+ if (cursor_left)
+ tputs(cursor_left, 1, _outc);
+ else
+ mvcur(-1, -1, i-1, j);
+ if (enter_insert_mode && exit_insert_mode) {
+ tputs(enter_insert_mode, 1, _outc);
+ PutAttrChar(newscr->_line[i-1][j]);
+ tputs(exit_insert_mode, 1, _outc);
+ } else if (insert_character) {
+ tputs(insert_character, 1, _outc);
+ PutAttrChar(newscr->_line[i-1][j]);
+ }
+ return;
+ }
+ }
+ PutAttrChar(ch);
+ SP->_curscol++;
+ if (SP->_curscol >= columns) {
+ if (auto_right_margin) {
+ SP->_curscol = 0;
+ SP->_cursrow++;
+ } else {
+ SP->_curscol--;
+ }
+ }
+}
+
+static inline void GoTo(int row, int col)
+{
+ mvcur(SP->_cursrow, SP->_curscol, row, col);
+ SP->_cursrow = row;
+ SP->_curscol = col;
+}
+
+int _outc(char ch)
+{
+ putc(ch, SP->_ofp);
+ return OK;
+}
+
+int doupdate(void)
+{
+int i;
+sigaction_t act, oact;
+
+ T(("doupdate() called"));
+
+ act.sa_handler = SIG_IGN;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+ sigaction(SIGTSTP, &act, &oact);
+
+ if (_isendwin == 1) {
+ T(("coming back from shell mode"));
+ reset_prog_mode();
+ /* is this necessary? */
+ if (enter_alt_charset_mode)
+ init_acs();
+ newscr->_clear = TRUE;
+ _isendwin = 0;
+ }
+
+ 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 {
+ T(("Transforming lines"));
+ for (i = 0; i < lines ; i++) {
+ if(newscr->_firstchar[i] != _NOCHANGE)
+ TransformLine(i);
+ }
+ }
+ }
+ T(("marking screen as updated"));
+ for (i = 0; i < lines; i++) {
+ newscr->_firstchar[i] = _NOCHANGE;
+ newscr->_lastchar[i] = _NOCHANGE;
+ }
+
+ curscr->_curx = newscr->_curx;
+ curscr->_cury = newscr->_cury;
+
+ GoTo(curscr->_cury, curscr->_curx);
+
+ /* perhaps we should turn attributes off here */
+
+ if (!(curscr->_attrs & A_NORMAL))
+ vidattr(curscr->_attrs = A_NORMAL);
+
+ fflush(SP->_ofp);
+
+ sigaction(SIGTSTP, &oact, NULL);
+
+ return OK;
+}
+
+static int move_right_cost = -1;
+
+static int countc(char c)
+{
+ return(move_right_cost++);
+}
+
+/*
+** ClrUpdate(scr)
+**
+** Update by clearing and redrawing the entire screen.
+**
+*/
+
+#define BLANK ' '|A_NORMAL
+
+static void ClrUpdate(WINDOW *scr)
+{
+int i = 0, j = 0;
+int lastNonBlank;
+
+ T(("ClrUpdate(%x) called", scr));
+ if (back_color_erase) {
+ T(("back_color_erase, turning attributes off"));
+ vidattr(A_NORMAL);
+ }
+ ClearScreen();
+
+ if ((move_right_cost == -1) && parm_right_cursor) {
+ move_right_cost = 0;
+ tputs(tparm(parm_right_cursor, 10), 1, countc);
+ }
+
+ T(("updating screen from scratch"));
+ for (i = 0; i < lines; i++) {
+ LRCORNER = FALSE;
+ lastNonBlank = columns - 1;
+
+ while (scr->_line[i][lastNonBlank] == BLANK )
+ lastNonBlank--;
+
+ T(("updating line %d upto %d", i, lastNonBlank));
+
+ /* check if we are at the lr corner */
+ if (i == lines-1)
+ if ((auto_right_margin) && !(eat_newline_glitch) &&
+ (lastNonBlank == columns-1) && !(scr->_scroll))
+ {
+ T(("Lower-right corner needs special handling"));
+ LRCORNER = TRUE;
+ }
+
+ for (j = 0; j <= lastNonBlank; j++) {
+ if (parm_right_cursor) {
+ static int inspace = 0;
+
+ T(("trying to use parm_right_cursor"));
+ if ((scr->_line[i][j]) == BLANK) {
+ inspace++;
+ continue;
+ } else if(inspace) {
+ if (inspace < move_right_cost) {
+ for (; inspace > 0; inspace--)
+ PutChar(scr->_line[i][j-1]);
+ } else {
+ tputs(tparm(parm_right_cursor, inspace), 1, _outc);
+ }
+ inspace = 0;
+ }
+ }
+ PutChar(scr->_line[i][j]);
+ }
+ /* move cursor to the next line */
+ if ((!auto_right_margin) || (lastNonBlank < columns - 1) ||
+ (auto_right_margin && eat_newline_glitch && lastNonBlank == columns-1))
+ {
+ SP->_curscol = (lastNonBlank < 0) ? 0 : lastNonBlank;
+ SP->_cursrow++;
+ GoTo(i+1, 0);
+ }
+ }
+
+
+ if (scr != curscr) {
+ for (i = 0; i < lines ; i++)
+ for (j = 0; j < columns; j++)
+ curscr->_line[i][j] = scr->_line[i][j];
+ }
+}
+
+/*
+** TransformLine(lineno)
+**
+** Call either IDcTransformLine or NoIDcTransformLine to do the
+** update, depending upon availability of insert/delete character.
+*/
+
+static void TransformLine(int 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 lineno)
+{
+int firstChar, lastChar;
+chtype *newLine = newscr->_line[lineno];
+chtype *oldLine = curscr->_line[lineno];
+int k;
+int attrchanged = 0;
+
+ T(("NoIDcTransformLine(%d) called", lineno));
+
+ firstChar = 0;
+ while (firstChar < columns - 1 && newLine[firstChar] == oldLine[firstChar]) {
+ if(ceol_standout_glitch) {
+ if((newLine[firstChar] & (chtype)A_ATTRIBUTES) != (oldLine[firstChar] & (chtype)A_ATTRIBUTES))
+ attrchanged = 1;
+ }
+ firstChar++;
+ }
+
+ T(("first char at %d is %x", firstChar, newLine[firstChar]));
+ if (firstChar > columns)
+ return;
+
+ if(ceol_standout_glitch && attrchanged) {
+ firstChar = 0;
+ lastChar = columns - 1;
+ GoTo(lineno, firstChar);
+ if(clr_eol) {
+ if (back_color_erase) {
+ T(("back_color_erase, turning attributes off"));
+ vidattr(A_NORMAL);
+ }
+ tputs(clr_eol, 1, _outc);
+ }
+ } else {
+ lastChar = columns - 1;
+ while (lastChar > firstChar && newLine[lastChar] == oldLine[lastChar])
+ lastChar--;
+ GoTo(lineno, firstChar);
+ }
+
+ /* check if we are at the lr corner */
+ if (lineno == lines-1)
+ if ((auto_right_margin) && !(eat_newline_glitch) &&
+ (lastChar == columns-1) && !(curscr->_scroll))
+ {
+ T(("Lower-right corner needs special handling"));
+ LRCORNER = TRUE;
+ }
+
+ 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 lineno)
+{
+int firstChar, oLastChar, nLastChar;
+chtype *newLine = newscr->_line[lineno];
+chtype *oldLine = curscr->_line[lineno];
+int k, n;
+int attrchanged = 0;
+
+ T(("IDcTransformLine(%d) called", lineno));
+
+ if(ceol_standout_glitch && clr_eol) {
+ firstChar = 0;
+ while(firstChar < columns) {
+ if((newLine[firstChar] & (chtype)A_ATTRIBUTES) != (oldLine[firstChar] & (chtype)A_ATTRIBUTES))
+ attrchanged = 1;
+ firstChar++;
+ }
+ }
+
+ firstChar = 0;
+
+ if (attrchanged) {
+ GoTo(lineno, firstChar);
+ if (back_color_erase) {
+ T(("back_color_erase, turning attributes off"));
+ vidattr(A_NORMAL);
+ }
+ tputs(clr_eol, 1, _outc);
+ for( k = 0 ; k <= (columns-1) ; k++ )
+ PutChar(newLine[k]);
+ } else {
+ while (firstChar < columns &&
+ newLine[firstChar] == oldLine[firstChar])
+ firstChar++;
+
+ if (firstChar >= columns)
+ return;
+
+ oLastChar = columns - 1;
+ while (oLastChar > firstChar && oldLine[oLastChar] == ' ')
+ oLastChar--;
+
+ nLastChar = columns - 1;
+ while (nLastChar > firstChar && newLine[nLastChar] == ' ')
+ nLastChar--;
+
+ if((nLastChar == firstChar) && clr_eol) {
+ GoTo(lineno, firstChar);
+ if (back_color_erase) {
+ T(("back_color_erase, turning attributes off"));
+ vidattr(A_NORMAL);
+ }
+ tputs(clr_eol,1,_outc);
+ if(newLine[firstChar] != ' ' )
+ 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]) {
+ nLastChar--;
+ oLastChar--;
+ }
+
+ 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 )
+ DelChar(oLastChar - nLastChar);
+ }
+ }
+ for (k = firstChar; k < columns; k++)
+ oldLine[k] = newLine[k];
+}
+
+/*
+** ClearScreen()
+**
+** Clear the physical screen and put cursor at home
+**
+*/
+
+static void ClearScreen()
+{
+
+ T(("ClearScreen() called"));
+
+ if (clear_screen) {
+ tputs(clear_screen, 1, _outc);
+ SP->_cursrow = SP->_curscol = 0;
+ } else if (clr_eos) {
+ SP->_cursrow = SP->_curscol = -1;
+ GoTo(0,0);
+
+ tputs(clr_eos, 1, _outc);
+ } else if (clr_eol) {
+ SP->_cursrow = SP->_curscol = -1;
+
+ while (SP->_cursrow < lines) {
+ GoTo(SP->_cursrow, 0);
+ tputs(clr_eol, 1, _outc);
+ }
+ GoTo(0,0);
+ }
+ T(("screen cleared"));
+}
+
+
+/*
+** InsStr(line, count)
+**
+** Insert the count characters pointed to by line.
+**
+*/
+
+static void InsStr(chtype *line, int count)
+{
+ T(("InsStr(%x,%d) called", line, count));
+
+ if (enter_insert_mode && exit_insert_mode) {
+ tputs(enter_insert_mode, 1, _outc);
+ while (count) {
+ PutChar(*line);
+ line++;
+ count--;
+ }
+ tputs(exit_insert_mode, 1, _outc);
+ } else if (parm_ich) {
+ tputs(tparm(parm_ich, count), 1, _outc);
+ while (count) {
+ PutChar(*line);
+ line++;
+ count--;
+ }
+ } else {
+ while (count) {
+ tputs(insert_character, 1, _outc);
+ PutChar(*line);
+ line++;
+ count--;
+ }
+ }
+}
+
+/*
+** DelChar(count)
+**
+** Delete count characters at current position
+**
+*/
+
+static void DelChar(int count)
+{
+ T(("DelChar(%d) called", count));
+
+ if (parm_dch) {
+ tputs(tparm(parm_dch, count), 1, _outc);
+ } else {
+ while (count--)
+ tputs(delete_character, 1, _outc);
+ }
+}
+
diff --git a/lib/libncurses/lib_endwin.c b/lib/libncurses/lib_endwin.c
new file mode 100644
index 0000000..b32af2d
--- /dev/null
+++ b/lib/libncurses/lib_endwin.c
@@ -0,0 +1,44 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_endwin.c
+**
+** The routine endwin().
+**
+*/
+
+#include <nterm.h>
+#include "curses.priv.h"
+
+int _isendwin;
+
+int isendwin()
+{
+ return _isendwin;
+}
+
+int
+endwin()
+{
+ T(("endwin() called"));
+
+ _isendwin = 1;
+
+ mvcur(-1, -1, lines - 1, 0);
+
+ if (exit_ca_mode)
+ tputs(exit_ca_mode, 1, _outc);
+
+ if (_coloron == 1)
+ tputs(orig_pair, 1, _outc);
+
+ if (curscr && (curscr->_attrs != A_NORMAL))
+ vidattr(curscr->_attrs = A_NORMAL);
+
+ fflush(SP->_ofp);
+
+ return(reset_shell_mode());
+}
diff --git a/lib/libncurses/lib_erase.c b/lib/libncurses/lib_erase.c
new file mode 100644
index 0000000..221a04c
--- /dev/null
+++ b/lib/libncurses/lib_erase.c
@@ -0,0 +1,50 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_erase.c
+**
+** The routine werase().
+**
+*/
+
+#include "curses.priv.h"
+#include <nterm.h>
+
+#define BLANK ' '
+
+int werase(WINDOW *win)
+{
+int y;
+chtype *sp, *end, *start, *maxx = NULL;
+int minx;
+
+ T(("werase(%x) called", win));
+
+ for (y = win->_regtop; y <= win->_regbottom; y++) {
+ minx = _NOCHANGE;
+ start = win->_line[y];
+ end = &start[win->_maxx];
+
+ maxx = start;
+ for (sp = start; sp <= end; sp++) {
+ maxx = sp;
+ if (minx == _NOCHANGE)
+ minx = sp - start;
+ *sp = BLANK;
+ }
+
+ if (minx != _NOCHANGE) {
+ if (win->_firstchar[y] > minx ||
+ win->_firstchar[y] == _NOCHANGE)
+ win->_firstchar[y] = minx;
+
+ if (win->_lastchar[y] < maxx - win->_line[y])
+ win->_lastchar[y] = maxx - win->_line[y];
+ }
+ }
+ win->_curx = win->_cury = 0;
+ return OK;
+}
diff --git a/lib/libncurses/lib_getch.c b/lib/libncurses/lib_getch.c
new file mode 100644
index 0000000..47192c2
--- /dev/null
+++ b/lib/libncurses/lib_getch.c
@@ -0,0 +1,217 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_getch.c
+**
+** The routine getch().
+**
+*/
+
+#include <sys/types.h>
+#include <string.h>
+#include <signal.h>
+#include <errno.h>
+#ifdef BRAINDEAD
+extern int errno;
+#endif
+#include "curses.priv.h"
+
+#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++;}
+
+static int fifo_peek()
+{
+ T(("peeking at %d", peek+1));
+ return SP->_fifo[++peek];
+}
+
+static inline void fifo_dump()
+{
+int i;
+ T(("head = %d, tail = %d, peek = %d", head, tail, peek));
+ for (i = 0; i < 10; i++)
+ T(("char %d = %d (%c)", i, SP->_fifo[i], (unsigned char)SP->_fifo[i]));
+}
+
+static inline int fifo_pull()
+{
+int ch;
+ ch = SP->_fifo[head];
+ T(("pulling %d from %d", ch, head));
+
+ h_inc();
+ fifo_dump();
+ 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"));
+ fifo_dump();
+ return OK;
+}
+
+static inline int fifo_push()
+{
+int n;
+unsigned char ch;
+
+ if (tail == -1) return ERR;
+again:
+ n = read(fileno(SP->_ifp), &ch, 1);
+ if (n == -1 && errno == EINTR)
+ goto again;
+ SP->_fifo[tail] = ch;
+ if (head == -1) head = tail;
+ t_inc();
+ T(("pushed %d at %d", ch, tail));
+ fifo_dump();
+ return ch;
+}
+
+static inline void fifo_clear()
+{
+int i;
+ for (i = 0; i < FIFO_SIZE; i++)
+ SP->_fifo[i] = 0;
+ head = -1; tail = peek = 0;
+}
+
+static int kgetch(WINDOW *);
+
+int
+wgetch(WINDOW *win)
+{
+bool setHere = FALSE; /* cbreak mode was set here */
+int ch;
+
+ T(("wgetch(%x) 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->_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 (timed_wait(fileno(SP->_ifp), delay, NULL) == 0)
+ return ERR;
+ /* else go on to read data available */
+ }
+
+ if (win->_use_keypad)
+ ch = kgetch(win);
+ else {
+ fifo_push();
+ ch = fifo_pull();
+ }
+
+ /* there must be a simpler way of doing this */
+ if (!(win->_flags & _ISPAD) &&
+ SP->_echo && ch < 0400) { /* ch < 0400 => not a keypad key */
+ mvwaddch(curscr, win->_begy + win->_cury,
+ win->_begx + win->_curx, ch | win->_attrs);
+ waddch(win, ch | win->_attrs);
+ }
+ if (setHere)
+ nocbreak();
+
+ T(("wgetch returning : '%c', '0x%x'", ch, 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 a one-second alarm call. 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 = 2000;
+
+ T(("kgetch(%x) called", win));
+
+ ptr = SP->_keytry;
+
+ if (head == -1) {
+ ch = fifo_push();
+ peek = 0;
+ while (ptr != NULL) {
+ T(("ch = %d", ch));
+ while ((ptr != NULL) && (ptr->ch != (unsigned char)ch))
+ ptr = ptr->sibling;
+
+ if (ptr != NULL)
+ if (ptr->value != 0) { /* sequence terminated */
+ T(("end of sequence"));
+ fifo_clear();
+ return(ptr->value);
+ } else { /* go back for another character */
+ ptr = ptr->child;
+ T(("going back for more"));
+ }
+ else
+ break;
+
+ T(("waiting for rest of sequence"));
+ if (timed_wait(fileno(SP->_ifp), timeleft, &timeleft) < 1) {
+ T(("ran out of time"));
+ return(fifo_pull());
+ } else {
+ T(("got more!"));
+ fifo_push();
+ ch = fifo_peek();
+ }
+ }
+ }
+ return(fifo_pull());
+}
diff --git a/lib/libncurses/lib_getstr.c b/lib/libncurses/lib_getstr.c
new file mode 100644
index 0000000..fae5b21
--- /dev/null
+++ b/lib/libncurses/lib_getstr.c
@@ -0,0 +1,113 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_getstr.c
+**
+** The routine wgetstr().
+**
+*/
+
+#include "curses.priv.h"
+#include "unctrl.h"
+
+inline void backspace(WINDOW *win)
+{
+ mvwaddstr(curscr, win->_begy + win->_cury, win->_begx + win->_curx,
+ "\b \b");
+ waddstr(win, "\b \b");
+ fputs("\b \b", SP->_ofp);
+ fflush(SP->_ofp);
+ SP->_curscol--;
+}
+
+int wgetnstr(WINDOW *win, char *str, int maxlen)
+{
+bool oldnl, oldecho, oldraw, oldcbreak, oldkeypad;
+char erasec;
+char killc;
+char *oldstr;
+int ch;
+
+ T(("wgetnstr(%x,%x, %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, FALSE);
+
+ erasec = erasechar();
+ killc = killchar();
+
+ oldstr = str;
+
+ vidattr(win->_attrs);
+ if (is_wintouched(win) || (win->_flags & _HASMOVED))
+ wrefresh(win);
+
+ while ((ch = wgetch(win)) != ERR) {
+ if (ch == '\n' || ch == '\r')
+ break;
+ if (ch == erasec || ch == KEY_LEFT || ch == KEY_BACKSPACE) {
+ if (str > oldstr) {
+ str--;
+ backspace(win);
+ }
+ } else if (ch == killc) {
+ while (str > oldstr) {
+ str--;
+ backspace(win);
+ }
+ } else if (maxlen >= 0 && str - oldstr >= maxlen) {
+ beep();
+ } else {
+ mvwaddstr(curscr, win->_begy + win->_cury,
+ win->_begx + win->_curx, unctrl(ch));
+ waddstr(win, unctrl(ch));
+ if (oldecho == TRUE) {
+ fputs(unctrl(ch), SP->_ofp);
+ fflush(SP->_ofp);
+ }
+ SP->_curscol++;
+ *str++ = ch;
+ }
+ }
+
+ win->_curx = 0;
+ if (win->_cury < win->_maxy)
+ win->_cury++;
+ wrefresh(win);
+
+ if (! oldnl)
+ nonl();
+
+ if (oldecho)
+ echo();
+
+ if (oldraw)
+ raw();
+
+ if (! oldcbreak)
+ nocbreak();
+
+ if (oldkeypad)
+ keypad(win, TRUE);
+
+ if (ch == ERR) {
+ *str = '\0';
+ return ERR;
+ }
+ *str = '\0';
+
+ T(("wgetnstr returns %s", oldstr));
+
+ return(OK);
+}
diff --git a/lib/libncurses/lib_inchstr.c b/lib/libncurses/lib_inchstr.c
new file mode 100644
index 0000000..d0ad351
--- /dev/null
+++ b/lib/libncurses/lib_inchstr.c
@@ -0,0 +1,29 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_inchstr.c
+**
+** The routine winchnstr().
+**
+*/
+
+#include "curses.priv.h"
+
+int winchnstr(WINDOW *win, chtype *chstr, int i)
+{
+chtype *point, *end;
+
+ T(("winschnstr(%x,'%x',%d) called", win, chstr, i));
+
+ point = &win->_line[win->_cury][win->_curx];
+ end = &win->_line[win->_cury][win->_maxx];
+ if (point + i - 1 < end)
+ end = point + i - 1;
+
+ chstr = (chtype *)malloc((end - point + 1)*sizeof(chtype));
+ chstr[end - point] = '\0';
+ return OK;
+}
diff --git a/lib/libncurses/lib_initscr.c b/lib/libncurses/lib_initscr.c
new file mode 100644
index 0000000..a81783f
--- /dev/null
+++ b/lib/libncurses/lib_initscr.c
@@ -0,0 +1,32 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_initscr.c
+**
+** The routine initscr().
+**
+*/
+
+#include <stdlib.h>
+#include "curses.priv.h"
+
+WINDOW *initscr()
+{
+#ifdef TRACE
+ _init_trace();
+
+ if (_tracing)
+ _tracef("initscr() called");
+#endif
+
+ if (newterm(getenv("TERM"), stdout, stdin) == NULL)
+ return NULL;
+ else {
+ def_shell_mode();
+ def_prog_mode();
+ return(stdscr);
+ }
+}
diff --git a/lib/libncurses/lib_insch.c b/lib/libncurses/lib_insch.c
new file mode 100644
index 0000000..a86732d
--- /dev/null
+++ b/lib/libncurses/lib_insch.c
@@ -0,0 +1,36 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_insch.c
+**
+** The routine winsch().
+**
+*/
+
+#include "curses.priv.h"
+
+int winsch(WINDOW *win, chtype c)
+{
+chtype *temp1, *temp2;
+chtype *end;
+
+ T(("winsch(%x,'%x') called", win, c));
+
+ end = &win->_line[win->_cury][win->_curx];
+ temp1 = &win->_line[win->_cury][win->_maxx];
+ temp2 = temp1 - 1;
+
+ while (temp1 > end)
+ *temp1-- = *temp2--;
+
+ *temp1 = c | win->_attrs;
+
+ win->_lastchar[win->_cury] = win->_maxx;
+ if (win->_firstchar[win->_cury] == _NOCHANGE
+ || win->_firstchar[win->_cury] > win->_curx)
+ win->_firstchar[win->_cury] = win->_curx;
+ return OK;
+}
diff --git a/lib/libncurses/lib_insdel.c b/lib/libncurses/lib_insdel.c
new file mode 100644
index 0000000..df68f87
--- /dev/null
+++ b/lib/libncurses/lib_insdel.c
@@ -0,0 +1,120 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_insdel.c
+**
+** The routine winsdel(win, n).
+** positive n insert n lines above current line
+** negative n delete n lines starting from current line
+**
+*/
+
+#include <stdlib.h>
+#include "curses.priv.h"
+#include <nterm.h>
+
+int
+winsdel(WINDOW *win, int n)
+{
+int line, i;
+int touched = 0;
+chtype *ptr, *temp;
+chtype **saved;
+chtype blank = ' ';
+
+ T(("winsdel(%x,%d) called", win, n));
+
+ if (n == 0)
+ return OK;
+ if (n < 0 && win->_cury - n >= win->_maxy)
+ /* request to delete too many lines */
+ /* should we truncate to an appropriate number? */
+ return ERR;
+
+
+ saved = (chtype **)malloc(sizeof(chtype *) * abs(n));
+
+ if (n < 0) {
+ /* save overwritten lines */
+
+ for (i = 0; i < -n; i++)
+ saved[i] = win->_line[win->_regbottom-i];
+
+ /* delete n lines */
+
+ for (line = win->_regbottom; line >= win->_cury; line--)
+ win->_line[line] = win->_line[line+n];
+
+ /* restore saved lines and blank them */
+
+ for (i = 0, line = win->_regtop; line < win->_regtop-n; line++, i++) {
+ win->_line[line] = saved[i];
+ temp = win->_line[line];
+ for (ptr = temp; ptr - temp <= win->_maxx; ptr++)
+ *ptr = blank;
+ }
+ }
+
+ if (n > 0) {
+ /* save overwritten lines */
+
+ for (i = 0; i < n; i++)
+ saved[i] = win->_line[win->_regtop+i];
+
+ /* insert n lines */
+
+ for (line = win->_regtop; line < win->_regtop + n; line++)
+ win->_line[line] = win->_line[line+n];
+
+ /* restore saved lines and blank them */
+
+ for (i = 0, line = win->_regtop + n; i < n; line--, i++) {
+ temp = win->_line[line] = saved[i];
+ for (ptr = temp; ptr - temp <= win->_maxx; ptr++)
+ *ptr = blank;
+ }
+ }
+
+ free(saved);
+
+ /* as an optimization, if the window is COLS wide we can try
+ using idl assuming _idlok is true */
+
+ if (win->_maxx == columns && win->_idlok == TRUE) {
+
+ if (n > 0) {
+ mvcur(-1, -1, win->_cury, 0);
+ if (parm_insert_line) {
+ putp(tparm(parm_insert_line, n));
+ touched = 1;
+ } else if (insert_line) {
+ while (n--)
+ putp(insert_line);
+ touched = 1;
+ }
+ }
+
+ if (n < 0) {
+ mvcur(-1, -1, win->_cury, 0);
+ n = abs(n);
+ if (parm_delete_line) {
+ putp(tparm(parm_delete_line, n));
+ touched = 1;
+ } else if (delete_line) {
+ while (n--)
+ putp(delete_line);
+ touched = 1;
+ }
+ }
+
+ mvcur(-1, -1, win->_cury, win->_curx);
+ }
+ if (touched == 0)
+ touchline(win, win->_regtop, win->_regbottom - win->_regtop + 1);
+ touched = 0;
+
+ return OK;
+}
diff --git a/lib/libncurses/lib_insertln.c b/lib/libncurses/lib_insertln.c
new file mode 100644
index 0000000..7a5694e
--- /dev/null
+++ b/lib/libncurses/lib_insertln.c
@@ -0,0 +1,49 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_insertln.c
+**
+** The routine winsertln().
+**
+*/
+
+#include "curses.priv.h"
+#include <nterm.h>
+
+int winsertln(WINDOW *win)
+{
+chtype *temp, *end;
+int y, touched = 0;
+
+ T(("winsertln(%x) called", win));
+
+ temp = win->_line[win->_regbottom];
+
+ if (win->_idlok && (insert_line != NULL)) {
+ putp(insert_line);
+ touched = 1;
+ }
+
+ if (!touched) {
+ win->_firstchar[win->_cury] = 0;
+ win->_lastchar[win->_cury] = win->_maxx;
+ }
+
+ for (y = win->_regbottom; y > win->_cury; y--) {
+ win->_line[y] = win->_line[y-1];
+
+ if (!touched) {
+ win->_firstchar[y] = 0;
+ win->_lastchar[y] = win->_maxx;
+ }
+ }
+
+ win->_line[win->_cury] = temp;
+
+ for (end = &temp[win->_maxx]; temp <= end; temp++)
+ *temp = ' ' | win->_attrs;
+ return OK;
+}
diff --git a/lib/libncurses/lib_insstr.c b/lib/libncurses/lib_insstr.c
new file mode 100644
index 0000000..6307662
--- /dev/null
+++ b/lib/libncurses/lib_insstr.c
@@ -0,0 +1,21 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_insstr.c
+**
+** The routine winsnstr().
+**
+*/
+
+#include "curses.priv.h"
+
+int winsnstr(WINDOW *win, char *str, int n)
+{
+
+ T(("winsstr(%x,'%x',%d) called", win, str, n));
+
+ return OK;
+}
diff --git a/lib/libncurses/lib_kernel.c b/lib/libncurses/lib_kernel.c
new file mode 100644
index 0000000..66659c7
--- /dev/null
+++ b/lib/libncurses/lib_kernel.c
@@ -0,0 +1,249 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+ * lib_kernel.c
+ *
+ * Misc. low-level routines:
+ * wattron()
+ * reset_prog_mode()
+ * reset_shell_mode()
+ * baudrate()
+ * erasechar()
+ * killchar()
+ * flushinp()
+ * savetty()
+ * resetty()
+ *
+ *
+ */
+
+#include "curses.priv.h"
+#include <nterm.h>
+
+int wattron(WINDOW *win, chtype at)
+{
+ win->_attrs &= (unsigned long)0xffff00ff;
+ win->_attrs |= at;
+ return OK;
+}
+
+#ifndef MYTINFO
+int reset_prog_mode()
+{
+ T(("reset_prog_mode() called"));
+
+#ifdef TERMIOS
+ tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Nttyb);
+#else
+ stty(cur_term->Filedes, &cur_term->Nttyb);
+#endif
+
+ return OK;
+}
+
+
+int reset_shell_mode()
+{
+ T(("reset_shell_mode() called"));
+
+#ifdef TERMIOS
+ tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Ottyb);
+#else
+ stty(cur_term->Filedes, &cur_term->Ottyb);
+#endif
+
+ return OK;
+}
+#endif
+
+int curs_set(int vis)
+{
+ T(("curs_set(%d)", vis));
+
+ if (vis < 0 || vis > 2)
+ return ERR;
+
+ switch(vis) {
+ case 2:
+ if (cursor_visible)
+ tputs(cursor_visible, 1, _outc);
+ break;
+ case 1:
+ if (cursor_normal)
+ tputs(cursor_normal, 1, _outc);
+ break;
+ case 0:
+ if (cursor_invisible)
+ tputs(cursor_invisible, 1, _outc);
+ break;
+ }
+ return OK;
+}
+
+/*
+ * erasechar()
+ *
+ * Return erase character as given in cur_term->Ottyb.
+ *
+ */
+
+char
+erasechar()
+{
+ 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()
+{
+ 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()
+{
+ T(("flushinp() called"));
+
+#ifdef TERMIOS
+ tcflush(cur_term->Filedes, TCIFLUSH);
+#else
+ ioctl(cur_term->Filedes, TIOCFLUSH, 0);
+#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 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,},
+#endif
+#ifdef B38400
+#undef MAX_BAUD
+#define MAX_BAUD B38400
+ {B38400, 38000,}
+#endif
+};
+
+int
+baudrate()
+{
+int i, ret;
+#ifdef UNTRACE
+ if (_tracing)
+ _tracef("baudrate() called");
+#endif
+#ifdef TERMIOS
+ ret = cfgetospeed(&cur_term->Nttyb);
+#else
+ ret = cur_term->Nttyb.sg_ospeed;
+#endif
+ if(ret < 0 || ret > MAX_BAUD)
+ return ERR;
+ for (i = 0; i < (sizeof(speeds) / sizeof(struct speed)); i++)
+ if (speeds[i].s == ret)
+ return speeds[i].sp;
+ return ERR;
+}
+
+
+/*
+** savetty() and resetty()
+**
+*/
+
+static TTY buf;
+
+int savetty()
+{
+ T(("savetty() called"));
+
+#ifdef TERMIOS
+ tcgetattr(cur_term->Filedes, &buf);
+#else
+ gtty(cur_term->Filedes, &buf);
+#endif
+ return OK;
+}
+
+int resetty()
+{
+ T(("resetty() called"));
+
+#ifdef TERMIOS
+ tcsetattr(cur_term->Filedes, TCSANOW, &buf);
+#else
+ stty(cur_term->Filedes, &buf);
+#endif
+ return OK;
+}
+
diff --git a/lib/libncurses/lib_longname.c b/lib/libncurses/lib_longname.c
new file mode 100644
index 0000000..528757b
--- /dev/null
+++ b/lib/libncurses/lib_longname.c
@@ -0,0 +1,35 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_longname.c
+**
+** The routine longname().
+**
+*/
+
+#include <string.h>
+#include "curses.priv.h"
+#include <nterm.h>
+
+char *
+longname()
+{
+#ifndef MYTINFO
+char *ptr;
+#endif
+
+ T(("longname() called"));
+
+#ifdef MYTINFO
+ return cur_term->name_long;
+#else
+ for (ptr = ttytype + strlen(ttytype); ptr > ttytype; ptr--)
+ if (*ptr == '|')
+ return(ptr + 1);
+
+ return(ttytype);
+#endif
+}
diff --git a/lib/libncurses/lib_move.c b/lib/libncurses/lib_move.c
new file mode 100644
index 0000000..e7a28eb
--- /dev/null
+++ b/lib/libncurses/lib_move.c
@@ -0,0 +1,33 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_move.c
+**
+** The routine wmove().
+**
+*/
+
+#include "curses.priv.h"
+
+int
+wmove(WINDOW *win, int y, int x)
+{
+#ifdef TRACE
+ if (_tracing)
+ _tracef("wmove(%x,%d,%d) called", win, y, x);
+#endif
+
+ if (x >= 0 && x <= win->_maxx &&
+ y >= 0 && y <= win->_maxy)
+ {
+ win->_curx = x;
+ win->_cury = y;
+
+ win->_flags |= _HASMOVED;
+ return(OK);
+ } else
+ return(ERR);
+}
diff --git a/lib/libncurses/lib_mvcur.c b/lib/libncurses/lib_mvcur.c
new file mode 100644
index 0000000..1a6ba65
--- /dev/null
+++ b/lib/libncurses/lib_mvcur.c
@@ -0,0 +1,719 @@
+/*---------------------------------------------------------------------------
+ *
+ * lib_mvcur.c
+ *
+ * The routine mvcur() etc.
+ *
+ * last edit-date: [Wed Jun 16 14:13:22 1993]
+ *
+ * -hm conversion from termcap -> terminfo
+ * -hm optimization debugging
+ * -hm zeyd's ncurses 0.7 update
+ * -hm eat_newline_glitch bugfix
+ * -hm hpux lint'ing ..
+ *
+ *---------------------------------------------------------------------------*/
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+#include <string.h>
+#include <stdlib.h>
+#include <nterm.h>
+#include "curses.priv.h"
+
+#ifndef OPT_MVCUR
+/*
+**
+** mvcur(oldrow, oldcol, newrow, newcol)
+** A hack for terminals that are smart enough
+** to know how to move cursor.
+** There is still a bug in the alternative long-
+** winded code.
+**
+*/
+
+int mvcur(int oldrow, int oldcol, int newrow, int newcol)
+{
+ T(("mvcur(%d,%d,%d,%d) called", oldrow, oldcol, newrow, newcol));
+
+ if(!cursor_address)
+ return ERR;
+
+ newrow %= lines;
+ newcol %= columns;
+
+ if (cursor_address)
+ putp(tparm(cursor_address, newrow, newcol));
+ return OK;
+
+}
+
+#else
+
+#define BUFSIZE 128 /* size of strategy buffer */
+
+struct Sequence
+{
+ int vec[BUFSIZE]; /* vector of operations */
+ int *end; /* end of vector */
+ int cost; /* cost of vector */
+};
+
+static void row(struct Sequence *outseq, int orow, int nrow);
+static void column(struct Sequence *outseq, int ocol, int ncol);
+static void simp_col(struct Sequence *outseq, int oc, int nc);
+static void zero_seq(struct Sequence *seq);
+static void add_seq(struct Sequence *seq1, struct Sequence *seq2);
+static void out_seq(struct Sequence *seq);
+static void update_ops(void);
+static void init_costs(int costs[]);
+static int countc(char ch);
+static void add_op(struct Sequence *seq, int op, ...);
+static char *sequence(int op);
+
+static int c_count; /* used for counting tputs output */
+
+#define INFINITY 1000 /* biggest, impossible sequence cost */
+#define NUM_OPS 16 /* num. term. control sequences */
+#define NUM_NPARM 9 /* num. ops wo/ parameters */
+
+ /* operator indexes into op_info */
+
+#define CARRIAGE_RETURN 0 /* watch out for nl mapping */
+#define CURS_DOWN 1
+#define CURS_HOME 2
+#define CURS_LEFT 3
+#define CURS_RIGHT 4
+#define CURS_TO_LL 5
+#define CURS_UP 6
+#define TAB 7
+#define BACK_TAB 8
+#define ROW_ADDR 9
+#define COL_ADDR 10
+#define P_DOWN_CURS 11
+#define P_LEFT_CURS 12
+#define P_RIGHT_CURS 13
+#define P_UP_CURS 14
+#define CURS_ADDR 15
+
+static bool loc_init = FALSE; /* set if op_info is init'ed */
+
+static bool rel_ok; /* set if we really know where we are */
+
+/*
+ * op_info[NUM_OPS]
+ *
+ * op_info[] contains for operations with no parameters
+ * the cost of the operation. These ops should be first in the array.
+ * For operations with parameters, op_info[] contains
+ * the negative of the number of parameters.
+ */
+
+static int op_info[NUM_OPS] = {
+ 0, /* carriage_return */
+ 0, /* cursor_down */
+ 0, /* cursor_home */
+ 0, /* cursor_left */
+ 0, /* cursor_right */
+ 0, /* cursor_to_ll */
+ 0, /* cursor_up */
+ 0, /* tab */
+ 0, /* back_tab */
+ -1, /* row_address */
+ -1, /* column_address */
+ -1, /* parm_down_cursor */
+ -1, /* parm_left_cursor */
+ -1, /* parm_right_cursor */
+ -1, /* parm_up_cursor */
+ -2 /* cursor_address */
+};
+
+/*
+** Make_seq_best(best, try)
+**
+** Make_seq_best() copies try to best if try->cost < best->cost
+**
+** fixed the old version, now it really runs .. (-hm/08.04.93)
+**
+*/
+
+inline void Make_seq_best(struct Sequence *best, struct Sequence *try)
+{
+ if (best->cost > try->cost) {
+ register int *sptr;
+
+ sptr = try->vec; /* src ptr */
+ best->end = best->vec; /* dst ptr */
+ while(sptr != try->end) /* copy src -> dst */
+ *(best->end++) = *(sptr++);
+ best->cost = try->cost; /* copy cost */
+ }
+}
+
+
+/*
+**
+** mvcur(oldrow, oldcol, newrow, newcol)
+**
+** mvcur() optimally moves the cursor from the position
+** specified by (oldrow, oldcol) to (newrow, newcol). If
+** (oldrow, oldcol) == (-1, -1), mvcur() does not use relative
+** cursor motions. If the coordinates are otherwise
+** out of bounds, it mods them into range.
+**
+** Revisions needed:
+** eat_newline_glitch, auto_right_margin
+*/
+
+int mvcur(int oldrow, int oldcol, int newrow, int newcol)
+{
+struct Sequence seqA, seqB, /* allocate work structures */
+ col0seq, /* sequence to get from col0 to nc */
+ *best, /* best sequence so far */
+ *try; /* next try */
+bool nlstat = SP->_nl; /* nl-output-mapping in effect ?*/
+
+#ifdef TRACE
+ if (_tracing)
+ _tracef("=============================\nmvcur(%d,%d,%d,%d) called",
+ oldrow, oldcol, newrow, newcol);
+#endif
+
+ if ((oldrow == newrow) && (oldcol == newcol))
+ return OK;
+
+ if (oldcol == columns-1 && eat_newline_glitch && auto_right_margin) {
+ tputs(tparm(cursor_address, newrow, newcol), 1, _outc);
+ return OK;
+ }
+
+#if 0
+ if (nlstat)
+ nonl();
+#endif
+ update_ops(); /* make sure op_info[] is current */
+
+ if (oldrow < 0 || oldcol < 0 || (eat_newline_glitch && oldcol == 0 )) {
+ rel_ok = FALSE; /* relative ops ok? */
+ } else {
+ rel_ok = TRUE;
+ oldrow %= lines; /* mod values into range */
+ oldcol %= columns;
+ }
+
+ newrow %= lines;
+ newcol %= columns;
+
+ best = &seqA;
+ try = &seqB;
+
+ /* try out direct cursor addressing */
+
+ zero_seq(best);
+ add_op(best, CURS_ADDR, newrow, newcol);
+
+ /* try out independent row/column addressing */
+
+ if(rel_ok) {
+ zero_seq(try);
+ row(try, oldrow, newrow);
+ column(try, oldcol, newcol);
+ Make_seq_best(best, try);
+ }
+
+ zero_seq(&col0seq); /* store seq. to get from c0 to nc */
+ column(&col0seq, 0, newcol);
+
+ if(col0seq.cost < INFINITY) { /* can get from col0 to newcol */
+
+ /* try out homing and then row/column */
+
+ if (! rel_ok || newcol < oldcol || newrow < oldrow) {
+ zero_seq(try);
+ add_op(try, CURS_HOME, 1);
+ row(try, 0, newrow);
+ add_seq(try, &col0seq);
+ Make_seq_best(best, try);
+ }
+
+ /* try out homing to last line and then row/column */
+
+ if (! rel_ok || newcol < oldcol || newrow > oldrow) {
+ zero_seq(try);
+ add_op(try, CURS_TO_LL, 1);
+ row(try, lines - 1, newrow);
+ add_seq(try, &col0seq);
+ Make_seq_best(best, try);
+ }
+ }
+
+ out_seq(best);
+#if 0
+ if(nlstat)
+ nl();
+#endif
+
+#ifdef TRACE
+ if (_tracing)
+ _tracef("===================================");
+#endif
+
+ return OK;
+}
+
+/*
+** row(outseq, oldrow, newrow)
+**
+** row() adds the best sequence for moving
+** the cursor from oldrow to newrow to seq.
+** row() considers row_address, parm_up/down_cursor
+** and cursor_up/down.
+*/
+
+static void
+row(struct Sequence *outseq, /* where to put the output */
+int orow, int nrow) /* old, new cursor locations */
+{
+struct Sequence seqA, seqB,
+ *best, /* best sequence so far */
+ *try; /* next try */
+
+int parm_cursor, one_step;
+
+ best = &seqA;
+ try = &seqB;
+
+ if (nrow == orow)
+ return;
+
+ if (nrow < orow) {
+ parm_cursor = P_UP_CURS;
+ one_step = CURS_UP;
+ } else {
+ parm_cursor = P_DOWN_CURS;
+ one_step = CURS_DOWN;
+ }
+
+ /* try out direct row addressing */
+
+ zero_seq(best);
+ add_op(best, ROW_ADDR, nrow);
+
+ /* try out paramaterized up or down motion */
+
+ if (rel_ok) {
+ zero_seq(try);
+ add_op(try, parm_cursor, abs(orow - nrow));
+ Make_seq_best(best, try);
+ }
+
+ /* try getting there one step at a time... */
+
+ if (rel_ok) {
+ zero_seq(try);
+ add_op(try, one_step, abs(orow-nrow));
+ Make_seq_best(best, try);
+ }
+
+ add_seq(outseq, best);
+}
+
+
+/*
+** column(outseq, oldcol, newcol)
+**
+** column() adds the best sequence for moving
+** the cursor from oldcol to newcol to outseq.
+** column() considers column_address, parm_left/right_cursor,
+** simp_col(), and carriage_return followed by simp_col().
+*/
+
+static void column(struct Sequence *outseq, /* where to put the output */
+int ocol, int ncol) /* old, new cursor column */
+{
+struct Sequence seqA, seqB,
+ *best, *try;
+int parm_cursor; /* set to either parm_up/down_cursor */
+
+ best = &seqA;
+ try = &seqB;
+
+ if (ncol == ocol)
+ return;
+
+ if (ncol < ocol)
+ parm_cursor = P_LEFT_CURS;
+ else
+ parm_cursor = P_RIGHT_CURS;
+
+ /* try out direct column addressing */
+
+ zero_seq(best);
+ add_op(best, COL_ADDR, ncol);
+
+ /* try carriage_return then simp_col() */
+
+ if(! rel_ok || (ncol < ocol)) {
+ zero_seq(try);
+ add_op(try, CARRIAGE_RETURN, 1);
+ simp_col(try, 0, ncol);
+ Make_seq_best(best, try);
+ }
+ if(rel_ok) {
+ /* try out paramaterized left or right motion */
+
+ zero_seq(try);
+ add_op(try, parm_cursor, abs(ocol - ncol));
+ Make_seq_best(best, try);
+
+ /* try getting there with simp_col() */
+
+ zero_seq(try);
+ simp_col(try, ocol, ncol);
+ Make_seq_best(best, try);
+ }
+
+ add_seq(outseq, best);
+}
+
+
+/*
+** simp_col(outseq, oldcol, newcol)
+**
+** simp_col() adds the best simple sequence for getting
+** from oldcol to newcol to outseq.
+** simp_col() considers (back_)tab and cursor_left/right.
+**
+** Revisions needed:
+** Simp_col asssumes that the cost of a (back_)tab
+** is less then the cost of one-stepping to get to the same column.
+** Should sometimes use overprinting instead of cursor_right.
+*/
+
+static void
+simp_col( struct Sequence *outseq, /* place to put sequence */
+int oc, int nc) /* old column, new column */
+{
+struct Sequence seqA, seqB, tabseq,
+ *best, *try;
+int mytab, tabs, onepast,
+ one_step, opp_step;
+
+ onepast = -1;
+
+ if (oc == nc)
+ return;
+
+ if(! rel_ok) {
+ outseq->cost = INFINITY;
+ return;
+ }
+
+ best = &seqA;
+ try = &seqB;
+
+ if(oc < nc) {
+ mytab = TAB;
+
+ if (init_tabs > 0 && op_info[TAB] < INFINITY) {
+ tabs = (nc / init_tabs) - (oc / init_tabs);
+ onepast = ((nc / init_tabs) + 1) * init_tabs;
+ if (tabs)
+ oc = onepast - init_tabs; /* consider it done */
+ } else {
+ tabs = 0;
+ }
+ one_step = CURS_RIGHT;
+ opp_step = CURS_LEFT;
+ } else {
+ mytab = BACK_TAB;
+ if (init_tabs > 0 && op_info[BACK_TAB] < INFINITY) {
+ tabs = (oc / init_tabs) - (nc / init_tabs);
+ onepast = ((nc - 1) / init_tabs) * init_tabs;
+ if (tabs)
+ oc = onepast + init_tabs; /* consider it done */
+ } else {
+ tabs = 0;
+ }
+ one_step = CURS_LEFT;
+ opp_step = CURS_RIGHT;
+ }
+
+ /* tab as close as possible to nc */
+
+ zero_seq(&tabseq);
+ add_op(&tabseq, mytab, tabs);
+
+ /* try extra tab and backing up */
+
+ zero_seq(best);
+
+ if (onepast >= 0 && onepast < columns) {
+ add_op(best, mytab, 1);
+ add_op(best, opp_step, abs(onepast - nc));
+ } else {
+ best->cost = INFINITY; /* make sure of next swap */
+ }
+
+ /* try stepping to nc */
+
+ zero_seq(try);
+ add_op(try, one_step, abs(nc - oc));
+ Make_seq_best(best, try);
+
+ if (tabseq.cost < INFINITY)
+ add_seq(outseq, &tabseq);
+ add_seq(outseq, best);
+}
+
+
+/*
+** zero_seq(seq) empties seq.
+** add_seq(seq1, seq2) adds seq1 to seq2.
+** out_seq(seq) outputs a sequence.
+*/
+
+static void
+zero_seq(seq)
+struct Sequence *seq;
+{
+ seq->end = seq->vec;
+ seq->cost = 0;
+}
+
+static void
+add_seq(struct Sequence *seq1, struct Sequence *seq2)
+{
+int *vptr;
+
+#ifdef TRACE
+ if (_tracing)
+ _tracef("add_seq(%x, %x)", seq1, seq2);
+#endif
+
+ if(seq1->cost >= INFINITY || seq2->cost >= INFINITY)
+ seq1->cost = INFINITY;
+ else {
+ vptr = seq2->vec;
+ while (vptr != seq2->end)
+ *(seq1->end++) = *(vptr++);
+ seq1->cost += seq2->cost;
+ }
+}
+
+
+static void
+out_seq(struct Sequence *seq)
+{
+int *opptr, prm[9], ps, p, op;
+int count;
+char *sequence();
+
+#ifdef TRACE
+ if (_tracing)
+ _tracef("out_seq(%x)", seq);
+#endif
+
+ if (seq->cost >= INFINITY)
+ return;
+
+ for (opptr = seq->vec; opptr < seq->end; opptr++) {
+ op = *opptr; /* grab operator */
+ ps = -op_info[op];
+ if(ps > 0) { /* parameterized */
+ for (p = 0; p < ps; p++) /* fill in needed parms */
+ prm[p] = *(++opptr);
+
+ tputs(tparm(sequence(op),
+ prm[0], prm[1], prm[2], prm[3], prm[4],
+ prm[5], prm[6], prm[7], prm[8]), 1, _outc);
+ } else {
+ count = *(++opptr);
+ /*rev should save tputs output instead of mult calls */
+ while (count--) /* do count times */
+ tputs(sequence(op), 1, _outc);
+ }
+ }
+}
+
+
+/*
+** update_ops()
+**
+** update_ops() makes sure that
+** the op_info[] array is updated and initializes
+** the cost array for SP if needed.
+*/
+
+static void
+update_ops()
+{
+#ifdef TRACE
+ if (_tracing)
+ _tracef("update_ops()");
+#endif
+
+ if (SP) { /* SP structure exists */
+ int op;
+
+ if (! SP->_costinit) { /* this term not yet assigned costs */
+ loc_init = FALSE; /* if !SP in the future, new term */
+ init_costs(SP->_costs); /* fill term costs */
+ SP->_costinit = TRUE;
+ }
+
+ for (op = 0; op < NUM_NPARM; op++)
+ op_info[op] = SP->_costs[op]; /* set up op_info */
+
+ /* check for newline that might be mapped... */
+
+ if (SP->_nlmapping && index(sequence(CURS_DOWN), '\n'))
+ op_info[CURS_DOWN] = INFINITY;
+ } else {
+ if (! loc_init) { /* using local costs */
+ loc_init = TRUE;
+ init_costs(op_info); /* set up op_info */
+ }
+
+ /* check for newline that might be mapped... */
+
+ if (index(sequence(CURS_DOWN), '\n'))
+ op_info[CURS_DOWN] = INFINITY;
+ }
+}
+
+
+/*
+** init_costs(costs)
+**
+** init_costs() fills the array costs[NUM_NPARM]
+** with costs calculated by doing tputs() calls.
+*/
+
+static void
+init_costs(int costs[])
+{
+int i;
+
+ for (i = 0; i < NUM_NPARM; i++) {
+ if (sequence(i) != (char *) 0) {
+ c_count = 0;
+ tputs(sequence(i), 1, countc);
+ costs[i] = c_count;
+ } else
+ costs[i] = INFINITY;
+ }
+}
+
+
+/*
+** countc() increments global var c_count.
+*/
+
+static int countc(char ch)
+{
+ return(c_count++);
+}
+
+/*
+** add_op(seq, op, p0, p1, ... , p8)
+**
+** add_op() adds the operator op and the appropriate
+** number of paramaters to seq. It also increases the
+** cost appropriately.
+** if op has no parameters, p0 is taken to be a count.
+*/
+
+static void add_op(struct Sequence *seq, int op, ...)
+{
+va_list argp;
+int num_ps, p;
+
+#ifdef TRACE
+ if (_tracing)
+ _tracef("adding op %d to sequence", op);
+#endif
+ va_start(argp, op);
+
+ num_ps = - op_info[op]; /* get parms or -cost */
+
+ *(seq->end++) = op;
+
+ if (num_ps == (- INFINITY) || sequence(op) == (char *) 0) {
+ seq->cost = INFINITY;
+ } else if (num_ps <= 0) { /* no parms, -cost */
+ int i = va_arg(argp, int);
+ seq->cost -= i * num_ps; /* ADD count * cost */
+ *(seq->end++) = i;
+ } else {
+ int prm[9];
+
+ for (p = 0; p < num_ps; p++)
+ *(seq->end++) = prm[p] = va_arg(argp, int);
+
+ c_count = 0;
+
+ tputs(tparm(sequence(op), prm[0], prm[1], prm[2], prm[3], prm[4],
+ prm[5], prm[6], prm[7], prm[8]), 1, countc);
+
+ seq->cost += c_count;
+ }
+ va_end(argp);
+}
+
+
+/*
+** char *sequence(op)
+**
+** sequence() returns a pointer to the op's
+** terminal control sequence.
+*/
+
+static char *sequence(int op)
+{
+#ifdef TRACE
+ if (_tracing)
+ _tracef("sequence(%d)", op);
+#endif
+ switch(op) {
+ case CARRIAGE_RETURN:
+ return (carriage_return);
+ case CURS_DOWN:
+ return (cursor_down);
+ case CURS_HOME:
+ return (cursor_home);
+ case CURS_LEFT:
+ return (cursor_left);
+ case CURS_RIGHT:
+ return (cursor_right);
+ case CURS_TO_LL:
+ return (cursor_to_ll);
+ case CURS_UP:
+ return (cursor_up);
+ case TAB:
+ return (tab);
+ case BACK_TAB:
+ return (back_tab);
+ case ROW_ADDR:
+ return (row_address);
+ case COL_ADDR:
+ return (column_address);
+ case P_DOWN_CURS:
+ return (parm_down_cursor);
+ case P_LEFT_CURS:
+ return (parm_left_cursor);
+ case P_RIGHT_CURS:
+ return (parm_right_cursor);
+ case P_UP_CURS:
+ return (parm_up_cursor);
+ case CURS_ADDR:
+ return (cursor_address);
+ default:
+ return ((char *) 0);
+ }
+}
+
+#endif
+
diff --git a/lib/libncurses/lib_mvwin.c b/lib/libncurses/lib_mvwin.c
new file mode 100644
index 0000000..f58925e
--- /dev/null
+++ b/lib/libncurses/lib_mvwin.c
@@ -0,0 +1,29 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_mvwin.c
+**
+** The routine mvwin().
+**
+*/
+
+#include "curses.priv.h"
+#include <nterm.h>
+
+int mvwin(WINDOW *win, int by, int bx)
+{
+ T(("mvwin(%x,%d,%d) called", win, by, bx));
+
+ if (by + win->_maxy > lines - 1 || bx + win->_maxx > columns - 1)
+ return(ERR);
+
+ win->_begy = by;
+ win->_begx = bx;
+
+ touchwin(win);
+
+ return(OK);
+}
diff --git a/lib/libncurses/lib_newterm.c b/lib/libncurses/lib_newterm.c
new file mode 100644
index 0000000..a411e26
--- /dev/null
+++ b/lib/libncurses/lib_newterm.c
@@ -0,0 +1,154 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_newterm.c
+**
+** The newterm() function.
+**
+*/
+
+#include <stdlib.h>
+#include "curses.priv.h"
+#include <nterm.h>
+#ifdef SVR4_ACTION
+#define _POSIX_SOURCE
+#endif
+#include <signal.h>
+
+#ifdef MYTINFO
+int LINES, COLS;
+#endif
+
+static void cleanup(int sig)
+{
+
+ if (sig == SIGSEGV)
+ fprintf(stderr, "Got a segmentation violation signal, cleaning up and exiting\n");
+ endwin();
+ exit(1);
+}
+
+WINDOW *stdscr, *curscr, *newscr;
+SCREEN *SP;
+
+struct ripoff_t
+{
+ int line;
+ int (*hook)();
+}
+rippedoff[5], *rsp = rippedoff;
+
+SCREEN * newterm(char *term, FILE *ofp, FILE *ifp)
+{
+sigaction_t act;
+int errret;
+int stolen, topstolen;
+
+#ifdef TRACE
+ _init_trace();
+ T(("newterm(%s,%x,%x) called", term, ofp, ifp));
+#endif
+
+#ifdef MYTINFO
+ if (setupterm(term, fileno(ofp), &errret) != OK)
+ return NULL;
+ COLS = cur_term->true_columns;
+ LINES = cur_term->true_lines;
+#else
+ if (setupterm(term, fileno(ofp), &errret) != 1)
+ return NULL;
+#endif
+
+ if ((SP = (SCREEN *) malloc(sizeof *SP)) == NULL)
+ return NULL;
+
+ if (ofp == stdout && ifp == stdin) {
+ SP->_ofp = stdout;
+ SP->_ifp = stdin;
+ } else {
+ SP->_ofp = ofp;
+ SP->_ifp = ofp;
+ }
+ SP->_term = cur_term;
+ SP->_cursrow = -1;
+ SP->_curscol = -1;
+ SP->_keytry = UNINITIALISED;
+ SP->_nl = TRUE;
+ SP->_raw = FALSE;
+ SP->_cbreak = FALSE;
+ SP->_echo = TRUE;
+ SP->_nlmapping = TRUE;
+ SP->_fifohead = -1;
+ SP->_fifotail = 0;
+ SP->_fifopeek = 0;
+
+ if (enter_ca_mode)
+ putp(enter_ca_mode);
+
+ init_acs();
+
+ T(("creating newscr"));
+ if ((newscr = newwin(lines, columns, 0, 0)) == (WINDOW *)NULL)
+ return(NULL);
+
+ T(("creating curscr"));
+ if ((curscr = newwin(lines, columns, 0, 0)) == (WINDOW *)NULL)
+ return(NULL);
+
+ 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,COLS, LINES-1,0), COLS);
+ else
+ rsp->hook(newwin(1,COLS, topstolen++,0), COLS);
+ --LINES;
+ stolen++;
+ }
+
+ act.sa_handler = tstp;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+ sigaction(SIGTSTP, &act, NULL);
+ act.sa_handler = cleanup;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+ sigaction(SIGINT, &act, NULL);
+#if 0
+ sigaction(SIGSEGV, &act, NULL);
+#endif
+ if (stdscr == NULL)
+ if ((stdscr = newwin(lines - stolen, columns, topstolen, 0)) == NULL)
+ return(NULL);
+
+ T(("newterm returns %x", SP));
+
+ return(SP);
+}
+
+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/libncurses/lib_newwin.c b/lib/libncurses/lib_newwin.c
new file mode 100644
index 0000000..f732a7c
--- /dev/null
+++ b/lib/libncurses/lib_newwin.c
@@ -0,0 +1,177 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_newwin.c
+**
+** The routines newwin(), subwin() and their dependent
+**
+*/
+
+#include <stdlib.h>
+#include <nterm.h>
+#include "curses.priv.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 = lines - begy;
+
+ if (num_columns == 0)
+ num_columns = columns - begx;
+
+ if (num_columns + begx > columns || num_lines + begy > lines)
+ return NULL;
+
+ if ((win = makenew(num_lines, num_columns, begy, begx)) == NULL)
+ return NULL;
+
+ for (i = 0; i < num_lines; i++) {
+ if ((win->_line[i] = (chtype *) calloc(num_columns, sizeof(chtype))) == NULL) {
+ for (j = 0; j < i; j++)
+ free(win->_line[j]);
+
+ free(win->_firstchar);
+ free(win->_lastchar);
+ free(win->_line);
+ free(win);
+
+ return NULL;
+ }
+ else
+ for (ptr = win->_line[i]; ptr < win->_line[i] + num_columns; )
+ *ptr++ = ' ';
+ }
+
+ T(("newwin: returned window is %x", win));
+
+ return(win);
+}
+
+WINDOW * derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx)
+{
+WINDOW *win;
+int i;
+
+ T(("derwin(%x, %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 - orig->_begy - begy;
+
+ if (num_columns == 0)
+ num_columns = orig->_maxx - orig->_begx - begx;
+
+ if ((win = makenew(num_lines, num_columns, orig->_begy + begy, orig->_begx + begx)) == NULL)
+ return NULL;
+
+ win->_pary = begy;
+ win->_parx = begx;
+
+ for (i = 0; i < num_lines; i++)
+ win->_line[i] = &orig->_line[begy++][begx];
+
+ win->_flags = _SUBWIN;
+ win->_parent = orig;
+
+ T(("derwin: returned window is %x", win));
+
+ return(win);
+}
+
+
+WINDOW *subwin(WINDOW *w, int l, int c, int y, int x)
+{
+ T(("subwin(%x, %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 *
+makenew(int num_lines, int num_columns, int begy, int begx)
+{
+int i;
+WINDOW *win;
+
+ T(("makenew(%d,%d,%d,%d)", num_lines, num_columns, begy, begx));
+
+ if ((win = (WINDOW *) malloc(sizeof(WINDOW))) == NULL)
+ return NULL;
+
+ if ((win->_line = (chtype **) calloc(num_lines, sizeof (chtype *))) == NULL) {
+ free(win);
+ return NULL;
+ }
+
+ if ((win->_firstchar = calloc(num_lines, sizeof(short))) == NULL) {
+ free(win);
+ free(win->_line);
+ return NULL;
+ }
+
+ if ((win->_lastchar = calloc(num_lines, sizeof(short))) == NULL) {
+ free(win);
+ free(win->_line);
+ free(win->_firstchar);
+ 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->_clear = (num_lines == lines && num_columns == columns);
+ win->_idlok = FALSE;
+ win->_use_idc = TRUE;
+ win->_scroll = FALSE;
+ win->_leave = FALSE;
+ win->_use_keypad = FALSE;
+ win->_use_meta = FALSE;
+ win->_delay = -1;
+ win->_immed = FALSE;
+ win->_sync = 0;
+ win->_parx = 0;
+ win->_pary = 0;
+ win->_parent = (WINDOW *)NULL;
+
+ win->_regtop = 0;
+ win->_regbottom = num_lines - 1;
+
+ for (i = 0; i < num_lines; i++)
+ win->_firstchar[i] = win->_lastchar[i] = _NOCHANGE;
+
+ if (begx + num_columns == columns) {
+ win->_flags |= _ENDLINE;
+
+ if (begx == 0 && num_lines == lines && begy == 0)
+ win->_flags |= _FULLWIN;
+
+ if (begy + num_lines == lines)
+ win->_flags |= _SCROLLWIN;
+ }
+
+ return(win);
+}
diff --git a/lib/libncurses/lib_options.c b/lib/libncurses/lib_options.c
new file mode 100644
index 0000000..fa4cbf0
--- /dev/null
+++ b/lib/libncurses/lib_options.c
@@ -0,0 +1,229 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_options.c
+**
+** The routines to handle option setting.
+**
+*/
+
+#include <stdlib.h>
+#include <nterm.h>
+#include "curses.priv.h"
+
+int idlok(WINDOW *win, int flag)
+{
+ T(("idlok(%x,%d) called", win, flag));
+
+ if (insert_line || delete_line || parm_insert_line || parm_delete_line) {
+ win->_idlok = flag;
+ }
+ return OK;
+}
+
+
+int clearok(WINDOW *win, int flag)
+{
+ T(("clearok(%x,%d) called", win, flag));
+
+ if (win == curscr)
+ newscr->_clear = flag;
+ else
+ win->_clear = flag;
+ return OK;
+}
+
+
+int leaveok(WINDOW *win, int flag)
+{
+ T(("leaveok(%x,%d) called", win, flag));
+
+ win->_leave = flag;
+ return OK;
+}
+
+
+int scrollok(WINDOW *win, int flag)
+{
+ T(("scrollok(%x,%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, int flag)
+{
+ T(("nodelay(%x,%d) called", win, flag));
+
+ if (flag == TRUE)
+ win->_delay = 0;
+ else win->_delay = -1;
+ return OK;
+}
+
+int notimeout(WINDOW *win, bool f)
+{
+ T(("notimout(%x,%d) called", win, f));
+
+ win->_notimeout = f;
+ return OK;
+}
+
+int wtimeout(WINDOW *win, int delay)
+{
+ T(("wtimeout(%x,%d) called", win, delay));
+
+ win->_delay = delay;
+ return OK;
+}
+
+static void init_keytry();
+static void add_to_try(char *, short);
+
+int keypad(WINDOW *win, int flag)
+{
+ T(("keypad(%x,%d) called", win, flag));
+
+ win->_use_keypad = flag;
+
+ if (flag && keypad_xmit)
+ tputs(keypad_xmit, 1, _outc);
+ else if (! flag && keypad_local)
+ tputs(keypad_local, 1, _outc);
+
+ if (SP->_keytry == UNINITIALISED)
+ init_keytry();
+ return OK;
+}
+
+
+
+int meta(WINDOW *win, int flag)
+{
+ T(("meta(%x,%d) called", win, flag));
+
+ win->_use_meta = flag;
+
+ if (flag && meta_on)
+ tputs(meta_on, 1, _outc);
+ else if (! flag && meta_off)
+ tputs(meta_off, 1, _outc);
+ return OK;
+}
+
+/*
+** init_keytry()
+**
+** Construct the try for the current terminal's keypad keys.
+**
+*/
+
+
+static struct try *newtry;
+
+static void init_keytry()
+{
+ 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;
+ ptr->ch = *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;
+ ptr->ch = *(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;
+ ptr->ch = *(str++);
+ ptr->value = (short) NULL;
+ }
+
+ ptr->value = code;
+ return;
+}
diff --git a/lib/libncurses/lib_overlay.c b/lib/libncurses/lib_overlay.c
new file mode 100644
index 0000000..62bb2f1
--- /dev/null
+++ b/lib/libncurses/lib_overlay.c
@@ -0,0 +1,110 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_overlay.c
+**
+** The routines overlay(), copywin(), and overwrite().
+**
+*/
+
+#include "curses.priv.h"
+
+static void overlap(WINDOW *s, WINDOW *d, int 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(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(WINDOW *win1, WINDOW *win2)
+{
+ overlap(win1, win2, FALSE);
+ return OK;
+}
+
+int copywin(WINDOW *src, WINDOW *dst,
+ int sminrow, int smincol,
+ int dminrow, int dmincol, int dmaxrow, int dmaxcol,
+ int over)
+{
+int sx, sy, dx, dy;
+
+ T(("copywin(%x, %x, %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++) {
+ dst->_firstchar[dy] = dmincol;
+ dst->_lastchar[dy] = dmincol;
+ for (dx = dmincol, sx = smincol; dx <= dmaxcol; sx++, dx++) {
+ if (over == TRUE ) {
+ if (((src->_line[sy][sx] & A_CHARTEXT) != ' ') && (dst->_line[dy][dx] != src->_line[sy][sx])) {
+ dst->_line[dy][dx] = src->_line[sy][sx];
+ dst->_lastchar[dy] = dx;
+ } else
+ dst->_firstchar[dy]++;
+ } else {
+ if (dst->_line[dy][dx] != src->_line[sy][sx]) {
+ dst->_line[dy][dx] = src->_line[sy][sx];
+ dst->_lastchar[dy] = dx;
+ } else
+ dst->_firstchar[dy]++;
+ }
+ }
+ }
+ T(("finished copywin"));
+ return OK;
+}
diff --git a/lib/libncurses/lib_pad.c b/lib/libncurses/lib_pad.c
new file mode 100644
index 0000000..75a639c
--- /dev/null
+++ b/lib/libncurses/lib_pad.c
@@ -0,0 +1,142 @@
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+ * lib_pad.c
+ * newpad -- create a new pad
+ * pnoutrefresh -- refresh a pad, no update
+ * pechochar -- add a char to a pad and refresh
+ */
+
+#include <stdlib.h>
+#include "curses.priv.h"
+
+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 = makenew(l,c,0,0)) == NULL)
+ return NULL;
+
+ win->_flags |= _ISPAD;
+
+ for (i = 0; i < l; i++) {
+ if ((win->_line[i] = (chtype *) calloc(c, sizeof(chtype))) == NULL) {
+ for (j = 0; j < i; j++)
+ free(win->_line[j]);
+
+ free(win->_firstchar);
+ free(win->_lastchar);
+ free(win->_line);
+ free(win);
+
+ return NULL;
+ }
+ else
+ for (ptr = win->_line[i]; ptr < win->_line[i] + c; )
+ *ptr++ = ' ';
+ }
+
+ T(("newpad: returned window is %x", 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)
+ return (doupdate());
+ else
+ return ERR;
+
+}
+
+int pnoutrefresh(WINDOW *win, int pminrow, int pmincol,
+ int sminrow, int smincol, int smaxrow, int smaxcol)
+{
+int i, j;
+int m, n;
+
+ T(("pnoutrefresh(%x, %d, %d, %d, %d, %d, %d) called",
+ win, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol));
+
+ if (!(win->_flags & _ISPAD))
+ return ERR;
+
+ T(("one"));
+ if (pminrow < 0) pminrow = 0;
+ if (pmincol < 0) pmincol = 0;
+ if (sminrow < 0) sminrow = 0;
+ if (smincol < 0) smincol = 0;
+
+ T(("two"));
+ if (smaxrow >= LINES || smaxcol >= COLS)
+ return ERR;
+
+ T(("three"));
+ if ((pminrow + smaxrow > win->_maxy) || (pmincol + smaxcol > win->_maxx))
+ return ERR;
+
+ T(("pad being refreshed"));
+
+ for (i = pminrow, m = sminrow; i <= smaxrow + pminrow; i++, m++) {
+ j = pmincol;
+ n = j + smincol;
+ for (; j <= pmincol + smaxcol; j++, n++) {
+ if (win->_line[i][j] != newscr->_line[m][n]) {
+ newscr->_line[m][n] = win->_line[i][j];
+
+ if (newscr->_firstchar[m] == _NOCHANGE)
+ newscr->_firstchar[m] = newscr->_lastchar[m] = n;
+ else if (n < newscr->_firstchar[m])
+ newscr->_firstchar[m] = n;
+ else if (n > newscr->_lastchar[m])
+ newscr->_lastchar[m] = n;
+ }
+ }
+ }
+
+ win->_firstchar[i] = win->_lastchar[i] = _NOCHANGE;
+
+ win->_begx = smincol;
+ win->_begy = sminrow;
+
+ if (win->_clear) {
+ win->_clear = FALSE;
+ newscr->_clear = TRUE;
+ }
+
+ if (! win->_leave) {
+ newscr->_cury = win->_cury + win->_begy;
+ newscr->_curx = win->_curx + win->_begx;
+ }
+ return OK;
+}
+
+int pechochar(WINDOW *pad, chtype ch)
+{
+int x, y;
+
+ T(("echochar(%x, %x)", pad, ch));
+
+ if (pad->_flags & _ISPAD)
+ return ERR;
+
+ x = pad->_begx + pad->_curx;
+ y = pad->_begy + pad->_cury;
+
+ waddch(curscr, ch);
+ doupdate();
+ return OK;
+}
+
diff --git a/lib/libncurses/lib_printw.c b/lib/libncurses/lib_printw.c
new file mode 100644
index 0000000..f4609c3
--- /dev/null
+++ b/lib/libncurses/lib_printw.c
@@ -0,0 +1,81 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_printw.c
+**
+** The routines printw(), wprintw() and friends.
+**
+*/
+
+#include "curses.priv.h"
+
+int printw(char *fmt, ...)
+{
+va_list argp;
+char buf[BUFSIZ];
+
+#ifdef TRACE
+ if (_tracing)
+ _tracef("printw(%s,...) called", fmt);
+#endif
+
+ va_start(argp, fmt);
+ vsprintf(buf, fmt, argp);
+ va_end(argp);
+ return(waddstr(stdscr, buf));
+}
+
+
+
+int wprintw(WINDOW *win, char *fmt, ...)
+{
+va_list argp;
+char buf[BUFSIZ];
+
+#ifdef TRACE
+ if (_tracing)
+ _tracef("wprintw(%x,%s,...) called", win, fmt);
+#endif
+
+ va_start(argp, fmt);
+ vsprintf(buf, fmt, argp);
+ va_end(argp);
+ return(waddstr(win, buf));
+}
+
+
+
+int mvprintw(int y, int x, 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, 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, char *fmt, va_list argp)
+{
+char buf[BUFSIZ];
+
+ vsprintf(buf, fmt, argp);
+ return(waddstr(win, buf));
+}
diff --git a/lib/libncurses/lib_raw.c b/lib/libncurses/lib_raw.c
new file mode 100644
index 0000000..fb2b928
--- /dev/null
+++ b/lib/libncurses/lib_raw.c
@@ -0,0 +1,195 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+ * raw.c
+ *
+ * Routines:
+ * raw()
+ * echo()
+ * nl()
+ * cbreak()
+ * noraw()
+ * noecho()
+ * nonl()
+ * nocbreak()
+ *
+ */
+
+#include "curses.priv.h"
+#include <nterm.h>
+
+int raw()
+{
+ T(("raw() called"));
+
+ SP->_raw = TRUE;
+ SP->_cbreak = TRUE;
+ SP->_nlmapping = TRUE;
+
+#ifdef TERMIOS
+ cur_term->Nttyb.c_lflag &= ~(ICANON|ISIG);
+ cur_term->Nttyb.c_iflag &= ~(INPCK|ISTRIP|IXON);
+ 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()
+{
+ T(("cbreak() called"));
+
+ SP->_cbreak = 1;
+
+#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()
+{
+ 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()
+{
+ T(("nl() called"));
+
+ SP->_nl = TRUE;
+ SP->_nlmapping = ! SP->_raw;
+
+#ifdef TERMIOS
+ cur_term->Nttyb.c_iflag |= IXON|ICRNL|IXOFF;
+ 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 noraw()
+{
+ T(("noraw() called"));
+
+ SP->_raw = FALSE;
+ SP->_cbreak = FALSE;
+ SP->_nlmapping = SP->_nl;
+
+#ifdef TERMIOS
+ cur_term->Nttyb.c_lflag |= ISIG|ICANON;
+ cur_term->Nttyb.c_iflag |= IXON;
+ 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()
+{
+ 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()
+{
+ T(("noecho() called"));
+
+ SP->_echo = FALSE;
+
+#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 nonl()
+{
+ T(("nonl() called"));
+
+ SP->_nl = SP->_nlmapping = 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
+}
diff --git a/lib/libncurses/lib_refresh.c b/lib/libncurses/lib_refresh.c
new file mode 100644
index 0000000..72ab095
--- /dev/null
+++ b/lib/libncurses/lib_refresh.c
@@ -0,0 +1,74 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+ * lib_refresh.c
+ *
+ * The routines wredrawln(), wrefresh() and wnoutrefresh().
+ *
+ */
+
+#include "curses.priv.h"
+
+int wredrawln(WINDOW *win, int beg, int num)
+{
+ T(("wredrawln(%x,%d,%d) called", win, beg, num));
+ touchline(win, beg, num);
+ wrefresh(win);
+ return OK;
+}
+
+int wrefresh(WINDOW *win)
+{
+ T(("wrefresh(%x) called", win));
+
+ if (win == curscr)
+ curscr->_clear = TRUE;
+ else
+ wnoutrefresh(win);
+ return(doupdate());
+}
+
+int wnoutrefresh(WINDOW *win)
+{
+int i, j;
+int begx = win->_begx;
+int begy = win->_begy;
+int m, n;
+
+ T(("wnoutrefresh(%x) called", win));
+
+ win->_flags &= ~_HASMOVED;
+ for (i = 0, m = begy; i <= win->_maxy; i++, m++) {
+ if (win->_firstchar[i] != _NOCHANGE) {
+ j = win->_firstchar[i];
+ n = j + begx;
+ for (; j <= win->_lastchar[i]; j++, n++) {
+ if (win->_line[i][j] != newscr->_line[m][n]) {
+ newscr->_line[m][n] = win->_line[i][j];
+
+ if (newscr->_firstchar[m] == _NOCHANGE)
+ newscr->_firstchar[m] = newscr->_lastchar[m] = n;
+ else if (n < newscr->_firstchar[m])
+ newscr->_firstchar[m] = n;
+ else if (n > newscr->_lastchar[m])
+ newscr->_lastchar[m] = n;
+ }
+ }
+ }
+ win->_firstchar[i] = win->_lastchar[i] = _NOCHANGE;
+ }
+
+ if (win->_clear) {
+ win->_clear = FALSE;
+ newscr->_clear = TRUE;
+ }
+
+ if (! win->_leave) {
+ newscr->_cury = win->_cury + win->_begy;
+ newscr->_curx = win->_curx + win->_begx;
+ }
+ return(OK);
+}
diff --git a/lib/libncurses/lib_scanw.c b/lib/libncurses/lib_scanw.c
new file mode 100644
index 0000000..68aeaea
--- /dev/null
+++ b/lib/libncurses/lib_scanw.c
@@ -0,0 +1,72 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_scanw.c
+**
+** The routines scanw(), wscanw() and friends.
+**
+*/
+
+#include "curses.priv.h"
+
+int vwscanw(WINDOW *win, char *fmt, va_list argp)
+{
+char buf[BUFSIZ];
+
+ if (wgetstr(win, buf) == ERR)
+ return(ERR);
+
+ return(vsscanf(buf, fmt, argp));
+}
+
+int scanw(char *fmt, ...)
+{
+va_list ap;
+
+#ifdef TRACE
+ if (_tracing)
+ _tracef("scanw(%s,...) called", fmt);
+#endif
+
+ va_start(ap, fmt);
+ return(vwscanw(stdscr, fmt, ap));
+}
+
+int wscanw(WINDOW *win, char *fmt, ...)
+{
+va_list ap;
+
+#ifdef TRACE
+ if (_tracing)
+ _tracef("wscanw(%x,%s,...) called", win, fmt);
+#endif
+
+ va_start(ap, fmt);
+ return(vwscanw(win, fmt, ap));
+}
+
+
+
+int mvscanw(int y, int x, 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, char *fmt, ...)
+{
+va_list ap;
+
+ va_start(ap, fmt);
+ return(wmove(win, y, x) == OK ? vwscanw(win, fmt, ap) : ERR);
+}
+
+
+
diff --git a/lib/libncurses/lib_screen.c b/lib/libncurses/lib_screen.c
new file mode 100644
index 0000000..0c0ab8a
--- /dev/null
+++ b/lib/libncurses/lib_screen.c
@@ -0,0 +1,58 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+#included "curses.priv.h"
+
+int putwin(WINDOW *win, char *file)
+{
+int fd, i;
+
+ fd = open(file, O_WRONLY);
+ if (fd < -1)
+ return ERR;
+ for (i = 0; i < lines; i++)
+ write(fd, win->_line[i], sizeof(chtype)*columns);
+ close(fd);
+ return OK;
+}
+
+int scr_restore(char *file)
+{
+int fd, i;
+
+ fd = open(file, O_RDONLY);
+ if (fd < -1)
+ return ERR;
+ for (i = 0; i < lines; i++)
+ read(fd, curscr->_line[i], sizeof(chtype)*columns);
+ touchwin(curscr);
+ close(fd);
+ return OK;
+}
+
+int scr_dump(char *file)
+{
+
+ putwin(curscr, file);
+}
+
+int scr_init(char *file)
+{
+
+ return ERR;
+}
+
+int scr_set(char *file)
+{
+
+ return ERR;
+}
+
+WINDOW *getwin(FILE *filep)
+{
+
+ return NULL;
+}
+
diff --git a/lib/libncurses/lib_scroll.c b/lib/libncurses/lib_scroll.c
new file mode 100644
index 0000000..a1f2a09
--- /dev/null
+++ b/lib/libncurses/lib_scroll.c
@@ -0,0 +1,120 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** 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 <stdlib.h>
+#include "curses.priv.h"
+#include <nterm.h>
+
+int
+wscrl(WINDOW *win, int n)
+{
+int line, i;
+chtype *ptr, *temp;
+chtype **saved;
+chtype blank = ' ';
+
+ T(("wscrl(%x,%d) called", win, n));
+
+ if (! win->_scroll)
+ return ERR;
+
+ if (n == 0)
+ return OK;
+
+ /* test for scrolling region == entire screen */
+
+ saved = (chtype **)malloc(sizeof(chtype *) * abs(n));
+
+ if (n < 0) {
+ /* save overwritten lines */
+
+ for (i = 0; i < -n; i++)
+ saved[i] = win->_line[win->_regbottom-i];
+
+ /* shift n lines */
+
+ for (line = win->_regbottom; line > win->_regtop+n; line--)
+ win->_line[line] = win->_line[line+n];
+
+ /* restore saved lines and blank them */
+
+ for (i = 0, line = win->_regtop; line < win->_regtop-n; line++, i++) {
+ win->_line[line] = saved[i];
+ temp = win->_line[line];
+ for (ptr = temp; ptr - temp <= win->_maxx; ptr++)
+ *ptr = blank;
+ }
+ }
+
+ if (n > 0) {
+ /* save overwritten lines */
+
+ for (i = 0; i < n; i++)
+ saved[i] = win->_line[win->_regtop+i];
+
+ /* shift n lines */
+
+ for (line = win->_regtop; line < win->_regbottom; line++)
+ win->_line[line] = win->_line[line+n];
+
+ /* restore saved lines and blank them */
+
+ for (i = 0, line = win->_regbottom; line > win->_regbottom - n; line--, i++) {
+ win->_line[line] = saved[i];
+ temp = win->_line[line];
+ for (ptr = temp; ptr - temp <= win->_maxx; ptr++)
+ *ptr = blank;
+ }
+ }
+
+ free(saved);
+
+ /* as an optimization, if the scrolling region is the entire screen
+ scroll the physical screen */
+ /* should we extend this to include smaller scrolling ranges by using
+ change_scroll_region? */
+
+ if (win->_maxx == columns && win->_regtop == 0 && win->_regbottom == lines) {
+
+ /* at the moment this relies on scroll_reverse and scroll_forward
+ or parm_rindex and parm_index.
+ we should add idl support as an alternative */
+
+ if (n > 0) {
+ mvcur(-1, -1, win->_regtop, 0);
+ if (parm_rindex) {
+ putp(tparm(parm_rindex, n));
+ } else if (scroll_reverse) {
+ while (n--)
+ putp(scroll_reverse);
+ }
+ }
+
+ if (n < 0) {
+ mvcur(-1, -1, win->_regbottom, columns);
+ n = abs(n);
+ if (parm_index) {
+ putp(tparm(parm_index, n));
+ } else if (scroll_forward) {
+ while (n--)
+ putp(scroll_forward);
+ }
+ }
+
+ mvcur(-1, -1, win->_cury, win->_curx);
+ } else
+ touchline(win, win->_regtop, win->_regbottom - win->_regtop + 1);
+
+ return OK;
+}
diff --git a/lib/libncurses/lib_scrreg.c b/lib/libncurses/lib_scrreg.c
new file mode 100644
index 0000000..d8c1423
--- /dev/null
+++ b/lib/libncurses/lib_scrreg.c
@@ -0,0 +1,32 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_scrreg.c
+**
+** The routine wsetscrreg().
+**
+*/
+
+#include "curses.priv.h"
+
+int wsetscrreg(WINDOW *win, int top, int bottom)
+{
+ T(("wsetscrreg(%x,%d,%d) called", win, top, bottom));
+
+ if (top >= 0 && top <= win->_maxy &&
+ bottom >= 0 && bottom <= win->_maxy &&
+ bottom > top)
+ {
+ win->_regtop = top;
+ win->_regbottom = bottom;
+
+ T(("correctly set scrolling region between %d and %d", top, bottom));
+
+ return(OK);
+ }
+ else
+ return(ERR);
+}
diff --git a/lib/libncurses/lib_set_term.c b/lib/libncurses/lib_set_term.c
new file mode 100644
index 0000000..7f273a8
--- /dev/null
+++ b/lib/libncurses/lib_set_term.c
@@ -0,0 +1,35 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_set_term.c
+**
+** The routine set_term().
+**
+*/
+
+#include "curses.priv.h"
+#include <nterm.h>
+
+struct screen *
+set_term(screen)
+struct screen *screen;
+{
+struct screen *oldSP;
+
+#ifdef TRACE
+ if (_tracing)
+ _tracef("set_term(%o) called", screen);
+#endif
+
+ oldSP = SP;
+ SP = screen;
+
+ cur_term = SP->_term;
+ curscr = SP->_curscr;
+ newscr = SP->_newscr;
+
+ return(oldSP);
+}
diff --git a/lib/libncurses/lib_slk.c b/lib/libncurses/lib_slk.c
new file mode 100644
index 0000000..f220a37
--- /dev/null
+++ b/lib/libncurses/lib_slk.c
@@ -0,0 +1,272 @@
+
+/*
+ * lib_slk.c
+ * Soft key routines.
+ *
+ * Copyright (C) Gerhard Fuernkranz 1993
+ * Permisson is granted to redistribute this
+ * code under the terms of the GNU Copyleft.
+ */
+
+#include <nterm.h>
+#include "curses.priv.h"
+#include <string.h>
+#include <stdlib.h>
+
+int _slk_format; /* format specified in slk_init() */
+
+#define MAXCOLUMNS 135
+#define MAXLINES 66
+#define UNINITIALISED ((struct try * ) -1)
+/*
+ * Retrieve label text.
+ */
+
+char *
+slk_label(int n)
+{
+SLK *slk = SP->_slk;
+#ifdef TRACE
+ if (_tracing)
+ _tracef("slk_label(%d)", n);
+#endif
+
+ if (slk == NULL || n < 1 || n > 8)
+ return NULL;
+ return slk->ent[n-1].text;
+}
+
+/*
+ * Write the soft lables to the slk window.
+ */
+
+static void
+slk_intern_refresh(SLK *slk)
+{
+int i;
+#ifdef TRACE
+ if (_tracing)
+ _tracef("slk_intern_refresh(%x)", slk);
+#endif
+
+ for (i = 0; i < 8; i++) {
+ if (slk->dirty || slk->ent[i].dirty) {
+ if (slk->ent[i].visible) {
+ wmove(slk->win,0,slk->ent[i].x);
+ wattrset(slk->win,A_REVERSE);
+ waddstr(slk->win,slk->ent[i].form_text);
+ wattrset(slk->win,A_NORMAL);
+ }
+ slk->ent[i].dirty = FALSE;
+ }
+ }
+ slk->dirty = FALSE;
+}
+
+/*
+ * Refresh the soft label window.
+ */
+
+int
+slk_noutrefresh(void)
+{
+SLK *slk = SP->_slk;
+#ifdef TRACE
+ if (_tracing)
+ _tracef("slk_noutrefresh()");
+#endif
+
+ if (slk == NULL)
+ return ERR;
+ if (slk->hidden)
+ return OK;
+ slk_intern_refresh(slk);
+ return wnoutrefresh(slk->win);
+}
+
+/*
+ * Refresh the soft label window.
+ */
+
+int
+slk_refresh(void)
+{
+SLK *slk = SP->_slk;
+#ifdef TRACE
+ if (_tracing)
+ _tracef("slk_refresh()");
+#endif
+
+ if (slk == NULL)
+ return ERR;
+ if (slk->hidden)
+ return OK;
+ slk_intern_refresh(slk);
+ return wrefresh(slk->win);
+}
+
+/*
+ * Restore the soft labels on the screen.
+ */
+
+int
+slk_restore(void)
+{
+SLK *slk = SP->_slk;
+#ifdef TRACE
+ if (_tracing)
+ _tracef("slk_restore()");
+#endif
+
+ if (slk == NULL)
+ return ERR;
+ slk->hidden = FALSE;
+ slk->dirty = TRUE;
+ return slk_refresh();
+}
+
+/*
+ * Set soft label text.
+ */
+
+int
+slk_set(int i, char *str, int format)
+{
+SLK *slk = SP->_slk;
+int len;
+#ifdef TRACE
+ if (_tracing)
+ _tracef("slk_set(%d, %s, %d)", i, str, format);
+#endif
+
+ if (slk == NULL || i < 1 || i > 8 || format < 0 || format > 2)
+ return ERR;
+ if (str == NULL)
+ str = "";
+ i--;
+ strncpy(slk->ent[i].text,str,8);
+ memset(slk->ent[i].form_text,' ',8);
+ slk->ent[i].text[8] = 0;
+ slk->ent[i].form_text[8] = 0;
+ len = strlen(slk->ent[i].text);
+ switch(format) {
+ case 0: /* left */
+ memcpy(slk->ent[i].form_text,slk->ent[i].text,len);
+ break;
+ case 1: /* center */
+ memcpy(slk->ent[i].form_text+(8-len)/2,slk->ent[i].text,len);
+ break;
+ case 2: /* right */
+ memcpy(slk->ent[i].form_text+8-len,slk->ent[i].text,len);
+ break;
+ }
+ slk->ent[i].dirty = TRUE;
+ return OK;
+}
+
+/*
+ * Pretend, that soft keys have been changed.
+ */
+
+int
+slk_touch(void)
+{
+SLK *slk = SP->_slk;
+#ifdef TRACE
+ if (_tracing)
+ _tracef("slk_touch()");
+#endif
+
+ if (slk == NULL)
+ return ERR;
+ slk->dirty = TRUE;
+ return OK;
+}
+
+/*
+ * Remove soft labels from the screen.
+ */
+
+int
+slk_clear(void)
+{
+SLK *slk = SP->_slk;
+#ifdef TRACE
+ if (_tracing)
+ _tracef("slk_clear()");
+#endif
+
+ if (slk == NULL)
+ return ERR;
+ slk->hidden = TRUE;
+ werase(slk->win);
+ return wrefresh(slk->win);
+}
+
+/*
+ * Initialize soft labels.
+ * Called from newterm()
+ */
+
+static int
+slk_initialize(WINDOW *stwin, int cols)
+{
+SLK *slk;
+int i, maxlab, x;
+#ifdef TRACE
+ if (_tracing)
+ _tracef("slk_initialize()");
+#endif
+
+ if ((SP->_slk = slk = (SLK*) calloc(1,sizeof(SLK))) == NULL)
+ return OK;
+ maxlab = (cols+1)/9;
+ for (i = 0; i < 8; i++) {
+ memset(slk->ent[i].form_text,' ',8);
+ slk->ent[i].visible = i < maxlab;
+ }
+ if (_slk_format == 1) { /* 4-4 */
+ int gap = cols - 64 - 6;
+ if (gap < 1)
+ gap = 1;
+ for (i = x = 0; i < 8; i++) {
+ slk->ent[i].x = x;
+ x += 8;
+ x += (i == 3) ? gap : 1;
+ }
+ }
+ else { /* 0 -> 3-2-3 */
+ int gap = (cols - 64 - 5) / 2;
+ if (gap < 1)
+ gap = 1;
+ for (i = x = 0; i < 8; i++) {
+ slk->ent[i].x = x;
+ x += 8;
+ 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.
+ */
+
+int
+slk_init(int format)
+{
+ if (format < 0 || format > 1)
+ return ERR;
+ _slk_format = format;
+ ripoffline(-1, slk_initialize);
+ return OK;
+}
+
diff --git a/lib/libncurses/lib_touch.c b/lib/libncurses/lib_touch.c
new file mode 100644
index 0000000..4d291b3
--- /dev/null
+++ b/lib/libncurses/lib_touch.c
@@ -0,0 +1,48 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** 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->_firstchar[line] != _NOCHANGE) return TRUE;
+ return FALSE;
+}
+
+int is_wintouched(WINDOW *win)
+{
+int i;
+
+ for (i = 0; i <= win->_maxy; i++)
+ if (win->_firstchar[i] != _NOCHANGE)
+ return TRUE;
+ return FALSE;
+}
+
+int wtouchln(WINDOW *win, int y, int n, int changed)
+{
+int i;
+
+ T(("wtouchln(%x,%d,%d,%d)", win, y, n, changed));
+
+ for (i = y; i < y+n; i++) {
+ win->_firstchar[i] = changed ? 0 : _NOCHANGE;
+ win->_lastchar[i] = changed ? win->_maxx : _NOCHANGE;
+ }
+ return OK;
+}
+
diff --git a/lib/libncurses/lib_trace.c b/lib/libncurses/lib_trace.c
new file mode 100644
index 0000000..c17f7dd
--- /dev/null
+++ b/lib/libncurses/lib_trace.c
@@ -0,0 +1,170 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+ * lib_trace.c - Tracing/Debugging routines
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <fcntl.h>
+#include <errno.h>
+#include "curses.priv.h"
+#include <nterm.h>
+
+#if defined(BRAINDEAD)
+extern int errno;
+#endif
+
+int _tracing = 0;
+
+static int tracefd;
+
+void _tracef(char *fmt, ...);
+
+void _init_trace()
+{
+static int been_here = 0;
+
+ if (! been_here) {
+ been_here = 1;
+
+ if ((tracefd = creat("trace", 0644)) < 0) {
+ write(2, "curses: Can't open 'trace' file: ", 33);
+ write(2, strerror(errno), strlen(strerror(errno)));
+ write(2, "\n", 1);
+ exit(1);
+ }
+ _tracef("TRACING NCURSES version %s", NCURSES_VERSION);
+ }
+}
+
+
+void traceon()
+{
+
+ _tracing = 1;
+}
+
+
+void traceoff()
+{
+
+ _tracing = 0;
+}
+
+char *_traceattr(int newmode)
+{
+static char buf[BUFSIZ];
+struct {unsigned int val; char *name;}
+names[] =
+ {
+ {A_STANDOUT, "A_STANDOUT, ",},
+ {A_UNDERLINE, "A_UNDERLINE, ",},
+ {A_REVERSE, "A_REVERSE, ",},
+ {A_BLINK, "A_BLINK, ",},
+ {A_DIM, "A_DIM, ",},
+ {A_BOLD, "A_BOLD, ",},
+ {A_ALTCHARSET, "A_ALTCHARSET, ",},
+ {A_INVIS, "A_INVIS, ",},
+ {A_PROTECT, "A_PROTECT, ",},
+ {A_CHARTEXT, "A_CHARTEXT, ",},
+ {A_NORMAL, "A_NORMAL, ",},
+ },
+colors[] =
+ {
+ {COLOR_BLACK, "COLOR_BLACK",},
+ {COLOR_RED, "COLOR_RED",},
+ {COLOR_GREEN, "COLOR_GREEN",},
+ {COLOR_YELLOW, "COLOR_YELLOW",},
+ {COLOR_BLUE, "COLOR_BLUE",},
+ {COLOR_MAGENTA, "COLOR_MAGENTA",},
+ {COLOR_CYAN, "COLOR_CYAN",},
+ {COLOR_WHITE, "COLOR_WHITE",},
+ },
+ *sp;
+
+ strcpy(buf, "{");
+ for (sp = names; sp->val; sp++)
+ if (newmode & sp->val)
+ strcat(buf, sp->name);
+ if (newmode & A_COLOR)
+ {
+ int pairnum = PAIR_NUMBER(newmode);
+
+ (void) sprintf(buf + strlen(buf),
+ "COLOR_PAIR(%d) = (%s, %s), ",
+ pairnum,
+ colors[BG(color_pairs[pairnum])].name,
+ colors[FG(color_pairs[pairnum])].name
+ );
+ }
+ if ((newmode & A_ATTRIBUTES) == 0)
+ strcat(buf,"A_NORMAL, ");
+ if (buf[strlen(buf) - 2] == ',')
+ buf[strlen(buf) - 2] = '\0';
+ return(strcat(buf,"}"));
+}
+
+static char *visbuf(const char *buf)
+/* visibilize a given string */
+{
+ static char vbuf[BUFSIZ];
+ char *tp = vbuf;
+
+ while (*buf)
+ {
+ if (isprint(*buf) || *buf == ' ')
+ *tp++ = *buf++;
+ else if (*buf == '\n')
+ {
+ *tp++ = '\\'; *tp++ = 'n';
+ buf++;
+ }
+ else if (*buf == '\r')
+ {
+ *tp++ = '\\'; *tp++ = 'r';
+ buf++;
+ }
+ else if (*buf == '\b')
+ {
+ *tp++ = '\\'; *tp++ = 'b';
+ buf++;
+ }
+ else if (*buf == '\033')
+ {
+ *tp++ = '\\'; *tp++ = 'e';
+ buf++;
+ }
+ else if (*buf < ' ')
+ {
+ *tp++ = '\\'; *tp++ = '^'; *tp++ = '@' + *buf;
+ buf++;
+ }
+ else
+ {
+ (void) sprintf(tp, "\\0x%02x", *buf++);
+ tp += strlen(tp);
+ }
+ }
+ *tp++ = '\0';
+ return(vbuf);
+}
+
+void
+_tracef(char *fmt, ...)
+{
+va_list ap;
+char buffer[256];
+char *vp;
+
+ va_start(ap, fmt);
+ vsprintf(buffer, fmt, ap);
+ vp = visbuf(buffer);
+ write(tracefd, vp, strlen(vp));
+ write(tracefd, "\n", 1);
+}
+
diff --git a/lib/libncurses/lib_tstp.c b/lib/libncurses/lib_tstp.c
new file mode 100644
index 0000000..691dcd3
--- /dev/null
+++ b/lib/libncurses/lib_tstp.c
@@ -0,0 +1,47 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_tstp.c
+**
+** The routine tstp().
+**
+*/
+
+#include "curses.priv.h"
+#include <nterm.h>
+#ifdef SVR4_ACTION
+#define _POSIX_SOURCE
+#endif
+#include <signal.h>
+
+void tstp(int dummy)
+{
+sigaction_t act, oact;
+sigset_t mask;
+
+ T(("tstp() called"));
+
+ endwin();
+
+ sigemptyset(&mask);
+ sigaddset(&mask, SIGTSTP);
+ sigprocmask(SIG_UNBLOCK, &mask, NULL);
+
+ act.sa_handler = SIG_DFL;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+ sigaction(SIGTSTP, &act, &oact);
+ kill(getpid(), SIGTSTP);
+
+ T(("SIGCONT received"));
+ sigaction(SIGTSTP, &oact, NULL);
+ reset_prog_mode();
+ flushinp();
+ if (enter_ca_mode)
+ tputs(enter_ca_mode, 1, _outc);
+ doupdate();
+}
+
diff --git a/lib/libncurses/lib_twait.c b/lib/libncurses/lib_twait.c
new file mode 100644
index 0000000..01e7ffa
--- /dev/null
+++ b/lib/libncurses/lib_twait.c
@@ -0,0 +1,59 @@
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_twait.c
+**
+** The routine timed_wait().
+**
+*/
+
+#include <string.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include "curses.priv.h"
+
+int timed_wait(int fd, int wait, int *timeleft)
+{
+int result;
+struct timeval timeout;
+static fd_set set;
+#ifndef GOOD_SELECT
+struct timeval starttime, returntime;
+
+ gettimeofday(&starttime, NULL);
+#endif
+
+ FD_ZERO(&set);
+ FD_SET(fd, &set);
+
+ /* the units of wait are milliseconds */
+ timeout.tv_sec = wait / 1000;
+ timeout.tv_usec = (wait % 1000) * 1000;
+
+ T(("start twait: sec = %d, usec = %d", timeout.tv_sec, timeout.tv_usec));
+
+ result = select(fd+1, &set, NULL, NULL, &timeout);
+
+#ifndef GOOD_SELECT
+ gettimeofday(&returntime, NULL);
+ timeout.tv_sec -= (returntime.tv_sec - starttime.tv_sec);
+ timeout.tv_usec -= (returntime.tv_usec - starttime.tv_usec);
+ if (timeout.tv_usec < 0 && timeout.tv_sec > 0) {
+ timeout.tv_sec--;
+ timeout.tv_usec += 1000000;
+ }
+ if (timeout.tv_sec < 0)
+ timeout.tv_sec = timeout.tv_usec = 0;
+#endif
+
+ /* return approximate time left on the timeout, in milliseconds */
+ if (timeleft)
+ *timeleft = (timeout.tv_sec * 1000) + (timeout.tv_usec / 1000);
+
+ T(("end twait: returned %d, sec = %d, usec = %d (%d msec)",
+ result, timeout.tv_sec, timeout.tv_usec, *timeleft));
+
+ return(result);
+}
diff --git a/lib/libncurses/lib_unctrl.c b/lib/libncurses/lib_unctrl.c
new file mode 100644
index 0000000..3c8f583
--- /dev/null
+++ b/lib/libncurses/lib_unctrl.c
@@ -0,0 +1,26 @@
+#include <ctype.h>
+#include <unctrl.h>
+
+char *
+ unctrl(register unsigned char uch)
+{
+ static char buffer[3] = "^x";
+
+ if (isgraph(uch)) {
+ /*
+ * Printable character. Simply return the character as a one-character
+ * string.
+ */
+ buffer[1] = uch;
+ return &buffer[1];
+ }
+ uch &= ~0x80;
+ /*
+ * 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/libncurses/lib_vidattr.c b/lib/libncurses/lib_vidattr.c
new file mode 100644
index 0000000..a3bd4c7
--- /dev/null
+++ b/lib/libncurses/lib_vidattr.c
@@ -0,0 +1,185 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+ * 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 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 <string.h>
+#include "curses.priv.h"
+#include <nterm.h>
+
+static void do_color(int pair, int (*outc)(char))
+{
+short fg, bg;
+
+ if ( pair == 0 ) {
+ tputs(orig_pair, 1, outc);
+ } else {
+ fg = FG(color_pairs[pair]);
+ bg = BG(color_pairs[pair]);
+
+ T(("setting colors: pair = %d, fg = %d, bg = %d\n", pair, fg, bg));
+
+ if (set_a_foreground)
+ tputs(tparm(set_a_foreground, fg), 1, outc);
+ else
+ tputs(tparm(set_foreground, fg), 1, outc);
+ if (set_a_background)
+ tputs(tparm(set_a_background, bg), 1, outc);
+ else
+ tputs(tparm(set_background, bg), 1, outc);
+ }
+}
+
+static int current_pair = 0;
+static chtype previous_attr = 0;
+
+int vidputs(chtype newmode, int (*outc)(char))
+{
+chtype turn_off, turn_on;
+
+ T(("vidputs(%x) called %s", newmode, _traceattr(newmode)));
+ T(("previous attribute was %s", _traceattr(previous_attr)));
+
+ if (newmode == A_NORMAL && exit_attribute_mode) {
+ tputs(exit_attribute_mode, 1, outc);
+ current_pair = -1;
+ goto set_color;
+ }
+ else if (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);
+ goto set_color;
+ } else {
+ if (exit_attribute_mode) {
+ if((previous_attr & A_ALTCHARSET) && exit_alt_charset_mode) {
+ tputs(exit_alt_charset_mode, 1, outc);
+ previous_attr &= ~A_ALTCHARSET;
+ }
+ if (previous_attr) {
+ T(("exiting attribute mode"));
+
+ tputs(exit_attribute_mode, 1, outc);
+ previous_attr = 0;
+ current_pair = -1;
+ }
+ } else {
+ turn_off = ~newmode & previous_attr;
+
+ T(("turning %x off", turn_off));
+
+ if ((turn_off & A_ALTCHARSET) && exit_alt_charset_mode)
+ tputs(exit_alt_charset_mode, 1, outc);
+
+ if ((turn_off & A_BOLD) && exit_standout_mode)
+ tputs(exit_standout_mode, 1, outc);
+
+ if ((turn_off & A_DIM) && exit_standout_mode)
+ tputs(exit_standout_mode, 1, outc);
+
+ if ((turn_off & A_BLINK) && exit_standout_mode)
+ tputs(exit_standout_mode, 1, outc);
+
+ if ((turn_off & A_INVIS) && exit_standout_mode)
+ tputs(exit_standout_mode, 1, outc);
+
+ if ((turn_off & A_PROTECT) && exit_standout_mode)
+ tputs(exit_standout_mode, 1, outc);
+
+ if ((turn_off & A_UNDERLINE) && exit_underline_mode)
+ tputs(exit_underline_mode, 1, outc);
+
+ if ((turn_off & A_REVERSE) && exit_standout_mode)
+ tputs(exit_standout_mode, 1, outc);
+
+ if ((turn_off & A_STANDOUT) && exit_standout_mode)
+ tputs(exit_standout_mode, 1, outc);
+ }
+
+ turn_on = newmode & ~previous_attr;
+
+ T(("turning %x on", turn_on));
+
+ if ((turn_on & A_ALTCHARSET) && enter_alt_charset_mode)
+ tputs(enter_alt_charset_mode, 1, outc);
+
+ if ((turn_on & A_BLINK) && enter_blink_mode)
+ tputs(enter_blink_mode, 1, outc);
+
+ if ((turn_on & A_BOLD) && enter_bold_mode)
+ tputs(enter_bold_mode, 1, outc);
+
+ if ((turn_on & A_DIM) && enter_dim_mode)
+ tputs(enter_dim_mode, 1, outc);
+
+ if ((turn_on & A_REVERSE) && enter_reverse_mode)
+ tputs(enter_reverse_mode, 1, outc);
+
+ if ((turn_on & A_STANDOUT) && enter_standout_mode)
+ tputs(enter_standout_mode, 1, outc);
+
+ if ((turn_on & A_PROTECT) && enter_protected_mode)
+ tputs(enter_protected_mode, 1, outc);
+
+ if ((turn_on & A_INVIS) && enter_secure_mode)
+ tputs(enter_secure_mode, 1, outc);
+
+ if ((turn_on & A_UNDERLINE) && enter_underline_mode)
+ tputs(enter_underline_mode, 1, outc);
+ set_color:
+ if (_coloron) {
+ int pair = PAIR_NUMBER(newmode);
+
+ T(("old pair = %d -- new pair = %d", current_pair, pair));
+ if (pair != current_pair) {
+ current_pair = pair;
+ do_color(pair, outc);
+ }
+ }
+ }
+
+
+ previous_attr = newmode;
+
+ T(("vidputs finished"));
+ return OK;
+}
+
+int vidattr(chtype newmode)
+{
+
+ T(("vidattr(%x) called", newmode));
+
+ return(vidputs(newmode, _outc));
+}
+
diff --git a/lib/libncurses/lib_window.c b/lib/libncurses/lib_window.c
new file mode 100644
index 0000000..ec18694
--- /dev/null
+++ b/lib/libncurses/lib_window.c
@@ -0,0 +1,84 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+/*
+** lib_window.c
+**
+**
+*/
+
+#include <string.h>
+#include "curses.priv.h"
+
+int mvder(WINDOW *win, int y, int x)
+{
+
+}
+
+void wsyncup(WINDOW *win)
+{
+
+}
+
+int syncok(WINDOW *win, bool bf)
+{
+
+}
+
+void wcursyncup(WINDOW *win)
+{
+
+}
+
+void wsyncdown(WINDOW *win)
+{
+
+}
+
+WINDOW *dupwin(WINDOW *win)
+{
+WINDOW *nwin;
+#ifdef TRACE
+ if (_tracing)
+ _tracef("dupwin(%x) called", win);
+#endif
+
+ if ((nwin = newwin(win->_maxy, win->_maxx, win->_bey, 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->_clear = win->_clear;
+ nwin->_scroll = win->_scroll;
+ nwin->_leave = win->_leave;
+ nwin->_use_keypad = win->_use_keypad;
+ nwin->_use_meta = win->_use_meta;
+ 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;
+
+ for (i = 0; i < nwin->_cury; i++) {
+ memcpy(nwin->_line[i], win->_line[i], win->_maxx * sizeof(chtype));
+ nwin->_firstchar[i] = win->_firstchar[i];
+ nwin->_lastchar[i] = win->_lastchar[i];
+ }
+
+ return nwin;
+}
+
diff --git a/lib/libncurses/ncurses.3 b/lib/libncurses/ncurses.3
new file mode 100644
index 0000000..e8d74bb
--- /dev/null
+++ b/lib/libncurses/ncurses.3
@@ -0,0 +1,433 @@
+.TH ncurses 3X ""
+.ds n 5
+.ds d /usr/lib/terminfo
+.SH NAME
+\fBncurses\fR - CRT screen handling and optimization package
+.SH SYNOPSIS
+\fB#include <ncurses.h>\fR
+.br
+.SH DESCRIPTION
+The \fBncurses\fR library routines give the user a terminal-independent
+method of updating character screens with reasonable optimization.
+
+The \fBncurses\fR routines emulate the \fBcurses\fR(3X) library of System V
+Release 4 UNIX, but is freely redistributable in source form. Differences from
+the SVr4 curses are described in the BUGS sections of individual man pages.
+There are only few of these, and as ncurses matures they will become fewer
+still.
+
+A program using these routines must be linked with the \fB-lncurses\fR option,
+or (if they have been generated) with one of the debugging libraries
+\fB-ldcurses\fR or \fB-lpcurses\fR. The dcurses library generates trace logs
+that describe curses actions; the pcurses library supports profiling.
+
+The \fBncurses\fR package supports: overall screen, window and pad
+manipulation; output to windows and pads; reading terminal input; control over
+terminal and \fBncurses\fR input and output options; environment query
+routines; color manipulation; use of soft label keys; terminfo capabilities;
+and access to low-level \fBncurses\fR 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(); intrflush(stdscr,FALSE); keypad(stdscr,TRUE);\fR
+
+Before a \fBncurses\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.
+[See \fBterminfo\fR(\*n) for further details.]
+
+The \fBncurses\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.
+
+Windows are referred to by variables declared as \fBWINDOW *\fR.
+These data structures are manipulated with routines described on 3X
+pages (whose names begin "curs_"). 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 \fBncurses\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, \fBncurses\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<ncurses.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
+\fBncurses\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, \fBncurses\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<ncurses.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 \fBncurses\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 \fBncurses\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<ncurses.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 \fBncurses\fR routine and the name of
+the manual page on which it is described.
+
+.nf
+\fBncurses\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(\*n)
+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)
+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)
+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(\*n)
+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(\*n)
+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(\*n)
+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(\*n)
+set_term curs_initscr(3X)
+setscrreg curs_outopts(3X)
+setsyx curs_kernel(3X)
+setterm curs_terminfo(\*n)
+setupterm curs_terminfo(\*n)
+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(\*n)
+tigetnum curs_terminfo(\*n)
+tigetstr curs_terminfo(\*n)
+timeout curs_inopts(3X)
+touchline curs_touch(3X)
+touchwin curs_touch(3X)
+tparm curs_terminfo(\*n)
+tputs curs_termcap(3X)
+tputs curs_terminfo(\*n)
+typeahead curs_inopts(3X)
+unctrl curs_util(3X)
+ungetch curs_getch(3X)
+untouchwin curs_touch(3X)
+use_env curs_util(3X)
+vidattr curs_terminfo(\*n)
+vidputs curs_terminfo(\*n)
+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)
+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)
+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 NOTES
+The header file \fB<ncurses.h>\fR automatically includes the header files
+\fB<stdio.h>\fR and \fB<unctrl.h>\fR.
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libncurses/ncurses.h b/lib/libncurses/ncurses.h
new file mode 100644
index 0000000..743a50b
--- /dev/null
+++ b/lib/libncurses/ncurses.h
@@ -0,0 +1,497 @@
+
+/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
+* details. If they are missing then this copy is in violation of *
+* the copyright conditions. */
+
+#ifndef __NCURSES_H
+#define __NCURSES_H
+#define CURSES 1
+#define CURSES_H 1
+
+#include <stdio.h>
+#include <stdarg.h>
+#ifndef NOTERMIOS
+#include <termios.h>
+#else
+#include <sgtty.h>
+#include <sys/ioctl.h>
+#endif
+#include <unctrl.h>
+
+#define bool char
+
+typedef unsigned long chtype;
+
+/* 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_CHARTEXT 0x000000ff
+#define A_COLOR 0x0000ff00
+#define COLOR_PAIR(n) (n << 8)
+#define PAIR_NUMBER(a) ((a & A_COLOR) >> 8)
+
+/* colors */
+extern int COLORS;
+extern int COLOR_PAIRS;
+extern unsigned char color_pairs[];
+
+#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
+
+/* line graphics */
+
+extern chtype acs_map[];
+
+
+#define ACS_ULCORNER (acs_map['l'])
+#define ACS_LLCORNER (acs_map['m'])
+#define ACS_URCORNER (acs_map['k'])
+#define ACS_LRCORNER (acs_map['j'])
+#define ACS_RTEE (acs_map['u'])
+#define ACS_LTEE (acs_map['t'])
+#define ACS_BTEE (acs_map['v'])
+#define ACS_TTEE (acs_map['w'])
+#define ACS_HLINE (acs_map['q'])
+#define ACS_VLINE (acs_map['x'])
+#define ACS_PLUS (acs_map['n'])
+#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 */
+#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 */
+
+#ifndef TRUE
+# define TRUE (1)
+# define FALSE (0)
+#endif
+
+#define ERR (-1)
+#define OK (0)
+
+#define _SUBWIN 0x01
+#define _ENDLINE 0x02
+#define _FULLWIN 0x04
+#define _SCROLLWIN 0x08
+#define _ISPAD 0x10
+#define _HASMOVED 0x20
+
+#define _NOCHANGE -1
+
+typedef struct screen SCREEN;
+typedef struct _win_st WINDOW;
+
+struct _win_st {
+ short _cury, _curx; /* current cursor position */
+ short _maxy, _maxx; /* maximum values of x and y NOT the screen dimensions */
+ short _begy, _begx;
+ short _flags;
+ chtype _attrs;
+ chtype _bkgd;
+
+ /* The following should be consolidated into one bitset */
+ bool _notimeout;
+ bool _use_idc;
+ bool _clear;
+ bool _leave;
+ bool _scroll;
+ bool _idlok;
+ bool _immed;
+ bool _sync;
+ bool _use_keypad; /* 0=no, 1=yes */
+ bool _use_meta; /* T=use the meta key */
+
+ int _delay; /* 0 = nodelay
+ <0 = blocking
+ >0 = delay */
+ chtype **_line;
+ short *_firstchar; /* First changed character in the line */
+ short *_lastchar; /* Last changed character in the line */
+ short _regtop; /* Top and bottom of scrolling region */
+ short _regbottom;
+ int _parx;
+ int _pary;
+ WINDOW *_parent; /* parent if a sub-window */
+};
+
+extern WINDOW *stdscr, *curscr;
+
+extern int LINES, COLS;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern char ttytype[]; /* needed for backward compatibility */
+
+extern int tigetflag(char *);
+extern int tigetnum(char *);
+extern char *tigetstr(char *);
+
+/* Debugging : use with libdcurses.a */
+
+extern void _init_trace(void);
+extern void _tracef(char *, ...);
+extern char *_traceattr(int mode);
+extern void traceon(void);
+extern void traceoff(void);
+
+/* function prototypes */
+
+extern int baudrate(void);
+extern int beep(void);
+extern int cbreak(void);
+extern int clearok(WINDOW *,int);
+extern int copywin(WINDOW *,WINDOW *,int,int,int,int,int,int,int);
+extern int crmode(void);
+extern int curs_set(int);
+extern int def_prog_mode(void);
+extern int def_shell_mode(void);
+extern int delwin(WINDOW *);
+extern WINDOW *derwin(WINDOW *,int,int,int,int);
+extern int doupdate(void);
+extern int echo(void);
+extern int endwin(void);
+extern char erasechar(void);
+extern int flash(void);
+extern int flushinp(void);
+extern int idlok(WINDOW *,int);
+extern int is_linetouched(WINDOW *,int);
+extern int is_wintouched(WINDOW *);
+extern WINDOW *initscr(void);
+extern int isendwin(void);
+extern char *keyname(int);
+extern int keypad(WINDOW *,int);
+extern char killchar(void);
+extern int leaveok(WINDOW *,int);
+extern char *longname(void);
+extern int meta(WINDOW *,int);
+extern int mvcur(int,int,int,int);
+extern int mvprintw(int,int,char *,...);
+extern int mvscanw(int,int,char *,...);
+extern int mvwin(WINDOW *,int,int);
+extern int mvwprintw(WINDOW *,int,int,char *,...);
+extern int mvwscanw(WINDOW *,int,int,char *,...);
+extern WINDOW *newpad(int,int);
+extern SCREEN *newterm(char *,FILE *,FILE *);
+extern WINDOW *newwin(int,int,int,int);
+extern int nl(void);
+extern int nocbreak(void);
+extern int nocrmode(void);
+extern int nodelay(WINDOW *,int);
+extern int noecho(void);
+extern int nonl(void);
+extern int noraw(void);
+extern int overlay(WINDOW *,WINDOW *);
+extern int overwrite(WINDOW *,WINDOW *);
+extern int pnoutrefresh(WINDOW *,int,int,int,int,int,int);
+extern int prefresh(WINDOW *,int,int,int,int,int,int);
+extern int printw(char *,...);
+extern int putp(char *);
+extern int raw(void);
+extern int reset_prog_mode(void);
+extern int reset_shell_mode(void);
+extern int resetty(void);
+extern int ripoffline(int line, int (*init)(WINDOW *, int));
+extern int savetty(void);
+extern int scanw(char *,...);
+extern int scrollok(WINDOW *,int);
+extern SCREEN *set_term(SCREEN *);
+extern int setupterm(char *,int,int *);
+extern WINDOW *subwin(WINDOW *,int,int,int,int);
+extern char *tgoto(char *,int,int);
+extern int timeout(int);
+extern char *tparm(char *, ...);
+extern int tputs(char *,int,int (*)(char));
+extern int ungetch(int);
+extern int vidattr(chtype);
+extern int vidputs(chtype,int (*)(char));
+extern int vwscanw(WINDOW *,char *,va_list);
+extern int vwprintw(WINDOW *,char *,va_list);
+extern int waddch(WINDOW *,chtype);
+extern int waddchnstr(WINDOW *,chtype *,int);
+extern int waddnstr(WINDOW *,char *,int);
+extern int wattron(WINDOW *,chtype);
+extern int wborder(WINDOW *,chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype);
+extern int wclear(WINDOW *);
+extern int wclrtobot(WINDOW *);
+extern int wclrtoeol(WINDOW *);
+extern int wdelch(WINDOW *);
+extern int wdeleteln(WINDOW *);
+extern int werase(WINDOW *);
+extern int wgetch(WINDOW *);
+extern int wgetnstr(WINDOW *,char *,int maxlen);
+extern int whline(WINDOW *,chtype,int);
+extern int winsch(WINDOW *,chtype);
+extern int winsdel(WINDOW *,int);
+extern int winsertln(WINDOW *);
+extern int winsnstr(WINDOW *,char *,int);
+extern int wmove(WINDOW *,int,int);
+extern int wnoutrefresh(WINDOW *);
+extern int wprintw(WINDOW *,char *,...);
+extern int redrawln(WINDOW *,int,int);
+extern int wrefresh(WINDOW *);
+extern int wscanw(WINDOW *,char *,...);
+extern int wscrl(WINDOW *,int);
+extern int wsetscrreg(WINDOW *,int,int);
+extern int wtimeout(WINDOW *,int);
+extern int wtouchln(WINDOW *,int,int,int);
+extern int wvline(WINDOW *,chtype,int);
+
+extern bool can_change_color(void);
+extern int color_content(short,short *,short *, short *);
+extern int has_colors(void);
+extern int init_color(short,short,short,short);
+extern int init_pair(short,short,short);
+extern int pair_content(short,short*,short*);
+extern int start_color(void);
+
+extern int slk_init(int);
+extern int slk_set(int,char *,int);
+extern int slk_refresh(void);
+extern int slk_noutrefresh(void);
+extern char *slk_label(int);
+extern int slk_clear(void);
+extern int slk_restore(void);
+extern int slk_touch(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*
+ * pseudo functions
+ */
+#define wgetstr(w, s) wgetnstr(w, s, -1)
+
+#define napms(x) usleep(1000*x)
+#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 getsyx(y,x) getyx(stdscr, y, x)
+#define setsyx(y,x) (stdscr->_cury = y, stdscr->_curx = x)
+
+/* It seems older SYSV curses 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][(win)->_curx])
+#define wstandout(win) (wattrset(win,A_STANDOUT))
+#define wstandend(win) (wattrset(win,A_NORMAL))
+#define wattroff(win,at) ((win)->_attrs &= ~(at))
+#define wattrset(win,at) ((win)->_attrs = (at))
+
+#define subpad(p,l,c,y,x) derwin(p,l,c,y,x)
+#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 winsstr(w, s) winsnstr(w, s, 0)
+
+#define redrawwin(w) redrawln(w, 0, w->_maxy+1)
+
+/*
+ * psuedo functions for standard screen
+ */
+
+#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 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() winsertln(stdscr)
+#define deleteln() wdeleteln(stdscr)
+#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 waddstr(win,str) waddnstr(win,str,-1)
+#define waddchstr(win,str) waddchnstr(win,str,-1)
+#define addchstr(str) waddchstr(stdscr, str)
+#define addchnstr(str, n) waddchnstr(stdscr, str, n)
+#define insdel(n) winsdel(stdscr, n)
+#define insstr(s) winsstr(stdscr, s)
+#define insnstr(s, n) winsnstr(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 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 mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch)
+#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 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)
+
+/* Funny "characters" enabled for various special function keys for input */
+/* Whether such a key exists depend if its definition is in the terminfo entry */
+
+#define KEY_MIN 0401 /* Minimum curses key */
+#define KEY_BREAK 0401 /* break key (unreliable) */
+#define KEY_DOWN 0402 /* The four arrow keys ... */
+#define KEY_UP 0403
+#define KEY_LEFT 0404
+#define KEY_RIGHT 0405 /* ... */
+#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)) /* keys is reserved. */
+#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 backwards (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 or copy */
+#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 key */
+#define KEY_BEG 0542 /* beg(inning) key */
+#define KEY_CANCEL 0543 /* cancel key */
+#define KEY_CLOSE 0544 /* close key */
+#define KEY_COMMAND 0545 /* cmd (command) key */
+#define KEY_COPY 0546 /* copy key */
+#define KEY_CREATE 0547 /* create key */
+#define KEY_END 0550 /* end key */
+#define KEY_EXIT 0551 /* exit key */
+#define KEY_FIND 0552 /* find key */
+#define KEY_HELP 0553 /* help key */
+#define KEY_MARK 0554 /* mark key */
+#define KEY_MESSAGE 0555 /* message key */
+#define KEY_MOVE 0556 /* move key */
+#define KEY_NEXT 0557 /* next object key */
+#define KEY_OPEN 0560 /* open key */
+#define KEY_OPTIONS 0561 /* options key */
+#define KEY_PREVIOUS 0562 /* previous object key */
+#define KEY_REDO 0563 /* redo key */
+#define KEY_REFERENCE 0564 /* ref(erence) key */
+#define KEY_REFRESH 0565 /* refresh key */
+#define KEY_REPLACE 0566 /* replace key */
+#define KEY_RESTART 0567 /* restart key */
+#define KEY_RESUME 0570 /* resume key */
+#define KEY_SAVE 0571 /* save key */
+#define KEY_SBEG 0572 /* shifted beginning key */
+#define KEY_SCANCEL 0573 /* shifted cancel key */
+#define KEY_SCOMMAND 0574 /* shifted command key */
+#define KEY_SCOPY 0575 /* shifted copy key */
+#define KEY_SCREATE 0576 /* shifted create key */
+#define KEY_SDC 0577 /* shifted delete char key */
+#define KEY_SDL 0600 /* shifted delete line key */
+#define KEY_SELECT 0601 /* select key */
+#define KEY_SEND 0602 /* shifted end key */
+#define KEY_SEOL 0603 /* shifted clear line key */
+#define KEY_SEXIT 0604 /* shifted exit key */
+#define KEY_SFIND 0605 /* shifted find key */
+#define KEY_SHELP 0606 /* shifted help key */
+#define KEY_SHOME 0607 /* shifted home key */
+#define KEY_SIC 0610 /* shifted input key */
+#define KEY_SLEFT 0611 /* shifted left arrow key */
+#define KEY_SMESSAGE 0612 /* shifted message key */
+#define KEY_SMOVE 0613 /* shifted move key */
+#define KEY_SNEXT 0614 /* shifted next key */
+#define KEY_SOPTIONS 0615 /* shifted options key */
+#define KEY_SPREVIOUS 0616 /* shifted prev key */
+#define KEY_SPRINT 0617 /* shifted print key */
+#define KEY_SREDO 0620 /* shifted redo key */
+#define KEY_SREPLACE 0621 /* shifted replace key */
+#define KEY_SRIGHT 0622 /* shifted right arrow */
+#define KEY_SRSUME 0623 /* shifted resume key */
+#define KEY_SSAVE 0624 /* shifted save key */
+#define KEY_SSUSPEND 0625 /* shifted suspend key */
+#define KEY_SUNDO 0626 /* shifted undo key */
+#define KEY_SUSPEND 0627 /* suspend key */
+#define KEY_UNDO 0630 /* undo key */
+#define KEY_MAX 0777 /* Maximum curses key */
+
+#endif
diff --git a/lib/libncurses/nterm.h b/lib/libncurses/nterm.h
new file mode 100644
index 0000000..bcbf315
--- /dev/null
+++ b/lib/libncurses/nterm.h
@@ -0,0 +1,6 @@
+/* libmytinfo must be installed first */
+#include <term.h>
+#define Filedes fd
+#define Ottyb shell_mode
+#define Nttyb prog_mode
+#define TTY struct termios
diff --git a/lib/libncurses/term.5 b/lib/libncurses/term.5
new file mode 100644
index 0000000..68f5d7f
--- /dev/null
+++ b/lib/libncurses/term.5
@@ -0,0 +1,153 @@
+.TH TERM 5
+.ds n 5
+.ds d /usr/lib/terminfo
+.SH NAME
+term \- format of compiled term file.
+.SH SYNOPSIS
+.B term
+.SH DESCRIPTION
+.PP
+Compiled terminfo descriptions are placed under the directory \fB\*d\fP.
+In order to avoid a linear search of a huge \s-1UNIX\s+1 system directory, a
+two-level scheme is used: \fB\*b/c/name\fP
+where
+.I name
+is the name of the terminal, and
+.I c
+is the first character of
+.IR name .
+Thus,
+.I act4
+can be found in the file \fB\*d/a/act4\fP.
+Synonyms for the same terminal are implemented by multiple
+links to the same compiled file.
+.PP
+The format has been chosen so that it will be the same on all hardware.
+An 8 or more bit byte is assumed, but no assumptions about byte ordering
+or sign extension are made.
+.PP
+The compiled file is created with the
+.I tic
+program, and read by the routine
+.IR setupterm .
+Both of these pieces of software are part of
+.IR ncurses (3X).
+The file is divided into six parts:
+the header,
+terminal names,
+boolean flags,
+numbers,
+strings,
+and
+string table.
+.PP
+The header section begins the file.
+This section contains six short integers in the format
+described below.
+These integers are
+(1) the magic number (octal 0432);
+(2) the size, in bytes, of the names section;
+(3) the number of bytes in the boolean section;
+(4) the number of short integers in the numbers section;
+(5) the number of offsets (short integers) in the strings section;
+(6) the size, in bytes, of the string table.
+.PP
+Short integers are stored in two 8-bit bytes.
+The first byte contains the least significant 8 bits of the value,
+and the second byte contains the most significant 8 bits.
+(Thus, the value represented is 256*second+first.)
+The value \-1 is represented by 0377, 0377, other negative
+value are illegal.
+The
+\-1 generally means that a capability is missing from this terminal.
+Note that this format corresponds to the hardware of the \s-1VAX\s+1 and \s-1PDP\s+1-11.
+Machines where this does not correspond to the hardware read the
+integers as two bytes and compute the result.
+.PP
+The terminal names section comes next.
+It contains the first line of the terminfo description,
+listing the various names for the terminal,
+separated by the `|' character.
+The section is terminated with an \s-1ASCII NUL\s+1 character.
+.PP
+The boolean flags have one byte for each flag.
+This byte is either 0 or 1 as the flag is present or absent.
+The capabilities are in the same order as the file <term.h>.
+.PP
+Between the boolean section and the number section,
+a null byte will be inserted, if necessary,
+to ensure that the number section begins on an even byte.
+All short integers are aligned on a short word boundary.
+.PP
+The numbers section is similar to the flags section.
+Each capability takes up two bytes,
+and is stored as a short integer.
+If the value represented is \-1, the capability is taken to be missing.
+.PP
+The strings section is also similar.
+Each capability is stored as a short integer, in the format above.
+A value of \-1 means the capability is missing.
+Otherwise, the value is taken as an offset from the beginning
+of the string table.
+Special characters in ^X or \ec notation are stored in their
+interpreted form, not the printing representation.
+Padding information $<nn> and parameter information %x are
+stored intact in uninterpreted form.
+.PP
+The final section is the string table.
+It contains all the values of string capabilities referenced in
+the string section.
+Each string is null terminated.
+.PP
+Note that it is possible for
+.I setupterm
+to expect a different set of capabilities
+than are actually present in the file.
+Either the database may have been updated since
+.I setupterm
+has been recompiled
+(resulting in extra unrecognized entries in the file)
+or the program may have been recompiled more recently
+than the database was updated
+(resulting in missing entries).
+The routine
+.I setupterm
+must be prepared for both possibilities \-
+this is why the numbers and sizes are included.
+Also, new capabilities must always be added at the end of the lists
+of boolean, number, and string capabilities.
+.PP
+As an example, an octal dump of the description for the Microterm ACT 4
+is included:
+.nf
+.sp
+microterm|act4|microterm act iv,
+ cr=^M, cud1=^J, ind=^J, bel=^G, am, cub1=^H,
+ ed=^_, el=^^, clear=^L, cup=^T%p1%c%p2%c,
+ cols#80, lines#24, cuf1=^X, cuu1=^Z, home=^],
+.sp
+.ft CW
+\s-2000 032 001 \e0 025 \e0 \eb \e0 212 \e0 " \e0 m i c r
+020 o t e r m | a c t 4 | m i c r o
+040 t e r m a c t i v \e0 \e0 001 \e0 \e0
+060 \e0 \e0 \e0 \e0 \e0 \e0 \e0 \e0 \e0 \e0 \e0 \e0 \e0 \e0 \e0 \e0
+100 \e0 \e0 P \e0 377 377 030 \e0 377 377 377 377 377 377 377 377
+120 377 377 377 377 \e0 \e0 002 \e0 377 377 377 377 004 \e0 006 \e0
+140 \eb \e0 377 377 377 377 \en \e0 026 \e0 030 \e0 377 377 032 \e0
+160 377 377 377 377 034 \e0 377 377 036 \e0 377 377 377 377 377 377
+200 377 377 377 377 377 377 377 377 377 377 377 377 377 377 377 377
+*
+520 377 377 377 377 \e0 377 377 377 377 377 377 377 377 377 377
+540 377 377 377 377 377 377 007 \e0 \er \e0 \ef \e0 036 \e0 037 \e0
+560 024 % p 1 % c % p 2 % c \e0 \en \e0 035 \e0
+600 \eb \e0 030 \e0 032 \e0 \en \e0\s+2
+.ft R
+.fi
+.sp
+.PP
+Some limitations: total compiled entries cannot exceed 4096 bytes.
+The name field cannot exceed 128 bytes.
+.SH FILES
+\*d/*/* compiled terminal capability data base
+.SH "SEE ALSO"
+ncurses(3X), terminfo(\*n).
diff --git a/lib/libncurses/termcap.h b/lib/libncurses/termcap.h
new file mode 100644
index 0000000..05c86ca
--- /dev/null
+++ b/lib/libncurses/termcap.h
@@ -0,0 +1,32 @@
+
+
+#ifndef _TERMCAP_H
+#define _TERMCAP_H 1
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+#include <sys/cdefs.h>
+
+extern char PC;
+extern char *UP;
+extern char *BC;
+extern short ospeed;
+
+extern int tgetent __P((char *, const char *));
+extern int tgetflag __P((const char *));
+extern int tgetnum __P((const char *));
+extern char *tgetstr __P((const char *, char **));
+
+extern int tputs __P((const char *, int, int (*)(int)));
+
+extern char *tgoto __P((const char *, int, int));
+extern char *tparam __P((const char *, char *, int, ...));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _TERMCAP_H */
diff --git a/lib/libncurses/terminfo.5 b/lib/libncurses/terminfo.5
new file mode 100644
index 0000000..8c774f8
--- /dev/null
+++ b/lib/libncurses/terminfo.5
@@ -0,0 +1,1656 @@
+.\" Note: this must be run through tbl befor nroff
+.TH TERMINFO 5
+.ds n 5
+.ds d /usr/lib/terminfo
+.SH NAME
+terminfo \- terminal capability data base
+.SH SYNOPSIS
+\*d/*/*
+.SH DESCRIPTION
+.I Terminfo
+is a data base describing terminals, used by screen-oriented programs such as
+.IR vi (1),
+.IR rogue (1)
+and
+.IR ncurses (3X).
+.I Terminfo
+describes terminals by giving a set of capabilities which they
+have, by specifying how to perform screen operations, and by
+specifying padding requirements and initialization sequences.
+.PP
+Entries in
+.I terminfo
+consist of a number of `,' separated fields.
+White space after each `,' is ignored.
+The first entry for each terminal gives the names which are known for the
+terminal, separated by `|' characters.
+The first name given is the most common abbreviation for the terminal,
+the last name given should be a long name fully identifying the terminal,
+and all others are understood as synonyms for the terminal name.
+All names but the last should be in lower case and contain no blanks;
+the last name may well contain upper case and blanks for readability.
+.PP
+Terminal names (except for the last, verbose entry) should
+be chosen using the following conventions.
+The particular piece of hardware making up the terminal should
+have a root name chosen, thus ``hp2621''.
+This name should not contain hyphens, except that synonyms may
+be chosen that do not conflict with other names.
+Modes that the hardware can be in, or user preferences, should
+be indicated by appending a hyphen and an indicator of the mode.
+Thus, a vt100 in 132 column mode would be vt100-w.
+The following suffixes should be used where possible:
+.TS
+center;
+l c l
+l l l.
+\fBSuffix Meaning Example\fP
+-w Wide mode (more than 80 columns) vt100-w
+-am With auto. margins (usually default) vt100-am
+-nam Without automatic margins vt100-nam
+-\fIn\fP Number of lines on the screen aaa-60
+-na No arrow keys (leave them in local) c100-na
+-\fIn\fPp Number of pages of memory c100-4p
+-rv Reverse video c100-rv
+.TE
+.SH CAPABILITIES
+The variable is the name by which the programmer (at the terminfo level)
+accesses the capability.
+The capname is the short name used in the text of the database,
+and is used by a person updating the database.
+The i.code is the two letter internal code used in the compiled database,
+and always corresponds to the old
+.B termcap
+capability name.
+.P
+Capability names have no hard length limit, but an informal limit of 5
+characters has been adopted to keep them short and to allow the tabs in
+the source file
+.B caps
+to line up nicely.
+Whenever possible, names are chosen to be the same as or similar to
+the ANSI X3.64-1979 standard. Semantics are also intended to match
+those of the specification.
+.TP
+(P)
+indicates that padding may be specified
+.TP
+(G)
+indicates that the string is passed through tparm with
+parms as given (#\fIi\fP).
+.TP
+(*)
+indicates that padding may be based on the number of
+lines affected
+.TP
+(#\d\fIi\fP\u)
+indicates the \fIi\fP\uth\d parameter.
+
+.TS
+center;
+c c c c
+c c c c
+l l l l.
+\fBVariable Cap- I. Description\fR
+\f3Booleans name Code\fR
+\s-1auto_left_margin, bw bw cub1 wraps from column 0 to last
+ column\s+1
+\s-1auto_right_margin, am am Terminal has automatic margins\s+1
+\s-1back_color_erase, bce ut screen erased with background color\s+1
+\s-1can_change, ccc cc terminal can re-define exiting colors\s+1
+\s-1ceol_standout_glitch, xhp xs Standout not erased by overwriting
+ (hp)\s+1
+\s-1col_addr_glitch, xhpa YA only positive motion for hpa/mhpa caps\s+1
+\s-1cpi_changes_res, cpix YF changing character pitch changes resolution\s+1
+\s-1cr_cancels_micro_mode, crxm YB using cr turns off micro mode\s+1
+\s-1eat_newline_glitch, xenl xn newline ignored after 80 cols
+ (Concept)\s+1
+\s-1erase_overstrike, eo eo Can erase overstrikes with a blank\s+1
+\s-1generic_type, gn gn Generic line type (e.g.,, dialup,
+ switch).\s+1
+\s-1hard_copy, hc hc Hardcopy terminal\s+1
+\s-1hard_cursor, chts HC cursor is hard to see\s+1
+\s-1has_meta_key, km km Has a meta key (shift, sets parity
+ bit)\s+1
+\s-1has_print_wheel, daisy YC printer needs operator to change character set\s+1
+\s-1has_status_line, hs hs Has extra "status line"\s+1
+\s-1hue_lightness_saturation, hls hl terminal uses only HLS color notation (tektronix)\s+1
+\s-1insert_null_glitch, in in Insert mode distinguishes nulls\s+1
+\s-1lpi_changes_res, lpix YG chnaging line pitch changes resolution\s+1
+\s-1memory_above, da da Display may be retained above the
+ screen\s+1
+\s-1memory_below, db db Display may be retained below the
+ screen\s+1
+\s-1move_insert_mode, mir mi Safe to move while in insert mode\s+1
+\s-1move_standout_mode, msgr ms Safe to move in standout modes\s+1
+\s-1needs_xon_xoff, nxon nx padding won't work, xon/xoff required\s+1
+\s-1no_esc_ctl_c, xsb xb Beehive (f1=escape, f2=ctrl C)\s+1
+\s-1non_rev_rmcup, nrrmc NR smcup does not revrse rmcup\s+1
+\s-1no_pad_char, npc NP pad character does not exist\s+1
+\s-1non_dest_scroll_region, ndscr ND scrolling region is non-destructive\s+1
+\s-1over_strike, os os Terminal overstrikes\s+1
+\s-1prtr_silent, mc5i 5i printer won't echo on screen\s+1
+\s-1row_addr_glitch, xvpa YD only posistive motion for vhp/mvpa caps\s+1
+\s-1semi_auto_right_margin, sam YE printing in last column causes cr\s+1
+\s-1status_line_esc_ok, eslok es Escape can be used on the status line\s+1
+\s-1dest_tabs_magic_smso, xt xt Tabs ruin, magic so char (Teleray
+ 1061)\s+1
+\s-1tilde_glitch, hz hz Hazeltine; can not print ~'s\s+1
+\s-1transparent_underline, ul ul underline character overstrikes\s+1
+\s-1xon_xoff, xon xo Terminal uses xon/xoff handshaking\s+1
+
+\s-1\f3Numbers:\fR\s+1
+\s-1bit_image_entwining, bitwin Yo Undocumented in SVr4.0\s+1
+\s-1buffer_capacity, bufsz Ya numbers of bytes buffered before printing\s+1
+\s-1columns, cols co Number of columns in a line\s+1
+\s-1dot_vert_spacing, spinv Yb spacing of dots horizontally in dots per inch\s+1
+\s-1dot_horz_spacing, spinh Yc spacing of pins vertically in pins per inch\s+1
+\s-1init_tabs, it it Tabs initially every # spaces\s+1
+\s-1label_height, lh lh rows in each label\s+1
+\s-1label_width, lw lw columns in each label\s+1
+\s-1lines, lines li Number of lines on screen or page\s+1
+\s-1lines_of_memory, lm lm Lines of memory if > lines. 0 means varies\s+1
+\s-1magic_cookie_glitch, xmc sg Number of blank chars left by smso or rmso\s+1
+\s-1max_colors, colors Co maximum numbers of colors on screen\s+1
+\s-1max_micro_address, maddr Yd maximum value in micro_..._address\s+1
+\s-1max_micro_jump, mjump Ye maximum value in parm_..._micro\s+1
+\s-1max_pairs, pairs pa maximum number of color-pairs on the screen\s+1
+\s-1micro_col_size, mcs Yf Character step size when in micro mode\s+1
+\s-1micro_line_size, mls Yg Line step size when in micro mode\s+1
+\s-1no_color_video, ncv NC video attributes that can't be used with colors\s+1
+\s-1number_of_pins, npins Yh numbers of pins in print-head\s+1
+\s-1num_labels, nlab Nl number of lables on screen\s+1
+\s-1output_res_char, orc Yi horizontal resolution in units per line\s+1
+\s-1output_res_line, orl Yj vertical resolution in units per line\s+1
+\s-1output_res_horz_inch, orhi Yk horizontal resolution in units per inch\s+1
+\s-1output_res_vert_inch, orvi Yl vertical resolution in units per inch\s+1
+\s-1padding_baud_rate, pb pb Lowest baud where cr/nl padding is needed\s+1
+\s-1virtual_terminal, vt vt Virtual terminal number (\s-1UNIX\s+1 system)\s+1
+\s-1width_status_line, wsl ws No. columns in status line\s+1
+.TE
+
+(The following numeric capabilities are present in the SVr4.0 term structure,
+but are not yet documented in the man page. Comments are from the term
+structure header.)
+
+.TS
+center;
+c c c c
+c c c c
+l l l l.
+\s-1bit_image_type, bitype Yp Type of bit-image device\s+1
+\s-1buttons, btns BT Number of mouse buttons\s+1
+\s-1max_attributes, ma ma Max combined attributes terminal can handle\s+1
+\s-1maximum_windows, wnum MW Max number of defineable windows\s+1
+\s-1print_rate, cps Ym Print rate in chars per second\s+1
+\s-1wide_char_size, widcs Yn Char step size in double wide mode\s+1
+
+\s-1\f3Strings:\fR\s+1
+\s-1acs_chars, acsc ac Graphics charset pairs - def=vt100\s+1
+\s-1alt_scancode_esc, scesa S8 Alternate esc for scancode emulation (default is vt100)\s+1
+\s-1back_tab, cbt bt Back tab (P)\s+1
+\s-1bell, bel bl Audible signal (bell) (P)\s+1
+\s-1bit_image_repeat, birep Xy Repeat bit image cell #1 #2 times (use tparm)\s+1
+\s-1bit_image_newline, binel Zz Move to next row of the bit image (use tparm)\s+1
+\s-1bit_image_carriage_return, bicr Yv Move to beginning of same row (use tparm)\s+1
+\s-1carriage_return, cr cr Carriage return (P*)\s+1
+\s-1change_char_pitch, cpi ZA Change # chars per inch\s+1
+\s-1change_line_pitch, lpi ZB Change # lines per inch\s+1
+\s-1change_res_horz, chr ZC Change horizontal resolution\s+1
+\s-1change_res_vert, cvr ZD Change vertical resolution\s+1
+\s-1change_scroll_region, csr cs Change to lines #1 through #2 (vt100) (PG)\s+1
+\s-1char_padding, rmp rP Like ip but when in insert mode\s+1
+\s-1char_set_names, csnm Zy List of character set names\s+1
+\s-1clear_all_tabs, tbc ct Clear all tab stops (P)\s+1
+\s-1clear_margins, mgc MC Clear all margins (top, bottom, and sides)\s+1
+\s-1clear_screen, clear cl Clear screen and home cursor (P*)\s+1
+\s-1clr_bol. el1 cb Clear to beginning of line\s+1
+\s-1clr_eol, el ce Clear to end of line (P)\s+1
+\s-1clr_eos, ed cd Clear to end of display (P*)\s+1
+\s-1code_set_init, csin ci Init sequence for multiple code sets\s+1
+\s-1color_names, colornm Yw Give name for color #1\s+1
+\s-1column_address, hpa ch Set cursor column (PG)\s+1
+\s-1command_character, cmdch CC Term. settable cmd char in prototype\s+1
+\s-1cursor_address, cup cm Screen rel. cursor motion row #1
+ col #2 (PG)\s+1
+\s-1cursor_down, cud1 do Down one line\s+1
+\s-1cursor_home, home ho Home cursor (if no cup)\s+1
+\s-1cursor_invisible, civis vi Make cursor invisible\s+1
+\s-1cursor_left, cub1 le Move cursor left one space\s+1
+\s-1cursor_mem_address, mrcup CM Memory relative cursor addressing\s+1
+\s-1cursor_normal, cnorm ve Make cursor appear normal (undo vs/vi)\s+1
+\s-1cursor_right, cuf1 nd Non-destructive space (cursor right)\s+1
+\s-1cursor_to_ll, ll ll Last line, first column (if no cup)\s+1
+\s-1cursor_up, cuu1 up Upline (cursor up)\s+1
+\s-1cursor_visible, cvvis vs Make cursor very visible\s+1
+\s-1define_bit_image_region, defbi Yx Define rectangular bit image region (use tparm)\s+1
+\s-1define_char, defc ZE Define character in a character set\s+1
+\s-1delete_character, dch1 dc Delete character (P*)\s+1
+\s-1delete_line, dl1 dl Delete line (P*)\s+1
+\s-1device_type, devt dv Indicate language/codeset support\s+1
+\s-1dis_status_line, dsl ds Disable status line\s+1
+\s-1display_pc_char, dispc S1 Display PC character\s+1
+\s-1down_half_line, hd hd Half-line down (forward 1/2 linefeed)\s+1
+\s-1ena_acs, enacs eA enable alternate char set\s+1
+\s-1end_bit_image_region, endbi Yy End bit image region (use tparm)\s+1
+\s-1enter_alt_charset_mode, smacs as Start alternate character set (P)\s+1
+\s-1enter_am_mode, smam SA turn on automatic margins\s+1
+\s-1enter_blink_mode, blink mb Turn on blinking\s+1
+\s-1enter_bold_mode, bold md Turn on bold (extra bright) mode\s+1
+\s-1enter_ca_mode, smcup ti String to begin programs that use cup\s+1
+\s-1enter_delete_mode, smdc dm Delete mode (enter)\s+1
+\s-1enter_dim_mode, dim mh Turn on half-bright mode\s+1
+\s-1enter_doublewide_mode, swidm ZF Enable double-wide mode\s+1
+\s-1enter_draft_quality, sdrfq ZG Set draft-quality printing\s+1
+\s-1enter_insert_mode, smir im Insert mode (enter);\s+1
+\s-1enter_italics_mode, sitm ZH Enable italics mode\s+1
+\s-1enter_leftward_mode, slm ZI Enable leftward carriage motion\s+1
+\s-1enter_micro_mode, smicm ZJ Enable micro-motion capabilities\s+1
+\s-1enter_near_letter_quality, snlq ZK Set NLQ printing\s+1
+\s-1enter_normal_quality, snrmq ZL Set normal quality printing\s+1
+\s-1enter_pc_charset_mode, smpch S2 Enter PC character display mode\s+1
+\s-1enter_protected_mode, prot mp Turn on protected mode\s+1
+\s-1enter_reverse_mode, rev mr Turn on reverse video mode\s+1
+\s-1enter_scancode_mode, smsc S4 Enter PC scancode mode\s+1
+\s-1enter_secure_mode, invis mk Turn on blank mode (chars invisible)\s+1
+\s-1enter_shadow_mode, sshm ZM Enable shadow-mode printing\s+1
+\s-1enter_standout_mode, smso so Begin stand out mode\s+1
+\s-1enter_subscript_mode, ssubm ZN Enable subscript printing\s+1
+\s-1enter_superscript_mode, ssupm ZO Enable supercript printing\s+1
+\s-1enter_underline_mode, smul us Start underscore mode\s+1
+\s-1enter_upward_mode, sum ZP Enable upward carriage motion\s+1
+\s-1enter_xon_mode, smxon SX Turn on xon/xoff handshaking\s+1
+\s-1erase_chars, ech ec Erase #1 characters (PG)\s+1
+\s-1exit_alt_charset_mode, rmacs ae End alternate character set (P)\s+1
+\s-1exit_am_mode, rmam RA Turn off automatic margins\s+1
+\s-1exit_attribute_mode, sgr0 me Turn off all attributes\s+1
+\s-1exit_ca_mode, rmcup te String to end programs that use cup\s+1
+\s-1exit_delete_mode, rmdc ed End delete mode\s+1
+\s-1exit_doublewide_mode, rwidm ZQ Disable doublewide printing\s+1
+\s-1exit_insert_mode, rmir ei End insert mode\s+1
+\s-1exit_italics_mode, ritm ZR Disable italic printing\s+1
+\s-1exit_leftward_mode, rlm ZS Enable rightward (normal) carriage motion\s+1
+\s-1exit_micro_mode, rmicm ZT Disable micro motion capabilities\s+1
+\s-1exit_pc_charset_mode, rmpch S3 Disable PC character display\s+1
+\s-1exit_scancode_mode, rmsc S5 Disable PC scancode mode\s+1
+\s-1exit_shadow_mode, rshm ZU Disable shadow printing\s+1
+\s-1exit_standout_mode, rmso se End stand out mode\s+1
+\s-1exit_subscript_mode, rsubm ZV Disable subscript printing\s+1
+\s-1exit_superscript_mode, rsupm ZW Disable supercript printing\s+1
+\s-1exit_underline_mode, rmul ue End underscore mode\s+1
+\s-1exit_upward_mode, rum ZX Enable downward (normal) carriage motion\s+1
+\s-1exit_xon_mode, rmxon RX turn off xon/xoff handshaking\s+1
+\s-1flash_screen, flash vb Visible bell (may not move cursor)\s+1
+\s-1form_feed, ff ff Hardcopy terminal page eject (P*)\s+1
+\s-1from_status_line, fsl fs Return from status line\s+1
+\s-1init_1string, is1 i1 Terminal initialization string\s+1
+\s-1init_2string, is2 i2 Terminal initialization string\s+1
+\s-1init_3string, is3 i3 Terminal initialization string\s+1
+\s-1init_file, if if Name of file containing is\s+1
+\s-1init_prog, iprog iP Path name of program for init\s+1
+\s-1initialize_color, initc Ic Initialize the definition of color\s+1
+\s-1initialize_pair, initp Ip Initialize color-pair\s+1
+\s-1insert_character, ich1 ic Insert character (P)\s+1
+\s-1insert_line, il1 al Add new blank line (P*)\s+1
+\s-1insert_padding, ip ip Insert pad after character inserted
+ (p*)\s+1
+\s-1key_a1, ka1 K1 Upper left of keypad\s+1
+\s-1key_a3, ka3 K3 Upper right of keypad\s+1
+\s-1key_b2, kb2 K2 Center of keypad\s+1
+\s-1key_backspace, kbs kb Sent by backspace key\s+1
+\s-1key_beg, kbeg @1 begin key\s+1
+\s-1key_btab, kcbt kB back-tab key\s+1
+\s-1key_c1, kc1 K4 Lower left of keypad\s+1
+\s-1key_c3, kc3 K5 Lower right of keypad\s+1
+\s-1key_cancel, kcan @2 cancel key\s+1
+\s-1key_catab, ktbc ka Sent by clear-all-tabs key\s+1
+\s-1key_clear, kclr kC Sent by clear screen or erase key\s+1
+\s-1key_close, kclo @3 close key\s+1
+\s-1key_command, kcmd @4 command key\s+1
+\s-1key_copy, kcpy @5 copy key\s+1
+\s-1key_create, kcrt @6 create key\s+1
+\s-1key_ctab, kctab kt Sent by clear-tab key\s+1
+\s-1key_dc, kdch1 kD Sent by delete character key\s+1
+\s-1key_dl, kdl1 kL Sent by delete line key\s+1
+\s-1key_down, kcud1 kd Sent by terminal down arrow key\s+1
+\s-1key_eic, krmir kM Sent by rmir or smir in insert mode\s+1
+\s-1key_end, kend @7 end key\s+1
+\s-1key_enter, kent @8 enter/send key\s+1
+\s-1key_eol, kel kE Sent by clear-to-end-of-line key\s+1
+\s-1key_eos, ked kS Sent by clear-to-end-of-screen key\s+1
+\s-1key_exit, kext @9 exit key\s+1
+\s-1key_f0, kf0 k0 Sent by function key f0\s+1
+\s-1key_f1, kf1 k1 Sent by function key f1\s+1
+\s-1key_f2, kf2 k2 Sent by function key f2\s+1
+\s-1key_f3, kf3 k3 Sent by function key f3\s+1
+\s-1key_f4, kf4 k4 Sent by function key f4\s+1
+\s-1key_f5, kf5 k5 Sent by function key f5\s+1
+\s-1key_f6, kf6 k6 Sent by function key f6\s+1
+\s-1key_f7, kf7 k7 Sent by function key f7\s+1
+\s-1key_f8, kf8 k8 Sent by function key f8\s+1
+\s-1key_f9, kf9 k9 Sent by function key f9\s+1
+\s-1key_f10, kf10 k; Sent by function key f10\s+1
+\s-1key_f11, kf11 F1 F11 function key\s+1
+\s-1key_f12, kf12 F2 F12 function key\s+1
+\s-1key_f13, kf13 F3 F13 function key\s+1
+\s-1key_f14, kf14 F4 F14 function key\s+1
+\s-1key_f15, kf15 F5 F15 function key\s+1
+\s-1key_f16, kf16 F6 F16 function key\s+1
+\s-1key_f17, kf17 F7 F17 function key\s+1
+\s-1key_f18, kf18 F8 F18 function key\s+1
+\s-1key_f19, kf19 F9 F19 function key\s+1
+\s-1key_f20, kf20 FA F20 function key\s+1
+\s-1key_f21, kf21 FB F21 function key\s+1
+\s-1key_f22, kf22 FC F22 function key\s+1
+\s-1key_f23, kf23 FD F23 function key\s+1
+\s-1key_f24, kf24 FE F24 function key\s+1
+\s-1key_f25, kf25 FF F25 function key\s+1
+\s-1key_f26, kf26 FG F26 function key\s+1
+\s-1key_f27, kf27 FH F27 function key\s+1
+\s-1key_f28, kf28 FI F28 function key\s+1
+\s-1key_f29, kf29 FJ F29 function key\s+1
+\s-1key_f30, kf30 FK F30 function key\s+1
+\s-1key_f31, kf31 FL F31 function key\s+1
+\s-1key_f32, kf32 FM F32 function key\s+1
+\s-1key_f33, kf33 FN F33 function key\s+1
+\s-1key_f34, kf34 FO F34 function key\s+1
+\s-1key_f35, kf35 FP F35 function key\s+1
+\s-1key_f36, kf36 FQ F36 function key\s+1
+\s-1key_f37, kf37 FR F37 function key\s+1
+\s-1key_f38, kf38 FS F38 function key\s+1
+\s-1key_f39, kf39 FT F39 function key\s+1
+\s-1key_f40, kf40 FU F40 function key\s+1
+\s-1key_f41, kf41 FV F41 function key\s+1
+\s-1key_f42, kf42 FW F42 function key\s+1
+\s-1key_f43, kf43 FX F43 function key\s+1
+\s-1key_f44, kf44 FY F44 function key\s+1
+\s-1key_f45, kf45 FZ F45 function key\s+1
+\s-1key_f46, kf46 Fa F46 function key\s+1
+\s-1key_f47, kf47 Fb F47 function key\s+1
+\s-1key_f48, kf48 Fc F48 function key\s+1
+\s-1key_f49, kf49 Fd F49 function key\s+1
+\s-1key_f50, kf50 Fe F50 function key\s+1
+\s-1key_f51, kf51 Ff F51 function key\s+1
+\s-1key_f52, kf52 Fg F52 function key\s+1
+\s-1key_f53, kf53 Fh F53 function key\s+1
+\s-1key_f54, kf54 Fi F54 function key\s+1
+\s-1key_f55, kf55 Fj F55 function key\s+1
+\s-1key_f56, kf56 Fk F56 function key\s+1
+\s-1key_f57, kf57 Fl F57 function key\s+1
+\s-1key_f58, kf58 Fm F58 function key\s+1
+\s-1key_f59, kf59 Fn F59 function key\s+1
+\s-1key_f60, kf60 Fo F60 function key\s+1
+\s-1key_f61, kf61 Fp F61 function key\s+1
+\s-1key_f62, kf62 Fq F62 function key\s+1
+\s-1key_f63, kf63 Fr F63 function key\s+1
+\s-1key_find, kfnd @0 find key\s+1
+\s-1key_help, khlp %1 help key\s+1
+\s-1key_home, khome kh Sent by home key\s+1
+\s-1key_ic, kich1 kI Sent by ins char/enter ins mode key\s+1
+\s-1key_il, kil1 kA Sent by insert line\s+1
+\s-1key_left, kcub1 kl Sent by terminal left arrow key\s+1
+\s-1key_ll, kll kH Sent by home-down key\s+1
+\s-1key_mark, kmrk %2 mark key\s+1
+\s-1key_message, kmsg %3 message key\s+1
+\s-1key_move, kmov %4 move key\s+1
+\s-1key_next, knxt %5 next key\s+1
+\s-1key_npage, knp kN Sent by next-page key\s+1
+\s-1key_open, kopn %6 open key\s+1
+\s-1key_options, kopt %7 options key\s+1
+\s-1key_ppage, kpp kP Sent by previous-page key\s+1
+\s-1key_previous, kprv %8 previous key\s+1
+\s-1key_print, kprt %9 print key\s+1
+\s-1key_redo, krdo %0 redo key\s+1
+\s-1key_reference, kref &1 reference key\s+1
+\s-1key_refresh, krfr &2 refresh key\s+1
+\s-1key_replace, krpl &3 replace key\s+1
+\s-1key_restart, krst &4 restart key\s+1
+\s-1key_resume, kres &5 resume key\s+1
+\s-1key_right, kcuf1 kr Sent by terminal right arrow key\s+1
+\s-1key_save, ksav &6 save key\s+1
+\s-1key_sbeg, kBEG &9 shifted begin key\s+1
+\s-1key_scancel, kCAN &0 shifted cancel key\s+1
+\s-1key_scommand, kCMD *1 shifted command key\s+1
+\s-1key_scopy, kCPY *2 shifted copy key\s+1
+\s-1key_screate, kCRT *3 shifted create key\s+1
+\s-1key_sdc, kDC *4 shifted delete char key\s+1
+\s-1key_sdl, kDL *5 shifted delete line key\s+1
+\s-1key_select, kslt *6 select key\s+1
+\s-1key_send, kEND *7 shifted end key\s+1
+\s-1key_seol, kEOL *8 shifted end of line key\s+1
+\s-1key_sexit, kEXT *9 shifted exit key\s+1
+\s-1key_sf, kind kF Sent by scroll-forward/down key\s+1
+\s-1key_sfind, kFND *0 shifted find key\s+1
+\s-1key_shelp, kHLP #1 shifted help key\s+1
+\s-1key_shome, kHOM #2 shifted home key\s+1
+\s-1key_sic, kIC #3 shifted insert char key\s+1
+\s-1key_sleft, kLFT #4 shifted left key\s+1
+\s-1key_smessage, kMSG %a shifted message key\s+1
+\s-1key_smove, kMOV %b shifted move key\s+1
+\s-1key_snext, kNXT %c shifted next key\s+1
+\s-1key_soptions, kOPT %d shifted options key\s+1
+\s-1key_sprevious, kPRV %e shifted previous key\s+1
+\s-1key_sprint, kPRT %f shifted print key\s+1
+\s-1key_sr, kri kR Sent by scroll-backward/up key\s+1
+\s-1key_sredo, kRDO %g shifted redo key\s+1
+\s-1key_sreplace, kRPL %h shifted replace key\s+1
+\s-1key_sright, kRIT %i shifted right key\s+1
+\s-1key_srsume, kRES %j shifted resume key\s+1
+\s-1key_ssave, kSAV !1 shifted save key\s+1
+\s-1key_ssuspend, kSPD !2 shifted suspend key\s+1
+\s-1key_stab, khts kT Sent by set-tab key\s+1
+\s-1key_sundo, kUND !3 shifted undo key\s+1
+\s-1key_suspend, kspd &7 suspend key\s+1
+\s-1key_undo, kund &8 undo key\s+1
+\s-1key_up, kcuu1 ku Sent by terminal up arrow key\s+1
+\s-1keypad_local, rmkx ke Out of "keypad transmit" mode\s+1
+\s-1keypad_xmit, smkx ks Put terminal in "keypad transmit" mode\s+1
+\s-1lab_f0, lf0 l0 Labels on function key f0 if not f0\s+1
+\s-1lab_f1, lf1 l1 Labels on function key f1 if not f1\s+1
+\s-1lab_f2, lf2 l2 Labels on function key f2 if not f2\s+1
+\s-1lab_f3, lf3 l3 Labels on function key f3 if not f3\s+1
+\s-1lab_f4, lf4 l4 Labels on function key f4 if not f4\s+1
+\s-1lab_f5, lf5 l5 Labels on function key f5 if not f5\s+1
+\s-1lab_f6, lf6 l6 Labels on function key f6 if not f6\s+1
+\s-1lab_f7, lf7 l7 Labels on function key f7 if not f7\s+1
+\s-1lab_f8, lf8 l8 Labels on function key f8 if not f8\s+1
+\s-1lab_f9, lf9 l9 Labels on function key f9 if not f9\s+1
+\s-1lab_f10, lf10 la Labels on function key f10 if not f10\s+1
+\s-1label_on, smln LO turn on soft labels\s+1
+\s-1label_off, rmln LF turn off soft labels\s+1
+\s-1meta_off, rmm mo Turn off "meta mode"\s+1
+\s-1meta_on, smm mm Turn on "meta mode" (8th bit)\s+1
+\s-1micro_column_address, mhpa ZY Like column_address for micro adjustment\s+1
+\s-1micro_down, mcud1 ZZ Like cursor_down for micro adjustment\s+1
+\s-1micro_left, mcub1 Za Like cursor_left for micro adjustment\s+1
+\s-1micro_right, mcuf1 Zb Like cursor_right for micro adjustment\s+1
+\s-1micro_row_address, mvpa Zc Like row_address for micro adjustment\s+1
+\s-1micro_up, mcuu1 Zd Like cursor_up for micro adjustment\s+1
+\s-1newline, nel nw Newline (behaves like cr followed by lf)\s+1
+\s-1order_of_pins, porder Ze Matches software buts to print-head pins\s+1
+\s-1orig_colors, oc oc Reset all color pairs\s+1
+\s-1orig_pair, op op Set default color-pair to original one\s+1
+\s-1pad_char, pad pc Pad character (rather than null)\s+1
+\s-1parm_dch, dch DC Delete #1 chars (PG*)\s+1
+\s-1parm_delete_line, dl DL Delete #1 lines (PG*)\s+1
+\s-1parm_down_cursor, cud DO Move cursor down #1 lines (PG*)\s+1
+\s-1parm_down_micro, mcud Zf Like cud for micro adjust\s+1
+\s-1parm_ich, ich IC Insert #1 blank chars (PG*)\s+1
+\s-1parm_index, indn SF Scroll forward #1 lines (PG)\s+1
+\s-1parm_insert_line, il AL Add #1 new blank lines (PG*)\s+1
+\s-1parm_left_cursor, cub LE Move cursor left #1 spaces (PG)\s+1
+\s-1parm_left_micro, mcub Zg Like cul for micro adjust\s+1
+\s-1parm_right_cursor, cuf RI Move cursor right #1 spaces (PG*)\s+1
+\s-1parm_right_micro, mcuf Zh Likr cuf for micro adjust\s+1
+\s-1parm_rindex, rin SR Scroll backward #1 lines (PG)\s+1
+\s-1parm_up_cursor, cuu UP Move cursor up #1 lines (PG*)\s+1
+\s-1parm_up_micro, mcuu Zi Like cuu for micro adjust\s+1
+\s-1pkey_key, pfkey pk Prog funct key #1 to type string #2\s+1
+\s-1pkey_local, pfloc pl Prog funct key #1 to execute string #2\s+1
+\s-1pkey_xmit, pfx px Prog funct key #1 to xmit string #2\s+1
+\s-1pkey_plab, pfxl xl Program key #1 to xmit #2 and show #3\s+1
+\s-1plab_norm, pln pn program label #1 to show string #2\s+1
+\s-1print_screen, mc0 ps Print contents of the screen\s+1
+\s-1prtr_non, mc5p pO Turn on the printer for #1 bytes\s+1
+\s-1prtr_off, mc4 pf Turn off the printer\s+1
+\s-1prtr_on, mc5 po Turn on the printer\s+1
+\s-1repeat_char, rep rp Repeat char #1 #2 times. (PG*)\s+1
+\s-1req_for_input, rfi RF request for input\s+1
+\s-1reset_1string, rs1 r1 Reset terminal completely to sane modes.\s+1
+\s-1reset_2string, rs2 r2 Reset terminal completely to sane modes.\s+1
+\s-1reset_3string, rs3 r3 Reset terminal completely to sane modes.\s+1
+\s-1reset_file, rf rf Name of file containing reset string\s+1
+\s-1restore_cursor, rc rc Restore cursor to position of last sc\s+1
+\s-1row_address, vpa cv Vertical position absolute (set row) (PG)\s+1
+\s-1save_cursor, sc sc Save cursor position (P)\s+1
+\s-1scancode_escape, scesc S7 Escape for scancode emulation\s+1
+\s-1scroll_forward, ind sf Scroll text up (P)\s+1
+\s-1scroll_reverse, ri sr Scroll text down (P)\s+1
+\s-1select_char_set, scs Zj Select character set\s+1
+\s-1set0_des_seq, s0ds s0 Shift to codeset 0 (EUC set 0, ASCII)\s+1
+\s-1set1_des_seq, s1ds s1 Shift to codeset 1\s+1
+\s-1set2_des_seq, s2ds s2 Shift to codeset 2\s+1
+\s-1set3_des_seq, s3ds s3 Shift to codeset 3\s+1
+\s-1set_a_background, setab AB Set background color using ANSI escape\s+1
+\s-1set_a_foreground, setaf AF Set foreground color using ANSI escape\s+1
+\s-1set_attributes, sgr sa Define the video attributes (PG9)\s+1
+\s-1set_background, setb Sb Set current background color\s+1
+\s-1set_bottom_margin, smgb Zk Set bottom margin at current line\s+1
+\s-1set_bottom_margin_parm, smgbp Zl Set bottom line at line #1 or #2 lines from bottom\s+1
+\s-1set_color_band, setcolor Yz Change to ribbon color #1\s+1
+\s-1set_color_pair, scp sp Set current color pair\s+1
+\s-1set_foreground, setf Sf Set current foreground color\s+1
+\s-1set_left_margin, smgl ML Set left margin at current line\s+1
+\s-1set_left_margin_parm, smglp Zm Set left (right) margin at #1 (#2)\s+1
+\s-1set_lr_margin, smglr ML Set both left and right margins\s+1
+\s-1set_page_length, slines YZ Set page length to #1 lines (use tparm)\s+1
+\s-1set_right_margin, smgr MR Set right margin at current column\s+1
+\s-1set_right_margin_parm, smgrp Zn Set right margin at column #1\s+1
+\s-1set_tab, hts st Set a tab in all rows, current column\s+1
+\s-1set_tb_margin, smgtb MT Sets both top and bottom margins\s+1
+\s-1set_top_margin, smgt Zo Set top margin at current line\s+1
+\s-1set_top_margin_parm, smgtp Zp Set top margin at line #1\s+1
+\s-1set_window, wind wi Current window is lines #1-#2 cols #3-#4\s+1
+\s-1start_bit_image, sbim Zq Start printing bit image graphics\s+1
+\s-1start_char_set_def, scsd Zr Start definition of a character set\s+1
+\s-1stop_bit_image, rbim Zs End printing bit image graphics\s+1
+\s-1stop_char_set_def, rcsd Zt End definition of character set\s+1
+\s-1subscript_characters, subcs Zu List of subscriptable chars\s+1
+\s-1superscript_characters, supcs Zv List of superscriptable chars\s+1
+\s-1tab, ht ta Tab to next 8 space hardware tab stop\s+1
+\s-1these_cause_cr, docr Zw These characters cause a CR\s+1
+\s-1to_status_line, tsl ts Go to status line, column #1\s+1
+\s-1underline_char, uc uc Underscore one char and move past it\s+1
+\s-1up_half_line, hu hu Half-line up (reverse 1/2 linefeed)\s+1
+\s-1xoff_character, xoffc XF XON character\s+1
+\s-1xon_character, xonc XN XOFF character\s+1
+.TE
+
+(The following string capabilities are present in the SVr4.0 term structure,
+but are not documented in the man page. Comments are from the term
+structure header.)
+
+.TS
+center;
+c c c c
+c c c c
+l l l l.
+\s-1label_format, fln Lf ??\s+1
+\s-1set_clock, sclk SC Set time-of-day clock\s+1
+\s-1display_clock, dclk DK Display time-of-day clock\s+1
+\s-1remove_clock, rmclk RC Remove time-of-day clock??\s+1
+\s-1create_window, cwin CW Define win #1 to go from #2,#3 to #4,#5\s+1
+\s-1goto_window, wingo WG Goto window #1\s+1
+\s-1hangup, hup HU Hang up phone\s+1
+\s-1dial_phone, dial DI Dial phone number #1\s+1
+\s-1quick_dial, qdial QD Dial phone number #1, without progress detection\s+1
+\s-1tone, tone TO Select touch tone dialing\s+1
+\s-1pulse, pulse PU Select pulse dialing\s+1
+\s-1flash_hook, hook fh Flash the switch hook\s+1
+\s-1fixed_pause, pause PA Pause for 2-3 seconds\s+1
+\s-1wait_tone, wait WA Wait for dial tone\s+1
+\s-1user0, u0 u0 User string # 0\s+1
+\s-1user1, u1 u1 User string # 1\s+1
+\s-1user2, u2 u2 User string # 2\s+1
+\s-1user3, u3 u3 User string # 3\s+1
+\s-1user4, u4 u4 User string # 4\s+1
+\s-1user5, u5 u5 User string # 5\s+1
+\s-1user6, u6 u6 User string # 6\s+1
+\s-1user7, u7 u7 User string # 7\s+1
+\s-1user8, u8 u8 User string # 8\s+1
+\s-1user9, u9 u9 User string # 9\s+1
+\s-1get_mouse, getm Gm Curses should get button events\s+1
+\s-1key_mouse, kmous Km ??\s+1
+\s-1mouse_info, minfo Mi Mouse status information\s+1
+\s-1pc_term_options, pctrm S6 PC terminal options\s+1
+\s-1req_mouse_pos, reqmp RQ Request mouse position report\s+1
+\s-1zero_motion, zerom, Zx No motion for the subsequent character\s+1
+.TE
+.PP
+.B A Sample Entry
+.PP
+The following entry, which describes the Concept\-100, is among the more
+complex entries in the
+.I terminfo
+file as of this writing.
+.PP
+.nf
+.in -2
+.ta .3i
+.ft CW
+\s-2concept100\||\|c100|\|\|concept\||\|c104\||\|c100-4p\||\|concept 100,
+ am, bel=^G, blank=\eEH, blink=\eEC, clear=^L$<2*>, cnorm=\eEw,
+ cols#80, cr=^M$<9>, cub1=^H, cud1=^J, cuf1=\eE=,
+ cup=\eEa%p1%' '%+%c%p2%' '%+%c,
+ cuu1=\eE;, cvvis=\eEW, db, dch1=\eE^A$<16*>, dim=\eEE, dl1=\eE^B$<3*>,
+ ed=\eE^C$<16*>, el=\eE^U$<16>, eo, flash=\eEk$<20>\eEK, ht=\et$<8>,
+ il1=\eE^R$<3*>, in, ind=^J, .ind=^J$<9>, ip=$<16*>,
+ is2=\eEU\eEf\eE7\eE5\eE8\eEl\eENH\eEK\eE\e200\eEo&\e200\eEo\e47\eE,
+ kbs=^h, kcub1=\eE>, kcud1=\eE<, kcuf1=\eE=, kcuu1=\eE;,
+ kf1=\eE5, kf2=\eE6, kf3=\eE7, khome=\eE?,
+ lines#24, mir, pb#9600, prot=\eEI, rep=\eEr%p1%c%p2%' '%+%c$<.2*>,
+ rev=\eED, rmcup=\eEv $<6>\eEp\er\en, rmir=\eE\e200, rmkx=\eEx,
+ rmso=\eEd\eEe, rmul=\eEg, rmul=\eEg, sgr0=\eEN\e200,
+ smcup=\eEU\eEv 8p\eEp\er, smir=\eE^P, smkx=\eEX, smso=\eEE\eED,
+ smul=\eEG, tabs, ul, vt#8, xenl,\s+2
+.in +2
+.fi
+.ft R
+.PP
+Entries may continue onto multiple lines by placing white space at
+the beginning of each line except the first.
+Comments may be included on lines beginning with ``#''.
+Capabilities in
+.I terminfo
+are of three types:
+Boolean capabilities which indicate that the terminal has
+some particular feature, numeric capabilities giving the size of the terminal
+or the size of particular delays, and string
+capabilities, which give a sequence which can be used to perform particular
+terminal operations.
+.PP
+.B Types of Capabilities
+.PP
+All capabilities have names. For instance, the fact that
+the Concept has
+.I "automatic margins"
+(i.e., an automatic return and linefeed
+when the end of a line is reached) is indicated by the capability \fBam\fR.
+Hence the description of the Concept includes \fBam\fR.
+Numeric capabilities are followed by the character `#' and then the value.
+Thus \fBcols\fR, which indicates the number of columns the terminal has,
+gives the value `80' for the Concept.
+.PP
+Finally, string valued capabilities, such as \fBel\fR (clear to end of line
+sequence) are given by the two-character code, an `=', and then a string
+ending at the next following `,'. A delay in milliseconds may appear
+anywhere in such a capability, enclosed in $<..> brackets,
+as in \fBel\fP=\eEK$<3>,
+and padding characters are supplied by
+.I tputs
+to provide this delay.
+The delay can be either a number, e.g., `20', or a number followed by
+an `*', i.e., `3*'. A `*' indicates that the padding required is proportional
+to the number of lines affected by the operation, and the amount given is
+the per-affected-unit padding required.
+(In the case of insert character, the factor is still the number of
+.IR lines
+affected.
+This is always one unless the terminal has \fBxenl\fP and the software uses it.)
+When a `*' is specified, it is sometimes useful to give a delay of the form
+`3.5' to specify a delay per unit to tenths of milliseconds.
+(Only one decimal place is allowed.)
+.PP
+A number of escape sequences are provided in the string valued capabilities
+for easy encoding of characters there. Both \fB\eE\fR and \fB\ee\fR
+map to an \s-1ESCAPE\s0 character,
+\fB^x\fR maps to a control-x for any appropriate x, and the sequences
+\fB\en \el \er \et \eb \ef \es\fR give
+a newline, linefeed, return, tab, backspace, formfeed, and space.
+Other escapes include \e^ for ^, \e\e for \e, \e, for comma, \e: for :,
+and \e0 for null.
+(\e0 will produce \e200, which does not terminate a string but behaves
+as a null character on most terminals.)
+Finally, characters may be given as three octal digits after a \fB\e\fR.
+.PP
+Sometimes individual capabilities must be commented out.
+To do this, put a period before the capability name.
+For example, see the second
+.B ind
+in the example above.
+.br
+.ne 5
+.PP
+.B Preparing Descriptions
+.PP
+We now outline how to prepare descriptions of terminals.
+The most effective way to prepare a terminal description is by imitating
+the description of a similar terminal in
+.I terminfo
+and to build up a description gradually, using partial descriptions
+with
+.I vi
+or some other screen-oriented program to check that they are correct.
+Be aware that a very unusual terminal may expose deficiencies in
+the ability of the
+.I terminfo
+file to describe it
+or bugs in the screen-handling code of the test program.
+To easily test a new terminal description you can set the environment variable
+TERMINFO to a pathname of a directory containing the
+compiled description you are working
+on and programs will look there rather than in
+.IR \*d .
+To get the padding for insert line right (if the terminal manufacturer
+did not document it) a severe test is to edit /etc/passwd at 9600 baud,
+delete 16 or so lines from the middle of the screen, then hit the `u'
+key several times quickly.
+If the terminal messes up, more padding is usually needed.
+A similar test can be used for insert character.
+.PP
+.B Basic Capabilities
+.PP
+The number of columns on each line for the terminal is given by the
+\fBcols\fR numeric capability. If the terminal is a \s-1CRT\s0, then the
+number of lines on the screen is given by the \fBlines\fR capability.
+If the terminal wraps around to the beginning of the next line when
+it reaches the right margin, then it should have the \fBam\fR capability.
+If the terminal can clear its screen, leaving the cursor in the home
+position, then this is given by the \fBclear\fR string capability.
+If the terminal overstrikes
+(rather than clearing a position when a character is struck over)
+then it should have the \fBos\fR capability.
+If the terminal is a printing terminal, with no soft copy unit,
+give it both
+.B hc
+and
+.BR os .
+.RB ( os
+applies to storage scope terminals, such as \s-1TEKTRONIX\s+1 4010
+series, as well as hard copy and APL terminals.)
+If there is a code to move the cursor to the left edge of the current
+row, give this as
+.BR cr .
+(Normally this will be carriage return, control M.)
+If there is a code to produce an audible signal (bell, beep, etc)
+give this as
+.BR bel .
+.PP
+If there is a code to move the cursor one position to the left
+(such as backspace) that capability should be given as
+.BR cub1 .
+Similarly, codes to move to the right, up, and down should be
+given as
+.BR cuf1 ,
+.BR cuu1 ,
+and
+.BR cud1 .
+These local cursor motions should not alter the text they pass over,
+for example, you would not normally use `\fBcuf1\fP=\ ' because the
+space would erase the character moved over.
+.PP
+A very important point here is that the local cursor motions encoded
+in
+.I terminfo
+are undefined at the left and top edges of a \s-1CRT\s0 terminal.
+Programs should never attempt to backspace around the left edge,
+unless
+.B bw
+is given,
+and never attempt to go up locally off the top.
+In order to scroll text up, a program will go to the bottom left corner
+of the screen and send the
+.B ind
+(index) string.
+.PP
+To scroll text down, a program goes to the top left corner
+of the screen and sends the
+.B ri
+(reverse index) string.
+The strings
+.B ind
+and
+.B ri
+are undefined when not on their respective corners of the screen.
+.PP
+Parameterized versions of the scrolling sequences are
+.B indn
+and
+.B rin
+which have the same semantics as
+.B ind
+and
+.B ri
+except that they take one parameter, and scroll that many lines.
+They are also undefined except at the appropriate edge of the screen.
+.PP
+The \fBam\fR capability tells whether the cursor sticks at the right
+edge of the screen when text is output, but this does not necessarily
+apply to a
+.B cuf1
+from the last column.
+The only local motion which is defined from the left edge is if
+.B bw
+is given, then a
+.B cub1
+from the left edge will move to the right edge of the previous row.
+If
+.B bw
+is not given, the effect is undefined.
+This is useful for drawing a box around the edge of the screen, for example.
+If the terminal has switch selectable automatic margins,
+the
+.I terminfo
+file usually assumes that this is on; i.e., \fBam\fR.
+If the terminal has a command which moves to the first column of the next
+line, that command can be given as
+.B nel
+(newline).
+It does not matter if the command clears the remainder of the current line,
+so if the terminal has no
+.B cr
+and
+.B lf
+it may still be possible to craft a working
+.B nel
+out of one or both of them.
+.PP
+These capabilities suffice to describe hardcopy and \*(lqglass-tty\*(rq terminals.
+Thus the model 33 teletype is described as
+.PP
+.DT
+.nf
+.ft CW
+.in -7
+ \s-133\||\|tty33\||\|tty\||\|model 33 teletype,
+ bel=^G, cols#72, cr=^M, cud1=^J, hc, ind=^J, os,\s+1
+.in +7
+.ft R
+.PP
+while the Lear Siegler \s-1ADM\-3\s0 is described as
+.PP
+.DT
+.nf
+.ft CW
+.in -7
+ \s-1adm3\||\|3\||\|lsi adm3,
+ am, bel=^G, clear=^Z, cols#80, cr=^M, cub1=^H, cud1=^J,
+ ind=^J, lines#24,\s+1
+.in +7
+.ft R
+.fi
+.PP
+.B Parameterized Strings
+.PP
+Cursor addressing and other strings requiring parameters
+in the terminal are described by a
+parameterized string capability, with
+.IR printf (3S)
+like escapes \fB%x\fR in it.
+For example, to address the cursor, the
+.B cup
+capability is given, using two parameters:
+the row and column to address to.
+(Rows and columns are numbered from zero and refer to the
+physical screen visible to the user, not to any unseen memory.)
+If the terminal has memory relative cursor addressing,
+that can be indicated by
+.BR mrcup .
+.PP
+The parameter mechanism uses a stack and special \fB%\fP codes
+to manipulate it. Typically a sequence will push one of the
+parameters onto the stack and then print it in some format.
+Often more complex operations are necessary.
+.PP
+The \fB%\fR encodings have the following meanings:
+.PP
+.DT
+.nf
+.ta .5i 1.5i
+ \s-1%% outputs `%'
+ %d print pop() as in printf
+ %2d print pop() like %2d
+ %3d print pop() like %3d
+ %02d
+ %03d as in printf
+ %c print pop() gives %c
+ %s print pop() gives %s
+
+ %p[1-9] push ith parm
+ %P[a-z] set variable [a-z] to pop()
+ %g[a-z] get variable [a-z] and push it
+ %'c' char constant c
+ %{nn} integer constant nn
+
+ %+ %- %* %/ %m
+ arithmetic (%m is mod): push(pop() op pop())
+ %& %| %^ bit operations: push(pop() op pop())
+ %= %> %< logical operations: push(pop() op pop())
+ %! %~ unary operations push(op pop())
+ %i add 1 to first two parms (for ANSI terminals)
+
+ %? expr %t thenpart %e elsepart %;
+ if-then-else, %e elsepart is optional.
+ else-if's are possible ala Algol 68:
+ %? c\d1\u %t b\d1\u %e c\d2\u %t b\d2\u %e c\d3\u %t b\d3\u %e c\d4\u %t b\d4\u %e %;
+\s+1 c\di\u are conditions, b\di\u are bodies.
+.fi
+.PP
+Binary operations are in postfix form with the operands in the usual order.
+That is, to get x-5 one would use "%gx%{5}%-".
+.PP
+Consider the HP2645, which, to get to row 3 and column 12, needs
+to be sent \eE&a12c03Y padded for 6 milliseconds. Note that the order
+of the rows and columns is inverted here, and that the row and column
+are printed as two digits.
+Thus its \fBcup\fR capability is \*(lqcup=6\eE&%p2%2dc%p1%2dY\*(rq.
+.PP
+The Microterm \s-1ACT-IV\s0 needs the current row and column sent
+preceded by a \fB^T\fR, with the row and column simply encoded in binary,
+\*(lqcup=^T%p1%c%p2%c\*(rq.
+Terminals which use \*(lq%c\*(rq need to be able to
+backspace the cursor (\fBcub1\fR),
+and to move the cursor up one line on the screen (\fBcuu1\fR).
+This is necessary because it is not always safe to transmit \fB\en\fR
+\fB^D\fR and \fB\er\fR, as the system may change or discard them.
+(The library routines dealing with terminfo set tty modes so that
+tabs are never expanded, so \et is safe to send.
+This turns out to be essential for the Ann Arbor 4080.)
+.PP
+A final example is the \s-1LSI ADM\s0-3a, which uses row and column
+offset by a blank character, thus \*(lqcup=\eE=%p1%' '%+%c%p2%' '%+%c\*(rq.
+After sending `\eE=', this pushes the first parameter, pushes the
+ASCII value for a space (32), adds them (pushing the sum on the stack
+in place of the two previous values) and outputs that value as a character.
+Then the same is done for the second parameter.
+More complex arithmetic is possible using the stack.
+.PP
+If the terminal has row or column absolute cursor addressing,
+these can be given as single parameter capabilities
+.B hpa
+(horizontal position absolute)
+and
+.B vpa
+(vertical position absolute).
+Sometimes these are shorter than the more general two parameter
+sequence (as with the hp2645) and can be used in preference to
+.B cup .
+If there are parameterized local motions (e.g., move
+.I n
+spaces to the right) these can be given as
+.BR cud ,
+.BR cub ,
+.BR cuf ,
+and
+.BR cuu
+with a single parameter indicating how many spaces to move.
+These are primarily useful if the terminal does not have
+.BR cup ,
+such as the \s-1TEKTRONIX\s+1 4025.
+.PP
+.B Cursor Motions
+.PP
+If the terminal has a fast way to home the cursor
+(to very upper left corner of screen) then this can be given as
+\fBhome\fR; similarly a fast way of getting to the lower left-hand corner
+can be given as \fBll\fR; this may involve going up with \fBcuu1\fR
+from the home position,
+but a program should never do this itself (unless \fBll\fR does) because it
+can make no assumption about the effect of moving up from the home position.
+Note that the home position is the same as addressing to (0,0):
+to the top left corner of the screen, not of memory.
+(Thus, the \eEH sequence on HP terminals cannot be used for
+.BR home .)
+.PP
+.B Area Clears
+.PP
+If the terminal can clear from the current position to the end of the
+line, leaving the cursor where it is, this should be given as \fBel\fR.
+If the terminal can clear from the current position to the end of the
+display, then this should be given as \fBed\fR.
+\fBEd\fR is only defined from the first column of a line.
+(Thus, it can be simulated by a request to delete a large number of lines,
+if a true
+.B ed
+is not available.)
+.PP
+.B Insert/delete line
+.PP
+If the terminal can open a new blank line before the line where the cursor
+is, this should be given as \fBil1\fR; this is done only from the first
+position of a line. The cursor must then appear on the newly blank line.
+If the terminal can delete the line which the cursor is on, then this
+should be given as \fBdl1\fR; this is done only from the first position on
+the line to be deleted.
+Versions of
+.B il1
+and
+.B dl1
+which take a single parameter and insert or delete that many lines can
+be given as
+.B il
+and
+.BR dl .
+If the terminal has a settable scrolling region (like the vt100)
+the command to set this can be described with the
+.B csr
+capability, which takes two parameters:
+the top and bottom lines of the scrolling region.
+The cursor position is, alas, undefined after using this command.
+It is possible to get the effect of insert or delete line using
+this command \- the
+.B sc
+and
+.B rc
+(save and restore cursor) commands are also useful.
+Inserting lines at the top or bottom of the screen can also be
+done using
+.B ri
+or
+.B ind
+on many terminals without a true insert/delete line,
+and is often faster even on terminals with those features.
+.PP
+If the terminal has the ability to define a window as part of
+memory, which all commands affect,
+it should be given as the parameterized string
+.BR wind .
+The four parameters are the starting and ending lines in memory
+and the starting and ending columns in memory, in that order.
+.PP
+If the terminal can retain display memory above, then the
+\fBda\fR capability should be given; if display memory can be retained
+below, then \fBdb\fR should be given. These indicate
+that deleting a line or scrolling may bring non-blank lines up from below
+or that scrolling back with \fBri\fR may bring down non-blank lines.
+.PP
+.B Insert/Delete Character
+.PP
+There are two basic kinds of intelligent terminals with respect to
+insert/delete character which can be described using
+.I terminfo.
+The most common insert/delete character operations affect only the characters
+on the current line and shift characters off the end of the line rigidly.
+Other terminals, such as the Concept 100 and the Perkin Elmer Owl, make
+a distinction between typed and untyped blanks on the screen, shifting
+upon an insert or delete only to an untyped blank on the screen which is
+either eliminated, or expanded to two untyped blanks. You can determine the
+kind of terminal you have by clearing the screen and then typing
+text separated by cursor motions. Type \*(lqabc\ \ \ \ def\*(rq using local
+cursor motions (not spaces) between the \*(lqabc\*(rq and the \*(lqdef\*(rq.
+Then position the cursor before the \*(lqabc\*(rq and put the terminal in insert
+mode. If typing characters causes the rest of the line to shift
+rigidly and characters to fall off the end, then your terminal does
+not distinguish between blanks and untyped positions. If the \*(lqabc\*(rq
+shifts over to the \*(lqdef\*(rq which then move together around the end of the
+current line and onto the next as you insert, you have the second type of
+terminal, and should give the capability \fBin\fR, which stands for
+\*(lqinsert null\*(rq.
+While these are two logically separate attributes (one line vs. multiline
+insert mode, and special treatment of untyped spaces) we have seen no
+terminals whose insert mode cannot be described with the single attribute.
+.PP
+Terminfo can describe both terminals which have an insert mode, and terminals
+which send a simple sequence to open a blank position on the current line.
+Give as \fBsmir\fR the sequence to get into insert mode.
+Give as \fBrmir\fR the sequence to leave insert mode.
+Now give as \fBich1\fR any sequence needed to be sent just before sending
+the character to be inserted. Most terminals with a true insert mode
+will not give \fBich1\fR; terminals which send a sequence to open a screen
+position should give it here.
+(If your terminal has both, insert mode is usually preferable to \fBich1\fP.
+Do not give both unless the terminal actually requires both
+to be used in combination.)
+If post insert padding is needed, give this as a number of milliseconds
+in \fBip\fR (a string option). Any other sequence which may need to be
+sent after an insert of a single character may also be given in \fBip\fR.
+If your terminal needs both to be placed into an `insert mode' and
+a special code to precede each inserted character, then both
+.BR smir / rmir
+and
+.B ich1
+can be given, and both will be used.
+The
+.B ich
+capability, with one parameter,
+.IR n ,
+will repeat the effects of
+.B ich1
+.I n
+times.
+.PP
+It is occasionally necessary to move around while in insert mode
+to delete characters on the same line (e.g., if there is a tab after
+the insertion position). If your terminal allows motion while in
+insert mode you can give the capability \fBmir\fR to speed up inserting
+in this case. Omitting \fBmir\fR will affect only speed. Some terminals
+(notably Datamedia's) must not have \fBmir\fR because of the way their
+insert mode works.
+.PP
+Finally, you can specify
+.B dch1
+to delete a single character,
+.B dch
+with one parameter,
+.IR n ,
+to delete
+.I n characters,
+and delete mode by giving \fBsmdc\fR and \fBrmdc\fR
+to enter and exit delete mode (any mode the terminal needs to be placed
+in for
+.B dch1
+to work).
+.PP
+A command to erase
+.I n
+characters (equivalent to outputting
+.I n
+blanks without moving the cursor)
+can be given as
+.B ech
+with one parameter.
+.PP
+.B "Highlighting, Underlining, and Visible Bells"
+.PP
+If your terminal has one or more kinds of display attributes,
+these can be represented in a number of different ways.
+You should choose one display form as
+\f2standout mode\fR,
+representing a good, high contrast, easy-on-the-eyes,
+format for highlighting error messages and other attention getters.
+(If you have a choice, reverse video plus half-bright is good,
+or reverse video alone.)
+The sequences to enter and exit standout mode
+are given as \fBsmso\fR and \fBrmso\fR, respectively.
+If the code to change into or out of standout
+mode leaves one or even two blank spaces on the screen,
+as the TVI 912 and Teleray 1061 do,
+then \fBxmc\fR should be given to tell how many spaces are left.
+.PP
+Codes to begin underlining and end underlining can be given as \fBsmul\fR
+and \fBrmul\fR respectively.
+If the terminal has a code to underline the current character and move
+the cursor one space to the right,
+such as the Microterm Mime,
+this can be given as \fBuc\fR.
+.PP
+Other capabilities to enter various highlighting modes include
+.B blink
+(blinking)
+.B bold
+(bold or extra bright)
+.B dim
+(dim or half-bright)
+.B invis
+(blanking or invisible text)
+.B prot
+(protected)
+.B rev
+(reverse video)
+.B sgr0
+(turn off
+.I all
+attribute modes)
+.B smacs
+(enter alternate character set mode)
+and
+.B rmacs
+(exit alternate character set mode).
+Turning on any of these modes singly may or may not turn off other modes.
+.PP
+If there is a sequence to set arbitrary combinations of modes,
+this should be given as
+.B sgr
+(set attributes),
+taking 9 parameters.
+Each parameter is either 0 or 1, as the corresponding attribute is on or off.
+The 9 parameters are, in order:
+standout, underline, reverse, blink, dim, bold, blank, protect, alternate
+character set.
+Not all modes need be supported by
+.BR sgr ,
+only those for which corresponding separate attribute commands exist.
+.PP
+Terminals with the ``magic cookie'' glitch
+.RB ( xmc )
+deposit special ``cookies'' when they receive mode-setting sequences,
+which affect the display algorithm rather than having extra bits for
+each character.
+Some terminals, such as the HP 2621, automatically leave standout
+mode when they move to a new line or the cursor is addressed.
+Programs using standout mode should exit standout mode before
+moving the cursor or sending a newline,
+unless the
+.B msgr
+capability, asserting that it is safe to move in standout mode, is present.
+.PP
+If the terminal has
+a way of flashing the screen to indicate an error quietly (a bell replacement)
+then this can be given as \fBflash\fR; it must not move the cursor.
+.PP
+If the cursor needs to be made more visible than normal when it is
+not on the bottom line (to make, for example, a non-blinking underline into an
+easier to find block or blinking underline)
+give this sequence as
+.BR cvvis .
+If there is a way to make the cursor completely invisible, give that as
+.BR civis .
+The capability
+.BR cnorm
+should be given which undoes the effects of both of these modes.
+.PP
+If the terminal needs to be in a special mode when running
+a program that uses these capabilities,
+the codes to enter and exit this mode can be given as \fBsmcup\fR and \fBrmcup\fR.
+This arises, for example, from terminals like the Concept with more than
+one page of memory.
+If the terminal has only memory relative cursor addressing and not screen
+relative cursor addressing, a one screen-sized window must be fixed into
+the terminal for cursor addressing to work properly.
+This is also used for the \s-1TEKTRONIX\s+1 4025,
+where
+.B smcup
+sets the command character to be the one used by terminfo.
+.PP
+If your terminal correctly generates underlined characters
+(with no special codes needed)
+even though it does not overstrike,
+then you should give the capability \fBul\fR.
+If overstrikes are erasable with a blank,
+then this should be indicated by giving \fBeo\fR.
+.PP
+.B Keypad
+.PP
+If the terminal has a keypad that transmits codes when the keys are pressed,
+this information can be given. Note that it is not possible to handle
+terminals where the keypad only works in local (this applies, for example,
+to the unshifted HP 2621 keys).
+If the keypad can be set to transmit or not transmit,
+give these codes as \fBsmkx\fR and \fBrmkx\fR.
+Otherwise the keypad is assumed to always transmit.
+The codes sent by the left arrow, right arrow, up arrow, down arrow,
+and home keys can be given as \fBkcub1, kcuf1, kcuu1, kcud1,
+\fRand\fB khome\fR respectively.
+If there are function keys such as f0, f1, ..., f10, the codes they send
+can be given as \fBkf0, kf1, ..., kf10\fR.
+If these keys have labels other than the default f0 through f10, the labels
+can be given as \fBlf0, lf1, ..., lf10\fR.
+The codes transmitted by certain other special keys can be given:
+.B kll
+(home down),
+.B kbs
+(backspace),
+.B ktbc
+(clear all tabs),
+.B kctab
+(clear the tab stop in this column),
+.B kclr
+(clear screen or erase key),
+.B kdch1
+(delete character),
+.B kdl1
+(delete line),
+.B krmir
+(exit insert mode),
+.B kel
+(clear to end of line),
+.B ked
+(clear to end of screen),
+.B kich1
+(insert character or enter insert mode),
+.B kil1
+(insert line),
+.B knp
+(next page),
+.B kpp
+(previous page),
+.B kind
+(scroll forward/down),
+.B kri
+(scroll backward/up),
+.B khts
+(set a tab stop in this column).
+In addition, if the keypad has a 3 by 3 array of keys including the four
+arrow keys, the other five keys can be given as
+.BR ka1 ,
+.BR ka3 ,
+.BR kb2 ,
+.BR kc1 ,
+and
+.BR kc3 .
+These keys are useful when the effects of a 3 by 3 directional pad are needed.
+.PP
+.B Tabs and Initialization
+.PP
+If the terminal has hardware tabs, the command to advance to the next
+tab stop can be given as
+.B ht
+(usually control I).
+A ``backtab'' command which moves leftward to the next tab stop can
+be given as
+.BR cbt .
+By convention, if the teletype modes indicate that tabs are being
+expanded by the computer rather than being sent to the terminal,
+programs should not use
+.B ht
+or
+.B cbt
+even if they are present, since the user may not have the tab stops
+properly set.
+If the terminal has hardware tabs which are initially set every
+.I n
+spaces when the terminal is powered up,
+the numeric parameter
+.B it
+is given, showing the number of spaces the tabs are set to.
+This is normally used by the
+.IR tset
+command to determine whether to set the mode for hardware tab expansion,
+and whether to set the tab stops.
+If the terminal has tab stops that can be saved in nonvolatile memory,
+the terminfo description can assume that they are properly set.
+.PP
+Other capabilities
+include
+.BR is1 ,
+.BR is2 ,
+and
+.BR is3 ,
+initialization strings for the terminal,
+.BR iprog ,
+the path name of a program to be run to initialize the terminal,
+and \fBif\fR, the name of a file containing long initialization strings.
+These strings are expected to set the terminal into modes consistent
+with the rest of the terminfo description.
+They are normally sent to the terminal, by the
+.IR tset
+program, each time the user logs in.
+They will be printed in the following order:
+.BR is1 ;
+.BR is2 ;
+setting tabs using
+.B tbc
+and
+.BR hts ;
+.BR if ;
+running the program
+.BR iprog ;
+and finally
+.BR is3 .
+Most initialization is done with
+.BR is2 .
+Special terminal modes can be set up without duplicating strings
+by putting the common sequences in
+.B is2
+and special cases in
+.B is1
+and
+.BR is3 .
+A pair of sequences that does a harder reset from a totally unknown state
+can be analogously given as
+.BR rs1 ,
+.BR rs2 ,
+.BR rf ,
+and
+.BR rs3 ,
+analogous to
+.B is2
+and
+.BR if .
+These strings are output by the
+.IR reset
+program, which is used when the terminal gets into a wedged state.
+Commands are normally placed in
+.B rs2
+and
+.B rf
+only if they produce annoying effects on the screen and are not
+necessary when logging in.
+For example, the command to set the vt100 into 80-column mode would
+normally be part of
+.BR is2 ,
+but it causes an annoying glitch of the screen and is not normally
+needed since the terminal is usually already in 80 column mode.
+.PP
+If there are commands to set and clear tab stops, they can be given as
+.B tbc
+(clear all tab stops)
+and
+.B hts
+(set a tab stop in the current column of every row).
+If a more complex sequence is needed to set the tabs than can be
+described by this, the sequence can be placed in
+.B is2
+or
+.BR if .
+.PP
+Delays
+.PP
+Certain capabilities control padding in the teletype driver.
+These are primarily needed by hard copy terminals, and are used
+by the
+.IR tset
+program to set teletype modes appropriately.
+Delays embedded in the capabilities
+.BR cr ,
+.BR ind ,
+.BR cub1 ,
+.BR ff ,
+and
+.B tab
+will cause the appropriate delay bits to be set in the teletype driver.
+If
+.B pb
+(padding baud rate)
+is given,
+these values can be ignored at baud rates below the value of
+.BR pb .
+.PP
+.B Miscellaneous
+.PP
+If the terminal requires other than a null (zero) character as a pad,
+then this can be given as \fBpad\fR.
+Only the first character of the
+.B pad
+string is used.
+.PP
+If the terminal has an extra ``status line'' that is not normally
+used by software, this fact can be indicated.
+If the status line is viewed as an extra line below the bottom line,
+into which one can cursor address normally
+(such as the Heathkit h19's 25th line, or the 24th line of a vt100
+which is set to a 23-line scrolling region),
+the capability
+.B hs
+should be given.
+Special strings to go to the beginning of the status
+line and to return from the status line can be given as
+.B tsl
+and
+.BR fsl .
+.RB ( fsl
+must leave the cursor position in the same place it was before
+.BR tsl .
+If necessary, the
+.B sc
+and
+.B rc
+strings can be included in
+.B tsl
+and
+.B fsl
+to get this effect.)
+The parameter
+.B tsl
+takes one parameter, which is the column number of the status line
+the cursor is to be moved to.
+If escape sequences and other special commands, such as tab, work
+while in the status line, the flag
+.B eslok
+can be given.
+A string which turns off the status line (or otherwise erases its
+contents) should be given as
+.BR dsl .
+If the terminal has commands to save and restore the position of the cursor,
+give them as
+.B sc
+and
+.BR rc .
+The status line is normally assumed to be the same width as the rest
+of the screen, e.g.,
+.BR cols .
+If the status line is a different width (possibly because the terminal
+does not allow an entire line to be loaded) the width, in columns,
+can be indicated with the numeric parameter
+.BR wsl .
+.PP
+If the terminal can move up or down half a line,
+this can be indicated with
+.B hu
+(half-line up)
+and
+.B hd
+(half-line down).
+This is primarily useful for superscripts and subscripts on hardcopy terminals.
+If a hardcopy terminal can eject to the next page (form feed), give this as
+.B ff
+(usually control L).
+.PP
+If there is a command to repeat a given character a given number of
+times (to save time transmitting a large number of identical characters)
+this can be indicated with the parameterized string
+.BR rep .
+The first parameter is the character to be repeated and the second
+is the number of times to repeat it.
+Thus, tparm(repeat_char, 'x', 10) is the same as `xxxxxxxxxx'.
+.PP
+If the terminal has a settable command character, such as the \s-1TEKTRONIX\s+1 4025,
+this can be indicated with
+.BR cmdch .
+A prototype command character is chosen which is used in all capabilities.
+This character is given in the
+.B cmdch
+capability to identify it.
+The following convention is supported on some UNIX systems:
+The environment is to be searched for a
+.B CC
+variable, and if found, all
+occurrences of the prototype character are replaced with the character
+in the environment variable.
+.PP
+Terminal descriptions that do not represent a specific kind of known
+terminal, such as
+.IR switch ,
+.IR dialup ,
+.IR patch ,
+and
+.IR network ,
+should include the
+.B gn
+(generic) capability so that programs can complain that they do not know
+how to talk to the terminal.
+(This capability does not apply to
+.I virtual
+terminal descriptions for which the escape sequences are known.)
+.PP
+If the terminal uses xon/xoff handshaking for flow control, give
+.BR xon .
+Padding information should still be included so that routines can
+make better decisions about costs, but actual pad characters will
+not be transmitted.
+.PP
+If the terminal has a ``meta key'' which acts as a shift key,
+setting the 8th bit of any character transmitted, this fact can
+be indicated with
+.BR km .
+Otherwise, software will assume that the 8th bit is parity and it
+will usually be cleared.
+If strings exist to turn this ``meta mode'' on and off, they
+can be given as
+.B smm
+and
+.BR rmm .
+.PP
+If the terminal has more lines of memory than will fit on the screen
+at once, the number of lines of memory can be indicated with
+.BR lm .
+A value of
+.BR lm #0
+indicates that the number of lines is not fixed,
+but that there is still more memory than fits on the screen.
+.PP
+If the terminal is one of those supported by the \s-1UNIX\s+1 virtual
+terminal protocol, the terminal number can be given as
+.BR vt .
+.PP
+Media copy
+strings which control an auxiliary printer connected to the terminal
+can be given as
+.BR mc0 :
+print the contents of the screen,
+.BR mc4 :
+turn off the printer, and
+.BR mc5 :
+turn on the printer.
+When the printer is on, all text sent to the terminal will be sent
+to the printer.
+It is undefined whether the text is also displayed on the terminal screen
+when the printer is on.
+A variation
+.B mc5p
+takes one parameter, and leaves the printer on for as many characters
+as the value of the parameter, then turns the printer off.
+The parameter should not exceed 255.
+All text, including
+.BR mc4 ,
+is transparently passed to the printer while an
+.B mc5p
+is in effect.
+.PP
+Strings to program function keys can be given as
+.BR pfkey ,
+.BR pfloc ,
+and
+.BR pfx .
+Each of these strings takes two parameters: the function key number to
+program (from 0 to 10) and the string to program it with.
+Function key numbers out of this range may program undefined keys in
+a terminal dependent manner.
+The difference between the capabilities is that
+.B pfkey
+causes pressing the given key to be the same as the user typing the
+given string;
+.B pfloc
+causes the string to be executed by the terminal in local; and
+.B pfx
+causes the string to be transmitted to the computer.
+.PP
+.B Glitches and Braindamage
+.PP
+Hazeltine terminals, which do not allow `~' characters to be displayed should
+indicate \fBhz\fR.
+.PP
+Terminals which ignore a linefeed immediately after an \fBam\fR wrap,
+such as the Concept and vt100,
+should indicate \fBxenl\fR.
+.PP
+If
+.B el
+is required to get rid of standout
+(instead of merely writing normal text on top of it),
+\fBxhp\fP should be given.
+.PP
+Teleray terminals, where tabs turn all characters moved over to blanks,
+should indicate \fBxt\fR (destructive tabs).
+Note: the variable indicating this is now `dest_tabs_magic_smso'; in
+older versions, it was teleray_glitch.
+This glitch is also taken to mean that it is not possible to position
+the cursor on top of a ``magic cookie'',
+that to erase standout mode it is instead necessary to use
+delete and insert line.
+.PP
+The Beehive Superbee, which is unable to correctly transmit the escape
+or control C characters, has
+.BR xsb ,
+indicating that the f1 key is used for escape and f2 for control C.
+(Only certain Superbees have this problem, depending on the ROM.)
+Note that in older terminfo versions, this capability was called
+`beehive_glitch'; it is now `no_esc_ctl_c'.
+.PP
+Other specific terminal problems may be corrected by adding more
+capabilities of the form \fBx\fIx\fR.
+.PP
+.B Similar Terminals
+.PP
+If there are two very similar terminals,
+one can be defined as being just like the other with certain exceptions.
+The string capability \fBuse\fR can be given
+with the name of the similar terminal.
+The capabilities given before
+.B use
+override those in the terminal type invoked by
+.BR use .
+A capability can be cancelled by placing \fBxx@\fR to the left of the
+capability definition, where xx is the capability.
+For example, the entry
+.PP
+ 2621-nl, smkx@, rmkx@, use=2621,
+.PP
+defines a 2621-nl that does not have the \fBsmkx\fR or \fBrmkx\fR capabilities,
+and hence does not turn on the function key labels when in visual mode.
+This is useful for different modes for a terminal, or for different
+user preferences.
+.SH FILES
+.TP 25
+\*d/?/*
+files containing terminal descriptions
+.SH "SEE ALSO"
+tic(1m), curses(3X), printf(3S), term(\*n).
+.SH AUTHORS
+Pavel Curtis, Zeyd M. Ben-Halim
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libncurses/unctrl.h b/lib/libncurses/unctrl.h
new file mode 100644
index 0000000..c80689c
--- /dev/null
+++ b/lib/libncurses/unctrl.h
@@ -0,0 +1,21 @@
+
+/*
+ * unctrl.h
+ *
+ * Display a printable version of a control character.
+ * Control characters are displayed in caret notation (^x), DELETE is displayed
+ * as ^?. Printable characters sre displatyed 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
+
+#include <sys/cdefs.h>
+
+extern char *unctrl __P((unsigned char));
+
+#endif /* _UNCTRL_H */
diff --git a/lib/libncurses/version.h b/lib/libncurses/version.h
new file mode 100644
index 0000000..15ec892
--- /dev/null
+++ b/lib/libncurses/version.h
@@ -0,0 +1,3 @@
+
+#define NCURSES_VERSION "1.8.5"
+
OpenPOWER on IntegriCloud