blob: 882a49dd463471c0888ff8500fbf25062ac2384b [file] [log] [blame]
micky3879b9f5e72025-07-08 18:04:53 -04001'\" t
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05302.\"***************************************************************************
micky3879b9f5e72025-07-08 18:04:53 -04003.\" Copyright 2018-2023,2024 Thomas E. Dickey *
4.\" Copyright 1998-2016,2017 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05305.\" *
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.\"
micky3879b9f5e72025-07-08 18:04:53 -040031.\" $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 Kondikae271bc2015-11-15 02:50:53 +010033.de bP
micky3879b9f5e72025-07-08 18:04:53 -040034.ie n .IP \(bu 4
35.el .IP \(bu 2
Steve Kondikae271bc2015-11-15 02:50:53 +010036..
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053037.SH NAME
micky3879b9f5e72025-07-08 18:04:53 -040038\fBform_driver\fP,
39\fBform_driver_w\fP \-
40command-processing loop of the form system
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053041.SH SYNOPSIS
micky3879b9f5e72025-07-08 18:04:53 -040042.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 Kachhape6a01f52011-07-20 11:45:59 +053048.SH DESCRIPTION
Steve Kondikae271bc2015-11-15 02:50:53 +010049.SS form_driver
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053050Once a form has been posted (displayed), you should funnel input events to it
micky3879b9f5e72025-07-08 18:04:53 -040051through \fBform_driver\fP. This routine has three major input cases:
Steve Kondikae271bc2015-11-15 02:50:53 +010052.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053053The input is a form navigation request.
54Navigation request codes are constants defined in \fB<form.h>\fP,
micky3879b9f5e72025-07-08 18:04:53 -040055which are distinct from the key- and character codes returned
56by \fBwgetch\fP(3X).
Steve Kondikae271bc2015-11-15 02:50:53 +010057.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053058The input is a printable character.
59Printable characters (which must be positive, less than 256) are
60checked according to the program's locale settings.
Steve Kondikae271bc2015-11-15 02:50:53 +010061.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053062The input is the KEY_MOUSE special key associated with an mouse event.
Steve Kondikae271bc2015-11-15 02:50:53 +010063.SS form_driver_w
Steve Kondikae271bc2015-11-15 02:50:53 +010064This extension simplifies the use of the forms library using wide characters.
65The input is either a key code (a request) or a wide character
66returned by \fBget_wch\fP(3X).
67The type must be passed as well,
68to enable the library to determine whether the parameter
69is a wide character or a request.
micky3879b9f5e72025-07-08 18:04:53 -040070.SS "Form Driver Requests"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053071The form driver requests are as follows:
micky3879b9f5e72025-07-08 18:04:53 -040072.PP
Steve Kondikae271bc2015-11-15 02:50:53 +010073.TS
micky3879b9f5e72025-07-08 18:04:53 -040074Lb Lb
75Lb Lx.
76Name Description
77_
78REQ_BEG_FIELD Move to beginning of field.
79REQ_BEG_LINE Move to beginning of the line.
Steve Kondikae271bc2015-11-15 02:50:53 +010080REQ_CLR_EOF Clear to end of field from cursor.
81REQ_CLR_EOL Clear to end of line from cursor.
82REQ_CLR_FIELD Clear the entire field.
83REQ_DEL_CHAR Delete character at the cursor.
84REQ_DEL_LINE Delete line at the cursor.
85REQ_DEL_PREV Delete character before the cursor.
micky3879b9f5e72025-07-08 18:04:53 -040086REQ_DEL_WORD Delete blank-delimited word at cursor.
87REQ_DOWN_CHAR Move down in field.
Steve Kondikae271bc2015-11-15 02:50:53 +010088REQ_DOWN_FIELD Move down to a field.
micky3879b9f5e72025-07-08 18:04:53 -040089REQ_END_FIELD Move to the end of field.
Steve Kondikae271bc2015-11-15 02:50:53 +010090REQ_END_LINE Move to the end of the line.
91REQ_FIRST_FIELD Move to the first field.
92REQ_FIRST_PAGE Move to the first page.
93REQ_INS_CHAR Insert a blank at the cursor.
94REQ_INS_LINE Insert a blank line at the cursor.
95REQ_INS_MODE Enter insert mode.
96REQ_LAST_FIELD Move to the last field.
97REQ_LAST_PAGE Move to the last field.
micky3879b9f5e72025-07-08 18:04:53 -040098REQ_LEFT_CHAR Move left in field.
Steve Kondikae271bc2015-11-15 02:50:53 +010099REQ_LEFT_FIELD Move left to a field.
100REQ_NEW_LINE Insert or overlay a new line.
101REQ_NEXT_CHAR Move to the next char.
102REQ_NEXT_CHOICE Display next field choice.
103REQ_NEXT_FIELD Move to the next field.
104REQ_NEXT_LINE Move to the next line.
105REQ_NEXT_PAGE Move to the next page.
106REQ_NEXT_PAGE Move to the next page.
107REQ_NEXT_WORD Move to the next word.
108REQ_OVL_MODE Enter overlay mode.
109REQ_PREV_CHAR Move to the previous char.
110REQ_PREV_CHOICE Display previous field choice.
111REQ_PREV_FIELD Move to the previous field.
112REQ_PREV_LINE Move to the previous line.
113REQ_PREV_PAGE Move to the previous page.
114REQ_PREV_WORD Move to the previous word.
micky3879b9f5e72025-07-08 18:04:53 -0400115REQ_RIGHT_CHAR Move right in field.
Steve Kondikae271bc2015-11-15 02:50:53 +0100116REQ_RIGHT_FIELD Move right to a field.
micky3879b9f5e72025-07-08 18:04:53 -0400117REQ_SCR_BCHAR Scroll field backward 1 character.
118REQ_SCR_BHPAGE Scroll field backward \(12 page.
119REQ_SCR_BLINE Scroll field backward 1 line.
120REQ_SCR_BPAGE Scroll field backward 1 page.
121REQ_SCR_FCHAR Scroll field forward 1 character.
122REQ_SCR_FHPAGE Scroll field forward \(12 page.
123REQ_SCR_FLINE Scroll field forward 1 line.
124REQ_SCR_FPAGE Scroll field forward 1 page.
125REQ_SCR_HBHALF Horizontal scroll field backward \(12 line.
126REQ_SCR_HBLINE Horizontal scroll field backward 1 line.
127REQ_SCR_HFHALF Horizontal scroll field forward \(12 line.
128REQ_SCR_HFLINE Horizontal scroll field forward 1 line.
Steve Kondikae271bc2015-11-15 02:50:53 +0100129REQ_SFIRST_FIELD Move to the sorted first field.
130REQ_SLAST_FIELD Move to the sorted last field.
131REQ_SNEXT_FIELD Move to the sorted next field.
132REQ_SPREV_FIELD Move to the sorted previous field.
micky3879b9f5e72025-07-08 18:04:53 -0400133REQ_UP_CHAR Move up in field.
Steve Kondikae271bc2015-11-15 02:50:53 +0100134REQ_UP_FIELD Move up to a field.
135REQ_VALIDATION Validate field.
136.TE
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530137.PP
138If the second argument is a printable character, the driver places it
micky3879b9f5e72025-07-08 18:04:53 -0400139in the current position in the current field.
140If it is one of the forms
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530141requests listed above, that request is executed.
micky3879b9f5e72025-07-08 18:04:53 -0400142.SS "Field Validation"
143The form library makes updates to the window associated
144with form fields rather than directly to the field buffers.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530145.PP
micky3879b9f5e72025-07-08 18:04:53 -0400146The form driver provides low-level control over updates to the form fields.
147The form driver also provides for validating modified fields
148to ensure that the contents
149meet whatever constraints an application may attach using \fBset_field_type\fP.
150.PP
151You can validate a field without making any changes to it using
152\fBREQ_VALIDATION\fP.
153The form driver also validates a field in these cases:
154.bP
155a call to \fBset_current_field\fP attempts to move to a different field.
156.bP
157a call to \fBset_current_page\fP attempts to move
158to a different page of the form.
159.bP
160a request attempts to move to a different field.
161.bP
162a request attempts to move to a different page of the form.
163.PP
164In each case, the move fails if the field is invalid.
165.PP
166If the modified field is valid, the form driver copies the modified
167data from the window associated with the field
168to the field buffer.
169.SS "Mouse Handling"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530170If the second argument is the KEY_MOUSE special key, the associated
171mouse event is translated into one of the above pre-defined requests.
Steve Kondikae271bc2015-11-15 02:50:53 +0100172Currently only clicks in the user window (e.g., inside the form display
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530173area or the decoration window) are handled.
174.PP
175If you click above the display region of the form:
Steve Kondikae271bc2015-11-15 02:50:53 +0100176.RS 3
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530177.TP
178a REQ_PREV_FIELD is generated for a single click,
179.TP
180a REQ_PREV_PAGE is generated for a double-click and
181.TP
182a REQ_FIRST_FIELD is generated for a triple-click.
183.RE
184.PP
185If you click below the display region of the form:
Steve Kondikae271bc2015-11-15 02:50:53 +0100186.RS 3
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530187.TP
188a REQ_NEXT_FIELD is generated for a single click,
189.TP
190a REQ_NEXT_PAGE is generated for a double-click and
191.TP
192a REQ_LAST_FIELD is generated for a triple-click.
193.RE
194.PP
195If you click at an field inside the display area of the form:
Steve Kondikae271bc2015-11-15 02:50:53 +0100196.RS 3
197.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530198the form cursor is positioned to that field.
Steve Kondikae271bc2015-11-15 02:50:53 +0100199.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530200If you double-click a field,
201the form cursor is positioned to that field
micky3879b9f5e72025-07-08 18:04:53 -0400202and \fBE_UNKNOWN_COMMAND\fP is returned.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530203This return value makes sense,
204because a double click usually means that an field-specific action should
205be returned.
206It is exactly the purpose of this return value to signal that an
207application specific command should be executed.
Steve Kondikae271bc2015-11-15 02:50:53 +0100208.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530209If a translation
micky3879b9f5e72025-07-08 18:04:53 -0400210into a request was done, \fBform_driver\fP returns the result of this request.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530211.RE
212.PP
micky3879b9f5e72025-07-08 18:04:53 -0400213If you clicked outside the user window
214or the mouse event could not be translated
215into a form request an \fBE_REQUEST_DENIED\fP is returned.
216.SS "Application-defined Commands"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530217If the second argument is neither printable nor one of the above
218pre-defined form requests, the driver assumes it is an application-specific
micky3879b9f5e72025-07-08 18:04:53 -0400219command and returns \fBE_UNKNOWN_COMMAND\fP. Application-defined commands
220should be defined relative to \fBMAX_COMMAND\fP, the maximum value of these
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530221pre-defined requests.
222.SH RETURN VALUE
micky3879b9f5e72025-07-08 18:04:53 -0400223\fBform_driver\fP returns one of the following error codes:
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530224.TP 5
225.B E_OK
226The routine succeeded.
227.TP 5
228.B E_BAD_ARGUMENT
229Routine detected an incorrect or out-of-range argument.
230.TP 5
231.B E_BAD_STATE
232Routine was called from an initialization or termination function.
233.TP 5
234.B E_NOT_POSTED
235The form has not been posted.
236.TP 5
237.B E_INVALID_FIELD
238Contents of field is invalid.
239.TP 5
micky3879b9f5e72025-07-08 18:04:53 -0400240.B E_NOT_CONNECTED
241No fields are connected to the form.
242.TP 5
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530243.B E_REQUEST_DENIED
244The form driver could not process the request.
245.TP 5
246.B E_SYSTEM_ERROR
micky3879b9f5e72025-07-08 18:04:53 -0400247System error occurred (see \fBerrno\fP(3)).
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530248.TP 5
249.B E_UNKNOWN_COMMAND
250The form driver code saw an unknown request code.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530251.SH PORTABILITY
micky3879b9f5e72025-07-08 18:04:53 -0400252These routines emulate the System V forms library.
253They were not supported on
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530254Version 7 or BSD versions.
255.SH AUTHORS
micky3879b9f5e72025-07-08 18:04:53 -0400256Juergen Pfeifer.
257Manual 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)