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