source: trunk/minix/commands/elvis/curses.h@ 10

Last change on this file since 10 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 10.4 KB
Line 
1/* curses.h */
2
3/* Author:
4 * Steve Kirkendall
5 * 14407 SW Teal Blvd. #C
6 * Beaverton, OR 97005
7 * kirkenda@cs.pdx.edu
8 */
9
10
11/* This is the header file for a small, fast, fake curses package */
12
13/* termcap stuff */
14extern char *tgoto();
15extern char *tgetstr();
16extern void tputs();
17
18#if MSDOS
19/* BIOS interface used instead of termcap for MS-DOS */
20extern int vmode;
21extern void v_up();
22extern void v_cb();
23extern void v_cs();
24extern void v_ce();
25extern void v_cl();
26extern void v_cd();
27extern void v_al();
28extern void v_dl();
29extern void v_sr();
30extern void v_move();
31#endif
32
33/* faddch() is a function. a pointer to it is passed to tputs() */
34extern int faddch();
35
36/* data types */
37#define WINDOW char
38
39/* CONSTANTS & SYMBOLS */
40#define TRUE 1
41#define FALSE 0
42#define A_NORMAL 0
43#define A_STANDOUT 1
44#define A_BOLD 2
45#define A_UNDERLINE 3
46#define A_ALTCHARSET 4
47#define A_POPUP 5
48#define A_VISIBLE 6
49#define KBSIZ 4096
50
51/* figure out how many function keys we need to allow. */
52#ifndef NO_FKEY
53# ifdef NO_SHIFT_FKEY
54# define NFKEYS 10
55# else
56# ifdef NO_CTRL_FKEY
57# define NFKEYS 20
58# else
59# ifdef NO_ALT_FKEY
60# define NFKEYS 30
61# else
62# define NFKEYS 40
63# endif
64# endif
65# endif
66extern char *FKEY[NFKEYS]; /* :k0=:...:k9=: codes sent by function keys */
67#endif
68
69/* extern variables, defined in curses.c */
70extern char *termtype; /* name of terminal entry */
71extern short ospeed; /* tty speed, eg B2400 */
72#if OSK
73extern char PC_; /* Pad char */
74extern char *BC; /* Backspace char string */
75#else
76extern char PC; /* Pad char */
77#endif
78extern WINDOW *stdscr; /* pointer into kbuf[] */
79extern WINDOW kbuf[KBSIZ]; /* a very large output buffer */
80extern int LINES; /* :li#: number of rows */
81extern int COLS; /* :co#: number of columns */
82extern int AM; /* :am: boolean: auto margins? */
83extern int PT; /* :pt: boolean: physical tabs? */
84extern char *VB; /* :vb=: visible bell */
85extern char *UP; /* :up=: move cursor up */
86extern char *SO; /* :so=: standout start */
87extern char *SE; /* :se=: standout end */
88extern char *US; /* :us=: underline start */
89extern char *UE; /* :ue=: underline end */
90extern char *MD; /* :md=: bold start */
91extern char *ME; /* :me=: bold end */
92extern char *AS; /* :as=: alternate (italic) start */
93extern char *AE; /* :ae=: alternate (italic) end */
94#ifndef NO_VISIBLE
95extern char *MV; /* :mv=: "visible" selection start */
96#endif
97extern char *CM; /* :cm=: cursor movement */
98extern char *CE; /* :ce=: clear to end of line */
99extern char *CD; /* :cd=: clear to end of screen */
100extern char *AL; /* :al=: add a line */
101extern char *DL; /* :dl=: delete a line */
102#if OSK
103extern char *SR_; /* :sr=: scroll reverse */
104#else
105extern char *SR; /* :sr=: scroll reverse */
106#endif
107extern char *KS; /* :ks=: init string for cursor */
108extern char *KE; /* :ke=: restore string for cursor */
109extern char *KU; /* :ku=: sequence sent by up key */
110extern char *KD; /* :kd=: sequence sent by down key */
111extern char *KL; /* :kl=: sequence sent by left key */
112extern char *KR; /* :kr=: sequence sent by right key */
113extern char *PU; /* :PU=: key sequence sent by PgUp key */
114extern char *PD; /* :PD=: key sequence sent by PgDn key */
115extern char *HM; /* :HM=: key sequence sent by Home key */
116extern char *EN; /* :EN=: key sequence sent by End key */
117extern char *KI; /* :kI=: key sequence sent by Insert key */
118extern char *IM; /* :im=: insert mode start */
119extern char *IC; /* :ic=: insert following char */
120extern char *EI; /* :ei=: insert mode end */
121extern char *DC; /* :dc=: delete a character */
122extern char *TI; /* :ti=: terminal init */ /* GB */
123extern char *TE; /* :te=: terminal exit */ /* GB */
124#ifndef NO_CURSORSHAPE
125extern char *CQ; /* :cQ=: normal cursor */
126extern char *CX; /* :cX=: cursor used for EX command/entry */
127extern char *CV; /* :cV=: cursor used for VI command mode */
128extern char *CI; /* :cI=: cursor used for VI input mode */
129extern char *CR; /* :cR=: cursor used for VI replace mode */
130#endif
131extern char *aend; /* end an attribute -- either UE or ME */
132extern char ERASEKEY; /* taken from the ioctl structure */
133#ifndef NO_COLOR
134extern char SOcolor[];
135extern char SEcolor[];
136extern char UScolor[];
137extern char UEcolor[];
138extern char MDcolor[];
139extern char MEcolor[];
140extern char AScolor[];
141extern char AEcolor[];
142# ifndef NO_POPUP
143extern char POPUPcolor[];
144# endif
145# ifndef NO_VISIBLE
146extern char VISIBLEcolor[];
147# endif
148extern char normalcolor[];
149#endif /* undef NO_COLOR */
150
151/* Msdos-versions may use bios; others always termcap.
152 * Will emit some 'code has no effect' warnings in unix.
153 */
154
155#if MSDOS
156extern char o_pcbios[1]; /* BAH! */
157#define CHECKBIOS(x,y) (*o_pcbios ? (x) : (y))
158#define VOIDBIOS(x,y) {if (*o_pcbios) {x;} else {y;}}
159#else
160#define CHECKBIOS(x,y) (y)
161#define VOIDBIOS(x,y) {y;}
162#endif
163
164#ifndef NO_COLOR
165# define setcolor(m,a) CHECKBIOS(bioscolor(m,a), ansicolor(m,a))
166# define fixcolor() VOIDBIOS(;, tputs(normalcolor, 1, faddch))
167# define quitcolor() CHECKBIOS(biosquit(), ansiquit())
168# define do_SO() VOIDBIOS((vmode=A_STANDOUT), tputs(SOcolor, 1, faddch))
169# define do_SE() VOIDBIOS((vmode=A_NORMAL), tputs(SEcolor, 1, faddch))
170# define do_US() VOIDBIOS((vmode=A_UNDERLINE), tputs(UScolor, 1, faddch))
171# define do_UE() VOIDBIOS((vmode=A_NORMAL), tputs(UEcolor, 1, faddch))
172# define do_MD() VOIDBIOS((vmode=A_BOLD), tputs(MDcolor, 1, faddch))
173# define do_ME() VOIDBIOS((vmode=A_NORMAL), tputs(MEcolor, 1, faddch))
174# define do_AS() VOIDBIOS((vmode=A_ALTCHARSET), tputs(AScolor, 1, faddch))
175# define do_AE() VOIDBIOS((vmode=A_NORMAL), tputs(AEcolor, 1, faddch))
176# define do_POPUP() VOIDBIOS((vmode=A_POPUP), tputs(POPUPcolor, 1, faddch))
177# define do_VISIBLE() VOIDBIOS((vmode=A_VISIBLE), tputs(VISIBLEcolor, 1, faddch))
178#else
179# define do_SO() VOIDBIOS((vmode=A_STANDOUT), tputs(SO, 1, faddch))
180# define do_SE() VOIDBIOS((vmode=A_NORMAL), tputs(SE, 1, faddch))
181# define do_US() VOIDBIOS((vmode=A_UNDERLINE), tputs(US, 1, faddch))
182# define do_UE() VOIDBIOS((vmode=A_NORMAL), tputs(UE, 1, faddch))
183# define do_MD() VOIDBIOS((vmode=A_BOLD), tputs(MD, 1, faddch))
184# define do_ME() VOIDBIOS((vmode=A_NORMAL), tputs(ME, 1, faddch))
185# define do_AS() VOIDBIOS((vmode=A_ALTCHARSET), tputs(AS, 1, faddch))
186# define do_AE() VOIDBIOS((vmode=A_NORMAL), tputs(AE, 1, faddch))
187# define do_POPUP() VOIDBIOS((vmode=A_POPUP), tputs(SO, 1, faddch))
188# define do_VISIBLE() VOIDBIOS((vmode=A_VISIBLE), tputs(MV, 1, faddch))
189#endif
190
191#define do_VB() VOIDBIOS(;, tputs(VB, 1, faddch))
192#define do_UP() VOIDBIOS(v_up(), tputs(UP, 1, faddch))
193#undef do_CM /* move */
194#define do_CE() VOIDBIOS(v_ce(), tputs(CE, 1, faddch))
195#define do_CD() VOIDBIOS(v_cd(), tputs(CD, 1, faddch))
196#define do_AL() VOIDBIOS(v_al(), tputs(AL, LINES, faddch))
197#define do_DL() VOIDBIOS(v_dl(), tputs(DL, LINES, faddch))
198#if OSK
199#define do_SR() VOIDBIOS(v_sr(), tputs(SR_, 1, faddch))
200#else
201#define do_SR() VOIDBIOS(v_sr(), tputs(SR, 1, faddch))
202#endif
203#define do_KS() VOIDBIOS(1, tputs(KS, 1, faddch))
204#define do_KE() VOIDBIOS(1, tputs(KE, 1, faddch))
205#define do_IM() VOIDBIOS(;, tputs(IM, 1, faddch))
206#define do_IC() VOIDBIOS(;, tputs(IC, 1, faddch))
207#define do_EI() VOIDBIOS(;, tputs(EI, 1, faddch))
208#define do_DC() VOIDBIOS(;, tputs(DC, COLS, faddch))
209#define do_TI() VOIDBIOS(;, (void)ttywrite(TI, (unsigned)strlen(TI)))
210#define do_TE() VOIDBIOS(;, (void)ttywrite(TE, (unsigned)strlen(TE)))
211#ifndef NO_CURSORSHAPE
212# define do_CQ() VOIDBIOS(v_cs(), tputs(CQ, 1, faddch))
213# define do_CX() VOIDBIOS(v_cs(), tputs(CX, 1, faddch))
214# define do_CV() VOIDBIOS(v_cs(), tputs(CV, 1, faddch))
215# define do_CI() VOIDBIOS(v_cb(), tputs(CI, 1, faddch))
216# define do_CR() VOIDBIOS(v_cb(), tputs(CR, 1, faddch))
217#endif
218#ifndef NO_COLOR
219# define do_aend() VOIDBIOS((vmode=A_NORMAL), endcolor())
220#else
221# define do_aend() VOIDBIOS((vmode=A_NORMAL), tputs(aend, 1, faddch))
222#endif
223
224#define has_AM CHECKBIOS(1, AM)
225#define has_PT CHECKBIOS(0, PT)
226#define has_VB CHECKBIOS((char *)0, VB)
227#define has_UP CHECKBIOS((char *)1, UP)
228#define has_SO CHECKBIOS((char)1, (*SO))
229#define has_SE CHECKBIOS((char)1, (*SE))
230#define has_US CHECKBIOS((char)1, (*US))
231#define has_UE CHECKBIOS((char)1, (*UE))
232#define has_MD CHECKBIOS((char)1, (*MD))
233#define has_ME CHECKBIOS((char)1, (*ME))
234#define has_AS CHECKBIOS((char)1, (*AS))
235#define has_AE CHECKBIOS((char)1, (*AE))
236#undef has_CM /* cursor move: don't need */
237#define has_CB CHECKBIOS(1, 0)
238#define has_CS CHECKBIOS(1, 0)
239#define has_CE CHECKBIOS((char *)1, CE)
240#define has_CD CHECKBIOS((char *)1, CD)
241#define has_AL CHECKBIOS((char *)1, AL)
242#define has_DL CHECKBIOS((char *)1, DL)
243#if OSK
244#define has_SR CHECKBIOS((char *)1, SR_)
245#else
246#define has_SR CHECKBIOS((char *)1, SR)
247#endif
248#define has_KS CHECKBIOS((char)1, (*KS))
249#define has_KE CHECKBIOS((char)1, (*KE))
250#define has_KU KU
251#define has_KD KD
252#define has_KL KL
253#define has_KR KR
254#define has_HM HM
255#define has_EN EN
256#define has_PU PU
257#define has_PD PD
258#define has_KI KI
259#define has_IM CHECKBIOS((char)0, (*IM))
260#define has_IC CHECKBIOS((char)0, (*IC))
261#define has_EI CHECKBIOS((char)0, (*EI))
262#define has_DC CHECKBIOS((char *)0, DC)
263#define has_TI CHECKBIOS((char)0, (*TI))
264#define has_TE CHECKBIOS((char)0, (*TE))
265#ifndef NO_CURSORSHAPE
266#define has_CQ CHECKBIOS((char *)1, CQ)
267#endif
268
269/* (pseudo)-Curses-functions */
270
271#ifdef lint
272# define _addCR VOIDBIOS(;, (stdscr[-1] == '\n' ? qaddch('\r') : (stdscr[-1] = '\n')))
273#else
274# if OSK
275# define _addCR VOIDBIOS(;, (stdscr[-1] == '\n' ? qaddch('\l') : (stdscr[-1] = stdscr[-1])))
276# else
277# define _addCR VOIDBIOS(;, (stdscr[-1] == '\n' ? qaddch('\r') : 0))
278# endif
279#endif
280
281#ifdef AZTEC_C
282# define qaddch(ch) CHECKBIOS(v_put(ch), (*stdscr = (ch), *stdscr++))
283#else
284#define qaddch(ch) CHECKBIOS(v_put(ch), (*stdscr++ = (ch)))
285#endif
286
287#if OSK
288#define addch(ch) if (qaddch(ch) == '\n') qaddch('\l'); else
289#else
290#define addch(ch) if (qaddch(ch) == '\n') qaddch('\r'); else
291#endif
292
293extern void initscr();
294extern void endwin();
295extern void suspend_curses();
296extern void resume_curses();
297extern void attrset();
298extern void insch();
299extern void qaddstr();
300extern void wrefresh();
301extern void wqrefresh();
302#define addstr(str) {qaddstr(str); _addCR;}
303#define move(y,x) VOIDBIOS(v_move(x,y), tputs(tgoto(CM, x, y), 1, faddch))
304#define mvaddch(y,x,ch) {move(y,x); addch(ch);}
305#define refresh() VOIDBIOS(;, wrefresh())
306#define standout() do_SO()
307#define standend() do_SE()
308#define clrtoeol() do_CE()
309#define clrtobot() do_CD()
310#define insertln() do_AL()
311#define deleteln() do_DL()
312#define delch() do_DC()
313#define scrollok(w,b)
314#define raw()
315#define echo()
316#define cbreak()
317#define noraw()
318#define noecho()
319#define nocbreak()
Note: See TracBrowser for help on using the repository browser.