[BACK]Return to curses_private.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libcurses

Annotation of src/lib/libcurses/curses_private.h, Revision 1.39

1.39    ! jdc         1: /*     $NetBSD: curses_private.h,v 1.38 2006/01/15 11:43:54 jdc Exp $  */
1.1       blymn       2:
                      3: /*-
                      4:  * Copyright (c) 1998-2000 Brett Lymn
                      5:  *                         (blymn@baea.com.au, brett_lymn@yahoo.com.au)
                      6:  * All rights reserved.
                      7:  *
                      8:  * This code has been donated to The NetBSD Foundation by the Author.
                      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. The name of the author may not be used to endorse or promote products
1.16      wiz        16:  *    derived from this software without specific prior written permission
1.1       blymn      17:  *
                     18:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     19:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     20:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     21:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     22:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     23:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     24:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     25:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     26:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
                     27:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     28:  *
                     29:  *
                     30:  */
                     31:
1.17      blymn      32: #include <termios.h>
                     33:
1.1       blymn      34: /* Private structure definitions for curses. */
1.18      blymn      35:
                     36: /* Termcap capabilities. */
                     37: extern char    __tc_am, __tc_bs, __tc_cc, __tc_da, __tc_eo,
                     38:                __tc_hc, __tc_hl, __tc_in, __tc_mi, __tc_ms,
                     39:                __tc_nc, __tc_ns, __tc_os, __tc_ul, __tc_ut,
                     40:                __tc_xb, __tc_xn, __tc_xt, __tc_xs, __tc_xx;
                     41: extern char    __CA;
                     42: extern int     __tc_pa, __tc_Co, __tc_NC;
                     43: extern char    *__tc_ac, *__tc_AB, *__tc_ae, *__tc_AF, *__tc_AL,
                     44:                *__tc_al, *__tc_as, *__tc_bc, *__tc_bl, *__tc_bt,
                     45:                *__tc_cd, *__tc_ce, *__tc_cl, *__tc_cm, *__tc_cr,
                     46:                *__tc_cs, *__tc_dc, *__tc_DL, *__tc_dl, *__tc_dm,
                     47:                *__tc_DO, *__tc_do, *__tc_eA, *__tc_ed, *__tc_ei,
                     48:                *__tc_ho, *__tc_Ic, *__tc_ic, *__tc_im, *__tc_Ip,
                     49:                *__tc_ip, *__tc_k0, *__tc_k1, *__tc_k2, *__tc_k3,
                     50:                *__tc_k4, *__tc_k5, *__tc_k6, *__tc_k7, *__tc_k8,
                     51:                *__tc_k9, *__tc_kd, *__tc_ke, *__tc_kh, *__tc_kl,
                     52:                *__tc_kr, *__tc_ks, *__tc_ku, *__tc_LE, *__tc_ll,
                     53:                *__tc_ma, *__tc_mb, *__tc_md, *__tc_me, *__tc_mh,
                     54:                *__tc_mk, *__tc_mm, *__tc_mo, *__tc_mp, *__tc_mr,
                     55:                *__tc_nd, *__tc_nl, *__tc_oc, *__tc_op,
                     56:                *__tc_rc, *__tc_RI, *__tc_Sb, *__tc_sc, *__tc_se,
                     57:                *__tc_SF, *__tc_Sf, *__tc_sf, *__tc_so, *__tc_sp,
                     58:                *__tc_SR, *__tc_sr, *__tc_ta, *__tc_te, *__tc_ti,
                     59:                *__tc_uc, *__tc_ue, *__tc_UP, *__tc_up, *__tc_us,
                     60:                *__tc_vb, *__tc_ve, *__tc_vi, *__tc_vs;
                     61:
1.1       blymn      62: /*
                     63:  * A window an array of __LINE structures pointed to by the 'lines' pointer.
                     64:  * A line is an array of __LDATA structures pointed to by the 'line' pointer.
                     65:  *
                     66:  * IMPORTANT: the __LDATA structure must NOT induce any padding, so if new
                     67:  * fields are added -- padding fields with *constant values* should ensure
                     68:  * that the compiler will not generate any padding when storing an array of
                     69:  *  __LDATA structures.  This is to enable consistent use of memcmp, and memcpy
                     70:  * for comparing and copying arrays.
                     71:  */
                     72:
                     73: struct __ldata {
                     74:        wchar_t ch;                     /* Character */
                     75:        attr_t  attr;                   /* Attributes */
                     76: };
                     77:
                     78: #define __LDATASIZE    (sizeof(__LDATA))
                     79:
                     80: struct __line {
1.24      blymn      81: #ifdef DEBUG
                     82: #define SENTINEL_VALUE 0xaac0ffee
                     83:
                     84:        unsigned int sentinel;          /* try to catch line overflows */
                     85: #endif
1.1       blymn      86: #define        __ISDIRTY       0x01            /* Line is dirty. */
                     87: #define __ISPASTEOL    0x02            /* Cursor is past end of line */
                     88:        unsigned int flags;
                     89:        unsigned int hash;              /* Hash value for the line. */
                     90:        int *firstchp, *lastchp;        /* First and last chngd columns ptrs */
                     91:        int firstch, lastch;            /* First and last changed columns. */
                     92:        __LDATA *line;                  /* Pointer to the line text. */
                     93: };
                     94:
                     95: struct __window {              /* Window structure. */
                     96:        struct __window *nextp, *orig;  /* Subwindows list and parent. */
                     97:        int begy, begx;                 /* Window home. */
                     98:        int cury, curx;                 /* Current x, y coordinates. */
                     99:        int maxy, maxx;                 /* Maximum values for curx, cury. */
1.29      dsl       100:        int reqy, reqx;                 /* Size requested when created */
                    101:        int ch_off;                     /* x offset for firstch/lastch. */
1.1       blymn     102:        __LINE **lines;                 /* Array of pointers to the lines */
                    103:        __LINE  *lspace;                /* line space (for cleanup) */
                    104:        __LDATA *wspace;                /* window space (for cleanup) */
                    105:
                    106: #define        __ENDLINE       0x00000001      /* End of screen. */
                    107: #define        __FLUSH         0x00000002      /* Fflush(stdout) after refresh. */
                    108: #define        __FULLWIN       0x00000004      /* Window is a screen. */
                    109: #define        __IDLINE        0x00000008      /* Insert/delete sequences. */
                    110: #define        __SCROLLWIN     0x00000010      /* Last char will scroll window. */
                    111: #define        __SCROLLOK      0x00000020      /* Scrolling ok. */
                    112: #define        __CLEAROK       0x00000040      /* Clear on next refresh. */
                    113: #define        __LEAVEOK       0x00000100      /* If cursor left */
                    114: #define        __KEYPAD        0x00010000      /* If interpreting keypad codes */
                    115: #define        __NOTIMEOUT     0x00020000      /* Wait indefinitely for func keys */
1.26      jdc       116: #define __IDCHAR       0x00040000      /* insert/delete char sequences */
                    117: #define __ISPAD                0x00080000      /* "window" is a pad */
1.1       blymn     118:        unsigned int flags;
                    119:        int     delay;                  /* delay for getch() */
                    120:        attr_t  wattr;                  /* Character attributes */
1.5       jdc       121:        wchar_t bch;                    /* Background character */
1.2       jdc       122:        attr_t  battr;                  /* Background attributes */
1.14      jdc       123:        int     scr_t, scr_b;           /* Scrolling region top, bottom */
1.32      dsl       124:        SCREEN  *screen;                /* Screen for this window */
1.36      jdc       125:        int     pbegy, pbegx,
                    126:                sbegy, sbegx,
                    127:                smaxy, smaxx;           /* Saved prefresh() values */
1.1       blymn     128: };
1.5       jdc       129:
                    130: /* Set of attributes unset by 'me' - 'mb', 'md', 'mh', 'mk', 'mp' and 'mr'. */
                    131: #define        __TERMATTR \
                    132:        (__REVERSE | __BLINK | __DIM | __BOLD | __BLANK | __PROTECT)
1.2       jdc       133:
1.3       jdc       134: struct __winlist {
                    135:        struct __window         *winp;  /* The window. */
                    136:        struct __winlist        *nextp; /* Next window. */
                    137: };
                    138:
1.17      blymn     139: struct __color {
                    140:        short   num;
                    141:        short   red;
                    142:        short   green;
                    143:        short   blue;
                    144:        int     flags;
                    145: };
                    146:
                    147: /* List of colour pairs */
                    148: struct __pair {
                    149:        short   fore;
                    150:        short   back;
                    151:        int     flags;
                    152: };
                    153:
                    154: /* Maximum colours */
                    155: #define        MAX_COLORS      64
                    156: /* Maximum colour pairs - determined by number of colour bits in attr_t */
1.25      jdc       157: #define        MAX_PAIRS       PAIR_NUMBER(__COLOR)
1.17      blymn     158:
                    159: typedef struct keymap keymap_t;
                    160:
                    161: /* this is the encapsulation of the terminal definition, one for
                    162:  * each terminal that curses talks to.
                    163:  */
                    164: struct __screen {
                    165:        FILE    *infd, *outfd;  /* input and output file descriptors */
                    166:        WINDOW  *curscr;        /* Current screen. */
                    167:        WINDOW  *stdscr;        /* Standard screen. */
                    168:        WINDOW  *__virtscr;     /* Virtual screen (for doupdate()). */
                    169:        int      curwin;        /* current window for refresh */
1.29      dsl       170:        int      lx, ly;        /* loop parameters for refresh */
1.17      blymn     171:        int      COLS;          /* Columns on the screen. */
                    172:        int      LINES;         /* Lines on the screen. */
                    173:        int      COLORS;        /* Maximum colors on the screen */
                    174:        int      COLOR_PAIRS;   /* Maximum color pairs on the screen */
                    175:        int      My_term;       /* Use Def_term regardless. */
                    176:        char     GT;            /* Gtty indicates tabs. */
                    177:        char     NONL;          /* Term can't hack LF doing a CR. */
                    178:        char     UPPERCASE;     /* Terminal is uppercase only. */
                    179:
                    180:         /* BEWARE!!! The order of the following terminal capabilities */
                    181:         /* (tc_foo) is important - do not update without fixing the zap */
                    182:         /* function in setterm.c */
                    183:        char    tc_am, tc_bs, tc_cc, tc_da, tc_eo, tc_hc, tc_hl, tc_in, tc_mi,
                    184:                tc_ms, tc_nc, tc_ns, tc_os, tc_ul, tc_ut, tc_xb, tc_xn, tc_xt,
                    185:                tc_xs, tc_xx;
                    186:        int     flag_count;
                    187:        int     tc_pa, tc_Co, tc_NC;
                    188:        int     int_count;
                    189:        char    *tc_AB, *tc_ac, *tc_ae, *tc_AF, *tc_AL,
                    190:                *tc_al, *tc_as, *tc_bc, *tc_bl, *tc_bt,
                    191:                *tc_cd, *tc_ce, *tc_cl, *tc_cm, *tc_cr,
                    192:                *tc_cs, *tc_dc, *tc_DL, *tc_dl, *tc_dm,
                    193:                *tc_DO, *tc_do, *tc_eA, *tc_ed, *tc_ei,
                    194:                *tc_ho, *tc_Ic, *tc_ic, *tc_im, *tc_Ip,
                    195:                *tc_ip, *tc_k0, *tc_k1, *tc_k2, *tc_k3,
                    196:                *tc_k4, *tc_k5, *tc_k6, *tc_k7, *tc_k8,
                    197:                *tc_k9, *tc_kd, *tc_ke, *tc_kh, *tc_kl,
                    198:                *tc_kr, *tc_ks, *tc_ku, *tc_LE, *tc_ll,
                    199:                *tc_ma, *tc_mb, *tc_md, *tc_me, *tc_mh,
                    200:                *tc_mk, *tc_mm, *tc_mo, *tc_mp, *tc_mr,
                    201:                *tc_nd, *tc_nl, *tc_oc, *tc_op, *tc_pc,
                    202:                *tc_rc, *tc_RI, *tc_Sb, *tc_sc, *tc_se,
                    203:                *tc_SF, *tc_Sf, *tc_sf, *tc_so, *tc_sp,
                    204:                *tc_SR, *tc_sr, *tc_ta, *tc_te, *tc_ti,
                    205:                *tc_uc, *tc_ue, *tc_UP, *tc_up, *tc_us,
                    206:                *tc_vb, *tc_ve, *tc_vi, *tc_vs;
                    207:        char CA;
                    208:        int str_count;
                    209:        chtype acs_char[NUM_ACS];
                    210:        struct __color colours[MAX_COLORS];
                    211:        struct __pair  colour_pairs[MAX_PAIRS];
                    212:        attr_t  nca;
1.20      blymn     213:
1.17      blymn     214: /* Style of colour manipulation */
                    215: #define COLOR_NONE     0
                    216: #define COLOR_ANSI     1       /* ANSI/DEC-style colour manipulation */
                    217: #define COLOR_HP       2       /* HP-style colour manipulation */
                    218: #define COLOR_TEK      3       /* Tektronix-style colour manipulation */
                    219: #define COLOR_OTHER    4       /* None of the others but can set fore/back */
                    220:        int color_type;
1.20      blymn     221:
1.17      blymn     222:        attr_t mask_op;
                    223:        attr_t mask_me;
                    224:        attr_t mask_ue;
                    225:        attr_t mask_se;
                    226:        struct tinfo *cursesi_genbuf;
                    227:        int old_mode; /* old cursor visibility state for terminal */
                    228:        keymap_t *base_keymap;
                    229:        int echoit;
                    230:        int pfast;
                    231:        int rawmode;
1.30      jdc       232:        int nl;
1.17      blymn     233:        int noqch;
                    234:        int clearok;
                    235:        int useraw;
                    236:        struct __winlist *winlistp;
                    237:        struct   termios cbreakt, rawt, *curt, save_termios;
                    238:        struct termios orig_termios, baset, savedtty;
                    239:        int ovmin;
                    240:        int ovtime;
                    241:        char *stdbuf;
                    242:        unsigned int len;
                    243:        int meta_state;
                    244:        char pad_char;
1.21      christos  245:        char ttytype[128];
1.17      blymn     246:        int endwin;
1.22      itojun    247:        int notty;
1.27      blymn     248:        int half_delay;
1.35      jdc       249:        int resized;
1.17      blymn     250: };
                    251:
                    252:
1.11      jdc       253: extern char     __GT;                  /* Gtty indicates tabs. */
                    254: extern char     __NONL;                /* Term can't hack LF doing a CR. */
                    255: extern char     __UPPERCASE;           /* Terminal is uppercase only. */
                    256: extern int      My_term;               /* Use Def_term regardless. */
                    257: extern const char      *Def_term;      /* Default terminal type. */
1.17      blymn     258: extern SCREEN   *_cursesi_screen;       /* The current screen in use */
1.11      jdc       259:
1.39    ! jdc       260: /* Debugging options/functions. */
1.2       jdc       261: #ifdef DEBUG
1.39    ! jdc       262: #define __CTRACE_TSTAMP                0x00000001
        !           263: #define __CTRACE_MISC          0x00000002
        !           264: #define __CTRACE_INIT          0x00000004
        !           265: #define __CTRACE_SCREEN                0x00000008
        !           266: #define __CTRACE_WINDOW                0x00000010
        !           267: #define __CTRACE_REFRESH       0x00000020
        !           268: #define __CTRACE_COLOR         0x00000040
        !           269: #define __CTRACE_INPUT         0x00000080
        !           270: #define __CTRACE_OUTPUT                0x00000100
        !           271: #define __CTRACE_LINE          0x00000200
        !           272: #define __CTRACE_ATTR          0x00000400
        !           273: #define __CTRACE_ERASE         0x00000800
        !           274: #define __CTRACE_ALL           0x7fffffff
        !           275: void    __CTRACE_init(void);
        !           276: void    __CTRACE(int, const char *, ...) __attribute__((__format__(__printf__, 2, 3)));
1.2       jdc       277: #endif
1.39    ! jdc       278:
        !           279: /* Private functions. */
1.23      itojun    280: void     __cputchar_args(char, void *);
                    281: void     _cursesi_free_keymap(keymap_t *);
                    282: int      _cursesi_gettmode(SCREEN *);
                    283: void     _cursesi_reset_acs(SCREEN *);
                    284: void     _cursesi_resetterm(SCREEN *);
                    285: int      _cursesi_setterm(char *, SCREEN *);
1.4       blymn     286: int     __delay(void);
1.37      dsl       287: u_int   __hash_more(const void *, size_t, u_int);
1.23      itojun    288: #define        __hash(s, len)  __hash_more((s), (len), 0u)
                    289: void    __id_subwins(WINDOW *);
                    290: void    __init_getch(SCREEN *);
                    291: void    __init_acs(SCREEN *);
                    292: char   *__longname(char *, char *);    /* Original BSD version */
                    293: int     __mvcur(int, int, int, int, int);
1.26      jdc       294: WINDOW  *__newwin(SCREEN *, int, int, int, int, int);
1.4       blymn     295: int     __nodelay(void);
                    296: int     __notimeout(void);
                    297: char   *__parse_cap(const char *, ...);
                    298: void    __restartwin(void);
                    299: void    __restore_colors(void);
1.6       blymn     300: void     __restore_cursor_vis(void);
                    301: void     __restore_meta_state(void);
1.4       blymn     302: void    __restore_termios(void);
                    303: void    __restore_stophandler(void);
1.35      jdc       304: void    __restore_winchhandler(void);
1.4       blymn     305: void    __save_termios(void);
1.25      jdc       306: void    __set_color(WINDOW *win, attr_t attr);
1.4       blymn     307: void    __set_stophandler(void);
1.35      jdc       308: void    __set_winchhandler(void);
1.23      itojun    309: void    __set_subwin(WINDOW *, WINDOW *);
                    310: void    __startwin(SCREEN *);
                    311: void    __stop_signal_handler(int);
1.4       blymn     312: int     __stopwin(void);
1.23      itojun    313: void    __swflags(WINDOW *);
                    314: int     __timeout(int);
                    315: int     __touchline(WINDOW *, int, int, int);
                    316: int     __touchwin(WINDOW *);
                    317: char   *__tscroll(const char *, int, int);
1.7       jdc       318: void    __unsetattr(int);
1.25      jdc       319: void    __unset_color(WINDOW *win);
1.23      itojun    320: int     __waddch(WINDOW *, __LDATA *);
1.15      jdc       321: int     __wgetnstr(WINDOW *, char *, int);
1.35      jdc       322: void    __winch_signal_handler(int);
1.2       jdc       323:
                    324: /* Private #defines. */
1.23      itojun    325: #define        min(a,b)        ((a) < (b) ? (a) : (b))
                    326: #define        max(a,b)        ((a) > (b) ? (a ): (b))
1.2       jdc       327:
                    328: /* Private externs. */
1.3       jdc       329: extern int              __echoit;
                    330: extern int              __endwin;
                    331: extern int              __pfast;
                    332: extern int              __rawmode;
                    333: extern int              __noqch;
1.11      jdc       334: extern attr_t           __mask_op, __mask_me, __mask_ue, __mask_se;
1.7       jdc       335: extern WINDOW          *__virtscr;
1.25      jdc       336: extern int              __using_color;
                    337: extern attr_t           __default_color;

CVSweb <webmaster@jp.NetBSD.org>