aboutsummaryrefslogtreecommitdiff
path: root/payloads/libpayload/curses/PDCurses/demos
diff options
context:
space:
mode:
authorStefan Reinauer <stefan.reinauer@coreboot.org>2015-11-10 09:00:41 -0800
committerStefan Reinauer <stefan.reinauer@coreboot.org>2015-11-11 21:38:48 +0100
commit4f85a1eb76d1e7109bcc60ba6f3262a5654ac61b (patch)
treee996818c6aa6b6f702a6c805c447c20724eff265 /payloads/libpayload/curses/PDCurses/demos
parent2ea24dabd658b8396e0abf79318a538ef0f3a5b8 (diff)
libpayload: Rename PDCurses-3.4 to PDCurses
Change-Id: If881ec130833c7e7e62caa3d31e350a531f5bc8e Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Reviewed-on: http://review.coreboot.org/12398 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'payloads/libpayload/curses/PDCurses/demos')
-rw-r--r--payloads/libpayload/curses/PDCurses/demos/README25
-rw-r--r--payloads/libpayload/curses/PDCurses/demos/firework.c148
-rw-r--r--payloads/libpayload/curses/PDCurses/demos/newdemo.c425
-rw-r--r--payloads/libpayload/curses/PDCurses/demos/ptest.c285
-rw-r--r--payloads/libpayload/curses/PDCurses/demos/rain.c159
-rw-r--r--payloads/libpayload/curses/PDCurses/demos/testcurs.c1144
-rw-r--r--payloads/libpayload/curses/PDCurses/demos/tui.c821
-rw-r--r--payloads/libpayload/curses/PDCurses/demos/tui.h67
-rw-r--r--payloads/libpayload/curses/PDCurses/demos/tuidemo.c233
-rw-r--r--payloads/libpayload/curses/PDCurses/demos/worm.c434
-rw-r--r--payloads/libpayload/curses/PDCurses/demos/xmas.c957
11 files changed, 4698 insertions, 0 deletions
diff --git a/payloads/libpayload/curses/PDCurses/demos/README b/payloads/libpayload/curses/PDCurses/demos/README
new file mode 100644
index 0000000000..8f4b5c6c23
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses/demos/README
@@ -0,0 +1,25 @@
+PDCurses Demos
+==============
+
+This directory contains demonstration programs to show and test the
+capabilities of curses libraries. Some of them predate PDCurses,
+PCcurses or even pcurses/ncurses. Although some PDCurses-specific code
+has been added, all programs remain portable to other implementations
+(at a minimum, to ncurses).
+
+
+Building
+--------
+
+The demos are built by the platform-specific makefiles, in the platform
+directories. Alternatively, you can build them manually, individually,
+and link with any curses library; e.g., "cc -lcurses -orain rain.c".
+There are no dependencies besides curses and the standard C library, and
+no configuration is needed.
+
+
+Distribution Status
+-------------------
+
+Public Domain, except for rain.c and worm.c, which are under the ncurses
+license (MIT-like).
diff --git a/payloads/libpayload/curses/PDCurses/demos/firework.c b/payloads/libpayload/curses/PDCurses/demos/firework.c
new file mode 100644
index 0000000000..61fd65d549
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses/demos/firework.c
@@ -0,0 +1,148 @@
+/* $Id: firework.c,v 1.25 2008/07/13 16:08:17 wmcbrine Exp $ */
+
+#include <stdio.h>
+#include <signal.h>
+#include <curses.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <time.h>
+
+#define DELAYSIZE 200
+
+void myrefresh(void);
+void get_color(void);
+void explode(int, int);
+
+short color_table[] =
+{
+ COLOR_RED, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN,
+ COLOR_RED, COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE
+};
+
+int main(int argc, char **argv)
+{
+ int i, start, end, row, diff, flag, direction, seed;
+
+#ifdef XCURSES
+ Xinitscr(argc, argv);
+#else
+ initscr();
+#endif
+ nodelay(stdscr, TRUE);
+ noecho();
+
+ if (has_colors())
+ start_color();
+
+ for (i = 0; i < 8; i++)
+ init_pair(i, color_table[i], COLOR_BLACK);
+
+ seed = time((time_t *)0);
+ srand(seed);
+ flag = 0;
+
+ while (getch() == ERR) /* loop until a key is hit */
+ {
+ 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++)
+ {
+ mvaddstr(LINES - row, row * direction + start,
+ (direction < 0) ? "\\" : "/");
+
+ if (flag++)
+ {
+ myrefresh();
+ erase();
+ flag = 0;
+ }
+ }
+
+ if (flag++)
+ {
+ myrefresh();
+ flag = 0;
+ }
+
+ explode(LINES - row, diff * direction + start);
+ erase();
+ myrefresh();
+ }
+
+ endwin();
+
+ return 0;
+}
+
+void explode(int row, int col)
+{
+ erase();
+ mvaddstr(row, col, "-");
+ myrefresh();
+
+ --col;
+
+ get_color();
+ mvaddstr(row - 1, col, " - ");
+ mvaddstr(row, col, "-+-");
+ mvaddstr(row + 1, col, " - ");
+ myrefresh();
+
+ --col;
+
+ get_color();
+ mvaddstr(row - 2, col, " --- ");
+ mvaddstr(row - 1, col, "-+++-");
+ mvaddstr(row, col, "-+#+-");
+ mvaddstr(row + 1, col, "-+++-");
+ mvaddstr(row + 2, col, " --- ");
+ myrefresh();
+
+ get_color();
+ mvaddstr(row - 2, col, " +++ ");
+ mvaddstr(row - 1, col, "++#++");
+ mvaddstr(row, col, "+# #+");
+ mvaddstr(row + 1, col, "++#++");
+ mvaddstr(row + 2, col, " +++ ");
+ myrefresh();
+
+ get_color();
+ mvaddstr(row - 2, col, " # ");
+ mvaddstr(row - 1, col, "## ##");
+ mvaddstr(row, col, "# #");
+ mvaddstr(row + 1, col, "## ##");
+ mvaddstr(row + 2, col, " # ");
+ myrefresh();
+
+ get_color();
+ mvaddstr(row - 2, col, " # # ");
+ mvaddstr(row - 1, col, "# #");
+ mvaddstr(row, col, " ");
+ mvaddstr(row + 1, col, "# #");
+ mvaddstr(row + 2, col, " # # ");
+ myrefresh();
+}
+
+void myrefresh(void)
+{
+ napms(DELAYSIZE);
+ move(LINES - 1, COLS - 1);
+ refresh();
+}
+
+void get_color(void)
+{
+ chtype bold = (rand() % 2) ? A_BOLD : A_NORMAL;
+ attrset(COLOR_PAIR(rand() % 8) | bold);
+}
diff --git a/payloads/libpayload/curses/PDCurses/demos/newdemo.c b/payloads/libpayload/curses/PDCurses/demos/newdemo.c
new file mode 100644
index 0000000000..eefc0c16f1
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses/demos/newdemo.c
@@ -0,0 +1,425 @@
+/*
+ * newdemo.c - A demo program using PDCurses. The program
+ * illustrates the use of colors for text output.
+ *
+ * Hacks by jbuhler@cs.washington.edu on 12/29/96
+ *
+ * $Id: newdemo.c,v 1.39 2008/07/13 16:08:17 wmcbrine Exp $
+ */
+
+#include <stdio.h>
+#include <signal.h>
+#include <string.h>
+#include <curses.h>
+#include <stdlib.h>
+#include <time.h>
+
+int WaitForUser(void);
+int SubWinTest(WINDOW *);
+int BouncingBalls(WINDOW *);
+void trap(int);
+
+/* An ASCII map of Australia */
+
+char *AusMap[17] =
+{
+ " A ",
+ " AA AA ",
+ " N.T. AAAAA AAAA ",
+ " AAAAAAAAAAA AAAAAAAA ",
+ " AAAAAAAAAAAAAAAAAAAAAAAAA Qld.",
+ " AAAAAAAAAAAAAAAAAAAAAAAAAAAA ",
+ " AAAAAAAAAAAAAAAAAAAAAAAAAAAAA ",
+ " AAAAAAAAAAAAAAAAAAAAAAAAAAAA ",
+ " AAAAAAAAAAAAAAAAAAAAAAAAA N.S.W.",
+ "W.A. AAAAAAAAA AAAAAA Vic.",
+ " AAA S.A. AA",
+ " A Tas.",
+ ""
+};
+
+/* Funny messages for the scroller */
+
+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",
+ NULL
+};
+
+int WaitForUser(void)
+{
+ chtype ch;
+
+ nodelay(stdscr, TRUE);
+ halfdelay(50);
+
+ ch = getch();
+
+ nodelay(stdscr, FALSE);
+ nocbreak(); /* Reset the halfdelay() value */
+ cbreak();
+
+ return (ch == '\033') ? ch : 0;
+}
+
+int SubWinTest(WINDOW *win)
+{
+ WINDOW *swin1, *swin2, *swin3;
+ int w, h, sw, sh, bx, by;
+
+ wattrset(win, 0);
+ getmaxyx(win, h, w);
+ getbegyx(win, by, bx);
+
+ sw = w / 3;
+ sh = h / 3;
+
+ if ((swin1 = derwin(win, sh, sw, 3, 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);
+ wbkgd(swin1, COLOR_PAIR(8));
+ werase(swin1);
+ mvwaddstr(swin1, 0, 3, "Sub-window 1");
+ wrefresh(swin1);
+
+ init_pair(9, COLOR_CYAN, COLOR_MAGENTA);
+ wbkgd(swin2, COLOR_PAIR(9));
+ werase(swin2);
+ mvwaddstr(swin2, 0, 3, "Sub-window 2");
+ wrefresh(swin2);
+
+ init_pair(10, COLOR_YELLOW, COLOR_GREEN);
+ wbkgd(swin3, COLOR_PAIR(10));
+ werase(swin3);
+ mvwaddstr(swin3, 0, 3, "Sub-window 3");
+ wrefresh(swin3);
+
+ delwin(swin1);
+ delwin(swin2);
+ delwin(swin3);
+ WaitForUser();
+
+ return 0;
+}
+
+int BouncingBalls(WINDOW *win)
+{
+ chtype c1, c2, c3, ball1, ball2, ball3;
+ int w, h, x1, y1, xd1, yd1, x2, y2, xd2, yd2, x3, y3, xd3, yd3, c;
+
+ curs_set(0);
+
+ wbkgd(win, COLOR_PAIR(1));
+ wrefresh(win);
+ wattrset(win, 0);
+
+ init_pair(11, COLOR_RED, COLOR_GREEN);
+ init_pair(12, COLOR_BLUE, COLOR_RED);
+ init_pair(13, COLOR_YELLOW, COLOR_WHITE);
+
+ ball1 = 'O' | COLOR_PAIR(11);
+ ball2 = '*' | COLOR_PAIR(12);
+ ball3 = '@' | COLOR_PAIR(13);
+
+ getmaxyx(win, h, w);
+
+ 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 = -1;
+ xd3 = -1;
+ yd3 = 1;
+
+ nodelay(stdscr, TRUE);
+
+ while ((c = getch()) == ERR)
+ {
+ x1 += xd1;
+ if (x1 <= 1 || x1 >= w - 2)
+ xd1 *= -1;
+
+ y1 += yd1;
+ if (y1 <= 1 || y1 >= h - 2)
+ yd1 *= -1;
+
+ x2 += xd2;
+ if (x2 <= 1 || x2 >= w - 2)
+ xd2 *= -1;
+
+ y2 += yd2;
+ if (y2 <= 1 || y2 >= h - 2)
+ yd2 *= -1;
+
+ x3 += xd3;
+ if (x3 <= 1 || x3 >= w - 2)
+ xd3 *= -1;
+
+ y3 += yd3;
+ if (y3 <= 1 || y3 >= h - 2)
+ yd3 *= -1;
+
+ c1 = mvwinch(win, y1, x1);
+ c2 = mvwinch(win, y2, x2);
+ c3 = mvwinch(win, y3, x3);
+
+ mvwaddch(win, y1, x1, ball1);
+ mvwaddch(win, y2, x2, ball2);
+ mvwaddch(win, y3, x3, ball3);
+
+ wmove(win, 0, 0);
+ wrefresh(win);
+
+ mvwaddch(win, y1, x1, c1);
+ mvwaddch(win, y2, x2, c2);
+ mvwaddch(win, y3, x3, c3);
+
+ napms(150);
+ }
+
+ nodelay(stdscr, FALSE);
+ ungetch(c);
+ return 0;
+}
+
+/* Trap interrupt */
+
+void trap(int sig)
+{
+ if (sig == SIGINT)
+ {
+ endwin();
+
+ exit(0);
+ }
+}
+
+int main(int argc, char **argv)
+{
+ WINDOW *win;
+ chtype save[80], ch;
+ int width, height, w, x, y, i, j, seed;
+
+#ifdef XCURSES
+ Xinitscr(argc, argv);
+#else
+ initscr();
+#endif
+ seed = time((time_t *)0);
+ srand(seed);
+
+ start_color();
+# if defined(NCURSES_VERSION) || (defined(PDC_BUILD) && PDC_BUILD > 3000)
+ use_default_colors();
+# endif
+ cbreak();
+ noecho();
+
+ curs_set(0);
+
+#if !defined(__TURBOC__) && !defined(OS2)
+ signal(SIGINT, trap);
+#endif
+ noecho();
+
+ /* refresh stdscr so that reading from it will not cause it to
+ overwrite the other windows that are being created */
+
+ refresh();
+
+ /* Create a drawing window */
+
+ width = 48;
+ height = 15;
+
+ win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2);
+
+ if (win == NULL)
+ {
+ endwin();
+
+ return 1;
+ }
+
+ for (;;)
+ {
+ init_pair(1, COLOR_WHITE, COLOR_BLUE);
+ wbkgd(win, COLOR_PAIR(1));
+ werase(win);
+
+ init_pair(2, COLOR_RED, COLOR_RED);
+ wattrset(win, COLOR_PAIR(2));
+ box(win, ' ', ' ');
+ wrefresh(win);
+
+ wattrset(win, 0);
+
+ /* Do random output of a character */
+
+ ch = 'a';
+
+ nodelay(stdscr, TRUE);
+
+ for (i = 0; i < 5000; ++i)
+ {
+ x = rand() % (width - 2) + 1;
+ y = rand() % (height - 2) + 1;
+
+ mvwaddch(win, y, x, ch);
+ wrefresh(win);
+
+ if (getch() != ERR)
+ break;
+
+ if (i == 2000)
+ {
+ ch = 'b';
+ init_pair(3, COLOR_CYAN, COLOR_YELLOW);
+ wattrset(win, COLOR_PAIR(3));
+ }
+ }
+
+ nodelay(stdscr, FALSE);
+
+ SubWinTest(win);
+
+ /* Erase and draw green window */
+
+ init_pair(4, COLOR_YELLOW, COLOR_GREEN);
+ wbkgd(win, COLOR_PAIR(4));
+ wattrset(win, A_BOLD);
+ werase(win);
+ wrefresh(win);
+
+ /* Draw RED bounding box */
+
+ wattrset(win, COLOR_PAIR(2));
+ box(win, ' ', ' ');
+ wrefresh(win);
+
+ /* Display Australia map */
+
+ wattrset(win, A_BOLD);
+ i = 0;
+
+ while (*AusMap[i])
+ {
+ mvwaddstr(win, i + 1, 8, AusMap[i]);
+ wrefresh(win);
+ napms(100);
+ ++i;
+ }
+
+ init_pair(5, COLOR_BLUE, COLOR_WHITE);
+ wattrset(win, COLOR_PAIR(5) | A_BLINK);
+ mvwaddstr(win, height - 2, 3,
+ " PDCurses 3.4 - DOS, OS/2, Win32, X11, SDL");
+ wrefresh(win);
+
+ /* Draw running messages */
+
+ init_pair(6, COLOR_BLACK, COLOR_WHITE);
+ wattrset(win, COLOR_PAIR(6));
+ w = width - 2;
+ nodelay(win, TRUE);
+
+ /* jbuhler's re-hacked scrolling messages */
+
+ for (j = 0; messages[j] != NULL; j++)
+ {
+ char *message = messages[j];
+ int msg_len = strlen(message);
+ int scroll_len = w + 2 * msg_len;
+ char *scrollbuf = malloc(scroll_len);
+ char *visbuf = scrollbuf + msg_len;
+ int stop = 0;
+ int i;
+
+ for (i = w + msg_len; i > 0; i--)
+ {
+ memset(visbuf, ' ', w);
+ strncpy(scrollbuf + i, message, msg_len);
+ mvwaddnstr(win, height / 2, 1, visbuf, w);
+ wrefresh(win);
+
+ if (wgetch(win) != ERR)
+ {
+ flushinp();
+ stop = 1;
+ break;
+ }
+
+ napms(100);
+ }
+
+ free(scrollbuf);
+
+ if (stop)
+ break;
+ }
+
+ j = 0;
+
+ /* Draw running 'A's across in RED */
+
+ init_pair(7, COLOR_RED, COLOR_GREEN);
+ wattron(win, COLOR_PAIR(7));
+
+ for (i = 2; i < width - 4; ++i)
+ {
+ ch = mvwinch(win, 5, i);
+ save[j++] = ch;
+ ch = ch & 0x7f;
+ mvwaddch(win, 5, i, ch);
+ }
+
+ wrefresh(win);
+
+ /* Put a message up; wait for a key */
+
+ i = height - 2;
+ wattrset(win, COLOR_PAIR(5));
+ mvwaddstr(win, i, 3,
+ " Type a key to continue or ESC to quit ");
+ wrefresh(win);
+
+ if (WaitForUser() == '\033')
+ break;
+
+ /* Restore the old line */
+
+ wattrset(win, 0);
+
+ for (i = 2, j = 0; i < width - 4; ++i)
+ mvwaddch(win, 5, i, save[j++]);
+
+ wrefresh(win);
+
+ BouncingBalls(win);
+
+ /* BouncingBalls() leaves a keystroke in the queue */
+
+ if (WaitForUser() == '\033')
+ break;
+ }
+
+ endwin();
+
+ return 0;
+}
diff --git a/payloads/libpayload/curses/PDCurses/demos/ptest.c b/payloads/libpayload/curses/PDCurses/demos/ptest.c
new file mode 100644
index 0000000000..6071f79d0e
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses/demos/ptest.c
@@ -0,0 +1,285 @@
+/* $Id: ptest.c,v 1.24 2008/07/13 16:08:17 wmcbrine Exp $ */
+
+#include <curses.h>
+#include <panel.h>
+#include <stdlib.h>
+
+PANEL *p1, *p2, *p3, *p4, *p5;
+WINDOW *w4, *w5;
+
+long nap_msec = 1;
+
+char *mod[] =
+{
+ "test ", "TEST ", "(**) ", "*()* ", "<--> ", "LAST "
+};
+
+void pflush(void)
+{
+ update_panels();
+ doupdate();
+}
+
+void backfill(void)
+{
+ int y, x;
+
+ erase();
+
+ for (y = 0; y < LINES - 1; y++)
+ for (x = 0; x < COLS; x++)
+ printw("%d", (y + x) % 10);
+}
+
+void wait_a_while(long msec)
+{
+ int c;
+
+ if (msec != 1)
+ timeout(msec);
+
+ c = getch();
+
+ if (c == 'q')
+ {
+ endwin();
+ exit(1);
+ }
+}
+
+void saywhat(const char *text)
+{
+ mvprintw(LINES - 1, 0, "%-20.20s", text);
+}
+
+/* mkpanel - alloc a win and panel and associate them */
+
+PANEL *mkpanel(int rows, int cols, int tly, int tlx)
+{
+ WINDOW *win = newwin(rows, cols, tly, tlx);
+ PANEL *pan = (PANEL *)0;
+
+ if (win)
+ {
+ pan = new_panel(win);
+
+ if (!pan)
+ delwin(win);
+ }
+
+ return pan;
+}
+
+void rmpanel(PANEL *pan)
+{
+ WINDOW *win = pan->win;
+
+ del_panel(pan);
+ delwin(win);
+}
+
+void fill_panel(PANEL *pan)
+{
+ WINDOW *win = pan->win;
+ char num = *((char *)pan->user + 1);
+ int y, x, maxy, maxx;
+
+ box(win, 0, 0);
+ mvwprintw(win, 1, 1, "-pan%c-", num);
+ getmaxyx(win, maxy, maxx);
+
+ for (y = 2; y < maxy - 1; y++)
+ for (x = 1; x < maxx - 1; x++)
+ mvwaddch(win, y, x, num);
+}
+
+int main(int argc, char **argv)
+{
+ int itmp, y;
+
+ if (argc > 1 && atol(argv[1]))
+ nap_msec = atol(argv[1]);
+
+#ifdef XCURSES
+ Xinitscr(argc, argv);
+#else
+ initscr();
+#endif
+ backfill();
+
+ for (y = 0; y < 5; y++)
+ {
+ p1 = mkpanel(10, 10, 0, 0);
+ set_panel_userptr(p1, "p1");
+
+ p2 = mkpanel(14, 14, 5, 5);
+ set_panel_userptr(p2, "p2");
+
+ p3 = mkpanel(6, 8, 12, 12);
+ set_panel_userptr(p3, "p3");
+
+ p4 = mkpanel(10, 10, 10, 30);
+ w4 = panel_window(p4);
+ set_panel_userptr(p4, "p4");
+
+ p5 = mkpanel(10, 10, 13, 37);
+ w5 = panel_window(p5);
+ set_panel_userptr(p5, "p5");
+
+ fill_panel(p1);
+ fill_panel(p2);
+ fill_panel(p3);
+ fill_panel(p4);
+ fill_panel(p5);
+ hide_panel(p4);
+ hide_panel(p5);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("h3 s1 s2 s4 s5;");
+ move_panel(p1, 0, 0);
+ hide_panel(p3);
+ show_panel(p1);
+ show_panel(p2);
+ show_panel(p4);
+ show_panel(p5);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("s1;");
+ show_panel(p1);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("s2;");
+ show_panel(p2);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("m2;");
+ move_panel(p2, 10, 10);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("s3;");
+ show_panel(p3);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("m3;");
+ move_panel(p3, 5, 5);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("b3;");
+ bottom_panel(p3);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("s4;");
+ show_panel(p4);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("s5;");
+ show_panel(p5);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("t3;");
+ top_panel(p3);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("t1;");
+ top_panel(p1);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("t2;");
+ top_panel(p2);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("t3;");
+ top_panel(p3);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("t4;");
+ top_panel(p4);
+ pflush();
+ wait_a_while(nap_msec);
+
+ for (itmp = 0; itmp < 6; itmp++)
+ {
+ saywhat("m4;");
+ mvwaddstr(w4, 3, 1, mod[itmp]);
+ move_panel(p4, 4, itmp * 10);
+ mvwaddstr(w5, 4, 1, mod[itmp]);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("m5;");
+ mvwaddstr(w4, 4, 1, mod[itmp]);
+ move_panel(p5, 7, itmp * 10 + 6);
+ mvwaddstr(w5, 3, 1, mod[itmp]);
+ pflush();
+ wait_a_while(nap_msec);
+ }
+
+ saywhat("m4;");
+ move_panel(p4, 4, itmp * 10);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("t5;");
+ top_panel(p5);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("t2;");
+ top_panel(p2);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("t1;");
+ top_panel(p1);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("d2;");
+ rmpanel(p2);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("h3;");
+ hide_panel(p3);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("d1;");
+ rmpanel(p1);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("d4; ");
+ rmpanel(p4);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("d5; ");
+ rmpanel(p5);
+ pflush();
+ wait_a_while(nap_msec);
+
+ if (nap_msec == 1)
+ break;
+
+ nap_msec = 100L;
+ }
+
+ endwin();
+
+ return 0;
+} /* end of main */
diff --git a/payloads/libpayload/curses/PDCurses/demos/rain.c b/payloads/libpayload/curses/PDCurses/demos/rain.c
new file mode 100644
index 0000000000..51d05a9056
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses/demos/rain.c
@@ -0,0 +1,159 @@
+/****************************************************************************
+ * Copyright (c) 2002 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/* $Id: rain.c,v 1.11 2008/07/13 16:08:17 wmcbrine Exp $ */
+
+#include <curses.h>
+#include <stdlib.h>
+#include <time.h>
+
+/* rain 11/3/1980 EPS/CITHEP */
+
+static int next_j(int j)
+{
+ if (j == 0)
+ j = 4;
+ else
+ --j;
+
+ if (has_colors())
+ {
+ int z = rand() % 3;
+ chtype color = COLOR_PAIR(z);
+
+ if (z)
+ color |= A_BOLD;
+
+ attrset(color);
+ }
+
+ return j;
+}
+
+int main(int argc, char *argv[])
+{
+ int x, y, j, r, c, seed;
+ static int xpos[5], ypos[5];
+
+#ifdef XCURSES
+ Xinitscr(argc, argv);
+#else
+ initscr();
+#endif
+ seed = time((time_t *)0);
+ srand(seed);
+
+ if (has_colors())
+ {
+ int bg = COLOR_BLACK;
+
+ start_color();
+
+#if defined(NCURSES_VERSION) || (defined(PDC_BUILD) && PDC_BUILD > 3000)
+ if (use_default_colors() == OK)
+ bg = -1;
+#endif
+ init_pair(1, COLOR_BLUE, bg);
+ init_pair(2, COLOR_CYAN, bg);
+ }
+
+ nl();
+ noecho();
+ curs_set(0);
+ timeout(0);
+ keypad(stdscr, TRUE);
+
+ r = LINES - 4;
+ c = COLS - 4;
+
+ for (j = 5; --j >= 0;)
+ {
+ xpos[j] = rand() % c + 2;
+ ypos[j] = rand() % r + 2;
+ }
+
+ for (j = 0;;)
+ {
+ x = rand() % c + 2;
+ y = rand() % r + 2;
+
+ mvaddch(y, x, '.');
+
+ mvaddch(ypos[j], xpos[j], 'o');
+
+ j = next_j(j);
+ mvaddch(ypos[j], xpos[j], 'O');
+
+ j = next_j(j);
+ mvaddch(ypos[j] - 1, xpos[j], '-');
+ mvaddstr(ypos[j], xpos[j] - 1, "|.|");
+ mvaddch(ypos[j] + 1, xpos[j], '-');
+
+ j = next_j(j);
+ mvaddch(ypos[j] - 2, xpos[j], '-');
+ mvaddstr(ypos[j] - 1, xpos[j] - 1, "/ \\");
+ mvaddstr(ypos[j], xpos[j] - 2, "| O |");
+ mvaddstr(ypos[j] + 1, xpos[j] - 1, "\\ /");
+ mvaddch(ypos[j] + 2, xpos[j], '-');
+
+ j = next_j(j);
+ mvaddch(ypos[j] - 2, xpos[j], ' ');
+ mvaddstr(ypos[j] - 1, xpos[j] - 1, " ");
+ mvaddstr(ypos[j], xpos[j] - 2, " ");
+ mvaddstr(ypos[j] + 1, xpos[j] - 1, " ");
+ mvaddch(ypos[j] + 2, xpos[j], ' ');
+
+ xpos[j] = x;
+ ypos[j] = y;
+
+ switch (getch())
+ {
+ case 'q':
+ case 'Q':
+ curs_set(1);
+ endwin();
+ return EXIT_SUCCESS;
+ case 's':
+ nodelay(stdscr, FALSE);
+ break;
+ case ' ':
+ nodelay(stdscr, TRUE);
+#ifdef KEY_RESIZE
+ break;
+ case KEY_RESIZE:
+# ifdef PDCURSES
+ resize_term(0, 0);
+ erase();
+# endif
+ r = LINES - 4;
+ c = COLS - 4;
+#endif
+ }
+ napms(50);
+ }
+}
diff --git a/payloads/libpayload/curses/PDCurses/demos/testcurs.c b/payloads/libpayload/curses/PDCurses/demos/testcurs.c
new file mode 100644
index 0000000000..54d44f42d9
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses/demos/testcurs.c
@@ -0,0 +1,1144 @@
+/*
+ * This is a test program for PDCurses. Originally by
+ * John Burnell <johnb@kea.am.dsir.govt.nz>
+ *
+ * wrs(5/28/93) -- modified to be consistent (perform identically)
+ * with either PDCurses or under Unix System V, R4
+ *
+ * $Id: testcurs.c,v 1.85 2008/07/14 12:35:23 wmcbrine Exp $
+ */
+
+#ifndef _XOPEN_SOURCE_EXTENDED
+# define _XOPEN_SOURCE_EXTENDED 1
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include <curses.h>
+
+#ifdef WACS_S1
+# define HAVE_WIDE 1
+#else
+# define HAVE_WIDE 0
+#endif
+
+#include <locale.h>
+
+#if HAVE_WIDE
+# include <wchar.h>
+#endif
+
+#if defined(PDCURSES) && !defined(XCURSES)
+# define HAVE_RESIZE 1
+#else
+# define HAVE_RESIZE 0
+#endif
+
+#ifdef A_COLOR
+# define HAVE_COLOR 1
+#else
+# define HAVE_COLOR 0
+#endif
+
+/* Set to non-zero if you want to test the PDCurses clipboard */
+
+#define HAVE_CLIPBOARD 0
+
+void inputTest(WINDOW *);
+void scrollTest(WINDOW *);
+void introTest(WINDOW *);
+int initTest(WINDOW **, int, char **);
+void outputTest(WINDOW *);
+void padTest(WINDOW *);
+void acsTest(WINDOW *);
+
+#if HAVE_COLOR
+void colorTest(WINDOW *);
+#endif
+
+#if HAVE_RESIZE
+void resizeTest(WINDOW *);
+#endif
+
+#if HAVE_CLIPBOARD
+void clipboardTest(WINDOW *);
+#endif
+
+#if HAVE_WIDE
+void wideTest(WINDOW *);
+#endif
+
+void display_menu(int, int);
+
+struct commands
+{
+ const char *text;
+ void (*function)(WINDOW *);
+};
+
+typedef struct commands COMMAND;
+
+#define MAX_OPTIONS (6 + HAVE_COLOR + HAVE_RESIZE + HAVE_CLIPBOARD + HAVE_WIDE)
+
+COMMAND command[MAX_OPTIONS] =
+{
+ {"Intro Test", introTest},
+ {"Pad Test", padTest},
+#if HAVE_RESIZE
+ {"Resize Test", resizeTest},
+#endif
+ {"Scroll Test", scrollTest},
+ {"Input Test", inputTest},
+ {"Output Test", outputTest},
+ {"ACS Test", acsTest},
+#if HAVE_COLOR
+ {"Color Test", colorTest},
+#endif
+#if HAVE_CLIPBOARD
+ {"Clipboard Test", clipboardTest},
+#endif
+#if HAVE_WIDE
+ {"Wide Input", wideTest}
+#endif
+};
+
+int width, height;
+
+int main(int argc, char *argv[])
+{
+ WINDOW *win;
+ int key, old_option = -1, new_option = 0;
+ bool quit = FALSE;
+
+ setlocale(LC_ALL, "");
+
+ if (initTest(&win, argc, argv))
+ return 1;
+
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(1, COLOR_WHITE, COLOR_BLUE);
+ wbkgd(win, COLOR_PAIR(1));
+ }
+ else
+#endif
+ wbkgd(win, A_REVERSE);
+
+ 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:
+ old_option = -1;
+ erase();
+ refresh();
+ (*command[new_option].function)(win);
+ erase();
+ display_menu(old_option, new_option);
+ break;
+
+ case KEY_PPAGE:
+ case KEY_HOME:
+ old_option = new_option;
+ new_option = 0;
+ display_menu(old_option, new_option);
+ break;
+
+ case KEY_NPAGE:
+ case KEY_END:
+ old_option = new_option;
+ new_option = MAX_OPTIONS - 1;
+ display_menu(old_option, new_option);
+ break;
+
+ case KEY_UP:
+ old_option = new_option;
+ new_option = (new_option == 0) ?
+ new_option : new_option - 1;
+ display_menu(old_option, new_option);
+ break;
+
+ case KEY_DOWN:
+ old_option = new_option;
+ new_option = (new_option == MAX_OPTIONS - 1) ?
+ new_option : new_option + 1;
+ display_menu(old_option, new_option);
+ break;
+#ifdef KEY_RESIZE
+ case KEY_RESIZE:
+# ifdef PDCURSES
+ resize_term(0, 0);
+# endif
+ old_option = -1;
+ erase();
+ display_menu(old_option, new_option);
+ break;
+#endif
+ case 'Q':
+ case 'q':
+ quit = TRUE;
+ }
+
+ if (quit == TRUE)
+ break;
+ }
+
+ delwin(win);
+ endwin();
+
+ return 0;
+}
+
+void Continue(WINDOW *win)
+{
+ mvwaddstr(win, 10, 1, " Press any key to continue");
+ wrefresh(win);
+ raw();
+ wgetch(win);
+}
+
+void Continue2(void)
+{
+ move(LINES - 1, 1);
+ clrtoeol();
+ mvaddstr(LINES - 2, 1, " Press any key to continue");
+ refresh();
+ raw();
+ getch();
+}
+
+int initTest(WINDOW **win, int argc, char *argv[])
+{
+#ifdef XCURSES
+ Xinitscr(argc, argv);
+#else
+ initscr();
+#endif
+#ifdef A_COLOR
+ if (has_colors())
+ start_color();
+#endif
+ /* Create a drawing window */
+
+ width = 60;
+ height = 13;
+
+ *win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2);
+
+ if (*win == NULL)
+ {
+ endwin();
+ return 1;
+ }
+
+ return 0;
+}
+
+void introTest(WINDOW *win)
+{
+ werase(win);
+ wmove(win, height / 2 - 5, width / 2);
+ wvline(win, ACS_VLINE, 10);
+ wmove(win, height / 2, width / 2 - 10);
+ whline(win, ACS_HLINE, 20);
+ Continue(win);
+
+ beep();
+ werase(win);
+
+ box(win, ACS_VLINE, ACS_HLINE);
+ wrefresh(win);
+
+ cbreak();
+ mvwaddstr(win, 1, 1,
+ "You should have a rectangle in the middle of the screen");
+ mvwaddstr(win, 2, 1, "You should have heard a beep");
+ Continue(win);
+
+ flash();
+ mvwaddstr(win, 3, 1, "You should have seen a flash");
+ Continue(win);
+}
+
+void scrollTest(WINDOW *win)
+{
+ int i, OldY;
+#ifndef PDCURSES
+ int OldX;
+#endif
+ werase(win);
+ mvwaddstr(win, height - 2, 1, "The window will now scroll slowly");
+ box(win, ACS_VLINE, ACS_HLINE);
+ wrefresh(win);
+ scrollok(win, TRUE);
+ napms(500);
+
+ for (i = 1; i <= height; i++)
+ {
+ napms(150);
+ scroll(win);
+ wrefresh(win);
+ };
+
+#ifdef PDCURSES
+ OldY = getmaxy(win);
+#else
+ getmaxyx(win, OldY, OldX);
+#endif
+ mvwaddstr(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++)
+ {
+ napms(500);
+ scroll(win);
+ wrefresh(win);
+ }
+
+ mvwaddstr(win, 3, 1, "The bottom of the window will scroll");
+ wmove(win, 8, 1);
+ wsetscrreg(win, 5, --OldY);
+ box(win, ACS_VLINE, ACS_HLINE);
+ wrefresh(win);
+
+ for (i = 5; i <= OldY; i++)
+ {
+ napms(300);
+ wscrl(win, -1);
+ wrefresh(win);
+ }
+
+ wsetscrreg(win, 0, OldY);
+}
+
+void inputTest(WINDOW *win)
+{
+ int w, h, bx, by, sw, sh, i, c, num = 0;
+ char buffer[80];
+ WINDOW *subWin;
+ static const char spinner[4] = "/-\\|";
+ int spinner_count = 0;
+
+ wclear(win);
+
+ getmaxyx(win, h, w);
+ getbegyx(win, by, bx);
+
+ 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_WHITE, COLOR_RED);
+ wbkgd(subWin, COLOR_PAIR(2) | A_BOLD);
+ }
+ else
+#endif
+ wbkgd(subWin, A_BOLD);
+
+ box(subWin, ACS_VLINE, ACS_HLINE);
+ wrefresh(win);
+
+ nocbreak();
+
+ wclear (win);
+ mvwaddstr(win, 1, 1,
+ "Press keys (or mouse buttons) to show their names");
+ mvwaddstr(win, 2, 1, "Press spacebar to finish");
+ wrefresh(win);
+
+ keypad(win, TRUE);
+ raw();
+ noecho();
+
+ wtimeout(win, 200);
+
+#ifdef PDCURSES
+ mouse_set(ALL_MOUSE_EVENTS);
+ PDC_save_key_modifiers(TRUE);
+ PDC_return_key_modifiers(TRUE);
+#endif
+ curs_set(0); /* turn cursor off */
+
+ while (1)
+ {
+ while (1)
+ {
+ c = wgetch(win);
+
+ if (c == ERR)
+ {
+ spinner_count++;
+ if (spinner_count == 4)
+ spinner_count = 0;
+ mvwaddch(win, 3, 3, spinner[spinner_count]);
+ wrefresh(win);
+ }
+ else
+ break;
+ }
+#ifdef PDCURSES
+ wmove(win, 4, 18);
+ wclrtoeol(win);
+#endif
+ mvwaddstr(win, 3, 5, "Key Pressed: ");
+ wclrtoeol(win);
+
+ if (c >= KEY_MIN)
+ wprintw(win, "%s", keyname(c));
+ else if (isprint(c))
+ wprintw(win, "%c", c);
+ else
+ wprintw(win, "%s", unctrl(c));
+#ifdef PDCURSES
+ if (c == KEY_MOUSE)
+ {
+ int button = 0;
+ request_mouse_pos();
+
+ if (BUTTON_CHANGED(1))
+ button = 1;
+ else if (BUTTON_CHANGED(2))
+ button = 2;
+ else if (BUTTON_CHANGED(3))
+ button = 3;
+
+ if (button && (BUTTON_STATUS(button) &
+ BUTTON_MODIFIER_MASK))
+ {
+ waddstr(win, " Modifier(s):");
+
+ if (BUTTON_STATUS(button) & BUTTON_SHIFT)
+ waddstr(win, " SHIFT");
+
+ if (BUTTON_STATUS(button) & BUTTON_CONTROL)
+ waddstr(win, " CONTROL");
+
+ if (BUTTON_STATUS(button) & BUTTON_ALT)
+ waddstr(win, " ALT");
+ }
+
+ wmove(win, 4, 18);
+ wclrtoeol(win);
+ wprintw(win, "Button %d: ", button);
+
+ if (MOUSE_MOVED)
+ waddstr(win, "moved: ");
+ else if (MOUSE_WHEEL_UP)
+ waddstr(win, "wheel up: ");
+ else if (MOUSE_WHEEL_DOWN)
+ waddstr(win, "wheel dn: ");
+ else if ((BUTTON_STATUS(button) &
+ BUTTON_ACTION_MASK) == BUTTON_PRESSED)
+ waddstr(win, "pressed: ");
+ else if ((BUTTON_STATUS(button) &
+ BUTTON_ACTION_MASK) == BUTTON_CLICKED)
+ waddstr(win, "clicked: ");
+ else if ((BUTTON_STATUS(button) &
+ BUTTON_ACTION_MASK) == BUTTON_DOUBLE_CLICKED)
+ waddstr(win, "double: ");
+ else
+ waddstr(win, "released: ");
+
+ wprintw(win, "Position: Y: %d X: %d", MOUSE_Y_POS, MOUSE_X_POS);
+ }
+ else if (PDC_get_key_modifiers())
+ {
+ waddstr(win, " Modifier(s):");
+ if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_SHIFT)
+ waddstr(win, " SHIFT");
+
+ if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_CONTROL)
+ waddstr(win, " CONTROL");
+
+ if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_ALT)
+ waddstr(win, " ALT");
+
+ if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_NUMLOCK)
+ waddstr(win, " NUMLOCK");
+ }
+#endif
+ wrefresh(win);
+
+ if (c == ' ')
+ break;
+ }
+
+ wtimeout(win, -1); /* turn off timeout() */
+ curs_set(1); /* turn cursor back on */
+
+#ifdef PDCURSES
+ mouse_set(0L);
+ PDC_save_key_modifiers(FALSE);
+ PDC_return_key_modifiers(FALSE);
+#endif
+ wclear(win);
+ mvwaddstr(win, 2, 1, "Press some keys for 5 seconds");
+ mvwaddstr(win, 1, 1, "Pressing ^C should do nothing");
+ wrefresh(win);
+
+ werase(subWin);
+ box(subWin, ACS_VLINE, ACS_HLINE);
+
+ for (i = 0; i < 5; i++)
+ {
+ mvwprintw(subWin, 1, 1, "Time = %d", i);
+ wrefresh(subWin);
+ napms(1000);
+ flushinp();
+ }
+
+ delwin(subWin);
+ werase(win);
+ flash();
+ wrefresh(win);
+ napms(500);
+ flushinp();
+
+ mvwaddstr(win, 2, 1, "Press a key, followed by ENTER");
+ wmove(win, 9, 10);
+ wrefresh(win);
+ echo();
+
+ keypad(win, TRUE);
+ raw();
+ wgetnstr(win, buffer, 3);
+ flushinp();
+
+ wmove(win, 9, 10);
+ wdelch(win);
+ mvwaddstr(win, 4, 1, "The character should now have been deleted");
+ Continue(win);
+
+ refresh();
+ wclear(win);
+ echo();
+ buffer[0] = '\0';
+ mvwaddstr(win, 3, 2, "The window should have moved");
+ mvwaddstr(win, 4, 2,
+ "This text should have appeared without you pressing a key");
+ mvwaddstr(win, 6, 2, "Enter a number then a string seperated by space");
+ mvwin(win, 2, 1);
+ wrefresh(win);
+ mvwscanw(win, 7, 6, "%d %s", &num, buffer);
+ mvwprintw(win, 8, 6, "String: %s Number: %d", buffer, num);
+ Continue(win);
+
+ refresh();
+ wclear(win);
+ echo();
+ mvwaddstr(win, 3, 2, "Enter a 5 character string: ");
+ wgetnstr(win, buffer, 5);
+ mvwprintw(win, 4, 2, "String: %s", buffer);
+ Continue(win);
+}
+
+void outputTest(WINDOW *win)
+{
+ WINDOW *win1;
+ char Buffer[80];
+ chtype ch;
+ int by, bx;
+
+ nl();
+ wclear(win);
+ mvwaddstr(win, 1, 1, "You should now have a screen in the upper "
+ "left corner, and this text should have wrapped");
+ waddstr(win,"\nThis text should be down\n");
+ waddstr(win, "and broken into two here ^");
+ Continue(win);
+
+ wclear(win);
+ wattron(win, A_BOLD);
+ 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);
+
+ getbegyx(win, by, bx);
+
+ if (LINES < 24 || COLS < 75)
+ {
+ mvwaddstr(win, 5, 1, "Some tests have been skipped as they require a");
+ mvwaddstr(win, 6, 1, "display of at least 24 LINES by 75 COLUMNS");
+ Continue(win);
+ }
+ else
+ {
+ win1 = newwin(10, 50, 14, 25);
+
+ if (win1 == NULL)
+ {
+ endwin();
+ return;
+ }
+
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(3, COLOR_BLUE, COLOR_WHITE);
+ wbkgd(win1, COLOR_PAIR(3));
+ }
+ else
+#endif
+ wbkgd(win1, A_NORMAL);
+
+ wclear(win1);
+ mvwaddstr(win1, 5, 1, "This text should appear; using overlay option");
+ copywin(win, win1, 0, 0, 0, 0, 9, 49, 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);
+
+ mvwin(win1, by, bx);
+ overlay(win, win1);
+ mvwin(win1, 14, 25);
+ wmove(win1, 8, 26);
+ wrefresh(win1);
+ wgetch(win1);
+
+ delwin(win1);
+ }
+
+ clear();
+ 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);
+ winsdelln(win, -1);
+ Continue(win);
+
+ 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);
+
+ mvwinsstr(win, 6, 2, "A1B2C3D4E5");
+ Continue(win);
+
+ wmove(win, 5, 1);
+ winsdelln(win, 1);
+ 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);
+ echo();
+ wscanw(win, "%s", Buffer);
+
+ printw("This is a formatted string in stdscr: %d %s\n", 42, "is it");
+ mvaddstr(10, 1, "Enter a string: ");
+ scanw("%s", Buffer);
+
+ wclear(win);
+ curs_set(2);
+ mvwaddstr(win, 1, 1, "The cursor should be in high-visibility mode");
+ 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 normal");
+ Continue(win);
+
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ wclear(win);
+ mvwaddstr(win, 1, 1, "Colors should change after you press a key");
+ Continue(win);
+
+ init_pair(1, COLOR_RED, COLOR_WHITE);
+ wrefresh(win);
+ }
+#endif
+ werase(win);
+ mvwaddstr(win, 1, 1, "Information About Your Terminal");
+ mvwaddstr(win, 3, 1, termname());
+ mvwaddstr(win, 4, 1, longname());
+
+ if (termattrs() & A_BLINK)
+ mvwaddstr(win, 5, 1, "This terminal claims to support blinking.");
+ else
+ mvwaddstr(win, 5, 1, "This terminal does NOT support blinking.");
+
+ mvwaddnstr(win, 7, 5, "Have a nice day!ok", 16);
+ wrefresh(win);
+
+ mvwinnstr(win, 7, 5, Buffer, 18);
+ mvaddstr(LINES - 2, 10, Buffer);
+ refresh();
+ Continue(win);
+}
+
+#if HAVE_RESIZE
+void resizeTest(WINDOW *dummy)
+{
+ WINDOW *win1;
+ int nwidth = 135, nheight = 52;
+ int owidth = COLS, oheight = LINES;
+
+ savetty();
+
+ resize_term(nheight, nwidth);
+
+ clear();
+ refresh();
+
+ win1 = newwin(10, 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));
+ }
+
+ wclear(win1);
+#endif
+ mvwaddstr(win1, 0, 0, "The screen may now be resized");
+ mvwprintw(win1, 1, 4, "Given size: %d by %d", nwidth, nheight);
+ mvwprintw(win1, 2, 4, "Actual size: %d by %d", COLS, LINES);
+ Continue(win1);
+
+ wclear(win1);
+ resetty();
+
+ mvwaddstr(win1, 0, 0, "The screen should now be reset");
+ mvwprintw(win1, 1, 6, "Old size: %d by %d", owidth, oheight);
+ mvwprintw(win1, 2, 6, "Size now: %d by %d", COLS, LINES);
+ Continue(win1);
+
+ delwin(win1);
+
+ clear();
+ refresh();
+}
+#endif /* HAVE_RESIZE */
+
+void padTest(WINDOW *dummy)
+{
+ WINDOW *pad, *spad;
+
+ pad = newpad(50, 100);
+ wattron(pad, A_REVERSE);
+ mvwaddstr(pad, 5, 2, "This is a new pad");
+ wattrset(pad, 0);
+ mvwaddstr(pad, 8, 0,
+ "The end of this line should be truncated here:except now");
+ mvwaddstr(pad, 11, 1, "This line should not appear.It will now");
+ 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);
+
+ spad = subpad(pad, 12, 25, 7, 52);
+ mvwaddstr(spad, 2, 2, "This is a new subpad");
+ box(spad, 0, 0);
+ prefresh(pad, 0, 0, 0, 0, 15, 75);
+ 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);
+}
+
+#if HAVE_CLIPBOARD
+void clipboardTest(WINDOW *win)
+{
+ static const char *text =
+ "This string placed in clipboard by PDCurses test program, testcurs.";
+ char *ptr = NULL;
+ long i, length = 0;
+
+ mvaddstr(1, 1,
+ "This test will display the contents of the system clipboard");
+
+ Continue2();
+
+ scrollok(stdscr, TRUE);
+ i = PDC_getclipboard(&ptr, &length);
+
+ switch(i)
+ {
+ case PDC_CLIP_ACCESS_ERROR:
+ mvaddstr(3, 1, "There was an error accessing the clipboard");
+ refresh();
+ break;
+
+ case PDC_CLIP_MEMORY_ERROR:
+ mvaddstr(3, 1,
+ "Unable to allocate memory for clipboard contents");
+ break;
+
+ case PDC_CLIP_EMPTY:
+ mvaddstr(3, 1, "There was no text in the clipboard");
+ break;
+
+ default:
+ wsetscrreg(stdscr, 0, LINES - 1);
+ clear();
+ mvaddstr(1, 1, "Clipboard contents...");
+ mvprintw(2, 1, "%s\n", ptr);
+ }
+
+ Continue2();
+
+ clear();
+ mvaddstr(1, 1,
+ "This test will place the following string in the system clipboard:");
+ mvaddstr(2, 1, text);
+
+ i = PDC_setclipboard(text, strlen(text));
+
+ switch(i)
+ {
+ case PDC_CLIP_ACCESS_ERROR:
+ mvaddstr(3, 1, "There was an error accessing the clipboard");
+ break;
+
+ case PDC_CLIP_MEMORY_ERROR:
+ mvaddstr(3, 1, "Unable to allocate memory for clipboard contents");
+ break;
+
+ default:
+ mvaddstr(3, 1, "The string was placed in the clipboard successfully");
+ }
+
+ Continue2();
+}
+#endif /* HAVE_CLIPBOARD */
+
+void acsTest(WINDOW *win)
+{
+#ifdef ACS_S3
+# define ACSNUM 32
+#else
+# define ACSNUM 25
+#endif
+ static const char *acs_names[] =
+ {
+ "ACS_ULCORNER", "ACS_URCORNER", "ACS_LLCORNER", "ACS_LRCORNER",
+ "ACS_LTEE", "ACS_RTEE", "ACS_TTEE", "ACS_BTEE", "ACS_HLINE",
+ "ACS_VLINE", "ACS_PLUS",
+
+ "ACS_S1", "ACS_S9", "ACS_DIAMOND", "ACS_CKBOARD", "ACS_DEGREE",
+ "ACS_PLMINUS", "ACS_BULLET",
+
+ "ACS_LARROW", "ACS_RARROW", "ACS_UARROW", "ACS_DARROW",
+ "ACS_BOARD", "ACS_LANTERN", "ACS_BLOCK"
+#ifdef ACS_S3
+ , "ACS_S3", "ACS_S7", "ACS_LEQUAL", "ACS_GEQUAL",
+ "ACS_PI", "ACS_NEQUAL", "ACS_STERLING"
+#endif
+ };
+
+ chtype acs_values[ACSNUM];
+
+#if HAVE_WIDE
+ cchar_t *wacs_values[] =
+ {
+ WACS_ULCORNER, WACS_URCORNER, WACS_LLCORNER, WACS_LRCORNER,
+ WACS_LTEE, WACS_RTEE, WACS_TTEE, WACS_BTEE, WACS_HLINE,
+ WACS_VLINE, WACS_PLUS,
+
+ WACS_S1, WACS_S9, WACS_DIAMOND, WACS_CKBOARD, WACS_DEGREE,
+ WACS_PLMINUS, WACS_BULLET,
+
+ WACS_LARROW, WACS_RARROW, WACS_UARROW, WACS_DARROW, WACS_BOARD,
+ WACS_LANTERN, WACS_BLOCK
+# ifdef WACS_S3
+ , WACS_S3, WACS_S7, WACS_LEQUAL, WACS_GEQUAL, WACS_PI,
+ WACS_NEQUAL, WACS_STERLING
+# endif
+ };
+
+ static const wchar_t russian[] = {0x0420, 0x0443, 0x0441, 0x0441,
+ 0x043a, 0x0438, 0x0439, L' ', 0x044f, 0x0437, 0x044b, 0x043a, 0};
+
+ static const wchar_t greek[] = {0x0395, 0x03bb, 0x03bb, 0x03b7,
+ 0x03bd, 0x03b9, 0x03ba, 0x03ac, 0};
+
+ static const wchar_t georgian[] = {0x10e5, 0x10d0, 0x10e0, 0x10d7,
+ 0x10e3, 0x10da, 0x10d8, L' ', 0x10d4, 0x10dc, 0x10d0, 0};
+#endif
+
+ int i, tmarg = (LINES - 22) / 2;
+
+ attrset(A_BOLD);
+ mvaddstr(tmarg, (COLS - 23) / 2, "Alternate Character Set");
+ attrset(A_NORMAL);
+
+ tmarg += 3;
+
+#define A(b,c) acs_values[b] = ACS_##c
+
+ A(0,ULCORNER); A(1,URCORNER); A(2,LLCORNER); A(3,LRCORNER);
+ A(4,LTEE); A(5,RTEE); A(6,TTEE); A(7,BTEE);
+ A(8,HLINE); A(9,VLINE); A(10,PLUS); A(11,S1);
+ A(12,S9); A(13,DIAMOND); A(14,CKBOARD); A(15,DEGREE);
+
+ A(16,PLMINUS); A(17,BULLET); A(18,LARROW); A(19,RARROW);
+ A(20,UARROW); A(21,DARROW); A(22,BOARD); A(23,LANTERN);
+ A(24,BLOCK);
+#ifdef ACS_S3
+ A(25,S3); A(26,S7); A(27,LEQUAL); A(28,GEQUAL);
+ A(29,PI); A(30,NEQUAL); A(31,STERLING);
+#endif
+
+#undef A
+
+ for (i = 0; i < ACSNUM; i++)
+ {
+ move((i % 8) * 2 + tmarg, (i / 8) * (COLS / 4) + (COLS / 8 - 7));
+ addch(acs_values[i]);
+ printw(" %s", acs_names[i]);
+ }
+
+ mvaddstr(tmarg + 18, 3, "Press any key to continue");
+ getch();
+
+#if HAVE_WIDE
+ clear();
+
+ attrset(A_BOLD);
+ mvaddstr(tmarg - 3, (COLS - 28) / 2, "Wide Alternate Character Set");
+ attrset(A_NORMAL);
+
+ for (i = 0; i < ACSNUM; i++)
+ {
+ move((i % 8) * 2 + tmarg, (i / 8) * (COLS / 4) + (COLS / 8 - 7));
+ add_wch(wacs_values[i]);
+ printw(" W%s", acs_names[i]);
+ }
+
+ /* Spanish, Russian, Greek, Georgian */
+
+ mvaddwstr(tmarg + 16, COLS / 8 - 5, L"Espa\xf1ol");
+ mvaddwstr(tmarg + 16, 3 * (COLS / 8) - 5, russian);
+ mvaddwstr(tmarg + 16, 5 * (COLS / 8) - 5, greek);
+ mvaddwstr(tmarg + 16, 7 * (COLS / 8) - 5, georgian);
+
+ mvaddstr(tmarg + 18, 3, "Press any key to continue");
+ getch();
+#endif
+}
+
+#if HAVE_COLOR
+void colorTest(WINDOW *win)
+{
+ static const short colors[] =
+ {
+ COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_BLUE,
+ COLOR_CYAN, COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE
+ };
+
+ static const char *colornames[] =
+ {
+ "COLOR_BLACK", "COLOR_RED", "COLOR_GREEN", "COLOR_BLUE",
+ "COLOR_CYAN", "COLOR_MAGENTA", "COLOR_YELLOW", "COLOR_WHITE"
+ };
+
+ chtype fill = ACS_BLOCK;
+
+ int i, j, tmarg, col1, col2, col3;
+
+ if (!has_colors())
+ return;
+
+ tmarg = (LINES - 19) / 2;
+ col1 = (COLS - 60) / 2;
+ col2 = col1 + 20;
+ col3 = col2 + 20;
+
+ attrset(A_BOLD);
+ mvaddstr(tmarg, (COLS - 22) / 2, "Color Attribute Macros");
+ attrset(A_NORMAL);
+
+ mvaddstr(tmarg + 3, col2 + 4, "A_NORMAL");
+ mvaddstr(tmarg + 3, col3 + 5, "A_BOLD");
+
+ for (i = 0; i < 8; i++)
+ {
+ init_pair(i + 4, colors[i], COLOR_BLACK);
+
+ mvaddstr(tmarg + i + 5, col1, colornames[i]);
+
+ for (j = 0; j < 16; j++)
+ {
+ mvaddch(tmarg + i + 5, col2 + j, fill | COLOR_PAIR(i + 4));
+ mvaddch(tmarg + i + 5, col3 + j, fill | COLOR_PAIR(i + 4) | A_BOLD);
+ }
+ }
+
+ mvprintw(tmarg + 15, col1, "COLORS = %d", COLORS);
+ mvprintw(tmarg + 16, col1, "COLOR_PAIRS = %d", COLOR_PAIRS);
+
+ mvaddstr(tmarg + 19, 3, "Press any key to continue");
+ getch();
+
+ if (can_change_color())
+ {
+ struct
+ {
+ short red, green, blue;
+ } orgcolors[16];
+
+ int MAXCOL = (COLORS >= 16) ? 16 : 8;
+
+ if (MAXCOL < 8)
+ return;
+
+ for (i = 0; i < MAXCOL; i++)
+ color_content(i, &(orgcolors[i].red),
+ &(orgcolors[i].green),
+ &(orgcolors[i].blue));
+
+ attrset(A_BOLD);
+ mvaddstr(tmarg, (COLS - 22) / 2, " init_color() Example ");
+ attrset(A_NORMAL);
+
+ refresh();
+
+ for (i = 0; i < 8; i++)
+ {
+ init_color(colors[i], i * 125, 0, i * 125);
+
+ if (MAXCOL == 16)
+ init_color(colors[i] + 8, 0, i * 125, 0);
+ }
+
+ mvaddstr(tmarg + 19, 3, "Press any key to continue");
+ getch();
+
+ for (i = 0; i < MAXCOL; i++)
+ init_color(i, orgcolors[i].red,
+ orgcolors[i].green,
+ orgcolors[i].blue);
+ }
+}
+#endif
+
+#if HAVE_WIDE
+void wideTest(WINDOW *win)
+{
+ wchar_t tmp[513];
+ size_t i;
+
+ attrset(A_BOLD);
+ mvaddstr(1, (COLS - 25) / 2, "Wide Character Input Test");
+ attrset(A_NORMAL);
+
+ mvaddstr(4, 1, "Enter a string: ");
+
+ echo();
+
+ get_wstr((wint_t *)tmp);
+ addstr("\n\n String:\n\n ");
+ addwstr(tmp);
+ addstr("\n\n\n Hex:\n\n ");
+
+ for (i = 0; i < wcslen(tmp); i++)
+ {
+ printw("%04x ", tmp[i]);
+ addnwstr(tmp + i, 1);
+ addstr(" ");
+ }
+
+ noecho();
+
+ Continue2();
+}
+#endif
+
+void display_menu(int old_option, int new_option)
+{
+ int lmarg = (COLS - 14) / 2,
+ tmarg = (LINES - (MAX_OPTIONS + 2)) / 2;
+
+ if (old_option == -1)
+ {
+ int i;
+
+ attrset(A_BOLD);
+ mvaddstr(tmarg - 3, lmarg - 5, "PDCurses Test Program");
+ attrset(A_NORMAL);
+
+ for (i = 0; i < MAX_OPTIONS; i++)
+ mvaddstr(tmarg + i, lmarg, command[i].text);
+ }
+ else
+ mvaddstr(tmarg + old_option, lmarg, command[old_option].text);
+
+ attrset(A_REVERSE);
+ mvaddstr(tmarg + new_option, lmarg, command[new_option].text);
+ attrset(A_NORMAL);
+
+ mvaddstr(tmarg + MAX_OPTIONS + 2, lmarg - 23,
+ "Use Up and Down Arrows to select - Enter to run - Q to quit");
+ refresh();
+}
diff --git a/payloads/libpayload/curses/PDCurses/demos/tui.c b/payloads/libpayload/curses/PDCurses/demos/tui.c
new file mode 100644
index 0000000000..62e0d53767
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses/demos/tui.c
@@ -0,0 +1,821 @@
+/********************************* tui.c ************************************/
+/*
+ * 'textual user interface'
+ *
+ * $Id: tui.c,v 1.34 2008/07/14 12:35:23 wmcbrine Exp $
+ *
+ * Author : P.J. Kunst <kunst@prl.philips.nl>
+ * Date : 25-02-93
+ */
+
+#include <ctype.h>
+#include <curses.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include "tui.h"
+
+void statusmsg(char *);
+int waitforkey(void);
+void rmerror(void);
+
+#if defined(__unix) && !defined(__DJGPP__)
+#include <unistd.h>
+#endif
+
+#ifdef A_COLOR
+# define TITLECOLOR 1 /* color pair indices */
+# define MAINMENUCOLOR (2 | A_BOLD)
+# define MAINMENUREVCOLOR (3 | A_BOLD | A_REVERSE)
+# define SUBMENUCOLOR (4 | A_BOLD)
+# define SUBMENUREVCOLOR (5 | A_BOLD | A_REVERSE)
+# define BODYCOLOR 6
+# define STATUSCOLOR (7 | A_BOLD)
+# define INPUTBOXCOLOR 8
+# define EDITBOXCOLOR (9 | A_BOLD | A_REVERSE)
+#else
+# define TITLECOLOR 0 /* color pair indices */
+# define MAINMENUCOLOR (A_BOLD)
+# define MAINMENUREVCOLOR (A_BOLD | A_REVERSE)
+# define SUBMENUCOLOR (A_BOLD)
+# define SUBMENUREVCOLOR (A_BOLD | A_REVERSE)
+# define BODYCOLOR 0
+# define STATUSCOLOR (A_BOLD)
+# define INPUTBOXCOLOR 0
+# define EDITBOXCOLOR (A_BOLD | A_REVERSE)
+#endif
+
+
+#define th 1 /* title window height */
+#define mh 1 /* main menu height */
+#define sh 2 /* status window height */
+#define bh (LINES - th - mh - sh) /* body window height */
+#define bw COLS /* body window width */
+
+
+/******************************* STATIC ************************************/
+
+static WINDOW *wtitl, *wmain, *wbody, *wstat; /* title, menu, body, status win*/
+static int nexty, nextx;
+static int key = ERR, ch = ERR;
+static bool quit = FALSE;
+static bool incurses = FALSE;
+
+#ifndef PDCURSES
+static char wordchar(void)
+{
+ return 0x17; /* ^W */
+}
+#endif
+
+static char *padstr(char *s, int length)
+{
+ static char buf[MAXSTRLEN];
+ char fmt[10];
+
+ sprintf(fmt, (int)strlen(s) > length ? "%%.%ds" : "%%-%ds", length);
+ sprintf(buf, fmt, s);
+
+ return buf;
+}
+
+static char *prepad(char *s, int length)
+{
+ int i;
+ char *p = s;
+
+ if (length > 0)
+ {
+ memmove((void *)(s + length), (const void *)s, strlen(s) + 1);
+
+ for (i = 0; i < length; i++)
+ *p++ = ' ';
+ }
+
+ return s;
+}
+
+static void rmline(WINDOW *win, int nr) /* keeps box lines intact */
+{
+ mvwaddstr(win, nr, 1, padstr(" ", bw - 2));
+ wrefresh(win);
+}
+
+static void initcolor(void)
+{
+#ifdef A_COLOR
+ if (has_colors())
+ start_color();
+
+ /* foreground, background */
+
+ init_pair(TITLECOLOR & ~A_ATTR, COLOR_BLACK, COLOR_CYAN);
+ init_pair(MAINMENUCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_CYAN);
+ init_pair(MAINMENUREVCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_BLACK);
+ init_pair(SUBMENUCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_CYAN);
+ init_pair(SUBMENUREVCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_BLACK);
+ init_pair(BODYCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_BLUE);
+ init_pair(STATUSCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_CYAN);
+ init_pair(INPUTBOXCOLOR & ~A_ATTR, COLOR_BLACK, COLOR_CYAN);
+ init_pair(EDITBOXCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_BLACK);
+#endif
+}
+
+static void setcolor(WINDOW *win, chtype color)
+{
+ chtype attr = color & A_ATTR; /* extract Bold, Reverse, Blink bits */
+
+#ifdef A_COLOR
+ attr &= ~A_REVERSE; /* ignore reverse, use colors instead! */
+ wattrset(win, COLOR_PAIR(color & A_CHARTEXT) | attr);
+#else
+ attr &= ~A_BOLD; /* ignore bold, gives messy display on HP-UX */
+ wattrset(win, attr);
+#endif
+}
+
+static void colorbox(WINDOW *win, chtype color, int hasbox)
+{
+ int maxy;
+#ifndef PDCURSES
+ int maxx;
+#endif
+ chtype attr = color & A_ATTR; /* extract Bold, Reverse, Blink bits */
+
+ setcolor(win, color);
+
+#ifdef A_COLOR
+ if (has_colors())
+ wbkgd(win, COLOR_PAIR(color & A_CHARTEXT) | (attr & ~A_REVERSE));
+ else
+#endif
+ wbkgd(win, attr);
+
+ werase(win);
+
+#ifdef PDCURSES
+ maxy = getmaxy(win);
+#else
+ getmaxyx(win, maxy, maxx);
+#endif
+ if (hasbox && (maxy > 2))
+ box(win, 0, 0);
+
+ touchwin(win);
+ wrefresh(win);
+}
+
+static void idle(void)
+{
+ char buf[MAXSTRLEN];
+ time_t t;
+ struct tm *tp;
+
+ if (time (&t) == -1)
+ return; /* time not available */
+
+ tp = localtime(&t);
+ sprintf(buf, " %.2d-%.2d-%.4d %.2d:%.2d:%.2d",
+ tp->tm_mday, tp->tm_mon + 1, tp->tm_year + 1900,
+ tp->tm_hour, tp->tm_min, tp->tm_sec);
+
+ mvwaddstr(wtitl, 0, bw - strlen(buf) - 2, buf);
+ wrefresh(wtitl);
+}
+
+static void menudim(menu *mp, int *lines, int *columns)
+{
+ int n, l, mmax = 0;
+
+ for (n=0; mp->func; n++, mp++)
+ if ((l = strlen(mp->name)) > mmax) mmax = l;
+
+ *lines = n;
+ *columns = mmax + 2;
+}
+
+static void setmenupos(int y, int x)
+{
+ nexty = y;
+ nextx = x;
+}
+
+static void getmenupos(int *y, int *x)
+{
+ *y = nexty;
+ *x = nextx;
+}
+
+static int hotkey(const char *s)
+{
+ int c0 = *s; /* if no upper case found, return first char */
+
+ for (; *s; s++)
+ if (isupper((unsigned char)*s))
+ break;
+
+ return *s ? *s : c0;
+}
+
+static void repaintmenu(WINDOW *wmenu, menu *mp)
+{
+ int i;
+ menu *p = mp;
+
+ for (i = 0; p->func; i++, p++)
+ mvwaddstr(wmenu, i + 1, 2, p->name);
+
+ touchwin(wmenu);
+ wrefresh(wmenu);
+}
+
+static void repaintmainmenu(int width, menu *mp)
+{
+ int i;
+ menu *p = mp;
+
+ for (i = 0; p->func; i++, p++)
+ mvwaddstr(wmain, 0, i * width, prepad(padstr(p->name, width - 1), 1));
+
+ touchwin(wmain);
+ wrefresh(wmain);
+}
+
+static void mainhelp(void)
+{
+#ifdef ALT_X
+ statusmsg("Use arrow keys and Enter to select (Alt-X to quit)");
+#else
+ statusmsg("Use arrow keys and Enter to select");
+#endif
+}
+
+static void mainmenu(menu *mp)
+{
+ int nitems, barlen, old = -1, cur = 0, c, cur0;
+
+ menudim(mp, &nitems, &barlen);
+ repaintmainmenu(barlen, mp);
+
+ while (!quit)
+ {
+ if (cur != old)
+ {
+ if (old != -1)
+ {
+ mvwaddstr(wmain, 0, old * barlen,
+ prepad(padstr(mp[old].name, barlen - 1), 1));
+
+ statusmsg(mp[cur].desc);
+ }
+ else
+ mainhelp();
+
+ setcolor(wmain, MAINMENUREVCOLOR);
+
+ mvwaddstr(wmain, 0, cur * barlen,
+ prepad(padstr(mp[cur].name, barlen - 1), 1));
+
+ setcolor(wmain, MAINMENUCOLOR);
+ old = cur;
+ wrefresh(wmain);
+ }
+
+ switch (c = (key != ERR ? key : waitforkey()))
+ {
+ case KEY_DOWN:
+ case '\n': /* menu item selected */
+ touchwin(wbody);
+ wrefresh(wbody);
+ rmerror();
+ setmenupos(th + mh, cur * barlen);
+ curs_set(1);
+ (mp[cur].func)(); /* perform function */
+ curs_set(0);
+
+ switch (key)
+ {
+ case KEY_LEFT:
+ cur = (cur + nitems - 1) % nitems;
+ key = '\n';
+ break;
+
+ case KEY_RIGHT:
+ cur = (cur + 1) % nitems;
+ key = '\n';
+ break;
+
+ default:
+ key = ERR;
+ }
+
+ repaintmainmenu(barlen, mp);
+ old = -1;
+ break;
+
+ case KEY_LEFT:
+ cur = (cur + nitems - 1) % nitems;
+ break;
+
+ case KEY_RIGHT:
+ cur = (cur + 1) % nitems;
+ break;
+
+ case KEY_ESC:
+ mainhelp();
+ break;
+
+ default:
+ cur0 = cur;
+
+ do
+ {
+ cur = (cur + 1) % nitems;
+
+ } while ((cur != cur0) && (hotkey(mp[cur].name) != toupper(c)));
+
+ if (hotkey(mp[cur].name) == toupper(c))
+ key = '\n';
+ }
+
+ }
+
+ rmerror();
+ touchwin(wbody);
+ wrefresh(wbody);
+}
+
+static void cleanup(void) /* cleanup curses settings */
+{
+ if (incurses)
+ {
+ delwin(wtitl);
+ delwin(wmain);
+ delwin(wbody);
+ delwin(wstat);
+ curs_set(1);
+ endwin();
+ incurses = FALSE;
+ }
+}
+
+
+/******************************* EXTERNAL **********************************/
+
+void clsbody(void)
+{
+ werase(wbody);
+ wmove(wbody, 0, 0);
+}
+
+int bodylen(void)
+{
+#ifdef PDCURSES
+ return getmaxy(wbody);
+#else
+ int maxy, maxx;
+
+ getmaxyx(wbody, maxy, maxx);
+ return maxy;
+#endif
+}
+
+WINDOW *bodywin(void)
+{
+ return wbody;
+}
+
+void rmerror(void)
+{
+ rmline(wstat, 0);
+}
+
+void rmstatus(void)
+{
+ rmline(wstat, 1);
+}
+
+void titlemsg(char *msg)
+{
+ mvwaddstr(wtitl, 0, 2, padstr(msg, bw - 3));
+ wrefresh(wtitl);
+}
+
+void bodymsg(char *msg)
+{
+ waddstr(wbody, msg);
+ wrefresh(wbody);
+}
+
+void errormsg(char *msg)
+{
+ beep();
+ mvwaddstr(wstat, 0, 2, padstr(msg, bw - 3));
+ wrefresh(wstat);
+}
+
+void statusmsg(char *msg)
+{
+ mvwaddstr(wstat, 1, 2, padstr(msg, bw - 3));
+ wrefresh(wstat);
+}
+
+bool keypressed(void)
+{
+ ch = wgetch(wbody);
+
+ return ch != ERR;
+}
+
+int getkey(void)
+{
+ int c = ch;
+
+ ch = ERR;
+#ifdef ALT_X
+ quit = (c == ALT_X); /* PC only ! */
+#endif
+ return c;
+}
+
+int waitforkey(void)
+{
+ do idle(); while (!keypressed());
+ return getkey();
+}
+
+void DoExit(void) /* terminate program */
+{
+ quit = TRUE;
+}
+
+void domenu(menu *mp)
+{
+ int y, x, nitems, barlen, mheight, mw, old = -1, cur = 0, cur0;
+ bool stop = FALSE;
+ WINDOW *wmenu;
+
+ curs_set(0);
+ getmenupos(&y, &x);
+ menudim(mp, &nitems, &barlen);
+ mheight = nitems + 2;
+ mw = barlen + 2;
+ wmenu = newwin(mheight, mw, y, x);
+ colorbox(wmenu, SUBMENUCOLOR, 1);
+ repaintmenu(wmenu, mp);
+
+ key = ERR;
+
+ while (!stop && !quit)
+ {
+ if (cur != old)
+ {
+ if (old != -1)
+ mvwaddstr(wmenu, old + 1, 1,
+ prepad(padstr(mp[old].name, barlen - 1), 1));
+
+ setcolor(wmenu, SUBMENUREVCOLOR);
+ mvwaddstr(wmenu, cur + 1, 1,
+ prepad(padstr(mp[cur].name, barlen - 1), 1));
+
+ setcolor(wmenu, SUBMENUCOLOR);
+ statusmsg(mp[cur].desc);
+
+ old = cur;
+ wrefresh(wmenu);
+ }
+
+ switch (key = ((key != ERR) ? key : waitforkey()))
+ {
+ case '\n': /* menu item selected */
+ touchwin(wbody);
+ wrefresh(wbody);
+ setmenupos(y + 1, x + 1);
+ rmerror();
+
+ key = ERR;
+ curs_set(1);
+ (mp[cur].func)(); /* perform function */
+ curs_set(0);
+
+ repaintmenu(wmenu, mp);
+
+ old = -1;
+ break;
+
+ case KEY_UP:
+ cur = (cur + nitems - 1) % nitems;
+ key = ERR;
+ break;
+
+ case KEY_DOWN:
+ cur = (cur + 1) % nitems;
+ key = ERR;
+ break;
+
+ case KEY_ESC:
+ case KEY_LEFT:
+ case KEY_RIGHT:
+ if (key == KEY_ESC)
+ key = ERR; /* return to prev submenu */
+
+ stop = TRUE;
+ break;
+
+ default:
+ cur0 = cur;
+
+ do
+ {
+ cur = (cur + 1) % nitems;
+
+ } while ((cur != cur0) &&
+ (hotkey(mp[cur].name) != toupper((int)key)));
+
+ key = (hotkey(mp[cur].name) == toupper((int)key)) ? '\n' : ERR;
+ }
+
+ }
+
+ rmerror();
+ delwin(wmenu);
+ touchwin(wbody);
+ wrefresh(wbody);
+}
+
+void startmenu(menu *mp, char *mtitle)
+{
+ initscr();
+ incurses = TRUE;
+ initcolor();
+
+ wtitl = subwin(stdscr, th, bw, 0, 0);
+ wmain = subwin(stdscr, mh, bw, th, 0);
+ wbody = subwin(stdscr, bh, bw, th + mh, 0);
+ wstat = subwin(stdscr, sh, bw, th + mh + bh, 0);
+
+ colorbox(wtitl, TITLECOLOR, 0);
+ colorbox(wmain, MAINMENUCOLOR, 0);
+ colorbox(wbody, BODYCOLOR, 0);
+ colorbox(wstat, STATUSCOLOR, 0);
+
+ if (mtitle)
+ titlemsg(mtitle);
+
+ cbreak(); /* direct input (no newline required)... */
+ noecho(); /* ... without echoing */
+ curs_set(0); /* hide cursor (if possible) */
+ nodelay(wbody, TRUE); /* don't wait for input... */
+ halfdelay(10); /* ...well, no more than a second, anyway */
+ keypad(wbody, TRUE); /* enable cursor keys */
+ scrollok(wbody, TRUE); /* enable scrolling in main window */
+
+ leaveok(stdscr, TRUE);
+ leaveok(wtitl, TRUE);
+ leaveok(wmain, TRUE);
+ leaveok(wstat, TRUE);
+
+ mainmenu(mp);
+
+ cleanup();
+}
+
+static void repainteditbox(WINDOW *win, int x, char *buf)
+{
+#ifndef PDCURSES
+ int maxy;
+#endif
+ int maxx;
+
+#ifdef PDCURSES
+ maxx = getmaxx(win);
+#else
+ getmaxyx(win, maxy, maxx);
+#endif
+ werase(win);
+ mvwprintw(win, 0, 0, "%s", padstr(buf, maxx));
+ wmove(win, 0, x);
+ wrefresh(win);
+}
+
+/*
+
+ weditstr() - edit string
+
+ Description:
+ The initial value of 'str' with a maximum length of 'field' - 1,
+ which is supplied by the calling routine, is editted. The user's
+ erase (^H), kill (^U) and delete word (^W) chars are interpreted.
+ The PC insert or Tab keys toggle between insert and edit mode.
+ Escape aborts the edit session, leaving 'str' unchanged.
+ Enter, Up or Down Arrow are used to accept the changes to 'str'.
+ NOTE: editstr(), mveditstr(), and mvweditstr() are macros.
+
+ Return Value:
+ Returns the input terminating character on success (Escape,
+ Enter, Up or Down Arrow) and ERR on error.
+
+ Errors:
+ It is an error to call this function with a NULL window pointer.
+ The length of the initial 'str' must not exceed 'field' - 1.
+
+*/
+
+int weditstr(WINDOW *win, char *buf, int field)
+{
+ char org[MAXSTRLEN], *tp, *bp = buf;
+ bool defdisp = TRUE, stop = FALSE, insert = FALSE;
+ int cury, curx, begy, begx, oldattr;
+ WINDOW *wedit;
+ int c = 0;
+
+ if ((field >= MAXSTRLEN) || (buf == NULL) ||
+ ((int)strlen(buf) > field - 1))
+ return ERR;
+
+ strcpy(org, buf); /* save original */
+
+ wrefresh(win);
+ getyx(win, cury, curx);
+ getbegyx(win, begy, begx);
+
+ wedit = subwin(win, 1, field, begy + cury, begx + curx);
+ oldattr = wedit->_attrs;
+ colorbox(wedit, EDITBOXCOLOR, 0);
+
+ keypad(wedit, TRUE);
+ curs_set(1);
+
+ while (!stop)
+ {
+ idle();
+ repainteditbox(wedit, bp - buf, buf);
+
+ switch (c = wgetch(wedit))
+ {
+ case ERR:
+ break;
+
+ case KEY_ESC:
+ strcpy(buf, org); /* restore original */
+ stop = TRUE;
+ break;
+
+ case '\n':
+ case KEY_UP:
+ case KEY_DOWN:
+ stop = TRUE;
+ break;
+
+ case KEY_LEFT:
+ if (bp > buf)
+ bp--;
+ break;
+
+ case KEY_RIGHT:
+ defdisp = FALSE;
+ if (bp - buf < (int)strlen(buf))
+ bp++;
+ break;
+
+ case '\t': /* TAB -- because insert
+ is broken on HPUX */
+ case KEY_IC: /* enter insert mode */
+ case KEY_EIC: /* exit insert mode */
+ defdisp = FALSE;
+ insert = !insert;
+
+ curs_set(insert ? 2 : 1);
+ break;
+
+ default:
+ if (c == erasechar()) /* backspace, ^H */
+ {
+ if (bp > buf)
+ {
+ memmove((void *)(bp - 1), (const void *)bp, strlen(bp) + 1);
+ bp--;
+ }
+ }
+ else if (c == killchar()) /* ^U */
+ {
+ bp = buf;
+ *bp = '\0';
+ }
+ else if (c == wordchar()) /* ^W */
+ {
+ tp = bp;
+
+ while ((bp > buf) && (*(bp - 1) == ' '))
+ bp--;
+ while ((bp > buf) && (*(bp - 1) != ' '))
+ bp--;
+
+ memmove((void *)bp, (const void *)tp, strlen(tp) + 1);
+ }
+ else if (isprint(c))
+ {
+ if (defdisp)
+ {
+ bp = buf;
+ *bp = '\0';
+ defdisp = FALSE;
+ }
+
+ if (insert)
+ {
+ if ((int)strlen(buf) < field - 1)
+ {
+ memmove((void *)(bp + 1), (const void *)bp,
+ strlen(bp) + 1);
+
+ *bp++ = c;
+ }
+ }
+ else if (bp - buf < field - 1)
+ {
+ /* append new string terminator */
+
+ if (!*bp)
+ bp[1] = '\0';
+
+ *bp++ = c;
+ }
+ }
+ }
+ }
+
+ curs_set(0);
+
+ wattrset(wedit, oldattr);
+ repainteditbox(wedit, bp - buf, buf);
+ delwin(wedit);
+
+ return c;
+}
+
+WINDOW *winputbox(WINDOW *win, int nlines, int ncols)
+{
+ WINDOW *winp;
+ int cury, curx, begy, begx;
+
+ getyx(win, cury, curx);
+ getbegyx(win, begy, begx);
+
+ winp = newwin(nlines, ncols, begy + cury, begx + curx);
+ colorbox(winp, INPUTBOXCOLOR, 1);
+
+ return winp;
+}
+
+int getstrings(char *desc[], char *buf[], int field)
+{
+ WINDOW *winput;
+ int oldy, oldx, maxy, maxx, nlines, ncols, i, n, l, mmax = 0;
+ int c = 0;
+ bool stop = FALSE;
+
+ for (n = 0; desc[n]; n++)
+ if ((l = strlen(desc[n])) > mmax)
+ mmax = l;
+
+ nlines = n + 2; ncols = mmax + field + 4;
+ getyx(wbody, oldy, oldx);
+ getmaxyx(wbody, maxy, maxx);
+
+ winput = mvwinputbox(wbody, (maxy - nlines) / 2, (maxx - ncols) / 2,
+ nlines, ncols);
+
+ for (i = 0; i < n; i++)
+ mvwprintw(winput, i + 1, 2, "%s", desc[i]);
+
+ i = 0;
+
+ while (!stop)
+ {
+ switch (c = mvweditstr(winput, i+1, mmax+3, buf[i], field))
+ {
+ case KEY_ESC:
+ stop = TRUE;
+ break;
+
+ case KEY_UP:
+ i = (i + n - 1) % n;
+ break;
+
+ case '\n':
+ case '\t':
+ case KEY_DOWN:
+ if (++i == n)
+ stop = TRUE; /* all passed? */
+ }
+ }
+
+ delwin(winput);
+ touchwin(wbody);
+ wmove(wbody, oldy, oldx);
+ wrefresh(wbody);
+
+ return c;
+}
diff --git a/payloads/libpayload/curses/PDCurses/demos/tui.h b/payloads/libpayload/curses/PDCurses/demos/tui.h
new file mode 100644
index 0000000000..7be91237cb
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses/demos/tui.h
@@ -0,0 +1,67 @@
+/*
+ * 'textual user interface'
+ *
+ * $Id: tui.h,v 1.11 2008/07/14 12:35:23 wmcbrine Exp $
+ *
+ * Author : P.J. Kunst <kunst@prl.philips.nl>
+ * Date : 25-02-93
+ */
+
+#ifndef _TUI_H_
+#define _TUI_H_
+
+#include <curses.h>
+
+#ifdef A_COLOR
+#define A_ATTR (A_ATTRIBUTES ^ A_COLOR) /* A_BLINK, A_REVERSE, A_BOLD */
+#else
+#define A_ATTR (A_ATTRIBUTES) /* standard UNIX attributes */
+#endif
+
+#define MAXSTRLEN 256
+#define KEY_ESC 0x1b /* Escape */
+
+typedef void (*FUNC)(void);
+
+typedef struct
+{
+ char *name; /* item label */
+ FUNC func; /* (pointer to) function */
+ char *desc; /* function description */
+} menu;
+
+/* ANSI C function prototypes: */
+
+void clsbody(void);
+int bodylen(void);
+WINDOW *bodywin(void);
+
+void rmerror(void);
+void rmstatus(void);
+
+void titlemsg(char *msg);
+void bodymsg(char *msg);
+void errormsg(char *msg);
+void statusmsg(char *msg);
+
+bool keypressed(void);
+int getkey(void);
+int waitforkey(void);
+
+void DoExit(void);
+void startmenu(menu *mp, char *title);
+void domenu(menu *mp);
+
+int weditstr(WINDOW *win, char *buf, int field);
+WINDOW *winputbox(WINDOW *win, int nlines, int ncols);
+int getstrings(char *desc[], char *buf[], int field);
+
+#define editstr(s,f) (weditstr(stdscr,s,f))
+#define mveditstr(y,x,s,f) (move(y,x)==ERR?ERR:editstr(s,f))
+#define mvweditstr(w,y,x,s,f) (wmove(w,y,x)==ERR?ERR:weditstr(w,s,f))
+
+#define inputbox(l,c) (winputbox(stdscr,l,c))
+#define mvinputbox(y,x,l,c) (move(y,x)==ERR?w:inputbox(l,c))
+#define mvwinputbox(w,y,x,l,c) (wmove(w,y,x)==ERR?w:winputbox(w,l,c))
+
+#endif
diff --git a/payloads/libpayload/curses/PDCurses/demos/tuidemo.c b/payloads/libpayload/curses/PDCurses/demos/tuidemo.c
new file mode 100644
index 0000000000..6f4d9f21df
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses/demos/tuidemo.c
@@ -0,0 +1,233 @@
+/*
+ * $Id: tuidemo.c,v 1.22 2008/07/14 12:35:23 wmcbrine Exp $
+ *
+ * Author : P.J. Kunst <kunst@prl.philips.nl>
+ * Date : 25-02-93
+ *
+ * Purpose: This program demonstrates the use of the 'curses' library
+ * for the creation of (simple) menu-operated programs.
+ * In the PDCurses version, use is made of colors for the
+ * highlighting of subwindows (title bar, status bar etc).
+ *
+ * Acknowledgement: some ideas were borrowed from Mark Hessling's
+ * version of the 'testcurs' program.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <locale.h>
+#include "tui.h"
+
+/* change this if source at other location */
+
+#ifdef XCURSES
+# define FNAME "../demos/tui.c"
+#else
+# define FNAME "..\\demos\\tui.c"
+#endif
+
+/**************************** strings entry box ***************************/
+
+void address(void)
+{
+ char *fieldname[6] =
+ {
+ "Name", "Street", "City", "State", "Country", (char *)0
+ };
+
+ char *fieldbuf[5];
+ WINDOW *wbody = bodywin();
+ int i, field = 50;
+
+ for (i = 0; i < 5; i++)
+ fieldbuf[i] = calloc(1, field + 1);
+
+ if (getstrings(fieldname, fieldbuf, field) != KEY_ESC)
+ {
+ for (i = 0; fieldname[i]; i++)
+ wprintw(wbody, "%10s : %s\n",
+ fieldname[i], fieldbuf[i]);
+
+ wrefresh(wbody);
+ }
+
+ for (i = 0; i < 5; i++)
+ free(fieldbuf[i]);
+}
+
+/**************************** string entry box ****************************/
+
+char *getfname(char *desc, char *fname, int field)
+{
+ char *fieldname[2];
+ char *fieldbuf[1];
+
+ fieldname[0] = desc;
+ fieldname[1] = 0;
+ fieldbuf[0] = fname;
+
+ return (getstrings(fieldname, fieldbuf, field) == KEY_ESC) ? NULL : fname;
+}
+
+/**************************** a very simple file browser ******************/
+
+void showfile(char *fname)
+{
+ int i, bh = bodylen();
+ FILE *fp;
+ char buf[MAXSTRLEN];
+ bool ateof = FALSE;
+
+ statusmsg("FileBrowser: Hit key to continue, Q to quit");
+
+ if ((fp = fopen(fname, "r")) != NULL) /* file available? */
+ {
+ while (!ateof)
+ {
+ clsbody();
+
+ for (i = 0; i < bh - 1 && !ateof; i++)
+ {
+ buf[0] = '\0';
+ fgets(buf, MAXSTRLEN, fp);
+
+ if (strlen(buf))
+ bodymsg(buf);
+ else
+ ateof = TRUE;
+ }
+
+ switch (waitforkey())
+ {
+ case 'Q':
+ case 'q':
+ case 0x1b:
+ ateof = TRUE;
+ }
+ }
+
+ fclose(fp);
+ }
+ else
+ {
+ sprintf(buf, "ERROR: file '%s' not found", fname);
+ errormsg(buf);
+ }
+}
+
+/***************************** forward declarations ***********************/
+
+void sub0(void), sub1(void), sub2(void), sub3(void);
+void func1(void), func2(void);
+void subfunc1(void), subfunc2(void);
+void subsub(void);
+
+/***************************** menus initialization ***********************/
+
+menu MainMenu[] =
+{
+ { "Asub", sub0, "Go inside first submenu" },
+ { "Bsub", sub1, "Go inside second submenu" },
+ { "Csub", sub2, "Go inside third submenu" },
+ { "Dsub", sub3, "Go inside fourth submenu" },
+ { "", (FUNC)0, "" } /* always add this as the last item! */
+};
+
+menu SubMenu0[] =
+{
+ { "Exit", DoExit, "Terminate program" },
+ { "", (FUNC)0, "" }
+};
+
+menu SubMenu1[] =
+{
+ { "OneBeep", func1, "Sound one beep" },
+ { "TwoBeeps", func2, "Sound two beeps" },
+ { "", (FUNC)0, "" }
+};
+
+menu SubMenu2[] =
+{
+ { "Browse", subfunc1, "Source file lister" },
+ { "Input", subfunc2, "Interactive file lister" },
+ { "Address", address, "Get address data" },
+ { "", (FUNC)0, "" }
+};
+
+menu SubMenu3[] =
+{
+ { "SubSub", subsub, "Go inside sub-submenu" },
+ { "", (FUNC)0, "" }
+};
+
+/***************************** main menu functions ************************/
+
+void sub0(void)
+{
+ domenu(SubMenu0);
+}
+
+void sub1(void)
+{
+ domenu(SubMenu1);
+}
+
+void sub2(void)
+{
+ domenu(SubMenu2);
+}
+
+void sub3(void)
+{
+ domenu(SubMenu3);
+}
+
+/***************************** submenu1 functions *************************/
+
+void func1(void)
+{
+ beep();
+ bodymsg("One beep! ");
+}
+
+void func2(void)
+{
+ beep();
+ bodymsg("Two beeps! ");
+ beep();
+}
+
+/***************************** submenu2 functions *************************/
+
+void subfunc1(void)
+{
+ showfile(FNAME);
+}
+
+void subfunc2(void)
+{
+ char fname[MAXSTRLEN];
+
+ strcpy(fname, FNAME);
+ if (getfname ("File to browse:", fname, 50))
+ showfile(fname);
+}
+
+/***************************** submenu3 functions *************************/
+
+void subsub(void)
+{
+ domenu(SubMenu2);
+}
+
+/***************************** start main menu ***************************/
+
+int main(int argc, char **argv)
+{
+ setlocale(LC_ALL, "");
+
+ startmenu(MainMenu, "TUI - 'textual user interface' demonstration program");
+
+ return 0;
+}
diff --git a/payloads/libpayload/curses/PDCurses/demos/worm.c b/payloads/libpayload/curses/PDCurses/demos/worm.c
new file mode 100644
index 0000000000..5a823f9069
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses/demos/worm.c
@@ -0,0 +1,434 @@
+/****************************************************************************
+ * Copyright (c) 2005 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/*
+
+ @@@ @@@ @@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@
+ @@@ @@@ @@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@@
+ @@@ @@@ @@@@ @@@@ @@@@ @@@@ @@@ @@@@
+ @@@ @@ @@@ @@@ @@@ @@@ @@@ @@@ @@@
+ @@@ @@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@
+ @@@@ @@@@ @@@@ @@@ @@@ @@@ @@@ @@@ @@@
+ @@@@@@@@@@@@ @@@@ @@@@ @@@ @@@ @@@ @@@
+ @@@@ @@@@ @@@@@@@@@@@@ @@@ @@@ @@@ @@@
+ @@ @@ @@@@@@@@@@ @@@ @@@ @@@ @@@
+
+ Eric P. Scott
+ Caltech High Energy Physics
+ October, 1980
+
+ Color by Eric S. Raymond
+ July, 1995
+
+Options:
+ -f fill screen with copies of 'WORM' at start.
+ -l <n> set worm length
+ -n <n> set number of worms
+ -t make worms leave droppings
+
+ $Id: worm.c,v 1.16 2008/07/13 16:08:17 wmcbrine Exp $
+*/
+
+#include <curses.h>
+#include <stdlib.h>
+#include <time.h>
+
+#define FLAVORS 7
+
+static chtype flavor[FLAVORS] =
+{
+ 'O', '*', '#', '$', '%', '0', '@'
+};
+
+static const 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 const char *field;
+static int length = 16, number = 3;
+static chtype trail = ' ';
+
+static const 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 } }
+};
+
+static void cleanup(void)
+{
+ standend();
+ refresh();
+ curs_set(1);
+ endwin();
+}
+
+int main(int argc, char *argv[])
+{
+ const struct options *op;
+ struct worm *w;
+ short **ref, *ip;
+ int x, y, n, h, last, bottom, seed;
+
+ for (x = 1; x < argc; x++)
+ {
+ char *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);
+ return EXIT_FAILURE;
+ }
+
+ 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);
+ return EXIT_FAILURE;
+ }
+
+ break;
+ case 't':
+ trail = '.';
+ break;
+ default:
+ usage:
+ fprintf(stderr, "usage: %s [-field] [-length #] "
+ "[-number #] [-trail]\n", *argv);
+ return EXIT_FAILURE;
+ }
+ }
+
+#ifdef XCURSES
+ Xinitscr(argc, argv);
+#else
+ initscr();
+#endif
+ seed = time((time_t *)0);
+ srand(seed);
+
+ noecho();
+ cbreak();
+ nonl();
+ keypad(stdscr, TRUE);
+
+ curs_set(0);
+
+ bottom = LINES - 1;
+ last = COLS - 1;
+
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ int bg = COLOR_BLACK;
+ start_color();
+
+# if defined(NCURSES_VERSION) || (defined(PDC_BUILD) && PDC_BUILD > 3000)
+ if (use_default_colors() == OK)
+ bg = -1;
+# endif
+
+# define SET_COLOR(num, fg) \
+ init_pair(num + 1, fg, bg); \
+ flavor[num] |= COLOR_PAIR(num + 1) | A_BOLD
+
+ SET_COLOR(0, COLOR_GREEN);
+ SET_COLOR(1, COLOR_RED);
+ SET_COLOR(2, COLOR_CYAN);
+ SET_COLOR(3, COLOR_WHITE);
+ SET_COLOR(4, COLOR_MAGENTA);
+ SET_COLOR(5, COLOR_BLUE);
+ SET_COLOR(6, COLOR_YELLOW);
+ }
+#endif
+
+ ref = malloc(sizeof(short *) * LINES);
+
+ for (y = 0; y < LINES; y++)
+ {
+ ref[y] = malloc(sizeof(short) * COLS);
+
+ for (x = 0; x < COLS; x++)
+ ref[y][x] = 0;
+ }
+
+#ifdef BADCORNER
+ /* if addressing the lower right corner doesn't work in your curses */
+
+ ref[bottom][last] = 1;
+#endif
+
+ for (n = number, w = &worm[0]; --n >= 0; w++)
+ {
+ w->orientation = w->head = 0;
+
+ if ((ip = malloc(sizeof(short) * (length + 1))) == NULL)
+ {
+ fprintf(stderr, "%s: out of memory\n", *argv);
+ return EXIT_FAILURE;
+ }
+
+ w->xpos = ip;
+
+ for (x = length; --x >= 0;)
+ *ip++ = -1;
+
+ if ((ip = malloc(sizeof(short) * (length + 1))) == NULL)
+ {
+ fprintf(stderr, "%s: out of memory\n", *argv);
+ return EXIT_FAILURE;
+ }
+
+ w->ypos = ip;
+
+ for (y = length; --y >= 0;)
+ *ip++ = -1;
+ }
+
+ if (field)
+ {
+ const char *p = field;
+
+ for (y = bottom; --y >= 0;)
+ for (x = COLS; --x >= 0;)
+ {
+ addch((chtype) (*p++));
+
+ if (!*p)
+ p = field;
+ }
+ }
+
+ napms(12);
+ refresh();
+ nodelay(stdscr, TRUE);
+
+ for (;;)
+ {
+ int ch;
+
+ if ((ch = getch()) > 0)
+ {
+#ifdef KEY_RESIZE
+ if (ch == KEY_RESIZE)
+ {
+# ifdef PDCURSES
+ resize_term(0, 0);
+ erase();
+# endif
+ if (last != COLS - 1)
+ {
+ for (y = 0; y <= bottom; y++)
+ {
+ ref[y] = realloc(ref[y], sizeof(short) * COLS);
+
+ for (x = last + 1; x < COLS; x++)
+ ref[y][x] = 0;
+ }
+
+ last = COLS - 1;
+ }
+
+ if (bottom != LINES - 1)
+ {
+ for (y = LINES; y <= bottom; y++)
+ free(ref[y]);
+
+ ref = realloc(ref, sizeof(short *) * LINES);
+
+ for (y = bottom + 1; y < LINES; y++)
+ {
+ ref[y] = malloc(sizeof(short) * COLS);
+
+ for (x = 0; x < COLS; x++)
+ ref[y][x] = 0;
+ }
+
+ bottom = LINES - 1;
+ }
+ }
+
+#endif /* KEY_RESIZE */
+
+ /* Make it simple to put this into single-step mode,
+ or resume normal operation - T. Dickey */
+
+ if (ch == 'q')
+ {
+ cleanup();
+ return EXIT_SUCCESS;
+ }
+ else if (ch == 's')
+ nodelay(stdscr, FALSE);
+ else if (ch == ' ')
+ nodelay(stdscr, TRUE);
+ }
+
+ for (n = 0, w = &worm[0]; n < number; n++, w++)
+ {
+ if ((x = w->xpos[h = w->head]) < 0)
+ {
+ move(y = w->ypos[h] = bottom, x = w->xpos[h] = 0);
+ addch(flavor[n % FLAVORS]);
+ ref[y][x]++;
+ }
+ else
+ y = w->ypos[h];
+
+ if (x > last)
+ x = last;
+
+ if (y > bottom)
+ y = bottom;
+
+ if (++h == length)
+ h = 0;
+
+ if (w->xpos[w->head = h] >= 0)
+ {
+ int x1 = w->xpos[h];
+ int y1 = w->ypos[h];
+
+ if (y1 < LINES && x1 < COLS && --ref[y1][x1] == 0)
+ {
+ move(y1, x1);
+ 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:
+ cleanup();
+ return EXIT_SUCCESS;
+ case 1:
+ w->orientation = op->opts[0];
+ break;
+ default:
+ w->orientation = op->opts[rand() % op->nopts];
+ }
+
+ move(y += yinc[w->orientation], x += xinc[w->orientation]);
+
+ if (y < 0)
+ y = 0;
+
+ addch(flavor[n % FLAVORS]);
+ ref[w->ypos[h] = y][w->xpos[h] = x]++;
+ }
+ napms(12);
+ refresh();
+ }
+}
diff --git a/payloads/libpayload/curses/PDCurses/demos/xmas.c b/payloads/libpayload/curses/PDCurses/demos/xmas.c
new file mode 100644
index 0000000000..706858a5aa
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses/demos/xmas.c
@@ -0,0 +1,957 @@
+/******************************************************************************/
+/* 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 looks a lot better if you can turn off your cursor before execution. */
+/* 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 xmas.c -lcurses -o xmas -s */
+/* */
+/******************************************************************************/
+
+/* $Id: xmas.c,v 1.29 2008/07/13 16:08:17 wmcbrine Exp $ */
+
+#include <curses.h>
+#include <signal.h>
+
+void lil(WINDOW *);
+void midtop(WINDOW *);
+void bigtop(WINDOW *);
+void bigface(WINDOW *, chtype);
+void legs1(WINDOW *);
+void legs2(WINDOW *);
+void legs3(WINDOW *);
+void legs4(WINDOW *);
+void initdeer(void);
+void boxit(void);
+void seas(void);
+void greet(void);
+void fromwho(void);
+void del_msg(void);
+void tree(void);
+void balls(void);
+void star(void);
+void strng1(void);
+void strng2(void);
+void strng3(void);
+void strng4(void);
+void strng5(void);
+void blinkit(void);
+void reindeer(void);
+
+#define FROMWHO "From Larry Bartz, Mark Hessling and William McBrine"
+
+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;
+
+int main(int argc, char **argv)
+{
+ int loopy;
+
+#ifdef XCURSES
+ Xinitscr(argc, argv);
+#else
+ initscr();
+#endif
+ nodelay(stdscr, TRUE);
+ noecho();
+ nonl();
+ refresh();
+
+#ifdef A_COLOR
+ if (has_colors())
+ start_color();
+#endif
+ curs_set(0);
+
+ 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);
+
+ w_holiday = newwin(1, 26, 3, 27);
+
+ w_del_msg = newwin(1, 12, 23, 60);
+
+ mvwaddstr(w_holiday, 0, 0, "H A P P Y H O L I D A Y S");
+
+ initdeer();
+
+ clear();
+ werase(treescrn);
+ touchwin(treescrn);
+ werase(treescrn2);
+ touchwin(treescrn2);
+ werase(treescrn8);
+ touchwin(treescrn8);
+ refresh();
+ napms(1000);
+
+ boxit();
+ del_msg();
+ napms(1000);
+
+ seas();
+ del_msg();
+ napms(1000);
+
+ greet();
+ del_msg();
+ napms(1000);
+
+ fromwho();
+ del_msg();
+ napms(1000);
+
+ tree();
+ napms(1000);
+
+ balls();
+ napms(1000);
+
+ star();
+ napms(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 */
+ mvwaddch(treescrn4, 0, 12, '*' | A_STANDOUT);
+
+ /* 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 */
+ mvwaddch(treescrn6, 0, 12, '*' | A_STANDOUT);
+
+ /* 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, ' ');
+
+ napms(1000);
+ reindeer();
+
+ touchwin(w_holiday);
+ wrefresh(w_holiday);
+ wrefresh(w_del_msg);
+
+ napms(1000);
+
+ for (loopy = 0; loopy < 50; loopy++)
+ blinkit();
+
+ clear();
+ refresh();
+ endwin();
+
+ return 0;
+}
+
+void lil(WINDOW *win)
+{
+ mvwaddch(win, 0, 0, (chtype) 'V');
+ mvwaddch(win, 1, 0, (chtype) '@');
+ mvwaddch(win, 1, 3, (chtype) '~');
+}
+
+void midtop(WINDOW *win)
+{
+ mvwaddstr(win, 0, 2, "yy");
+ mvwaddstr(win, 1, 2, "0(=)~");
+}
+
+void bigtop(WINDOW *win)
+{
+ mvwaddstr(win, 0, 17, "\\/");
+ mvwaddstr(win, 0, 20, "\\/");
+ mvwaddch(win, 1, 18, (chtype) '\\');
+ mvwaddch(win, 1, 20, (chtype) '/');
+ mvwaddstr(win, 2, 19, "|_");
+ mvwaddstr(win, 3, 18, "/^0\\");
+ mvwaddstr(win, 4, 17, "//\\");
+ mvwaddch(win, 4, 22, (chtype) '\\');
+ mvwaddstr(win, 5, 7, "^~~~~~~~~// ~~U");
+}
+
+void bigface(WINDOW *win, chtype noseattr)
+{
+ mvwaddstr(win, 0, 16, "\\/ \\/");
+ mvwaddstr(win, 1, 17, "\\Y/ \\Y/");
+ mvwaddstr(win, 2, 19, "\\=/");
+ mvwaddstr(win, 3, 17, "^\\o o/^");
+ mvwaddstr(win, 4, 17, "//( )");
+ mvwaddstr(win, 5, 7, "^~~~~~~~~// \\");
+ waddch(win, 'O' | noseattr);
+ waddstr(win, "/");
+}
+
+void legs1(WINDOW *win)
+{
+ mvwaddstr(win, 6, 7, "( \\_____( /");
+ mvwaddstr(win, 7, 8, "( ) /");
+ mvwaddstr(win, 8, 9, "\\\\ /");
+ mvwaddstr(win, 9, 11, "\\>/>");
+}
+
+void legs2(WINDOW *win)
+{
+ mvwaddstr(win, 6, 7, "(( )____( /");
+ mvwaddstr(win, 7, 7, "( / |");
+ mvwaddstr(win, 8, 8, "\\/ |");
+ mvwaddstr(win, 9, 9, "|> |>");
+}
+
+void legs3(WINDOW *win)
+{
+ mvwaddstr(win, 6, 6, "( ()_____( /");
+ mvwaddstr(win, 7, 6, "/ / /");
+ mvwaddstr(win, 8, 5, "|/ \\");
+ mvwaddstr(win, 9, 5, "/> \\>");
+}
+
+void legs4(WINDOW *win)
+{
+ mvwaddstr(win, 6, 6, "( )______( /");
+ mvwaddstr(win, 7, 5, "(/ \\");
+ mvwaddstr(win, 8, 0, "v___= ----^");
+}
+
+void initdeer(void)
+{
+ chtype noseattr;
+
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(31, COLOR_RED, COLOR_BLACK);
+ noseattr = COLOR_PAIR(31);
+ }
+ else
+#endif
+ noseattr = A_NORMAL;
+
+ /* set up the windows for our various reindeer */
+
+ dotdeer0 = newwin(3, 71, 0, 8);
+ stardeer0 = newwin(4, 56, 0, 8);
+ lildeer0 = newwin(7, 54, 0, 8);
+ middeer0 = newwin(15, 42, 0, 8);
+ bigdeer0 = newwin(10, 23, 0, 0);
+ lookdeer0 = newwin(10, 25, 0, 0);
+
+ /* lildeer1 */
+ lildeer1 = newwin(2, 4, 0, 0);
+ lil(lildeer1);
+ mvwaddstr(lildeer1, 1, 1, "<>");
+
+ /* lildeer2 */
+ lildeer2 = newwin(2, 4, 0, 0);
+ lil(lildeer2);
+ mvwaddstr(lildeer2, 1, 1, "||");
+
+ /* lildeer3 */
+ lildeer3 = newwin(2, 4, 0, 0);
+ lil(lildeer3);
+ mvwaddstr(lildeer3, 1, 1, "><");
+
+ /* middeer1 */
+ middeer1 = newwin(3, 7, 0, 0);
+ midtop(middeer1);
+ mvwaddstr(middeer1, 2, 3, "\\/");
+
+ /* middeer2 */
+ middeer2 = newwin(3, 7, 0, 0);
+ midtop(middeer2);
+ mvwaddch(middeer2, 2, 3, (chtype) '|');
+ mvwaddch(middeer2, 2, 5, (chtype) '|');
+
+ /* middeer3 */
+ middeer3 = newwin(3, 7, 0, 0);
+ midtop(middeer3);
+ mvwaddch(middeer3, 2, 2, (chtype) '/');
+ mvwaddch(middeer3, 2, 6, (chtype) '\\');
+
+ /* bigdeer1 */
+ bigdeer1 = newwin(10, 23, 0, 0);
+ bigtop(bigdeer1);
+ legs1(bigdeer1);
+
+ /* bigdeer2 */
+ bigdeer2 = newwin(10, 23, 0, 0);
+ bigtop(bigdeer2);
+ legs2(bigdeer2);
+
+ /* bigdeer3 */
+ bigdeer3 = newwin(10, 23, 0, 0);
+ bigtop(bigdeer3);
+ legs3(bigdeer3);
+
+ /* bigdeer4 */
+ bigdeer4 = newwin(10, 23, 0, 0);
+ bigtop(bigdeer4);
+ legs4(bigdeer4);
+
+ /* lookdeer1 */
+ lookdeer1 = newwin(10, 25, 0, 0);
+ bigface(lookdeer1, noseattr);
+ legs1(lookdeer1);
+
+ /* lookdeer2 */
+ lookdeer2 = newwin(10, 25, 0, 0);
+ bigface(lookdeer2, noseattr);
+ legs2(lookdeer2);
+
+ /* lookdeer3 */
+ lookdeer3 = newwin(10, 25, 0, 0);
+ bigface(lookdeer3, noseattr);
+ legs3(lookdeer3);
+
+ /* lookdeer4 */
+ lookdeer4 = newwin(10, 25, 0, 0);
+ bigface(lookdeer4, noseattr);
+ legs4(lookdeer4);
+}
+
+void boxit(void)
+{
+ int x;
+
+ for (x = 0; x < 20; ++x)
+ mvaddch(x, 7, '|');
+
+ for (x = 0; x < 80; ++x)
+ {
+ if (x > 7)
+ mvaddch(19, x, '_');
+
+ mvaddch(22, x, '_');
+ }
+}
+
+void seas(void)
+{
+ 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');
+}
+
+void greet(void)
+{
+ 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');
+}
+
+void fromwho(void)
+{
+ mvaddstr(21, 13, FROMWHO);
+}
+
+void del_msg(void)
+{
+ refresh();
+}
+
+void tree(void)
+{
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(30, COLOR_GREEN, COLOR_BLACK);
+ wattrset(treescrn, COLOR_PAIR(30));
+ }
+#endif
+ 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,
+ "//////////// \\\\\\\\\\\\\\\\\\\\\\\\");
+
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(20, COLOR_YELLOW, COLOR_BLACK);
+ wattrset(treescrn, COLOR_PAIR(20));
+ }
+#endif
+ mvwaddstr(treescrn, 14, 11, "| |");
+ mvwaddstr(treescrn, 15, 11, "|_|");
+
+ wrefresh(treescrn);
+ wrefresh(w_del_msg);
+}
+
+void balls(void)
+{
+ chtype ball1, ball2, ball3, ball4, ball5, ball6;
+
+ overlay(treescrn, treescrn2);
+
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(1, COLOR_BLUE, COLOR_BLACK);
+ init_pair(2, COLOR_RED, COLOR_BLACK);
+ init_pair(3, COLOR_MAGENTA, COLOR_BLACK);
+ init_pair(4, COLOR_CYAN, COLOR_BLACK);
+ init_pair(5, COLOR_YELLOW, COLOR_BLACK);
+ init_pair(6, COLOR_WHITE, COLOR_BLACK);
+ ball1 = COLOR_PAIR(1) | '@';
+ ball2 = COLOR_PAIR(2) | '@';
+ ball3 = COLOR_PAIR(3) | '@';
+ ball4 = COLOR_PAIR(4) | '@';
+ ball5 = COLOR_PAIR(5) | '@';
+ ball6 = COLOR_PAIR(6) | '@';
+ }
+ else
+#endif
+ ball1 = ball2 = ball3 = ball4 = ball5 = ball6 = '@';
+
+ mvwaddch(treescrn2, 3, 9, ball1);
+ mvwaddch(treescrn2, 3, 15, ball2);
+ mvwaddch(treescrn2, 4, 8, ball3);
+ mvwaddch(treescrn2, 4, 16, ball4);
+ mvwaddch(treescrn2, 5, 7, ball5);
+ mvwaddch(treescrn2, 5, 17, ball6);
+ mvwaddch(treescrn2, 7, 6, ball1 | A_BOLD);
+ mvwaddch(treescrn2, 7, 18, ball2 | A_BOLD);
+ mvwaddch(treescrn2, 8, 5, ball3 | A_BOLD);
+ mvwaddch(treescrn2, 8, 19, ball4 | A_BOLD);
+ mvwaddch(treescrn2, 10, 4, ball5 | A_BOLD);
+ mvwaddch(treescrn2, 10, 20, ball6 | A_BOLD);
+ mvwaddch(treescrn2, 11, 2, ball1);
+ mvwaddch(treescrn2, 11, 22, ball2);
+ mvwaddch(treescrn2, 12, 1, ball3);
+ mvwaddch(treescrn2, 12, 23, ball4);
+
+ wrefresh(treescrn2);
+ wrefresh(w_del_msg);
+}
+
+void star(void)
+{
+ mvwaddch(treescrn2, 0, 12, (chtype) '*' | A_STANDOUT);
+
+ wrefresh(treescrn2);
+ wrefresh(w_del_msg);
+}
+
+void strng1(void)
+{
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(10, COLOR_YELLOW, COLOR_BLACK);
+ wattrset(treescrn2, COLOR_PAIR(10) | A_BOLD);
+ }
+#endif
+ mvwaddstr(treescrn2, 3, 11, ".:'");
+
+ wrefresh(treescrn2);
+ wrefresh(w_del_msg);
+}
+
+void strng2(void)
+{
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(11, COLOR_RED, COLOR_BLACK);
+ wattrset(treescrn2, COLOR_PAIR(11) | A_BOLD);
+ }
+#endif
+ mvwaddstr(treescrn2, 5, 11, ",.:'");
+ mvwaddstr(treescrn2, 6, 9, ":'");
+
+ wrefresh(treescrn2);
+ wrefresh(w_del_msg);
+}
+
+void strng3(void)
+{
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(12, COLOR_GREEN, COLOR_BLACK);
+ wattrset(treescrn2, COLOR_PAIR(12) | A_BOLD);
+ }
+#endif
+ mvwaddstr(treescrn2, 7, 13, ",.:'");
+ mvwaddstr(treescrn2, 8, 9, ",.:'");
+
+ wrefresh(treescrn2);
+ wrefresh(w_del_msg);
+}
+
+void strng4(void)
+{
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(13, COLOR_WHITE, COLOR_BLACK);
+ wattrset(treescrn2, COLOR_PAIR(13) | A_BOLD);
+ }
+#endif
+ mvwaddstr(treescrn2, 9, 14, ",.:'");
+ mvwaddstr(treescrn2, 10, 10, ",.:'");
+ mvwaddstr(treescrn2, 11, 6, ",.:'");
+ mvwaddch(treescrn2, 12, 5, (chtype) '\'');
+
+ wrefresh(treescrn2);
+ wrefresh(w_del_msg);
+}
+
+void strng5(void)
+{
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(14, COLOR_CYAN, COLOR_BLACK);
+ wattrset(treescrn2, COLOR_PAIR(14) | A_BOLD);
+ }
+#endif
+ mvwaddstr(treescrn2, 11, 16, ",.:'");
+ mvwaddstr(treescrn2, 12, 12, ",.:'");
+
+ /* save a fully lit tree */
+ overlay(treescrn2, treescrn);
+
+ wrefresh(treescrn2);
+ wrefresh(w_del_msg);
+}
+
+void blinkit(void)
+{
+ static int cycle;
+
+ if (cycle > 4)
+ cycle = 0;
+
+ touchwin(treescrn8);
+
+ switch (cycle)
+ {
+ case 0:
+ overlay(treescrn3, treescrn8);
+ break;
+
+ case 1:
+ overlay(treescrn4, treescrn8);
+ break;
+
+ case 2:
+ overlay(treescrn5, treescrn8);
+ break;
+
+ case 3:
+ overlay(treescrn6, treescrn8);
+ break;
+
+ case 4:
+ overlay(treescrn7, treescrn8);
+ }
+
+ wrefresh(treescrn8);
+ wrefresh(w_del_msg);
+
+ napms(50);
+ touchwin(treescrn8);
+
+ /*ALL ON************************************************** */
+
+ overlay(treescrn, treescrn8);
+ wrefresh(treescrn8);
+ wrefresh(w_del_msg);
+
+ ++cycle;
+}
+
+#define TSHOW(win, pause) touchwin(win); wrefresh(win); \
+ wrefresh(w_del_msg); napms(pause)
+
+#define SHOW(win, pause) mvwin(win, y_pos, x_pos); wrefresh(win); \
+ wrefresh(w_del_msg); napms(pause)
+
+void reindeer(void)
+{
+ 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);
+ }
+ 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++)
+ {
+ TSHOW(lildeer0, 50);
+
+ for (looper = 0; looper < 4; looper++)
+ {
+ SHOW(lildeer3, 50);
+ SHOW(lildeer2, 50);
+ SHOW(lildeer1, 50);
+ SHOW(lildeer2, 50);
+ SHOW(lildeer3, 50);
+
+ TSHOW(lildeer0, 50);
+
+ 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++)
+ {
+ SHOW(middeer3, 50);
+ SHOW(middeer2, 50);
+ SHOW(middeer1, 50);
+ SHOW(middeer2, 50);
+ SHOW(middeer3, 50);
+
+ TSHOW(middeer0, 50);
+
+ x_pos -= 3;
+ }
+ }
+
+ napms(2000);
+
+ y_pos = 1;
+
+ for (x_pos = 8; x_pos < 16; x_pos++)
+ {
+ SHOW(bigdeer4, 30);
+ SHOW(bigdeer3, 30);
+ SHOW(bigdeer2, 30);
+ SHOW(bigdeer1, 30);
+ SHOW(bigdeer2, 30);
+ SHOW(bigdeer3, 30);
+ SHOW(bigdeer4, 30);
+ SHOW(bigdeer0, 30);
+ }
+
+ --x_pos;
+
+ for (looper = 0; looper < 6; looper++)
+ {
+ SHOW(lookdeer4, 40);
+ SHOW(lookdeer3, 40);
+ SHOW(lookdeer2, 40);
+ SHOW(lookdeer1, 40);
+ SHOW(lookdeer2, 40);
+ SHOW(lookdeer3, 40);
+ SHOW(lookdeer4, 40);
+ }
+
+ SHOW(lookdeer0, 40);
+
+ for (; y_pos < 10; y_pos++)
+ {
+ for (looper = 0; looper < 2; looper++)
+ {
+ SHOW(bigdeer4, 30);
+ SHOW(bigdeer3, 30);
+ SHOW(bigdeer2, 30);
+ SHOW(bigdeer1, 30);
+ SHOW(bigdeer2, 30);
+ SHOW(bigdeer3, 30);
+ SHOW(bigdeer4, 30);
+ }
+
+ SHOW(bigdeer0, 30);
+ }
+
+ --y_pos;
+
+ mvwin(lookdeer3, y_pos, x_pos);
+ wrefresh(lookdeer3);
+ wrefresh(w_del_msg);
+}