X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Ftest_get_wstr.c;h=f07c2e05d1ef1faecfdb1cc389fcf9351bfa243f;hp=eb229a52a00fe0b1785f5a4ff42b12a21766a37b;hb=22a4b929f47f85588dc07fddf98b09776cec658f;hpb=c8e187fc9682a3c5cfaebc480fc98d8585f6caf6 diff --git a/test/test_get_wstr.c b/test/test_get_wstr.c index eb229a52..f07c2e05 100644 --- a/test/test_get_wstr.c +++ b/test/test_get_wstr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2007,2009 Free Software Foundation, Inc. * + * Copyright (c) 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 * @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: test_get_wstr.c,v 1.6 2009/08/29 19:02:25 tom Exp $ + * $Id: test_get_wstr.c,v 1.11 2017/09/28 23:10:54 tom Exp $ * * Author: Thomas E Dickey * @@ -43,6 +43,10 @@ */ #include +#include + +#if HAVE_CHGAT +/* NetBSD curses wchgat */ #if USE_WIDEC_SUPPORT @@ -76,14 +80,14 @@ Remainder(WINDOW *txtwin) 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); } @@ -131,8 +135,30 @@ ShowFlavor(WINDOW *strwin, WINDOW *txtwin, int flavor, int limit) } 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, - move beginning of prompt one up row", + " j, - move beginning of prompt one down row", + " h, - move beginning of prompt one left column", + " l, - 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", + " ?, - show help-screen", + 0 + }; WINDOW *txtbox = 0; WINDOW *txtwin = 0; FILE *fp; @@ -222,7 +248,7 @@ test_get_wstr(int level, char **argv, WINDOW *strwin) break; case 'w': - test_get_wstr(level + 1, argv, strwin); + recursive_test(level + 1, argv, strwin); if (txtbox != 0) { touchwin(txtbox); wnoutrefresh(txtbox); @@ -308,10 +334,13 @@ test_get_wstr(int level, char **argv, WINDOW *strwin) } noecho(); (void) wattrset(txtwin, A_NORMAL); - wprintw(strwin, "%d", rc); + 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; @@ -346,7 +375,7 @@ main(int argc, char *argv[]) strwin = derwin(chrbox, 4, COLS - 2, 1, 1); - test_get_wstr(1, argv, strwin); + recursive_test(1, argv, strwin); endwin(); ExitProgram(EXIT_SUCCESS); @@ -359,3 +388,11 @@ main(void) ExitProgram(EXIT_FAILURE); } #endif +#else +int +main(void) +{ + printf("This program requires the curses chgat function\n"); + ExitProgram(EXIT_FAILURE); +} +#endif