X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fsavescreen.c;h=09f328baf273d340eda9ede1e0e51fe30a8bc26b;hp=24e8a658309ee589320b0355e7270e2af73d2d15;hb=d998cb49bfb53bd99900fd4ed94519579bea99de;hpb=c13e57306ae5c4431fddd0fe856c3bcae6aeeb2c;ds=sidebyside diff --git a/test/savescreen.c b/test/savescreen.c old mode 100755 new mode 100644 index 24e8a658..09f328ba --- a/test/savescreen.c +++ b/test/savescreen.c @@ -26,15 +26,11 @@ * authorization. * ****************************************************************************/ /* - * $Id: savescreen.c,v 1.9 2007/07/14 23:16:55 tom Exp $ + * $Id: savescreen.c,v 1.10 2007/07/21 17:57:37 tom Exp $ * * Demonstrate save/restore functions from the curses library. * Thomas Dickey - 2007/7/14 */ -/* -scr_set - -scr_init - -*/ #include @@ -49,6 +45,8 @@ scr_init - # endif #endif +static bool use_init = FALSE; + static void setup_next(void) { @@ -66,6 +64,20 @@ cleanup(char *files[]) } } +static int +load_screen(char *filename) +{ + int result; + + if (use_init) { + if ((result = scr_init(filename)) != ERR) + result = scr_restore(filename); + } else { + result = scr_set(filename); + } + return result; +} + /* * scr_restore() or scr_set() operates on curscr. If we read a character using * getch() that will refresh stdscr, wiping out the result. To avoid that, @@ -117,6 +129,7 @@ usage(void) "Usage: savescreen [-r] files", "", "Options:", + " -i use scr_init/scr_restore rather than scr_set", " -r replay the screen-dump files" }; unsigned n; @@ -136,8 +149,11 @@ main(int argc, char *argv[]) bool done = FALSE; char **files; - while ((ch = getopt(argc, argv, "r")) != -1) { + while ((ch = getopt(argc, argv, "ir")) != -1) { switch (ch) { + case 'i': + use_init = TRUE; + break; case 'r': replaying = TRUE; break; @@ -174,7 +190,7 @@ main(int argc, char *argv[]) } which = last; - if (scr_set(files[which]) == ERR) { + if (load_screen(files[which]) == ERR) { endwin(); printf("Cannot load screen-dump %s\n", files[which]); ExitProgram(EXIT_FAILURE);