xref: /original-bsd/usr.bin/window/tt.h (revision 9ae781f3)
15e07adaeSedward /*
2*9ae781f3Sbostic  * Copyright (c) 1983, 1993
3*9ae781f3Sbostic  *	The Regents of the University of California.  All rights reserved.
4bac0d407Sbostic  *
58e751acfSbostic  * This code is derived from software contributed to Berkeley by
68e751acfSbostic  * Edward Wang at The University of California, Berkeley.
78e751acfSbostic  *
8122a1d9eSbostic  * %sccs.include.redist.c%
9bac0d407Sbostic  *
10*9ae781f3Sbostic  *	@(#)tt.h	8.1 (Berkeley) 06/06/93
115e07adaeSedward  */
125e07adaeSedward 
130bbb2bdbSedward /*
140bbb2bdbSedward  * Interface structure for the terminal drivers.
150bbb2bdbSedward  */
165e07adaeSedward struct tt {
170bbb2bdbSedward 		/* startup and cleanup */
185ec5e80aSedward 	int (*tt_start)();
193b2f06aaSedward 	int (*tt_reset)();
20b7046220Sedward 	int (*tt_end)();
210bbb2bdbSedward 
220bbb2bdbSedward 		/* terminal functions */
23b7046220Sedward 	int (*tt_move)();
245e07adaeSedward 	int (*tt_insline)();
255e07adaeSedward 	int (*tt_delline)();
2664a3ee6bSedward 	int (*tt_inschar)();
2717648675Sedward 	int (*tt_insspace)();
285e07adaeSedward 	int (*tt_delchar)();
290bbb2bdbSedward 	int (*tt_write)();		/* write a whole block */
300bbb2bdbSedward 	int (*tt_putc)();		/* write one character */
315e07adaeSedward 	int (*tt_clreol)();
325e07adaeSedward 	int (*tt_clreos)();
335e07adaeSedward 	int (*tt_clear)();
34233f513cSedward 	int (*tt_scroll_down)();
35233f513cSedward 	int (*tt_scroll_up)();
36233f513cSedward 	int (*tt_setscroll)();		/* set scrolling region */
37c657ab77Sedward 	int (*tt_setmodes)();		/* set display modes */
385ec5e80aSedward 	int (*tt_set_token)();		/* define a token */
395ec5e80aSedward 	int (*tt_put_token)();		/* refer to a defined token */
403b2f06aaSedward 	int (*tt_compress)();		/* begin, end compression */
413b2f06aaSedward 	int (*tt_checksum)();		/* compute checksum */
423b2f06aaSedward 	int (*tt_checkpoint)();		/* checkpoint protocol */
434277bd53Sedward 	int (*tt_rint)();		/* input processing */
440bbb2bdbSedward 
450bbb2bdbSedward 		/* internal variables */
460bbb2bdbSedward 	char tt_modes;			/* the current display modes */
470bbb2bdbSedward 	char tt_nmodes;			/* the new modes for next write */
480bbb2bdbSedward 	char tt_insert;			/* currently in insert mode */
490bbb2bdbSedward 	int tt_row;			/* cursor row */
500bbb2bdbSedward 	int tt_col;			/* cursor column */
51233f513cSedward 	int tt_scroll_top;		/* top of scrolling region */
52233f513cSedward 	int tt_scroll_bot;		/* bottom of scrolling region */
530bbb2bdbSedward 
540bbb2bdbSedward 		/* terminal info */
550bbb2bdbSedward 	int tt_nrow;			/* number of display rows */
560bbb2bdbSedward 	int tt_ncol;			/* number of display columns */
570bbb2bdbSedward 	char tt_availmodes;		/* the display modes supported */
588ae7c6f7Sedward 	char tt_wrap;			/* has auto wrap around */
59513fd5f5Sedward 	char tt_retain;			/* can retain below (db flag) */
607175ad38Sedward 	short tt_padc;			/* the pad character */
615ec5e80aSedward 	int tt_ntoken;			/* number of compression tokens */
625ec5e80aSedward 	int tt_token_min;		/* minimun token size */
635ec5e80aSedward 	int tt_token_max;		/* maximum token size */
645ec5e80aSedward 	int tt_set_token_cost;		/* cost in addition to string */
655ec5e80aSedward 	int tt_put_token_cost;		/* constant cost */
663b2f06aaSedward 	int tt_ack;			/* checkpoint ack-nack flag */
670bbb2bdbSedward 
680bbb2bdbSedward 		/* the frame characters */
69d19dc739Sedward 	short *tt_frame;
707175ad38Sedward 
713b2f06aaSedward 		/* ttflush() hook */
727175ad38Sedward 	int (*tt_flush)();
735e07adaeSedward };
745e07adaeSedward struct tt tt;
755e07adaeSedward 
760bbb2bdbSedward /*
777175ad38Sedward  * tt_padc is used by the compression routine.
787175ad38Sedward  * It is a short to allow the driver to indicate that there is no padding.
797175ad38Sedward  */
807175ad38Sedward #define TT_PADC_NONE 0x100
817175ad38Sedward 
827175ad38Sedward /*
830bbb2bdbSedward  * List of terminal drivers.
840bbb2bdbSedward  */
855e07adaeSedward struct tt_tab {
865e07adaeSedward 	char *tt_name;
875e07adaeSedward 	int tt_len;
885e07adaeSedward 	int (*tt_func)();
895e07adaeSedward };
906eab0aaaSedward extern struct tt_tab tt_tab[];
9163b0d991Sedward 
9263b0d991Sedward /*
930bbb2bdbSedward  * Clean interface to termcap routines.
94ac9c5eecSedward  * Too may t's.
9563b0d991Sedward  */
9663b0d991Sedward char tt_strings[1024];		/* string buffer */
9763b0d991Sedward char *tt_strp;			/* pointer for it */
9863b0d991Sedward 
997c2cde3aSedward struct tt_str {
1007c2cde3aSedward 	char *ts_str;
1017c2cde3aSedward 	int ts_n;
1027c2cde3aSedward };
1037c2cde3aSedward 
1047c2cde3aSedward struct tt_str *tttgetstr();
1057c2cde3aSedward struct tt_str *ttxgetstr();	/* tgetstr() and expand delays */
10663b0d991Sedward 
107ac9c5eecSedward int tttputc();
1087c2cde3aSedward #define tttputs(s, n)	tputs((s)->ts_str, (n), tttputc)
1097c2cde3aSedward #define ttxputs(s)	ttwrite((s)->ts_str, (s)->ts_n)
110ac9c5eecSedward 
111ac9c5eecSedward /*
112ac9c5eecSedward  * Buffered output without stdio.
11353c9470aSedward  * These variables have different meanings from the ww_ob* variables.
114ac9c5eecSedward  * But I'm too lazy to think up different names.
115ac9c5eecSedward  */
1167175ad38Sedward char *tt_ob;
117ac9c5eecSedward char *tt_obp;
118ac9c5eecSedward char *tt_obe;
11913ff643cSedward #define ttputc(c)	(tt_obp < tt_obe ? (*tt_obp++ = (c)) \
1203b2f06aaSedward 				: (ttflush(), *tt_obp++ = (c)))
12153c9470aSedward 
12253c9470aSedward /*
12353c9470aSedward  * Convenience macros for the drivers
12453c9470aSedward  * They require char.h
12553c9470aSedward  */
12653c9470aSedward #define ttctrl(c)	ttputc(ctrl(c))
12753c9470aSedward #define ttesc(c)	(ttctrl('['), ttputc(c))
128