X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fmovewindow.c;h=9effda41a4da145f421aa376aa04f7f48d12cad1;hp=11521a0722388bc06fd9bbe728eb9d5d7915a3ce;hb=cea2b8032daa63b0f131fd5793de28b2abdf5471;hpb=91fa4688e82518794fcf0c32a36f3fcca5e4c2d5 diff --git a/test/movewindow.c b/test/movewindow.c index 11521a07..9effda41 100644 --- a/test/movewindow.c +++ b/test/movewindow.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2006-2010,2012 Free Software Foundation, Inc. * + * Copyright (c) 2006-2012,2013 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: movewindow.c,v 1.37 2012/10/27 19:37:56 tom Exp $ + * $Id: movewindow.c,v 1.39 2013/05/04 19:41:02 tom Exp $ * * Demonstrate move functions for windows and derived windows from the curses * library. @@ -218,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. @@ -486,34 +494,32 @@ move_derwin(WINDOW *win) if (parent != 0) { bool top = (parent == stdscr); - if (!top) { - int min_col = top ? COL_MIN : 0; - int max_col = top ? COL_MAX : getmaxx(parent); - int min_line = top ? LINE_MIN : 0; - int max_line = top ? LINE_MAX : getmaxy(parent); - PAIR *tmp; - bool more; - - show_derwin(win); - while ((tmp = selectcell(parent, - win, - min_line, min_col, - max_line, max_col, - TRUE, - &more)) != 0) { - if (mvderwin(win, tmp->y, tmp->x) != ERR) { - refresh_all(win); - doupdate(); - repaint_one(win); - doupdate(); - result = TRUE; - show_derwin(win); - } else { - flash(); - } - if (!more) - break; + int min_col = top ? COL_MIN : 0; + int max_col = top ? COL_MAX : getmaxx(parent); + int min_line = top ? LINE_MIN : 0; + int max_line = top ? LINE_MAX : getmaxy(parent); + PAIR *tmp; + bool more; + + show_derwin(win); + while ((tmp = selectcell(parent, + win, + min_line, min_col, + max_line, max_col, + TRUE, + &more)) != 0) { + if (mvderwin(win, tmp->y, tmp->x) != ERR) { + refresh_all(win); + doupdate(); + repaint_one(win); + doupdate(); + result = TRUE; + show_derwin(win); + } else { + flash(); } + if (!more) + break; } } head_line("done");