xref: /original-bsd/usr.bin/window/tt.h (revision e59fb703)
1 /*
2  * Copyright (c) 1983 Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Edward Wang at The University of California, Berkeley.
7  *
8  * %sccs.include.redist.c%
9  *
10  *	@(#)tt.h	3.27 (Berkeley) 06/06/90
11  */
12 
13 /*
14  * Interface structure for the terminal drivers.
15  */
16 struct tt {
17 		/* startup and cleanup */
18 	int (*tt_start)();
19 	int (*tt_end)();
20 
21 		/* terminal functions */
22 	int (*tt_move)();
23 	int (*tt_insline)();
24 	int (*tt_delline)();
25 	int (*tt_inschar)();
26 	int (*tt_insspace)();
27 	int (*tt_delchar)();
28 	int (*tt_write)();		/* write a whole block */
29 	int (*tt_putc)();		/* write one character */
30 	int (*tt_clreol)();
31 	int (*tt_clreos)();
32 	int (*tt_clear)();
33 	int (*tt_scroll_down)();
34 	int (*tt_scroll_up)();
35 	int (*tt_setscroll)();		/* set scrolling region */
36 	int (*tt_setmodes)();		/* set display modes */
37 	int (*tt_set_token)();		/* define a token */
38 	int (*tt_put_token)();		/* refer to a defined token */
39 
40 		/* internal variables */
41 	char tt_modes;			/* the current display modes */
42 	char tt_nmodes;			/* the new modes for next write */
43 	char tt_insert;			/* currently in insert mode */
44 	int tt_row;			/* cursor row */
45 	int tt_col;			/* cursor column */
46 	int tt_scroll_top;		/* top of scrolling region */
47 	int tt_scroll_bot;		/* bottom of scrolling region */
48 
49 		/* terminal info */
50 	int tt_nrow;			/* number of display rows */
51 	int tt_ncol;			/* number of display columns */
52 	char tt_availmodes;		/* the display modes supported */
53 	char tt_wrap;			/* has auto wrap around */
54 	char tt_retain;			/* can retain below (db flag) */
55 	short tt_padc;			/* the pad character */
56 	int tt_ntoken;			/* number of compression tokens */
57 	int tt_token_min;		/* minimun token size */
58 	int tt_token_max;		/* maximum token size */
59 	int tt_set_token_cost;		/* cost in addition to string */
60 	int tt_put_token_cost;		/* constant cost */
61 
62 		/* the frame characters */
63 	short *tt_frame;
64 
65 		/* the output routine */
66 	int (*tt_flush)();
67 };
68 struct tt tt;
69 
70 /*
71  * tt_padc is used by the compression routine.
72  * It is a short to allow the driver to indicate that there is no padding.
73  */
74 #define TT_PADC_NONE 0x100
75 
76 /*
77  * List of terminal drivers.
78  */
79 struct tt_tab {
80 	char *tt_name;
81 	int tt_len;
82 	int (*tt_func)();
83 };
84 extern struct tt_tab tt_tab[];
85 
86 /*
87  * Clean interface to termcap routines.
88  * Too may t's.
89  */
90 char tt_strings[1024];		/* string buffer */
91 char *tt_strp;			/* pointer for it */
92 
93 struct tt_str {
94 	char *ts_str;
95 	int ts_n;
96 };
97 
98 struct tt_str *tttgetstr();
99 struct tt_str *ttxgetstr();	/* tgetstr() and expand delays */
100 
101 int tttputc();
102 #define tttputs(s, n)	tputs((s)->ts_str, (n), tttputc)
103 #define ttxputs(s)	ttwrite((s)->ts_str, (s)->ts_n)
104 
105 /*
106  * Buffered output without stdio.
107  * These variables have different meanings from the ww_ob* variables.
108  * But I'm too lazy to think up different names.
109  */
110 char *tt_ob;
111 char *tt_obp;
112 char *tt_obe;
113 #define ttputc(c)	(tt_obp < tt_obe ? (*tt_obp++ = (c)) \
114 				: ((*tt.tt_flush)(), *tt_obp++ = (c)))
115 
116 /*
117  * Convenience macros for the drivers
118  * They require char.h
119  */
120 #define ttctrl(c)	ttputc(ctrl(c))
121 #define ttesc(c)	(ttctrl('['), ttputc(c))
122