2 .\"***************************************************************************
3 .\" Copyright 2018-2022,2023 Thomas E. Dickey *
4 .\" Copyright 1998-2006,2010 Free Software Foundation, Inc. *
6 .\" Permission is hereby granted, free of charge, to any person obtaining a *
7 .\" copy of this software and associated documentation files (the *
8 .\" "Software"), to deal in the Software without restriction, including *
9 .\" without limitation the rights to use, copy, modify, merge, publish, *
10 .\" distribute, distribute with modifications, sublicense, and/or sell *
11 .\" copies of the Software, and to permit persons to whom the Software is *
12 .\" furnished to do so, subject to the following conditions: *
14 .\" The above copyright notice and this permission notice shall be included *
15 .\" in all copies or substantial portions of the Software. *
17 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
25 .\" Except as contained in this notice, the name(s) of the above copyright *
26 .\" holders shall not be used in advertising or otherwise to promote the *
27 .\" sale, use or other dealings in this Software without prior written *
29 .\"***************************************************************************
31 .\" $Id: form_fieldtype.3x,v 1.38 2023/09/16 23:37:03 tom Exp $
32 .TH form_fieldtype 3X 2023-09-16 "ncurses 6.4" "Library calls"
38 \fBform_fieldtype\fP \-
39 define validation-field types
41 \fB#include <form.h>\fP
43 \fBFIELDTYPE *new_fieldtype(\fP
44 \fBbool (* const \fIfield_check\fB)(FIELD *, const void *),\fR
45 \fBbool (* const \fIchar_check\fB)(int, const void *));\fR
47 \fBint free_fieldtype(FIELDTYPE *\fIfieldtype\fB);\fR
49 \fBint set_fieldtype_arg(\fP
50 \fBFIELDTYPE *\fIfieldtype\fB,\fR
51 \fBvoid *(* const \fImake_arg\fB)(va_list *),\fR
52 \fBvoid *(* const \fIcopy_arg\fB)(const void *),\fR
53 \fBvoid (* const \fIfree_arg\fB)(void *));\fR
55 \fBint set_fieldtype_choice(\fP
56 \fBFIELDTYPE *\fIfieldtype\fB,\fR
57 \fBbool (* const \fInext_choice\fB)(FIELD *, const void *),\fR
58 \fBbool (* const \fIprev_choice\fB)(FIELD *, const void *));\fR
60 \fBFIELDTYPE *link_fieldtype(FIELDTYPE *\fItype1\fB,\fR
61 \fBFIELDTYPE *\fItype2\fB);\fR
64 The function \fBnew_fieldtype\fP creates a new field type usable for data
66 Its parameters are function pointers:
69 This function checks the
70 validity of an entered data string whenever the user attempts to leave a field.
74 The (FIELD *) argument is passed in so the validation predicate can see the
75 field's buffer, sizes and other attributes.
77 The second argument is an
78 argument-block structure, about which more below.
82 This function validates input characters as they are entered.
83 The form library passes it the character to be checked
84 and a pointer to an argument-block structure.
86 The \fBfree_fieldtype\fP function
87 frees the space allocated for a given validation type by \fBnew_fieldtype\fP.
89 The function \fBset_fieldtype_arg\fP associates
90 three storage-management functions with a field type:
93 This function is automatically applied to the
94 list of arguments you give \fBset_field_type\fP when attaching validation
96 It stores the arguments in an allocated argument-block
97 object which is used when validating input.
100 This function may be used by applications to copy argument-blocks.
103 Frees an argument-block structure.
105 You must supply the \fImake_arg\fP function.
106 The other two are optional: you may supply NULL for them.
107 In this case, the form library assumes
108 that \fImake_arg\fP does not allocate memory but simply loads the
109 argument into a single scalar value.
110 .SS set_fieldtype_choice
111 The form driver requests \fBREQ_NEXT_CHOICE\fP and \fBREQ_PREV_CHOICE\fP assume
112 that the possible values of a field form an ordered set, and provide the forms
113 user with a way to move through the set.
115 The \fBset_fieldtype_choice\fP
116 function allows forms programmers to define successor and predecessor functions
118 These functions take the field pointer and an
119 argument-block structure as arguments.
121 The function \fBlink_fieldtype\fP creates
122 a new field type from the two given types.
123 They are connected by an logical 'OR'.
125 The pointer-valued routines return NULL on error.
126 They set \fBerrno\fP according to their success:
129 The routine succeeded.
132 Routine detected an incorrect or out-of-range argument.
135 System error occurred, e.g., malloc failure.
137 The integer-valued routines return one of the following codes on
141 The routine succeeded.
144 Routine detected an incorrect or out-of-range argument.
147 The field is already connected to a form.
150 The field is the current field.
153 System error occurred (see \fBerrno\fP(3)).
157 \fBform_field_validation\fP(3X).
159 The header file \fB<form.h>\fP automatically includes the header file
162 These routines emulate the System V forms library.
163 They were not supported on
164 Version 7 or BSD versions.
167 Manual pages and adaptation for new curses by Eric S. Raymond.