X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fmovewindow.c;h=b8e9e049602dcf0298a27ae3c60a418a6e20e44d;hp=91c7266ad77998834cfe1b499303638342fc08a4;hb=2017ab0e60ca857accae38a01252e0cbdf5f1efe;hpb=a924c24b2535cccdc0f5f991cd8ddcadcfa1f0d2 diff --git a/test/movewindow.c b/test/movewindow.c index 91c7266a..b8e9e049 100644 --- a/test/movewindow.c +++ b/test/movewindow.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: movewindow.c,v 1.40 2017/04/08 23:01:47 tom Exp $ + * $Id: movewindow.c,v 1.46 2017/12/23 21:36:59 tom Exp $ * * Demonstrate move functions for windows and derived windows from the curses * library. @@ -45,13 +45,16 @@ TODO: */ #include -#include + +#if HAVE_MVDERWIN && HAVE_MVWIN + +#include #ifdef HAVE_XCURSES #undef derwin #endif -#ifdef NCURSES_VERSION +#if defined(NCURSES_VERSION) || defined(PDCURSES) #define CONST_FMT const #else #define CONST_FMT /* nothing */ @@ -190,6 +193,7 @@ selectcell(WINDOW *parent, moved = TRUE; break; case QUIT: + /* FALLTHRU */ case ESCAPE: return ((PAIR *) 0); #ifdef NCURSES_MOUSE_VERSION @@ -211,8 +215,8 @@ selectcell(WINDOW *parent, break; } } - /* FALLTHRU */ #endif + /* FALLTHRU */ default: res.y = uli + i; res.x = ulj + j; @@ -637,7 +641,7 @@ show_help(WINDOW *current) int key; CONST_FMT char * msg; } help[] = { - { '?', "Show this screen" }, + { HELP_KEY_1, "Show this screen" }, { 'b', "Draw a box inside the current window" }, { 'c', "Create a new window" }, { 'd', "Create a new derived window" }, @@ -654,20 +658,18 @@ show_help(WINDOW *current) }; /* *INDENT-ON* */ - WINDOW *mywin = newwin(LINES, COLS, 0, 0); - int row; + char **msgs = typeCalloc(char *, SIZEOF(help) + 1); + size_t n; - for (row = 0; row < LINES - 2 && row < (int) SIZEOF(help); ++row) { - wmove(mywin, row + 1, 1); - wprintw(mywin, "%s", keyname(help[row].key)); - wmove(mywin, row + 1, 20); - wprintw(mywin, "%s", help[row].msg); + for (n = 0; n < SIZEOF(help); ++n) { + msgs[n] = typeMalloc(char, 21 + strlen(help[n].msg)); + sprintf(msgs[n], "%-20s%s", keyname(help[n].key), help[n].msg); + } + popup_msg2(current, msgs); + for (n = 0; n < SIZEOF(help); ++n) { + free(msgs[n]); } - box_inside(mywin); - wmove(mywin, 1, 1); - wgetch(mywin); - delwin(mywin); - refresh_all(current); + free(msgs); } int @@ -695,7 +697,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) getyx(current_win, y, x); switch (ch) { - case '?': + case HELP_KEY_1: show_help(current_win); break; case 'b': @@ -767,3 +769,11 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) #endif ExitProgram(EXIT_SUCCESS); } +#else +int +main(void) +{ + printf("This program requires the curses mvderwin and mvwin functions\n"); + ExitProgram(EXIT_FAILURE); +} +#endif