]> ncurses.scripts.mit.edu Git - ncurses.git/blob - doc/html/man/form_fieldtype.3x.html
ncurses 6.2 - patch 20210619
[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 <B><A HREF="form_fieldtype.3X.html">form_fieldtype(3X)</A></B>                                          <B><A HREF="form_fieldtype.3X.html">form_fieldtype(3X)</A></B>
46
47
48
49
50 </PRE><H2><a name="h2-NAME">NAME</a></H2><PRE>
51        <B>form_fieldtype</B> - define validation-field types
52
53
54 </PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
55        <B>#include</B> <B>&lt;form.h&gt;</B>
56
57        <B>FIELDTYPE</B> <B>*new_fieldtype(</B>
58            <B>bool</B> <B>(*</B> <B>const</B> <I>field</I><B>_</B><I>check</I><B>)(FIELD</B> <B>*,</B> <B>const</B> <B>void</B> <B>*),</B>
59            <B>bool</B> <B>(*</B> <B>const</B> <I>char</I><B>_</B><I>check</I><B>)(int,</B> <B>const</B> <B>void</B> <B>*));</B>
60        <B>int</B> <B>free_fieldtype(FIELDTYPE</B> <B>*</B><I>fieldtype</I><B>);</B>
61
62        <B>int</B> <B>set_fieldtype_arg(</B>
63            <B>FIELDTYPE</B> <B>*</B><I>fieldtype</I><B>,</B>
64            <B>void</B> <B>*(*</B> <B>const</B> <I>make</I><B>_</B><I>arg</I><B>)(va_list</B> <B>*),</B>
65            <B>void</B> <B>*(*</B> <B>const</B> <I>copy</I><B>_</B><I>arg</I><B>)(const</B> <B>void</B> <B>*),</B>
66            <B>void</B>  <B>(*</B> <B>const</B> <I>free</I><B>_</B><I>arg</I><B>)(void</B> <B>*));</B>
67        <B>int</B> <B>set_fieldtype_choice(</B>
68            <B>FIELDTYPE</B> <B>*</B><I>fieldtype</I><B>,</B>
69            <B>bool</B> <B>(*</B> <B>const</B> <I>next</I><B>_</B><I>choice</I><B>)(FIELD</B> <B>*,</B> <B>const</B> <B>void</B> <B>*),</B>
70            <B>bool</B> <B>(*</B> <B>const</B> <I>prev</I><B>_</B><I>choice</I><B>)(FIELD</B> <B>*,</B> <B>const</B> <B>void</B> <B>*));</B>
71
72        <B>FIELDTYPE</B> <B>*link_fieldtype(FIELDTYPE</B> <B>*</B><I>type1</I><B>,</B>
73                                  <B>FIELDTYPE</B> <B>*</B><I>type2</I><B>);</B>
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  <B>new_fieldtype</B>  creates  a new field type usable for data
80        validation.  Its parameters are function pointers:
81
82        <I>field</I><B>_</B><I>check</I>
83             This function checks  the  validity  of  an  entered  data  string
84             whenever  the  user  attempts  to  leave  a  field.   It  has  two
85             arguments:
86
87             <B>o</B>   The  (FIELD  *)  argument  is  passed  in  so  the  validation
88                 predicate   can  see  the  field's  buffer,  sizes  and  other
89                 attributes.
90
91             <B>o</B>   The second argument  is  an  argument-block  structure,  about
92                 which more below.
93
94        <I>char</I><B>_</B><I>check</I>
95             This function validates input characters as they are entered.  The
96             form library passes it the character to be checked and  a  pointer
97             to an argument-block structure.
98
99
100 </PRE><H3><a name="h3-free_fieldtype">free_fieldtype</a></H3><PRE>
101        The  <B>free_fieldtype</B>  function  frees  the  space  allocated for a given
102        validation type by <B>new_fieldtype</B>.
103
104
105 </PRE><H3><a name="h3-set_fieldtype_arg">set_fieldtype_arg</a></H3><PRE>
106        The  function  <B>set_fieldtype_arg</B>  associates  three  storage-management
107        functions with a field type:
108
109        <I>make</I><B>_</B><I>arg</I>
110             This  function  is  automatically applied to the list of arguments
111             you give <B>set_field_type</B> when attaching validation to a field.   It
112             stores  the  arguments in an allocated argument-block object which
113             is used when validating input.
114
115        <I>copy</I><B>_</B><I>arg</I>
116             This function may be used by applications to copy argument-blocks.
117
118        <I>free</I><B>_</B><I>arg</I>
119             Frees an argument-block structure.
120
121        You must supply the <I>make</I><B>_</B><I>arg</I> function.  The other two are optional: you
122        may  supply NULL for them.  In this case, the form library assumes that
123        <I>make</I><B>_</B><I>arg</I> does not allocate memory but simply loads the argument into  a
124        single scalar value.
125
126
127 </PRE><H3><a name="h3-set_fieldtype_choice">set_fieldtype_choice</a></H3><PRE>
128        The  form  driver  requests  <B>REQ_NEXT_CHOICE</B> and <B>REQ_PREV_CHOICE</B> assume
129        that the possible values of a field form an ordered  set,  and  provide
130        the forms user with a way to move through the set.
131
132        The  <B>set_fieldtype_choice</B>  function  allows forms programmers to define
133        successor  and  predecessor  functions  for  the  field  type.    These
134        functions  take  the  field  pointer and an argument-block structure as
135        arguments.
136
137
138 </PRE><H3><a name="h3-link_fieldtype">link_fieldtype</a></H3><PRE>
139        The function <B>link_fieldtype</B> creates a new field type from the two given
140        types.  They are connected by an logical 'OR'.
141
142
143 </PRE><H2><a name="h2-RETURN-VALUE">RETURN VALUE</a></H2><PRE>
144        The  pointer-valued  routines  return  NULL  on  error.  They set <B>errno</B>
145        according to their success:
146
147        <B>E_OK</B> The routine succeeded.
148
149        <B>E_BAD_ARGUMENT</B>
150             Routine detected an incorrect or out-of-range argument.
151
152        <B>E_SYSTEM_ERROR</B>
153             System error occurred, e.g., malloc failure.
154
155        The integer-valued routines return one of the following codes on error:
156
157        <B>E_OK</B> The routine succeeded.
158
159        <B>E_BAD_ARGUMENT</B>
160             Routine detected an incorrect or out-of-range argument.
161
162        <B>E_CONNECTED</B>
163             The field is already connected to a form.
164
165        <B>E_CURRENT</B>
166             The field is the current field.
167
168        <B>E_SYSTEM_ERROR</B>
169             System error occurred (see <B>errno(3)</B>).
170
171
172 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
173        <B><A HREF="curses.3X.html">curses(3X)</A></B>, <B><A HREF="form.3X.html">form(3X)</A></B>, <B><A HREF="form_field_validation.3X.html">form_field_validation(3X)</A></B>.
174
175
176 </PRE><H2><a name="h2-NOTES">NOTES</a></H2><PRE>
177        The  header  file  <B>&lt;form.h&gt;</B>  automatically  includes  the  header  file
178        <B>&lt;curses.h&gt;</B>.
179
180
181 </PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
182        These  routines  emulate  the  System  V  forms library.  They were not
183        supported on Version 7 or BSD versions.
184
185
186 </PRE><H2><a name="h2-AUTHORS">AUTHORS</a></H2><PRE>
187        Juergen Pfeifer.  Manual pages and adaptation for new curses by Eric S.
188        Raymond.
189
190
191
192                                                             <B><A HREF="form_fieldtype.3X.html">form_fieldtype(3X)</A></B>
193 </PRE>
194 <div class="nav">
195 <ul>
196 <li><a href="#h2-NAME">NAME</a></li>
197 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
198 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a>
199 <ul>
200 <li><a href="#h3-new_fieldtype">new_fieldtype</a></li>
201 <li><a href="#h3-free_fieldtype">free_fieldtype</a></li>
202 <li><a href="#h3-set_fieldtype_arg">set_fieldtype_arg</a></li>
203 <li><a href="#h3-set_fieldtype_choice">set_fieldtype_choice</a></li>
204 <li><a href="#h3-link_fieldtype">link_fieldtype</a></li>
205 </ul>
206 </li>
207 <li><a href="#h2-RETURN-VALUE">RETURN VALUE</a></li>
208 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>
209 <li><a href="#h2-NOTES">NOTES</a></li>
210 <li><a href="#h2-PORTABILITY">PORTABILITY</a></li>
211 <li><a href="#h2-AUTHORS">AUTHORS</a></li>
212 </ul>
213 </div>
214 </BODY>
215 </HTML>