]> git.saurik.com Git - apple/shell_cmds.git/blob - window/tt.h
shell_cmds-34.tar.gz
[apple/shell_cmds.git] / window / tt.h
1 /* $NetBSD: tt.h,v 1.4 1997/11/21 08:36:24 lukem Exp $ */
2
3 /*
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Edward Wang at The University of California, Berkeley.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)tt.h 8.1 (Berkeley) 6/6/93
39 */
40
41 #include <unistd.h>
42
43 #ifndef EXTERN
44 #define EXTERN extern
45 #endif
46
47 /*
48 * Interface structure for the terminal drivers.
49 */
50 struct tt {
51 /* startup and cleanup */
52 void (*tt_start) __P((void));
53 void (*tt_reset) __P((void));
54 void (*tt_end) __P((void));
55
56 /* terminal functions */
57 void (*tt_move) __P((int, int));
58 void (*tt_insline) __P((int));
59 void (*tt_delline) __P((int));
60 void (*tt_inschar) __P((char));
61 void (*tt_insspace) __P((int));
62 void (*tt_delchar) __P((int));
63 void (*tt_write) __P((char *, int)); /* write a whole block */
64 void (*tt_putc) __P((char)); /* write one character */
65 void (*tt_clreol) __P((void));
66 void (*tt_clreos) __P((void));
67 void (*tt_clear) __P((void));
68 void (*tt_scroll_down) __P((int));
69 void (*tt_scroll_up) __P((int));
70 void (*tt_setscroll) __P((int, int));/* set scrolling region */
71 void (*tt_setmodes) __P((int)); /* set display modes */
72 void (*tt_set_token) __P((int, char *, int));
73 /* define a token */
74 void (*tt_put_token) __P((int, char *, int));
75 /* refer to a defined token */
76 void (*tt_compress) __P((int)); /* begin, end compression */
77 void (*tt_checksum) __P((char *, int));
78 /* compute checksum */
79 void (*tt_checkpoint) __P((void)); /* checkpoint protocol */
80 int (*tt_rint) __P((char *, int)); /* input processing */
81
82 /* internal variables */
83 char tt_modes; /* the current display modes */
84 char tt_nmodes; /* the new modes for next write */
85 char tt_insert; /* currently in insert mode */
86 int tt_row; /* cursor row */
87 int tt_col; /* cursor column */
88 int tt_scroll_top; /* top of scrolling region */
89 int tt_scroll_bot; /* bottom of scrolling region */
90
91 /* terminal info */
92 int tt_nrow; /* number of display rows */
93 int tt_ncol; /* number of display columns */
94 char tt_availmodes; /* the display modes supported */
95 char tt_wrap; /* has auto wrap around */
96 char tt_retain; /* can retain below (db flag) */
97 short tt_padc; /* the pad character */
98 int tt_ntoken; /* number of compression tokens */
99 int tt_token_min; /* minimun token size */
100 int tt_token_max; /* maximum token size */
101 int tt_set_token_cost; /* cost in addition to string */
102 int tt_put_token_cost; /* constant cost */
103 int tt_ack; /* checkpoint ack-nack flag */
104
105 /* the frame characters */
106 short *tt_frame;
107
108 /* ttflush() hook */
109 void (*tt_flush) __P((void));
110 };
111 EXTERN struct tt tt;
112
113 /*
114 * tt_padc is used by the compression routine.
115 * It is a short to allow the driver to indicate that there is no padding.
116 */
117 #define TT_PADC_NONE 0x100
118
119 /*
120 * List of terminal drivers.
121 */
122 struct tt_tab {
123 char *tt_name;
124 int tt_len;
125 int (*tt_func) __P((void));
126 };
127 extern struct tt_tab tt_tab[11];
128
129 /*
130 * Clean interface to termcap routines.
131 * Too may t's.
132 */
133 EXTERN char tt_strings[1024]; /* string buffer */
134 EXTERN char *tt_strp; /* pointer for it */
135
136 struct tt_str {
137 char *ts_str;
138 int ts_n;
139 };
140
141 struct tt_str *tttgetstr __P((char *));
142 struct tt_str *ttxgetstr __P((char *)); /* tgetstr() and expand delays */
143
144 int tt_f100 __P((void));
145 int tt_generic __P((void));
146 int tt_h19 __P((void));
147 int tt_h29 __P((void));
148 int tt_tvi925 __P((void));
149 int tt_wyse60 __P((void));
150 int tt_wyse75 __P((void));
151 int tt_zapple __P((void));
152 int tt_zentec __P((void));
153 void ttflush __P((void));
154 struct tt_str *tttgetstr __P((char *));
155 int ttinit __P((void));
156 void ttpgoto __P((struct tt_str *, int, int, int));
157 void ttputs __P((char *));
158 int ttstrcmp __P((struct tt_str *, struct tt_str *));
159 void tttgoto __P((struct tt_str *, int, int));
160 void tttputc __P((int));
161 void ttwrite __P((char *, int));
162 void ttxputc __P((int));
163
164 #define tttputs(s, n) tputs((s)->ts_str, (n), tttputc)
165 #define ttxputs(s) ttwrite((s)->ts_str, (s)->ts_n)
166
167 /*
168 * Buffered output without stdio.
169 * These variables have different meanings from the ww_ob* variables.
170 * But I'm too lazy to think up different names.
171 */
172 EXTERN char *tt_ob;
173 EXTERN char *tt_obp;
174 EXTERN char *tt_obe;
175 #define ttputc(c) (tt_obp < tt_obe ? (*tt_obp++ = (c)) \
176 : (ttflush(), *tt_obp++ = (c)))
177
178 /*
179 * Convenience macros for the drivers
180 * They require char.h
181 */
182 #define ttctrl(c) ttputc(ctrl(c))
183 #define ttesc(c) (ttctrl('['), ttputc(c))