1.\" $NetBSD: forms.3,v 1.9 2002/08/09 14:15:13 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_printf form_field_buffer(3) 138set_field_status form_field_buffer(3) 139set_field_term form_hook(3) 140set_field_type form_field_validation(3) 141set_field_userptr form_field_userptr(3) 142set_fieldtype_arg form_fieldtype(3) 143set_fieldtype_choice form_fieldtype(3) 144set_form_fields form_field(3) 145set_form_init form_hook(3) 146set_form_opts form_opts(3) 147set_form_page form_page(3) 148set_form_sub form_win(3) 149set_form_term form_hook(3) 150set_form_userptr form_userptr(3) 151set_form_win form_win(3) 152set_max_field form_field_buffer(3) 153set_new_page form_new_page(3) 154unpost_form form_post(3) 155.fi 156.ft 1 157.br 158.ne 8 159.Sh RETURN VALUES 160Any function returning a string pointer will return NULL if an error 161occurs. Functions returning an integer will return one of the 162following: 163.Pp 164.ta 20 165.nf 166E_OK The function was successful 167E_SYSTEM_ERROR There was a system error during the call. 168E_BAD_ARGUMENT One or more of the arguments passed to the function 169 was incorrect. 170E_POSTED The form is already posted. 171E_CONNECTED An field was already connected to a form. 172E_BAD_STATE The function was called from within an initialisation 173 or termination routine. 174E_NO_ROOM The form does not fit within the subwindow. 175E_NOT_POSTED The form is not posted 176E_UNKNOWN_COMMAND The form driver does not recognise the request 177 passed to it. 178E_NOT_SELECTABLE The field could not be selected. 179E_NOT_CONNECTED The field is not connected to a form. 180E_REQUEST_DENIED The form driver could not process the request. 181E_INVALID_FIELD The field is invalid. 182E_CURRENT The field is the active one on the form. 183.fi 184.ft 1 185.br 186.ne 8 187.Sh SEE ALSO 188.Xr curses 3 , 189.Xr menus 3 190.Sh NOTES 191This implementation of the forms library does depart in behaviour 192subtly from the original AT \*[Am] T implementation. Some of the more 193notable departures are: 194.Pp 195.Bl -tag -width "circular fields" -compact 196.It field wrapping 197For multiline fields the data will be wrapped as it is entered, this 198does not happen in the AT\*[Am]T implementation. 199.It buffer 0 200In this implementation, the contents of buffer 0 are always current 201regardless of whether the field has been validated or not. 202.It circular fields 203In the AT\*[Am]T implementation fields are circular on a page, that is, a 204next field from the last field will go to the first field on the 205curent page. In this implementation a next field request on the last 206field of a page will result in the forms library positioning the 207cursor on the first field of the next page. If the field is the last 208field in the form then going to the next field will be denied, in the 209AT\*[Am]T it would result in the cursor being placed on the first field of 210the first page. 211.It buffer returns 212In this implementation only the data entered by the user in the form 213field will be returned, unlike the AT\*[Am]T library which would return the 214contents of the field padded to the size of the field with the pad 215character. 216.It The TAB character 217The handling of the TAB character in fields varies between 218implementations. In ncurses attempting to set a field contents with a 219string containing a TAB will result in an error and will not allow a 220TAB to be entered into a field. The AT\*[Am]T library statically 221converts tabs to the equivalent number of spaces when the field buffer 222is set but the form driver will not allow a TAB to be inserted into 223the field buffer. This implementation allows TAB when setting the 224field buffer and also will allow TAB to be inserted into a field 225buffer via the form driver and correctly calculates the cursor 226position allowing for expansion of the TAB character. 227.It set_field_printf 228This function is a NetBSD extension and must not be used in portable 229code. 230.El 231