blob: 4084eac08aaf5dded19ed599a0fe41ddddc2fc25 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301.\"***************************************************************************
Steve Kondikae271bc2015-11-15 02:50:53 +01002.\" Copyright (c) 1998-2010,2015 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05303.\" *
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.\"
Steve Kondikae271bc2015-11-15 02:50:53 +010029.\" $Id: form_driver.3x,v 1.24 2015/08/02 18:21:11 tom Exp $
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053030.TH form_driver 3X ""
Steve Kondikae271bc2015-11-15 02:50:53 +010031.de bP
32.IP \(bu 4
33..
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053034.SH NAME
Steve Kondikae271bc2015-11-15 02:50:53 +010035\fBform_driver\fR \- command-processing loop of the form system
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053036.SH SYNOPSIS
37\fB#include <form.h>\fR
38.br
Steve Kondikae271bc2015-11-15 02:50:53 +010039\fBint form_driver(FORM *\fP\fIform\fP\fB, int \fP\fIc\fP\fB);\fP
40.br
41\fBint form_driver_w(FORM *\fP\fIform\fP\fB, int \fP\fIc\fP\fB, wchar_t \fP\fIwch\fP\fB);\fP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053042.br
43.SH DESCRIPTION
Steve Kondikae271bc2015-11-15 02:50:53 +010044.SS form_driver
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053045Once a form has been posted (displayed), you should funnel input events to it
46through \fBform_driver\fR. This routine has three major input cases:
Steve Kondikae271bc2015-11-15 02:50:53 +010047.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053048The input is a form navigation request.
49Navigation request codes are constants defined in \fB<form.h>\fP,
Steve Kondikae271bc2015-11-15 02:50:53 +010050which are distinct from the key- and character codes returned by \fBwgetch\fP(3X).
51.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053052The input is a printable character.
53Printable characters (which must be positive, less than 256) are
54checked according to the program's locale settings.
Steve Kondikae271bc2015-11-15 02:50:53 +010055.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053056The input is the KEY_MOUSE special key associated with an mouse event.
Steve Kondikae271bc2015-11-15 02:50:53 +010057.SS form_driver_w
58.PP
59This extension simplifies the use of the forms library using wide characters.
60The input is either a key code (a request) or a wide character
61returned by \fBget_wch\fP(3X).
62The type must be passed as well,
63to enable the library to determine whether the parameter
64is a wide character or a request.
65.SS Form-driver requests
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053066.PP
67The form driver requests are as follows:
Steve Kondikae271bc2015-11-15 02:50:53 +010068.TS
69l l
70_ _ _
71l l.
72\fIName\fR \fIDescription\fR
73REQ_BEG_FIELD Move to the beginning of the field.
74REQ_BEG_LINE Move to the beginning of the line.
75REQ_CLR_EOF Clear to end of field from cursor.
76REQ_CLR_EOL Clear to end of line from cursor.
77REQ_CLR_FIELD Clear the entire field.
78REQ_DEL_CHAR Delete character at the cursor.
79REQ_DEL_LINE Delete line at the cursor.
80REQ_DEL_PREV Delete character before the cursor.
81REQ_DEL_WORD Delete blank-delimited word at the cursor.
82REQ_DOWN_CHAR Move down in the field.
83REQ_DOWN_FIELD Move down to a field.
84REQ_END_FIELD Move to the end of the field.
85REQ_END_LINE Move to the end of the line.
86REQ_FIRST_FIELD Move to the first field.
87REQ_FIRST_PAGE Move to the first page.
88REQ_INS_CHAR Insert a blank at the cursor.
89REQ_INS_LINE Insert a blank line at the cursor.
90REQ_INS_MODE Enter insert mode.
91REQ_LAST_FIELD Move to the last field.
92REQ_LAST_PAGE Move to the last field.
93REQ_LEFT_CHAR Move left in the field.
94REQ_LEFT_FIELD Move left to a field.
95REQ_NEW_LINE Insert or overlay a new line.
96REQ_NEXT_CHAR Move to the next char.
97REQ_NEXT_CHOICE Display next field choice.
98REQ_NEXT_FIELD Move to the next field.
99REQ_NEXT_LINE Move to the next line.
100REQ_NEXT_PAGE Move to the next page.
101REQ_NEXT_PAGE Move to the next page.
102REQ_NEXT_WORD Move to the next word.
103REQ_OVL_MODE Enter overlay mode.
104REQ_PREV_CHAR Move to the previous char.
105REQ_PREV_CHOICE Display previous field choice.
106REQ_PREV_FIELD Move to the previous field.
107REQ_PREV_LINE Move to the previous line.
108REQ_PREV_PAGE Move to the previous page.
109REQ_PREV_WORD Move to the previous word.
110REQ_RIGHT_CHAR Move right in the field.
111REQ_RIGHT_FIELD Move right to a field.
112REQ_SCR_BCHAR Scroll the field backward a character.
113REQ_SCR_BHPAGE Scroll the field backward half a page.
114REQ_SCR_BLINE Scroll the field backward a line.
115REQ_SCR_BPAGE Scroll the field backward a page.
116REQ_SCR_FCHAR Scroll the field forward a character.
117REQ_SCR_FHPAGE Scroll the field forward half a page.
118REQ_SCR_FLINE Scroll the field forward a line.
119REQ_SCR_FPAGE Scroll the field forward a page.
120REQ_SCR_HBHALF Horizontal scroll the field backward half a line.
121REQ_SCR_HBLINE Horizontal scroll the field backward a line.
122REQ_SCR_HFHALF Horizontal scroll the field forward half a line.
123REQ_SCR_HFLINE Horizontal scroll the field forward a line.
124REQ_SFIRST_FIELD Move to the sorted first field.
125REQ_SLAST_FIELD Move to the sorted last field.
126REQ_SNEXT_FIELD Move to the sorted next field.
127REQ_SPREV_FIELD Move to the sorted previous field.
128REQ_UP_CHAR Move up in the field.
129REQ_UP_FIELD Move up to a field.
130REQ_VALIDATION Validate field.
131.TE
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530132.PP
133If the second argument is a printable character, the driver places it
134in the current position in the current field. If it is one of the forms
135requests listed above, that request is executed.
Steve Kondikae271bc2015-11-15 02:50:53 +0100136.SS Mouse handling
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530137.PP
138If the second argument is the KEY_MOUSE special key, the associated
139mouse event is translated into one of the above pre-defined requests.
Steve Kondikae271bc2015-11-15 02:50:53 +0100140Currently only clicks in the user window (e.g., inside the form display
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530141area or the decoration window) are handled.
142.PP
143If you click above the display region of the form:
Steve Kondikae271bc2015-11-15 02:50:53 +0100144.RS 3
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530145.TP
146a REQ_PREV_FIELD is generated for a single click,
147.TP
148a REQ_PREV_PAGE is generated for a double-click and
149.TP
150a REQ_FIRST_FIELD is generated for a triple-click.
151.RE
152.PP
153If you click below the display region of the form:
Steve Kondikae271bc2015-11-15 02:50:53 +0100154.RS 3
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530155.TP
156a REQ_NEXT_FIELD is generated for a single click,
157.TP
158a REQ_NEXT_PAGE is generated for a double-click and
159.TP
160a REQ_LAST_FIELD is generated for a triple-click.
161.RE
162.PP
163If you click at an field inside the display area of the form:
Steve Kondikae271bc2015-11-15 02:50:53 +0100164.RS 3
165.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530166the form cursor is positioned to that field.
Steve Kondikae271bc2015-11-15 02:50:53 +0100167.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530168If you double-click a field,
169the form cursor is positioned to that field
170and \fBE_UNKNOWN_COMMAND\fR is returned.
171This return value makes sense,
172because a double click usually means that an field-specific action should
173be returned.
174It is exactly the purpose of this return value to signal that an
175application specific command should be executed.
Steve Kondikae271bc2015-11-15 02:50:53 +0100176.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530177If a translation
178into a request was done, \fBform_driver\fR returns the result of this request.
179.RE
180.PP
181If you clicked outside the user window or the mouse event could not be translated
182into a form request an \fBE_REQUEST_DENIED\fR is returned.
Steve Kondikae271bc2015-11-15 02:50:53 +0100183.SS Application-defined commands
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530184.PP
185If the second argument is neither printable nor one of the above
186pre-defined form requests, the driver assumes it is an application-specific
187command and returns \fBE_UNKNOWN_COMMAND\fR. Application-defined commands
188should be defined relative to \fBMAX_COMMAND\fR, the maximum value of these
189pre-defined requests.
190.SH RETURN VALUE
191\fBform_driver\fR returns one of the following error codes:
192.TP 5
193.B E_OK
194The routine succeeded.
195.TP 5
196.B E_BAD_ARGUMENT
197Routine detected an incorrect or out-of-range argument.
198.TP 5
199.B E_BAD_STATE
200Routine was called from an initialization or termination function.
201.TP 5
202.B E_NOT_POSTED
203The form has not been posted.
204.TP 5
205.B E_INVALID_FIELD
206Contents of field is invalid.
207.TP 5
208.B E_REQUEST_DENIED
209The form driver could not process the request.
210.TP 5
211.B E_SYSTEM_ERROR
212System error occurred (see \fBerrno\fR).
213.TP 5
214.B E_UNKNOWN_COMMAND
215The form driver code saw an unknown request code.
216.
217.SH SEE ALSO
218\fBcurses\fR(3X),
219\fBform\fR(3X),
Steve Kondikae271bc2015-11-15 02:50:53 +0100220\fBform_variables\fR(3X),
221\fBgetch\fR(3X).
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530222.SH NOTES
223The header file \fB<form.h>\fR automatically includes the header files
224\fB<curses.h>\fR.
225.SH PORTABILITY
226These routines emulate the System V forms library. They were not supported on
227Version 7 or BSD versions.
228.SH AUTHORS
229Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
230S. Raymond.