xref: /netbsd-src/lib/libform/forms.3 (revision 5e4c038a45edbc7d63b7c2daa76e29f88b64a4e3)
1.\"	$NetBSD: forms.3,v 1.8 2002/05/20 15:00:11 blymn Exp $
2.\"
3.\" Copyright (c) 2001
4.\"	Brett Lymn - blymn@baea.com.au, brett_lymn@yahoo.com.au
5.\"
6.\" This code is donated to The NetBSD Foundation by the author.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\"    notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\"    notice, this list of conditions and the following disclaimer in the
15.\"    documentation and/or other materials provided with the distribution.
16.\" 3. The name of the Author may not be used to endorse or promote
17.\"    products derived from this software without specific prior written
18.\"    permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.Dd January 1, 2001
33.Dt FORMS 3
34.Os
35.Sh NAME
36.Nm form
37.Nd form library
38.Sh LIBRARY
39.Lb libform
40.Sh SYNOPSIS
41.Fd #include \*[Lt]form.h\*[Gt]
42.Sh DESCRIPTION
43The
44.Nm
45library provides a terminal independent form system using the
46.Xr curses 3
47library.  Before using the
48.Nm
49functions the terminal must be set up by
50.Xr curses 3
51using the
52.Fn initscr
53function or similar.  Programs using
54.Nm
55functions must be linked with the
56.Xr curses 3
57library
58.Fl lcurses .
59.Pp
60The
61.Nm
62library provides facilities for defining form fields, placing a form on the
63terminal screen, assign pre and post change operations and setting the
64attributes of both the form and its fields.
65.Ss Defining default attributes for forms and fields
66The
67.Nm
68library allows any settable attribute or option of both the form and field
69objects to be defined such that any new form or field automatically inherits
70the value as default.  Setting the default value will not affect any field or
71form that has already been created but will be applied to subsequent objects.
72To set the default attribute or option the set routine is passed a NULL
73pointer in the field or form parameter when calling the set routine.  The
74current default value can be retrieved by calling the get routine with a
75NULL pointer for the field or form parameter.
76.Pp
77.ta 20
78.nf
79.ft 3
80Form Routine Name      Manual Page Name
81.sp 0.5
82current_field		form_page(3)
83data_ahead		form_data(3
84data_behind		form_data(3)
85dup_field		form_field_new(3)
86dynamic_field_info	form_field_info(3)
87field_arg		form_field_validation(3)
88field_back		form_field_attributes(3)
89field_buffer		form_field_buffer(3)
90field_count		form_field(3)
91field_fore		form_field_attributes(3)
92field_index		form_page(3)
93field_info		form_field_info(3)
94field_init		form_hook(3)
95field_just		form_field_just(3)
96field_opts		form_field_opts(3)
97field_opts_off		form_field_opts(3)
98field_opts_on		form_field_opts(3)
99field_pad		form_field_attributes(3)
100field_status		form_field_buffer(3)
101field_term		form_hook(3)
102field_type		form_field_validation(3)
103field_userptr		form_field_userptr(3)
104form_driver		form_driver(3)
105form_fields		form_field(3)
106form_init		form_hook(3)
107form_max_page		form_page(3)
108form_opts		form_opts(3)
109form_opts_off		form_opts(3)
110form_opts_on		form_opts(3)
111form_page		form_page(3)
112form_sub		form_win(3)
113form_term		form_hook(3)
114form_userptr		form_userptr(3)
115form_win		form_win(3)
116free_field		form_field_new(3)
117free_fieldtype		form_fieldtype(3)
118free_form		form_new(3)
119link_field		form_field_new(3)
120link_fieldtype		form_fieldtype(3)
121move_field		form_field(3)
122new_field		form_field_new(3)
123new_fieldtype		form_fieldtype(3)
124new_form		form_new(3)
125new_page		form_new_page(3)
126pos_form_cursor		form_cursor(3)
127post_form		form_post(3)
128scale_form		form_win(3)
129set_current_field	form_page(3)
130set_field_back		form_field_attributes(3)
131set_field_buffer	form_field_buffer(3)
132set_field_fore		form_field_attributes(3)
133set_field_init		form_hook(3)
134set_field_just		form_field_just(3)
135set_field_opts		form_field_opts(3)
136set_field_pad		form_field_attributes(3)
137set_field_status	form_field_buffer(3)
138set_field_term		form_hook(3)
139set_field_type		form_field_validation(3)
140set_field_userptr	form_field_userptr(3)
141set_fieldtype_arg	form_fieldtype(3)
142set_fieldtype_choice	form_fieldtype(3)
143set_form_fields		form_field(3)
144set_form_init		form_hook(3)
145set_form_opts		form_opts(3)
146set_form_page		form_page(3)
147set_form_sub		form_win(3)
148set_form_term		form_hook(3)
149set_form_userptr	form_userptr(3)
150set_form_win		form_win(3)
151set_max_field		form_field_buffer(3)
152set_new_page		form_new_page(3)
153unpost_form		form_post(3)
154.fi
155.ft 1
156.br
157.ne 8
158.Sh RETURN VALUES
159Any function returning a string pointer will return NULL if an error
160occurs.  Functions returning an integer will return one of the
161following:
162.Pp
163.ta 20
164.nf
165E_OK			The function was successful
166E_SYSTEM_ERROR		There was a system error during the call.
167E_BAD_ARGUMENT		One or more of the arguments passed to the function
168			was incorrect.
169E_POSTED		The form is already posted.
170E_CONNECTED		An field was already connected to a form.
171E_BAD_STATE		The function was called from within an initialisation
172			or termination routine.
173E_NO_ROOM		The form does not fit within the subwindow.
174E_NOT_POSTED		The form is not posted
175E_UNKNOWN_COMMAND	The form driver does not recognise the request
176			passed to it.
177E_NOT_SELECTABLE	The field could not be selected.
178E_NOT_CONNECTED		The field is not connected to a form.
179E_REQUEST_DENIED	The form driver could not process the request.
180E_INVALID_FIELD		The field is invalid.
181E_CURRENT		The field is the active one on the form.
182.fi
183.ft 1
184.br
185.ne 8
186.Sh SEE ALSO
187.Xr curses 3 ,
188.Xr menus 3
189.Sh NOTES
190This implementation of the forms library does depart in behaviour
191subtly from the original AT \*[Am] T implementation.  Some of the more
192notable departures are:
193.Pp
194.Bl -tag -width "circular fields" -compact
195.It field wrapping
196For multiline fields the data will be wrapped as it is entered, this
197does not happen in the AT\*[Am]T implementation.
198.It buffer 0
199In this implementation, the contents of buffer 0 are always current
200regardless of whether the field has been validated or not.
201.It circular fields
202In the AT\*[Am]T implementation fields are circular on a page, that is, a
203next field from the last field will go to the first field on the
204curent page.  In this implementation a next field request on the last
205field of a page will result in the forms library positioning the
206cursor on the first field of the next page.  If the field is the last
207field in the form then going to the next field will be denied, in the
208AT\*[Am]T it would result in the cursor being placed on the first field of
209the first page.
210.It buffer returns
211In this implementation only the data entered by the user in the form
212field will be returned, unlike the AT\*[Am]T library which would return the
213contents of the field padded to the size of the field with the pad
214character.
215.It The TAB character
216The handling of the TAB character in fields varies between
217implementations.  In ncurses attempting to set a field contents with a
218string containing a TAB will result in an error and will not allow a
219TAB to be entered into a field.  The AT\*[Am]T library statically
220converts tabs to the equivalent number of spaces when the field buffer
221is set but the form driver will not allow a TAB to be inserted into
222the field buffer.  This implementation allows TAB when setting the
223field buffer and also will allow TAB to be inserted into a field
224buffer via the form driver and correctly calculates the cursor
225position allowing for expansion of the TAB character.
226.El
227