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