]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/form_fieldtype.3x
ncurses 6.4 - patch 20240323
[ncurses.git] / man / form_fieldtype.3x
1 .\"***************************************************************************
2 .\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
3 .\" Copyright 1998-2006,2010 Free Software Foundation, Inc.                  *
4 .\"                                                                          *
5 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
6 .\" copy of this software and associated documentation files (the            *
7 .\" "Software"), to deal in the Software without restriction, including      *
8 .\" without limitation the rights to use, copy, modify, merge, publish,      *
9 .\" distribute, distribute with modifications, sublicense, and/or sell       *
10 .\" copies of the Software, and to permit persons to whom the Software is    *
11 .\" furnished to do so, subject to the following conditions:                 *
12 .\"                                                                          *
13 .\" The above copyright notice and this permission notice shall be included  *
14 .\" in all copies or substantial portions of the Software.                   *
15 .\"                                                                          *
16 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23 .\"                                                                          *
24 .\" Except as contained in this notice, the name(s) of the above copyright   *
25 .\" holders shall not be used in advertising or otherwise to promote the     *
26 .\" sale, use or other dealings in this Software without prior written       *
27 .\" authorization.                                                           *
28 .\"***************************************************************************
29 .\"
30 .\" $Id: form_fieldtype.3x,v 1.46 2024/03/16 15:35:01 tom Exp $
31 .TH form_fieldtype 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
32 .de bP
33 .ie n  .IP \(bu 4
34 .el    .IP \(bu 2
35 ..
36 .SH NAME
37 \fBform_fieldtype\fP \-
38 define validation-field types
39 .SH SYNOPSIS
40 .nf
41 \fB#include <form.h>
42 .PP
43 \fBFIELDTYPE *new_fieldtype(
44     \fBbool (* const \fIfield_check\fB)(FIELD *, const void *),\fR
45     \fBbool (* const \fIchar_check\fB)(int, const void *));\fR
46 \fBint free_fieldtype(FIELDTYPE *\fIfieldtype\fB);\fR
47 .PP
48 \fBint set_fieldtype_arg(\fP
49     \fBFIELDTYPE *\fIfieldtype\fB,\fR
50     \fBvoid *(* const \fImake_arg\fB)(va_list *),\fR
51     \fBvoid *(* const \fIcopy_arg\fB)(const void *),\fR
52     \fBvoid  (* const \fIfree_arg\fB)(void *));\fR
53 \fBint set_fieldtype_choice(\fP
54     \fBFIELDTYPE *\fIfieldtype\fB,\fR
55     \fBbool (* const \fInext_choice\fB)(FIELD *, const void *),\fR
56     \fBbool (* const \fIprev_choice\fB)(FIELD *, const void *));\fR
57 .PP
58 \fBFIELDTYPE *link_fieldtype(FIELDTYPE *\fItype1\fB,\fR
59                           \fBFIELDTYPE *\fItype2\fB);\fR
60 .fi
61 .SH DESCRIPTION
62 .SS new_fieldtype
63 The function \fBnew_fieldtype\fP creates a new field type usable for data
64 validation.
65 Its parameters are function pointers:
66 .TP 5
67 \fIfield_check\fP
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\fP
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 The \fBfree_fieldtype\fP function
86 frees the space allocated for a given validation type by \fBnew_fieldtype\fP.
87 .SS set_fieldtype_arg
88 The function \fBset_fieldtype_arg\fP associates
89 three storage-management functions with a field type:
90 .TP 5
91 \fImake_arg\fP
92 This function is automatically applied to the
93 list of arguments you give \fBset_field_type\fP when attaching validation
94 to a field.
95 It stores the arguments in an allocated argument-block
96 object which is used when validating input.
97 .TP 5
98 \fIcopy_arg\fP
99 This function may be used by applications to copy argument-blocks.
100 .TP 5
101 \fIfree_arg\fP
102 Frees an argument-block structure.
103 .PP
104 You must supply the \fImake_arg\fP function.
105 The other two are optional: you may supply NULL for them.
106 In this case, the form library assumes
107 that \fImake_arg\fP does not allocate memory but simply loads the
108 argument into a single scalar value.
109 .SS set_fieldtype_choice
110 The form driver requests \fBREQ_NEXT_CHOICE\fP and \fBREQ_PREV_CHOICE\fP assume
111 that the possible values of a field form an ordered set, and provide the forms
112 user with a way to move through the set.
113 .PP
114 The \fBset_fieldtype_choice\fP
115 function allows forms programmers to define successor and predecessor functions
116 for the field type.
117 These functions take the field pointer and an
118 argument-block structure as arguments.
119 .SS link_fieldtype
120 The function \fBlink_fieldtype\fP creates
121 a new field type from the two given types.
122 They are connected by an logical 'OR'.
123 .SH RETURN VALUE
124 The pointer-valued routines return NULL on error.
125 They set \fBerrno\fP according to their success:
126 .TP 5
127 .B E_OK
128 The routine succeeded.
129 .TP 5
130 .B E_BAD_ARGUMENT
131 Routine detected an incorrect or out-of-range argument.
132 .TP 5
133 .B E_SYSTEM_ERROR
134 System error occurred, e.g., malloc failure.
135 .PP
136 The integer-valued routines return one of the following codes on
137 error:
138 .TP 5
139 .B E_OK
140 The routine succeeded.
141 .TP 5
142 .B E_BAD_ARGUMENT
143 Routine detected an incorrect or out-of-range argument.
144 .TP 5
145 .B E_CONNECTED
146 The field is already connected to a form.
147 .TP 5
148 .B E_CURRENT
149 The field is the current field.
150 .TP 5
151 .B E_SYSTEM_ERROR
152 System error occurred (see \fBerrno\fP(3)).
153 .SH PORTABILITY
154 These routines emulate the System V forms library.
155 They were not supported on
156 Version 7 or BSD versions.
157 .SH AUTHORS
158 Juergen Pfeifer.
159 Manual pages and adaptation for new curses by Eric S. Raymond.
160 .SH SEE ALSO
161 \fB\%curses\fP(3X),
162 \fB\%form\fP(3X),
163 \fB\%form_field_validation\fP(3X)