1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 1997 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */ 28*0Sstevel@tonic-gate /* All Rights Reserved */ 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate /* 31*0Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 32*0Sstevel@tonic-gate * The Regents of the University of California 33*0Sstevel@tonic-gate * All Rights Reserved 34*0Sstevel@tonic-gate * 35*0Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 36*0Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 37*0Sstevel@tonic-gate * contributors. 38*0Sstevel@tonic-gate */ 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate #ifndef _CURSHDR_H 41*0Sstevel@tonic-gate #define _CURSHDR_H 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gate #ifdef __cplusplus 46*0Sstevel@tonic-gate extern "C" { 47*0Sstevel@tonic-gate #endif 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate #define _NOHASH (-1) /* if the hash value is unknown */ 50*0Sstevel@tonic-gate #define _REDRAW (-2) /* if line need redrawn */ 51*0Sstevel@tonic-gate #define _BLANK (-3) /* if line is blank */ 52*0Sstevel@tonic-gate #define _THASH (123) /* base hash if clash with other hashes */ 53*0Sstevel@tonic-gate #define _KEY (01) 54*0Sstevel@tonic-gate #define _MACRO (02) 55*0Sstevel@tonic-gate 56*0Sstevel@tonic-gate #define _INPUTPENDING cur_term->_iwait 57*0Sstevel@tonic-gate #define _PUTS(x, y) (void) tputs(x, y, _outch) 58*0Sstevel@tonic-gate #define _VIDS(na, oa) (vidupdate((na), (oa), _outch), curscr->_attrs = (na)) 59*0Sstevel@tonic-gate #define _ONINSERT() (_PUTS(enter_insert_mode, 1), SP->phys_irm = TRUE) 60*0Sstevel@tonic-gate #define _OFFINSERT() (_PUTS(exit_insert_mode, 1), SP->phys_irm = FALSE) 61*0Sstevel@tonic-gate #define _STRNOTEQ(a, b) (a == NULL ? (b != NULL) : \ 62*0Sstevel@tonic-gate (b == NULL ? 1 : strcmp(a, b))) 63*0Sstevel@tonic-gate 64*0Sstevel@tonic-gate /* 65*0Sstevel@tonic-gate * IC and IL overheads and costs should be set to this 66*0Sstevel@tonic-gate * value if the corresponding feature is missing 67*0Sstevel@tonic-gate */ 68*0Sstevel@tonic-gate 69*0Sstevel@tonic-gate #define LARGECOST 500 70*0Sstevel@tonic-gate 71*0Sstevel@tonic-gate typedef struct 72*0Sstevel@tonic-gate { 73*0Sstevel@tonic-gate short icfixed; /* Insert char fixed overhead */ 74*0Sstevel@tonic-gate short dcfixed; /* Delete char fixed overhead */ 75*0Sstevel@tonic-gate short Insert_character; 76*0Sstevel@tonic-gate short Delete_character; 77*0Sstevel@tonic-gate short Cursor_home; 78*0Sstevel@tonic-gate short Cursor_to_ll; 79*0Sstevel@tonic-gate short Cursor_left; 80*0Sstevel@tonic-gate short Cursor_right; 81*0Sstevel@tonic-gate short Cursor_down; 82*0Sstevel@tonic-gate short Cursor_up; 83*0Sstevel@tonic-gate short Carriage_return; 84*0Sstevel@tonic-gate short Tab; 85*0Sstevel@tonic-gate short Back_tab; 86*0Sstevel@tonic-gate short Clr_eol; 87*0Sstevel@tonic-gate short Clr_bol; 88*0Sstevel@tonic-gate short Parm_ich; 89*0Sstevel@tonic-gate short Parm_dch; 90*0Sstevel@tonic-gate short Parm_left_cursor; 91*0Sstevel@tonic-gate short Parm_up_cursor; 92*0Sstevel@tonic-gate short Parm_down_cursor; 93*0Sstevel@tonic-gate short Parm_right_cursor; 94*0Sstevel@tonic-gate short Cursor_address; 95*0Sstevel@tonic-gate short Row_address; 96*0Sstevel@tonic-gate } COSTS; 97*0Sstevel@tonic-gate 98*0Sstevel@tonic-gate #define _COST(field) (SP->term_costs.field) 99*0Sstevel@tonic-gate 100*0Sstevel@tonic-gate /* Soft label keys */ 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gate #define LABMAX 16 /* max number of labels allowed */ 103*0Sstevel@tonic-gate #define LABLEN 8 /* max length of each label */ 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gate typedef struct 106*0Sstevel@tonic-gate { 107*0Sstevel@tonic-gate WINDOW *_win; /* the window to display labels */ 108*0Sstevel@tonic-gate char _ldis[LABMAX][LABLEN+1]; /* labels suitable to display */ 109*0Sstevel@tonic-gate char _lval[LABMAX][LABLEN+1]; /* labels' true values */ 110*0Sstevel@tonic-gate short _labx[LABMAX]; /* where to display labels */ 111*0Sstevel@tonic-gate short _num; /* actual number of labels */ 112*0Sstevel@tonic-gate short _len; /* real length of labels */ 113*0Sstevel@tonic-gate bool _changed; /* TRUE if some labels changed */ 114*0Sstevel@tonic-gate bool _lch[LABMAX]; /* change status */ 115*0Sstevel@tonic-gate } SLK_MAP; 116*0Sstevel@tonic-gate 117*0Sstevel@tonic-gate struct screen 118*0Sstevel@tonic-gate { 119*0Sstevel@tonic-gate unsigned fl_echoit : 1; /* in software echo mode */ 120*0Sstevel@tonic-gate unsigned fl_endwin : 2; /* has called endwin */ 121*0Sstevel@tonic-gate unsigned fl_meta : 1; /* in meta mode */ 122*0Sstevel@tonic-gate unsigned fl_nonl : 1; /* do not xlate input \r-> \n */ 123*0Sstevel@tonic-gate unsigned yesidln : 1; /* has idln capabilities */ 124*0Sstevel@tonic-gate unsigned dmode : 1; /* Terminal has delete mode */ 125*0Sstevel@tonic-gate unsigned imode : 1; /* Terminal has insert mode */ 126*0Sstevel@tonic-gate unsigned ichok : 1; /* Terminal can insert characters */ 127*0Sstevel@tonic-gate unsigned dchok : 1; /* Terminal can delete characters */ 128*0Sstevel@tonic-gate unsigned sid_equal : 1; /* enter insert and delete mode equal */ 129*0Sstevel@tonic-gate unsigned eid_equal : 1; /* exit insert and delete mode equal */ 130*0Sstevel@tonic-gate unsigned phys_irm : 1; /* in insert mode or not */ 131*0Sstevel@tonic-gate long baud; /* baud rate of this tty */ 132*0Sstevel@tonic-gate short kp_state; /* 1 iff keypad is on, else 0 */ 133*0Sstevel@tonic-gate short Yabove; /* How many lines are above stdscr */ 134*0Sstevel@tonic-gate short lsize; /* How many lines decided by newscreen */ 135*0Sstevel@tonic-gate short csize; /* How many columns decided by newscreen */ 136*0Sstevel@tonic-gate short tsize; /* How big is a tab decided by newscreen */ 137*0Sstevel@tonic-gate WINDOW *std_scr; /* primary output screen */ 138*0Sstevel@tonic-gate WINDOW *cur_scr; /* what's physically on the screen */ 139*0Sstevel@tonic-gate WINDOW *virt_scr; /* what's virtually on the screen */ 140*0Sstevel@tonic-gate int *cur_hash; /* hash table of curscr */ 141*0Sstevel@tonic-gate int *virt_hash; /* hash table of virtscr */ 142*0Sstevel@tonic-gate TERMINAL *tcap; /* TERMINFO info */ 143*0Sstevel@tonic-gate FILE *term_file; /* File to write on for output. */ 144*0Sstevel@tonic-gate FILE *input_file; /* Where to get keyboard input */ 145*0Sstevel@tonic-gate SLK_MAP *slk; /* Soft label information */ 146*0Sstevel@tonic-gate char **_mks; /* marks, only used with xhp terminals */ 147*0Sstevel@tonic-gate COSTS term_costs; /* costs of various capabilities */ 148*0Sstevel@tonic-gate SGTTY save_tty_buf; /* saved termio state of this tty */ 149*0Sstevel@tonic-gate #ifdef SYSV 150*0Sstevel@tonic-gate SGTTYS save_tty_bufs; /* saved termios state of this tty */ 151*0Sstevel@tonic-gate #endif 152*0Sstevel@tonic-gate char **_color_mks; /* marks, only used with color xhp terminals */ 153*0Sstevel@tonic-gate unsigned long _trap_mbe; /* trap these mouse button events */ 154*0Sstevel@tonic-gate unsigned long _map_mbe_to_key; /* map selected buttons on top of */ 155*0Sstevel@tonic-gate /* slk's to function keys */ 156*0Sstevel@tonic-gate }; 157*0Sstevel@tonic-gate 158*0Sstevel@tonic-gate extern SCREEN *SP; 159*0Sstevel@tonic-gate extern WINDOW *_virtscr; 160*0Sstevel@tonic-gate 161*0Sstevel@tonic-gate #ifdef DEBUG 162*0Sstevel@tonic-gate #ifndef outf 163*0Sstevel@tonic-gate extern FILE *outf; 164*0Sstevel@tonic-gate #endif /* outf */ 165*0Sstevel@tonic-gate #endif /* DEBUG */ 166*0Sstevel@tonic-gate 167*0Sstevel@tonic-gate extern short cswidth[], /* byte size of multi-byte chars */ 168*0Sstevel@tonic-gate _curs_scrwidth[]; /* display size */ 169*0Sstevel@tonic-gate extern short _csmax, 170*0Sstevel@tonic-gate _scrmax; 171*0Sstevel@tonic-gate extern bool _mbtrue; 172*0Sstevel@tonic-gate 173*0Sstevel@tonic-gate #define MBIT 0200 /* indicator for a multi-byte char */ 174*0Sstevel@tonic-gate #define CBIT 002000000000 /* indicator for a continuing col */ 175*0Sstevel@tonic-gate #define RBYTE(x) ((x) & 0377) 176*0Sstevel@tonic-gate #define LBYTE(x) (((x) >> 8) & 0177) 177*0Sstevel@tonic-gate #define ISMBIT(x) ((x) & MBIT) 178*0Sstevel@tonic-gate #define SETMBIT(x) ((x) |= MBIT) 179*0Sstevel@tonic-gate #define CLRMBIT(x) ((x) &= ~MBIT) 180*0Sstevel@tonic-gate #define ISCBIT(x) ((x) & CBIT) 181*0Sstevel@tonic-gate #define SETCBIT(x) ((x) |= CBIT) 182*0Sstevel@tonic-gate #define CLRCBIT(x) ((x) &= ~CBIT) 183*0Sstevel@tonic-gate #define TYPE(x) ((x) == SS2 ? 1 : (x) == SS3 ? 2 : ISMBIT(x) ? 0 : 3) 184*0Sstevel@tonic-gate #define TRIM 037777777777 /* 0xFFFFFFFF */ 185*0Sstevel@tonic-gate 186*0Sstevel@tonic-gate /* terminfo magic number */ 187*0Sstevel@tonic-gate #define MAGNUM 0432 188*0Sstevel@tonic-gate 189*0Sstevel@tonic-gate /* curses screen dump magic number */ 190*0Sstevel@tonic-gate #define SVR2_DUMP_MAGIC_NUMBER 0433 191*0Sstevel@tonic-gate #define SVR3_DUMP_MAGIC_NUMBER 0434 192*0Sstevel@tonic-gate 193*0Sstevel@tonic-gate /* Getting the baud rate is different on the two systems. */ 194*0Sstevel@tonic-gate 195*0Sstevel@tonic-gate #ifdef SYSV 196*0Sstevel@tonic-gate #define _BR(x) (x.c_cflag & CBAUD) 197*0Sstevel@tonic-gate #define _BRS(x) (cfgetospeed(&x)) 198*0Sstevel@tonic-gate #include <values.h> 199*0Sstevel@tonic-gate #else /* SYSV */ 200*0Sstevel@tonic-gate #define BITSPERBYTE 8 201*0Sstevel@tonic-gate #define MAXINT 32767 202*0Sstevel@tonic-gate #define _BR(x) (x.sg_ispeed) 203*0Sstevel@tonic-gate #endif /* SYSV */ 204*0Sstevel@tonic-gate 205*0Sstevel@tonic-gate #define _BLNKCHAR ' ' 206*0Sstevel@tonic-gate #define _CTRL(c) (c | 0100) 207*0Sstevel@tonic-gate #define _ATTR(c) ((c) & A_ATTRIBUTES) 208*0Sstevel@tonic-gate #define _CHAR(c) ((c) & A_CHARTEXT) 209*0Sstevel@tonic-gate 210*0Sstevel@tonic-gate /* 211*0Sstevel@tonic-gate * combine CHAR par of the character with the attributes of the window. 212*0Sstevel@tonic-gate * Two points: 1) If character is blank, usebackground instead 213*0Sstevel@tonic-gate * 2) If character contains color, delete color from 214*0Sstevel@tonic-gate * window attribute. 215*0Sstevel@tonic-gate */ 216*0Sstevel@tonic-gate 217*0Sstevel@tonic-gate #define _WCHAR(w, c) (_CHAR((c) == _BLNKCHAR ? (w)->_bkgd : (c))| \ 218*0Sstevel@tonic-gate (((c) & A_COLOR) ? ((w)->_attrs & ~A_COLOR) : \ 219*0Sstevel@tonic-gate ((w)->_attrs))) 220*0Sstevel@tonic-gate 221*0Sstevel@tonic-gate #define _DARKCHAR(c) ((c) != _BLNKCHAR) 222*0Sstevel@tonic-gate #define _UNCTRL(c) ((c) ^ 0100) 223*0Sstevel@tonic-gate 224*0Sstevel@tonic-gate /* blank lines info of curscr */ 225*0Sstevel@tonic-gate #define _BEGNS curscr->_firstch 226*0Sstevel@tonic-gate #define _ENDNS curscr->_lastch 227*0Sstevel@tonic-gate 228*0Sstevel@tonic-gate /* hash tables */ 229*0Sstevel@tonic-gate #define _CURHASH SP->cur_hash 230*0Sstevel@tonic-gate #define _VIRTHASH SP->virt_hash 231*0Sstevel@tonic-gate 232*0Sstevel@tonic-gate /* top/bot line changed */ 233*0Sstevel@tonic-gate #define _VIRTTOP _virtscr->_parx 234*0Sstevel@tonic-gate #define _VIRTBOT _virtscr->_pary 235*0Sstevel@tonic-gate 236*0Sstevel@tonic-gate /* video marks */ 237*0Sstevel@tonic-gate #define _MARKS SP->_mks 238*0Sstevel@tonic-gate #define _COLOR_MARKS SP->_color_mks 239*0Sstevel@tonic-gate 240*0Sstevel@tonic-gate #define _NUMELEMENTS(x) (sizeof (x)/sizeof (x[0])) 241*0Sstevel@tonic-gate 242*0Sstevel@tonic-gate #ifdef _VR3_COMPAT_CODE 243*0Sstevel@tonic-gate /* 244*0Sstevel@tonic-gate * #define _TO_OCHTYPE(x) ((_ochtype)(((x&A_ATTRIBUTES)>>9)| \ 245*0Sstevel@tonic-gate * (x&0x0000007FUL))) 246*0Sstevel@tonic-gate */ 247*0Sstevel@tonic-gate #define _TO_OCHTYPE(x) ((_ochtype)(((x&A_ATTRIBUTES)>>9)|(x&0177))) 248*0Sstevel@tonic-gate #define _FROM_OCHTYPE(x) ((chtype) ((x&0177) | ((x&0177600)<<9))) 249*0Sstevel@tonic-gate extern void (*_y16update)(WINDOW *, int, int, int, int); 250*0Sstevel@tonic-gate #endif /* _VR3_COMPAT_CODE */ 251*0Sstevel@tonic-gate 252*0Sstevel@tonic-gate /* functions for screen updates */ 253*0Sstevel@tonic-gate 254*0Sstevel@tonic-gate extern int (*_setidln)(void); 255*0Sstevel@tonic-gate extern int (*_useidln)(void); 256*0Sstevel@tonic-gate extern int (*_quick_ptr)(WINDOW *, chtype); 257*0Sstevel@tonic-gate extern int (_quick_echo)(WINDOW *, chtype); 258*0Sstevel@tonic-gate 259*0Sstevel@tonic-gate /* min/max functions */ 260*0Sstevel@tonic-gate 261*0Sstevel@tonic-gate #define _MIN(a, b) ((a) < (b) ? (a) : (b)) 262*0Sstevel@tonic-gate #define _MAX(a, b) ((a) > (b) ? (a) : (b)) 263*0Sstevel@tonic-gate 264*0Sstevel@tonic-gate extern int (*_do_slk_ref)(void); 265*0Sstevel@tonic-gate extern int (*_do_slk_tch)(void); 266*0Sstevel@tonic-gate extern int (*_do_slk_noref)(void); 267*0Sstevel@tonic-gate extern int _image(WINDOW *); 268*0Sstevel@tonic-gate extern int _outch(char); 269*0Sstevel@tonic-gate extern int _outwch(chtype); 270*0Sstevel@tonic-gate extern int _chkinput(void); 271*0Sstevel@tonic-gate extern int _curs_mbtowc(wchar_t *, const char *, size_t); 272*0Sstevel@tonic-gate extern int _curs_wctomb(char *, wchar_t); 273*0Sstevel@tonic-gate extern int _delay(int, int (*)(char)); 274*0Sstevel@tonic-gate extern int _mbaddch(WINDOW *, chtype, chtype); 275*0Sstevel@tonic-gate extern int _mbclrch(WINDOW *, int, int); 276*0Sstevel@tonic-gate extern int _mbinsshift(WINDOW *, int), _mbvalid(WINDOW *); 277*0Sstevel@tonic-gate extern int _padjust(WINDOW *, int, int, int, int, int, int); 278*0Sstevel@tonic-gate extern int _prefresh(int (*)(WINDOW *), WINDOW *, int, int, int, 279*0Sstevel@tonic-gate int, int, int); 280*0Sstevel@tonic-gate extern int _overlap(WINDOW *, WINDOW *, int); 281*0Sstevel@tonic-gate extern int _scr_all(char *, int); 282*0Sstevel@tonic-gate extern int _slk_update(void); 283*0Sstevel@tonic-gate extern int _tcsearch(char *, short [], char *[], int, int); 284*0Sstevel@tonic-gate extern int _vsscanf(char *, char *, __va_list); 285*0Sstevel@tonic-gate extern int force_doupdate(void); 286*0Sstevel@tonic-gate extern int init_acs(void); 287*0Sstevel@tonic-gate extern int mbscrw(int); 288*0Sstevel@tonic-gate extern int mbeucw(int); 289*0Sstevel@tonic-gate extern int scr_ll_dump(FILE *); 290*0Sstevel@tonic-gate extern int scr_reset(FILE *, int); 291*0Sstevel@tonic-gate extern int setkeymap(void); 292*0Sstevel@tonic-gate extern int ttimeout(int); 293*0Sstevel@tonic-gate extern int wadjcurspos(WINDOW *); 294*0Sstevel@tonic-gate extern int wcscrw(wchar_t); 295*0Sstevel@tonic-gate extern int wmbmove(WINDOW *, int, int); 296*0Sstevel@tonic-gate 297*0Sstevel@tonic-gate extern chtype tgetch(int); 298*0Sstevel@tonic-gate 299*0Sstevel@tonic-gate extern WINDOW *_makenew(int, int, int, int); 300*0Sstevel@tonic-gate 301*0Sstevel@tonic-gate extern void (*_slk_init)(void); 302*0Sstevel@tonic-gate extern void (*_rip_init)(void); 303*0Sstevel@tonic-gate extern void delkeymap(TERMINAL *); 304*0Sstevel@tonic-gate extern void mbgetwidth(void); 305*0Sstevel@tonic-gate extern void memSset(chtype *, chtype, int); 306*0Sstevel@tonic-gate extern void _blast_keys(TERMINAL *); 307*0Sstevel@tonic-gate extern void _init_costs(void); 308*0Sstevel@tonic-gate extern void _init_HP_pair(short, short, short); 309*0Sstevel@tonic-gate extern void _update_old_y_area(WINDOW *, int, int, int, int); 310*0Sstevel@tonic-gate 311*0Sstevel@tonic-gate extern char *tparm_p0(char *); 312*0Sstevel@tonic-gate extern char *tparm_p1(char *, long); 313*0Sstevel@tonic-gate extern char *tparm_p2(char *, long, long); 314*0Sstevel@tonic-gate extern char *tparm_p3(char *, long, long, long); 315*0Sstevel@tonic-gate extern char *tparm_p4(char *, long, long, long, long); 316*0Sstevel@tonic-gate extern char *tparm_p7(char *, long, long, long, long, long, long, long); 317*0Sstevel@tonic-gate 318*0Sstevel@tonic-gate 319*0Sstevel@tonic-gate extern char *infotocap(char *, int *); 320*0Sstevel@tonic-gate extern char *_strcode2byte(wchar_t *, char *, int); 321*0Sstevel@tonic-gate extern char *wmbinch(WINDOW *, int, int); 322*0Sstevel@tonic-gate 323*0Sstevel@tonic-gate #ifdef __cplusplus 324*0Sstevel@tonic-gate } 325*0Sstevel@tonic-gate #endif 326*0Sstevel@tonic-gate 327*0Sstevel@tonic-gate #endif /* _CURSHDR_H */ 328