home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.bin / window / tt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-18  |  4.7 KB  |  148 lines

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