/****************************************************************************
- * Copyright (c) 2006-2012,2013 Free Software Foundation, Inc. *
+ * Copyright (c) 2006-2017,2018 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 *
* authorization. *
****************************************************************************/
/*
- * $Id: movewindow.c,v 1.39 2013/05/04 19:41:02 tom Exp $
+ * $Id: movewindow.c,v 1.48 2018/11/24 21:29:46 tom Exp $
*
* Demonstrate move functions for windows and derived windows from the curses
* library.
*/
#include <test.priv.h>
-#include <stdarg.h>
+
+#if HAVE_MVDERWIN && HAVE_MVWIN
+
+#include <popup_msg.h>
#ifdef HAVE_XCURSES
#undef derwin
#endif
-#ifdef NCURSES_VERSION
+#if defined(NCURSES_VERSION) || defined(PDCURSES)
#define CONST_FMT const
#else
#define CONST_FMT /* nothing */
vsprintf(buffer, fmt, argp);
addstr(buffer);
}
+#elif defined(HAVE_VW_PRINTW)
+ vw_printw(stdscr, fmt, argp);
#else
vwprintw(stdscr, fmt, argp);
#endif
moved = TRUE;
break;
case QUIT:
+ /* FALLTHRU */
case ESCAPE:
return ((PAIR *) 0);
#ifdef NCURSES_MOUSE_VERSION
break;
}
}
- /* FALLTHRU */
#endif
+ /* FALLTHRU */
default:
res.y = uli + i;
res.x = ulj + j;
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" },
};
/* *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
getyx(current_win, y, x);
switch (ch) {
- case '?':
+ case HELP_KEY_1:
show_help(current_win);
break;
case 'b':
wmove(current_win, 0, 0);
}
endwin();
+#if NO_LEAKS
+ free(all_windows);
+#endif
ExitProgram(EXIT_SUCCESS);
}
+#else
+int
+main(void)
+{
+ printf("This program requires the curses mvderwin and mvwin functions\n");
+ ExitProgram(EXIT_FAILURE);
+}
+#endif