xref: /minix3/lib/libform/internals.h (revision a0e6850f820f09a03a1da1b4d78f9fafb3b9782f)
1*a0e6850fSThomas Cort /*	$NetBSD: internals.h,v 1.10 2004/11/24 11:57:09 blymn Exp $	*/
2*a0e6850fSThomas Cort 
3*a0e6850fSThomas Cort /*-
4*a0e6850fSThomas Cort  * Copyright (c) 1998-1999 Brett Lymn
5*a0e6850fSThomas Cort  *                         (blymn@baea.com.au, brett_lymn@yahoo.com.au)
6*a0e6850fSThomas Cort  * All rights reserved.
7*a0e6850fSThomas Cort  *
8*a0e6850fSThomas Cort  * This code has been donated to The NetBSD Foundation by the Author.
9*a0e6850fSThomas Cort  *
10*a0e6850fSThomas Cort  * Redistribution and use in source and binary forms, with or without
11*a0e6850fSThomas Cort  * modification, are permitted provided that the following conditions
12*a0e6850fSThomas Cort  * are met:
13*a0e6850fSThomas Cort  * 1. Redistributions of source code must retain the above copyright
14*a0e6850fSThomas Cort  *    notice, this list of conditions and the following disclaimer.
15*a0e6850fSThomas Cort  * 2. The name of the author may not be used to endorse or promote products
16*a0e6850fSThomas Cort  *    derived from this software without specific prior written permission
17*a0e6850fSThomas Cort  *
18*a0e6850fSThomas Cort  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19*a0e6850fSThomas Cort  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20*a0e6850fSThomas Cort  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21*a0e6850fSThomas Cort  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22*a0e6850fSThomas Cort  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23*a0e6850fSThomas Cort  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24*a0e6850fSThomas Cort  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25*a0e6850fSThomas Cort  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26*a0e6850fSThomas Cort  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27*a0e6850fSThomas Cort  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*a0e6850fSThomas Cort  *
29*a0e6850fSThomas Cort  *
30*a0e6850fSThomas Cort  */
31*a0e6850fSThomas Cort 
32*a0e6850fSThomas Cort #include <stdio.h>
33*a0e6850fSThomas Cort #include "form.h"
34*a0e6850fSThomas Cort 
35*a0e6850fSThomas Cort #ifndef FORMI_INTERNALS_H
36*a0e6850fSThomas Cort #define FORMI_INTERNALS_H 1
37*a0e6850fSThomas Cort 
38*a0e6850fSThomas Cort #ifdef DEBUG
39*a0e6850fSThomas Cort extern FILE *dbg;
40*a0e6850fSThomas Cort #endif
41*a0e6850fSThomas Cort 
42*a0e6850fSThomas Cort /* direction definitions for _formi_pos_new_field */
43*a0e6850fSThomas Cort #define _FORMI_BACKWARD 1
44*a0e6850fSThomas Cort #define _FORMI_FORWARD  2
45*a0e6850fSThomas Cort 
46*a0e6850fSThomas Cort /* define the default options for a form... */
47*a0e6850fSThomas Cort #define DEFAULT_FORM_OPTS (O_VISIBLE | O_ACTIVE | O_PUBLIC | O_EDIT | \
48*a0e6850fSThomas Cort                            O_WRAP | O_BLANK | O_AUTOSKIP | O_NULLOK | \
49*a0e6850fSThomas Cort                            O_PASSOK | O_STATIC)
50*a0e6850fSThomas Cort 
51*a0e6850fSThomas Cort /* definitions of the flags for the FIELDTYPE structure */
52*a0e6850fSThomas Cort #define _TYPE_NO_FLAGS   0
53*a0e6850fSThomas Cort #define _TYPE_HAS_ARGS   0x01
54*a0e6850fSThomas Cort #define _TYPE_IS_LINKED  0x02
55*a0e6850fSThomas Cort #define _TYPE_IS_BUILTIN 0x04
56*a0e6850fSThomas Cort #define _TYPE_HAS_CHOICE 0x08
57*a0e6850fSThomas Cort 
58*a0e6850fSThomas Cort typedef struct formi_type_link_struct formi_type_link;
59*a0e6850fSThomas Cort 
60*a0e6850fSThomas Cort struct formi_type_link_struct
61*a0e6850fSThomas Cort {
62*a0e6850fSThomas Cort 	FIELDTYPE *next;
63*a0e6850fSThomas Cort 	FIELDTYPE *prev;
64*a0e6850fSThomas Cort };
65*a0e6850fSThomas Cort 
66*a0e6850fSThomas Cort 
67*a0e6850fSThomas Cort struct _formi_page_struct
68*a0e6850fSThomas Cort {
69*a0e6850fSThomas Cort 	int in_use;
70*a0e6850fSThomas Cort 	int first;
71*a0e6850fSThomas Cort 	int last;
72*a0e6850fSThomas Cort 	int top_left;
73*a0e6850fSThomas Cort 	int bottom_right;
74*a0e6850fSThomas Cort };
75*a0e6850fSThomas Cort 
76*a0e6850fSThomas Cort struct _formi_tab_stops
77*a0e6850fSThomas Cort {
78*a0e6850fSThomas Cort 	struct _formi_tab_stops *fwd;
79*a0e6850fSThomas Cort 	struct _formi_tab_stops *back;
80*a0e6850fSThomas Cort 	unsigned char in_use;
81*a0e6850fSThomas Cort 	unsigned pos;
82*a0e6850fSThomas Cort 	unsigned size;
83*a0e6850fSThomas Cort };
84*a0e6850fSThomas Cort 
85*a0e6850fSThomas Cort typedef struct _formi_tab_stops _formi_tab_t;
86*a0e6850fSThomas Cort 
87*a0e6850fSThomas Cort /* lines structure for the field - keeps start and ends and length of the
88*a0e6850fSThomas Cort  * lines in a field.
89*a0e6850fSThomas Cort  */
90*a0e6850fSThomas Cort struct _formi_field_lines
91*a0e6850fSThomas Cort {
92*a0e6850fSThomas Cort 	_FORMI_FIELD_LINES *prev;
93*a0e6850fSThomas Cort 	_FORMI_FIELD_LINES *next;
94*a0e6850fSThomas Cort 	unsigned allocated;
95*a0e6850fSThomas Cort 	unsigned length;
96*a0e6850fSThomas Cort 	unsigned expanded;
97*a0e6850fSThomas Cort 	char *string;
98*a0e6850fSThomas Cort 	unsigned char hard_ret; /* line contains hard return */
99*a0e6850fSThomas Cort 	_formi_tab_t *tabs;
100*a0e6850fSThomas Cort };
101*a0e6850fSThomas Cort 
102*a0e6850fSThomas Cort 
103*a0e6850fSThomas Cort /* function prototypes */
104*a0e6850fSThomas Cort unsigned
105*a0e6850fSThomas Cort _formi_skip_blanks(char *string, unsigned int start);
106*a0e6850fSThomas Cort int
107*a0e6850fSThomas Cort _formi_add_char(FIELD *cur, unsigned pos, char c);
108*a0e6850fSThomas Cort void
109*a0e6850fSThomas Cort _formi_calculate_tabs(_FORMI_FIELD_LINES *row);
110*a0e6850fSThomas Cort int
111*a0e6850fSThomas Cort _formi_draw_page(FORM *form);
112*a0e6850fSThomas Cort int
113*a0e6850fSThomas Cort _formi_find_pages(FORM *form);
114*a0e6850fSThomas Cort int
115*a0e6850fSThomas Cort _formi_field_choice(FORM *form, int c);
116*a0e6850fSThomas Cort void
117*a0e6850fSThomas Cort _formi_init_field_xpos(FIELD *field);
118*a0e6850fSThomas Cort int
119*a0e6850fSThomas Cort _formi_manipulate_field(FORM *form, int c);
120*a0e6850fSThomas Cort int
121*a0e6850fSThomas Cort _formi_pos_first_field(FORM *form);
122*a0e6850fSThomas Cort int
123*a0e6850fSThomas Cort _formi_pos_new_field(FORM *form, unsigned direction, unsigned use_sorted);
124*a0e6850fSThomas Cort void
125*a0e6850fSThomas Cort _formi_redraw_field(FORM *form, int field);
126*a0e6850fSThomas Cort void
127*a0e6850fSThomas Cort _formi_sort_fields(FORM *form);
128*a0e6850fSThomas Cort void
129*a0e6850fSThomas Cort _formi_stitch_fields(FORM *form);
130*a0e6850fSThomas Cort int
131*a0e6850fSThomas Cort _formi_tab_expanded_length(char *str, unsigned int start, unsigned int end);
132*a0e6850fSThomas Cort int
133*a0e6850fSThomas Cort _formi_update_field(FORM *form, int old_field);
134*a0e6850fSThomas Cort int
135*a0e6850fSThomas Cort _formi_validate_char(FIELD *field, char c);
136*a0e6850fSThomas Cort int
137*a0e6850fSThomas Cort _formi_validate_field(FORM *form);
138*a0e6850fSThomas Cort int
139*a0e6850fSThomas Cort _formi_wrap_field(FIELD *field, _FORMI_FIELD_LINES *pos);
140*a0e6850fSThomas Cort int
141*a0e6850fSThomas Cort _formi_sync_buffer(FIELD *field);
142*a0e6850fSThomas Cort 
143*a0e6850fSThomas Cort #ifdef DEBUG
144*a0e6850fSThomas Cort int
145*a0e6850fSThomas Cort _formi_create_dbg_file(void);
146*a0e6850fSThomas Cort #endif /* DEBUG */
147*a0e6850fSThomas Cort 
148*a0e6850fSThomas Cort #endif
149*a0e6850fSThomas Cort 
150*a0e6850fSThomas Cort 
151*a0e6850fSThomas Cort 
152