X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fmovewindow.c;h=612cb8823cb75cbabb200f2f9701654a5a72d1e2;hp=b855942832c7ed97ab19f688e181b19a7042dc51;hb=1c551ea75ea57f9186fbe8d79674ac85baa4d358;hpb=0573f2d712e4b5cb2a02a3fe52d513843d536b34 diff --git a/test/movewindow.c b/test/movewindow.c index b8559428..612cb882 100644 --- a/test/movewindow.c +++ b/test/movewindow.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: movewindow.c,v 1.36 2012/09/01 23:54:00 tom Exp $ + * $Id: movewindow.c,v 1.38 2012/12/15 18:36:40 tom Exp $ * * Demonstrate move functions for windows and derived windows from the curses * library. @@ -79,6 +79,14 @@ static void tail_line(CONST_FMT char *fmt,...) GCC_PRINTFLIKE(1, 2); static unsigned num_windows; static FRAME *all_windows; +static void +failed(const char *s) +{ + perror(s); + endwin(); + ExitProgram(EXIT_FAILURE); +} + static void message(int lineno, CONST_FMT char *fmt, va_list argp) { @@ -210,8 +218,16 @@ selectcell(WINDOW *parent, res.x = ulj + j; return (&res); } - i %= si; - j %= sj; + + if (si <= 0) + i = 0; + else + i %= si; + + if (sj <= 0) + j = 0; + else + j %= sj; /* * If the caller can handle continuous movement, return the result. @@ -305,6 +321,8 @@ add_window(WINDOW *parent, WINDOW *child) keypad(child, TRUE); if (need > have) { all_windows = typeRealloc(FRAME, need, all_windows); + if (!all_windows) + failed("add_window"); } all_windows[num_windows].parent = parent; all_windows[num_windows].child = child;