aboutsummaryrefslogtreecommitdiff
path: root/contrib/ncurses/test/testcurs.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ncurses/test/testcurs.c')
-rw-r--r--contrib/ncurses/test/testcurs.c683
1 files changed, 350 insertions, 333 deletions
diff --git a/contrib/ncurses/test/testcurs.c b/contrib/ncurses/test/testcurs.c
index ff776570e2e8..5fa054a943a5 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.19 1999/02/14 00:42:28 tom Exp $
+ * $Id: testcurs.c,v 1.22 2000/06/17 23:23:34 tom Exp $
*/
#include <test.priv.h>
@@ -17,103 +17,102 @@
char *XCursesProgramName = "testcurs";
#endif
-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 *);
+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 *);
#endif
-struct commands
-{
- NCURSES_CONST char *text;
- void (*function)(WINDOW *);
+struct commands {
+ NCURSES_CONST char *text;
+ void (*function) (WINDOW *);
};
typedef struct commands COMMAND;
const COMMAND command[] =
{
- {"Intro Test", introTest},
- {"Pad Test", padTest},
-# if defined(PDCURSES) && !defined(XCURSES)
- {"Resize Test", resizeTest},
+ {"Intro Test", introTest},
+ {"Pad Test", padTest},
+#if defined(PDCURSES) && !defined(XCURSES)
+ {"Resize Test", resizeTest},
#endif
- {"Scroll Test", scrollTest},
- {"Input Test", inputTest},
- {"Output Test", outputTest}
+ {"Scroll Test", scrollTest},
+ {"Input Test", inputTest},
+ {"Output Test", outputTest}
};
#define MAX_OPTIONS ((sizeof(command)/sizeof(command[0])))
-int width, height;
+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;
-bool quit=FALSE;
+ WINDOW *win;
+ int key, old_option = (-1), new_option = 0;
+ bool quit = FALSE;
#ifdef PDCDEBUG
- PDC_debug("testcurs started\n");
+ PDC_debug("testcurs started\n");
#endif
- if (!initTest (&win)) return EXIT_FAILURE;
+ if (!initTest(&win))
+ return EXIT_FAILURE;
+ erase();
+ display_menu(old_option, new_option);
+ while (1) {
#ifdef A_COLOR
- if (has_colors())
- {
- init_pair(1,COLOR_WHITE,COLOR_BLUE);
- wbkgd(win, COLOR_PAIR(1));
- }
- else
- wbkgd(win, A_REVERSE);
+ if (has_colors()) {
+ init_pair(1, COLOR_WHITE, COLOR_BLUE);
+ wbkgd(win, COLOR_PAIR(1));
+ } else
+ wbkgd(win, A_REVERSE);
#else
- wbkgd(win, A_REVERSE);
+ wbkgd(win, A_REVERSE);
#endif
+ 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;
+ }
- erase();
- display_menu(old_option,new_option);
- while(1)
- {
- noecho();
- keypad(stdscr,TRUE);
- raw();
- key = getch();
- switch(key)
- {
- case 10:
- case 13:
- case KEY_ENTER:
- erase();
- refresh();
- (*command[new_option].function)(win);
- erase();
- display_menu(old_option,new_option);
- break;
- case KEY_UP:
- new_option = (new_option == 0) ? new_option : new_option-1;
- display_menu(old_option,new_option);
- break;
- case KEY_DOWN:
- new_option = (new_option == MAX_OPTIONS-1) ? new_option : new_option+1;
- display_menu(old_option,new_option);
- break;
- case 'Q':
- case 'q':
- quit = TRUE;
- break;
- default: break;
- }
- if (quit == TRUE)
- break;
- }
-
- delwin (win);
+ delwin(win);
endwin();
#ifdef XCURSES
@@ -122,24 +121,35 @@ bool quit=FALSE;
return EXIT_SUCCESS;
}
-static
-void Continue (WINDOW *win)
+static void
+Continue(WINDOW *win)
{
- wmove(win, 10, 1);
+ 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");
wclrtoeol(win);
- mvwaddstr(win, 10, 1, " Press any key to continue");
- wrefresh(win);
+ getyx(win, y0, x0);
+
+ mvwaddch(win, y0, x1 - 1, save);
+
+ wmove(win, y0, x0);
raw();
wgetch(win);
}
static int
-initTest (WINDOW **win)
+initTest(WINDOW **win)
{
#ifdef PDCDEBUG
PDC_debug("initTest called\n");
#endif
-#ifdef NCURSES_VERSION
+#ifdef TRACE
trace(TRACE_MAXIMUM);
#endif
initscr();
@@ -148,106 +158,115 @@ initTest (WINDOW **win)
#endif
#ifdef A_COLOR
if (has_colors())
- start_color();
+ start_color();
#endif
- width = 60;
- height = 13; /* Create a drawing window */
- *win = newwin(height, width, (LINES-height)/2, (COLS-width)/2);
- if(*win == NULL)
- {
- endwin();
- return 0;
+ width = 60;
+ height = 13; /* Create a drawing window */
+ *win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2);
+ if (*win == NULL) {
+ endwin();
+ return 0;
}
return 1;
}
static void
-introTest (WINDOW *win)
+introTest(WINDOW *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 );
+ 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 ();
+ beep();
werase(win);
box(win, ACS_VLINE, ACS_HLINE);
wrefresh(win);
- cbreak ();
- mvwaddstr(win, 1, 1, "You should have rectangle in the middle of the screen");
+ cbreak();
+ mvwaddstr(win, 1, 1,
+ "You should have rectangle in the middle of the screen");
mvwaddstr(win, 2, 1, "You should have heard a beep");
Continue(win);
return;
}
static void
-scrollTest (WINDOW *win)
+scrollTest(WINDOW *win)
{
int i;
+ int half;
int OldX, OldY;
NCURSES_CONST char *Message = "The window will now scroll slowly";
wclear(win);
- mvwprintw (win, height - 2, 1, Message);
- wrefresh (win);
+ getmaxyx(win, OldY, OldX);
+ half = OldY / 2;
+ mvwprintw(win, OldY - 2, 1, Message);
+ wrefresh(win);
scrollok(win, TRUE);
- for (i = 1; i <= height; i++) {
- napms(250);
- scroll(win);
- wrefresh (win);
+ for (i = 1; i <= OldY; i++) {
+ napms(600);
+ scroll(win);
+ wrefresh(win);
}
- getmaxyx (win, OldY, OldX);
- mvwprintw (win, 6, 1, "The top of the window will scroll");
- wmove (win, 1, 1);
- wsetscrreg (win, 0, 4);
+ 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);
box(win, ACS_VLINE, ACS_HLINE);
- wrefresh (win);
- for (i = 1; i <= 5; i++) {
- napms(500);
- scroll(win);
- wrefresh (win);
+ wrefresh(win);
+ for (i = 1; i <= half; i++) {
+ napms(600);
+ scroll(win);
+ box(win, ACS_VLINE, ACS_HLINE);
+ wrefresh(win);
}
- mvwprintw (win, 3, 1, "The bottom of the window will scroll");
- wmove (win, 8, 1);
- wsetscrreg (win, 5, --OldY);
+ 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);
box(win, ACS_VLINE, ACS_HLINE);
- wrefresh (win);
- for (i = 5; i <= OldY; i++) {
- napms (300);
- wscrl(win,-1);
- wrefresh (win);
+ wrefresh(win);
+ for (i = half; i <= OldY; i++) {
+ napms(600);
+ wscrl(win, -1);
+ box(win, ACS_VLINE, ACS_HLINE);
+ wrefresh(win);
}
- wsetscrreg (win, 0, OldY);
-
+ wsetscrreg(win, 0, OldY);
}
static void
-inputTest (WINDOW *win)
+inputTest(WINDOW *win)
{
- int w, h, bx, by, sw, sh, i, c,num;
- char buffer [80];
+ int w, h, bx, by, sw, sh, i, c, num;
+ char buffer[80];
WINDOW *subWin;
- wclear (win);
+ wclear(win);
- getmaxyx(win, h, w);
+ 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;
+ 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
- wbkgd(subWin, A_BOLD);
+ if (has_colors()) {
+ init_pair(2, COLOR_WHITE, COLOR_RED);
+ wbkgd(subWin, COLOR_PAIR(2) | A_BOLD);
+ } else
+ wbkgd(subWin, A_BOLD);
#else
wbkgd(subWin, A_BOLD);
#endif
@@ -259,16 +278,16 @@ inputTest (WINDOW *win)
mvwaddstr(win, 1, 1, "Pressing ^C should do nothing");
wrefresh(win);
- werase (subWin);
+ 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();
+ mvwprintw(subWin, 1, 1, "Time = %d", i);
+ wrefresh(subWin);
+ napms(1000);
+ flushinp();
}
- delwin (subWin);
+ delwin(subWin);
werase(win);
flash();
wrefresh(win);
@@ -287,7 +306,7 @@ inputTest (WINDOW *win)
mvwaddstr(win, 4, 1, "The character should now have been deleted");
Continue(win);
- wclear (win);
+ 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);
@@ -298,49 +317,44 @@ inputTest (WINDOW *win)
#if defined(PDCURSES)
mouse_set(ALL_MOUSE_EVENTS);
#endif
- 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));
+ 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));
#if defined(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;
- 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);
- }
+ 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);
+ }
#endif
- wrefresh(win);
- if (c == ' ')
- break;
+ wrefresh(win);
+ if (c == ' ')
+ break;
}
#if 0
nodelay(win, TRUE);
@@ -351,9 +365,10 @@ inputTest (WINDOW *win)
mouse_set(0L);
#endif
refresh();
- wclear (win);
+ 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, 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);
@@ -361,25 +376,26 @@ inputTest (WINDOW *win)
noraw();
num = 0;
*buffer = 0;
- mvwscanw(win, 7, 6, "%d %s", &num,buffer);
- mvwprintw(win, 8, 6, "String: %s Number: %d", buffer,num);
+ mvwscanw(win, 7, 6, "%d %s", &num, buffer);
+ mvwprintw(win, 8, 6, "String: %s Number: %d", buffer, num);
Continue(win);
}
static void
-outputTest (WINDOW *win)
+outputTest(WINDOW *win)
{
WINDOW *win1;
- char Buffer [80];
+ 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");
+ nl();
+ wclear(win);
+ mvwaddstr(win, 1, 1,
+ "You should now have a screen in the upper left corner, and this text should have wrapped");
mvwin(win, 2, 1);
- waddstr(win,"\nThis text should be down\n");
- waddstr(win, "and broken into two here ^");
+ waddstr(win, "\nThis text should be down\n");
+ waddstr(win, "and broken into two here ^");
Continue(win);
wclear(win);
@@ -392,51 +408,51 @@ outputTest (WINDOW *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);
+ 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;
- }
+ 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
- wbkgd(win1, A_NORMAL);
+ if (has_colors()) {
+ init_pair(3, COLOR_BLUE, COLOR_WHITE);
+ wbkgd(win1, COLOR_PAIR(3));
+ } else
+ wbkgd(win1, A_NORMAL);
#else
- wbkgd(win1, A_NORMAL);
+ wbkgd(win1, A_NORMAL);
#endif
- wclear (win1);
- mvwaddstr(win1, 5, 1, "This text should appear; using overlay option");
- copywin(win, win1,0,0,0,0,9,49,TRUE);
+ wclear(win1);
+ mvwaddstr(win1, 5, 1,
+ "This text should appear; using overlay option");
+ copywin(win, win1, 0, 0, 0, 0, 9, 49, TRUE);
#if defined(PDCURSES) && !defined(XCURSES)
- box(win1,0xb3,0xc4);
+ box(win1, 0xb3, 0xc4);
#else
- box(win1,ACS_VLINE,ACS_HLINE);
+ box(win1, ACS_VLINE, ACS_HLINE);
#endif
- wmove(win1, 8, 26);
- wrefresh(win1);
- wgetch(win1);
-
- wclear(win1);
- wattron(win1, A_BLINK);
- mvwaddstr(win1, 4, 1, "This blinking text should appear in only the second window");
- wattroff(win1, A_BLINK);
- mvwin(win1, by, bx);
- overlay(win, win1);
- mvwin(win1,14,25);
- wmove(win1, 8, 26);
- wrefresh(win1);
- wgetch(win1);
- delwin(win1);
+ 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();
@@ -446,74 +462,75 @@ outputTest (WINDOW *win)
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);
+ wclrtobot(win);
wmove(win, 5, 20);
- wclrtoeol (win);
+ wclrtoeol(win);
mvwaddstr(win, 8, 2, "This line also shouldn't appear");
wmove(win, 8, 1);
wdeleteln(win);
Continue(win);
- wmove (win, 5, 9);
- ch = winch (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);
+ wmove(win, 6, 2);
+ waddstr(win, "The next char should be l: ");
+ winsch(win, ch);
Continue(win);
- mvwinsstr( win, 6, 2, "A1B2C3D4E5" );
+ mvwinsstr(win, 6, 2, "A1B2C3D4E5");
Continue(win);
wmove(win, 5, 1);
- winsertln (win);
+ winsertln(win);
mvwaddstr(win, 5, 2, "The lines below should have moved down");
Continue(win);
wclear(win);
wmove(win, 2, 2);
- wprintw(win, "This is a formatted string in a window: %d %s\n", 42, "is it");
+ wprintw(win, "This is a formatted string in a window: %d %s\n", 42,
+ "is it");
mvwaddstr(win, 10, 1, "Enter a string: ");
wrefresh(win);
noraw();
echo();
*Buffer = 0;
- wscanw (win, "%s", Buffer);
+ wscanw(win, "%s", Buffer);
printw("This is a formatted string in stdscr: %d %s\n", 42, "is it");
mvaddstr(10, 1, "Enter a string: ");
*Buffer = 0;
- scanw ("%s", Buffer);
+ scanw("%s", Buffer);
if (tigetstr("cvvis") != 0) {
- wclear(win);
- curs_set(2);
- mvwaddstr(win, 1, 1, "The cursor should appear as a block (visible)");
- Continue(win);
+ wclear(win);
+ curs_set(2);
+ mvwaddstr(win, 1, 1, "The cursor should appear as a block (visible)");
+ Continue(win);
}
if (tigetstr("civis") != 0) {
- wclear(win);
- curs_set(0);
- mvwaddstr(win, 1, 1, "The cursor should have disappeared (invisible)");
- Continue(win);
+ wclear(win);
+ curs_set(0);
+ mvwaddstr(win, 1, 1,
+ "The cursor should have disappeared (invisible)");
+ Continue(win);
}
if (tigetstr("cnorm") != 0) {
- wclear(win);
- curs_set(1);
- mvwaddstr(win, 1, 1, "The cursor should be an underline (normal)");
- Continue(win);
+ wclear(win);
+ curs_set(1);
+ mvwaddstr(win, 1, 1, "The cursor should be an underline (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);
+ 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
@@ -521,16 +538,16 @@ outputTest (WINDOW *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 supports blinking.");
+ if (termattrs() & A_BLINK)
+ mvwaddstr(win, 5, 1, "This terminal supports blinking.");
else
- mvwaddstr(win,5, 1, "This terminal does NOT support blinking.");
+ mvwaddstr(win, 5, 1, "This terminal does NOT support blinking.");
- mvwaddnstr( win, 7,5, "Have a nice day!ok", 16 );
+ mvwaddnstr(win, 7, 5, "Have a nice day!ok", 16);
wrefresh(win);
- mvwinnstr( win, 7,5, Buffer, 18 );
- mvaddstr( LINES-2, 10, Buffer );
+ mvwinnstr(win, 7, 5, Buffer, 18);
+ mvaddstr(LINES - 2, 10, Buffer);
refresh();
Continue(win);
}
@@ -541,35 +558,34 @@ resizeTest(WINDOW *dummy GCC_UNUSED)
{
WINDOW *win1;
- savetty ();
+ savetty();
clear();
refresh();
# if defined(OS2)
- resize_term(50,120);
+ resize_term(50, 120);
# else
- resize_term(50,80);
+ resize_term(50, 80);
# endif
win1 = newwin(10, 50, 14, 25);
- if(win1 == NULL)
- { endwin();
- return;
+ if (win1 == NULL) {
+ endwin();
+ return;
}
#ifdef A_COLOR
- if (has_colors())
- {
- init_pair(3,COLOR_BLUE,COLOR_WHITE);
- wattrset(win1, COLOR_PAIR(3));
- }
+ if (has_colors()) {
+ init_pair(3, COLOR_BLUE, COLOR_WHITE);
+ wattrset(win1, COLOR_PAIR(3));
+ }
#endif
- wclear (win1);
+ wclear(win1);
mvwaddstr(win1, 1, 1, "The screen may now have 50 lines");
Continue(win1);
- wclear (win1);
- resetty ();
+ wclear(win1);
+ resetty();
mvwaddstr(win1, 1, 1, "The screen should now be reset");
Continue(win1);
@@ -585,56 +601,57 @@ resizeTest(WINDOW *dummy GCC_UNUSED)
static void
padTest(WINDOW *dummy GCC_UNUSED)
{
-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);
+ 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);
}
static void
-display_menu(int old_option,int new_option)
+display_menu(int old_option, int new_option)
{
- 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();
+ 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();
}
-