1 /****************************************************************************
2 * Copyright (c) 2013,2014 Free Software Foundation, Inc. *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
27 ****************************************************************************/
29 /****************************************************************************
30 * Author: Gaute Hope, 2013 *
31 ****************************************************************************/
34 * $Id: form_driver_w.c,v 1.12 2014/06/01 20:37:19 tom Exp $
36 * Test form_driver_w (int, int, wchar_t), a wide char aware
37 * replacement of form_driver.
42 #include <test.priv.h>
44 #if USE_WIDEC_SUPPORT && USE_LIBFORM && (defined(NCURSES_VERSION_PATCH) && NCURSES_VERSION_PATCH >= 20131207)
55 setlocale(LC_ALL, "");
57 /* Initialize curses */
63 /* Initialize the fields */
64 field[0] = new_field(1, 10, 4, 18, 0, 0);
65 field[1] = new_field(1, 10, 6, 18, 0, 0);
68 /* Set field options */
69 set_field_back(field[0], A_UNDERLINE); /* Print a line for the option */
70 field_opts_off(field[0], O_AUTOSKIP); /* Don't go to next field when this */
71 /* Field is filled up */
72 set_field_back(field[1], A_UNDERLINE);
73 field_opts_off(field[1], O_AUTOSKIP);
75 /* Create the form and post it */
76 my_form = new_form(field);
80 mvprintw(4, 10, "Value 1:");
81 mvprintw(6, 10, "Value 2:");
84 /* Loop through to get user requests */
87 int ret = get_wch(&ch);
89 mvprintw(8, 10, "Got %d (%#x), type: %s", (int) ch, (int) ch,
103 /* Go to next field */
104 form_driver_w(my_form, KEY_CODE_YES, REQ_NEXT_FIELD);
105 /* Go to the end of the present buffer */
106 /* Leaves nicely at the last character */
107 form_driver_w(my_form, KEY_CODE_YES, REQ_END_LINE);
110 /* Go to previous field */
111 form_driver_w(my_form, KEY_CODE_YES, REQ_PREV_FIELD);
112 form_driver_w(my_form, KEY_CODE_YES, REQ_END_LINE);
126 form_driver_w(my_form, OK, ch);
133 /* Un post form and free the memory */
134 unpost_form(my_form);
136 free_field(field[0]);
137 free_field(field[1]);
140 ExitProgram(EXIT_SUCCESS);
147 printf("This program requires the wide-ncurses and forms library\n");
148 ExitProgram(EXIT_FAILURE);
150 #endif /* USE_WIDEC_SUPPORT */