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