1 /*
2  * term.h: header file for term.c
3  *
4  * Copyright 1990 Michael Sandrof
5  * Copyright 1997 EPIC Software Labs
6  * Copyright 1998 J. Kean Johnston
7  * See the COPYRIGHT file, or do a HELP IRCII COPYRIGHT
8  */
9 
10 #ifndef __term_h__
11 #define __term_h__
12 
13 /* To get declaration of "output_screen" */
14 #include "screen.h"
15 
16 extern	volatile int	need_redraw;
17 extern	int	meta_mode;
18 
19 /*
20  * This puts a character to the current target, whatever it is.
21  * All output everywhere should go through this.
22  * This does not mangle its output, so its suitable for outputting
23  * escape sequences.
24  */
25 #if !defined(WTERM_C) && !defined(WSERV_C)
26 #define current_ftarget (output_screen ? output_screen->fpout : stdout)
27 
28 #ifdef __need_putchar_x__
29 __inline__
putchar_x(int c)30 static int putchar_x (int c) { return fputc((int) c, current_ftarget ); }
31 #endif
32 
33 #ifdef __need_term_flush__
34 __inline__
term_flush(void)35 static void term_flush (void) { fflush( current_ftarget ); }
36 #endif
37 #endif
38 
39 #define	TERM_SGR_BOLD_ON	1
40 #define TERM_SGR_BOLD_OFF	2
41 #define TERM_SGR_BLINK_ON	3
42 #define TERM_SGR_BLINK_OFF	4
43 #define TERM_SGR_UNDL_ON	5
44 #define TERM_SGR_UNDL_OFF	6
45 #define TERM_SGR_REV_ON		7
46 #define TERM_SGR_REV_OFF	8
47 #define TERM_SGR_NORMAL		9
48 #define TERM_SGR_RESET		10
49 #define TERM_SGR_FOREGROUND	11
50 #define TERM_SGR_BACKGROUND	12
51 #define TERM_SGR_GCHAR		13
52 #define TERM_SGR_ALTCHAR_ON	14
53 #define TERM_SGR_ALTCHAR_OFF	15
54 #define TERM_SGR_MAXVAL		16
55 
56 #define TERM_CAN_CUP		1 << 0
57 #define TERM_CAN_CLEAR		1 << 1
58 #define TERM_CAN_CLREOL		1 << 2
59 #define TERM_CAN_RIGHT		1 << 3
60 #define TERM_CAN_LEFT		1 << 4
61 #define TERM_CAN_SCROLL		1 << 5
62 #define TERM_CAN_DELETE		1 << 6
63 #define TERM_CAN_INSERT		1 << 7
64 #define TERM_CAN_DELLINES	1 << 8
65 #define TERM_CAN_INSLINES	1 << 9
66 #define TERM_CAN_REPEAT		1 << 10
67 #define TERM_CAN_BOLD		1 << 11
68 #define TERM_CAN_BLINK		1 << 12
69 #define TERM_CAN_UNDL		1 << 13
70 #define TERM_CAN_REVERSE	1 << 14
71 #define TERM_CAN_COLOR		1 << 15
72 #define TERM_CAN_GCHAR		1 << 16
73 
74 #if 0
75 extern	char	*TI_cr, *TI_nl;
76 extern	int	TI_lines, TI_cols;
77 extern	char	*TI_sgrstrs[];
78 extern	char	*TI_forecolors[];
79 extern	char	*TI_backcolors[];
80 #endif
81 
82 extern	int	termfeatures;
83 extern	struct	my_term	*current_term;
84 
85 /*      Our variable name   Cap / Info      Description */
86 struct my_term {
87 	int TI_bw;	 /* bw  / bw        cub1 wraps from column 0 to last column */
88 	int TI_am;	 /* am  / am        terminal has automatic margins */
89 	int TI_xsb;	 /* xb  / xsb       beehive (f1=escape, f2=ctrl C) */
90 	int TI_xhp;	 /* xs  / xhp       standout not erased by overwriting (hp) */
91 	int TI_xenl;	 /* xn  / xenl      newline ignored after 80 cols (concept) */
92 	int TI_eo;	 /* eo  / eo        can erase overstrikes with a blank */
93 	int TI_gn;	 /* gn  / gn        generic line type */
94 	int TI_hc;	 /* hc  / hc        hardcopy terminal */
95 	int TI_km;	 /* km  / km        Has a meta key (shift, sets parity bit) */
96 	int TI_hs;	 /* hs  / hs        has extra status line */
97 	int TI_in;	 /* in  / in        insert mode distinguishes nulls */
98 	int TI_da;	 /* da  / da        display may be retained above the screen */
99 	int TI_db;	 /* db  / db        display may be retained below the screen */
100 	int TI_mir;	 /* mi  / mir       safe to move while in insert mode */
101 	int TI_msgr;	 /* ms  / msgr      safe to move while in standout mode */
102 	int TI_os;	 /* os  / os        terminal can overstrike */
103 	int TI_eslok;	 /* es  / eslok     escape can be used on the status line */
104 	int TI_xt;	 /* xt  / xt        tabs destructive, magic so char (t1061) */
105 	int TI_hz;	 /* hz  / hz        can't print ~'s (hazeltine) */
106 	int TI_ul;	 /* ul  / ul        underline character overstrikes */
107 	int TI_xon;	 /* xo  / xon       terminal uses xon/xoff handshaking */
108 	int TI_nxon;	 /* nx  / nxon      padding won't work, xon/xoff required */
109 	int TI_mc5i;	 /* 5i  / mc5i      printer won't echo on screen */
110 	int TI_chts;	 /* HC  / chts      cursor is hard to see */
111 	int TI_nrrmc;	 /* NR  / nrrmc     smcup does not reverse rmcup */
112 	int TI_npc;	 /* NP  / npc       pad character does not exist */
113 	int TI_ndscr;	 /* ND  / ndscr     scrolling region is non-destructive */
114 	int TI_ccc;	 /* cc  / ccc       terminal can re-define existing colors */
115 	int TI_bce;	 /* ut  / bce       screen erased with background color */
116 	int TI_hls;	 /* hl  / hls       terminal uses only HLS color notation (Tektronix) */
117 	int TI_xhpa;	 /* YA  / xhpa      only positive motion for hpa/mhpa caps */
118 	int TI_crxm;	 /* YB  / crxm      using cr turns off micro mode */
119 	int TI_daisy;	 /* YC  / daisy     printer needs operator to change character set */
120 	int TI_xvpa;	 /* YD  / xvpa      only positive motion for vpa/mvpa caps */
121 	int TI_sam;	 /* YE  / sam       printing in last column causes cr */
122 	int TI_cpix;	 /* YF  / cpix      changing character pitch changes resolution */
123 	int TI_lpix;	 /* YG  / lpix      changing line pitch changes resolution */
124 	int TI_cols;	 /* co  / cols      number of columns in a line */
125 	int TI_it;	 /* it  / it        tabs initially every # spaces */
126 	int TI_lines;	 /* li  / lines     number of lines on screen or page */
127 	int TI_lm;	 /* lm  / lm        lines of memory if > line. 0 means varies */
128 	int TI_xmc;	 /* sg  / xmc       number of blank characters left by smso or rmso */
129 	int TI_pb;	 /* pb  / pb        lowest baud rate where padding needed */
130 	int TI_vt;	 /* vt  / vt        virtual terminal number (CB/unix) */
131 	int TI_wsl;	 /* ws  / wsl       number of columns in status line */
132 	int TI_nlab;	 /* Nl  / nlab      number of labels on screen */
133 	int TI_lh;	 /* lh  / lh        rows in each label */
134 	int TI_lw;	 /* lw  / lw        columns in each label */
135 	int TI_ma;	 /* ma  / ma        maximum combined attributes terminal can handle */
136 	int TI_wnum;	 /* MW  / wnum      maximum number of defineable windows */
137 	int TI_colors;	 /* Co  / colors    maximum number of colors on screen */
138 	int TI_pairs;	 /* pa  / pairs     maximum number of color-pairs on the screen */
139 	int TI_ncv;	 /* NC  / ncv       video attributes that can't be used with colors */
140 	int TI_bufsz;	 /* Ya  / bufsz     numbers of bytes buffered before printing */
141 	int TI_spinv;	 /* Yb  / spinv     spacing of pins vertically in pins per inch */
142 	int TI_spinh;	 /* Yc  / spinh     spacing of dots horizontally in dots per inch */
143 	int TI_maddr;	 /* Yd  / maddr     maximum value in micro_..._address */
144 	int TI_mjump;	 /* Ye  / mjump     maximum value in parm_..._micro */
145 	int TI_mcs;	 /* Yf  / mcs       character step size when in micro mode */
146 	int TI_mls;	 /* Yg  / mls       line step size when in micro mode */
147 	int TI_npins;	 /* Yh  / npins     numbers of pins in print-head */
148 	int TI_orc;	 /* Yi  / orc       horizontal resolution in units per line */
149 	int TI_orl;	 /* Yj  / orl       vertical resolution in units per line */
150 	int TI_orhi;	 /* Yk  / orhi      horizontal resolution in units per inch */
151 	int TI_orvi;	 /* Yl  / orvi      vertical resolution in units per inch */
152 	int TI_cps;	 /* Ym  / cps       print rate in characters per second */
153 	int TI_widcs;	 /* Yn  / widcs     character step size when in double wide mode */
154 	int TI_btns;	 /* BT  / btns      number of buttons on mouse */
155 	int TI_bitwin;	 /* Yo  / bitwin    number of passes for each bit-image row */
156 	int TI_bitype;	 /* Yp  / bitype    type of bit-image device */
157 	const char *TI_cbt;	 /* bt  / cbt       back tab (P) */
158 	const char *TI_bel;	 /* bl  / bel       audible signal (bell) (P) */
159 	const char *TI_cr;	 /* cr  / cr        carriage return (P*) (P*) */
160 	const char *TI_csr;	 /* cs  / csr       change region to line #1 to line #2 (P) */
161 	const char *TI_tbc;	 /* ct  / tbc       clear all tab stops (P) */
162 	const char *TI_clear;	 /* cl  / clear     clear screen and home cursor (P*) */
163 	const char *TI_el;	 /* ce  / el        clear to end of line (P) */
164 	const char *TI_ed;	 /* cd  / ed        clear to end of screen (P*) */
165 	const char *TI_hpa;	 /* ch  / hpa       horizontal position #1, absolute (P) */
166 	const char *TI_cmdch;	 /* CC  / cmdch     terminal settable cmd character in prototype !? */
167 	const char *TI_cup;	 /* cm  / cup       move to row #1 columns #2 */
168 	const char *TI_cud1;	 /* do  / cud1      down one line */
169 	const char *TI_home;	 /* ho  / home      home cursor (if no cup) */
170 	const char *TI_civis;	 /* vi  / civis     make cursor invisible */
171 	const char *TI_cub1;	 /* le  / cub1      move left one space */
172 	const char *TI_mrcup;	 /* CM  / mrcup     memory relative cursor addressing */
173 	const char *TI_cnorm;	 /* ve  / cnorm     make cursor appear normal (undo civis/cvvis) */
174 	const char *TI_cuf1;	 /* nd  / cuf1      non-destructive space (move right one space) */
175 	const char *TI_ll;	 /* ll  / ll        last line, first column (if no cup) */
176 	const char *TI_cuu1;	 /* up  / cuu1      up one line */
177 	const char *TI_cvvis;	 /* vs  / cvvis     make cursor very visible */
178 	const char *TI_dch1;	 /* dc  / dch1      delete character (P*) */
179 	const char *TI_dl1;	 /* dl  / dl1       delete line (P*) */
180 	const char *TI_dsl;	 /* ds  / dsl       disable status line */
181 	const char *TI_hd;	 /* hd  / hd        half a line down */
182 	const char *TI_smacs;	 /* as  / smacs     start alternate character set (P) */
183 	const char *TI_blink;	 /* mb  / blink     turn on blinking */
184 	const char *TI_bold;	 /* md  / bold      turn on bold (extra bright) mode */
185 	const char *TI_smcup;	 /* ti  / smcup     string to start programs using cup */
186 	const char *TI_smdc;	 /* dm  / smdc      enter delete mode */
187 	const char *TI_dim;	 /* mh  / dim       turn on half-bright mode */
188 	const char *TI_smir;	 /* im  / smir      enter insert mode */
189 	const char *TI_invis;	 /* mk  / invis     turn on blank mode (characters invisible) */
190 	const char *TI_prot;	 /* mp  / prot      turn on protected mode */
191 	const char *TI_rev;	 /* mr  / rev       turn on reverse video mode */
192 	const char *TI_smso;	 /* so  / smso      begin standout mode */
193 	const char *TI_smul;	 /* us  / smul      begin underline mode */
194 	const char *TI_ech;	 /* ec  / ech       erase #1 characters (P) */
195 	const char *TI_rmacs;	 /* ae  / rmacs     end alternate character set (P) */
196 	const char *TI_sgr0;	 /* me  / sgr0      turn off all attributes */
197 	const char *TI_rmcup;	 /* te  / rmcup     strings to end programs using cup */
198 	const char *TI_rmdc;	 /* ed  / rmdc      end delete mode */
199 	const char *TI_rmir;	 /* ei  / rmir      exit insert mode */
200 	const char *TI_rmso;	 /* se  / rmso      exit standout mode */
201 	const char *TI_rmul;	 /* ue  / rmul      exit underline mode */
202 	const char *TI_flash;	 /* vb  / flash     visible bell (may not move cursor) */
203 	const char *TI_ff;	 /* ff  / ff        hardcopy terminal page eject (P*) */
204 	const char *TI_fsl;	 /* fs  / fsl       return from status line */
205 	const char *TI_is1;	 /* i1  / is1       initialization string */
206 	const char *TI_is2;	 /* is  / is2       initialization string */
207 	const char *TI_is3;	 /* i3  / is3       initialization string */
208 	const char *TI_if;	 /* if  / if        name of initialization file */
209 	const char *TI_ich1;	 /* ic  / ich1      insert character (P) */
210 	const char *TI_il1;	 /* al  / il1       insert line (P*) */
211 	const char *TI_ip;	 /* ip  / ip        insert padding after inserted character */
212 	const char *TI_kbs;	 /* kb  / kbs       backspace key */
213 	const char *TI_ktbc;	 /* ka  / ktbc      clear-all-tabs key */
214 	const char *TI_kclr;	 /* kC  / kclr      clear-screen or erase key */
215 	const char *TI_kctab;	 /* kt  / kctab     clear-tab key */
216 	const char *TI_kdch1;	 /* kD  / kdch1     delete-character key */
217 	const char *TI_kdl1;	 /* kL  / kdl1      delete-line key */
218 	const char *TI_kcud1;	 /* kd  / kcud1     down-arrow key */
219 	const char *TI_krmir;	 /* kM  / krmir     sent by rmir or smir in insert mode */
220 	const char *TI_kel;	 /* kE  / kel       clear-to-end-of-line key */
221 	const char *TI_ked;	 /* kS  / ked       clear-to-end-of-screen key */
222 	const char *TI_kf0;	 /* k0  / kf0       F0 function key */
223 	const char *TI_kf1;	 /* k1  / kf1       F1 function key */
224 	const char *TI_kf10;	 /* k;  / kf10      F10 function key */
225 	const char *TI_kf2;	 /* k2  / kf2       F2 function key */
226 	const char *TI_kf3;	 /* k3  / kf3       F3 function key */
227 	const char *TI_kf4;	 /* k4  / kf4       F4 function key */
228 	const char *TI_kf5;	 /* k5  / kf5       F5 function key */
229 	const char *TI_kf6;	 /* k6  / kf6       F6 function key */
230 	const char *TI_kf7;	 /* k7  / kf7       F7 function key */
231 	const char *TI_kf8;	 /* k8  / kf8       F8 function key */
232 	const char *TI_kf9;	 /* k9  / kf9       F9 function key */
233 	const char *TI_khome;	 /* kh  / khome     home key */
234 	const char *TI_kich1;	 /* kI  / kich1     insert-character key */
235 	const char *TI_kil1;	 /* kA  / kil1      insert-line key */
236 	const char *TI_kcub1;	 /* kl  / kcub1     left-arrow key */
237 	const char *TI_kll;	 /* kH  / kll       lower-left key (home down) */
238 	const char *TI_knp;	 /* kN  / knp       next-page key */
239 	const char *TI_kpp;	 /* kP  / kpp       previous-page key */
240 	const char *TI_kcuf1;	 /* kr  / kcuf1     right-arrow key */
241 	const char *TI_kind;	 /* kF  / kind      scroll-forward key */
242 	const char *TI_kri;	 /* kR  / kri       scroll-backward key */
243 	const char *TI_khts;	 /* kT  / khts      set-tab key */
244 	const char *TI_kcuu1;	 /* ku  / kcuu1     up-arrow key */
245 	const char *TI_rmkx;	 /* ke  / rmkx      leave 'keyboard_transmit' mode */
246 	const char *TI_smkx;	 /* ks  / smkx      enter 'keyboard_transmit' mode */
247 	const char *TI_lf0;	 /* l0  / lf0       label on function key f0 if not f0 */
248 	const char *TI_lf1;	 /* l1  / lf1       label on function key f1 if not f1 */
249 	const char *TI_lf10;	 /* la  / lf10      label on function key f10 if not f10 */
250 	const char *TI_lf2;	 /* l2  / lf2       label on function key f2 if not f2 */
251 	const char *TI_lf3;	 /* l3  / lf3       label on function key f3 if not f3 */
252 	const char *TI_lf4;	 /* l4  / lf4       label on function key f4 if not f4 */
253 	const char *TI_lf5;	 /* l5  / lf5       label on function key f5 if not f5 */
254 	const char *TI_lf6;	 /* l6  / lf6       label on function key f6 if not f6 */
255 	const char *TI_lf7;	 /* l7  / lf7       label on function key f7 if not f7 */
256 	const char *TI_lf8;	 /* l8  / lf8       label on function key f8 if not f8 */
257 	const char *TI_lf9;	 /* l9  / lf9       label on function key f9 if not f9 */
258 	const char *TI_rmm;	 /* mo  / rmm       turn off meta mode */
259 	const char *TI_smm;	 /* mm  / smm       turn on meta mode (8th-bit on) */
260 	const char *TI_nel;	 /* nw  / nel       newline (behave like cr followed by lf) */
261 	const char *TI_pad;	 /* pc  / pad       padding char (instead of null) */
262 	const char *TI_dch;	 /* DC  / dch       delete #1 characters (P*) */
263 	const char *TI_dl;	 /* DL  / dl        delete #1 lines (P*) */
264 	const char *TI_cud;	 /* DO  / cud       down #1 lines (P*) */
265 	const char *TI_ich;	 /* IC  / ich       insert #1 characters (P*) */
266 	const char *TI_indn;	 /* SF  / indn      scroll forward #1 lines (P) */
267 	const char *TI_il;	 /* AL  / il        insert #1 lines (P*) */
268 	const char *TI_cub;	 /* LE  / cub       move #1 characters to the left (P) */
269 	const char *TI_cuf;	 /* RI  / cuf       move #1 characters to the right (P*) */
270 	const char *TI_rin;	 /* SR  / rin       scroll back #1 lines (P) */
271 	const char *TI_cuu;	 /* UP  / cuu       up #1 lines (P*) */
272 	const char *TI_pfkey;	 /* pk  / pfkey     program function key #1 to type string #2 */
273 	const char *TI_pfloc;	 /* pl  / pfloc     program function key #1 to execute string #2 */
274 	const char *TI_pfx;	 /* px  / pfx       program function key #1 to transmit string #2 */
275 	const char *TI_mc0;	 /* ps  / mc0       print contents of screen */
276 	const char *TI_mc4;	 /* pf  / mc4       turn off printer */
277 	const char *TI_mc5;	 /* po  / mc5       turn on printer */
278 	const char *TI_rep;	 /* rp  / rep       repeat char #1 #2 times (P*) */
279 	const char *TI_rs1;	 /* r1  / rs1       reset string */
280 	const char *TI_rs2;	 /* r2  / rs2       reset string */
281 	const char *TI_rs3;	 /* r3  / rs3       reset string */
282 	const char *TI_rf;	 /* rf  / rf        name of reset file */
283 	const char *TI_rc;	 /* rc  / rc        restore cursor to position of last save_cursor */
284 	const char *TI_vpa;	 /* cv  / vpa       vertical position #1 absolute (P) */
285 	const char *TI_sc;	 /* sc  / sc        save current cursor position (P) */
286 	const char *TI_ind;	 /* sf  / ind       scroll text up (P) */
287 	const char *TI_ri;	 /* sr  / ri        scroll text down (P) */
288 	const char *TI_sgr;	 /* sa  / sgr       define video attributes #1-#9 (PG9) */
289 	const char *TI_hts;	 /* st  / hts       set a tab in every row, current columns */
290 	const char *TI_wind;	 /* wi  / wind      current window is lines #1-#2 cols #3-#4 */
291 	const char *TI_ht;	 /* ta  / ht        tab to next 8-space hardware tab stop */
292 	const char *TI_tsl;	 /* ts  / tsl       move to status line */
293 	const char *TI_uc;	 /* uc  / uc        underline char and move past it */
294 	const char *TI_hu;	 /* hu  / hu        half a line up */
295 	const char *TI_iprog;	 /* iP  / iprog     path name of program for initialization */
296 	const char *TI_ka1;	 /* K1  / ka1       upper left of keypad */
297 	const char *TI_ka3;	 /* K3  / ka3       upper right of keypad */
298 	const char *TI_kb2;	 /* K2  / kb2       center of keypad */
299 	const char *TI_kc1;	 /* K4  / kc1       lower left of keypad */
300 	const char *TI_kc3;	 /* K5  / kc3       lower right of keypad */
301 	const char *TI_mc5p;	 /* pO  / mc5p      turn on printer for #1 bytes */
302 	const char *TI_rmp;	 /* rP  / rmp       like ip but when in insert mode */
303 	const char *TI_acsc;	 /* ac  / acsc      graphics charset pairs, based on vt100 */
304 	const char *TI_pln;	 /* pn  / pln       program label #1 to show string #2 */
305 	const char *TI_kcbt;	 /* kB  / kcbt      back-tab key */
306 	const char *TI_smxon;	 /* SX  / smxon     turn on xon/xoff handshaking */
307 	const char *TI_rmxon;	 /* RX  / rmxon     turn off xon/xoff handshaking */
308 	const char *TI_smam;	 /* SA  / smam      turn on automatic margins */
309 	const char *TI_rmam;	 /* RA  / rmam      turn off automatic margins */
310 	const char *TI_xonc;	 /* XN  / xonc      XON character */
311 	const char *TI_xoffc;	 /* XF  / xoffc     XOFF character */
312 	const char *TI_enacs;	 /* eA  / enacs     enable alternate char set */
313 	const char *TI_smln;	 /* LO  / smln      turn on soft labels */
314 	const char *TI_rmln;	 /* LF  / rmln      turn off soft labels */
315 	const char *TI_kbeg;	 /* @1  / kbeg      begin key */
316 	const char *TI_kcan;	 /* @2  / kcan      cancel key */
317 	const char *TI_kclo;	 /* @3  / kclo      close key */
318 	const char *TI_kcmd;	 /* @4  / kcmd      command key */
319 	const char *TI_kcpy;	 /* @5  / kcpy      copy key */
320 	const char *TI_kcrt;	 /* @6  / kcrt      create key */
321 	const char *TI_kend;	 /* @7  / kend      end key */
322 	const char *TI_kent;	 /* @8  / kent      enter/send key */
323 	const char *TI_kext;	 /* @9  / kext      exit key */
324 	const char *TI_kfnd;	 /* @0  / kfnd      find key */
325 	const char *TI_khlp;	 /* %1  / khlp      help key */
326 	const char *TI_kmrk;	 /* %2  / kmrk      mark key */
327 	const char *TI_kmsg;	 /* %3  / kmsg      message key */
328 	const char *TI_kmov;	 /* %4  / kmov      move key */
329 	const char *TI_knxt;	 /* %5  / knxt      next key */
330 	const char *TI_kopn;	 /* %6  / kopn      open key */
331 	const char *TI_kopt;	 /* %7  / kopt      options key */
332 	const char *TI_kprv;	 /* %8  / kprv      previous key */
333 	const char *TI_kprt;	 /* %9  / kprt      print key */
334 	const char *TI_krdo;	 /* %0  / krdo      redo key */
335 	const char *TI_kref;	 /* &1  / kref      reference key */
336 	const char *TI_krfr;	 /* &2  / krfr      refresh key */
337 	const char *TI_krpl;	 /* &3  / krpl      replace key */
338 	const char *TI_krst;	 /* &4  / krst      restart key */
339 	const char *TI_kres;	 /* &5  / kres      resume key */
340 	const char *TI_ksav;	 /* &6  / ksav      save key */
341 	const char *TI_kspd;	 /* &7  / kspd      suspend key */
342 	const char *TI_kund;	 /* &8  / kund      undo key */
343 	const char *TI_kBEG;	 /* &9  / kBEG      shifted begin key */
344 	const char *TI_kCAN;	 /* &0  / kCAN      shifted cancel key */
345 	const char *TI_kCMD;	 /* *1  / kCMD      shifted command key */
346 	const char *TI_kCPY;	 /* *2  / kCPY      shifted copy key */
347 	const char *TI_kCRT;	 /* *3  / kCRT      shifted create key */
348 	const char *TI_kDC;	 /* *4  / kDC       shifted delete-character key */
349 	const char *TI_kDL;	 /* *5  / kDL       shifted delete-line key */
350 	const char *TI_kslt;	 /* *6  / kslt      select key */
351 	const char *TI_kEND;	 /* *7  / kEND      shifted end key */
352 	const char *TI_kEOL;	 /* *8  / kEOL      shifted clear-to-end-of-line key */
353 	const char *TI_kEXT;	 /* *9  / kEXT      shifted exit key */
354 	const char *TI_kFND;	 /* *0  / kFND      shifted find key */
355 	const char *TI_kHLP;	 /* #1  / kHLP      shifted help key */
356 	const char *TI_kHOM;	 /* #2  / kHOM      shifted home key */
357 	const char *TI_kIC;	 /* #3  / kIC       shifted insert-character key */
358 	const char *TI_kLFT;	 /* #4  / kLFT      shifted left-arrow key */
359 	const char *TI_kMSG;	 /* %a  / kMSG      shifted message key */
360 	const char *TI_kMOV;	 /* %b  / kMOV      shifted move key */
361 	const char *TI_kNXT;	 /* %c  / kNXT      shifted next key */
362 	const char *TI_kOPT;	 /* %d  / kOPT      shifted options key */
363 	const char *TI_kPRV;	 /* %e  / kPRV      shifted previous key */
364 	const char *TI_kPRT;	 /* %f  / kPRT      shifted print key */
365 	const char *TI_kRDO;	 /* %g  / kRDO      shifted redo key */
366 	const char *TI_kRPL;	 /* %h  / kRPL      shifted replace key */
367 	const char *TI_kRIT;	 /* %i  / kRIT      shifted right-arrow key */
368 	const char *TI_kRES;	 /* %j  / kRES      shifted resume key */
369 	const char *TI_kSAV;	 /* !1  / kSAV      shifted save key */
370 	const char *TI_kSPD;	 /* !2  / kSPD      shifted suspend key */
371 	const char *TI_kUND;	 /* !3  / kUND      shifted undo key */
372 	const char *TI_rfi;	 /* RF  / rfi       send next input char (for ptys) */
373 	const char *TI_kf11;	 /* F1  / kf11      F11 function key */
374 	const char *TI_kf12;	 /* F2  / kf12      F12 function key */
375 	const char *TI_kf13;	 /* F3  / kf13      F13 function key */
376 	const char *TI_kf14;	 /* F4  / kf14      F14 function key */
377 	const char *TI_kf15;	 /* F5  / kf15      F15 function key */
378 	const char *TI_kf16;	 /* F6  / kf16      F16 function key */
379 	const char *TI_kf17;	 /* F7  / kf17      F17 function key */
380 	const char *TI_kf18;	 /* F8  / kf18      F18 function key */
381 	const char *TI_kf19;	 /* F9  / kf19      F19 function key */
382 	const char *TI_kf20;	 /* FA  / kf20      F20 function key */
383 	const char *TI_kf21;	 /* FB  / kf21      F21 function key */
384 	const char *TI_kf22;	 /* FC  / kf22      F22 function key */
385 	const char *TI_kf23;	 /* FD  / kf23      F23 function key */
386 	const char *TI_kf24;	 /* FE  / kf24      F24 function key */
387 	const char *TI_kf25;	 /* FF  / kf25      F25 function key */
388 	const char *TI_kf26;	 /* FG  / kf26      F26 function key */
389 	const char *TI_kf27;	 /* FH  / kf27      F27 function key */
390 	const char *TI_kf28;	 /* FI  / kf28      F28 function key */
391 	const char *TI_kf29;	 /* FJ  / kf29      F29 function key */
392 	const char *TI_kf30;	 /* FK  / kf30      F30 function key */
393 	const char *TI_kf31;	 /* FL  / kf31      F31 function key */
394 	const char *TI_kf32;	 /* FM  / kf32      F32 function key */
395 	const char *TI_kf33;	 /* FN  / kf33      F33 function key */
396 	const char *TI_kf34;	 /* FO  / kf34      F34 function key */
397 	const char *TI_kf35;	 /* FP  / kf35      F35 function key */
398 	const char *TI_kf36;	 /* FQ  / kf36      F36 function key */
399 	const char *TI_kf37;	 /* FR  / kf37      F37 function key */
400 	const char *TI_kf38;	 /* FS  / kf38      F38 function key */
401 	const char *TI_kf39;	 /* FT  / kf39      F39 function key */
402 	const char *TI_kf40;	 /* FU  / kf40      F40 function key */
403 	const char *TI_kf41;	 /* FV  / kf41      F41 function key */
404 	const char *TI_kf42;	 /* FW  / kf42      F42 function key */
405 	const char *TI_kf43;	 /* FX  / kf43      F43 function key */
406 	const char *TI_kf44;	 /* FY  / kf44      F44 function key */
407 	const char *TI_kf45;	 /* FZ  / kf45      F45 function key */
408 	const char *TI_kf46;	 /* Fa  / kf46      F46 function key */
409 	const char *TI_kf47;	 /* Fb  / kf47      F47 function key */
410 	const char *TI_kf48;	 /* Fc  / kf48      F48 function key */
411 	const char *TI_kf49;	 /* Fd  / kf49      F49 function key */
412 	const char *TI_kf50;	 /* Fe  / kf50      F50 function key */
413 	const char *TI_kf51;	 /* Ff  / kf51      F51 function key */
414 	const char *TI_kf52;	 /* Fg  / kf52      F52 function key */
415 	const char *TI_kf53;	 /* Fh  / kf53      F53 function key */
416 	const char *TI_kf54;	 /* Fi  / kf54      F54 function key */
417 	const char *TI_kf55;	 /* Fj  / kf55      F55 function key */
418 	const char *TI_kf56;	 /* Fk  / kf56      F56 function key */
419 	const char *TI_kf57;	 /* Fl  / kf57      F57 function key */
420 	const char *TI_kf58;	 /* Fm  / kf58      F58 function key */
421 	const char *TI_kf59;	 /* Fn  / kf59      F59 function key */
422 	const char *TI_kf60;	 /* Fo  / kf60      F60 function key */
423 	const char *TI_kf61;	 /* Fp  / kf61      F61 function key */
424 	const char *TI_kf62;	 /* Fq  / kf62      F62 function key */
425 	const char *TI_kf63;	 /* Fr  / kf63      F63 function key */
426 	const char *TI_el1;	 /* cb  / el1       Clear to beginning of line */
427 	const char *TI_mgc;	 /* MC  / mgc       clear right and left soft margins */
428 	const char *TI_smgl;	 /* ML  / smgl      set left soft margin at current column */
429 	const char *TI_smgr;	 /* MR  / smgr      set right soft margin at current column */
430 	const char *TI_fln;	 /* Lf  / fln       label format */
431 	const char *TI_sclk;	 /* SC  / sclk      set clock, #1 hrs #2 mins #3 secs */
432 	const char *TI_dclk;	 /* DK  / dclk      display clock at (#1,#2) */
433 	const char *TI_rmclk;	 /* RC  / rmclk     remove clock */
434 	const char *TI_cwin;	 /* CW  / cwin      define a window #1 from #2,#3 to #4,#5 */
435 	const char *TI_wingo;	 /* WG  / wingo     go to window #1 */
436 	const char *TI_hup;	 /* HU  / hup       hang-up phone */
437 	const char *TI_dial;	 /* DI  / dial      dial number #1 */
438 	const char *TI_qdial;	 /* QD  / qdial     dial number #1 without checking */
439 	const char *TI_tone;	 /* TO  / tone      select touch tone dialing */
440 	const char *TI_pulse;	 /* PU  / pulse     select pulse dialing */
441 	const char *TI_hook;	 /* fh  / hook      flash switch hook */
442 	const char *TI_pause;	 /* PA  / pause     pause for 2-3 seconds */
443 	const char *TI_wait;	 /* WA  / wait      wait for dial-tone */
444 	const char *TI_u0;	 /* u0  / u0        User string #0 */
445 	const char *TI_u1;	 /* u1  / u1        User string #1 */
446 	const char *TI_u2;	 /* u2  / u2        User string #2 */
447 	const char *TI_u3;	 /* u3  / u3        User string #3 */
448 	const char *TI_u4;	 /* u4  / u4        User string #4 */
449 	const char *TI_u5;	 /* u5  / u5        User string #5 */
450 	const char *TI_u6;	 /* u6  / u6        User string #6 */
451 	const char *TI_u7;	 /* u7  / u7        User string #7 */
452 	const char *TI_u8;	 /* u8  / u8        User string #8 */
453 	const char *TI_u9;	 /* u9  / u9        User string #9 */
454 	const char *TI_op;	 /* op  / op        Set default pair to its original value */
455 	const char *TI_oc;	 /* oc  / oc        Set all color pairs to the original ones */
456 	const char *TI_initc;	 /* Ic  / initc     initialize color #1 to (#2,#3,#4) */
457 	const char *TI_initp;	 /* Ip  / initp     Initialize color pair #1 to fg=(#2,#3,#4), bg=(#5,#6,#7) */
458 	const char *TI_scp;	 /* sp  / scp       Set current color pair to #1 */
459 	const char *TI_setf;	 /* Sf  / setf      Set foreground color #1 */
460 	const char *TI_setb;	 /* Sb  / setb      Set background color #1 */
461 	const char *TI_cpi;	 /* ZA  / cpi       Change number of characters per inch */
462 	const char *TI_lpi;	 /* ZB  / lpi       Change number of lines per inch */
463 	const char *TI_chr;	 /* ZC  / chr       Change horizontal resolution */
464 	const char *TI_cvr;	 /* ZD  / cvr       Change vertical resolution */
465 	const char *TI_defc;	 /* ZE  / defc      Define a character */
466 	const char *TI_swidm;	 /* ZF  / swidm     Enter double-wide mode */
467 	const char *TI_sdrfq;	 /* ZG  / sdrfq     Enter draft-quality mode */
468 	const char *TI_sitm;	 /* ZH  / sitm      Enter italic mode */
469 	const char *TI_slm;	 /* ZI  / slm       Start leftward carriage motion */
470 	const char *TI_smicm;	 /* ZJ  / smicm     Start micro-motion mode */
471 	const char *TI_snlq;	 /* ZK  / snlq      Enter NLQ mode */
472 	const char *TI_snrmq;	 /* ZL  / snrmq     Enter normal-quality mode */
473 	const char *TI_sshm;	 /* ZM  / sshm      Enter shadow-print mode */
474 	const char *TI_ssubm;	 /* ZN  / ssubm     Enter subscript mode */
475 	const char *TI_ssupm;	 /* ZO  / ssupm     Enter superscript mode */
476 	const char *TI_sum;	 /* ZP  / sum       Start upward carriage motion */
477 	const char *TI_rwidm;	 /* ZQ  / rwidm     End double-wide mode */
478 	const char *TI_ritm;	 /* ZR  / ritm      End italic mode */
479 	const char *TI_rlm;	 /* ZS  / rlm       End left-motion mode */
480 	const char *TI_rmicm;	 /* ZT  / rmicm     End micro-motion mode */
481 	const char *TI_rshm;	 /* ZU  / rshm      End shadow-print mode */
482 	const char *TI_rsubm;	 /* ZV  / rsubm     End subscript mode */
483 	const char *TI_rsupm;	 /* ZW  / rsupm     End superscript mode */
484 	const char *TI_rum;	 /* ZX  / rum       End reverse character motion */
485 	const char *TI_mhpa;	 /* ZY  / mhpa      Like column_address in micro mode */
486 	const char *TI_mcud1;	 /* ZZ  / mcud1     Like cursor_down in micro mode */
487 	const char *TI_mcub1;	 /* Za  / mcub1     Like cursor_left in micro mode */
488 	const char *TI_mcuf1;	 /* Zb  / mcuf1     Like cursor_right in micro mode */
489 	const char *TI_mvpa;	 /* Zc  / mvpa      Like row_address in micro mode */
490 	const char *TI_mcuu1;	 /* Zd  / mcuu1     Like cursor_up in micro mode */
491 	const char *TI_porder; /* Ze  / porder    Match software bits to print-head pins */
492 	const char *TI_mcud;	 /* Zf  / mcud      Like parm_down_cursor in micro mode */
493 	const char *TI_mcub;	 /* Zg  / mcub      Like parm_left_cursor in micro mode */
494 	const char *TI_mcuf;	 /* Zh  / mcuf      Like parm_right_cursor in micro mode */
495 	const char *TI_mcuu;	 /* Zi  / mcuu      Like parm_up_cursor in micro mode */
496 	const char *TI_scs;	 /* Zj  / scs       Select character set */
497 	const char *TI_smgb;	 /* Zk  / smgb      Set bottom margin at current line */
498 	const char *TI_smgbp;	 /* Zl  / smgbp     Set bottom margin at line #1 or #2 lines from bottom */
499 	const char *TI_smglp;	 /* Zm  / smglp     Set left (right) margin at column #1 (#2) */
500 	const char *TI_smgrp;	 /* Zn  / smgrp     Set right margin at column #1 */
501 	const char *TI_smgt;	 /* Zo  / smgt      Set top margin at current line */
502 	const char *TI_smgtp;	 /* Zp  / smgtp     Set top (bottom) margin at row #1 (#2) */
503 	const char *TI_sbim;	 /* Zq  / sbim      Start printing bit image graphics */
504 	const char *TI_scsd;	 /* Zr  / scsd      Start character set definition */
505 	const char *TI_rbim;	 /* Zs  / rbim      Stop printing bit image graphics */
506 	const char *TI_rcsd;	 /* Zt  / rcsd      End definition of character set */
507 	const char *TI_subcs;	 /* Zu  / subcs     List of subscriptable characters */
508 	const char *TI_supcs;	 /* Zv  / supcs     List of superscriptable characters */
509 	const char *TI_docr;	 /* Zw  / docr      Printing any of these characters causes CR */
510 	const char *TI_zerom;	 /* Zx  / zerom     No motion for subsequent character */
511 	const char *TI_csnm;	 /* Zy  / csnm      List of character set names */
512 	const char *TI_kmous;	 /* Km  / kmous     Mouse event has occurred */
513 	const char *TI_minfo;	 /* Mi  / minfo     Mouse status information */
514 	const char *TI_reqmp;	 /* RQ  / reqmp     Request mouse position */
515 	const char *TI_getm;	 /* Gm  / getm      Curses should get button events */
516 	const char *TI_setaf;	 /* AF  / setaf     Set foreground color using ANSI escape */
517 	const char *TI_setab;	 /* AB  / setab     Set background color using ANSI escape */
518 	const char *TI_pfxl;	 /* xl  / pfxl      Program function key #1 to type string #2 and show string #3 */
519 	const char *TI_devt;	 /* dv  / devt      Indicate language/codeset support */
520 	const char *TI_csin;	 /* ci  / csin      Init sequence for multiple codesets */
521 	const char *TI_s0ds;	 /* s0  / s0ds      Shift to code set 0 (EUC set 0, ASCII) */
522 	const char *TI_s1ds;	 /* s1  / s1ds      Shift to code set 1 */
523 	const char *TI_s2ds;	 /* s2  / s2ds      Shift to code set 2 */
524 	const char *TI_s3ds;	 /* s3  / s3ds      Shift to code set 3 */
525 	const char *TI_smglr;	 /* ML  / smglr     Set both left and right margins to #1, #2 */
526 	const char *TI_smgtb;	 /* MT  / smgtb     Sets both top and bottom margins to #1, #2 */
527 	const char *TI_birep;	 /* Xy  / birep     Repeat bit image cell #1 #2 times */
528 	const char *TI_binel;	 /* Zz  / binel     Move to next row of the bit image */
529 	const char *TI_bicr;	 /* Yv  / bicr      Move to beginning of same row */
530 	const char *TI_colornm; /* Yw  / colornm   Give name for color #1 */
531 	const char *TI_defbi;	 /* Yx  / defbi     Define rectangualar bit image region */
532 	const char *TI_endbi;	 /* Yy  / endbi     End a bit-image region */
533 	const char *TI_setcolor; /* Yz  / setcolor  Change to ribbon color #1 */
534 	const char *TI_slines; /* YZ  / slines    Set page length to #1 lines */
535 	const char *TI_dispc;	 /* S1  / dispc     Display PC character */
536 	const char *TI_smpch;	 /* S2  / smpch     Enter PC character display mode */
537 	const char *TI_rmpch;	 /* S3  / rmpch     Exit PC character display mode */
538 	const char *TI_smsc;	 /* S4  / smsc      Enter PC scancode mode */
539 	const char *TI_rmsc;	 /* S5  / rmsc      Exit PC scancode mode */
540 	const char *TI_pctrm;	 /* S6  / pctrm     PC terminal options */
541 	const char *TI_scesc;	 /* S7  / scesc     Escape for scancode emulation */
542 	const char *TI_scesa;	 /* S8  / scesa     Alternate escape for scancode emulation */
543 	const char *TI_ehhlm;	 /* Xh  / ehhlm     Enter horizontal highlight mode */
544 	const char *TI_elhlm;	 /* Xl  / elhlm     Enter left highlight mode */
545 	const char *TI_elohlm; /* Xo  / elohlm    Enter low highlight mode */
546 	const char *TI_erhlm;	 /* Xr  / erhlm     Enter right highlight mode */
547 	const char *TI_ethlm;	 /* Xt  / ethlm     Enter top highlight mode */
548 	const char *TI_evhlm;	 /* Xv  / evhlm     Enter vertical highlight mode */
549 	const char *TI_sgr1;	 /* sA  / sgr1      Define second set of video attributes #1-#6 */
550 	const char *TI_slength; /* sL  / slength   YI Set page length to #1 hundredth of an inch */
551 	const char *TI_OTi2;	 /* i2  / OTi2      secondary initialization string */
552 	const char *TI_OTrs;	 /* rs  / OTrs      terminal reset string */
553 	int TI_OTug;	 /* ug  / OTug      number of blanks left by ul */
554 	int TI_OTbs;	 /* bs  / OTbs      uses ^H to move left */
555 	int TI_OTns;	 /* ns  / OTns      crt cannot scroll */
556 	int TI_OTnc;	 /* nc  / OTnc      no way to go to start of line */
557 	int TI_OTdC;	 /* dC  / OTdC      pad needed for CR */
558 	int TI_OTdN;	 /* dN  / OTdN      pad needed for LF */
559 	const char *TI_OTnl;	 /* nl  / OTnl      use to move down */
560 	const char *TI_OTbc;	 /* bc  / OTbc      move left, if not ^H */
561 	int TI_OTMT;	 /* MT  / OTMT      has meta key */
562 	int TI_OTNL;	 /* NL  / OTNL      move down with \n */
563 	int TI_OTdB;	 /* dB  / OTdB      padding required for ^H */
564 	int TI_OTdT;	 /* dT  / OTdT      padding required for ^I */
565 	int TI_OTkn;	 /* kn  / OTkn      count of function keys */
566 	const char *TI_OTko;	 /* ko  / OTko      list of self-mapped keycaps */
567 	const char *TI_OTma;	 /* ma  / OTma      map arrow keys rogue(1) motion keys */
568 	int TI_OTpt;	 /* pt  / OTpt      has 8-const char tabs invoked with ^I */
569 	int TI_OTxr;	 /* xr  / OTxr      return clears the line */
570 	const char *TI_OTG2;	 /* G2  / OTG2      single upper left */
571 	const char *TI_OTG3;	 /* G3  / OTG3      single lower left */
572 	const char *TI_OTG1;	 /* G1  / OTG1      single upper right */
573 	const char *TI_OTG4;	 /* G4  / OTG4      single lower right */
574 	const char *TI_OTGR;	 /* GR  / OTGR      tee pointing right */
575 	const char *TI_OTGL;	 /* GL  / OTGL      tee pointing left */
576 	const char *TI_OTGU;	 /* GU  / OTGU      tee pointing up */
577 	const char *TI_OTGD;	 /* GD  / OTGD      tee pointing down */
578 	const char *TI_OTGH;	 /* GH  / OTGH      single horizontal line */
579 	const char *TI_OTGV;	 /* GV  / OTGV      single vertical line */
580 	const char *TI_OTGC;	 /* GC  / OTGC      single intersection */
581 	const char *TI_meml;	 /* ml  / meml      memory lock above */
582 	const char *TI_memu;	 /* mu  / memu      memory unlock */
583 	const char *TI_box1;	 /* bx  / box1      box characters primary set */
584 	/* non termcap/terminfo terminal info (generated by epic) */
585 	char TI_normal[256];
586 	const char *TI_sgrstrs[TERM_SGR_MAXVAL];
587 	const char *TI_forecolors[16];
588 	const char *TI_backcolors[16];
589 	int TI_meta_mode;
590 /*	int TI_need_redraw ; */
591 };
592 
593 #define term_has(x) 	(termfeatures & (x))
594 #define capstr(x) 	(current_term->TI_sgrstrs[(TERM_SGR_ ## x)-1])
595 #define outcap(x)	(tputs_x(capstr(x)))
596 
597 #ifndef TERM_DEBUG
598 #define tputs_x(s)		(tputs(s, 0, putchar_x))
599 #else
600 int	tputs_x(char *);
601 #endif
602 
603 #define IFV(x) if (get_int_var((x ## _VIDEO_VAR)))
604 #define term_underline_on()	IFV(UNDERLINE) 	outcap(UNDL_ON)
605 #define term_underline_off()	IFV(UNDERLINE) 	outcap(UNDL_OFF)
606 #define term_standout_on()	IFV(INVERSE) 	outcap(REV_ON)
607 #define term_standout_off()	IFV(INVERSE) 	outcap(REV_OFF)
608 #define term_blink_on()		IFV(BLINK) 	outcap(BLINK_ON)
609 #define term_blink_off()	IFV(BLINK) 	outcap(BLINK_OFF)
610 #define term_bold_on()		IFV(BOLD) 	outcap(BOLD_ON)
611 #define	term_bold_off()		IFV(BOLD) 	outcap(BOLD_OFF)
612 #define term_altcharset_on()	if (get_int_var(ALT_CHARSET_VAR)) \
613 					outcap(ALTCHAR_ON)
614 #define term_altcharset_off()	if (get_int_var(ALT_CHARSET_VAR)) \
615 					outcap(ALTCHAR_OFF)
616 #define term_set_foreground(x)	tputs_x(current_term->TI_forecolors[(x) & 0x0f])
617 #define term_set_background(x)	tputs_x(current_term->TI_backcolors[(x) & 0x0f])
618 #define term_set_attribs(f,b)	tputs_x(term_getsgr(TERM_SGR_COLORS,(f),(b)))
619 #define term_putgchar(x)	tputs_x(term_getsgr(TERM_SGR_GCHAR,(x),0))
620 #define term_clear_screen()	term_clrscr()
621 #define term_move_cursor(c, r)	term_gotoxy((c),(r))
622 #define term_cr()		tputs_x(current_term->TI_cr)
623 #define term_newline()		tputs_x(current_term->TI_nel)
624 #define term_cursor_left()	term_left(1)
625 #define term_cursor_right()	term_right(1)
626 #define term_clear_to_eol()	term_clreol()
627 #define term_all_off()          tputs_x(current_term->TI_normal);
628 
629 	RETSIGTYPE 	term_cont 		(int);
630 	void 		term_beep 		(void);
631 	int		term_echo 		(int);
632 	int		term_init 		(void);
633 	int		term_resize 		(void);
634 	void		term_pause 		(char, char *);
635 	void		term_putchar 		(unsigned char);
636 	void		term_scroll 		(int, int, int);
637 	void		term_insert 		(unsigned char);
638 	void		term_delete 		(int);
639 	void		term_repeat		(unsigned char, int);
640 	void		term_right		(int);
641 	void		term_left		(int);
642 	void		term_clreol		(void);
643 	void		term_clrscr		(void);
644 	void		term_gotoxy		(int, int);
645 	void		term_reset		(void);
646 	int		term_eight_bit		(void);
647 	void		set_term_eight_bit	(int);
648 	void		set_meta_8bit		(const void *);
649 	const char *	term_getsgr		(int, int, int);
650 	const char *	get_term_capability	(const char *, int, int);
651 
652 #endif /* _TERM_H_ */
653