114411Sedward /* 2*62463Sbostic * Copyright (c) 1983, 1993 3*62463Sbostic * The Regents of the University of California. All rights reserved. 433514Sbostic * 542954Sbostic * This code is derived from software contributed to Berkeley by 642954Sbostic * Edward Wang at The University of California, Berkeley. 742954Sbostic * 842835Sbostic * %sccs.include.redist.c% 933514Sbostic * 10*62463Sbostic * @(#)tt.h 8.1 (Berkeley) 06/06/93 1114411Sedward */ 1214411Sedward 1314991Sedward /* 1414991Sedward * Interface structure for the terminal drivers. 1514991Sedward */ 1614411Sedward struct tt { 1714991Sedward /* startup and cleanup */ 1838563Sedward int (*tt_start)(); 1956710Sedward int (*tt_reset)(); 2014649Sedward int (*tt_end)(); 2114991Sedward 2214991Sedward /* terminal functions */ 2314649Sedward int (*tt_move)(); 2414411Sedward int (*tt_insline)(); 2514411Sedward int (*tt_delline)(); 2637998Sedward int (*tt_inschar)(); 2738747Sedward int (*tt_insspace)(); 2814411Sedward int (*tt_delchar)(); 2914991Sedward int (*tt_write)(); /* write a whole block */ 3014991Sedward int (*tt_putc)(); /* write one character */ 3114411Sedward int (*tt_clreol)(); 3214411Sedward int (*tt_clreos)(); 3314411Sedward int (*tt_clear)(); 3434264Sedward int (*tt_scroll_down)(); 3534264Sedward int (*tt_scroll_up)(); 3634264Sedward int (*tt_setscroll)(); /* set scrolling region */ 3724289Sedward int (*tt_setmodes)(); /* set display modes */ 3838563Sedward int (*tt_set_token)(); /* define a token */ 3938563Sedward int (*tt_put_token)(); /* refer to a defined token */ 4056710Sedward int (*tt_compress)(); /* begin, end compression */ 4156710Sedward int (*tt_checksum)(); /* compute checksum */ 4256710Sedward int (*tt_checkpoint)(); /* checkpoint protocol */ 4354374Sedward int (*tt_rint)(); /* input processing */ 4414991Sedward 4514991Sedward /* internal variables */ 4614991Sedward char tt_modes; /* the current display modes */ 4714991Sedward char tt_nmodes; /* the new modes for next write */ 4814991Sedward char tt_insert; /* currently in insert mode */ 4914991Sedward int tt_row; /* cursor row */ 5014991Sedward int tt_col; /* cursor column */ 5134264Sedward int tt_scroll_top; /* top of scrolling region */ 5234264Sedward int tt_scroll_bot; /* bottom of scrolling region */ 5314991Sedward 5414991Sedward /* terminal info */ 5514991Sedward int tt_nrow; /* number of display rows */ 5614991Sedward int tt_ncol; /* number of display columns */ 5714991Sedward char tt_availmodes; /* the display modes supported */ 5814696Sedward char tt_wrap; /* has auto wrap around */ 5914838Sedward char tt_retain; /* can retain below (db flag) */ 6039159Sedward short tt_padc; /* the pad character */ 6138563Sedward int tt_ntoken; /* number of compression tokens */ 6238563Sedward int tt_token_min; /* minimun token size */ 6338563Sedward int tt_token_max; /* maximum token size */ 6438563Sedward int tt_set_token_cost; /* cost in addition to string */ 6538563Sedward int tt_put_token_cost; /* constant cost */ 6656710Sedward int tt_ack; /* checkpoint ack-nack flag */ 6714991Sedward 6814991Sedward /* the frame characters */ 6915733Sedward short *tt_frame; 7039159Sedward 7156710Sedward /* ttflush() hook */ 7239159Sedward int (*tt_flush)(); 7314411Sedward }; 7414411Sedward struct tt tt; 7514411Sedward 7614991Sedward /* 7739159Sedward * tt_padc is used by the compression routine. 7839159Sedward * It is a short to allow the driver to indicate that there is no padding. 7939159Sedward */ 8039159Sedward #define TT_PADC_NONE 0x100 8139159Sedward 8239159Sedward /* 8314991Sedward * List of terminal drivers. 8414991Sedward */ 8514411Sedward struct tt_tab { 8614411Sedward char *tt_name; 8714411Sedward int tt_len; 8814411Sedward int (*tt_func)(); 8914411Sedward }; 9032325Sedward extern struct tt_tab tt_tab[]; 9114690Sedward 9214690Sedward /* 9314991Sedward * Clean interface to termcap routines. 9416122Sedward * Too may t's. 9514690Sedward */ 9614690Sedward char tt_strings[1024]; /* string buffer */ 9714690Sedward char *tt_strp; /* pointer for it */ 9814690Sedward 9924975Sedward struct tt_str { 10024975Sedward char *ts_str; 10124975Sedward int ts_n; 10224975Sedward }; 10314690Sedward 10424975Sedward struct tt_str *tttgetstr(); 10524975Sedward struct tt_str *ttxgetstr(); /* tgetstr() and expand delays */ 10624975Sedward 10716122Sedward int tttputc(); 10824975Sedward #define tttputs(s, n) tputs((s)->ts_str, (n), tttputc) 10924975Sedward #define ttxputs(s) ttwrite((s)->ts_str, (s)->ts_n) 11016122Sedward 11116122Sedward /* 11216122Sedward * Buffered output without stdio. 11338797Sedward * These variables have different meanings from the ww_ob* variables. 11416122Sedward * But I'm too lazy to think up different names. 11516122Sedward */ 11639159Sedward char *tt_ob; 11716122Sedward char *tt_obp; 11816122Sedward char *tt_obe; 11917396Sedward #define ttputc(c) (tt_obp < tt_obe ? (*tt_obp++ = (c)) \ 12056710Sedward : (ttflush(), *tt_obp++ = (c))) 12138797Sedward 12238797Sedward /* 12338797Sedward * Convenience macros for the drivers 12438797Sedward * They require char.h 12538797Sedward */ 12638797Sedward #define ttctrl(c) ttputc(ctrl(c)) 12738797Sedward #define ttesc(c) (ttctrl('['), ttputc(c)) 128