xref: /freebsd/contrib/ee/new_curse.h (revision c6989859ae9388eeb46a24fe88f9b8d07101c710)
1 /*
2  |	new_curse.h
3  |
4  |	A subset of curses developed for use with ae.
5  |
6  |	written by Hugh Mahon
7  |
8  |	THIS MATERIAL IS PROVIDED "AS IS".  THERE ARE
9  |	NO WARRANTIES OF ANY KIND WITH REGARD TO THIS
10  |	MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE
11  |	IMPLIED WARRANTIES OF MERCHANTABILITY AND
12  |	FITNESS FOR A PARTICULAR PURPOSE.  Neither
13  |	Hewlett-Packard nor Hugh Mahon shall be liable
14  |	for errors contained herein, nor for
15  |	incidental or consequential damages in
16  |	connection with the furnishing, performance or
17  |	use of this material.  Neither Hewlett-Packard
18  |	nor Hugh Mahon assumes any responsibility for
19  |	the use or reliability of this software or
20  |	documentation.  This software and
21  |	documentation is totally UNSUPPORTED.  There
22  |	is no support contract available.  Hewlett-
23  |	Packard has done NO Quality Assurance on ANY
24  |	of the program or documentation.  You may find
25  |	the quality of the materials inferior to
26  |	supported materials.
27  |
28  |	This software is not a product of Hewlett-Packard, Co., or any
29  |	other company.  No support is implied or offered with this software.
30  |	You've got the source, and you're on your own.
31  |
32  |	This software may be distributed under the terms of Larry Wall's
33  |	Artistic license, a copy of which is included in this distribution.
34  |
35  |	This notice must be included with this software and any derivatives.
36  |
37  |	Copyright (c) 1986, 1987, 1988, 1991, 1995 Hugh Mahon
38  |	All are rights reserved.
39  |
40  */
41 
42 #include <stdio.h>
43 
44 #ifdef SYS5
45 #include <termio.h>
46 #else
47 #include <sgtty.h>
48 #include <fcntl.h>
49 #endif
50 
51 #define KEY_BREAK	0401
52 #define KEY_DOWN	0402
53 #define KEY_UP		0403
54 #define KEY_LEFT	0404
55 #define KEY_RIGHT	0405
56 #define KEY_HOME	0406
57 #define KEY_BACKSPACE	0407
58 #define KEY_F0		0410
59 #define KEY_F(n) 	(KEY_F0+(n))
60 #define KEY_DL		0510
61 #define KEY_IL		0511
62 #define KEY_DC		0512
63 #define KEY_IC		0513
64 #define KEY_EIC		0514
65 #define KEY_CLEAR	0515
66 #define KEY_EOS		0516
67 #define KEY_EOL		0517
68 #define KEY_SF		0520
69 #define KEY_SR		0521
70 #define KEY_NPAGE	0522
71 #define KEY_PPAGE	0523
72 #define KEY_STAB	0524
73 #define KEY_CTAB	0525
74 #define KEY_CATAB	0526
75 #define KEY_ENTER	0527
76 #define KEY_SRESET	0530
77 #define KEY_RESET	0531
78 #define KEY_PRINT	0532
79 #define KEY_LL		0533
80 #define KEY_A1	0534
81 #define KEY_A3	0535
82 #define KEY_B2	0536
83 #define KEY_C1	0537
84 #define KEY_C3	0540
85 #define KEY_BTAB	0541
86 #define KEY_BEG	0542
87 #define KEY_CANCEL	0543
88 #define KEY_CLOSE	0544
89 #define KEY_COMMAND	0545
90 #define KEY_COPY	0546
91 #define KEY_CREATE	0547
92 #define KEY_END	0550
93 #define KEY_EXIT	0551
94 #define KEY_FIND	0552
95 #define KEY_HELP	0553
96 #define KEY_MARK	0554
97 #define KEY_MESSAGE	0555
98 #define KEY_MOVE	0556
99 #define KEY_NEXT	0557
100 #define KEY_OPEN	0560
101 #define KEY_OPTIONS	0561
102 #define KEY_PREVIOUS	0562
103 #define KEY_REDO	0563
104 #define KEY_REFERENCE	0564
105 #define KEY_REFRESH	0565
106 #define KEY_REPLACE	0566
107 #define KEY_RESTART	0567
108 #define KEY_RESUME	0570
109 #define KEY_SAVE	0571
110 #define KEY_SBEG	0572
111 #define KEY_SCANCEL	0573
112 #define KEY_SCOMMAND	0574
113 #define KEY_SCOPY	0575
114 #define KEY_SCREATE	0576
115 #define KEY_SDC	0577
116 #define KEY_SDL	0600
117 #define KEY_SELECT	0601
118 #define KEY_SEND	0602
119 #define KEY_SEOL	0603
120 #define KEY_SEXIT	0604
121 #define KEY_SFIND	0605
122 #define KEY_SHELP	0606
123 #define KEY_SHOME	0607
124 #define KEY_SIC	0610
125 #define KEY_SLEFT	0611
126 #define KEY_SMESSAGE	0612
127 #define KEY_SMOVE	0613
128 #define KEY_SNEXT	0614
129 #define KEY_SOPTIONS	0615
130 #define KEY_SPREVIOUS	0616
131 #define KEY_SPRINT	0617
132 #define KEY_SREDO	0620
133 #define KEY_SREPLACE	0621
134 #define KEY_SRIGHT	0622
135 #define KEY_SRSUME	0623
136 #define KEY_SSAVE	0624
137 #define KEY_SSUSPEND	0625
138 #define KEY_SUNDO	0626
139 #define KEY_SUSPEND	0627
140 #define KEY_UNDO	0630
141 
142 #define TRUE 1
143 #define FALSE 0
144 
145 #define A_STANDOUT 0001		/* standout mode		*/
146 #define A_NC_BIG5  0x0100	/* Handle Chinese Big5 characters	*/
147 #define SCROLL 1		/* text has been scrolled	*/
148 #define CLEAR  2		/* window has been cleared	*/
149 #define CHANGE 3		/* window has been changed	*/
150 #define UP 1			/* direction of scroll		*/
151 #define DOWN 2
152 
153 struct _line {
154 	struct _line *next_screen;
155 	struct _line *prev_screen;
156 	char *row;
157 	char *attributes;
158 	int last_char;
159 	int changed;
160 	int scroll;
161 	int number;
162 	};
163 
164 struct _line *top_of_win;
165 
166 typedef struct WIND {
167 	int SR;		/* starting row		*/
168 	int SC;		/* starting column	*/
169 	int LC;		/* last column		*/
170 	int LX;		/* last cursor column position	*/
171 	int LY;		/* last cursor row position	*/
172 	int Attrib;	/* attributes active in window	*/
173 	int Num_lines;	/* number of lines		*/
174 	int Num_cols;	/* number of columns		*/
175 	int scroll_up;	/* number of lines moved	*/
176 	int scroll_down;
177 	int SCROLL_CLEAR;	/* indicates that window has been scrolled or cleared	*/
178 	struct _line *first_line;
179 	struct _line **line_array;
180 	} WINDOW;
181 
182 extern WINDOW *curscr;
183 extern WINDOW *stdscr;
184 
185 extern int LINES, COLS;
186 
187 #if defined(__STDC__) || defined(__cplusplus)
188 #define P_(s) s
189 #else
190 #define P_(s) ()
191 #endif
192 
193 extern void copy_window P_((WINDOW *origin, WINDOW *destination));
194 extern void reinitscr P_((int));
195 extern void initscr P_((void));
196 extern int Get_int P_((void));
197 extern int INFO_PARSE P_((void));
198 extern int AtoI P_((void));
199 extern void Key_Get P_((void));
200 extern void keys_vt100 P_((void));
201 extern struct _line *Screenalloc P_((int columns));
202 extern WINDOW *newwin P_((int lines, int cols, int start_l, int start_c));
203 extern int Operation P_((int Temp_Stack[], int place));
204 extern void Info_Out P_((char *string, int p_list[], int place));
205 extern void wmove P_((WINDOW *window, int row, int column));
206 extern void clear_line P_((struct _line *line, int column, int cols));
207 extern void werase P_((WINDOW *window));
208 extern void wclrtoeol P_((WINDOW *window));
209 extern void wrefresh P_((WINDOW *window));
210 extern void touchwin P_((WINDOW *window));
211 extern void wnoutrefresh P_((WINDOW *window));
212 extern void flushinp P_((void));
213 extern void ungetch P_((int c));
214 extern int wgetch P_((WINDOW *window));
215 extern void Clear P_((int));
216 extern int Get_key P_((int first_char));
217 extern void waddch P_((WINDOW *window, int c));
218 extern void winsertln P_((WINDOW *window));
219 extern void wdeleteln P_((WINDOW *window));
220 extern void wclrtobot P_((WINDOW *window));
221 extern void wstandout P_((WINDOW *window));
222 extern void wstandend P_((WINDOW *window));
223 extern void waddstr P_((WINDOW *window, char *string));
224 extern void clearok P_((WINDOW *window, int flag));
225 extern void echo P_((void));
226 extern void noecho P_((void));
227 extern void raw P_((void));
228 extern void noraw P_((void));
229 extern void nl P_((void));
230 extern void nonl P_((void));
231 extern void saveterm P_((void));
232 extern void fixterm P_((void));
233 extern void resetterm P_((void));
234 extern void nodelay P_((WINDOW *window, int flag));
235 extern void idlok P_((WINDOW *window, int flag));
236 extern void keypad P_((WINDOW *window, int flag));
237 extern void savetty P_((void));
238 extern void resetty P_((void));
239 extern void endwin P_((void));
240 extern void delwin P_((WINDOW *window));
241 extern void wprintw P_((WINDOW *window, const char* format, ...));
242 extern void iout P_((WINDOW *window, int value));
243 extern int Comp_line P_((struct _line *line1, struct _line *line2));
244 extern struct _line *Insert_line P_((int row, int end_row, WINDOW *window));
245 extern struct _line *Delete_line P_((int row, int end_row, WINDOW *window));
246 extern void CLEAR_TO_EOL P_((WINDOW *window, int row, int column));
247 extern int check_delete P_((WINDOW *window, int line, int offset, struct _line *pointer_new, struct _line *pointer_old));
248 extern int check_insert P_((WINDOW *window, int line, int offset, struct _line *pointer_new, struct _line *pointer_old));
249 extern void doupdate P_((void));
250 extern void Position P_((WINDOW *window, int row, int col));
251 extern void Char_del P_((char *line, char *attrib, int offset, int maxlen));
252 extern void Char_ins P_((char *line, char *attrib, int newc, int newatt, int offset, int maxlen));
253 extern void attribute_on P_((void));
254 extern void attribute_off P_((void));
255 extern void Char_out P_((int newc, int newatt, char *line, char *attrib, int offset));
256 
257 extern void nc_setattrib P_((int));
258 extern void nc_clearattrib P_((int));
259 #undef P_
260 
261