]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/form_fieldtype.3x
ncurses 6.4 - patch 20230917
[ncurses.git] / man / form_fieldtype.3x
1 '\" t
2 .\"***************************************************************************
3 .\" Copyright 2018-2022,2023 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.38 2023/09/16 23:37:03 tom Exp $
32 .TH form_fieldtype 3X 2023-09-16 "ncurses 6.4" "Library calls"
33 .de bP
34 .ie n  .IP \(bu 4
35 .el    .IP \(bu 2
36 ..
37 .SH NAME
38 \fBform_fieldtype\fP \-
39 define validation-field types
40 .SH SYNOPSIS
41 \fB#include <form.h>\fP
42 .sp
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
46 .br
47 \fBint free_fieldtype(FIELDTYPE *\fIfieldtype\fB);\fR
48 .sp
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
54 .br
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
59 .sp
60 \fBFIELDTYPE *link_fieldtype(FIELDTYPE *\fItype1\fB,\fR
61                           \fBFIELDTYPE *\fItype2\fB);\fR
62 .SH DESCRIPTION
63 .SS new_fieldtype
64 The function \fBnew_fieldtype\fP creates a new field type usable for data
65 validation.
66 Its parameters are function pointers:
67 .TP 5
68 \fIfield_check\fP
69 This function checks the
70 validity of an entered data string whenever the user attempts to leave a field.
71 It has two arguments:
72 .RS
73 .bP
74 The (FIELD *) argument is passed in so the validation predicate can see the
75 field's buffer, sizes and other attributes.
76 .bP
77 The second argument is an
78 argument-block structure, about which more below.
79 .RE
80 .TP 5
81 \fIchar_check\fP
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.
85 .SS free_fieldtype
86 The \fBfree_fieldtype\fP function
87 frees the space allocated for a given validation type by \fBnew_fieldtype\fP.
88 .SS set_fieldtype_arg
89 The function \fBset_fieldtype_arg\fP associates
90 three storage-management functions with a field type:
91 .TP 5
92 \fImake_arg\fP
93 This function is automatically applied to the
94 list of arguments you give \fBset_field_type\fP when attaching validation
95 to a field.
96 It stores the arguments in an allocated argument-block
97 object which is used when validating input.
98 .TP 5
99 \fIcopy_arg\fP
100 This function may be used by applications to copy argument-blocks.
101 .TP 5
102 \fIfree_arg\fP
103 Frees an argument-block structure.
104 .PP
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.
114 .PP
115 The \fBset_fieldtype_choice\fP
116 function allows forms programmers to define successor and predecessor functions
117 for the field type.
118 These functions take the field pointer and an
119 argument-block structure as arguments.
120 .SS link_fieldtype
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'.
124 .SH RETURN VALUE
125 The pointer-valued routines return NULL on error.
126 They set \fBerrno\fP according to their success:
127 .TP 5
128 .B E_OK
129 The routine succeeded.
130 .TP 5
131 .B E_BAD_ARGUMENT
132 Routine detected an incorrect or out-of-range argument.
133 .TP 5
134 .B E_SYSTEM_ERROR
135 System error occurred, e.g., malloc failure.
136 .PP
137 The integer-valued routines return one of the following codes on
138 error:
139 .TP 5
140 .B E_OK
141 The routine succeeded.
142 .TP 5
143 .B E_BAD_ARGUMENT
144 Routine detected an incorrect or out-of-range argument.
145 .TP 5
146 .B E_CONNECTED
147 The field is already connected to a form.
148 .TP 5
149 .B E_CURRENT
150 The field is the current field.
151 .TP 5
152 .B E_SYSTEM_ERROR
153 System error occurred (see \fBerrno\fP(3)).
154 .SH SEE ALSO
155 \fBcurses\fP(3X),
156 \fBform\fP(3X),
157 \fBform_field_validation\fP(3X).
158 .SH NOTES
159 The header file \fB<form.h>\fP automatically includes the header file
160 \fB<curses.h>\fP.
161 .SH PORTABILITY
162 These routines emulate the System V forms library.
163 They were not supported on
164 Version 7 or BSD versions.
165 .SH AUTHORS
166 Juergen Pfeifer.
167 Manual pages and adaptation for new curses by Eric S. Raymond.