xref: /netbsd/lib/libform/forms.3 (revision c4a72b64)
1.\"	$NetBSD: forms.3,v 1.10 2002/10/01 19:15:17 wiz 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.
48Before using the
49.Nm
50functions the terminal must be set up by
51.Xr curses 3
52using the
53.Fn initscr
54function or similar.
55Programs using
56.Nm
57functions must be linked with the
58.Xr curses 3
59library
60.Fl lcurses .
61.Pp
62The
63.Nm
64library provides facilities for defining form fields, placing a form on the
65terminal screen, assign pre and post change operations and setting the
66attributes of both the form and its fields.
67.Ss Defining default attributes for forms and fields
68The
69.Nm
70library allows any settable attribute or option of both the form and field
71objects to be defined such that any new form or field automatically inherits
72the value as default.
73Setting the default value will not affect any field or
74form that has already been created but will be applied to subsequent objects.
75To set the default attribute or option the set routine is passed a NULL
76pointer in the field or form parameter when calling the set routine.
77The current default value can be retrieved by calling the get routine with a
78NULL pointer for the field or form parameter.
79.Pp
80.ta 20
81.nf
82.ft 3
83Form Routine Name      Manual Page Name
84.sp 0.5
85current_field		form_page(3)
86data_ahead		form_data(3
87data_behind		form_data(3)
88dup_field		form_field_new(3)
89dynamic_field_info	form_field_info(3)
90field_arg		form_field_validation(3)
91field_back		form_field_attributes(3)
92field_buffer		form_field_buffer(3)
93field_count		form_field(3)
94field_fore		form_field_attributes(3)
95field_index		form_page(3)
96field_info		form_field_info(3)
97field_init		form_hook(3)
98field_just		form_field_just(3)
99field_opts		form_field_opts(3)
100field_opts_off		form_field_opts(3)
101field_opts_on		form_field_opts(3)
102field_pad		form_field_attributes(3)
103field_status		form_field_buffer(3)
104field_term		form_hook(3)
105field_type		form_field_validation(3)
106field_userptr		form_field_userptr(3)
107form_driver		form_driver(3)
108form_fields		form_field(3)
109form_init		form_hook(3)
110form_max_page		form_page(3)
111form_opts		form_opts(3)
112form_opts_off		form_opts(3)
113form_opts_on		form_opts(3)
114form_page		form_page(3)
115form_sub		form_win(3)
116form_term		form_hook(3)
117form_userptr		form_userptr(3)
118form_win		form_win(3)
119free_field		form_field_new(3)
120free_fieldtype		form_fieldtype(3)
121free_form		form_new(3)
122link_field		form_field_new(3)
123link_fieldtype		form_fieldtype(3)
124move_field		form_field(3)
125new_field		form_field_new(3)
126new_fieldtype		form_fieldtype(3)
127new_form		form_new(3)
128new_page		form_new_page(3)
129pos_form_cursor		form_cursor(3)
130post_form		form_post(3)
131scale_form		form_win(3)
132set_current_field	form_page(3)
133set_field_back		form_field_attributes(3)
134set_field_buffer	form_field_buffer(3)
135set_field_fore		form_field_attributes(3)
136set_field_init		form_hook(3)
137set_field_just		form_field_just(3)
138set_field_opts		form_field_opts(3)
139set_field_pad		form_field_attributes(3)
140set_field_printf	form_field_buffer(3)
141set_field_status	form_field_buffer(3)
142set_field_term		form_hook(3)
143set_field_type		form_field_validation(3)
144set_field_userptr	form_field_userptr(3)
145set_fieldtype_arg	form_fieldtype(3)
146set_fieldtype_choice	form_fieldtype(3)
147set_form_fields		form_field(3)
148set_form_init		form_hook(3)
149set_form_opts		form_opts(3)
150set_form_page		form_page(3)
151set_form_sub		form_win(3)
152set_form_term		form_hook(3)
153set_form_userptr	form_userptr(3)
154set_form_win		form_win(3)
155set_max_field		form_field_buffer(3)
156set_new_page		form_new_page(3)
157unpost_form		form_post(3)
158.fi
159.ft 1
160.br
161.ne 8
162.Sh RETURN VALUES
163Any function returning a string pointer will return NULL if an error occurs.
164Functions returning an integer will return one of the following:
165.Pp
166.ta 20
167.nf
168E_OK			The function was successful
169E_SYSTEM_ERROR		There was a system error during the call.
170E_BAD_ARGUMENT		One or more of the arguments passed to the function
171			was incorrect.
172E_POSTED		The form is already posted.
173E_CONNECTED		An field was already connected to a form.
174E_BAD_STATE		The function was called from within an initialisation
175			or termination routine.
176E_NO_ROOM		The form does not fit within the subwindow.
177E_NOT_POSTED		The form is not posted
178E_UNKNOWN_COMMAND	The form driver does not recognise the request
179			passed to it.
180E_NOT_SELECTABLE	The field could not be selected.
181E_NOT_CONNECTED		The field is not connected to a form.
182E_REQUEST_DENIED	The form driver could not process the request.
183E_INVALID_FIELD		The field is invalid.
184E_CURRENT		The field is the active one on the form.
185.fi
186.ft 1
187.br
188.ne 8
189.Sh SEE ALSO
190.Xr curses 3 ,
191.Xr menus 3
192.Sh NOTES
193This implementation of the forms library does depart in behaviour
194subtly from the original AT \*[Am] T implementation.
195Some of the more notable departures are:
196.Pp
197.Bl -tag -width "circular fields" -compact
198.It field wrapping
199For multiline fields the data will be wrapped as it is entered, this
200does not happen in the AT\*[Am]T implementation.
201.It buffer 0
202In this implementation, the contents of buffer 0 are always current
203regardless of whether the field has been validated or not.
204.It circular fields
205In the AT\*[Am]T implementation fields are circular on a page, that is, a
206next field from the last field will go to the first field on the
207curent page.
208In this implementation a next field request on the last
209field of a page will result in the forms library positioning the
210cursor on the first field of the next page.
211If the field is the last
212field in the form then going to the next field will be denied, in the
213AT\*[Am]T it would result in the cursor being placed on the first field of
214the first page.
215.It buffer returns
216In this implementation only the data entered by the user in the form
217field will be returned, unlike the AT\*[Am]T library which would return the
218contents of the field padded to the size of the field with the pad
219character.
220.It The TAB character
221The handling of the TAB character in fields varies between
222implementations.
223In ncurses attempting to set a field contents with a
224string containing a TAB will result in an error and will not allow a
225TAB to be entered into a field.
226The AT\*[Am]T library statically
227converts tabs to the equivalent number of spaces when the field buffer
228is set but the form driver will not allow a TAB to be inserted into
229the field buffer.
230This implementation allows TAB when setting the
231field buffer and also will allow TAB to be inserted into a field
232buffer via the form driver and correctly calculates the cursor
233position allowing for expansion of the TAB character.
234.It set_field_printf
235This function is a NetBSD extension and must not be used in portable
236code.
237.El
238