3 ****************************************************************************
4 * Copyright 2018-2022,2023 Thomas E. Dickey *
5 * Copyright 1998-2016,2017 Free Software Foundation, Inc. *
7 * Permission is hereby granted, free of charge, to any person obtaining a *
8 * copy of this software and associated documentation files (the *
9 * "Software"), to deal in the Software without restriction, including *
10 * without limitation the rights to use, copy, modify, merge, publish, *
11 * distribute, distribute with modifications, sublicense, and/or sell *
12 * copies of the Software, and to permit persons to whom the Software is *
13 * furnished to do so, subject to the following conditions: *
15 * The above copyright notice and this permission notice shall be included *
16 * in all copies or substantial portions of the Software. *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
21 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
24 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
26 * Except as contained in this notice, the name(s) of the above copyright *
27 * holders shall not be used in advertising or otherwise to promote the *
28 * sale, use or other dealings in this Software without prior written *
30 ****************************************************************************
31 * @Id: form_driver.3x,v 1.47 2023/09/16 23:37:03 tom Exp @
33 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
36 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
37 <meta name="generator" content="Manpage converted by man2html - see https://invisible-island.net/scripts/readme.html#others_scripts">
38 <TITLE>form_driver 3x 2023-09-16 ncurses 6.4 Library calls</TITLE>
39 <link rel="author" href="mailto:bug-ncurses@gnu.org">
43 <H1 class="no-header">form_driver 3x 2023-09-16 ncurses 6.4 Library calls</H1>
45 <STRONG><A HREF="form_driver.3x.html">form_driver(3x)</A></STRONG> Library calls <STRONG><A HREF="form_driver.3x.html">form_driver(3x)</A></STRONG>
50 </PRE><H2><a name="h2-NAME">NAME</a></H2><PRE>
51 <STRONG>form_driver</STRONG>, <STRONG>form_driver_w</STRONG> - command-processing loop of the form system
54 </PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
55 <STRONG>#include</STRONG> <STRONG><form.h></STRONG>
57 <STRONG>int</STRONG> <STRONG>form_driver(FORM</STRONG> <STRONG>*</STRONG><EM>form</EM><STRONG>,</STRONG> <STRONG>int</STRONG> <EM>c</EM><STRONG>);</STRONG>
58 <STRONG>int</STRONG> <STRONG>form_driver_w(FORM</STRONG> <STRONG>*</STRONG><EM>form</EM><STRONG>,</STRONG> <STRONG>int</STRONG> <EM>c</EM><STRONG>,</STRONG> <STRONG>wchar_t</STRONG> <EM>wch</EM><STRONG>);</STRONG>
61 </PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE>
63 </PRE><H3><a name="h3-form_driver">form_driver</a></H3><PRE>
64 Once a form has been posted (displayed), you should funnel input events
65 to it through <STRONG>form_driver</STRONG>. This routine has three major input cases:
67 <STRONG>o</STRONG> The input is a form navigation request. Navigation request codes
68 are constants defined in <STRONG><form.h></STRONG>, which are distinct from the key-
69 and character codes returned by <STRONG><A HREF="curs_getch.3x.html">wgetch(3x)</A></STRONG>.
71 <STRONG>o</STRONG> The input is a printable character. Printable characters (which
72 must be positive, less than 256) are checked according to the
73 program's locale settings.
75 <STRONG>o</STRONG> The input is the KEY_MOUSE special key associated with an mouse
79 </PRE><H3><a name="h3-form_driver_w">form_driver_w</a></H3><PRE>
80 This extension simplifies the use of the forms library using wide
81 characters. The input is either a key code (a request) or a wide
82 character returned by <STRONG><A HREF="curs_get_wch.3x.html">get_wch(3x)</A></STRONG>. The type must be passed as well, to
83 enable the library to determine whether the parameter is a wide
84 character or a request.
87 </PRE><H3><a name="h3-Form-driver-requests">Form-driver requests</a></H3><PRE>
88 The form driver requests are as follows:
90 <STRONG>Name</STRONG> <STRONG>Description</STRONG>
91 ---------------------------------------------------------------------
92 REQ_BEG_FIELD Move to the beginning of the field.
93 REQ_BEG_LINE Move to the beginning of the line.
94 REQ_CLR_EOF Clear to end of field from cursor.
95 REQ_CLR_EOL Clear to end of line from cursor.
96 REQ_CLR_FIELD Clear the entire field.
97 REQ_DEL_CHAR Delete character at the cursor.
98 REQ_DEL_LINE Delete line at the cursor.
99 REQ_DEL_PREV Delete character before the cursor.
100 REQ_DEL_WORD Delete blank-delimited word at the cursor.
101 REQ_DOWN_CHAR Move down in the field.
102 REQ_DOWN_FIELD Move down to a field.
103 REQ_END_FIELD Move to the end of the field.
104 REQ_END_LINE Move to the end of the line.
105 REQ_FIRST_FIELD Move to the first field.
106 REQ_FIRST_PAGE Move to the first page.
107 REQ_INS_CHAR Insert a blank at the cursor.
108 REQ_INS_LINE Insert a blank line at the cursor.
109 REQ_INS_MODE Enter insert mode.
110 REQ_LAST_FIELD Move to the last field.
111 REQ_LAST_PAGE Move to the last field.
112 REQ_LEFT_CHAR Move left in the field.
113 REQ_LEFT_FIELD Move left to a field.
114 REQ_NEW_LINE Insert or overlay a new line.
115 REQ_NEXT_CHAR Move to the next char.
117 REQ_NEXT_CHOICE Display next field choice.
118 REQ_NEXT_FIELD Move to the next field.
119 REQ_NEXT_LINE Move to the next line.
120 REQ_NEXT_PAGE Move to the next page.
121 REQ_NEXT_PAGE Move to the next page.
122 REQ_NEXT_WORD Move to the next word.
123 REQ_OVL_MODE Enter overlay mode.
124 REQ_PREV_CHAR Move to the previous char.
125 REQ_PREV_CHOICE Display previous field choice.
126 REQ_PREV_FIELD Move to the previous field.
127 REQ_PREV_LINE Move to the previous line.
128 REQ_PREV_PAGE Move to the previous page.
129 REQ_PREV_WORD Move to the previous word.
130 REQ_RIGHT_CHAR Move right in the field.
131 REQ_RIGHT_FIELD Move right to a field.
132 REQ_SCR_BCHAR Scroll the field backward a character.
133 REQ_SCR_BHPAGE Scroll the field backward half a page.
134 REQ_SCR_BLINE Scroll the field backward a line.
135 REQ_SCR_BPAGE Scroll the field backward a page.
136 REQ_SCR_FCHAR Scroll the field forward a character.
137 REQ_SCR_FHPAGE Scroll the field forward half a page.
138 REQ_SCR_FLINE Scroll the field forward a line.
139 REQ_SCR_FPAGE Scroll the field forward a page.
140 REQ_SCR_HBHALF Horizontal scroll the field backward half a line.
141 REQ_SCR_HBLINE Horizontal scroll the field backward a line.
142 REQ_SCR_HFHALF Horizontal scroll the field forward half a line.
143 REQ_SCR_HFLINE Horizontal scroll the field forward a line.
144 REQ_SFIRST_FIELD Move to the sorted first field.
145 REQ_SLAST_FIELD Move to the sorted last field.
146 REQ_SNEXT_FIELD Move to the sorted next field.
147 REQ_SPREV_FIELD Move to the sorted previous field.
148 REQ_UP_CHAR Move up in the field.
149 REQ_UP_FIELD Move up to a field.
150 REQ_VALIDATION Validate field.
152 If the second argument is a printable character, the driver places it
153 in the current position in the current field. If it is one of the
154 forms requests listed above, that request is executed.
157 </PRE><H3><a name="h3-Field-validation">Field validation</a></H3><PRE>
158 The form library makes updates to the window associated with form
159 fields rather than directly to the field buffers.
161 The form driver provides low-level control over updates to the form
162 fields. The form driver also provides for validating modified fields
163 to ensure that the contents meet whatever constraints an application
164 may attach using <STRONG>set_field_type</STRONG>.
166 You can validate a field without making any changes to it using
167 <STRONG>REQ_VALIDATION</STRONG>. The form driver also validates a field in these cases:
169 <STRONG>o</STRONG> a call to <STRONG>set_current_field</STRONG> attempts to move to a different field.
171 <STRONG>o</STRONG> a call to <STRONG>set_current_page</STRONG> attempts to move to a different page of
174 <STRONG>o</STRONG> a request attempts to move to a different field.
176 <STRONG>o</STRONG> a request attempts to move to a different page of the form.
178 In each case, the move fails if the field is invalid.
180 If the modified field is valid, the form driver copies the modified
181 data from the window associated with the field to the field buffer.
184 </PRE><H3><a name="h3-Mouse-handling">Mouse handling</a></H3><PRE>
185 If the second argument is the KEY_MOUSE special key, the associated
186 mouse event is translated into one of the above pre-defined requests.
187 Currently only clicks in the user window (e.g., inside the form display
188 area or the decoration window) are handled.
190 If you click above the display region of the form:
192 a REQ_PREV_FIELD is generated for a single click,
194 a REQ_PREV_PAGE is generated for a double-click and
196 a REQ_FIRST_FIELD is generated for a triple-click.
198 If you click below the display region of the form:
200 a REQ_NEXT_FIELD is generated for a single click,
202 a REQ_NEXT_PAGE is generated for a double-click and
204 a REQ_LAST_FIELD is generated for a triple-click.
206 If you click at an field inside the display area of the form:
208 <STRONG>o</STRONG> the form cursor is positioned to that field.
210 <STRONG>o</STRONG> If you double-click a field, the form cursor is positioned to
211 that field and <STRONG>E_UNKNOWN_COMMAND</STRONG> is returned. This return value
212 makes sense, because a double click usually means that an field-
213 specific action should be returned. It is exactly the purpose
214 of this return value to signal that an application specific
215 command should be executed.
217 <STRONG>o</STRONG> If a translation into a request was done, <STRONG>form_driver</STRONG> returns
218 the result of this request.
220 If you clicked outside the user window or the mouse event could not be
221 translated into a form request an <STRONG>E_REQUEST_DENIED</STRONG> is returned.
224 </PRE><H3><a name="h3-Application-defined-commands">Application-defined commands</a></H3><PRE>
225 If the second argument is neither printable nor one of the above pre-
226 defined form requests, the driver assumes it is an application-specific
227 command and returns <STRONG>E_UNKNOWN_COMMAND</STRONG>. Application-defined commands
228 should be defined relative to <STRONG>MAX_COMMAND</STRONG>, the maximum value of these
229 pre-defined requests.
232 </PRE><H2><a name="h2-RETURN-VALUE">RETURN VALUE</a></H2><PRE>
233 <STRONG>form_driver</STRONG> returns one of the following error codes:
235 <STRONG>E_OK</STRONG> The routine succeeded.
237 <STRONG>E_BAD_ARGUMENT</STRONG>
238 Routine detected an incorrect or out-of-range argument.
240 <STRONG>E_BAD_STATE</STRONG>
241 Routine was called from an initialization or termination function.
243 <STRONG>E_NOT_POSTED</STRONG>
244 The form has not been posted.
246 <STRONG>E_INVALID_FIELD</STRONG>
247 Contents of field is invalid.
249 <STRONG>E_NOT_CONNECTED</STRONG>
250 No fields are connected to the form.
252 <STRONG>E_REQUEST_DENIED</STRONG>
253 The form driver could not process the request.
255 <STRONG>E_SYSTEM_ERROR</STRONG>
256 System error occurred (see <STRONG>errno(3)</STRONG>).
258 <STRONG>E_UNKNOWN_COMMAND</STRONG>
259 The form driver code saw an unknown request code.
262 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
263 <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="form.3x.html">form(3x)</A></STRONG>, <STRONG><A HREF="form_fieldtype.3x.html">form_fieldtype(3x)</A></STRONG>, <STRONG><A HREF="form_field_buffer.3x.html">form_field_buffer(3x)</A></STRONG>,
264 <STRONG><A HREF="form_field_validation.3x.html">form_field_validation(3x)</A></STRONG>, <STRONG><A HREF="form_variables.3x.html">form_variables(3x)</A></STRONG>, <STRONG><A HREF="curs_getch.3x.html">getch(3x)</A></STRONG>.
267 </PRE><H2><a name="h2-NOTES">NOTES</a></H2><PRE>
268 The header file <STRONG><form.h></STRONG> automatically includes the header files
269 <STRONG><curses.h></STRONG>.
272 </PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
273 These routines emulate the System V forms library. They were not
274 supported on Version 7 or BSD versions.
277 </PRE><H2><a name="h2-AUTHORS">AUTHORS</a></H2><PRE>
278 Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S.
283 ncurses 6.4 2023-09-16 <STRONG><A HREF="form_driver.3x.html">form_driver(3x)</A></STRONG>
287 <li><a href="#h2-NAME">NAME</a></li>
288 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
289 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a>
291 <li><a href="#h3-form_driver">form_driver</a></li>
292 <li><a href="#h3-form_driver_w">form_driver_w</a></li>
293 <li><a href="#h3-Form-driver-requests">Form-driver requests</a></li>
294 <li><a href="#h3-Field-validation">Field validation</a></li>
295 <li><a href="#h3-Mouse-handling">Mouse handling</a></li>
296 <li><a href="#h3-Application-defined-commands">Application-defined commands</a></li>
299 <li><a href="#h2-RETURN-VALUE">RETURN VALUE</a></li>
300 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>
301 <li><a href="#h2-NOTES">NOTES</a></li>
302 <li><a href="#h2-PORTABILITY">PORTABILITY</a></li>
303 <li><a href="#h2-AUTHORS">AUTHORS</a></li>