Commit | Line | Data |
---|---|---|
17865084 | 1 | /* |
46e9ea25 KB |
2 | * Copyright (c) 1983 Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
3dd3a9e5 KB |
5 | * This code is derived from software contributed to Berkeley by |
6 | * Edward Wang at The University of California, Berkeley. | |
7 | * | |
87f529ec | 8 | * %sccs.include.redist.c% |
46e9ea25 | 9 | * |
3dd3a9e5 | 10 | * @(#)tt.h 3.27 (Berkeley) %G% |
17865084 EW |
11 | */ |
12 | ||
3130283e EW |
13 | /* |
14 | * Interface structure for the terminal drivers. | |
15 | */ | |
17865084 | 16 | struct tt { |
3130283e | 17 | /* startup and cleanup */ |
ab8b3b31 | 18 | int (*tt_start)(); |
e908bfac | 19 | int (*tt_end)(); |
3130283e EW |
20 | |
21 | /* terminal functions */ | |
e908bfac | 22 | int (*tt_move)(); |
17865084 EW |
23 | int (*tt_insline)(); |
24 | int (*tt_delline)(); | |
2d152f42 | 25 | int (*tt_inschar)(); |
d9375810 | 26 | int (*tt_insspace)(); |
17865084 | 27 | int (*tt_delchar)(); |
3130283e EW |
28 | int (*tt_write)(); /* write a whole block */ |
29 | int (*tt_putc)(); /* write one character */ | |
17865084 EW |
30 | int (*tt_clreol)(); |
31 | int (*tt_clreos)(); | |
32 | int (*tt_clear)(); | |
16ea9636 EW |
33 | int (*tt_scroll_down)(); |
34 | int (*tt_scroll_up)(); | |
35 | int (*tt_setscroll)(); /* set scrolling region */ | |
c1a57462 | 36 | int (*tt_setmodes)(); /* set display modes */ |
ab8b3b31 EW |
37 | int (*tt_set_token)(); /* define a token */ |
38 | int (*tt_put_token)(); /* refer to a defined token */ | |
3130283e EW |
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 */ | |
3130283e EW |
44 | int tt_row; /* cursor row */ |
45 | int tt_col; /* cursor column */ | |
16ea9636 EW |
46 | int tt_scroll_top; /* top of scrolling region */ |
47 | int tt_scroll_bot; /* bottom of scrolling region */ | |
3130283e EW |
48 | |
49 | /* terminal info */ | |
50 | int tt_nrow; /* number of display rows */ | |
51 | int tt_ncol; /* number of display columns */ | |
3130283e | 52 | char tt_availmodes; /* the display modes supported */ |
5e785082 | 53 | char tt_wrap; /* has auto wrap around */ |
377a2410 | 54 | char tt_retain; /* can retain below (db flag) */ |
17f96a0f | 55 | short tt_padc; /* the pad character */ |
ab8b3b31 EW |
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 */ | |
3130283e EW |
61 | |
62 | /* the frame characters */ | |
a830e8bb | 63 | short *tt_frame; |
17f96a0f EW |
64 | |
65 | /* the output routine */ | |
66 | int (*tt_flush)(); | |
17865084 | 67 | }; |
17865084 EW |
68 | struct tt tt; |
69 | ||
17f96a0f EW |
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 | ||
3130283e EW |
76 | /* |
77 | * List of terminal drivers. | |
78 | */ | |
17865084 EW |
79 | struct tt_tab { |
80 | char *tt_name; | |
81 | int tt_len; | |
82 | int (*tt_func)(); | |
83 | }; | |
b15b4a3f | 84 | extern struct tt_tab tt_tab[]; |
c3f80cb5 EW |
85 | |
86 | /* | |
3130283e | 87 | * Clean interface to termcap routines. |
b1189050 | 88 | * Too may t's. |
c3f80cb5 EW |
89 | */ |
90 | char tt_strings[1024]; /* string buffer */ | |
91 | char *tt_strp; /* pointer for it */ | |
92 | ||
e1daf7d6 EW |
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 */ | |
c3f80cb5 | 100 | |
b1189050 | 101 | int tttputc(); |
e1daf7d6 EW |
102 | #define tttputs(s, n) tputs((s)->ts_str, (n), tttputc) |
103 | #define ttxputs(s) ttwrite((s)->ts_str, (s)->ts_n) | |
b1189050 EW |
104 | |
105 | /* | |
106 | * Buffered output without stdio. | |
27c9228e | 107 | * These variables have different meanings from the ww_ob* variables. |
b1189050 EW |
108 | * But I'm too lazy to think up different names. |
109 | */ | |
17f96a0f | 110 | char *tt_ob; |
b1189050 EW |
111 | char *tt_obp; |
112 | char *tt_obe; | |
cc3bd200 | 113 | #define ttputc(c) (tt_obp < tt_obe ? (*tt_obp++ = (c)) \ |
17f96a0f | 114 | : ((*tt.tt_flush)(), *tt_obp++ = (c))) |
27c9228e EW |
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)) |