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