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