| 1 |
'\" t |
| 2 |
.\"*************************************************************************** |
| 3 |
.\" Copyright 2018-2024,2025 Thomas E. Dickey * |
| 4 |
.\" Copyright 1998-2016,2017 Free Software Foundation, Inc. * |
| 5 |
.\" * |
| 6 |
.\" Permission is hereby granted, free of charge, to any person obtaining a * |
| 7 |
.\" copy of this software and associated documentation files (the * |
| 8 |
.\" "Software"), to deal in the Software without restriction, including * |
| 9 |
.\" without limitation the rights to use, copy, modify, merge, publish, * |
| 10 |
.\" distribute, distribute with modifications, sublicense, and/or sell * |
| 11 |
.\" copies of the Software, and to permit persons to whom the Software is * |
| 12 |
.\" furnished to do so, subject to the following conditions: * |
| 13 |
.\" * |
| 14 |
.\" The above copyright notice and this permission notice shall be included * |
| 15 |
.\" in all copies or substantial portions of the Software. * |
| 16 |
.\" * |
| 17 |
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * |
| 18 |
.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * |
| 19 |
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * |
| 20 |
.\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * |
| 21 |
.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * |
| 22 |
.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * |
| 23 |
.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. * |
| 24 |
.\" * |
| 25 |
.\" Except as contained in this notice, the name(s) of the above copyright * |
| 26 |
.\" holders shall not be used in advertising or otherwise to promote the * |
| 27 |
.\" sale, use or other dealings in this Software without prior written * |
| 28 |
.\" authorization. * |
| 29 |
.\"*************************************************************************** |
| 30 |
.\" |
| 31 |
.\" $Id: form_driver.3x,v 1.64 2025/10/04 20:59:08 tom Exp $ |
| 32 |
.TH driver 3FORM 2025-10-04 "ncurses 6.6" "Library calls" |
| 33 |
.de bP |
| 34 |
.ie n .IP \(bu 4 |
| 35 |
.el .IP \(bu 2 |
| 36 |
.. |
| 37 |
.SH NAME |
| 38 |
\fBform_driver\fP, |
| 39 |
\fBform_driver_w\fP \- |
| 40 |
command-processing loop of the form system |
| 41 |
.SH SYNOPSIS |
| 42 |
.nf |
| 43 |
\fB#include <form.h> |
| 44 |
.PP |
| 45 |
\fBint form_driver(FORM *\fIform\fP, int \fIc\fP); |
| 46 |
\fBint form_driver_w(FORM *\fIform\fP, int \fIc\fP, wchar_t \fIwc\fP); |
| 47 |
.fi |
| 48 |
.SH DESCRIPTION |
| 49 |
.SS form_driver |
| 50 |
Once a form has been posted (displayed), you should funnel input events to it |
| 51 |
through \fBform_driver\fP. This routine has three major input cases: |
| 52 |
.bP |
| 53 |
The input is a form navigation request. |
| 54 |
Navigation request codes are constants defined in |
| 55 |
.IR form.h "," |
| 56 |
which are distinct from the key- and character codes returned |
| 57 |
by \fBwgetch\fP(3NCURSES). |
| 58 |
.bP |
| 59 |
The input is a printable character. |
| 60 |
Printable characters (which must be positive, less than 256) are |
| 61 |
checked according to the program's locale settings. |
| 62 |
.bP |
| 63 |
The input is the KEY_MOUSE special key associated with an mouse event. |
| 64 |
.SS form_driver_w |
| 65 |
This extension simplifies the use of the forms library using wide characters. |
| 66 |
The input is either a key code (a request) or a wide character |
| 67 |
returned by \fBget_wch\fP(3NCURSES). |
| 68 |
The type must be passed as well, |
| 69 |
to enable the library to determine whether the parameter |
| 70 |
is a wide character or a request. |
| 71 |
.SS "Form Driver Requests" |
| 72 |
The form driver requests are as follows: |
| 73 |
.PP |
| 74 |
.TS |
| 75 |
Lb Lb |
| 76 |
Lb Lx. |
| 77 |
Name Description |
| 78 |
_ |
| 79 |
REQ_BEG_FIELD Move to beginning of field. |
| 80 |
REQ_BEG_LINE Move to beginning of the line. |
| 81 |
REQ_CLR_EOF Clear to end of field from cursor. |
| 82 |
REQ_CLR_EOL Clear to end of line from cursor. |
| 83 |
REQ_CLR_FIELD Clear the entire field. |
| 84 |
REQ_DEL_CHAR Delete character at the cursor. |
| 85 |
REQ_DEL_LINE Delete line at the cursor. |
| 86 |
REQ_DEL_PREV Delete character before the cursor. |
| 87 |
REQ_DEL_WORD Delete blank-delimited word at cursor. |
| 88 |
REQ_DOWN_CHAR Move down in field. |
| 89 |
REQ_DOWN_FIELD Move down to a field. |
| 90 |
REQ_END_FIELD Move to the end of field. |
| 91 |
REQ_END_LINE Move to the end of the line. |
| 92 |
REQ_FIRST_FIELD Move to the first field. |
| 93 |
REQ_FIRST_PAGE Move to the first page. |
| 94 |
REQ_INS_CHAR Insert a blank at the cursor. |
| 95 |
REQ_INS_LINE Insert a blank line at the cursor. |
| 96 |
REQ_INS_MODE Enter insert mode. |
| 97 |
REQ_LAST_FIELD Move to the last field. |
| 98 |
REQ_LAST_PAGE Move to the last field. |
| 99 |
REQ_LEFT_CHAR Move left in field. |
| 100 |
REQ_LEFT_FIELD Move left to a field. |
| 101 |
REQ_NEW_LINE Insert or overlay a new line. |
| 102 |
REQ_NEXT_CHAR Move to the next char. |
| 103 |
REQ_NEXT_CHOICE Display next field choice. |
| 104 |
REQ_NEXT_FIELD Move to the next field. |
| 105 |
REQ_NEXT_LINE Move to the next line. |
| 106 |
REQ_NEXT_PAGE Move to the next page. |
| 107 |
REQ_NEXT_PAGE Move to the next page. |
| 108 |
REQ_NEXT_WORD Move to the next word. |
| 109 |
REQ_OVL_MODE Enter overlay mode. |
| 110 |
REQ_PREV_CHAR Move to the previous char. |
| 111 |
REQ_PREV_CHOICE Display previous field choice. |
| 112 |
REQ_PREV_FIELD Move to the previous field. |
| 113 |
REQ_PREV_LINE Move to the previous line. |
| 114 |
REQ_PREV_PAGE Move to the previous page. |
| 115 |
REQ_PREV_WORD Move to the previous word. |
| 116 |
REQ_RIGHT_CHAR Move right in field. |
| 117 |
REQ_RIGHT_FIELD Move right to a field. |
| 118 |
REQ_SCR_BCHAR Scroll field backward 1 character. |
| 119 |
REQ_SCR_BHPAGE Scroll field backward \(12 page. |
| 120 |
REQ_SCR_BLINE Scroll field backward 1 line. |
| 121 |
REQ_SCR_BPAGE Scroll field backward 1 page. |
| 122 |
REQ_SCR_FCHAR Scroll field forward 1 character. |
| 123 |
REQ_SCR_FHPAGE Scroll field forward \(12 page. |
| 124 |
REQ_SCR_FLINE Scroll field forward 1 line. |
| 125 |
REQ_SCR_FPAGE Scroll field forward 1 page. |
| 126 |
REQ_SCR_HBHALF Horizontal scroll field backward \(12 line. |
| 127 |
REQ_SCR_HBLINE Horizontal scroll field backward 1 line. |
| 128 |
REQ_SCR_HFHALF Horizontal scroll field forward \(12 line. |
| 129 |
REQ_SCR_HFLINE Horizontal scroll field forward 1 line. |
| 130 |
REQ_SFIRST_FIELD Move to the sorted first field. |
| 131 |
REQ_SLAST_FIELD Move to the sorted last field. |
| 132 |
REQ_SNEXT_FIELD Move to the sorted next field. |
| 133 |
REQ_SPREV_FIELD Move to the sorted previous field. |
| 134 |
REQ_UP_CHAR Move up in field. |
| 135 |
REQ_UP_FIELD Move up to a field. |
| 136 |
REQ_VALIDATION Validate field. |
| 137 |
.TE |
| 138 |
.PP |
| 139 |
If the second argument is a printable character, the driver places it |
| 140 |
in the current position in the current field. |
| 141 |
If it is one of the forms |
| 142 |
requests listed above, that request is executed. |
| 143 |
.SS "Field Validation" |
| 144 |
The form library makes updates to the window associated |
| 145 |
with form fields rather than directly to the field buffers. |
| 146 |
.PP |
| 147 |
The form driver provides low-level control over updates to the form fields. |
| 148 |
The form driver also provides for validating modified fields |
| 149 |
to ensure that the contents |
| 150 |
meet whatever constraints an application may attach using \fBset_field_type\fP. |
| 151 |
.PP |
| 152 |
You can validate a field without making any changes to it using |
| 153 |
\fBREQ_VALIDATION\fP. |
| 154 |
The form driver also validates a field in these cases: |
| 155 |
.bP |
| 156 |
a call to \fBset_current_field\fP attempts to move to a different field. |
| 157 |
.bP |
| 158 |
a call to \fBset_current_page\fP attempts to move |
| 159 |
to a different page of the form. |
| 160 |
.bP |
| 161 |
a request attempts to move to a different field. |
| 162 |
.bP |
| 163 |
a request attempts to move to a different page of the form. |
| 164 |
.PP |
| 165 |
In each case, the move fails if the field is invalid. |
| 166 |
.PP |
| 167 |
If the modified field is valid, the form driver copies the modified |
| 168 |
data from the window associated with the field |
| 169 |
to the field buffer. |
| 170 |
.SS "Mouse Handling" |
| 171 |
If the second argument is the KEY_MOUSE special key, the associated |
| 172 |
mouse event is translated into one of the above pre-defined requests. |
| 173 |
Currently only clicks in the user window (e.g., inside the form display |
| 174 |
area or the decoration window) are handled. |
| 175 |
.PP |
| 176 |
If you click above the display region of the form: |
| 177 |
.RS 3 |
| 178 |
.TP |
| 179 |
a REQ_PREV_FIELD is generated for a single click, |
| 180 |
.TP |
| 181 |
a REQ_PREV_PAGE is generated for a double-click and |
| 182 |
.TP |
| 183 |
a REQ_FIRST_FIELD is generated for a triple-click. |
| 184 |
.RE |
| 185 |
.PP |
| 186 |
If you click below the display region of the form: |
| 187 |
.RS 3 |
| 188 |
.TP |
| 189 |
a REQ_NEXT_FIELD is generated for a single click, |
| 190 |
.TP |
| 191 |
a REQ_NEXT_PAGE is generated for a double-click and |
| 192 |
.TP |
| 193 |
a REQ_LAST_FIELD is generated for a triple-click. |
| 194 |
.RE |
| 195 |
.PP |
| 196 |
If you click at an field inside the display area of the form: |
| 197 |
.RS 3 |
| 198 |
.bP |
| 199 |
the form cursor is positioned to that field. |
| 200 |
.bP |
| 201 |
If you double-click a field, |
| 202 |
the form cursor is positioned to that field |
| 203 |
and \fBE_UNKNOWN_COMMAND\fP is returned. |
| 204 |
This return value makes sense, |
| 205 |
because a double click usually means that an field-specific action should |
| 206 |
be returned. |
| 207 |
It is exactly the purpose of this return value to signal that an |
| 208 |
application specific command should be executed. |
| 209 |
.bP |
| 210 |
If a translation |
| 211 |
into a request was done, \fBform_driver\fP returns the result of this request. |
| 212 |
.RE |
| 213 |
.PP |
| 214 |
If you clicked outside the user window |
| 215 |
or the mouse event could not be translated |
| 216 |
into a form request an \fBE_REQUEST_DENIED\fP is returned. |
| 217 |
.SS "Application-defined Commands" |
| 218 |
If the second argument is neither printable nor one of the above |
| 219 |
pre-defined form requests, the driver assumes it is an application-specific |
| 220 |
command and returns \fBE_UNKNOWN_COMMAND\fP. Application-defined commands |
| 221 |
should be defined relative to \fBMAX_COMMAND\fP, the maximum value of these |
| 222 |
pre-defined requests. |
| 223 |
.SH RETURN VALUE |
| 224 |
\fBform_driver\fP returns one of the following error codes: |
| 225 |
.TP 5 |
| 226 |
.B E_OK |
| 227 |
The routine succeeded. |
| 228 |
.TP 5 |
| 229 |
.B E_BAD_ARGUMENT |
| 230 |
Routine detected an incorrect or out-of-range argument. |
| 231 |
.TP 5 |
| 232 |
.B E_BAD_STATE |
| 233 |
Routine was called from an initialization or termination function. |
| 234 |
.TP 5 |
| 235 |
.B E_NOT_POSTED |
| 236 |
The form has not been posted. |
| 237 |
.TP 5 |
| 238 |
.B E_INVALID_FIELD |
| 239 |
Contents of field is invalid. |
| 240 |
.TP 5 |
| 241 |
.B E_NOT_CONNECTED |
| 242 |
No fields are connected to the form. |
| 243 |
.TP 5 |
| 244 |
.B E_REQUEST_DENIED |
| 245 |
The form driver could not process the request. |
| 246 |
.TP 5 |
| 247 |
.B E_SYSTEM_ERROR |
| 248 |
System error occurred (see \fBerrno\fP(3)). |
| 249 |
.TP 5 |
| 250 |
.B E_UNKNOWN_COMMAND |
| 251 |
The form driver code saw an unknown request code. |
| 252 |
.SH PORTABILITY |
| 253 |
These routines emulate the System V forms library. |
| 254 |
They were not supported on |
| 255 |
Version 7 or BSD versions. |
| 256 |
.SH AUTHORS |
| 257 |
Juergen Pfeifer. |
| 258 |
Manual pages and adaptation for new curses by Eric S. Raymond. |
| 259 |
.SH SEE ALSO |
| 260 |
\fB\%ncurses\fP(3NCURSES), |
| 261 |
\fB\%form\fP(3FORM), |
| 262 |
\fB\%fieldtype\fP(3FORM), |
| 263 |
\fB\%field_buffer\fP(3FORM), |
| 264 |
\fB\%field_validation\fP(3FORM), |
| 265 |
\fB\%form_variables\fP(3FORM), |
| 266 |
\fB\%getch\fP(3NCURSES) |