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