X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Ftestcurs.c;h=f9762b0b328a848550631c63c7eec48d4c4b3f4f;hp=fd3431ce1d9987234cc7426e808430a104cc0e22;hb=HEAD;hpb=aed072e27e60c2abc5ac0ab8113aacf9b4908d50;ds=sidebyside diff --git a/test/testcurs.c b/test/testcurs.c index fd3431ce..750e5a45 100644 --- a/test/testcurs.c +++ b/test/testcurs.c @@ -6,7 +6,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.53 2017/12/23 21:38:26 tom Exp $ + * $Id: testcurs.c,v 1.58 2023/05/28 14:23:34 tom Exp $ */ #include @@ -59,7 +59,7 @@ initTest(WINDOW **win) PDC_debug("initTest called\n"); #endif #ifdef TRACE - trace(TRACE_MAXIMUM); + curses_trace(TRACE_MAXIMUM); #endif initscr(); #ifdef PDCDEBUG @@ -73,7 +73,7 @@ initTest(WINDOW **win) height = 13; /* Create a drawing window */ *win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2); if (*win == NULL) { - exit_curses(); + stop_curses(); return 0; } return 1; @@ -160,7 +160,7 @@ inputTest(WINDOW *win) { int answered; int repeat; - int w, h, bx, by, sw, sh, i, c, num; + int w, h, bx, by, sw, sh, i, num; char buffer[80]; WINDOW *subWin; wclear(win); @@ -238,6 +238,8 @@ inputTest(WINDOW *win) #endif for (;;) { + int c; + wmove(win, 3, 5); c = wgetch(win); wclrtobot(win); @@ -250,11 +252,11 @@ inputTest(WINDOW *win) #ifdef KEY_MOUSE if (c == KEY_MOUSE) { #if defined(NCURSES_MOUSE_VERSION) -#define ButtonChanged(n) ((event.bstate) & NCURSES_MOUSE_MASK(1, 037)) -#define ButtonPressed(n) ((event.bstate) & NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_PRESSED)) -#define ButtonDouble(n) ((event.bstate) & NCURSES_MOUSE_MASK(1, NCURSES_DOUBLE_CLICKED)) -#define ButtonTriple(n) ((event.bstate) & NCURSES_MOUSE_MASK(1, NCURSES_TRIPLE_CLICKED)) -#define ButtonRelease(n) ((event.bstate) & NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED)) +#define ButtonChanged(n) ((event.bstate) & NCURSES_MOUSE_MASK(n, (NCURSES_BUTTON_RELEASED|NCURSES_BUTTON_PRESSED|NCURSES_BUTTON_CLICKED|NCURSES_DOUBLE_CLICKED|NCURSES_TRIPLE_CLICKED|NCURSES_RESERVED_EVENT))) +#define ButtonPressed(n) ((event.bstate) & NCURSES_MOUSE_MASK(n, NCURSES_BUTTON_PRESSED)) +#define ButtonDouble(n) ((event.bstate) & NCURSES_MOUSE_MASK(n, NCURSES_DOUBLE_CLICKED)) +#define ButtonTriple(n) ((event.bstate) & NCURSES_MOUSE_MASK(n, NCURSES_TRIPLE_CLICKED)) +#define ButtonRelease(n) ((event.bstate) & NCURSES_MOUSE_MASK(n, NCURSES_BUTTON_RELEASED)) MEVENT event; int button = 0; @@ -355,7 +357,6 @@ inputTest(WINDOW *win) static void outputTest(WINDOW *win) { - WINDOW *win1; char Buffer[80]; chtype ch; int by, bx; @@ -395,7 +396,7 @@ outputTest(WINDOW *win) MvWAddStr(win, 6, 1, "display of at least 24 LINES by 75 COLUMNS"); Continue(win); } else { - win1 = newwin(10, 50, 14, 25); + WINDOW *win1 = newwin(10, 50, 14, 25); if (win1 == NULL) { endwin(); return; @@ -557,7 +558,7 @@ resizeTest(WINDOW *dummy GCC_UNUSED) win1 = newwin(10, 50, 14, 25); if (win1 == NULL) { - exit_curses(); + stop_curses(); return; } #ifdef A_COLOR @@ -589,9 +590,11 @@ resizeTest(WINDOW *dummy GCC_UNUSED) static void padTest(WINDOW *dummy GCC_UNUSED) { - WINDOW *pad, *spad; + WINDOW *pad; if ((pad = newpad(50, 100)) != 0) { + WINDOW *spad; + wattron(pad, A_REVERSE); MvWAddStr(pad, 5, 2, "This is a new pad"); (void) wattrset(pad, A_NORMAL); @@ -673,17 +676,48 @@ display_menu(int old_option, int new_option) refresh(); } +static void +usage(int ok) +{ + static const char *msg[] = + { + "Usage: testcurs [options]" + ,"" + ,USAGE_COMMON + }; + size_t n; + + for (n = 0; n < SIZEOF(msg); n++) + fprintf(stderr, "%s\n", msg[n]); + + ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE); +} +/* *INDENT-OFF* */ +VERSION_COMMON() +/* *INDENT-ON* */ + int -main( - int argc GCC_UNUSED, - char *argv[]GCC_UNUSED) +main(int argc, char *argv[]) { WINDOW *win; - int key; int old_option = (-1); int new_option = 0; bool quit = FALSE; int n; + int ch; + + while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) { + switch (ch) { + case OPTS_VERSION: + show_version(argv); + ExitProgram(EXIT_SUCCESS); + default: + usage(ch == OPTS_USAGE); + /* NOTREACHED */ + } + } + if (optind < argc) + usage(FALSE); setlocale(LC_ALL, ""); @@ -695,7 +729,10 @@ main( erase(); display_menu(old_option, new_option); + for (;;) { + int key; + #ifdef A_COLOR if (has_colors()) { init_pair(1, COLOR_WHITE, COLOR_BLUE); @@ -760,7 +797,7 @@ main( delwin(win); - exit_curses(); + stop_curses(); #ifdef XCURSES XCursesExit(); #endif