aboutsummaryrefslogtreecommitdiff
path: root/contrib/ncurses/test/testcurs.c
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2002-05-21 05:30:25 +0000
committerPeter Wemm <peter@FreeBSD.org>2002-05-21 05:30:25 +0000
commit39f2269fcb4873fd97d70af944ec49f4230fadea (patch)
treebd986d58f5a6e348466b5362637ba93e6cd5bf8c /contrib/ncurses/test/testcurs.c
parent7e6a63408cfb0b48f0e41f77ed82f5d0ca60bda5 (diff)
downloadsrc-39f2269fcb4873fd97d70af944ec49f4230fadea.tar.gz
src-39f2269fcb4873fd97d70af944ec49f4230fadea.zip
Import ncurses-5.2-20020518 onto the vendor branch.
Obtained from: ftp://dickey.his.com/ncurses/
Notes
Notes: svn path=/vendor/ncurses/dist/; revision=97049
Diffstat (limited to 'contrib/ncurses/test/testcurs.c')
-rw-r--r--contrib/ncurses/test/testcurs.c101
1 files changed, 69 insertions, 32 deletions
diff --git a/contrib/ncurses/test/testcurs.c b/contrib/ncurses/test/testcurs.c
index efcd39faac43..b08c766f3bcd 100644
--- a/contrib/ncurses/test/testcurs.c
+++ b/contrib/ncurses/test/testcurs.c
@@ -7,7 +7,7 @@
* wrs(5/28/93) -- modified to be consistent (perform identically) with either
* PDCurses or under Unix System V, R4
*
- * $Id: testcurs.c,v 1.24 2001/02/24 22:13:23 tom Exp $
+ * $Id: testcurs.c,v 1.28 2002/02/03 00:29:22 tom Exp $
*/
#include <test.priv.h>
@@ -36,7 +36,7 @@ typedef struct commands COMMAND;
const COMMAND command[] =
{
- {"Intro Test", introTest},
+ {"General Test", introTest},
{"Pad Test", padTest},
#if defined(PDCURSES) && !defined(XCURSES)
{"Resize Test", resizeTest},
@@ -51,22 +51,25 @@ int width, height;
int
main(
- int argc GCC_UNUSED,
- char *argv[]GCC_UNUSED)
+ int argc GCC_UNUSED,
+ char *argv[]GCC_UNUSED)
{
WINDOW *win;
- int key, old_option = (-1), new_option = 0;
+ int key;
+ int old_option = (-1);
+ int new_option = 0;
bool quit = FALSE;
+ unsigned n;
#ifdef PDCDEBUG
PDC_debug("testcurs started\n");
#endif
if (!initTest(&win))
- return EXIT_FAILURE;
+ ExitProgram(EXIT_FAILURE);
erase();
display_menu(old_option, new_option);
- while (1) {
+ for (;;) {
#ifdef A_COLOR
if (has_colors()) {
init_pair(1, COLOR_WHITE, COLOR_BLUE);
@@ -82,6 +85,17 @@ main(
keypad(stdscr, TRUE);
raw();
key = getch();
+ if (key < KEY_MIN && key > 0 && isalpha(key)) {
+ if (islower(key))
+ key = toupper(key);
+ for (n = 0; n < MAX_OPTIONS; ++n) {
+ if (key == command[n].text[0]) {
+ display_menu(old_option, new_option = n);
+ key = ' ';
+ break;
+ }
+ }
+ }
switch (key) {
case 10:
case 13:
@@ -106,6 +120,9 @@ main(
quit = TRUE;
break;
default:
+ beep();
+ break;
+ case ' ':
break;
}
if (quit == TRUE)
@@ -118,7 +135,7 @@ main(
#ifdef XCURSES
XCursesExit();
#endif
- return EXIT_SUCCESS;
+ ExitProgram(EXIT_SUCCESS);
}
static void
@@ -186,7 +203,7 @@ introTest(WINDOW *win)
wrefresh(win);
cbreak();
mvwaddstr(win, 1, 1,
- "You should have rectangle in the middle of the screen");
+ "You should have rectangle in the middle of the screen");
mvwaddstr(win, 2, 1, "You should have heard a beep");
Continue(win);
return;
@@ -249,6 +266,8 @@ scrollTest(WINDOW *win)
static void
inputTest(WINDOW *win)
{
+ int answered;
+ int repeat;
int w, h, bx, by, sw, sh, i, c, num;
char buffer[80];
WINDOW *subWin;
@@ -317,7 +336,7 @@ inputTest(WINDOW *win)
#if defined(PDCURSES)
mouse_set(ALL_MOUSE_EVENTS);
#endif
- while (1) {
+ for (;;) {
wmove(win, 3, 5);
c = wgetch(win);
wclrtobot(win);
@@ -365,20 +384,38 @@ inputTest(WINDOW *win)
mouse_set(0L);
#endif
refresh();
- wclear(win);
- mvwaddstr(win, 3, 2, "The window should have moved");
- mvwaddstr(win, 4, 2,
- "This text should have appeared without you pressing a key");
- mvwaddstr(win, 6, 2, "Enter a number then a string separated by space");
- mvwin(win, 2, 1);
- wrefresh(win);
- echo();
- noraw();
- num = 0;
- *buffer = 0;
- mvwscanw(win, 7, 6, "%d %s", &num, buffer);
- mvwprintw(win, 8, 6, "String: %s Number: %d", buffer, num);
- Continue(win);
+
+ repeat = 0;
+ do {
+ static char *fmt[] = {
+ "%d %10s",
+ "%d %[a-zA-Z]s",
+ "%d %[][a-zA-Z]s",
+ "%d %[^0-9]"
+ };
+ char *format = fmt[repeat % SIZEOF(fmt)];
+
+ wclear(win);
+ mvwaddstr(win, 3, 2, "The window should have moved");
+ mvwaddstr(win, 4, 2,
+ "This text should have appeared without you pressing a key");
+ mvwprintw(win, 6, 2,
+ "Scanning with format \"%s\"", format);
+ mvwin(win, 2 + 2 * (repeat % 4), 1 + 2 * (repeat % 4));
+ erase();
+ refresh();
+ wrefresh(win);
+ echo();
+ noraw();
+ num = 0;
+ *buffer = 0;
+ answered = mvwscanw(win, 7, 6, format, &num, buffer);
+ mvwprintw(win, 8, 6,
+ "String: %s Number: %d (%d values read)",
+ buffer, num, answered);
+ Continue(win);
+ ++repeat;
+ } while (answered > 0);
}
static void
@@ -392,7 +429,7 @@ outputTest(WINDOW *win)
nl();
wclear(win);
mvwaddstr(win, 1, 1,
- "You should now have a screen in the upper left corner, and this text should have wrapped");
+ "You should now have a screen in the upper left corner, and this text should have wrapped");
mvwin(win, 2, 1);
waddstr(win, "\nThis text should be down\n");
waddstr(win, "and broken into two here ^");
@@ -409,7 +446,7 @@ outputTest(WINDOW *win)
if (LINES < 24 || COLS < 75) {
mvwaddstr(win, 5, 1,
- "Some tests have been skipped as they require a");
+ "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 {
@@ -429,7 +466,7 @@ outputTest(WINDOW *win)
#endif
wclear(win1);
mvwaddstr(win1, 5, 1,
- "This text should appear; using overlay option");
+ "This text should appear; using overlay option");
copywin(win, win1, 0, 0, 0, 0, 9, 49, TRUE);
#if defined(PDCURSES) && !defined(XCURSES)
@@ -444,7 +481,7 @@ outputTest(WINDOW *win)
wclear(win1);
wattron(win1, A_BLINK);
mvwaddstr(win1, 4, 1,
- "This blinking text should appear in only the second window");
+ "This blinking text should appear in only the second window");
wattroff(win1, A_BLINK);
mvwin(win1, by, bx);
overlay(win, win1);
@@ -490,7 +527,7 @@ outputTest(WINDOW *win)
wclear(win);
wmove(win, 2, 2);
wprintw(win, "This is a formatted string in a window: %d %s\n", 42,
- "is it");
+ "is it");
mvwaddstr(win, 10, 1, "Enter a string: ");
wrefresh(win);
noraw();
@@ -514,7 +551,7 @@ outputTest(WINDOW *win)
wclear(win);
curs_set(0);
mvwaddstr(win, 1, 1,
- "The cursor should have disappeared (invisible)");
+ "The cursor should have disappeared (invisible)");
Continue(win);
}
@@ -608,7 +645,7 @@ padTest(WINDOW *dummy GCC_UNUSED)
mvwaddstr(pad, 5, 2, "This is a new pad");
wattrset(pad, A_NORMAL);
mvwaddstr(pad, 8, 0,
- "The end of this line should be truncated here:except now");
+ "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);
@@ -652,6 +689,6 @@ display_menu(int old_option, int new_option)
mvaddstr(5 + new_option, 25, command[new_option].text);
attrset(A_NORMAL);
mvaddstr(13, 3,
- "Use Up and Down Arrows to select - Enter to run - Q to quit");
+ "Use Up and Down Arrows to select - Enter to run - Q to quit");
refresh();
}