5 * 14407 SW Teal Blvd. #C
11 /* This is the header file for a small, fast, fake curses package */
15 extern char *tgetstr();
19 /* BIOS interface used instead of termcap for MS-DOS */
33 /* faddch() is a function. a pointer to it is passed to tputs() */
39 /* CONSTANTS & SYMBOLS */
46 #define A_ALTCHARSET 4
51 /* figure out how many function keys we need to allow. */
66 extern char *FKEY
[NFKEYS
]; /* :k0=:...:k9=: codes sent by function keys */
69 /* extern variables, defined in curses.c */
70 extern char *termtype
; /* name of terminal entry */
71 extern short ospeed
; /* tty speed, eg B2400 */
73 extern char PC_
; /* Pad char */
74 extern char *BC
; /* Backspace char string */
76 extern char PC
; /* Pad char */
78 extern WINDOW
*stdscr
; /* pointer into kbuf[] */
79 extern WINDOW kbuf
[KBSIZ
]; /* a very large output buffer */
80 extern int LINES
; /* :li#: number of rows */
81 extern int COLS
; /* :co#: number of columns */
82 extern int AM
; /* :am: boolean: auto margins? */
83 extern int PT
; /* :pt: boolean: physical tabs? */
84 extern char *VB
; /* :vb=: visible bell */
85 extern char *UP
; /* :up=: move cursor up */
86 extern char *SO
; /* :so=: standout start */
87 extern char *SE
; /* :se=: standout end */
88 extern char *US
; /* :us=: underline start */
89 extern char *UE
; /* :ue=: underline end */
90 extern char *MD
; /* :md=: bold start */
91 extern char *ME
; /* :me=: bold end */
92 extern char *AS
; /* :as=: alternate (italic) start */
93 extern char *AE
; /* :ae=: alternate (italic) end */
95 extern char *MV
; /* :mv=: "visible" selection start */
97 extern char *CM
; /* :cm=: cursor movement */
98 extern char *CE
; /* :ce=: clear to end of line */
99 extern char *CD
; /* :cd=: clear to end of screen */
100 extern char *AL
; /* :al=: add a line */
101 extern char *DL
; /* :dl=: delete a line */
103 extern char *SR_
; /* :sr=: scroll reverse */
105 extern char *SR
; /* :sr=: scroll reverse */
107 extern char *KS
; /* :ks=: init string for cursor */
108 extern char *KE
; /* :ke=: restore string for cursor */
109 extern char *KU
; /* :ku=: sequence sent by up key */
110 extern char *KD
; /* :kd=: sequence sent by down key */
111 extern char *KL
; /* :kl=: sequence sent by left key */
112 extern char *KR
; /* :kr=: sequence sent by right key */
113 extern char *PU
; /* :PU=: key sequence sent by PgUp key */
114 extern char *PD
; /* :PD=: key sequence sent by PgDn key */
115 extern char *HM
; /* :HM=: key sequence sent by Home key */
116 extern char *EN
; /* :EN=: key sequence sent by End key */
117 extern char *KI
; /* :kI=: key sequence sent by Insert key */
118 extern char *IM
; /* :im=: insert mode start */
119 extern char *IC
; /* :ic=: insert following char */
120 extern char *EI
; /* :ei=: insert mode end */
121 extern char *DC
; /* :dc=: delete a character */
122 extern char *TI
; /* :ti=: terminal init */ /* GB */
123 extern char *TE
; /* :te=: terminal exit */ /* GB */
124 #ifndef NO_CURSORSHAPE
125 extern char *CQ
; /* :cQ=: normal cursor */
126 extern char *CX
; /* :cX=: cursor used for EX command/entry */
127 extern char *CV
; /* :cV=: cursor used for VI command mode */
128 extern char *CI
; /* :cI=: cursor used for VI input mode */
129 extern char *CR
; /* :cR=: cursor used for VI replace mode */
131 extern char *aend
; /* end an attribute -- either UE or ME */
132 extern char ERASEKEY
; /* taken from the ioctl structure */
134 extern char SOcolor
[];
135 extern char SEcolor
[];
136 extern char UScolor
[];
137 extern char UEcolor
[];
138 extern char MDcolor
[];
139 extern char MEcolor
[];
140 extern char AScolor
[];
141 extern char AEcolor
[];
143 extern char POPUPcolor
[];
146 extern char VISIBLEcolor
[];
148 extern char normalcolor
[];
149 #endif /* undef NO_COLOR */
151 /* Msdos-versions may use bios; others always termcap.
152 * Will emit some 'code has no effect' warnings in unix.
156 extern 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;}}
160 #define CHECKBIOS(x,y) (y)
161 #define VOIDBIOS(x,y) {y;}
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))
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))
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))
199 #define do_SR() VOIDBIOS(v_sr(), tputs(SR_, 1, faddch))
201 #define do_SR() VOIDBIOS(v_sr(), tputs(SR, 1, faddch))
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))
219 # define do_aend() VOIDBIOS((vmode=A_NORMAL), endcolor())
221 # define do_aend() VOIDBIOS((vmode=A_NORMAL), tputs(aend, 1, faddch))
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)
244 #define has_SR CHECKBIOS((char *)1, SR_)
246 #define has_SR CHECKBIOS((char *)1, SR)
248 #define has_KS CHECKBIOS((char)1, (*KS))
249 #define has_KE CHECKBIOS((char)1, (*KE))
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)
269 /* (pseudo)-Curses-functions */
272 # define _addCR VOIDBIOS(;, (stdscr[-1] == '\n' ? qaddch('\r') : (stdscr[-1] = '\n')))
275 # define _addCR VOIDBIOS(;, (stdscr[-1] == '\n' ? qaddch('\l') : (stdscr[-1] = stdscr[-1])))
277 # define _addCR VOIDBIOS(;, (stdscr[-1] == '\n' ? qaddch('\r') : 0))
282 # define qaddch(ch) CHECKBIOS(v_put(ch), (*stdscr = (ch), *stdscr++))
284 #define qaddch(ch) CHECKBIOS(v_put(ch), (*stdscr++ = (ch)))
288 #define addch(ch) if (qaddch(ch) == '\n') qaddch('\l'); else
290 #define addch(ch) if (qaddch(ch) == '\n') qaddch('\r'); else
293 extern void initscr();
294 extern void endwin();
295 extern void suspend_curses();
296 extern void resume_curses();
297 extern void attrset();
299 extern void qaddstr();
300 extern void wrefresh();
301 extern 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)