micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 1 | '\" t |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 2 | .\"*************************************************************************** |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 3 | .\" Copyright 2018-2023,2024 Thomas E. Dickey * |
| 4 | .\" Copyright 1998-2016,2017 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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 | .\" |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 31 | .\" $Id: form_driver.3x,v 1.61 2024/04/20 18:55:09 tom Exp $ |
| 32 | .TH form_driver 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls" |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 33 | .de bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 34 | .ie n .IP \(bu 4 |
| 35 | .el .IP \(bu 2 |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 36 | .. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 37 | .SH NAME |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 38 | \fBform_driver\fP, |
| 39 | \fBform_driver_w\fP \- |
| 40 | command-processing loop of the form system |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 41 | .SH SYNOPSIS |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 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 |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 48 | .SH DESCRIPTION |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 49 | .SS form_driver |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 50 | Once a form has been posted (displayed), you should funnel input events to it |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 51 | through \fBform_driver\fP. This routine has three major input cases: |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 52 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 53 | The input is a form navigation request. |
| 54 | Navigation request codes are constants defined in \fB<form.h>\fP, |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 55 | which are distinct from the key- and character codes returned |
| 56 | by \fBwgetch\fP(3X). |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 57 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 58 | The input is a printable character. |
| 59 | Printable characters (which must be positive, less than 256) are |
| 60 | checked according to the program's locale settings. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 61 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 62 | The input is the KEY_MOUSE special key associated with an mouse event. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 63 | .SS form_driver_w |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 64 | This extension simplifies the use of the forms library using wide characters. |
| 65 | The input is either a key code (a request) or a wide character |
| 66 | returned by \fBget_wch\fP(3X). |
| 67 | The type must be passed as well, |
| 68 | to enable the library to determine whether the parameter |
| 69 | is a wide character or a request. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 70 | .SS "Form Driver Requests" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 71 | The form driver requests are as follows: |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 72 | .PP |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 73 | .TS |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 74 | Lb Lb |
| 75 | Lb Lx. |
| 76 | Name Description |
| 77 | _ |
| 78 | REQ_BEG_FIELD Move to beginning of field. |
| 79 | REQ_BEG_LINE Move to beginning of the line. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 80 | REQ_CLR_EOF Clear to end of field from cursor. |
| 81 | REQ_CLR_EOL Clear to end of line from cursor. |
| 82 | REQ_CLR_FIELD Clear the entire field. |
| 83 | REQ_DEL_CHAR Delete character at the cursor. |
| 84 | REQ_DEL_LINE Delete line at the cursor. |
| 85 | REQ_DEL_PREV Delete character before the cursor. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 86 | REQ_DEL_WORD Delete blank-delimited word at cursor. |
| 87 | REQ_DOWN_CHAR Move down in field. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 88 | REQ_DOWN_FIELD Move down to a field. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 89 | REQ_END_FIELD Move to the end of field. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 90 | REQ_END_LINE Move to the end of the line. |
| 91 | REQ_FIRST_FIELD Move to the first field. |
| 92 | REQ_FIRST_PAGE Move to the first page. |
| 93 | REQ_INS_CHAR Insert a blank at the cursor. |
| 94 | REQ_INS_LINE Insert a blank line at the cursor. |
| 95 | REQ_INS_MODE Enter insert mode. |
| 96 | REQ_LAST_FIELD Move to the last field. |
| 97 | REQ_LAST_PAGE Move to the last field. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 98 | REQ_LEFT_CHAR Move left in field. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 99 | REQ_LEFT_FIELD Move left to a field. |
| 100 | REQ_NEW_LINE Insert or overlay a new line. |
| 101 | REQ_NEXT_CHAR Move to the next char. |
| 102 | REQ_NEXT_CHOICE Display next field choice. |
| 103 | REQ_NEXT_FIELD Move to the next field. |
| 104 | REQ_NEXT_LINE Move to the next line. |
| 105 | REQ_NEXT_PAGE Move to the next page. |
| 106 | REQ_NEXT_PAGE Move to the next page. |
| 107 | REQ_NEXT_WORD Move to the next word. |
| 108 | REQ_OVL_MODE Enter overlay mode. |
| 109 | REQ_PREV_CHAR Move to the previous char. |
| 110 | REQ_PREV_CHOICE Display previous field choice. |
| 111 | REQ_PREV_FIELD Move to the previous field. |
| 112 | REQ_PREV_LINE Move to the previous line. |
| 113 | REQ_PREV_PAGE Move to the previous page. |
| 114 | REQ_PREV_WORD Move to the previous word. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 115 | REQ_RIGHT_CHAR Move right in field. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 116 | REQ_RIGHT_FIELD Move right to a field. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 117 | REQ_SCR_BCHAR Scroll field backward 1 character. |
| 118 | REQ_SCR_BHPAGE Scroll field backward \(12 page. |
| 119 | REQ_SCR_BLINE Scroll field backward 1 line. |
| 120 | REQ_SCR_BPAGE Scroll field backward 1 page. |
| 121 | REQ_SCR_FCHAR Scroll field forward 1 character. |
| 122 | REQ_SCR_FHPAGE Scroll field forward \(12 page. |
| 123 | REQ_SCR_FLINE Scroll field forward 1 line. |
| 124 | REQ_SCR_FPAGE Scroll field forward 1 page. |
| 125 | REQ_SCR_HBHALF Horizontal scroll field backward \(12 line. |
| 126 | REQ_SCR_HBLINE Horizontal scroll field backward 1 line. |
| 127 | REQ_SCR_HFHALF Horizontal scroll field forward \(12 line. |
| 128 | REQ_SCR_HFLINE Horizontal scroll field forward 1 line. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 129 | REQ_SFIRST_FIELD Move to the sorted first field. |
| 130 | REQ_SLAST_FIELD Move to the sorted last field. |
| 131 | REQ_SNEXT_FIELD Move to the sorted next field. |
| 132 | REQ_SPREV_FIELD Move to the sorted previous field. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 133 | REQ_UP_CHAR Move up in field. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 134 | REQ_UP_FIELD Move up to a field. |
| 135 | REQ_VALIDATION Validate field. |
| 136 | .TE |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 137 | .PP |
| 138 | If the second argument is a printable character, the driver places it |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 139 | in the current position in the current field. |
| 140 | If it is one of the forms |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 141 | requests listed above, that request is executed. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 142 | .SS "Field Validation" |
| 143 | The form library makes updates to the window associated |
| 144 | with form fields rather than directly to the field buffers. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 145 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 146 | The form driver provides low-level control over updates to the form fields. |
| 147 | The form driver also provides for validating modified fields |
| 148 | to ensure that the contents |
| 149 | meet whatever constraints an application may attach using \fBset_field_type\fP. |
| 150 | .PP |
| 151 | You can validate a field without making any changes to it using |
| 152 | \fBREQ_VALIDATION\fP. |
| 153 | The form driver also validates a field in these cases: |
| 154 | .bP |
| 155 | a call to \fBset_current_field\fP attempts to move to a different field. |
| 156 | .bP |
| 157 | a call to \fBset_current_page\fP attempts to move |
| 158 | to a different page of the form. |
| 159 | .bP |
| 160 | a request attempts to move to a different field. |
| 161 | .bP |
| 162 | a request attempts to move to a different page of the form. |
| 163 | .PP |
| 164 | In each case, the move fails if the field is invalid. |
| 165 | .PP |
| 166 | If the modified field is valid, the form driver copies the modified |
| 167 | data from the window associated with the field |
| 168 | to the field buffer. |
| 169 | .SS "Mouse Handling" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 170 | If the second argument is the KEY_MOUSE special key, the associated |
| 171 | mouse event is translated into one of the above pre-defined requests. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 172 | Currently only clicks in the user window (e.g., inside the form display |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 173 | area or the decoration window) are handled. |
| 174 | .PP |
| 175 | If you click above the display region of the form: |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 176 | .RS 3 |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 177 | .TP |
| 178 | a REQ_PREV_FIELD is generated for a single click, |
| 179 | .TP |
| 180 | a REQ_PREV_PAGE is generated for a double-click and |
| 181 | .TP |
| 182 | a REQ_FIRST_FIELD is generated for a triple-click. |
| 183 | .RE |
| 184 | .PP |
| 185 | If you click below the display region of the form: |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 186 | .RS 3 |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 187 | .TP |
| 188 | a REQ_NEXT_FIELD is generated for a single click, |
| 189 | .TP |
| 190 | a REQ_NEXT_PAGE is generated for a double-click and |
| 191 | .TP |
| 192 | a REQ_LAST_FIELD is generated for a triple-click. |
| 193 | .RE |
| 194 | .PP |
| 195 | If you click at an field inside the display area of the form: |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 196 | .RS 3 |
| 197 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 198 | the form cursor is positioned to that field. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 199 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 200 | If you double-click a field, |
| 201 | the form cursor is positioned to that field |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 202 | and \fBE_UNKNOWN_COMMAND\fP is returned. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 203 | This return value makes sense, |
| 204 | because a double click usually means that an field-specific action should |
| 205 | be returned. |
| 206 | It is exactly the purpose of this return value to signal that an |
| 207 | application specific command should be executed. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 208 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 209 | If a translation |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 210 | into a request was done, \fBform_driver\fP returns the result of this request. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 211 | .RE |
| 212 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 213 | If you clicked outside the user window |
| 214 | or the mouse event could not be translated |
| 215 | into a form request an \fBE_REQUEST_DENIED\fP is returned. |
| 216 | .SS "Application-defined Commands" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 217 | If the second argument is neither printable nor one of the above |
| 218 | pre-defined form requests, the driver assumes it is an application-specific |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 219 | command and returns \fBE_UNKNOWN_COMMAND\fP. Application-defined commands |
| 220 | should be defined relative to \fBMAX_COMMAND\fP, the maximum value of these |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 221 | pre-defined requests. |
| 222 | .SH RETURN VALUE |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 223 | \fBform_driver\fP returns one of the following error codes: |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 224 | .TP 5 |
| 225 | .B E_OK |
| 226 | The routine succeeded. |
| 227 | .TP 5 |
| 228 | .B E_BAD_ARGUMENT |
| 229 | Routine detected an incorrect or out-of-range argument. |
| 230 | .TP 5 |
| 231 | .B E_BAD_STATE |
| 232 | Routine was called from an initialization or termination function. |
| 233 | .TP 5 |
| 234 | .B E_NOT_POSTED |
| 235 | The form has not been posted. |
| 236 | .TP 5 |
| 237 | .B E_INVALID_FIELD |
| 238 | Contents of field is invalid. |
| 239 | .TP 5 |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 240 | .B E_NOT_CONNECTED |
| 241 | No fields are connected to the form. |
| 242 | .TP 5 |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 243 | .B E_REQUEST_DENIED |
| 244 | The form driver could not process the request. |
| 245 | .TP 5 |
| 246 | .B E_SYSTEM_ERROR |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 247 | System error occurred (see \fBerrno\fP(3)). |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 248 | .TP 5 |
| 249 | .B E_UNKNOWN_COMMAND |
| 250 | The form driver code saw an unknown request code. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 251 | .SH PORTABILITY |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 252 | These routines emulate the System V forms library. |
| 253 | They were not supported on |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 254 | Version 7 or BSD versions. |
| 255 | .SH AUTHORS |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 256 | Juergen Pfeifer. |
| 257 | Manual pages and adaptation for new curses by Eric S. Raymond. |
| 258 | .SH SEE ALSO |
| 259 | \fB\%curses\fP(3X), |
| 260 | \fB\%form\fP(3X), |
| 261 | \fB\%form_fieldtype\fP(3X), |
| 262 | \fB\%form_field_buffer\fP(3X), |
| 263 | \fB\%form_field_validation\fP(3X), |
| 264 | \fB\%form_variables\fP(3X), |
| 265 | \fB\%getch\fP(3X) |