DESCRIPTION
An interactive test module for the ncurses library.
AUTHOR
This software is Copyright (C) 1993 by Eric S. Raymond, all rights reserved.
It is issued with ncurses under the same terms and conditions as the ncurses
library source.
/****************************************************************************
*
* Character input test
*
****************************************************************************/
static void getch_test(void)
/* test the keypad feature */
{
char buf[BUFSIZ];
int c;
int incount = 0, firsttime = 0;
bool blocking = TRUE;
int y, x;
attrset(A_NORMAL);
mvaddstr(18,8,"This is NORMAL mode: ");
addstr("abcde fghij klmno pqrst uvwxy z");
refresh();
Pause();
erase();
endwin();
}
/****************************************************************************
*
* Color support tests
*
****************************************************************************/
static void color_test(void)
/* generate a color test pattern */
{
int i;
refresh();
(void) printw("There are %d color pairs\n", COLOR_PAIRS);
(void) mvprintw(1, 0,
"%dx%d matrix of foreground/background colors, bright *off*\n",
COLORS, COLORS);
for (i = 0; i < COLORS; i++)
mvaddstr(2, (i+1) * 8, colors[i]);
for (i = 0; i < COLORS; i++)
mvaddstr(3 + i, 0, colors[i]);
for (i = 1; i < COLOR_PAIRS; i++)
{
init_pair(i, i % COLORS, i / COLORS);
attron((attr_t)COLOR_PAIR(i));
mvaddstr(3 + (i / COLORS), (i % COLORS + 1) * 8, "Hello");
attrset(A_NORMAL);
}
(void) mvprintw(COLORS + 4, 0,
"%dx%d matrix of foreground/background colors, bright *on*\n",
COLORS, COLORS);
for (i = 0; i < COLORS; i++)
mvaddstr(5 + COLORS, (i+1) * 8, colors[i]);
for (i = 0; i < COLORS; i++)
mvaddstr(6 + COLORS + i, 0, colors[i]);
for (i = 1; i < COLOR_PAIRS; i++)
{
init_pair(i, i % COLORS, i / COLORS);
attron((attr_t)(COLOR_PAIR(i) | A_BOLD));
mvaddstr(6 + COLORS + (i / COLORS), (i % COLORS + 1) * 8, "Hello");
attrset(A_NORMAL);
}
Pause();
erase();
endwin();
}
static void color_edit(void)
/* display the color test pattern, without trying to edit colors */
{
int i, c, value = 0, current = 0, field = 0, usebase = 0;
refresh();
for (i = 0; i < COLORS; i++)
init_pair(i, COLOR_WHITE, i);
do {
short red, green, blue;
attron(A_BOLD);
mvaddstr(0, 20, "Color RGB Value Editing");
attroff(A_BOLD);
for (i = 0; i < COLORS; i++)
{
mvprintw(2 + i, 0, "%c %-8s:",
(i == current ? '>' : ' '),
(i < sizeof(colors)/sizeof(colors[0]) ? colors[i] : ""));
attrset(COLOR_PAIR(i));
addstr(" ");
attrset(A_NORMAL);
/*
* Note: this refresh should *not* be necessary! It works around
* a bug in attribute handling that apparently causes the A_NORMAL
* attribute sets to interfere with the actual emission of the
* color setting somehow. This needs to be fixed.
*/
refresh();
color_content(i, &red, &green, &blue);
addstr(" R = ");
if (current == i && field == 0) attron(A_STANDOUT);
printw("%04d", red);
if (current == i && field == 0) attrset(A_NORMAL);
addstr(", G = ");
if (current == i && field == 1) attron(A_STANDOUT);
printw("%04d", green);
if (current == i && field == 1) attrset(A_NORMAL);
addstr(", B = ");
if (current == i && field == 2) attron(A_STANDOUT);
printw("%04d", blue);
if (current == i && field == 2) attrset(A_NORMAL);
attrset(A_NORMAL);
addstr(")");
}
mvaddstr(COLORS + 3, 0,
"Use up/down to select a color, left/right to change fields.");
mvaddstr(COLORS + 4, 0,
"Modify field by typing nnn=, nnn-, or nnn+. ? for help.");
move(2 + current, 0);
switch (c = getch())
{
case KEY_UP:
current = (current == 0 ? (COLORS - 1) : current - 1);
value = 0;
break;
case KEY_DOWN:
current = (current == (COLORS - 1) ? 0 : current + 1);
value = 0;
break;
case KEY_RIGHT:
field = (field == 2 ? 0 : field + 1);
value = 0;
break;
case KEY_LEFT:
field = (field == 0 ? 2 : field - 1);
value = 0;
break;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
do {
value = value * 10 + (c - '0');
c = getch();
} while
(isdigit(c));
if (c != '+' && c != '-' && c != '=')
beep();
else
ungetch(c);
break;
case '+':
usebase = 1;
goto changeit;
case '-':
value = -value;
usebase = 1;
goto changeit;
case '=':
usebase = 0;
changeit:
color_content(current, &red, &green, &blue);
if (field == 0)
red = red * usebase + value;
else if (field == 1)
green = green * usebase + value;
else if (field == 2)
blue = blue * usebase + value;
init_color(current, red, green, blue);
break;
case '?':
erase();
P(" RGB Value Editing Help");
P("");
P("You are in the RGB value editor. Use the arrow keys to select one of");
P("the fields in one of the RGB triples of the current colors; the one");
P("currently selected will be reverse-video highlighted.");
P("");
P("To change a field, enter the digits of the new value; they won't be");
P("echoed. Finish by typing `='; the change will take effect instantly.");
P("To increment or decrement a value, use the same procedure, but finish");
P("with a `+' or `-'.");
P("");
P("To quit, do `x' or 'q'");
Pause();
erase();
break;
case 'x':
case 'q':
break;
default:
beep();
break;
}
} while
(c != 'x' && c != 'q');
erase();
endwin();
}
/****************************************************************************
*
* Soft-key label test
*
****************************************************************************/
static void slk_test(void)
/* exercise the soft keys */
{
int c, fmt = 1;
char buf[9];
c = CTRL('l');
do {
switch(c)
{
case CTRL('l'):
erase();
attron(A_BOLD);
mvaddstr(0, 20, "Soft Key Exerciser");
attroff(A_BOLD);
move(2, 0);
P("Available commands are:");
P("");
P("^L -- refresh screen");
P("a -- activate or restore soft keys");
P("d -- disable soft keys");
P("c -- set centered format for labels");
P("l -- set left-justified format for labels");
P("r -- set right-justified format for labels");
P("[12345678] -- set label; labels are numbered 1 through 8");
P("e -- erase stdscr (should not erase labels)");
P("s -- test scrolling of shortened screen");
P("x, q -- return to main menu");
P("");
P("Note: if activating the soft keys causes your terminal to");
P("scroll up one line, your terminal auto-scrolls when anything");
P("is written to the last screen position. The ncurses code");
P("does not yet handle this gracefully.");
refresh();
/* fall through */
case 'a':
slk_restore();
break;
case 'e':
wclear(stdscr);
break;
case 's':
move(20, 0);
while ((c = getch()) != 'Q' && (c != ERR))
addch((chtype)c);
break;
case 'd':
slk_clear();
break;
case 'l':
fmt = 0;
break;
case 'c':
fmt = 1;
break;
case 'r':
fmt = 2;
break;
case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8':
(void) mvaddstr(20, 0, "Please enter the label value: ");
echo();
wgetnstr(stdscr, buf, 8);
noecho();
slk_set((c - '0'), buf, fmt);
slk_refresh();
break;
case 'x':
case 'q':
goto done;
default:
beep();
}
} while
((c = getch()) != EOF);
#define HYBASE (ACSY + 17)
mvprintw(HYBASE, 0, "High-half characters via echochar:\n");
for (i = 0; i < 4; i++)
{
move(HYBASE + 1 + i, 24);
for (j = 0; j < 32; j++)
echochar((chtype)(128 + 32 * i + j));
}
Pause();
erase();
endwin();
}
/****************************************************************************
*
* Windows and scrolling tester.
*
****************************************************************************/
#define BOTLINES 4 /* number of line stolen from screen bottom */
typedef struct
{
int y, x;
}
pair;
static void report(void)
/* report on the cursor's current position, then restore it */
{
int y, x;
getyx(stdscr, y, x);
move(LINES - 1, COLS - 17);
printw("Y = %2d X = %2d", y, x);
move(y, x);
}
static pair *selectcell(int uli, int ulj, int lri, int lrj)
/* arrows keys move cursor, return location at current on non-arrow key */
{
static pair res; /* result cell */
int si = lri - uli + 1; /* depth of the select area */
int sj = lrj - ulj + 1; /* width of the select area */
int i = 0, j = 0; /* offsets into the select area */
res.y = uli;
res.x = ulj;
for (;;)
{
move(LINES - 1, COLS - 17);
clrtoeol();
printw("Y = %2d X = %2d", uli + i, ulj + j);
move(uli + i, ulj + j);
switch(getch())
{
case KEY_UP: i += si - 1; break;
case KEY_DOWN: i++; break;
case KEY_LEFT: j += sj - 1; break;
case KEY_RIGHT: j++; break;
case '\004': return((pair *)NULL);
default: res.y = uli + i; res.x = ulj + j; return(&res);
}
i %= si;
j %= sj;
}
}
/*+-------------------------------------------------------------------------
saywhat(text)
--------------------------------------------------------------------------*/
static void
saywhat(char *text)
{
wmove(stdscr,LINES - 1,0);
wclrtoeol(stdscr);
waddstr(stdscr, text);
} /* end of saywhat */
/*+-------------------------------------------------------------------------
mkpanel(rows,cols,tly,tlx) - alloc a win and panel and associate them
--------------------------------------------------------------------------*/
static PANEL *
mkpanel(int rows, int cols, int tly, int tlx)
{
WINDOW *win = newwin(rows,cols,tly,tlx);
PANEL *pan;
if(!win)
return((PANEL *)0);
if((pan = new_panel(win)))
return(pan);
delwin(win);
return((PANEL *)0);
} /* end of mkpanel */
/*+-------------------------------------------------------------------------
rmpanel(pan)
--------------------------------------------------------------------------*/
static void
rmpanel(PANEL *pan)
{
WINDOW *win = pan->win;
del_panel(pan);
delwin(win);
} /* end of rmpanel */
/*+-------------------------------------------------------------------------
pflush()
--------------------------------------------------------------------------*/
static void
pflush(void)
{
update_panels();
doupdate();
} /* end of pflush */
/*+-------------------------------------------------------------------------
fill_panel(win)
--------------------------------------------------------------------------*/
static void
fill_panel(PANEL *pan)
{
WINDOW *win = pan->win;
chtype num = *(pan->user + 1);
int y,x;
box(win, 0, 0);
wmove(win,1,1);
wprintw(win,"-pan%c-",num);
for(y = 2; y < getmaxy(win) - 1; y++)
{
for(x = 1; x < getmaxx(win) - 1; x++)
{
wmove(win,y,x);
waddch(win,num);
}
}
} /* end of fill_panel */
saywhat("m3; press any key to continue");
move_panel(p3,5,5);
pflush();
wait_a_while(nap_msec);
saywhat("b3; press any key to continue");
bottom_panel(p3);
pflush();
wait_a_while(nap_msec);
saywhat("s4; press any key to continue");
show_panel(p4);
pflush();
wait_a_while(nap_msec);
saywhat("s5; press any key to continue");
show_panel(p5);
pflush();
wait_a_while(nap_msec);
saywhat("t3; press any key to continue");
top_panel(p3);
pflush();
wait_a_while(nap_msec);
saywhat("t1; press any key to continue");
top_panel(p1);
pflush();
wait_a_while(nap_msec);
saywhat("t2; press any key to continue");
top_panel(p2);
pflush();
wait_a_while(nap_msec);
saywhat("t3; press any key to continue");
top_panel(p3);
pflush();
wait_a_while(nap_msec);
saywhat("t4; press any key to continue");
top_panel(p4);
pflush();
wait_a_while(nap_msec);
for(itmp = 0; itmp < 6; itmp++)
{
saywhat("m4; press any key to continue");
wmove(w4,3,1);
waddstr(w4,mod[itmp]);
move_panel(p4,4,itmp*10);
wmove(w5,4,1);
waddstr(w5,mod[itmp]);
pflush();
wait_a_while(nap_msec);
saywhat("m5; press any key to continue");
wmove(w4,4,1);
waddstr(w4,mod[itmp]);
move_panel(p5,7,(itmp*10) + 6);
wmove(w5,3,1);
waddstr(w5,mod[itmp]);
pflush();
wait_a_while(nap_msec);
}
saywhat("m4; press any key to continue");
move_panel(p4,4,itmp*10);
pflush();
wait_a_while(nap_msec);
saywhat("t5; press any key to continue");
top_panel(p5);
pflush();
wait_a_while(nap_msec);
saywhat("t2; press any key to continue");
top_panel(p2);
pflush();
wait_a_while(nap_msec);
saywhat("t1; press any key to continue");
top_panel(p1);
pflush();
wait_a_while(nap_msec);
saywhat("d2; press any key to continue");
rmpanel(p2);
pflush();
wait_a_while(nap_msec);
saywhat("h3; press any key to continue");
hide_panel(p3);
pflush();
wait_a_while(nap_msec);
saywhat("d1; press any key to continue");
rmpanel(p1);
pflush();
wait_a_while(nap_msec);
saywhat("d4; press any key to continue");
rmpanel(p4);
pflush();
wait_a_while(nap_msec);
saywhat("d5; press any key to continue");
rmpanel(p5);
pflush();
wait_a_while(nap_msec);
if(nap_msec == 1)
break;
nap_msec = 100L;
}
erase();
endwin();
}
/****************************************************************************
*
* Pad tester
*
****************************************************************************/
#define GRIDSIZE 3
static void panner(WINDOW *pad, int iy, int ix, int (*pgetc)(WINDOW *))
{
#if HAVE_GETTIMEOFDAY
struct timeval before, after;
#endif
static int porty, portx, basex = 0, basey = 0;
int pxmax, pymax, lowend, highend, i, j, c;
int top_x = 0, top_y = 0;
porty = iy; portx = ix;
getmaxyx(pad, pymax, pxmax);
c = KEY_REFRESH;
do {
switch(c)
{
case KEY_REFRESH:
/* do nothing */
break;
/* Move the top-left corner of the pad, keeping the bottom-right
* corner fixed.
*/
case 'h': /* increase-columns */
if (top_x <= 0)
beep();
else
{
if (top_x-- > 0)
for (i = top_y; i < porty; i++)
mvaddch(i, top_x, ' ');
}
break;
case 'j': /* decrease-lines */
if (top_y >= porty)
beep();
else
{
if (top_y > 0)
for (j = top_x - (top_x > 0); j < portx; j++)
mvaddch(top_y-1, j, ' ');
top_y++;
}
break;
case 'k': /* increase-lines */
if (top_y <= 0)
beep();
else
{
top_y--;
for (j = top_x; j < portx; j++)
mvaddch(top_y, j, ' ');
}
break;
case 'l': /* decrease-columns */
if (top_x >= portx)
beep();
else
{
if (top_x > 0)
for (i = top_y - (top_y > 0); i <= porty; i++)
mvaddch(i, top_x-1, ' ');
top_x++;
}
break;
/* Move the bottom-right corner of the pad, keeping the top-left
* corner fixed.
*/
case KEY_IC: /* increase-columns */
if (portx >= pxmax || portx >= ix)
beep();
else
{
for (i = top_y; i < porty; i++)
mvaddch(i, portx-1, ' ');
++portx;
}
break;
for (i = top_y; i < lowend; i++)
mvaddch(i, portx - 1, ACS_VLINE);
attron(A_REVERSE);
for (i = lowend; i <= highend; i++)
mvaddch(i, portx - 1, ' ');
attroff(A_REVERSE);
for (i = highend + 1; i < porty; i++)
mvaddch(i, portx - 1, ACS_VLINE);
}
switch(c = wgetch(win))
{
case 'U': return(KEY_UP);
case 'D': return(KEY_DOWN);
case 'R': return(KEY_RIGHT);
case 'L': return(KEY_LEFT);
case '+': return(KEY_IL);
case '-': return(KEY_DL);
case '>': return(KEY_IC);
case '<': return(KEY_DC);
case 'q': return(KEY_EXIT);
default: return(c);
}
}
static void demo_pad(void)
/* Demonstrate pads. */
{
int i, j;
unsigned gridcount = 0;
WINDOW *panpad = newpad(200, 200);
for (i = 0; i < 200; i++)
{
for (j = 0; j < 200; j++)
if (i % GRIDSIZE == 0 && j % GRIDSIZE == 0)
{
if (i == 0 || j == 0)
waddch(panpad, '+');
else
waddch(panpad, (chtype)('A' + (gridcount++ % 26)));
}
else if (i % GRIDSIZE == 0)
waddch(panpad, '-');
else if (j % GRIDSIZE == 0)
waddch(panpad, '|');
else
waddch(panpad, ' ');
}
mvprintw(LINES - 3, 0, "Use arrow keys (or U,D,L,R) to pan over the test pattern - 'q' to quit");
mvprintw(LINES - 2, 0, "Use +,- (or j,k) to grow/shrink the panner vertically.");
mvprintw(LINES - 1, 0, "Use <,> (or h,l) to grow/shrink the panner horizontally.");
w = win->_maxx;
h = win->_maxy;
bx = win->_begx;
by = win->_begy;
sw = w / 3;
sh = h / 3;
if((subWin = subwin(win, sh, sw, by + h - sh - 2, bx + w - sw - 2)) == NULL)
return;
nocbreak();
mvwaddstr(win, 1, 1, "Type random keys for 5 seconds.");
mvwaddstr(win, 2, 1,
"These should be discarded (not echoed) after the subwindow goes away.");
wrefresh(win);
for (i = 0; i < 5; i++)
{
mvwprintw (subWin, 1, 1, "Time = %d", i);
wrefresh(subWin);
sleep(1);
flushinp();
}
mvwaddstr(win, 2, 1, "Press a key");
wmove(win, 9, 10);
wrefresh(win);
echo();
wgetch(win);
flushinp();
mvwaddstr(win, 12, 0,
"If you see any key other than what you typed, flushinp() is broken.");
Continue(win);
wmove(win, 9, 10);
wdelch(win);
wrefresh(win);
wmove(win, 12, 0);
clrtoeol();
waddstr(win,
"What you typed should now have been deleted; if not, wdelch() failed.");
Continue(win);
#ifdef FOO
/*
* This test won't be portable until vsscanf() is
*/
mvwaddstr(win, 6, 2, "Enter a number then a string separated by space");
echo();
mvwscanw(win, 7, 6, "%d %s", &num,buffer);
mvwprintw(win, 8, 6, "String: %s Number: %d", buffer,num);
#endif /* FOO */
Continue(win);
}
/****************************************************************************
*
* Menu test
*
****************************************************************************/
#if HAVE_MENU_H
#define MENU_Y 4
#define MENU_X 4
static int menu_virtualize(int c)
{
if (c == '\n' || c == KEY_EXIT)
return(MAX_COMMAND + 1);
else if (c == 'n' || c == KEY_DOWN)
return(REQ_NEXT_ITEM);
else if (c == 'p' || c == KEY_UP)
return(REQ_PREV_ITEM);
else
return(c);
}
static int form_virtualize(WINDOW *w)
{
static int mode = REQ_INS_MODE;
int c = wgetch(w);
switch(c)
{
case CTRL('Q'):
return(MAX_FORM_COMMAND + 1);
/* demo doesn't use these three, leave them in anyway as sample code */
case KEY_NPAGE:
case CTRL('F'):
return(REQ_NEXT_PAGE);
case KEY_PPAGE:
return(REQ_PREV_PAGE);
case KEY_NEXT:
case CTRL('N'):
return(REQ_NEXT_FIELD);
case KEY_PREVIOUS:
case CTRL('P'):
return(REQ_PREV_FIELD);
case KEY_HOME:
return(REQ_FIRST_FIELD);
case KEY_END:
case KEY_LL:
return(REQ_LAST_FIELD);
case CTRL('L'):
return(REQ_LEFT_FIELD);
case CTRL('R'):
return(REQ_RIGHT_FIELD);
case CTRL('U'):
return(REQ_UP_FIELD);
case CTRL('D'):
return(REQ_DOWN_FIELD);
case CTRL('W'):
return(REQ_NEXT_WORD);
case CTRL('T'):
return(REQ_PREV_WORD);
case CTRL('S'):
return(REQ_BEG_FIELD);
case CTRL('E'):
return(REQ_END_FIELD);
case KEY_LEFT:
return(REQ_LEFT_CHAR);
case KEY_RIGHT:
return(REQ_RIGHT_CHAR);
case KEY_UP:
return(REQ_UP_CHAR);
case KEY_DOWN:
return(REQ_DOWN_CHAR);
case CTRL('M'):
return(REQ_NEW_LINE);
case CTRL('I'):
return(REQ_INS_CHAR);
case CTRL('O'):
return(REQ_INS_LINE);
case CTRL('V'):
return(REQ_DEL_CHAR);
case CTRL('H'):
case KEY_BACKSPACE:
return(REQ_DEL_PREV);
case CTRL('Y'):
return(REQ_DEL_LINE);
case CTRL('G'):
return(REQ_DEL_WORD);
case CTRL('C'):
return(REQ_CLR_EOL);
case CTRL('K'):
return(REQ_CLR_EOF);
case CTRL('X'):
return(REQ_CLR_FIELD);
case CTRL('A'):
return(REQ_NEXT_CHOICE);
case CTRL('Z'):
return(REQ_PREV_CHOICE);
case CTRL(']'):
if (mode == REQ_INS_MODE)
return(mode = REQ_OVL_MODE);
else
return(mode = REQ_INS_MODE);
default:
return(c);
}
}
static int my_form_driver(FORM *form, int c)
{
if (c == (MAX_FORM_COMMAND + 1)
&& form_driver(form, REQ_VALIDATION) == E_OK)
return(TRUE);
else
{
beep();
return(FALSE);
}
}
static void demo_forms(void)
{
WINDOW *w;
FORM *form;
FIELD *f[10];
int finished = 0, c;
mvaddstr(10, 57, "Forms Entry Test");
move(18, 0);
addstr("Defined form-traversal keys: ^Q -- exit form\n");
addstr("^N -- go to next field ^P -- go to previous field\n");
addstr("Home -- go to first field End -- go to last field\n");
addstr("^L -- go to field to left ^R -- go to field to right\n");
addstr("^U -- move upward to field ^D -- move downard to field\n");
addstr("^W -- go to next word ^T -- go to previous word\n");
addstr("^S -- go to start of field ^E -- go to end of field\n");
addstr("^H -- delete previous char ^Y -- delete line\n");
addstr("^G -- delete current word ^C -- clear to end of line\n");
addstr("^K -- clear to end of field ^X -- clear field\n");
addstr("Arrow keys move within a field as you would expect.");
refresh();
refresh();
move(0, 0);
printw("This test shows the behavior of wnoutrefresh() with respect to\n");
printw("the shared region of two overlapping windows. The cross pattern\n");
printw("in each wind does not overlap the other.\n");
move(18, 0);
printw("F1 = refresh window A, then window B, then doupdaute.\n");
printw("F2 = refresh window B, then window A, then doupdaute.\n");
printw("F3 = fill window A with letter A. F4 = fill window B with letter B.\n");
printw("F5 = cross pattern in window A. F6 = cross pattern in window B.\n");
printw("F7 = clear window A. F8 = clear window B.\n");
printw("F9 = terminate test.");
while ((ch = getch()) != CTRL('D') && ch != KEY_F(9))
switch (ch)
{
case KEY_F(1): /* refresh window A first, then B */
wnoutrefresh(win1);
wnoutrefresh(win2);
doupdate();
break;
case KEY_F(2): /* refresh window B first, then A */
wnoutrefresh(win2);
wnoutrefresh(win1);
doupdate();
break;
case KEY_F(3): /* fill window A so it's visible */
fillwin(win1, 'A');
break;
case KEY_F(4): /* fill window B so it's visible */
fillwin(win2, 'B');
break;
case KEY_F(5): /* cross test pattern in window A */
crosswin(win1, 'A');
break;
case KEY_F(6): /* cross test pattern in window A */
crosswin(win2, 'B');
break;
case KEY_F(7): /* clear window A */
wclear(win1);
wmove(win1, 0, 0);
break;
case KEY_F(8): /* clear window B */
wclear(win2);
wmove(win2, 0, 0);
break;
}
erase();
endwin();
}
/****************************************************************************
*
* Main sequence
*
****************************************************************************/
static bool
do_single_test(const char c)
/* perform a single specified test */
{
switch (c)
{
case 'a':
getch_test();
return(TRUE);
case 'b':
attr_test();
return(TRUE);
case 'c':
if (!has_colors())
Cannot("does not support color.");
else
color_test();
return(TRUE);
case 'd':
if (!has_colors())
Cannot("does not support color.");
else if (!can_change_color())
Cannot("has hardwired color values.");
else
color_edit();
return(TRUE);
case 'e':
slk_test();
return(TRUE);
case 'f':
acs_display();
return(TRUE);
#if HAVE_PANEL_H
case 'o':
demo_panels();
return(TRUE);
#endif
case 'g':
acs_and_scroll();
return(TRUE);
case 'i':
input_test(stdscr);
return(TRUE);
#if HAVE_MENU_H
case 'm':
menu_test();
return(TRUE);
#endif
#if HAVE_PANEL_H
case 'p':
demo_pad();
return(TRUE);
#endif
#if HAVE_FORM_H
case 'r':
demo_forms();
return(TRUE);
#endif
case 's':
overlap_test();
return(TRUE);
case '?':
(void) puts("This is the ncurses capability tester.");
(void) puts("You may select a test from the main menu by typing the");
(void) puts("key letter of the choice (the letter to left of the =)");
(void) puts("at the > prompt. The commands `x' or `q' will exit.");
return(TRUE);
}
return(FALSE);
}
int main(const int argc, const char *argv[])
{
char buf[BUFSIZ];