X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fhashtest.c;fp=test%2Fhashtest.c;h=6cf7b7538bfdb9142941f86983d7abe777aee2ee;hp=174495a7c6563238f32d4f03bc1e35087a092697;hb=661078ddbde3ce0f3b06e95642fbb9b5fef7dca1;hpb=3a9b6a3bf0269231bef7de74757a910dedd04e0c diff --git a/test/hashtest.c b/test/hashtest.c index 174495a7..6cf7b753 100644 --- a/test/hashtest.c +++ b/test/hashtest.c @@ -3,7 +3,7 @@ * * Generate timing statistics for vertical-motion optimization. * - * $Id: hashtest.c,v 1.8 1997/01/18 19:09:30 tom Exp $ + * $Id: hashtest.c,v 1.12 1997/08/09 14:25:18 tom Exp $ */ #define NCURSES_TRACE @@ -25,14 +25,27 @@ #define LO_CHAR ' ' #define HI_CHAR '~' -static void finish(int sig) GCC_NORETURN; - static bool continuous = FALSE; static bool reverse_loops = FALSE; +static bool single_step = FALSE; static bool extend_corner = FALSE; static int foot_lines = 0; static int head_lines = 0; +static void cleanup(void) +{ + move(LINES-1,0); + clrtoeol(); + refresh(); + endwin(); +} + +static RETSIGTYPE finish(int sig GCC_UNUSED) +{ + cleanup(); + exit(EXIT_FAILURE); +} + static void genlines(int base) { int i, j; @@ -44,6 +57,12 @@ static void genlines(int base) Trace(("Painting `%c' screen", base)); #endif + /* Do this so writes to lower-right corner don't cause a spurious + * scrolling operation. This _shouldn't_ break the scrolling + * optimization, since that's computed in the refresh() call. + */ + scrollok(stdscr, FALSE); + move(0,0); for (i = 0; i < head_lines; i++) for (j = 0; j < COLS; j++) @@ -57,11 +76,18 @@ static void genlines(int base) addch(c); } - move(LINES - foot_lines, 0); - for (i = LINES - foot_lines; i < LINES; i++) - for (j = 0; j < extend_corner ? COLS : COLS - 1; j++) + for (i = LINES - foot_lines; i < LINES; i++) { + move(i, 0); + for (j = 0; j < (extend_corner ? COLS : COLS - 1); j++) addch((j % 8 == 0) ? ('A' + j/8) : '-'); - refresh(); + } + + scrollok(stdscr, TRUE); + if (single_step) { + move(LINES-1, 0); + getch(); + } else + refresh(); } static void one_cycle(int ch) @@ -111,6 +137,7 @@ static void usage(void) ," -n test the normal optimizer" ," -o test the hashed optimizer" ," -r reverse the loops" + ," -s single-step" ," -x assume lower-right corner extension" }; size_t n; @@ -127,7 +154,7 @@ int main(int argc, char *argv[]) int test_normal = FALSE; int test_optimize = FALSE; - while ((c = getopt(argc, argv, "cf:h:l:norx")) != EOF) { + while ((c = getopt(argc, argv, "cf:h:l:norsx")) != EOF) { switch (c) { case 'c': continuous = TRUE; @@ -150,6 +177,9 @@ int main(int argc, char *argv[]) case 'r': reverse_loops = TRUE; break; + case 's': + single_step = TRUE; + break; case 'x': extend_corner = TRUE; break; @@ -181,13 +211,7 @@ int main(int argc, char *argv[]) run_test(TRUE); } - finish(0); /* we're done */ + cleanup(); /* we're done */ + return(EXIT_SUCCESS); } - -static RETSIGTYPE finish(int sig) -{ - endwin(); - exit(sig != 0 ? EXIT_FAILURE : EXIT_SUCCESS); -} - /* hashtest.c ends here */