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