[BACK]Return to tt.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / window

Annotation of src/usr.bin/window/tt.h, Revision 1.1.1.1

1.1       deraadt     1: /*     $NetBSD: tt.h,v 1.3 1995/09/28 10:34:42 tls Exp $       */
                      2:
                      3: /*
                      4:  * Copyright (c) 1983, 1993
                      5:  *     The Regents of the University of California.  All rights reserved.
                      6:  *
                      7:  * This code is derived from software contributed to Berkeley by
                      8:  * Edward Wang at The University of California, Berkeley.
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
                     18:  * 3. All advertising materials mentioning features or use of this software
                     19:  *    must display the following acknowledgement:
                     20:  *     This product includes software developed by the University of
                     21:  *     California, Berkeley and its contributors.
                     22:  * 4. Neither the name of the University nor the names of its contributors
                     23:  *    may be used to endorse or promote products derived from this software
                     24:  *    without specific prior written permission.
                     25:  *
                     26:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     27:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     28:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     29:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     30:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     31:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     32:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     33:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     34:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     35:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     36:  * SUCH DAMAGE.
                     37:  *
                     38:  *     @(#)tt.h        8.1 (Berkeley) 6/6/93
                     39:  */
                     40:
                     41: /*
                     42:  * Interface structure for the terminal drivers.
                     43:  */
                     44: struct tt {
                     45:                /* startup and cleanup */
                     46:        int (*tt_start)();
                     47:        int (*tt_reset)();
                     48:        int (*tt_end)();
                     49:
                     50:                /* terminal functions */
                     51:        int (*tt_move)();
                     52:        int (*tt_insline)();
                     53:        int (*tt_delline)();
                     54:        int (*tt_inschar)();
                     55:        int (*tt_insspace)();
                     56:        int (*tt_delchar)();
                     57:        int (*tt_write)();              /* write a whole block */
                     58:        int (*tt_putc)();               /* write one character */
                     59:        int (*tt_clreol)();
                     60:        int (*tt_clreos)();
                     61:        int (*tt_clear)();
                     62:        int (*tt_scroll_down)();
                     63:        int (*tt_scroll_up)();
                     64:        int (*tt_setscroll)();          /* set scrolling region */
                     65:        int (*tt_setmodes)();           /* set display modes */
                     66:        int (*tt_set_token)();          /* define a token */
                     67:        int (*tt_put_token)();          /* refer to a defined token */
                     68:        int (*tt_compress)();           /* begin, end compression */
                     69:        int (*tt_checksum)();           /* compute checksum */
                     70:        int (*tt_checkpoint)();         /* checkpoint protocol */
                     71:        int (*tt_rint)();               /* input processing */
                     72:
                     73:                /* internal variables */
                     74:        char tt_modes;                  /* the current display modes */
                     75:        char tt_nmodes;                 /* the new modes for next write */
                     76:        char tt_insert;                 /* currently in insert mode */
                     77:        int tt_row;                     /* cursor row */
                     78:        int tt_col;                     /* cursor column */
                     79:        int tt_scroll_top;              /* top of scrolling region */
                     80:        int tt_scroll_bot;              /* bottom of scrolling region */
                     81:
                     82:                /* terminal info */
                     83:        int tt_nrow;                    /* number of display rows */
                     84:        int tt_ncol;                    /* number of display columns */
                     85:        char tt_availmodes;             /* the display modes supported */
                     86:        char tt_wrap;                   /* has auto wrap around */
                     87:        char tt_retain;                 /* can retain below (db flag) */
                     88:        short tt_padc;                  /* the pad character */
                     89:        int tt_ntoken;                  /* number of compression tokens */
                     90:        int tt_token_min;               /* minimun token size */
                     91:        int tt_token_max;               /* maximum token size */
                     92:        int tt_set_token_cost;          /* cost in addition to string */
                     93:        int tt_put_token_cost;          /* constant cost */
                     94:        int tt_ack;                     /* checkpoint ack-nack flag */
                     95:
                     96:                /* the frame characters */
                     97:        short *tt_frame;
                     98:
                     99:                /* ttflush() hook */
                    100:        int (*tt_flush)();
                    101: };
                    102: struct tt tt;
                    103:
                    104: /*
                    105:  * tt_padc is used by the compression routine.
                    106:  * It is a short to allow the driver to indicate that there is no padding.
                    107:  */
                    108: #define TT_PADC_NONE 0x100
                    109:
                    110: /*
                    111:  * List of terminal drivers.
                    112:  */
                    113: struct tt_tab {
                    114:        char *tt_name;
                    115:        int tt_len;
                    116:        int (*tt_func)();
                    117: };
                    118: extern struct tt_tab tt_tab[];
                    119:
                    120: /*
                    121:  * Clean interface to termcap routines.
                    122:  * Too may t's.
                    123:  */
                    124: char tt_strings[1024];         /* string buffer */
                    125: char *tt_strp;                 /* pointer for it */
                    126:
                    127: struct tt_str {
                    128:        char *ts_str;
                    129:        int ts_n;
                    130: };
                    131:
                    132: struct tt_str *tttgetstr();
                    133: struct tt_str *ttxgetstr();    /* tgetstr() and expand delays */
                    134:
                    135: int tttputc();
                    136: #define tttputs(s, n)  tputs((s)->ts_str, (n), tttputc)
                    137: #define ttxputs(s)     ttwrite((s)->ts_str, (s)->ts_n)
                    138:
                    139: /*
                    140:  * Buffered output without stdio.
                    141:  * These variables have different meanings from the ww_ob* variables.
                    142:  * But I'm too lazy to think up different names.
                    143:  */
                    144: char *tt_ob;
                    145: char *tt_obp;
                    146: char *tt_obe;
                    147: #define ttputc(c)      (tt_obp < tt_obe ? (*tt_obp++ = (c)) \
                    148:                                : (ttflush(), *tt_obp++ = (c)))
                    149:
                    150: /*
                    151:  * Convenience macros for the drivers
                    152:  * They require char.h
                    153:  */
                    154: #define ttctrl(c)      ttputc(ctrl(c))
                    155: #define ttesc(c)       (ttctrl('['), ttputc(c))