| 1 | /* |
| 2 | * Copyright (c) 1983 Regents of the University of California. |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms are permitted |
| 6 | * provided that the above copyright notice and this paragraph are |
| 7 | * duplicated in all such forms and that any documentation, |
| 8 | * advertising materials, and other materials related to such |
| 9 | * distribution and use acknowledge that the software was developed |
| 10 | * by the University of California, Berkeley. The name of the |
| 11 | * University may not be used to endorse or promote products derived |
| 12 | * from this software without specific prior written permission. |
| 13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
| 14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
| 15 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 16 | * |
| 17 | * @(#)tt.h 3.23 (Berkeley) %G% |
| 18 | */ |
| 19 | |
| 20 | /* |
| 21 | * Interface structure for the terminal drivers. |
| 22 | */ |
| 23 | struct tt { |
| 24 | /* startup and cleanup */ |
| 25 | int (*tt_start)(); |
| 26 | int (*tt_end)(); |
| 27 | |
| 28 | /* terminal functions */ |
| 29 | int (*tt_move)(); |
| 30 | int (*tt_insline)(); |
| 31 | int (*tt_delline)(); |
| 32 | int (*tt_inschar)(); |
| 33 | int (*tt_insspace)(); |
| 34 | int (*tt_delchar)(); |
| 35 | int (*tt_write)(); /* write a whole block */ |
| 36 | int (*tt_putc)(); /* write one character */ |
| 37 | int (*tt_clreol)(); |
| 38 | int (*tt_clreos)(); |
| 39 | int (*tt_clear)(); |
| 40 | int (*tt_scroll_down)(); |
| 41 | int (*tt_scroll_up)(); |
| 42 | int (*tt_setscroll)(); /* set scrolling region */ |
| 43 | int (*tt_setmodes)(); /* set display modes */ |
| 44 | int (*tt_set_token)(); /* define a token */ |
| 45 | int (*tt_put_token)(); /* refer to a defined token */ |
| 46 | |
| 47 | /* internal variables */ |
| 48 | char tt_modes; /* the current display modes */ |
| 49 | char tt_nmodes; /* the new modes for next write */ |
| 50 | char tt_insert; /* currently in insert mode */ |
| 51 | int tt_row; /* cursor row */ |
| 52 | int tt_col; /* cursor column */ |
| 53 | int tt_scroll_top; /* top of scrolling region */ |
| 54 | int tt_scroll_bot; /* bottom of scrolling region */ |
| 55 | |
| 56 | /* terminal info */ |
| 57 | int tt_nrow; /* number of display rows */ |
| 58 | int tt_ncol; /* number of display columns */ |
| 59 | char tt_availmodes; /* the display modes supported */ |
| 60 | char tt_wrap; /* has auto wrap around */ |
| 61 | char tt_retain; /* can retain below (db flag) */ |
| 62 | int tt_ntoken; /* number of compression tokens */ |
| 63 | int tt_token_min; /* minimun token size */ |
| 64 | int tt_token_max; /* maximum token size */ |
| 65 | int tt_set_token_cost; /* cost in addition to string */ |
| 66 | int tt_put_token_cost; /* constant cost */ |
| 67 | |
| 68 | /* the frame characters */ |
| 69 | short *tt_frame; |
| 70 | }; |
| 71 | struct tt tt; |
| 72 | |
| 73 | /* |
| 74 | * List of terminal drivers. |
| 75 | */ |
| 76 | struct tt_tab { |
| 77 | char *tt_name; |
| 78 | int tt_len; |
| 79 | int (*tt_func)(); |
| 80 | }; |
| 81 | extern struct tt_tab tt_tab[]; |
| 82 | |
| 83 | /* |
| 84 | * Clean interface to termcap routines. |
| 85 | * Too may t's. |
| 86 | */ |
| 87 | char tt_strings[1024]; /* string buffer */ |
| 88 | char *tt_strp; /* pointer for it */ |
| 89 | |
| 90 | struct tt_str { |
| 91 | char *ts_str; |
| 92 | int ts_n; |
| 93 | }; |
| 94 | |
| 95 | struct tt_str *tttgetstr(); |
| 96 | struct tt_str *ttxgetstr(); /* tgetstr() and expand delays */ |
| 97 | |
| 98 | int tttputc(); |
| 99 | #define tttputs(s, n) tputs((s)->ts_str, (n), tttputc) |
| 100 | #define ttxputs(s) ttwrite((s)->ts_str, (s)->ts_n) |
| 101 | |
| 102 | /* |
| 103 | * Buffered output without stdio. |
| 104 | * These variables have different meanings from the ww_ob* variabels. |
| 105 | * But I'm too lazy to think up different names. |
| 106 | */ |
| 107 | char tt_ob[512]; |
| 108 | char *tt_obp; |
| 109 | char *tt_obe; |
| 110 | #define ttputc(c) (tt_obp < tt_obe ? (*tt_obp++ = (c)) \ |
| 111 | : (ttflush(), *tt_obp++ = (c))) |