fm/ipmitopo: fix 64-bit compilation
[unleashed.git] / contrib / ncurses / form / form.h
blobf11807f593df6c35a04c9fb2d18a91a338fe2f30
1 /****************************************************************************
2 * Copyright (c) 1998-2016,2017 Free Software Foundation, Inc. *
3 * *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
11 * *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
14 * *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
22 * *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
26 * authorization. *
27 ****************************************************************************/
29 /****************************************************************************
30 * Author: Juergen Pfeifer, 1995,1997 *
31 ****************************************************************************/
33 /* $Id: form.h,v 0.27 2017/02/11 16:35:42 tom Exp $ */
35 #ifndef FORM_H
36 #define FORM_H
37 /* *INDENT-OFF*/
39 #include <curses.h>
40 #include <eti.h>
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
46 #ifndef FORM_PRIV_H
47 typedef void *FIELD_CELL;
48 #endif
50 #ifndef NCURSES_FIELD_INTERNALS
51 #define NCURSES_FIELD_INTERNALS /* nothing */
52 #endif
54 typedef int Form_Options;
55 typedef int Field_Options;
57 /**********
58 * _PAGE *
59 **********/
61 typedef struct pagenode
62 #if !NCURSES_OPAQUE_FORM
64 short pmin; /* index of first field on page */
65 short pmax; /* index of last field on page */
66 short smin; /* index of top leftmost field on page */
67 short smax; /* index of bottom rightmost field on page */
69 #endif /* !NCURSES_OPAQUE_FORM */
70 _PAGE;
72 /**********
73 * FIELD *
74 **********/
76 typedef struct fieldnode
77 #if 1 /* not yet: !NCURSES_OPAQUE_FORM */
79 unsigned short status; /* flags */
80 short rows; /* size in rows */
81 short cols; /* size in cols */
82 short frow; /* first row */
83 short fcol; /* first col */
84 int drows; /* dynamic rows */
85 int dcols; /* dynamic cols */
86 int maxgrow; /* maximum field growth */
87 int nrow; /* off-screen rows */
88 short nbuf; /* additional buffers */
89 short just; /* justification */
90 short page; /* page on form */
91 short index; /* into form -> field */
92 int pad; /* pad character */
93 chtype fore; /* foreground attribute */
94 chtype back; /* background attribute */
95 Field_Options opts; /* options */
96 struct fieldnode * snext; /* sorted order pointer */
97 struct fieldnode * sprev; /* sorted order pointer */
98 struct fieldnode * link; /* linked field chain */
99 struct formnode * form; /* containing form */
100 struct typenode * type; /* field type */
101 void * arg; /* argument for type */
102 FIELD_CELL * buf; /* field buffers */
103 void * usrptr; /* user pointer */
105 * The wide-character configuration requires extra information. Because
106 * there are existing applications that manipulate the members of FIELD
107 * directly, we cannot make the struct opaque, except by changing the ABI.
108 * Offsets of members up to this point are the same in the narrow- and
109 * wide-character configuration. But note that the type of buf depends on
110 * the configuration, and is made opaque for that reason.
112 NCURSES_FIELD_INTERNALS
114 #endif /* NCURSES_OPAQUE_FORM */
115 FIELD;
118 /*********
119 * FORM *
120 *********/
122 typedef struct formnode
123 #if 1 /* not yet: !NCURSES_OPAQUE_FORM */
125 unsigned short status; /* flags */
126 short rows; /* size in rows */
127 short cols; /* size in cols */
128 int currow; /* current row in field window */
129 int curcol; /* current col in field window */
130 int toprow; /* in scrollable field window */
131 int begincol; /* in horiz. scrollable field */
132 short maxfield; /* number of fields */
133 short maxpage; /* number of pages */
134 short curpage; /* index into page */
135 Form_Options opts; /* options */
136 WINDOW * win; /* window */
137 WINDOW * sub; /* subwindow */
138 WINDOW * w; /* window for current field */
139 FIELD ** field; /* field [maxfield] */
140 FIELD * current; /* current field */
141 _PAGE * page; /* page [maxpage] */
142 void * usrptr; /* user pointer */
144 void (*forminit)(struct formnode *);
145 void (*formterm)(struct formnode *);
146 void (*fieldinit)(struct formnode *);
147 void (*fieldterm)(struct formnode *);
150 #endif /* !NCURSES_OPAQUE_FORM */
151 FORM;
154 /**************
155 * FIELDTYPE *
156 **************/
158 typedef struct typenode
159 #if !NCURSES_OPAQUE_FORM
161 unsigned short status; /* flags */
162 long ref; /* reference count */
163 struct typenode * left; /* ptr to operand for | */
164 struct typenode * right; /* ptr to operand for | */
166 void* (*makearg)(va_list *); /* make fieldtype arg */
167 void* (*copyarg)(const void *); /* copy fieldtype arg */
168 void (*freearg)(void *); /* free fieldtype arg */
170 #if NCURSES_INTEROP_FUNCS
171 union {
172 bool (*ofcheck)(FIELD *,const void *); /* field validation */
173 bool (*gfcheck)(FORM*,FIELD *,const void*); /* generic field validation */
174 } fieldcheck;
175 union {
176 bool (*occheck)(int,const void *); /* character validation */
177 bool (*gccheck)(int,FORM*,
178 FIELD*,const void*); /* generic char validation */
179 } charcheck;
180 union {
181 bool (*onext)(FIELD *,const void *); /* enumerate next value */
182 bool (*gnext)(FORM*,FIELD*,const void*); /* generic enumerate next */
183 } enum_next;
184 union {
185 bool (*oprev)(FIELD *,const void *); /* enumerate prev value */
186 bool (*gprev)(FORM*,FIELD*,const void*); /* generic enumerate prev */
187 } enum_prev;
188 void* (*genericarg)(void*); /* Alternate Arg method */
189 #else
190 bool (*fcheck)(FIELD *,const void *); /* field validation */
191 bool (*ccheck)(int,const void *); /* character validation */
193 bool (*next)(FIELD *,const void *); /* enumerate next value */
194 bool (*prev)(FIELD *,const void *); /* enumerate prev value */
195 #endif
197 #endif /* !NCURSES_OPAQUE_FORM */
198 FIELDTYPE;
200 typedef void (*Form_Hook)(FORM *);
202 /***************************
203 * miscellaneous #defines *
204 ***************************/
206 /* field justification */
207 #define NO_JUSTIFICATION (0)
208 #define JUSTIFY_LEFT (1)
209 #define JUSTIFY_CENTER (2)
210 #define JUSTIFY_RIGHT (3)
212 /* field options */
213 #define O_VISIBLE (0x0001U)
214 #define O_ACTIVE (0x0002U)
215 #define O_PUBLIC (0x0004U)
216 #define O_EDIT (0x0008U)
217 #define O_WRAP (0x0010U)
218 #define O_BLANK (0x0020U)
219 #define O_AUTOSKIP (0x0040U)
220 #define O_NULLOK (0x0080U)
221 #define O_PASSOK (0x0100U)
222 #define O_STATIC (0x0200U)
223 #define O_DYNAMIC_JUSTIFY (0x0400U) /* ncurses extension */
224 #define O_NO_LEFT_STRIP (0x0800U) /* ncurses extension */
226 /* form options */
227 #define O_NL_OVERLOAD (0x0001U)
228 #define O_BS_OVERLOAD (0x0002U)
230 /* form driver commands */
231 #define REQ_NEXT_PAGE (KEY_MAX + 1) /* move to next page */
232 #define REQ_PREV_PAGE (KEY_MAX + 2) /* move to previous page */
233 #define REQ_FIRST_PAGE (KEY_MAX + 3) /* move to first page */
234 #define REQ_LAST_PAGE (KEY_MAX + 4) /* move to last page */
236 #define REQ_NEXT_FIELD (KEY_MAX + 5) /* move to next field */
237 #define REQ_PREV_FIELD (KEY_MAX + 6) /* move to previous field */
238 #define REQ_FIRST_FIELD (KEY_MAX + 7) /* move to first field */
239 #define REQ_LAST_FIELD (KEY_MAX + 8) /* move to last field */
240 #define REQ_SNEXT_FIELD (KEY_MAX + 9) /* move to sorted next field */
241 #define REQ_SPREV_FIELD (KEY_MAX + 10) /* move to sorted prev field */
242 #define REQ_SFIRST_FIELD (KEY_MAX + 11) /* move to sorted first field */
243 #define REQ_SLAST_FIELD (KEY_MAX + 12) /* move to sorted last field */
244 #define REQ_LEFT_FIELD (KEY_MAX + 13) /* move to left to field */
245 #define REQ_RIGHT_FIELD (KEY_MAX + 14) /* move to right to field */
246 #define REQ_UP_FIELD (KEY_MAX + 15) /* move to up to field */
247 #define REQ_DOWN_FIELD (KEY_MAX + 16) /* move to down to field */
249 #define REQ_NEXT_CHAR (KEY_MAX + 17) /* move to next char in field */
250 #define REQ_PREV_CHAR (KEY_MAX + 18) /* move to prev char in field */
251 #define REQ_NEXT_LINE (KEY_MAX + 19) /* move to next line in field */
252 #define REQ_PREV_LINE (KEY_MAX + 20) /* move to prev line in field */
253 #define REQ_NEXT_WORD (KEY_MAX + 21) /* move to next word in field */
254 #define REQ_PREV_WORD (KEY_MAX + 22) /* move to prev word in field */
255 #define REQ_BEG_FIELD (KEY_MAX + 23) /* move to first char in field */
256 #define REQ_END_FIELD (KEY_MAX + 24) /* move after last char in fld */
257 #define REQ_BEG_LINE (KEY_MAX + 25) /* move to beginning of line */
258 #define REQ_END_LINE (KEY_MAX + 26) /* move after last char in line */
259 #define REQ_LEFT_CHAR (KEY_MAX + 27) /* move left in field */
260 #define REQ_RIGHT_CHAR (KEY_MAX + 28) /* move right in field */
261 #define REQ_UP_CHAR (KEY_MAX + 29) /* move up in field */
262 #define REQ_DOWN_CHAR (KEY_MAX + 30) /* move down in field */
264 #define REQ_NEW_LINE (KEY_MAX + 31) /* insert/overlay new line */
265 #define REQ_INS_CHAR (KEY_MAX + 32) /* insert blank char at cursor */
266 #define REQ_INS_LINE (KEY_MAX + 33) /* insert blank line at cursor */
267 #define REQ_DEL_CHAR (KEY_MAX + 34) /* delete char at cursor */
268 #define REQ_DEL_PREV (KEY_MAX + 35) /* delete char before cursor */
269 #define REQ_DEL_LINE (KEY_MAX + 36) /* delete line at cursor */
270 #define REQ_DEL_WORD (KEY_MAX + 37) /* delete word at cursor */
271 #define REQ_CLR_EOL (KEY_MAX + 38) /* clear to end of line */
272 #define REQ_CLR_EOF (KEY_MAX + 39) /* clear to end of field */
273 #define REQ_CLR_FIELD (KEY_MAX + 40) /* clear entire field */
274 #define REQ_OVL_MODE (KEY_MAX + 41) /* begin overlay mode */
275 #define REQ_INS_MODE (KEY_MAX + 42) /* begin insert mode */
276 #define REQ_SCR_FLINE (KEY_MAX + 43) /* scroll field forward a line */
277 #define REQ_SCR_BLINE (KEY_MAX + 44) /* scroll field backward a line */
278 #define REQ_SCR_FPAGE (KEY_MAX + 45) /* scroll field forward a page */
279 #define REQ_SCR_BPAGE (KEY_MAX + 46) /* scroll field backward a page */
280 #define REQ_SCR_FHPAGE (KEY_MAX + 47) /* scroll field forward half page */
281 #define REQ_SCR_BHPAGE (KEY_MAX + 48) /* scroll field backward half page */
282 #define REQ_SCR_FCHAR (KEY_MAX + 49) /* horizontal scroll char */
283 #define REQ_SCR_BCHAR (KEY_MAX + 50) /* horizontal scroll char */
284 #define REQ_SCR_HFLINE (KEY_MAX + 51) /* horizontal scroll line */
285 #define REQ_SCR_HBLINE (KEY_MAX + 52) /* horizontal scroll line */
286 #define REQ_SCR_HFHALF (KEY_MAX + 53) /* horizontal scroll half line */
287 #define REQ_SCR_HBHALF (KEY_MAX + 54) /* horizontal scroll half line */
289 #define REQ_VALIDATION (KEY_MAX + 55) /* validate field */
290 #define REQ_NEXT_CHOICE (KEY_MAX + 56) /* display next field choice */
291 #define REQ_PREV_CHOICE (KEY_MAX + 57) /* display prev field choice */
293 #define MIN_FORM_COMMAND (KEY_MAX + 1) /* used by form_driver */
294 #define MAX_FORM_COMMAND (KEY_MAX + 57) /* used by form_driver */
296 #if defined(MAX_COMMAND)
297 # if (MAX_FORM_COMMAND > MAX_COMMAND)
298 # error Something is wrong -- MAX_FORM_COMMAND is greater than MAX_COMMAND
299 # elif (MAX_COMMAND != (KEY_MAX + 128))
300 # error Something is wrong -- MAX_COMMAND is already inconsistently defined.
301 # endif
302 #else
303 # define MAX_COMMAND (KEY_MAX + 128)
304 #endif
306 /*************************
307 * standard field types *
308 *************************/
309 extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ALPHA;
310 extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ALNUM;
311 extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ENUM;
312 extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_INTEGER;
313 extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_NUMERIC;
314 extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_REGEXP;
316 /************************************
317 * built-in additional field types *
318 * They are not defined in SVr4 *
319 ************************************/
320 extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_IPV4; /* Internet IP Version 4 address */
322 /***********************
323 * FIELDTYPE routines *
324 ***********************/
325 extern NCURSES_EXPORT(FIELDTYPE *) new_fieldtype (
326 bool (* const field_check)(FIELD *,const void *),
327 bool (* const char_check)(int,const void *));
328 extern NCURSES_EXPORT(FIELDTYPE *) link_fieldtype(
329 FIELDTYPE *, FIELDTYPE *);
331 extern NCURSES_EXPORT(int) free_fieldtype (FIELDTYPE *);
332 extern NCURSES_EXPORT(int) set_fieldtype_arg (FIELDTYPE *,
333 void * (* const make_arg)(va_list *),
334 void * (* const copy_arg)(const void *),
335 void (* const free_arg)(void *));
336 extern NCURSES_EXPORT(int) set_fieldtype_choice (FIELDTYPE *,
337 bool (* const next_choice)(FIELD *,const void *),
338 bool (* const prev_choice)(FIELD *,const void *));
340 /*******************
341 * FIELD routines *
342 *******************/
343 extern NCURSES_EXPORT(FIELD *) new_field (int,int,int,int,int,int);
344 extern NCURSES_EXPORT(FIELD *) dup_field (FIELD *,int,int);
345 extern NCURSES_EXPORT(FIELD *) link_field (FIELD *,int,int);
347 extern NCURSES_EXPORT(int) free_field (FIELD *);
348 extern NCURSES_EXPORT(int) field_info (const FIELD *,int *,int *,int *,int *,int *,int *);
349 extern NCURSES_EXPORT(int) dynamic_field_info (const FIELD *,int *,int *,int *);
350 extern NCURSES_EXPORT(int) set_max_field ( FIELD *,int);
351 extern NCURSES_EXPORT(int) move_field (FIELD *,int,int);
352 extern NCURSES_EXPORT(int) set_field_type (FIELD *,FIELDTYPE *,...);
353 extern NCURSES_EXPORT(int) set_new_page (FIELD *,bool);
354 extern NCURSES_EXPORT(int) set_field_just (FIELD *,int);
355 extern NCURSES_EXPORT(int) field_just (const FIELD *);
356 extern NCURSES_EXPORT(int) set_field_fore (FIELD *,chtype);
357 extern NCURSES_EXPORT(int) set_field_back (FIELD *,chtype);
358 extern NCURSES_EXPORT(int) set_field_pad (FIELD *,int);
359 extern NCURSES_EXPORT(int) field_pad (const FIELD *);
360 extern NCURSES_EXPORT(int) set_field_buffer (FIELD *,int,const char *);
361 extern NCURSES_EXPORT(int) set_field_status (FIELD *,bool);
362 extern NCURSES_EXPORT(int) set_field_userptr (FIELD *, void *);
363 extern NCURSES_EXPORT(int) set_field_opts (FIELD *,Field_Options);
364 extern NCURSES_EXPORT(int) field_opts_on (FIELD *,Field_Options);
365 extern NCURSES_EXPORT(int) field_opts_off (FIELD *,Field_Options);
367 extern NCURSES_EXPORT(chtype) field_fore (const FIELD *);
368 extern NCURSES_EXPORT(chtype) field_back (const FIELD *);
370 extern NCURSES_EXPORT(bool) new_page (const FIELD *);
371 extern NCURSES_EXPORT(bool) field_status (const FIELD *);
373 extern NCURSES_EXPORT(void *) field_arg (const FIELD *);
375 extern NCURSES_EXPORT(void *) field_userptr (const FIELD *);
377 extern NCURSES_EXPORT(FIELDTYPE *) field_type (const FIELD *);
379 extern NCURSES_EXPORT(char *) field_buffer (const FIELD *,int);
381 extern NCURSES_EXPORT(Field_Options) field_opts (const FIELD *);
383 /******************
384 * FORM routines *
385 ******************/
387 extern NCURSES_EXPORT(FORM *) new_form (FIELD **);
389 extern NCURSES_EXPORT(FIELD **) form_fields (const FORM *);
390 extern NCURSES_EXPORT(FIELD *) current_field (const FORM *);
392 extern NCURSES_EXPORT(WINDOW *) form_win (const FORM *);
393 extern NCURSES_EXPORT(WINDOW *) form_sub (const FORM *);
395 extern NCURSES_EXPORT(Form_Hook) form_init (const FORM *);
396 extern NCURSES_EXPORT(Form_Hook) form_term (const FORM *);
397 extern NCURSES_EXPORT(Form_Hook) field_init (const FORM *);
398 extern NCURSES_EXPORT(Form_Hook) field_term (const FORM *);
400 extern NCURSES_EXPORT(int) free_form (FORM *);
401 extern NCURSES_EXPORT(int) set_form_fields (FORM *,FIELD **);
402 extern NCURSES_EXPORT(int) field_count (const FORM *);
403 extern NCURSES_EXPORT(int) set_form_win (FORM *,WINDOW *);
404 extern NCURSES_EXPORT(int) set_form_sub (FORM *,WINDOW *);
405 extern NCURSES_EXPORT(int) set_current_field (FORM *,FIELD *);
406 extern NCURSES_EXPORT(int) unfocus_current_field (FORM *);
407 extern NCURSES_EXPORT(int) field_index (const FIELD *);
408 extern NCURSES_EXPORT(int) set_form_page (FORM *,int);
409 extern NCURSES_EXPORT(int) form_page (const FORM *);
410 extern NCURSES_EXPORT(int) scale_form (const FORM *,int *,int *);
411 extern NCURSES_EXPORT(int) set_form_init (FORM *,Form_Hook);
412 extern NCURSES_EXPORT(int) set_form_term (FORM *,Form_Hook);
413 extern NCURSES_EXPORT(int) set_field_init (FORM *,Form_Hook);
414 extern NCURSES_EXPORT(int) set_field_term (FORM *,Form_Hook);
415 extern NCURSES_EXPORT(int) post_form (FORM *);
416 extern NCURSES_EXPORT(int) unpost_form (FORM *);
417 extern NCURSES_EXPORT(int) pos_form_cursor (FORM *);
418 extern NCURSES_EXPORT(int) form_driver (FORM *,int);
419 # if NCURSES_WIDECHAR
420 extern NCURSES_EXPORT(int) form_driver_w (FORM *,int,wchar_t);
421 # endif
422 extern NCURSES_EXPORT(int) set_form_userptr (FORM *,void *);
423 extern NCURSES_EXPORT(int) set_form_opts (FORM *,Form_Options);
424 extern NCURSES_EXPORT(int) form_opts_on (FORM *,Form_Options);
425 extern NCURSES_EXPORT(int) form_opts_off (FORM *,Form_Options);
426 extern NCURSES_EXPORT(int) form_request_by_name (const char *);
428 extern NCURSES_EXPORT(const char *) form_request_name (int);
430 extern NCURSES_EXPORT(void *) form_userptr (const FORM *);
432 extern NCURSES_EXPORT(Form_Options) form_opts (const FORM *);
434 extern NCURSES_EXPORT(bool) data_ahead (const FORM *);
435 extern NCURSES_EXPORT(bool) data_behind (const FORM *);
437 #if NCURSES_SP_FUNCS
438 extern NCURSES_EXPORT(FORM *) NCURSES_SP_NAME(new_form) (SCREEN*, FIELD **);
439 #endif
441 #ifdef __cplusplus
443 #endif
444 /* *INDENT-ON*/
446 #endif /* FORM_H */