-
Notifications
You must be signed in to change notification settings - Fork 2
/
window.h
259 lines (234 loc) · 6.79 KB
/
window.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
/*
########################################################################
# This file is part of the minicom communications package for WRAMP.
#
# Copyright 1991-1995 Miquel van Smoorenburg.
# Copyright (C) 2019 The University of Waikato, Hamilton, New Zealand.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
########################################################################
* fmg 1/11/94 colors
*
*/
/*
* One character is contained in a "ELM"
*/
typedef struct _elm {
char value;
char attr;
char color;
} ELM;
/*
* Control struct of a window
*/
typedef struct _win {
int x1, y1, x2, y2; /* Coordinates */
int sy1, sy2; /* Scrolling region */
int xs, ys; /* x and y size */
char border; /* type of border */
char cursor; /* Does it have a cursor */
char attr; /* Current attribute of window */
char color; /* Current color of window */
char autocr; /* With '\n', do an automatic '\r' */
char doscroll; /* Automatically scroll up */
char wrap; /* Wrap around edge */
char direct; /* Direct write to screen ? */
short curx, cury; /* current x and y */
char o_cursor;
short o_curx;
short o_cury;
char o_attr;
char o_color; /* Position & attributes before window was opened */
ELM *map; /* Map of contents */
ELM *histbuf; /* History buffer. */
int histlines; /* How many lines we keep in the history buffer */
int histline; /* Current line in the history buffer. */
} WIN;
/*
* Stdwin is the whole screen
*/
extern WIN *stdwin; /* Whole screen */
extern int LINES, COLS; /* Size of sreen */
extern int usecolor; /* Use ansi color escape sequences */
extern int useattr; /* Use attributes (reverse, bold etc. ) */
extern int dirflush; /* Direct flush after write */
extern int screen_ibmpc; /* Literal pass-through of all characters? */
extern int screen_iso; /* Literal pass-through of all characters? */
extern int w_init; /* Already initialized? */
/* fmg 1/11/94 colors */
extern int mfcolor; /* Menu Foreground Color */
extern int mbcolor; /* Menu Background Color */
extern int tfcolor; /* Terminal Foreground Color */
extern int tbcolor; /* Terminal Background Color */
extern int sfcolor; /* Status Bar Foreground Color */
extern int sbcolor; /* Status Bar Background Color */
extern char *J_col[]; /* Color's names */
/*
* Possible attributes.
*/
#define XA_NORMAL 0
#define XA_BLINK 1
#define XA_BOLD 2
#define XA_REVERSE 4
#define XA_STANDOUT 8
#define XA_UNDERLINE 16
#define XA_ALTCHARSET 32
#define XA_BLANK 64
/*
* Possible colors
*/
#define BLACK 0
#define RED 1
#define GREEN 2
#define YELLOW 3
#define BLUE 4
#define MAGENTA 5
#define CYAN 6
#define WHITE 7
#define COLATTR(fg, bg) (((fg) << 4) + (bg))
#define COLFG(ca) ((ca) >> 4)
#define COLBG(ca) ((ca) % 16)
/*
* Possible borders.
*/
#define BNONE 0
#define BSINGLE 1
#define BDOUBLE 2
/*
* Scrolling directions.
*/
#define S_UP 1
#define S_DOWN 2
/*
* Cursor types.
*/
#define CNONE 0
#define CNORMAL 1
/*
* Title Positions
*/
#define TLEFT 0
#define TMID 1
#define TRIGHT 2
/*
* For wselect.
*/
#define NIL_FUNLIST ((void (**)()) 0)
#define NIL_FUN ((void (*)()) 0)
#define MENU_END ((char *) 0)
#define CNULL ((char *)0)
#define NIL_WIN (WIN *) 0
/*
* Function prototypes.
*/
#ifndef _PROTO
# if __STDC__
# define _PROTO(fun, args) fun args
# else
# define _PROTO(fun, args) fun()
# endif
#endif
_PROTO( int wxgetch, ( void ));
_PROTO(void wflush, ( void ));
_PROTO(WIN *wopen, ( int x1 , int y1 , int x2 , int y2 , int border ,
int attr , int fg , int bg , int direct , int hl , int rel ));
_PROTO(void wclose, ( WIN *win , int replace ));
_PROTO(void wleave, ( void ));
_PROTO(void wreturn, ( void ));
_PROTO(void wresize, (WIN *w, int x, int y ));
_PROTO(void wredraw, ( WIN *w , int newdirect ));
_PROTO(void wscroll, ( WIN *win , int dir ));
_PROTO(void wlocate, ( WIN *win , int x , int y ));
_PROTO(void wputc, ( WIN *win , int c ));
_PROTO(void wdrawelm, ( WIN *win, int y, ELM *e ));
_PROTO(void wputs, ( WIN *win , char *s ));
/* Should use stdarg et al. */
int wprintf();
_PROTO(void wbell, ( void ));
_PROTO(void wcursor, ( WIN *win , int type ));
_PROTO(void wtitle, ( WIN *w , int pos , char *s ));
_PROTO(void wcurbar, ( WIN *w , int y , int attr ));
_PROTO(int wselect, ( int x , int y , char **choices , void (**funlist)() ,
char *title , int attr , int fg , int bg ));
_PROTO(void wclrel, ( WIN *w ));
_PROTO(void wclreol, ( WIN *w ));
_PROTO(void wclrbol, ( WIN *w ));
_PROTO(void wclreos, ( WIN *w ));
_PROTO(void wclrbos, ( WIN *w ));
_PROTO(void winclr, ( WIN *w ));
_PROTO(void winsline, ( WIN *w ));
_PROTO(void wdelline, ( WIN *w ));
_PROTO(void winschar, ( WIN *w ));
_PROTO(void winschar2, ( WIN *w , int c , int move ));
_PROTO(void wdelchar, ( WIN *w ));
_PROTO(int wgets, ( WIN *win , char *s , int linemax, int totmax ));
_PROTO(void win_end, ( void ));
#ifdef BBS
_PROTO(int win_init, ( char *term, int lines ));
#else
_PROTO(int win_init, ( int fg , int bg , int attr ));
#endif
/*
* Some macro's that can be used as functions.
*/
#define wsetregion(w, z1, z2) (((w)->sy1=(w)->y1+(z1)),((w)->sy2=(w)->y1+(z2)))
#define wresetregion(w) ( (w)->sy1 = (w)->y1, (w)->sy2 = (w)->y2 )
#define wgetattr(w) ( (w)->attr )
#define wsetattr(w, a) ( (w)->attr = (a) )
#define wsetfgcol(w, fg) ( (w)->color = ((w)->color & 15) + ((fg) << 4))
#define wsetbgcol(w, bg) ( (w)->color = ((w)->color & 240) + (bg) )
#define wsetam(w) ( (w)->wrap = 1 )
#define wresetam(w) ( (w)->wrap = 0 )
/*
* Allright, now the macro's for our keyboard routines.
*/
#define K_BS 8
#define K_ESC 27
#define K_STOP 256
#define K_F1 257
#define K_F2 258
#define K_F3 259
#define K_F4 260
#define K_F5 261
#define K_F6 262
#define K_F7 263
#define K_F8 264
#define K_F9 265
#define K_F10 266
#define K_HOME 267
#define K_PGUP 268
#define K_UP 269
#define K_LT 270
#define K_RT 271
#define K_DN 272
#define K_END 273
#define K_PGDN 274
#define K_INS 275
#define K_DEL 276
#define K_F11 277
#define K_F12 278
#define NUM_KEYS 23
#define KEY_OFFS 256
/* Here's where the meta keycode start. (512 + keycode). */
#define K_META 512
#ifndef EOF
# define EOF ((int) -1)
#endif
#define K_ERA '\b'
#define K_KILL ((int) -2)
/* Internal structure. */
struct key {
char *cap;
char len;
};