]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/form_driver.3x
292f93a5d30497f1eeb04e014df477a270b92a1d
[ncurses.git] / man / form_driver.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2017,2018 Free Software Foundation, Inc.              *
3 .\"                                                                          *
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:                 *
11 .\"                                                                          *
12 .\" The above copyright notice and this permission notice shall be included  *
13 .\" in all copies or substantial portions of the Software.                   *
14 .\"                                                                          *
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.                               *
22 .\"                                                                          *
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       *
26 .\" authorization.                                                           *
27 .\"***************************************************************************
28 .\"
29 .\" $Id: form_driver.3x,v 1.31 2018/07/28 22:08:59 tom Exp $
30 .TH form_driver 3X ""
31 .de bP
32 .ie n  .IP \(bu 4
33 .el    .IP \(bu 2
34 ..
35 .SH NAME
36 \fBform_driver\fR,
37 \fBform_driver_w\fR \- command-processing loop of the form system
38 .SH SYNOPSIS
39 \fB#include <form.h>\fR
40 .br
41 \fBint form_driver(FORM *\fP\fIform\fP\fB, int \fP\fIc\fP\fB);\fP
42 .br
43 \fBint form_driver_w(FORM *\fP\fIform\fP\fB, int \fP\fIc\fP\fB, wchar_t \fP\fIwch\fP\fB);\fP
44 .br
45 .SH DESCRIPTION
46 .SS form_driver
47 Once a form has been posted (displayed), you should funnel input events to it
48 through \fBform_driver\fR.  This routine has three major input cases:
49 .bP
50 The input is a form navigation request.
51 Navigation request codes are constants defined in \fB<form.h>\fP,
52 which are distinct from the key- and character codes returned
53 by \fBwgetch\fP(3X).
54 .bP
55 The input is a printable character.
56 Printable characters (which must be positive, less than 256) are
57 checked according to the program's locale settings.
58 .bP
59 The input is the KEY_MOUSE special key associated with an mouse event.
60 .SS form_driver_w
61 .PP
62 This extension simplifies the use of the forms library using wide characters.
63 The input is either a key code (a request) or a wide character
64 returned by \fBget_wch\fP(3X).
65 The type must be passed as well,
66 to enable the library to determine whether the parameter
67 is a wide character or a request.
68 .SS Form-driver requests
69 .PP
70 The form driver requests are as follows:
71 .TS
72 l l
73 _ _
74 l l.
75 \fIName\fR      \fIDescription\fR
76 REQ_BEG_FIELD   Move to the beginning of the field.
77 REQ_BEG_LINE    Move to the beginning of the line.
78 REQ_CLR_EOF     Clear to end of field from cursor.
79 REQ_CLR_EOL     Clear to end of line from cursor.
80 REQ_CLR_FIELD   Clear the entire field.
81 REQ_DEL_CHAR    Delete character at the cursor.
82 REQ_DEL_LINE    Delete line at the cursor.
83 REQ_DEL_PREV    Delete character before the cursor.
84 REQ_DEL_WORD    Delete blank-delimited word at the cursor.
85 REQ_DOWN_CHAR   Move down in the field.
86 REQ_DOWN_FIELD  Move down to a field.
87 REQ_END_FIELD   Move to the end of the field.
88 REQ_END_LINE    Move to the end of the line.
89 REQ_FIRST_FIELD Move to the first field.
90 REQ_FIRST_PAGE  Move to the first page.
91 REQ_INS_CHAR    Insert a blank at the cursor.
92 REQ_INS_LINE    Insert a blank line at the cursor.
93 REQ_INS_MODE    Enter insert mode.
94 REQ_LAST_FIELD  Move to the last field.
95 REQ_LAST_PAGE   Move to the last field.
96 REQ_LEFT_CHAR   Move left in the field.
97 REQ_LEFT_FIELD  Move left to a field.
98 REQ_NEW_LINE    Insert or overlay a new line.
99 REQ_NEXT_CHAR   Move to the next char.
100 REQ_NEXT_CHOICE Display next field choice.
101 REQ_NEXT_FIELD  Move to the next field.
102 REQ_NEXT_LINE   Move to the next line.
103 REQ_NEXT_PAGE   Move to the next page.
104 REQ_NEXT_PAGE   Move to the next page.
105 REQ_NEXT_WORD   Move to the next word.
106 REQ_OVL_MODE    Enter overlay mode.
107 REQ_PREV_CHAR   Move to the previous char.
108 REQ_PREV_CHOICE Display previous field choice.
109 REQ_PREV_FIELD  Move to the previous field.
110 REQ_PREV_LINE   Move to the previous line.
111 REQ_PREV_PAGE   Move to the previous page.
112 REQ_PREV_WORD   Move to the previous word.
113 REQ_RIGHT_CHAR  Move right in the field.
114 REQ_RIGHT_FIELD Move right to a field.
115 REQ_SCR_BCHAR   Scroll the field backward a character.
116 REQ_SCR_BHPAGE  Scroll the field backward half a page.
117 REQ_SCR_BLINE   Scroll the field backward a line.
118 REQ_SCR_BPAGE   Scroll the field backward a page.
119 REQ_SCR_FCHAR   Scroll the field forward a character.
120 REQ_SCR_FHPAGE  Scroll the field forward half a page.
121 REQ_SCR_FLINE   Scroll the field forward a line.
122 REQ_SCR_FPAGE   Scroll the field forward a page.
123 REQ_SCR_HBHALF  Horizontal scroll the field backward half a line.
124 REQ_SCR_HBLINE  Horizontal scroll the field backward a line.
125 REQ_SCR_HFHALF  Horizontal scroll the field forward half a line.
126 REQ_SCR_HFLINE  Horizontal scroll the field forward a line.
127 REQ_SFIRST_FIELD        Move to the sorted first field.
128 REQ_SLAST_FIELD Move to the sorted last field.
129 REQ_SNEXT_FIELD Move to the sorted next field.
130 REQ_SPREV_FIELD Move to the sorted previous field.
131 REQ_UP_CHAR     Move up in the field.
132 REQ_UP_FIELD    Move up to a field.
133 REQ_VALIDATION  Validate field.
134 .TE
135 .PP
136 If the second argument is a printable character, the driver places it
137 in the current position in the current field.
138 If it is one of the forms
139 requests listed above, that request is executed.
140 .SS Field validation
141 The form library makes updates to the window associated
142 with form fields rather than directly to the field buffers.
143 .PP
144 The form driver provides low-level control over updates to the form fields.
145 The form driver also provides for validating modified fields
146 to ensure that the contents
147 meet whatever constraints an application may attach using \fBset_field_type\fP.
148 .PP
149 .PP
150 You can validate a field without making any changes to it using
151 \fBREQ_VALIDATION\fP.
152 The form driver also validates a field in these cases:
153 .bP
154 a call to \fBset_current_field\fP attempts to move to a different field.
155 .bP
156 a call to \fBset_current_page\fP attempts to move
157 to a different page of the form.
158 .bP
159 a request attempts to move to a different field.
160 .bP
161 a request attempts to move to a different page of the form.
162 .PP
163 In each case, the move fails if the field is invalid.
164 .PP
165 If the modified field is valid, the form driver copies the modified
166 data from the window associated with the field
167 to the field buffer.
168 .SS Mouse handling
169 .PP
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.
172 Currently only clicks in the user window (e.g., inside the form display
173 area or the decoration window) are handled.
174 .PP
175 If you click above the display region of the form:
176 .RS 3
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:
186 .RS 3
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:
196 .RS 3
197 .bP
198 the form cursor is positioned to that field.
199 .bP
200 If you double-click a field,
201 the form cursor is positioned to that field
202 and \fBE_UNKNOWN_COMMAND\fR is returned.
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.
208 .bP
209 If a translation
210 into a request was done, \fBform_driver\fR returns the result of this request.
211 .RE
212 .PP
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\fR is returned.
216 .SS Application-defined commands
217 .PP
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\fR.  Application-defined commands
221 should be defined relative to \fBMAX_COMMAND\fR, the maximum value of these
222 pre-defined requests.
223 .SH RETURN VALUE
224 \fBform_driver\fR 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\fR).
249 .TP 5
250 .B E_UNKNOWN_COMMAND
251 The form driver code saw an unknown request code.
252 .
253 .SH SEE ALSO
254 \fBcurses\fR(3X),
255 \fBform\fR(3X),
256 \fBform_field_buffer\fR(3X),
257 \fBform_field_validation\fR(3X),
258 \fBform_fieldtype\fR(3X),
259 \fBform_variables\fR(3X),
260 \fBgetch\fR(3X).
261 .SH NOTES
262 The header file \fB<form.h>\fR automatically includes the header files
263 \fB<curses.h>\fR.
264 .SH PORTABILITY
265 These routines emulate the System V forms library.
266 They were not supported on
267 Version 7 or BSD versions.
268 .SH AUTHORS
269 Juergen Pfeifer.
270 Manual pages and adaptation for new curses by Eric S. Raymond.