xref: /illumos-gate/usr/src/lib/libeti/form/inc/form.h (revision 948f2876ce2a3010558f4f6937e16086ebcd36f2)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright (c) 1988 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 #ifndef _FORM_H
27 #define	_FORM_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.10	*/
30 
31 #include <curses.h>
32 #include <eti.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * FIELDTYPE
40  */
41 
42 typedef struct typenode {
43 
44 	int			status;		/* flags		*/
45 	int			ref;		/* reference count	*/
46 	struct typenode *	left;		/* ptr to operand for |	*/
47 	struct typenode *	right;		/* ptr to operand for |	*/
48 	PTF_charP		makearg;	/* make fieldtype arg	*/
49 	PTF_charP		copyarg;	/* copy fieldtype arg	*/
50 	PTF_void		freearg;	/* free fieldtype arg	*/
51 	PTF_int			fcheck;		/* field validation	*/
52 	PTF_int			ccheck;		/* character validation	*/
53 	PTF_int			next;		/* enumerate next value	*/
54 	PTF_int			prev;		/* enumerate prev value	*/
55 }
56 	FIELDTYPE;
57 
58 /*
59  * _PAGE
60  */
61 
62 typedef struct {
63 
64 	int			pmin;		/* first field on page	*/
65 	int			pmax;		/* last field on page	*/
66 	int			smin;		/* top leftmost field	*/
67 	int			smax;		/* bottom rightmost	*/
68 }
69 	_PAGE;
70 
71 /*
72  * FIELD
73  */
74 
75 typedef struct fieldnode {
76 
77 	int			status;		/* flags		*/
78 	int			rows;		/* size in rows		*/
79 	int			cols;		/* size in cols		*/
80 	int			frow;		/* first row		*/
81 	int			fcol;		/* first col		*/
82 	int			drows;		/* dynamic rows		*/
83 	int			dcols;		/* dynamic cols		*/
84 	int			maxgrow;	/* maximum field growth */
85 	int			nrow;		/* offscreen rows	*/
86 	int			nbuf;		/* additional buffers	*/
87 	int			just;		/* justification	*/
88 	int			page;		/* page on form		*/
89 	int			index;		/* into form -> field	*/
90 	int			pad;		/* pad character	*/
91 	chtype			fore;		/* foreground attribute	*/
92 	chtype			back;		/* background attribute	*/
93 	OPTIONS			opts;		/* options		*/
94 	struct fieldnode *	snext;		/* sorted order pointer	*/
95 	struct fieldnode *	sprev;		/* sorted order pointer	*/
96 	struct fieldnode *	link;		/* linked field chain	*/
97 	struct formnode *	form;		/* containing form	*/
98 	FIELDTYPE *		type;		/* field type		*/
99 	char *			arg;		/* argument for type	*/
100 	char *			buf;		/* field buffers	*/
101 	char *			usrptr;		/* user pointer		*/
102 }
103 	FIELD;
104 
105 /*
106  * FORM
107  */
108 
109 typedef struct formnode {
110 
111 	int			status;		/* flags		*/
112 	int			rows;		/* size in rows		*/
113 	int			cols;		/* size in cols		*/
114 	int			currow;		/* current row		*/
115 	int			curcol;		/* current col		*/
116 	int			toprow;		/* in vertically	*/
117 						/* scrollable field	*/
118 	int			begincol;	/* in horizontally	*/
119 						/* scrollable field	*/
120 	int			maxfield;	/* number of fields	*/
121 	int			maxpage;	/* number of pages	*/
122 	int			curpage;	/* index into page	*/
123 	OPTIONS			opts;		/* options		*/
124 	WINDOW *		win;		/* window		*/
125 	WINDOW *		sub;		/* subwindow		*/
126 	WINDOW *		w;		/* window		*/
127 	FIELD **		field;		/* field [maxfield]	*/
128 	FIELD *			current;	/* current field	*/
129 	_PAGE *			page;		/* page [maxpage]	*/
130 	char *			usrptr;		/* user pointer		*/
131 	PTF_void		forminit;	/* user function	*/
132 	PTF_void		formterm;	/* user function	*/
133 	PTF_void		fieldinit;	/* user function	*/
134 	PTF_void		fieldterm;	/* user function	*/
135 }
136 	FORM;
137 
138 /*
139  * miscellaneous #defines
140  */
141 
142 /*
143  *	field justification
144  */
145 #define	NO_JUSTIFICATION	0
146 #define	JUSTIFY_LEFT		1
147 #define	JUSTIFY_CENTER		2
148 #define	JUSTIFY_RIGHT		3
149 /*
150  *	field options
151  */
152 #define	O_VISIBLE		0x0001
153 #define	O_ACTIVE		0x0002
154 #define	O_PUBLIC		0x0004
155 #define	O_EDIT			0x0008
156 #define	O_WRAP			0x0010
157 #define	O_BLANK			0x0020
158 #define	O_AUTOSKIP		0x0040
159 #define	O_NULLOK		0x0080
160 #define	O_PASSOK		0x0100
161 #define	O_STATIC		0x0200
162 /*
163  *	form options
164  */
165 #define	O_NL_OVERLOAD		0x0001
166 #define	O_BS_OVERLOAD		0x0002
167 /*
168  *	form driver commands
169  */
170 #define	REQ_NEXT_PAGE	(KEY_MAX + 1)	/* move to next page		*/
171 #define	REQ_PREV_PAGE	(KEY_MAX + 2)	/* move to previous page	*/
172 #define	REQ_FIRST_PAGE	(KEY_MAX + 3)	/* move to first page		*/
173 #define	REQ_LAST_PAGE	(KEY_MAX + 4)	/* move to last page		*/
174 
175 #define	REQ_NEXT_FIELD	(KEY_MAX + 5)	/* move to next field		*/
176 #define	REQ_PREV_FIELD	(KEY_MAX + 6)	/* move to previous field	*/
177 #define	REQ_FIRST_FIELD	(KEY_MAX + 7)	/* move to first field		*/
178 #define	REQ_LAST_FIELD	(KEY_MAX + 8)	/* move to last field		*/
179 #define	REQ_SNEXT_FIELD	(KEY_MAX + 9)	/* move to sorted next field	*/
180 #define	REQ_SPREV_FIELD	(KEY_MAX + 10)	/* move to sorted prev field	*/
181 #define	REQ_SFIRST_FIELD (KEY_MAX + 11)	/* move to sorted first field	*/
182 #define	REQ_SLAST_FIELD	(KEY_MAX + 12)	/* move to sorted last field	*/
183 #define	REQ_LEFT_FIELD	(KEY_MAX + 13)	/* move to left to field	*/
184 #define	REQ_RIGHT_FIELD	(KEY_MAX + 14)	/* move to right to field	*/
185 #define	REQ_UP_FIELD	(KEY_MAX + 15)	/* move to up to field		*/
186 #define	REQ_DOWN_FIELD	(KEY_MAX + 16)	/* move to down to field	*/
187 
188 #define	REQ_NEXT_CHAR	(KEY_MAX + 17)	/* move to next char in field	*/
189 #define	REQ_PREV_CHAR	(KEY_MAX + 18)	/* move to prev char in field	*/
190 #define	REQ_NEXT_LINE	(KEY_MAX + 19)	/* move to next line in field	*/
191 #define	REQ_PREV_LINE	(KEY_MAX + 20)	/* move to prev line in field	*/
192 #define	REQ_NEXT_WORD	(KEY_MAX + 21)	/* move to next word in field	*/
193 #define	REQ_PREV_WORD	(KEY_MAX + 22)	/* move to prev word in field	*/
194 #define	REQ_BEG_FIELD	(KEY_MAX + 23)	/* move to first char in field	*/
195 #define	REQ_END_FIELD	(KEY_MAX + 24)	/* move after last char in fld	*/
196 #define	REQ_BEG_LINE	(KEY_MAX + 25)	/* move to beginning of line	*/
197 #define	REQ_END_LINE	(KEY_MAX + 26)	/* move after last char in line	*/
198 #define	REQ_LEFT_CHAR	(KEY_MAX + 27)	/* move left in field		*/
199 #define	REQ_RIGHT_CHAR	(KEY_MAX + 28)	/* move right in field		*/
200 #define	REQ_UP_CHAR	(KEY_MAX + 29)	/* move up in field		*/
201 #define	REQ_DOWN_CHAR	(KEY_MAX + 30)	/* move down in field		*/
202 
203 #define	REQ_NEW_LINE	(KEY_MAX + 31)	/* insert/overlay new line	*/
204 #define	REQ_INS_CHAR	(KEY_MAX + 32)	/* insert blank char at cursor	*/
205 #define	REQ_INS_LINE	(KEY_MAX + 33)	/* insert blank line at cursor	*/
206 #define	REQ_DEL_CHAR	(KEY_MAX + 34)	/* delete char at cursor	*/
207 #define	REQ_DEL_PREV	(KEY_MAX + 35)	/* delete char before cursor	*/
208 #define	REQ_DEL_LINE	(KEY_MAX + 36)	/* delete line at cursor	*/
209 #define	REQ_DEL_WORD	(KEY_MAX + 37)	/* delete line at cursor	*/
210 #define	REQ_CLR_EOL	(KEY_MAX + 38)	/* clear to end of line		*/
211 #define	REQ_CLR_EOF	(KEY_MAX + 39)	/* clear to end of field	*/
212 #define	REQ_CLR_FIELD	(KEY_MAX + 40)	/* clear entire field		*/
213 #define	REQ_OVL_MODE	(KEY_MAX + 41)	/* begin overlay mode		*/
214 #define	REQ_INS_MODE	(KEY_MAX + 42)	/* begin insert mode		*/
215 
216 #define	REQ_SCR_FLINE	(KEY_MAX + 43)	/* scroll field forward a line	*/
217 #define	REQ_SCR_BLINE	(KEY_MAX + 44)	/* scroll field backward a line	*/
218 #define	REQ_SCR_FPAGE	(KEY_MAX + 45)	/* scroll field forward a page	*/
219 #define	REQ_SCR_BPAGE	(KEY_MAX + 46)	/* scroll field backward a page	*/
220 #define	REQ_SCR_FHPAGE	(KEY_MAX + 47)	/* scroll field forward half page */
221 #define	REQ_SCR_BHPAGE	(KEY_MAX + 48)	/* scroll field backward half page */
222 
223 #define	REQ_SCR_FCHAR	(KEY_MAX + 49)	/* horizontal scroll char */
224 #define	REQ_SCR_BCHAR	(KEY_MAX + 50)	/* horizontal scroll char */
225 #define	REQ_SCR_HFLINE	(KEY_MAX + 51)	/* horizontal scroll line */
226 #define	REQ_SCR_HBLINE	(KEY_MAX + 52)	/* horizontal scroll line */
227 #define	REQ_SCR_HFHALF	(KEY_MAX + 53)	/* horizontal scroll half line */
228 #define	REQ_SCR_HBHALF	(KEY_MAX + 54)	/* horizontal scroll half line */
229 
230 #define	REQ_VALIDATION	(KEY_MAX + 55)	/* validate field		*/
231 #define	REQ_NEXT_CHOICE	(KEY_MAX + 56)	/* display next field choice	*/
232 #define	REQ_PREV_CHOICE	(KEY_MAX + 57)	/* display prev field choice	*/
233 
234 #define	MIN_FORM_COMMAND (KEY_MAX + 1)	/* used by form_driver		*/
235 #define	MAX_FORM_COMMAND (KEY_MAX + 57)	/* used by form_driver		*/
236 
237 /*
238  *  standard field types
239  */
240 
241 extern FIELDTYPE *	TYPE_ALPHA;
242 extern FIELDTYPE *	TYPE_ALNUM;
243 extern FIELDTYPE *	TYPE_ENUM;
244 extern FIELDTYPE *	TYPE_INTEGER;
245 extern FIELDTYPE *	TYPE_NUMERIC;
246 extern FIELDTYPE *	TYPE_REGEXP;
247 
248 /*
249  *  default objects
250  */
251 
252 extern FORM *		_DEFAULT_FORM;
253 extern FIELD *		_DEFAULT_FIELD;
254 
255 #ifdef __STDC__
256 
257 /*
258  *  FIELDTYPE routines
259  */
260 
261 extern FIELDTYPE *	new_fieldtype(PTF_int, PTF_int);
262 extern FIELDTYPE *	link_fieldtype(FIELDTYPE *, FIELDTYPE *);
263 extern int		free_fieldtype(FIELDTYPE *);
264 extern int		set_fieldtype_arg(FIELDTYPE *, PTF_charP,
265 					    PTF_charP, PTF_void);
266 extern int		set_fieldtype_choice(FIELDTYPE *, PTF_int, PTF_int);
267 
268 /*
269  *  FIELD routines
270  */
271 
272 extern FIELD *		new_field(int, int, int, int, int, int);
273 extern FIELD *		dup_field(FIELD *, int, int);
274 extern FIELD *		link_field(FIELD *, int, int);
275 extern int		free_field(FIELD *);
276 extern int		field_info(FIELD *, int *, int *, int *, int *,
277 			    int *, int *);
278 extern int		dynamic_field_info(FIELD *, int *, int *, int *);
279 extern int		set_max_field(FIELD *, int);
280 extern int		move_field(FIELD *, int, int);
281 extern int		set_field_type(FIELD *, FIELDTYPE *, ...);
282 extern FIELDTYPE *	field_type(FIELD *);
283 extern char *		field_arg(FIELD *);
284 extern int		set_new_page(FIELD *, int);
285 extern int		new_page(FIELD *);
286 extern int		set_field_just(FIELD *, int);
287 extern int		field_just(FIELD *);
288 extern int		set_field_fore(FIELD *, chtype);
289 extern chtype		field_fore(FIELD *);
290 extern int		set_field_back(FIELD *, chtype);
291 extern chtype		field_back(FIELD *);
292 extern int		set_field_pad(FIELD *, int);
293 extern int		field_pad(FIELD *);
294 extern int		set_field_buffer(FIELD *, int, char *);
295 extern char *		field_buffer(FIELD *, int);
296 extern int		set_field_status(FIELD *, int);
297 extern int		field_status(FIELD *);
298 extern int		set_field_userptr(FIELD *, char *);
299 extern char *		field_userptr(FIELD *);
300 extern int		set_field_opts(FIELD *, OPTIONS);
301 extern OPTIONS		field_opts(FIELD *);
302 extern int		field_opts_on(FIELD *, OPTIONS);
303 extern int		field_opts_off(FIELD *, OPTIONS);
304 extern int		field_index(FIELD *);
305 
306 /*
307  *  FORM routines
308  */
309 
310 extern FORM *		new_form(FIELD **);
311 extern int		free_form(FORM *);
312 extern int		set_form_fields(FORM *, FIELD **);
313 extern FIELD **		form_fields(FORM *);
314 extern int		field_count(FORM *);
315 extern int		set_form_win(FORM *, WINDOW *);
316 extern WINDOW *		form_win(FORM *);
317 extern int		set_form_sub(FORM *, WINDOW *);
318 extern WINDOW *		form_sub(FORM *);
319 extern int		set_current_field(FORM *, FIELD *);
320 extern FIELD *		current_field(FORM *);
321 extern int		set_form_page(FORM *, int);
322 extern int		form_page(FORM *);
323 extern int		scale_form(FORM *, int *, int *);
324 extern int		set_form_init(FORM *, PTF_void);
325 extern PTF_void		form_init(FORM *);
326 extern int		set_form_term(FORM *, PTF_void);
327 extern PTF_void		form_term(FORM *);
328 extern int		set_field_init(FORM *, PTF_void);
329 extern PTF_void		field_init(FORM *);
330 extern int		set_field_term(FORM *, PTF_void);
331 extern PTF_void		field_term(FORM *);
332 extern int		post_form(FORM *);
333 extern int		unpost_form(FORM *);
334 extern int		pos_form_cursor(FORM *);
335 extern int		form_driver(FORM *, int);
336 extern int		set_form_userptr(FORM *, char *);
337 extern char *		form_userptr(FORM *);
338 extern int		set_form_opts(FORM *, OPTIONS);
339 extern OPTIONS		form_opts(FORM *);
340 extern int		form_opts_on(FORM *, OPTIONS);
341 extern int		form_opts_off(FORM *, OPTIONS);
342 extern int		data_ahead(FORM *);
343 extern int		data_behind(FORM *);
344 
345 #else	/* old style extern's */
346 
347 /*
348  *  FIELDTYPE routines
349  */
350 
351 extern FIELDTYPE *	new_fieldtype();
352 extern FIELDTYPE *	link_fieldtype();
353 extern int		free_fieldtype();
354 extern int		set_fieldtype_arg();
355 extern int		set_fieldtype_choice();
356 
357 /*
358  *  FIELD routines
359  */
360 
361 extern FIELD *		new_field();
362 extern FIELD *		dup_field();
363 extern FIELD *		link_field();
364 extern int		free_field();
365 extern int		field_info();
366 extern int		dynamic_field_info();
367 extern int		set_max_field();
368 extern int		move_field();
369 extern int		set_field_type();
370 extern FIELDTYPE *	field_type();
371 extern char *		field_arg();
372 extern int		set_new_page();
373 extern int		new_page();
374 extern int		set_field_just();
375 extern int		field_just();
376 extern int		set_field_fore();
377 extern chtype		field_fore();
378 extern int		set_field_back();
379 extern chtype		field_back();
380 extern int		set_field_pad();
381 extern int		field_pad();
382 extern int		set_field_buffer();
383 extern char *		field_buffer();
384 extern int		set_field_status();
385 extern int		field_status();
386 extern int		set_field_userptr();
387 extern char *		field_userptr();
388 extern int		set_field_opts();
389 extern OPTIONS		field_opts();
390 extern int		field_opts_on();
391 extern int		field_opts_off();
392 extern int		field_index();
393 
394 /*
395  *  FORM routines
396  */
397 
398 extern FORM *		new_form();
399 extern int		free_form();
400 extern int		set_form_fields();
401 extern FIELD **		form_fields();
402 extern int		field_count();
403 extern int		set_form_win();
404 extern WINDOW *		form_win();
405 extern int		set_form_sub();
406 extern WINDOW *		form_sub();
407 extern int		set_current_field();
408 extern FIELD *		current_field();
409 extern int		set_form_page();
410 extern int		form_page();
411 extern int		scale_form();
412 extern int		set_form_init();
413 extern PTF_void		form_init();
414 extern int		set_form_term();
415 extern PTF_void		form_term();
416 extern int		set_field_init();
417 extern PTF_void		field_init();
418 extern int		set_field_term();
419 extern PTF_void		field_term();
420 extern int		post_form();
421 extern int		unpost_form();
422 extern int		pos_form_cursor();
423 extern int		form_driver();
424 extern int		set_form_userptr();
425 extern char *		form_userptr();
426 extern int		set_form_opts();
427 extern OPTIONS		form_opts();
428 extern int		form_opts_on();
429 extern int		form_opts_off();
430 extern int		data_ahead();
431 extern int		data_behind();
432 
433 #endif	/* __STDC__ */
434 
435 #ifdef	__cplusplus
436 }
437 #endif
438 
439 #endif	/* _FORM_H */
440