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