/****************************************************************************
- * Copyright (c) 2007 Free Software Foundation, Inc. *
+ * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2007-2011,2017 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: test_get_wstr.c,v 1.4 2007/07/28 19:46:34 tom Exp $
+ * $Id: test_get_wstr.c,v 1.12 2020/02/02 23:34:34 tom Exp $
*
* Author: Thomas E Dickey
*
*/
#include <test.priv.h>
+#include <popup_msg.h>
+
+#if HAVE_CHGAT
+/* NetBSD curses wchgat */
#if USE_WIDEC_SUPPORT
static void
ShowPrompt(WINDOW *txtwin, int limit)
{
- wchgat(txtwin, limit, A_REVERSE, 0, NULL);
+ wchgat(txtwin, limit, WA_REVERSE, 0, NULL);
wnoutrefresh(txtwin);
}
static void
MovePrompt(WINDOW *txtwin, int limit, int y, int x)
{
- wchgat(txtwin, Remainder(txtwin), A_NORMAL, 0, NULL);
+ wchgat(txtwin, Remainder(txtwin), WA_NORMAL, 0, NULL);
wmove(txtwin, y, x);
ShowPrompt(txtwin, limit);
}
static int
-ShowFlavor(WINDOW *strwin, WINDOW *txtwin, Flavors flavor, int limit)
+ShowFlavor(WINDOW *strwin, WINDOW *txtwin, int flavor, int limit)
{
const char *name = "?";
bool limited = FALSE;
}
static int
-test_get_wstr(int level, char **argv, WINDOW *strwin)
+recursive_test(int level, char **argv, WINDOW *strwin)
{
+ static const char *help[] =
+ {
+ "Commands:",
+ " q,^Q,ESC - quit this program",
+ " ^Q,ESC - quit help-screen",
+ "",
+ " p,<Up> - move beginning of prompt one up row",
+ " j,<Down> - move beginning of prompt one down row",
+ " h,<Left> - move beginning of prompt one left column",
+ " l,<Right> - move beginning of prompt one right column",
+ "",
+ " - - reduce getnstr buffer-size one column",
+ " + - increase getnstr buffer-size one column",
+ " : - prompt for input-text",
+ "",
+ " < - scroll \"left\" through getstr-functions",
+ " > - scroll \"right\" through getstr-functions",
+ "",
+ " w - recur to subwindow",
+ " ?,<F1> - show help-screen",
+ 0
+ };
WINDOW *txtbox = 0;
WINDOW *txtwin = 0;
FILE *fp;
break;
case 'w':
- test_get_wstr(level + 1, argv, strwin);
+ recursive_test(level + 1, argv, strwin);
if (txtbox != 0) {
touchwin(txtbox);
wnoutrefresh(txtbox);
*buffer = '\0';
rc = ERR;
echo();
- wattrset(txtwin, A_REVERSE);
+ (void) wattrset(txtwin, A_REVERSE);
switch (flavor) {
case eGetStr:
if (txtwin != stdscr) {
break;
}
noecho();
- wattrset(txtwin, A_NORMAL);
- wprintw(strwin, "%d", rc);
- waddwstr(strwin, (wchar_t *) buffer);
+ (void) wattrset(txtwin, A_NORMAL);
+ wprintw(strwin, "%s:", (rc == OK) ? "OK" : "ERR");
+ (void) waddwstr(strwin, (wchar_t *) buffer);
wnoutrefresh(strwin);
break;
+ case HELP_KEY_1:
+ popup_msg(stdscr, help);
+ break;
default:
beep();
break;
strwin = derwin(chrbox, 4, COLS - 2, 1, 1);
- test_get_wstr(1, argv, strwin);
+ recursive_test(1, argv, strwin);
endwin();
ExitProgram(EXIT_SUCCESS);
ExitProgram(EXIT_FAILURE);
}
#endif
+#else
+int
+main(void)
+{
+ printf("This program requires the curses chgat function\n");
+ ExitProgram(EXIT_FAILURE);
+}
+#endif