1 /* $NetBSD: tt.h,v 1.8 2003/08/07 11:17:30 agc Exp $ */
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * Edward Wang at The University of California, Berkeley.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * @(#)tt.h 8.1 (Berkeley) 6/6/93
44 * Interface structure for the terminal drivers.
47 /* startup and cleanup */
48 void (*tt_start
)(void);
49 void (*tt_reset
)(void);
52 /* terminal functions */
53 void (*tt_move
)(int, int);
54 void (*tt_insline
)(int);
55 void (*tt_delline
)(int);
56 void (*tt_inschar
)(char);
57 void (*tt_insspace
)(int);
58 void (*tt_delchar
)(int);
59 void (*tt_write
)(const char *, int); /* write a whole block */
60 void (*tt_putc
)(char); /* write one character */
61 void (*tt_clreol
)(void);
62 void (*tt_clreos
)(void);
63 void (*tt_clear
)(void);
64 void (*tt_scroll_down
)(int);
65 void (*tt_scroll_up
)(int);
66 void (*tt_setscroll
)(int, int);/* set scrolling region */
67 void (*tt_setmodes
)(int); /* set display modes */
68 void (*tt_set_token
)(int, char *, int);
70 void (*tt_put_token
)(int, const char *, int);
71 /* refer to a defined token */
72 void (*tt_compress
)(int); /* begin, end compression */
73 void (*tt_checksum
)(char *, int);
74 /* compute checksum */
75 void (*tt_checkpoint
)(void); /* checkpoint protocol */
76 int (*tt_rint
)(char *, int); /* input processing */
78 /* internal variables */
79 char tt_modes
; /* the current display modes */
80 char tt_nmodes
; /* the new modes for next write */
81 char tt_insert
; /* currently in insert mode */
82 int tt_row
; /* cursor row */
83 int tt_col
; /* cursor column */
84 int tt_scroll_top
; /* top of scrolling region */
85 int tt_scroll_bot
; /* bottom of scrolling region */
88 int tt_nrow
; /* number of display rows */
89 int tt_ncol
; /* number of display columns */
90 char tt_availmodes
; /* the display modes supported */
91 char tt_wrap
; /* has auto wrap around */
92 char tt_retain
; /* can retain below (db flag) */
93 short tt_padc
; /* the pad character */
94 int tt_ntoken
; /* number of compression tokens */
95 int tt_token_min
; /* minimun token size */
96 int tt_token_max
; /* maximum token size */
97 int tt_set_token_cost
; /* cost in addition to string */
98 int tt_put_token_cost
; /* constant cost */
99 int tt_ack
; /* checkpoint ack-nack flag */
101 /* the frame characters */
105 void (*tt_flush
)(void);
110 * tt_padc is used by the compression routine.
111 * It is a short to allow the driver to indicate that there is no padding.
113 #define TT_PADC_NONE 0x100
116 * List of terminal drivers.
121 int (*tt_func
)(void);
123 EXTERN
struct tt_tab tt_tab
[];
126 * Clean interface to termcap routines.
129 EXTERN
char tt_strings
[1024]; /* string buffer */
130 EXTERN
char *tt_strp
; /* pointer for it */
137 struct tt_str
*tttgetstr(const char *);
138 struct tt_str
*ttxgetstr(const char *); /* tgetstr() and expand delays */
141 int tt_generic(void);
150 struct tt_str
*tttgetstr(const char *);
152 void ttpgoto(struct tt_str
*, int, int, int);
153 void ttputs(const char *);
154 int ttstrcmp(struct tt_str
*, struct tt_str
*);
155 void tttgoto(struct tt_str
*, int, int);
157 void ttwrite(const char *, int);
160 #define tttputs(s, n) tputs((s)->ts_str, (n), tttputc)
161 #define ttxputs(s) ttwrite((s)->ts_str, (s)->ts_n)
164 * Buffered output without stdio.
165 * These variables have different meanings from the ww_ob* variables.
166 * But I'm too lazy to think up different names.
171 #define ttputc(c) (tt_obp < tt_obe ? (*tt_obp++ = (c)) \
172 : (ttflush(), *tt_obp++ = (c)))
175 * Convenience macros for the drivers
176 * They require char.h
178 #define ttctrl(c) ttputc(ctrl(c))
179 #define ttesc(c) (ttctrl('['), ttputc(c))