1999-08-24 01:06:48 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* This is a test program for the PDCurses screen package for IBM PC type
|
|
|
|
* machines.
|
|
|
|
*
|
|
|
|
* This program was written by John Burnell (johnb@kea.am.dsir.govt.nz)
|
|
|
|
* wrs(5/28/93) -- modified to be consistent (perform identically) with either
|
|
|
|
* PDCurses or under Unix System V, R4
|
|
|
|
*
|
2000-07-03 09:24:12 +00:00
|
|
|
* $Id: testcurs.c,v 1.22 2000/06/17 23:23:34 tom Exp $
|
1999-08-24 01:06:48 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <test.priv.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
#if defined(XCURSES)
|
|
|
|
char *XCursesProgramName = "testcurs";
|
|
|
|
#endif
|
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
static int initTest(WINDOW **);
|
|
|
|
static void display_menu(int, int);
|
|
|
|
static void inputTest(WINDOW *);
|
|
|
|
static void introTest(WINDOW *);
|
|
|
|
static void outputTest(WINDOW *);
|
|
|
|
static void padTest(WINDOW *);
|
|
|
|
static void scrollTest(WINDOW *);
|
|
|
|
#if defined(PDCURSES) && !defined(XCURSES)
|
|
|
|
static void resizeTest(WINDOW *);
|
1999-08-24 01:06:48 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
struct commands {
|
|
|
|
NCURSES_CONST char *text;
|
|
|
|
void (*function) (WINDOW *);
|
1999-08-24 01:06:48 +00:00
|
|
|
};
|
|
|
|
typedef struct commands COMMAND;
|
|
|
|
|
|
|
|
const COMMAND command[] =
|
|
|
|
{
|
2000-07-03 09:24:12 +00:00
|
|
|
{"Intro Test", introTest},
|
|
|
|
{"Pad Test", padTest},
|
|
|
|
#if defined(PDCURSES) && !defined(XCURSES)
|
|
|
|
{"Resize Test", resizeTest},
|
1999-08-24 01:06:48 +00:00
|
|
|
#endif
|
2000-07-03 09:24:12 +00:00
|
|
|
{"Scroll Test", scrollTest},
|
|
|
|
{"Input Test", inputTest},
|
|
|
|
{"Output Test", outputTest}
|
1999-08-24 01:06:48 +00:00
|
|
|
};
|
|
|
|
#define MAX_OPTIONS ((sizeof(command)/sizeof(command[0])))
|
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
int width, height;
|
1999-08-24 01:06:48 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
main(
|
2000-07-03 09:24:12 +00:00
|
|
|
int argc GCC_UNUSED,
|
|
|
|
char *argv[]GCC_UNUSED)
|
1999-08-24 01:06:48 +00:00
|
|
|
{
|
2000-07-03 09:24:12 +00:00
|
|
|
WINDOW *win;
|
|
|
|
int key, old_option = (-1), new_option = 0;
|
|
|
|
bool quit = FALSE;
|
1999-08-24 01:06:48 +00:00
|
|
|
|
|
|
|
#ifdef PDCDEBUG
|
2000-07-03 09:24:12 +00:00
|
|
|
PDC_debug("testcurs started\n");
|
1999-08-24 01:06:48 +00:00
|
|
|
#endif
|
2000-07-03 09:24:12 +00:00
|
|
|
if (!initTest(&win))
|
|
|
|
return EXIT_FAILURE;
|
1999-08-24 01:06:48 +00:00
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
erase();
|
|
|
|
display_menu(old_option, new_option);
|
|
|
|
while (1) {
|
1999-08-24 01:06:48 +00:00
|
|
|
#ifdef A_COLOR
|
2000-07-03 09:24:12 +00:00
|
|
|
if (has_colors()) {
|
|
|
|
init_pair(1, COLOR_WHITE, COLOR_BLUE);
|
|
|
|
wbkgd(win, COLOR_PAIR(1));
|
|
|
|
} else
|
|
|
|
wbkgd(win, A_REVERSE);
|
1999-08-24 01:06:48 +00:00
|
|
|
#else
|
2000-07-03 09:24:12 +00:00
|
|
|
wbkgd(win, A_REVERSE);
|
1999-08-24 01:06:48 +00:00
|
|
|
#endif
|
2000-07-03 09:24:12 +00:00
|
|
|
werase(win);
|
|
|
|
|
|
|
|
noecho();
|
|
|
|
keypad(stdscr, TRUE);
|
|
|
|
raw();
|
|
|
|
key = getch();
|
|
|
|
switch (key) {
|
|
|
|
case 10:
|
|
|
|
case 13:
|
|
|
|
case KEY_ENTER:
|
|
|
|
erase();
|
|
|
|
refresh();
|
|
|
|
(*command[new_option].function) (win);
|
|
|
|
erase();
|
|
|
|
display_menu(old_option, new_option);
|
|
|
|
break;
|
|
|
|
case KEY_UP:
|
|
|
|
new_option = (new_option == 0) ? new_option : new_option - 1;
|
|
|
|
display_menu(old_option, new_option);
|
|
|
|
break;
|
|
|
|
case KEY_DOWN:
|
|
|
|
new_option = (new_option == MAX_OPTIONS - 1) ? new_option :
|
|
|
|
new_option + 1;
|
|
|
|
display_menu(old_option, new_option);
|
|
|
|
break;
|
|
|
|
case 'Q':
|
|
|
|
case 'q':
|
|
|
|
quit = TRUE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (quit == TRUE)
|
|
|
|
break;
|
|
|
|
}
|
1999-08-24 01:06:48 +00:00
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
delwin(win);
|
1999-08-24 01:06:48 +00:00
|
|
|
|
|
|
|
endwin();
|
|
|
|
#ifdef XCURSES
|
|
|
|
XCursesExit();
|
|
|
|
#endif
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
static void
|
|
|
|
Continue(WINDOW *win)
|
1999-08-24 01:06:48 +00:00
|
|
|
{
|
2000-07-03 09:24:12 +00:00
|
|
|
int y1 = getmaxy(win);
|
|
|
|
int x1 = getmaxx(win);
|
|
|
|
int y0 = y1 < 10 ? y1 : 10;
|
|
|
|
int x0 = 1;
|
|
|
|
long save;
|
|
|
|
|
|
|
|
save = mvwinch(win, y0, x1 - 1);
|
|
|
|
|
|
|
|
mvwaddstr(win, y0, x0, " Press any key to continue");
|
1999-08-24 01:06:48 +00:00
|
|
|
wclrtoeol(win);
|
2000-07-03 09:24:12 +00:00
|
|
|
getyx(win, y0, x0);
|
|
|
|
|
|
|
|
mvwaddch(win, y0, x1 - 1, save);
|
|
|
|
|
|
|
|
wmove(win, y0, x0);
|
1999-08-24 01:06:48 +00:00
|
|
|
raw();
|
|
|
|
wgetch(win);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-07-03 09:24:12 +00:00
|
|
|
initTest(WINDOW **win)
|
1999-08-24 01:06:48 +00:00
|
|
|
{
|
|
|
|
#ifdef PDCDEBUG
|
|
|
|
PDC_debug("initTest called\n");
|
|
|
|
#endif
|
2000-07-03 09:24:12 +00:00
|
|
|
#ifdef TRACE
|
1999-08-24 01:06:48 +00:00
|
|
|
trace(TRACE_MAXIMUM);
|
|
|
|
#endif
|
|
|
|
initscr();
|
|
|
|
#ifdef PDCDEBUG
|
|
|
|
PDC_debug("after initscr()\n");
|
|
|
|
#endif
|
|
|
|
#ifdef A_COLOR
|
|
|
|
if (has_colors())
|
2000-07-03 09:24:12 +00:00
|
|
|
start_color();
|
1999-08-24 01:06:48 +00:00
|
|
|
#endif
|
2000-07-03 09:24:12 +00:00
|
|
|
width = 60;
|
|
|
|
height = 13; /* Create a drawing window */
|
|
|
|
*win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2);
|
|
|
|
if (*win == NULL) {
|
|
|
|
endwin();
|
|
|
|
return 0;
|
1999-08-24 01:06:48 +00:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-07-03 09:24:12 +00:00
|
|
|
introTest(WINDOW *win)
|
1999-08-24 01:06:48 +00:00
|
|
|
{
|
2000-07-03 09:24:12 +00:00
|
|
|
wmove(win, height / 2 - 5, width / 2);
|
|
|
|
wvline(win, ACS_VLINE, 10);
|
|
|
|
wmove(win, height / 2, width / 2 - 10);
|
|
|
|
whline(win, ACS_HLINE, 20);
|
1999-08-24 01:06:48 +00:00
|
|
|
Continue(win);
|
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
beep();
|
1999-08-24 01:06:48 +00:00
|
|
|
werase(win);
|
|
|
|
|
|
|
|
box(win, ACS_VLINE, ACS_HLINE);
|
|
|
|
wrefresh(win);
|
2000-07-03 09:24:12 +00:00
|
|
|
cbreak();
|
|
|
|
mvwaddstr(win, 1, 1,
|
|
|
|
"You should have rectangle in the middle of the screen");
|
1999-08-24 01:06:48 +00:00
|
|
|
mvwaddstr(win, 2, 1, "You should have heard a beep");
|
|
|
|
Continue(win);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-07-03 09:24:12 +00:00
|
|
|
scrollTest(WINDOW *win)
|
1999-08-24 01:06:48 +00:00
|
|
|
{
|
|
|
|
int i;
|
2000-07-03 09:24:12 +00:00
|
|
|
int half;
|
1999-08-24 01:06:48 +00:00
|
|
|
int OldX, OldY;
|
|
|
|
NCURSES_CONST char *Message = "The window will now scroll slowly";
|
|
|
|
|
|
|
|
wclear(win);
|
2000-07-03 09:24:12 +00:00
|
|
|
getmaxyx(win, OldY, OldX);
|
|
|
|
half = OldY / 2;
|
|
|
|
mvwprintw(win, OldY - 2, 1, Message);
|
|
|
|
wrefresh(win);
|
1999-08-24 01:06:48 +00:00
|
|
|
scrollok(win, TRUE);
|
2000-07-03 09:24:12 +00:00
|
|
|
for (i = 1; i <= OldY; i++) {
|
|
|
|
napms(600);
|
|
|
|
scroll(win);
|
|
|
|
wrefresh(win);
|
1999-08-24 01:06:48 +00:00
|
|
|
}
|
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
werase(win);
|
|
|
|
for (i = 1; i < OldY; i++) {
|
|
|
|
mvwprintw(win, i, 1, "Line %d", i);
|
|
|
|
}
|
|
|
|
mvwprintw(win, OldY - 2, 1, "The top of the window will scroll");
|
|
|
|
wmove(win, 1, 1);
|
|
|
|
wsetscrreg(win, 0, half - 1);
|
1999-08-24 01:06:48 +00:00
|
|
|
box(win, ACS_VLINE, ACS_HLINE);
|
2000-07-03 09:24:12 +00:00
|
|
|
wrefresh(win);
|
|
|
|
for (i = 1; i <= half; i++) {
|
|
|
|
napms(600);
|
|
|
|
scroll(win);
|
|
|
|
box(win, ACS_VLINE, ACS_HLINE);
|
|
|
|
wrefresh(win);
|
1999-08-24 01:06:48 +00:00
|
|
|
}
|
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
werase(win);
|
|
|
|
for (i = 1; i < OldY; i++) {
|
|
|
|
mvwprintw(win, i, 1, "Line %d", i);
|
|
|
|
}
|
|
|
|
mvwprintw(win, 1, 1, "The bottom of the window will scroll");
|
|
|
|
wmove(win, OldY - 2, 1);
|
|
|
|
wsetscrreg(win, half, --OldY);
|
1999-08-24 01:06:48 +00:00
|
|
|
box(win, ACS_VLINE, ACS_HLINE);
|
2000-07-03 09:24:12 +00:00
|
|
|
wrefresh(win);
|
|
|
|
for (i = half; i <= OldY; i++) {
|
|
|
|
napms(600);
|
|
|
|
wscrl(win, -1);
|
|
|
|
box(win, ACS_VLINE, ACS_HLINE);
|
|
|
|
wrefresh(win);
|
1999-08-24 01:06:48 +00:00
|
|
|
}
|
2000-07-03 09:24:12 +00:00
|
|
|
wsetscrreg(win, 0, OldY);
|
1999-08-24 01:06:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-07-03 09:24:12 +00:00
|
|
|
inputTest(WINDOW *win)
|
1999-08-24 01:06:48 +00:00
|
|
|
{
|
2000-07-03 09:24:12 +00:00
|
|
|
int w, h, bx, by, sw, sh, i, c, num;
|
|
|
|
char buffer[80];
|
1999-08-24 01:06:48 +00:00
|
|
|
WINDOW *subWin;
|
2000-07-03 09:24:12 +00:00
|
|
|
wclear(win);
|
1999-08-24 01:06:48 +00:00
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
getmaxyx(win, h, w);
|
1999-08-24 01:06:48 +00:00
|
|
|
getbegyx(win, by, bx);
|
|
|
|
sw = w / 3;
|
|
|
|
sh = h / 3;
|
2000-07-03 09:24:12 +00:00
|
|
|
if ((subWin = subwin(win, sh, sw, by + h - sh - 2, bx + w - sw - 2)) == NULL)
|
|
|
|
return;
|
1999-08-24 01:06:48 +00:00
|
|
|
|
|
|
|
#ifdef A_COLOR
|
2000-07-03 09:24:12 +00:00
|
|
|
if (has_colors()) {
|
|
|
|
init_pair(2, COLOR_WHITE, COLOR_RED);
|
|
|
|
wbkgd(subWin, COLOR_PAIR(2) | A_BOLD);
|
|
|
|
} else
|
|
|
|
wbkgd(subWin, A_BOLD);
|
1999-08-24 01:06:48 +00:00
|
|
|
#else
|
|
|
|
wbkgd(subWin, A_BOLD);
|
|
|
|
#endif
|
|
|
|
box(subWin, ACS_VLINE, ACS_HLINE);
|
|
|
|
wrefresh(win);
|
|
|
|
|
|
|
|
nocbreak();
|
|
|
|
mvwaddstr(win, 2, 1, "Press some keys for 5 seconds");
|
|
|
|
mvwaddstr(win, 1, 1, "Pressing ^C should do nothing");
|
|
|
|
wrefresh(win);
|
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
werase(subWin);
|
1999-08-24 01:06:48 +00:00
|
|
|
box(subWin, ACS_VLINE, ACS_HLINE);
|
|
|
|
for (i = 0; i < 5; i++) {
|
2000-07-03 09:24:12 +00:00
|
|
|
mvwprintw(subWin, 1, 1, "Time = %d", i);
|
|
|
|
wrefresh(subWin);
|
|
|
|
napms(1000);
|
|
|
|
flushinp();
|
1999-08-24 01:06:48 +00:00
|
|
|
}
|
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
delwin(subWin);
|
1999-08-24 01:06:48 +00:00
|
|
|
werase(win);
|
|
|
|
flash();
|
|
|
|
wrefresh(win);
|
|
|
|
napms(500);
|
|
|
|
|
|
|
|
mvwaddstr(win, 2, 1, "Press a key, followed by ENTER");
|
|
|
|
wmove(win, 9, 10);
|
|
|
|
wrefresh(win);
|
|
|
|
echo();
|
|
|
|
noraw();
|
|
|
|
wgetch(win);
|
|
|
|
flushinp();
|
|
|
|
|
|
|
|
wmove(win, 9, 10);
|
|
|
|
wdelch(win);
|
|
|
|
mvwaddstr(win, 4, 1, "The character should now have been deleted");
|
|
|
|
Continue(win);
|
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
wclear(win);
|
1999-08-24 01:06:48 +00:00
|
|
|
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();
|
|
|
|
typeahead(-1);
|
|
|
|
#if defined(PDCURSES)
|
|
|
|
mouse_set(ALL_MOUSE_EVENTS);
|
|
|
|
#endif
|
2000-07-03 09:24:12 +00:00
|
|
|
while (1) {
|
|
|
|
wmove(win, 3, 5);
|
|
|
|
c = wgetch(win);
|
|
|
|
wclrtobot(win);
|
|
|
|
if (c >= KEY_MIN)
|
|
|
|
wprintw(win, "Key Pressed: %s", keyname(c));
|
|
|
|
else if (isprint(c))
|
|
|
|
wprintw(win, "Key Pressed: %c", c);
|
|
|
|
else
|
|
|
|
wprintw(win, "Key Pressed: %s", unctrl(c));
|
1999-08-24 01:06:48 +00:00
|
|
|
#if defined(PDCURSES)
|
2000-07-03 09:24:12 +00:00
|
|
|
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;
|
|
|
|
else
|
|
|
|
button = 0;
|
|
|
|
wmove(win, 4, 18);
|
|
|
|
wprintw(win, "Button %d: ", button);
|
|
|
|
if (MOUSE_MOVED)
|
|
|
|
wprintw(win, "moved: ");
|
|
|
|
else if ((BUTTON_STATUS(button) & BUTTON_ACTION_MASK) == BUTTON_PRESSED)
|
|
|
|
wprintw(win, "pressed: ");
|
|
|
|
else if ((BUTTON_STATUS(button) & BUTTON_ACTION_MASK) == BUTTON_DOUBLE_CLICKED)
|
|
|
|
wprintw(win, "double: ");
|
|
|
|
else
|
|
|
|
wprintw(win, "released: ");
|
|
|
|
wprintw(win, " Position: Y: %d X: %d", MOUSE_Y_POS, MOUSE_X_POS);
|
|
|
|
}
|
1999-08-24 01:06:48 +00:00
|
|
|
#endif
|
2000-07-03 09:24:12 +00:00
|
|
|
wrefresh(win);
|
|
|
|
if (c == ' ')
|
|
|
|
break;
|
1999-08-24 01:06:48 +00:00
|
|
|
}
|
|
|
|
#if 0
|
|
|
|
nodelay(win, TRUE);
|
|
|
|
wgetch(win);
|
|
|
|
nodelay(win, FALSE);
|
|
|
|
#endif
|
|
|
|
#if defined(PDCURSES)
|
|
|
|
mouse_set(0L);
|
|
|
|
#endif
|
|
|
|
refresh();
|
2000-07-03 09:24:12 +00:00
|
|
|
wclear(win);
|
1999-08-24 01:06:48 +00:00
|
|
|
mvwaddstr(win, 3, 2, "The window should have moved");
|
2000-07-03 09:24:12 +00:00
|
|
|
mvwaddstr(win, 4, 2,
|
|
|
|
"This text should have appeared without you pressing a key");
|
1999-08-24 01:06:48 +00:00
|
|
|
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;
|
2000-07-03 09:24:12 +00:00
|
|
|
mvwscanw(win, 7, 6, "%d %s", &num, buffer);
|
|
|
|
mvwprintw(win, 8, 6, "String: %s Number: %d", buffer, num);
|
1999-08-24 01:06:48 +00:00
|
|
|
Continue(win);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-07-03 09:24:12 +00:00
|
|
|
outputTest(WINDOW *win)
|
1999-08-24 01:06:48 +00:00
|
|
|
{
|
|
|
|
WINDOW *win1;
|
2000-07-03 09:24:12 +00:00
|
|
|
char Buffer[80];
|
1999-08-24 01:06:48 +00:00
|
|
|
chtype ch;
|
|
|
|
int by, bx;
|
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
nl();
|
|
|
|
wclear(win);
|
|
|
|
mvwaddstr(win, 1, 1,
|
|
|
|
"You should now have a screen in the upper left corner, and this text should have wrapped");
|
1999-08-24 01:06:48 +00:00
|
|
|
mvwin(win, 2, 1);
|
2000-07-03 09:24:12 +00:00
|
|
|
waddstr(win, "\nThis text should be down\n");
|
|
|
|
waddstr(win, "and broken into two here ^");
|
1999-08-24 01:06:48 +00:00
|
|
|
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) {
|
2000-07-03 09:24:12 +00:00
|
|
|
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);
|
1999-08-24 01:06:48 +00:00
|
|
|
} else {
|
2000-07-03 09:24:12 +00:00
|
|
|
win1 = newwin(10, 50, 14, 25);
|
|
|
|
if (win1 == NULL) {
|
|
|
|
endwin();
|
|
|
|
return;
|
|
|
|
}
|
1999-08-24 01:06:48 +00:00
|
|
|
#ifdef A_COLOR
|
2000-07-03 09:24:12 +00:00
|
|
|
if (has_colors()) {
|
|
|
|
init_pair(3, COLOR_BLUE, COLOR_WHITE);
|
|
|
|
wbkgd(win1, COLOR_PAIR(3));
|
|
|
|
} else
|
|
|
|
wbkgd(win1, A_NORMAL);
|
1999-08-24 01:06:48 +00:00
|
|
|
#else
|
2000-07-03 09:24:12 +00:00
|
|
|
wbkgd(win1, A_NORMAL);
|
1999-08-24 01:06:48 +00:00
|
|
|
#endif
|
2000-07-03 09:24:12 +00:00
|
|
|
wclear(win1);
|
|
|
|
mvwaddstr(win1, 5, 1,
|
|
|
|
"This text should appear; using overlay option");
|
|
|
|
copywin(win, win1, 0, 0, 0, 0, 9, 49, TRUE);
|
1999-08-24 01:06:48 +00:00
|
|
|
|
|
|
|
#if defined(PDCURSES) && !defined(XCURSES)
|
2000-07-03 09:24:12 +00:00
|
|
|
box(win1, 0xb3, 0xc4);
|
1999-08-24 01:06:48 +00:00
|
|
|
#else
|
2000-07-03 09:24:12 +00:00
|
|
|
box(win1, ACS_VLINE, ACS_HLINE);
|
1999-08-24 01:06:48 +00:00
|
|
|
#endif
|
2000-07-03 09:24:12 +00:00
|
|
|
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);
|
1999-08-24 01:06:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2000-07-03 09:24:12 +00:00
|
|
|
wclrtobot(win);
|
1999-08-24 01:06:48 +00:00
|
|
|
wmove(win, 5, 20);
|
2000-07-03 09:24:12 +00:00
|
|
|
wclrtoeol(win);
|
1999-08-24 01:06:48 +00:00
|
|
|
mvwaddstr(win, 8, 2, "This line also shouldn't appear");
|
|
|
|
wmove(win, 8, 1);
|
|
|
|
wdeleteln(win);
|
|
|
|
Continue(win);
|
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
wmove(win, 5, 9);
|
|
|
|
ch = winch(win);
|
1999-08-24 01:06:48 +00:00
|
|
|
|
|
|
|
wclear(win);
|
2000-07-03 09:24:12 +00:00
|
|
|
wmove(win, 6, 2);
|
|
|
|
waddstr(win, "The next char should be l: ");
|
|
|
|
winsch(win, ch);
|
1999-08-24 01:06:48 +00:00
|
|
|
Continue(win);
|
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
mvwinsstr(win, 6, 2, "A1B2C3D4E5");
|
1999-08-24 01:06:48 +00:00
|
|
|
Continue(win);
|
|
|
|
|
|
|
|
wmove(win, 5, 1);
|
2000-07-03 09:24:12 +00:00
|
|
|
winsertln(win);
|
1999-08-24 01:06:48 +00:00
|
|
|
mvwaddstr(win, 5, 2, "The lines below should have moved down");
|
|
|
|
Continue(win);
|
|
|
|
|
|
|
|
wclear(win);
|
|
|
|
wmove(win, 2, 2);
|
2000-07-03 09:24:12 +00:00
|
|
|
wprintw(win, "This is a formatted string in a window: %d %s\n", 42,
|
|
|
|
"is it");
|
1999-08-24 01:06:48 +00:00
|
|
|
mvwaddstr(win, 10, 1, "Enter a string: ");
|
|
|
|
wrefresh(win);
|
|
|
|
noraw();
|
|
|
|
echo();
|
|
|
|
*Buffer = 0;
|
2000-07-03 09:24:12 +00:00
|
|
|
wscanw(win, "%s", Buffer);
|
1999-08-24 01:06:48 +00:00
|
|
|
|
|
|
|
printw("This is a formatted string in stdscr: %d %s\n", 42, "is it");
|
|
|
|
mvaddstr(10, 1, "Enter a string: ");
|
|
|
|
*Buffer = 0;
|
2000-07-03 09:24:12 +00:00
|
|
|
scanw("%s", Buffer);
|
1999-08-24 01:06:48 +00:00
|
|
|
|
|
|
|
if (tigetstr("cvvis") != 0) {
|
2000-07-03 09:24:12 +00:00
|
|
|
wclear(win);
|
|
|
|
curs_set(2);
|
|
|
|
mvwaddstr(win, 1, 1, "The cursor should appear as a block (visible)");
|
|
|
|
Continue(win);
|
1999-08-24 01:06:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (tigetstr("civis") != 0) {
|
2000-07-03 09:24:12 +00:00
|
|
|
wclear(win);
|
|
|
|
curs_set(0);
|
|
|
|
mvwaddstr(win, 1, 1,
|
|
|
|
"The cursor should have disappeared (invisible)");
|
|
|
|
Continue(win);
|
1999-08-24 01:06:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (tigetstr("cnorm") != 0) {
|
2000-07-03 09:24:12 +00:00
|
|
|
wclear(win);
|
|
|
|
curs_set(1);
|
|
|
|
mvwaddstr(win, 1, 1, "The cursor should be an underline (normal)");
|
|
|
|
Continue(win);
|
1999-08-24 01:06:48 +00:00
|
|
|
}
|
|
|
|
#ifdef A_COLOR
|
2000-07-03 09:24:12 +00:00
|
|
|
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);
|
1999-08-24 01:06:48 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
werase(win);
|
|
|
|
mvwaddstr(win, 1, 1, "Information About Your Terminal");
|
|
|
|
mvwaddstr(win, 3, 1, termname());
|
|
|
|
mvwaddstr(win, 4, 1, longname());
|
2000-07-03 09:24:12 +00:00
|
|
|
if (termattrs() & A_BLINK)
|
|
|
|
mvwaddstr(win, 5, 1, "This terminal supports blinking.");
|
1999-08-24 01:06:48 +00:00
|
|
|
else
|
2000-07-03 09:24:12 +00:00
|
|
|
mvwaddstr(win, 5, 1, "This terminal does NOT support blinking.");
|
1999-08-24 01:06:48 +00:00
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
mvwaddnstr(win, 7, 5, "Have a nice day!ok", 16);
|
1999-08-24 01:06:48 +00:00
|
|
|
wrefresh(win);
|
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
mvwinnstr(win, 7, 5, Buffer, 18);
|
|
|
|
mvaddstr(LINES - 2, 10, Buffer);
|
1999-08-24 01:06:48 +00:00
|
|
|
refresh();
|
|
|
|
Continue(win);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(PDCURSES) && !defined(XCURSES)
|
|
|
|
static void
|
|
|
|
resizeTest(WINDOW *dummy GCC_UNUSED)
|
|
|
|
{
|
|
|
|
WINDOW *win1;
|
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
savetty();
|
1999-08-24 01:06:48 +00:00
|
|
|
|
|
|
|
clear();
|
|
|
|
refresh();
|
|
|
|
# if defined(OS2)
|
2000-07-03 09:24:12 +00:00
|
|
|
resize_term(50, 120);
|
1999-08-24 01:06:48 +00:00
|
|
|
# else
|
2000-07-03 09:24:12 +00:00
|
|
|
resize_term(50, 80);
|
1999-08-24 01:06:48 +00:00
|
|
|
# endif
|
|
|
|
|
|
|
|
win1 = newwin(10, 50, 14, 25);
|
2000-07-03 09:24:12 +00:00
|
|
|
if (win1 == NULL) {
|
|
|
|
endwin();
|
|
|
|
return;
|
1999-08-24 01:06:48 +00:00
|
|
|
}
|
|
|
|
#ifdef A_COLOR
|
2000-07-03 09:24:12 +00:00
|
|
|
if (has_colors()) {
|
|
|
|
init_pair(3, COLOR_BLUE, COLOR_WHITE);
|
|
|
|
wattrset(win1, COLOR_PAIR(3));
|
|
|
|
}
|
1999-08-24 01:06:48 +00:00
|
|
|
#endif
|
2000-07-03 09:24:12 +00:00
|
|
|
wclear(win1);
|
1999-08-24 01:06:48 +00:00
|
|
|
|
|
|
|
mvwaddstr(win1, 1, 1, "The screen may now have 50 lines");
|
|
|
|
Continue(win1);
|
|
|
|
|
2000-07-03 09:24:12 +00:00
|
|
|
wclear(win1);
|
|
|
|
resetty();
|
1999-08-24 01:06:48 +00:00
|
|
|
|
|
|
|
mvwaddstr(win1, 1, 1, "The screen should now be reset");
|
|
|
|
Continue(win1);
|
|
|
|
|
|
|
|
delwin(win1);
|
|
|
|
|
|
|
|
clear();
|
|
|
|
refresh();
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void
|
|
|
|
padTest(WINDOW *dummy GCC_UNUSED)
|
|
|
|
{
|
2000-07-03 09:24:12 +00:00
|
|
|
WINDOW *pad, *spad;
|
|
|
|
|
|
|
|
pad = newpad(50, 100);
|
|
|
|
wattron(pad, A_REVERSE);
|
|
|
|
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");
|
|
|
|
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, 6, 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);
|
1999-08-24 01:06:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-07-03 09:24:12 +00:00
|
|
|
display_menu(int old_option, int new_option)
|
1999-08-24 01:06:48 +00:00
|
|
|
{
|
2000-07-03 09:24:12 +00:00
|
|
|
register size_t i;
|
|
|
|
|
|
|
|
attrset(A_NORMAL);
|
|
|
|
mvaddstr(3, 20, "PDCurses Test Program");
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_OPTIONS; i++)
|
|
|
|
mvaddstr(5 + i, 25, command[i].text);
|
|
|
|
if (old_option != (-1))
|
|
|
|
mvaddstr(5 + old_option, 25, command[old_option].text);
|
|
|
|
attrset(A_REVERSE);
|
|
|
|
mvaddstr(5 + new_option, 25, command[new_option].text);
|
|
|
|
attrset(A_NORMAL);
|
|
|
|
mvaddstr(13, 3,
|
|
|
|
"Use Up and Down Arrows to select - Enter to run - Q to quit");
|
|
|
|
refresh();
|
1999-08-24 01:06:48 +00:00
|
|
|
}
|