1 /* 2 * Copyright (c) 1983 Regents of the University of California. 3 * 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 * %sccs.include.redist.c% 9 * 10 * @(#)tt.h 3.29 (Berkeley) 11/10/92 11 */ 12 13 /* 14 * Interface structure for the terminal drivers. 15 */ 16 struct tt { 17 /* startup and cleanup */ 18 int (*tt_start)(); 19 int (*tt_reset)(); 20 int (*tt_end)(); 21 22 /* terminal functions */ 23 int (*tt_move)(); 24 int (*tt_insline)(); 25 int (*tt_delline)(); 26 int (*tt_inschar)(); 27 int (*tt_insspace)(); 28 int (*tt_delchar)(); 29 int (*tt_write)(); /* write a whole block */ 30 int (*tt_putc)(); /* write one character */ 31 int (*tt_clreol)(); 32 int (*tt_clreos)(); 33 int (*tt_clear)(); 34 int (*tt_scroll_down)(); 35 int (*tt_scroll_up)(); 36 int (*tt_setscroll)(); /* set scrolling region */ 37 int (*tt_setmodes)(); /* set display modes */ 38 int (*tt_set_token)(); /* define a token */ 39 int (*tt_put_token)(); /* refer to a defined token */ 40 int (*tt_compress)(); /* begin, end compression */ 41 int (*tt_checksum)(); /* compute checksum */ 42 int (*tt_checkpoint)(); /* checkpoint protocol */ 43 int (*tt_rint)(); /* input processing */ 44 45 /* internal variables */ 46 char tt_modes; /* the current display modes */ 47 char tt_nmodes; /* the new modes for next write */ 48 char tt_insert; /* currently in insert mode */ 49 int tt_row; /* cursor row */ 50 int tt_col; /* cursor column */ 51 int tt_scroll_top; /* top of scrolling region */ 52 int tt_scroll_bot; /* bottom of scrolling region */ 53 54 /* terminal info */ 55 int tt_nrow; /* number of display rows */ 56 int tt_ncol; /* number of display columns */ 57 char tt_availmodes; /* the display modes supported */ 58 char tt_wrap; /* has auto wrap around */ 59 char tt_retain; /* can retain below (db flag) */ 60 short tt_padc; /* the pad character */ 61 int tt_ntoken; /* number of compression tokens */ 62 int tt_token_min; /* minimun token size */ 63 int tt_token_max; /* maximum token size */ 64 int tt_set_token_cost; /* cost in addition to string */ 65 int tt_put_token_cost; /* constant cost */ 66 int tt_ack; /* checkpoint ack-nack flag */ 67 68 /* the frame characters */ 69 short *tt_frame; 70 71 /* ttflush() hook */ 72 int (*tt_flush)(); 73 }; 74 struct tt tt; 75 76 /* 77 * tt_padc is used by the compression routine. 78 * It is a short to allow the driver to indicate that there is no padding. 79 */ 80 #define TT_PADC_NONE 0x100 81 82 /* 83 * List of terminal drivers. 84 */ 85 struct tt_tab { 86 char *tt_name; 87 int tt_len; 88 int (*tt_func)(); 89 }; 90 extern struct tt_tab tt_tab[]; 91 92 /* 93 * Clean interface to termcap routines. 94 * Too may t's. 95 */ 96 char tt_strings[1024]; /* string buffer */ 97 char *tt_strp; /* pointer for it */ 98 99 struct tt_str { 100 char *ts_str; 101 int ts_n; 102 }; 103 104 struct tt_str *tttgetstr(); 105 struct tt_str *ttxgetstr(); /* tgetstr() and expand delays */ 106 107 int tttputc(); 108 #define tttputs(s, n) tputs((s)->ts_str, (n), tttputc) 109 #define ttxputs(s) ttwrite((s)->ts_str, (s)->ts_n) 110 111 /* 112 * Buffered output without stdio. 113 * These variables have different meanings from the ww_ob* variables. 114 * But I'm too lazy to think up different names. 115 */ 116 char *tt_ob; 117 char *tt_obp; 118 char *tt_obe; 119 #define ttputc(c) (tt_obp < tt_obe ? (*tt_obp++ = (c)) \ 120 : (ttflush(), *tt_obp++ = (c))) 121 122 /* 123 * Convenience macros for the drivers 124 * They require char.h 125 */ 126 #define ttctrl(c) ttputc(ctrl(c)) 127 #define ttesc(c) (ttctrl('['), ttputc(c)) 128