]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/form_fieldtype.3x
775d1f26480cad3660a75281284368a5679a8884
[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.22 2020/10/17 23:07:47 tom Exp $
32 .TH form_fieldtype 3X ""
33 .SH NAME
34 \fBform_fieldtype\fR \- define validation-field types
35 .SH SYNOPSIS
36 \fB#include <form.h>\fR
37 .sp
38 FIELDTYPE *new_fieldtype(
39     bool (* const field_check)(FIELD *, const void *),
40     bool (* const char_check)(int, const void *));
41 .br
42 int free_fieldtype(FIELDTYPE *fieldtype);
43 .sp
44 int set_fieldtype_arg(
45     FIELDTYPE *fieldtype,
46     void *(* const make_arg)(va_list *),
47     void *(* const copy_arg)(const void *),
48     void  (* const free_arg)(void *));
49 .br
50 int set_fieldtype_choice(
51     FIELDTYPE *fieldtype,
52     bool (* const next_choice)(FIELD *, const void *),
53     bool (* const prev_choice)(FIELD *, const void *));
54 .sp
55 FIELDTYPE *link_fieldtype(FIELDTYPE *type1,
56                           FIELDTYPE *type2);
57 .SH DESCRIPTION
58 The function \fBnew_fieldtype\fR creates a new field type usable for data
59 validation.
60 You supply it with \fIfield_check\fR, a predicate to check the
61 validity of an entered data string whenever the user attempts to leave a field.
62 The (FIELD *) argument is passed in so the validation predicate can see the
63 field's buffer, sizes and other attributes; the second argument is an
64 argument-block structure, about which more below.
65 .PP
66 You also supply \fBnew_fieldtype\fR with \fIchar_check\fR,
67 a function to validate input characters as they are entered; it will be passed
68 the character to be checked and a pointer to an argument-block structure.
69 .PP
70 The function \fBfree_fieldtype\fR frees the space allocated for a given
71 validation type.
72 .PP
73 The function \fBset_fieldtype_arg\fR associates
74 three storage-management functions with a field type.
75 The \fImake_arg\fR function is automatically applied to the
76 list of arguments you give \fBset_field_type\fR when attaching validation
77 to a field; its job is to bundle these into an allocated argument-block
78 object which can later be passed to validation predicated.
79 The other two hook arguments should copy and free argument-block structures.
80 They will be used by the forms-driver code.
81 You must supply the \fImake_arg\fR function,
82 the other two are optional, you may supply NULL for them.
83 In this case it is assumed
84 that \fImake_arg\fR does not allocate memory but simply loads the
85 argument into a single scalar value.
86 .PP
87 The function \fBlink_fieldtype\fR creates
88 a new field type from the two given types.
89 They are connected by an logical 'OR'.
90 .PP
91 The form driver requests \fBREQ_NEXT_CHOICE\fR and \fBREQ_PREV_CHOICE\fR assume
92 that the possible values of a field form an ordered set, and provide the forms
93 user with a way to move through the set.
94 The \fBset_fieldtype_choice\fR
95 function allows forms programmers to define successor and predecessor functions
96 for the field type.
97 These functions take the field pointer and an
98 argument-block structure as arguments.
99 .SH RETURN VALUE
100 The pointer-valued routines return NULL on error.
101 They set \fBerrno\fP according to their success:
102 .TP 5
103 .B E_OK
104 The routine succeeded.
105 .TP 5
106 .B E_BAD_ARGUMENT
107 Routine detected an incorrect or out-of-range argument.
108 .TP 5
109 .B E_SYSTEM_ERROR
110 System error occurred, e.g., malloc failure.
111 .PP
112 The integer-valued routines return one of the following codes on
113 error:
114 .TP 5
115 .B E_OK
116 The routine succeeded.
117 .TP 5
118 .B E_BAD_ARGUMENT
119 Routine detected an incorrect or out-of-range argument.
120 .TP 5
121 .B E_CONNECTED
122 The field is already connected to a form.
123 .TP 5
124 .B E_CURRENT
125 The field is the current field.
126 .TP 5
127 .B E_SYSTEM_ERROR
128 System error occurred (see \fBerrno\fR(3)).
129 .SH SEE ALSO
130 \fBcurses\fR(3X), \fBform\fR(3X).
131 .SH NOTES
132 The header file \fB<form.h>\fR automatically includes the header file
133 \fB<curses.h>\fR.
134 .PP
135 All of the \fB(char *)\fR arguments of these functions should actually be
136 \fB(void *)\fR.  The type has been left uncorrected for strict compatibility
137 with System V.
138 .SH PORTABILITY
139 These routines emulate the System V forms library.
140 They were not supported on
141 Version 7 or BSD versions.
142 .SH AUTHORS
143 Juergen Pfeifer.
144 Manual pages and adaptation for new curses by Eric S. Raymond.