]> ncurses.scripts.mit.edu Git - ncurses.git/blob - doc/html/man/form_fieldtype.3x.html
ncurses 6.2 - patch 20201212
[ncurses.git] / doc / html / man / form_fieldtype.3x.html
1 <!-- 
2   * t
3   ****************************************************************************
4   * Copyright 2018-2019,2020 Thomas E. Dickey                                *
5   * Copyright 1998-2006,2010 Free Software Foundation, Inc.                  *
6   *                                                                          *
7   * Permission is hereby granted, free of charge, to any person obtaining a  *
8   * copy of this software and associated documentation files (the            *
9   * "Software"), to deal in the Software without restriction, including      *
10   * without limitation the rights to use, copy, modify, merge, publish,      *
11   * distribute, distribute with modifications, sublicense, and/or sell       *
12   * copies of the Software, and to permit persons to whom the Software is    *
13   * furnished to do so, subject to the following conditions:                 *
14   *                                                                          *
15   * The above copyright notice and this permission notice shall be included  *
16   * in all copies or substantial portions of the Software.                   *
17   *                                                                          *
18   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
19   * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
20   * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
21   * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
22   * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
23   * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
24   * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
25   *                                                                          *
26   * Except as contained in this notice, the name(s) of the above copyright   *
27   * holders shall not be used in advertising or otherwise to promote the     *
28   * sale, use or other dealings in this Software without prior written       *
29   * authorization.                                                           *
30   ****************************************************************************
31   * @Id: form_fieldtype.3x,v 1.28 2020/12/12 17:11:21 tom Exp @
32 -->
33 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
34 <HTML>
35 <HEAD>
36 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
37 <meta name="generator" content="Manpage converted by man2html - see https://invisible-island.net/scripts/readme.html#others_scripts">
38 <TITLE>form_fieldtype 3x</TITLE>
39 <link rel="author" href="mailto:bug-ncurses@gnu.org">
40 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
41 </HEAD>
42 <BODY>
43 <H1 class="no-header">form_fieldtype 3x</H1>
44 <PRE>
45 <STRONG><A HREF="form_fieldtype.3x.html">form_fieldtype(3x)</A></STRONG>                                          <STRONG><A HREF="form_fieldtype.3x.html">form_fieldtype(3x)</A></STRONG>
46
47
48
49
50 </PRE><H2><a name="h2-NAME">NAME</a></H2><PRE>
51        <STRONG>form_fieldtype</STRONG> - define validation-field types
52
53
54 </PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
55        <STRONG>#include</STRONG> <STRONG>&lt;form.h&gt;</STRONG>
56
57        <STRONG>FIELDTYPE</STRONG> <STRONG>*new_fieldtype(</STRONG>
58            <STRONG>bool</STRONG> <STRONG>(*</STRONG> <STRONG>const</STRONG> <EM>field</EM><STRONG>_</STRONG><EM>check</EM><STRONG>)(FIELD</STRONG> <STRONG>*,</STRONG> <STRONG>const</STRONG> <STRONG>void</STRONG> <STRONG>*),</STRONG>
59            <STRONG>bool</STRONG> <STRONG>(*</STRONG> <STRONG>const</STRONG> <EM>char</EM><STRONG>_</STRONG><EM>check</EM><STRONG>)(int,</STRONG> <STRONG>const</STRONG> <STRONG>void</STRONG> <STRONG>*));</STRONG>
60        <STRONG>int</STRONG> <STRONG>free_fieldtype(FIELDTYPE</STRONG> <STRONG>*</STRONG><EM>fieldtype</EM><STRONG>);</STRONG>
61
62        <STRONG>int</STRONG> <STRONG>set_fieldtype_arg(</STRONG>
63            <STRONG>FIELDTYPE</STRONG> <STRONG>*</STRONG><EM>fieldtype</EM><STRONG>,</STRONG>
64            <STRONG>void</STRONG> <STRONG>*(*</STRONG> <STRONG>const</STRONG> <EM>make</EM><STRONG>_</STRONG><EM>arg</EM><STRONG>)(va_list</STRONG> <STRONG>*),</STRONG>
65            <STRONG>void</STRONG> <STRONG>*(*</STRONG> <STRONG>const</STRONG> <EM>copy</EM><STRONG>_</STRONG><EM>arg</EM><STRONG>)(const</STRONG> <STRONG>void</STRONG> <STRONG>*),</STRONG>
66            <STRONG>void</STRONG>  <STRONG>(*</STRONG> <STRONG>const</STRONG> <EM>free</EM><STRONG>_</STRONG><EM>arg</EM><STRONG>)(void</STRONG> <STRONG>*));</STRONG>
67        <STRONG>int</STRONG> <STRONG>set_fieldtype_choice(</STRONG>
68            <STRONG>FIELDTYPE</STRONG> <STRONG>*</STRONG><EM>fieldtype</EM><STRONG>,</STRONG>
69            <STRONG>bool</STRONG> <STRONG>(*</STRONG> <STRONG>const</STRONG> <EM>next</EM><STRONG>_</STRONG><EM>choice</EM><STRONG>)(FIELD</STRONG> <STRONG>*,</STRONG> <STRONG>const</STRONG> <STRONG>void</STRONG> <STRONG>*),</STRONG>
70            <STRONG>bool</STRONG> <STRONG>(*</STRONG> <STRONG>const</STRONG> <EM>prev</EM><STRONG>_</STRONG><EM>choice</EM><STRONG>)(FIELD</STRONG> <STRONG>*,</STRONG> <STRONG>const</STRONG> <STRONG>void</STRONG> <STRONG>*));</STRONG>
71
72        <STRONG>FIELDTYPE</STRONG> <STRONG>*link_fieldtype(FIELDTYPE</STRONG> <STRONG>*</STRONG><EM>type1</EM><STRONG>,</STRONG>
73                                  <STRONG>FIELDTYPE</STRONG> <STRONG>*</STRONG><EM>type2</EM><STRONG>);</STRONG>
74
75
76 </PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE>
77
78 </PRE><H3><a name="h3-new_fieldtype">new_fieldtype</a></H3><PRE>
79        The  function  <STRONG>new_fieldtype</STRONG>  creates  a new field type usable for data
80        validation.  Its parameters are function pointers:
81
82        <EM>field</EM><STRONG>_</STRONG><EM>check</EM>
83             This function checks the validity of an entered data string  when-
84             ever the user attempts to leave a field.  It has two arguments:
85
86             <STRONG>o</STRONG>   The  (FIELD  *) argument is passed in so the validation predi-
87                 cate can see the field's buffer, sizes and other attributes.
88
89             <STRONG>o</STRONG>   The second argument  is  an  argument-block  structure,  about
90                 which more below.
91
92        <EM>char</EM><STRONG>_</STRONG><EM>check</EM>
93             This function validates input characters as they are entered.  The
94             form library passes it the character to be checked and  a  pointer
95             to an argument-block structure.
96
97
98 </PRE><H3><a name="h3-free_fieldtype">free_fieldtype</a></H3><PRE>
99        The <STRONG>free_fieldtype</STRONG> function frees the space allocated for a given vali-
100        dation type by <STRONG>new_fieldtype</STRONG>.
101
102
103 </PRE><H3><a name="h3-set_fieldtype_arg">set_fieldtype_arg</a></H3><PRE>
104        The  function  <STRONG>set_fieldtype_arg</STRONG>  associates  three  storage-management
105        functions with a field type:
106
107        <EM>make</EM><STRONG>_</STRONG><EM>arg</EM>
108             This  function  is  automatically applied to the list of arguments
109             you give <STRONG>set_field_type</STRONG> when attaching validation to a field.   It
110             stores  the  arguments in an allocated argument-block object which
111             is used when validating input.
112
113        <EM>copy</EM><STRONG>_</STRONG><EM>arg</EM>
114             This function may be used by applications to copy argument-blocks.
115
116        <EM>free</EM><STRONG>_</STRONG><EM>arg</EM>
117             Frees an argument-block structure.
118
119        You must supply the <EM>make</EM><STRONG>_</STRONG><EM>arg</EM> function.  The other two are optional: you
120        may  supply NULL for them.  In this case, the form library assumes that
121        <EM>make</EM><STRONG>_</STRONG><EM>arg</EM> does not allocate memory but simply loads the argument into  a
122        single scalar value.
123
124
125 </PRE><H3><a name="h3-set_fieldtype_choice">set_fieldtype_choice</a></H3><PRE>
126        The  form  driver  requests  <STRONG>REQ_NEXT_CHOICE</STRONG> and <STRONG>REQ_PREV_CHOICE</STRONG> assume
127        that the possible values of a field form an ordered  set,  and  provide
128        the forms user with a way to move through the set.
129
130        The  <STRONG>set_fieldtype_choice</STRONG>  function  allows forms programmers to define
131        successor and predecessor functions for the field  type.   These  func-
132        tions  take  the field pointer and an argument-block structure as argu-
133        ments.
134
135
136 </PRE><H3><a name="h3-link_fieldtype">link_fieldtype</a></H3><PRE>
137        The function <STRONG>link_fieldtype</STRONG> creates a new field type from the two given
138        types.  They are connected by an logical 'OR'.
139
140
141 </PRE><H2><a name="h2-RETURN-VALUE">RETURN VALUE</a></H2><PRE>
142        The  pointer-valued  routines  return  NULL  on  error.  They set <STRONG>errno</STRONG>
143        according to their success:
144
145        <STRONG>E_OK</STRONG> The routine succeeded.
146
147        <STRONG>E_BAD_ARGUMENT</STRONG>
148             Routine detected an incorrect or out-of-range argument.
149
150        <STRONG>E_SYSTEM_ERROR</STRONG>
151             System error occurred, e.g., malloc failure.
152
153        The integer-valued routines return one of the following codes on error:
154
155        <STRONG>E_OK</STRONG> The routine succeeded.
156
157        <STRONG>E_BAD_ARGUMENT</STRONG>
158             Routine detected an incorrect or out-of-range argument.
159
160        <STRONG>E_CONNECTED</STRONG>
161             The field is already connected to a form.
162
163        <STRONG>E_CURRENT</STRONG>
164             The field is the current field.
165
166        <STRONG>E_SYSTEM_ERROR</STRONG>
167             System error occurred (see <STRONG>errno(3)</STRONG>).
168
169
170 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
171        <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="form.3x.html">form(3x)</A></STRONG>, <STRONG><A HREF="form_field_validation.3x.html">form_field_validation(3x)</A></STRONG>.
172
173
174 </PRE><H2><a name="h2-NOTES">NOTES</a></H2><PRE>
175        The  header  file  <STRONG>&lt;form.h&gt;</STRONG>  automatically  includes  the  header  file
176        <STRONG>&lt;curses.h&gt;</STRONG>.
177
178
179 </PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
180        These  routines emulate the System V forms library.  They were not sup-
181        ported on Version 7 or BSD versions.
182
183
184 </PRE><H2><a name="h2-AUTHORS">AUTHORS</a></H2><PRE>
185        Juergen Pfeifer.  Manual pages and adaptation for new curses by Eric S.
186        Raymond.
187
188
189
190                                                             <STRONG><A HREF="form_fieldtype.3x.html">form_fieldtype(3x)</A></STRONG>
191 </PRE>
192 <div class="nav">
193 <ul>
194 <li><a href="#h2-NAME">NAME</a></li>
195 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
196 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a>
197 <ul>
198 <li><a href="#h3-new_fieldtype">new_fieldtype</a></li>
199 <li><a href="#h3-free_fieldtype">free_fieldtype</a></li>
200 <li><a href="#h3-set_fieldtype_arg">set_fieldtype_arg</a></li>
201 <li><a href="#h3-set_fieldtype_choice">set_fieldtype_choice</a></li>
202 <li><a href="#h3-link_fieldtype">link_fieldtype</a></li>
203 </ul>
204 </li>
205 <li><a href="#h2-RETURN-VALUE">RETURN VALUE</a></li>
206 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>
207 <li><a href="#h2-NOTES">NOTES</a></li>
208 <li><a href="#h2-PORTABILITY">PORTABILITY</a></li>
209 <li><a href="#h2-AUTHORS">AUTHORS</a></li>
210 </ul>
211 </div>
212 </BODY>
213 </HTML>