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