]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/form_fieldtype.3x
ncurses 6.4 - patch 20240414
[ncurses.git] / man / form_fieldtype.3x
1 '\" t
2 .\"***************************************************************************
3 .\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
4 .\" Copyright 1998-2006,2010 Free Software Foundation, Inc.                  *
5 .\"                                                                          *
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:                 *
13 .\"                                                                          *
14 .\" The above copyright notice and this permission notice shall be included  *
15 .\" in all copies or substantial portions of the Software.                   *
16 .\"                                                                          *
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.                               *
24 .\"                                                                          *
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       *
28 .\" authorization.                                                           *
29 .\"***************************************************************************
30 .\"
31 .\" $Id: form_fieldtype.3x,v 1.28 2020/12/12 17:11:21 tom Exp $
32 .de bP
33 .ie n  .IP \(bu 4
34 .el    .IP \(bu 2
35 ..
36 .TH form_fieldtype 3X ""
37 .SH NAME
38 \fBform_fieldtype\fR \- define validation-field types
39 .SH SYNOPSIS
40 \fB#include <form.h>\fR
41 .sp
42 \fBFIELDTYPE *new_fieldtype(\fP
43     \fBbool (* const \fP\fIfield_check\fP\fB)(FIELD *, const void *),\fP
44     \fBbool (* const \fP\fIchar_check\fP\fB)(int, const void *));\fP
45 .br
46 \fBint free_fieldtype(FIELDTYPE *\fP\fIfieldtype\fP\fB);\fP
47 .sp
48 \fBint set_fieldtype_arg(\fP
49     \fBFIELDTYPE *\fP\fIfieldtype\fP\fB,\fP
50     \fBvoid *(* const \fP\fImake_arg\fP\fB)(va_list *),\fP
51     \fBvoid *(* const \fP\fIcopy_arg\fP\fB)(const void *),\fP
52     \fBvoid  (* const \fP\fIfree_arg\fP\fB)(void *));\fP
53 .br
54 \fBint set_fieldtype_choice(\fP
55     \fBFIELDTYPE *\fP\fIfieldtype\fP\fB,\fP
56     \fBbool (* const \fP\fInext_choice\fP\fB)(FIELD *, const void *),\fP
57     \fBbool (* const \fP\fIprev_choice\fP\fB)(FIELD *, const void *));\fP
58 .sp
59 \fBFIELDTYPE *link_fieldtype(FIELDTYPE *\fP\fItype1\fP\fB,\fP
60                           \fBFIELDTYPE *\fP\fItype2\fP\fB);\fP
61 .SH DESCRIPTION
62 .SS new_fieldtype
63 The function \fBnew_fieldtype\fR creates a new field type usable for data
64 validation.
65 Its parameters are function pointers:
66 .TP 5
67 \fIfield_check\fR
68 This function checks the
69 validity of an entered data string whenever the user attempts to leave a field.
70 It has two arguments:
71 .RS
72 .bP
73 The (FIELD *) argument is passed in so the validation predicate can see the
74 field's buffer, sizes and other attributes.
75 .bP
76 The second argument is an
77 argument-block structure, about which more below.
78 .RE
79 .TP 5
80 \fIchar_check\fR
81 This function validates input characters as they are entered.
82 The form library passes it the character to be checked
83 and a pointer to an argument-block structure.
84 .SS free_fieldtype
85 .PP
86 The \fBfree_fieldtype\fR function
87 frees the space allocated for a given validation type by \fBnew_fieldtype\fP.
88 .SS set_fieldtype_arg
89 .PP
90 The function \fBset_fieldtype_arg\fR associates
91 three storage-management functions with a field type:
92 .TP 5
93 \fImake_arg\fR
94 This function is automatically applied to the
95 list of arguments you give \fBset_field_type\fR when attaching validation
96 to a field.
97 It stores the arguments in an allocated argument-block
98 object which is used when validating input.
99 .TP 5
100 \fIcopy_arg\fR
101 This function may be used by applications to copy argument-blocks.
102 .TP 5
103 \fIfree_arg\fR
104 Frees an argument-block structure.
105 .PP
106 You must supply the \fImake_arg\fR function.
107 The other two are optional: you may supply NULL for them.
108 In this case, the form library assumes
109 that \fImake_arg\fR does not allocate memory but simply loads the
110 argument into a single scalar value.
111 .SS set_fieldtype_choice
112 .PP
113 The form driver requests \fBREQ_NEXT_CHOICE\fR and \fBREQ_PREV_CHOICE\fR assume
114 that the possible values of a field form an ordered set, and provide the forms
115 user with a way to move through the set.
116 .PP
117 The \fBset_fieldtype_choice\fR
118 function allows forms programmers to define successor and predecessor functions
119 for the field type.
120 These functions take the field pointer and an
121 argument-block structure as arguments.
122 .SS link_fieldtype
123 .PP
124 The function \fBlink_fieldtype\fR creates
125 a new field type from the two given types.
126 They are connected by an logical 'OR'.
127 .SH RETURN VALUE
128 The pointer-valued routines return NULL on error.
129 They set \fBerrno\fP according to their success:
130 .TP 5
131 .B E_OK
132 The routine succeeded.
133 .TP 5
134 .B E_BAD_ARGUMENT
135 Routine detected an incorrect or out-of-range argument.
136 .TP 5
137 .B E_SYSTEM_ERROR
138 System error occurred, e.g., malloc failure.
139 .PP
140 The integer-valued routines return one of the following codes on
141 error:
142 .TP 5
143 .B E_OK
144 The routine succeeded.
145 .TP 5
146 .B E_BAD_ARGUMENT
147 Routine detected an incorrect or out-of-range argument.
148 .TP 5
149 .B E_CONNECTED
150 The field is already connected to a form.
151 .TP 5
152 .B E_CURRENT
153 The field is the current field.
154 .TP 5
155 .B E_SYSTEM_ERROR
156 System error occurred (see \fBerrno\fR(3)).
157 .SH SEE ALSO
158 \fBcurses\fR(3X),
159 \fBform\fR(3X),
160 \fBform_field_validation\fR(3X).
161 .SH NOTES
162 The header file \fB<form.h>\fR automatically includes the header file
163 \fB<curses.h>\fR.
164 .SH PORTABILITY
165 These routines emulate the System V forms library.
166 They were not supported on
167 Version 7 or BSD versions.
168 .SH AUTHORS
169 Juergen Pfeifer.
170 Manual pages and adaptation for new curses by Eric S. Raymond.