10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 22*1219Sraf 230Sstevel@tonic-gate /* 24*1219Sraf * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 250Sstevel@tonic-gate * Use is subject to license terms. 260Sstevel@tonic-gate */ 270Sstevel@tonic-gate 280Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */ 290Sstevel@tonic-gate /* All Rights Reserved */ 300Sstevel@tonic-gate 310Sstevel@tonic-gate /* 320Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 330Sstevel@tonic-gate * The Regents of the University of California 340Sstevel@tonic-gate * All Rights Reserved 350Sstevel@tonic-gate * 360Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 370Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 380Sstevel@tonic-gate * contributors. 390Sstevel@tonic-gate */ 400Sstevel@tonic-gate 410Sstevel@tonic-gate #ifndef _CURSHDR_H 420Sstevel@tonic-gate #define _CURSHDR_H 430Sstevel@tonic-gate 440Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 450Sstevel@tonic-gate 460Sstevel@tonic-gate #ifdef __cplusplus 470Sstevel@tonic-gate extern "C" { 480Sstevel@tonic-gate #endif 490Sstevel@tonic-gate 500Sstevel@tonic-gate #define _NOHASH (-1) /* if the hash value is unknown */ 510Sstevel@tonic-gate #define _REDRAW (-2) /* if line need redrawn */ 520Sstevel@tonic-gate #define _BLANK (-3) /* if line is blank */ 530Sstevel@tonic-gate #define _THASH (123) /* base hash if clash with other hashes */ 540Sstevel@tonic-gate #define _KEY (01) 550Sstevel@tonic-gate #define _MACRO (02) 560Sstevel@tonic-gate 570Sstevel@tonic-gate #define _INPUTPENDING cur_term->_iwait 580Sstevel@tonic-gate #define _PUTS(x, y) (void) tputs(x, y, _outch) 590Sstevel@tonic-gate #define _VIDS(na, oa) (vidupdate((na), (oa), _outch), curscr->_attrs = (na)) 600Sstevel@tonic-gate #define _ONINSERT() (_PUTS(enter_insert_mode, 1), SP->phys_irm = TRUE) 610Sstevel@tonic-gate #define _OFFINSERT() (_PUTS(exit_insert_mode, 1), SP->phys_irm = FALSE) 620Sstevel@tonic-gate #define _STRNOTEQ(a, b) (a == NULL ? (b != NULL) : \ 630Sstevel@tonic-gate (b == NULL ? 1 : strcmp(a, b))) 640Sstevel@tonic-gate 650Sstevel@tonic-gate /* 660Sstevel@tonic-gate * IC and IL overheads and costs should be set to this 670Sstevel@tonic-gate * value if the corresponding feature is missing 680Sstevel@tonic-gate */ 690Sstevel@tonic-gate 700Sstevel@tonic-gate #define LARGECOST 500 710Sstevel@tonic-gate 720Sstevel@tonic-gate typedef struct 730Sstevel@tonic-gate { 740Sstevel@tonic-gate short icfixed; /* Insert char fixed overhead */ 750Sstevel@tonic-gate short dcfixed; /* Delete char fixed overhead */ 760Sstevel@tonic-gate short Insert_character; 770Sstevel@tonic-gate short Delete_character; 780Sstevel@tonic-gate short Cursor_home; 790Sstevel@tonic-gate short Cursor_to_ll; 800Sstevel@tonic-gate short Cursor_left; 810Sstevel@tonic-gate short Cursor_right; 820Sstevel@tonic-gate short Cursor_down; 830Sstevel@tonic-gate short Cursor_up; 840Sstevel@tonic-gate short Carriage_return; 850Sstevel@tonic-gate short Tab; 860Sstevel@tonic-gate short Back_tab; 870Sstevel@tonic-gate short Clr_eol; 880Sstevel@tonic-gate short Clr_bol; 890Sstevel@tonic-gate short Parm_ich; 900Sstevel@tonic-gate short Parm_dch; 910Sstevel@tonic-gate short Parm_left_cursor; 920Sstevel@tonic-gate short Parm_up_cursor; 930Sstevel@tonic-gate short Parm_down_cursor; 940Sstevel@tonic-gate short Parm_right_cursor; 950Sstevel@tonic-gate short Cursor_address; 960Sstevel@tonic-gate short Row_address; 970Sstevel@tonic-gate } COSTS; 980Sstevel@tonic-gate 990Sstevel@tonic-gate #define _COST(field) (SP->term_costs.field) 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate /* Soft label keys */ 1020Sstevel@tonic-gate 1030Sstevel@tonic-gate #define LABMAX 16 /* max number of labels allowed */ 1040Sstevel@tonic-gate #define LABLEN 8 /* max length of each label */ 1050Sstevel@tonic-gate 1060Sstevel@tonic-gate typedef struct 1070Sstevel@tonic-gate { 1080Sstevel@tonic-gate WINDOW *_win; /* the window to display labels */ 1090Sstevel@tonic-gate char _ldis[LABMAX][LABLEN+1]; /* labels suitable to display */ 1100Sstevel@tonic-gate char _lval[LABMAX][LABLEN+1]; /* labels' true values */ 1110Sstevel@tonic-gate short _labx[LABMAX]; /* where to display labels */ 1120Sstevel@tonic-gate short _num; /* actual number of labels */ 1130Sstevel@tonic-gate short _len; /* real length of labels */ 1140Sstevel@tonic-gate bool _changed; /* TRUE if some labels changed */ 1150Sstevel@tonic-gate bool _lch[LABMAX]; /* change status */ 1160Sstevel@tonic-gate } SLK_MAP; 1170Sstevel@tonic-gate 1180Sstevel@tonic-gate struct screen 1190Sstevel@tonic-gate { 1200Sstevel@tonic-gate unsigned fl_echoit : 1; /* in software echo mode */ 1210Sstevel@tonic-gate unsigned fl_endwin : 2; /* has called endwin */ 1220Sstevel@tonic-gate unsigned fl_meta : 1; /* in meta mode */ 1230Sstevel@tonic-gate unsigned fl_nonl : 1; /* do not xlate input \r-> \n */ 1240Sstevel@tonic-gate unsigned yesidln : 1; /* has idln capabilities */ 1250Sstevel@tonic-gate unsigned dmode : 1; /* Terminal has delete mode */ 1260Sstevel@tonic-gate unsigned imode : 1; /* Terminal has insert mode */ 1270Sstevel@tonic-gate unsigned ichok : 1; /* Terminal can insert characters */ 1280Sstevel@tonic-gate unsigned dchok : 1; /* Terminal can delete characters */ 1290Sstevel@tonic-gate unsigned sid_equal : 1; /* enter insert and delete mode equal */ 1300Sstevel@tonic-gate unsigned eid_equal : 1; /* exit insert and delete mode equal */ 1310Sstevel@tonic-gate unsigned phys_irm : 1; /* in insert mode or not */ 1320Sstevel@tonic-gate long baud; /* baud rate of this tty */ 1330Sstevel@tonic-gate short kp_state; /* 1 iff keypad is on, else 0 */ 1340Sstevel@tonic-gate short Yabove; /* How many lines are above stdscr */ 1350Sstevel@tonic-gate short lsize; /* How many lines decided by newscreen */ 1360Sstevel@tonic-gate short csize; /* How many columns decided by newscreen */ 1370Sstevel@tonic-gate short tsize; /* How big is a tab decided by newscreen */ 1380Sstevel@tonic-gate WINDOW *std_scr; /* primary output screen */ 1390Sstevel@tonic-gate WINDOW *cur_scr; /* what's physically on the screen */ 1400Sstevel@tonic-gate WINDOW *virt_scr; /* what's virtually on the screen */ 1410Sstevel@tonic-gate int *cur_hash; /* hash table of curscr */ 1420Sstevel@tonic-gate int *virt_hash; /* hash table of virtscr */ 1430Sstevel@tonic-gate TERMINAL *tcap; /* TERMINFO info */ 1440Sstevel@tonic-gate FILE *term_file; /* File to write on for output. */ 1450Sstevel@tonic-gate FILE *input_file; /* Where to get keyboard input */ 1460Sstevel@tonic-gate SLK_MAP *slk; /* Soft label information */ 1470Sstevel@tonic-gate char **_mks; /* marks, only used with xhp terminals */ 1480Sstevel@tonic-gate COSTS term_costs; /* costs of various capabilities */ 1490Sstevel@tonic-gate SGTTY save_tty_buf; /* saved termio state of this tty */ 1500Sstevel@tonic-gate #ifdef SYSV 1510Sstevel@tonic-gate SGTTYS save_tty_bufs; /* saved termios state of this tty */ 1520Sstevel@tonic-gate #endif 1530Sstevel@tonic-gate char **_color_mks; /* marks, only used with color xhp terminals */ 1540Sstevel@tonic-gate unsigned long _trap_mbe; /* trap these mouse button events */ 1550Sstevel@tonic-gate unsigned long _map_mbe_to_key; /* map selected buttons on top of */ 1560Sstevel@tonic-gate /* slk's to function keys */ 1570Sstevel@tonic-gate }; 1580Sstevel@tonic-gate 1590Sstevel@tonic-gate extern SCREEN *SP; 1600Sstevel@tonic-gate extern WINDOW *_virtscr; 1610Sstevel@tonic-gate 1620Sstevel@tonic-gate #ifdef DEBUG 1630Sstevel@tonic-gate #ifndef outf 1640Sstevel@tonic-gate extern FILE *outf; 1650Sstevel@tonic-gate #endif /* outf */ 1660Sstevel@tonic-gate #endif /* DEBUG */ 1670Sstevel@tonic-gate 1680Sstevel@tonic-gate extern short cswidth[], /* byte size of multi-byte chars */ 1690Sstevel@tonic-gate _curs_scrwidth[]; /* display size */ 1700Sstevel@tonic-gate extern short _csmax, 1710Sstevel@tonic-gate _scrmax; 1720Sstevel@tonic-gate extern bool _mbtrue; 1730Sstevel@tonic-gate 1740Sstevel@tonic-gate #define MBIT 0200 /* indicator for a multi-byte char */ 1750Sstevel@tonic-gate #define CBIT 002000000000 /* indicator for a continuing col */ 1760Sstevel@tonic-gate #define RBYTE(x) ((x) & 0377) 1770Sstevel@tonic-gate #define LBYTE(x) (((x) >> 8) & 0177) 1780Sstevel@tonic-gate #define ISMBIT(x) ((x) & MBIT) 1790Sstevel@tonic-gate #define SETMBIT(x) ((x) |= MBIT) 1800Sstevel@tonic-gate #define CLRMBIT(x) ((x) &= ~MBIT) 1810Sstevel@tonic-gate #define ISCBIT(x) ((x) & CBIT) 1820Sstevel@tonic-gate #define SETCBIT(x) ((x) |= CBIT) 1830Sstevel@tonic-gate #define CLRCBIT(x) ((x) &= ~CBIT) 1840Sstevel@tonic-gate #define TYPE(x) ((x) == SS2 ? 1 : (x) == SS3 ? 2 : ISMBIT(x) ? 0 : 3) 1850Sstevel@tonic-gate #define TRIM 037777777777 /* 0xFFFFFFFF */ 1860Sstevel@tonic-gate 1870Sstevel@tonic-gate /* terminfo magic number */ 1880Sstevel@tonic-gate #define MAGNUM 0432 1890Sstevel@tonic-gate 1900Sstevel@tonic-gate /* curses screen dump magic number */ 1910Sstevel@tonic-gate #define SVR2_DUMP_MAGIC_NUMBER 0433 1920Sstevel@tonic-gate #define SVR3_DUMP_MAGIC_NUMBER 0434 1930Sstevel@tonic-gate 1940Sstevel@tonic-gate /* Getting the baud rate is different on the two systems. */ 1950Sstevel@tonic-gate 1960Sstevel@tonic-gate #ifdef SYSV 1970Sstevel@tonic-gate #define _BR(x) (x.c_cflag & CBAUD) 1980Sstevel@tonic-gate #define _BRS(x) (cfgetospeed(&x)) 1990Sstevel@tonic-gate #include <values.h> 2000Sstevel@tonic-gate #else /* SYSV */ 2010Sstevel@tonic-gate #define BITSPERBYTE 8 2020Sstevel@tonic-gate #define MAXINT 32767 2030Sstevel@tonic-gate #define _BR(x) (x.sg_ispeed) 2040Sstevel@tonic-gate #endif /* SYSV */ 2050Sstevel@tonic-gate 2060Sstevel@tonic-gate #define _BLNKCHAR ' ' 2070Sstevel@tonic-gate #define _CTRL(c) (c | 0100) 2080Sstevel@tonic-gate #define _ATTR(c) ((c) & A_ATTRIBUTES) 2090Sstevel@tonic-gate #define _CHAR(c) ((c) & A_CHARTEXT) 2100Sstevel@tonic-gate 2110Sstevel@tonic-gate /* 2120Sstevel@tonic-gate * combine CHAR par of the character with the attributes of the window. 2130Sstevel@tonic-gate * Two points: 1) If character is blank, usebackground instead 2140Sstevel@tonic-gate * 2) If character contains color, delete color from 2150Sstevel@tonic-gate * window attribute. 2160Sstevel@tonic-gate */ 2170Sstevel@tonic-gate 2180Sstevel@tonic-gate #define _WCHAR(w, c) (_CHAR((c) == _BLNKCHAR ? (w)->_bkgd : (c))| \ 2190Sstevel@tonic-gate (((c) & A_COLOR) ? ((w)->_attrs & ~A_COLOR) : \ 2200Sstevel@tonic-gate ((w)->_attrs))) 2210Sstevel@tonic-gate 2220Sstevel@tonic-gate #define _DARKCHAR(c) ((c) != _BLNKCHAR) 2230Sstevel@tonic-gate #define _UNCTRL(c) ((c) ^ 0100) 2240Sstevel@tonic-gate 2250Sstevel@tonic-gate /* blank lines info of curscr */ 2260Sstevel@tonic-gate #define _BEGNS curscr->_firstch 2270Sstevel@tonic-gate #define _ENDNS curscr->_lastch 2280Sstevel@tonic-gate 2290Sstevel@tonic-gate /* hash tables */ 2300Sstevel@tonic-gate #define _CURHASH SP->cur_hash 2310Sstevel@tonic-gate #define _VIRTHASH SP->virt_hash 2320Sstevel@tonic-gate 2330Sstevel@tonic-gate /* top/bot line changed */ 2340Sstevel@tonic-gate #define _VIRTTOP _virtscr->_parx 2350Sstevel@tonic-gate #define _VIRTBOT _virtscr->_pary 2360Sstevel@tonic-gate 2370Sstevel@tonic-gate /* video marks */ 2380Sstevel@tonic-gate #define _MARKS SP->_mks 2390Sstevel@tonic-gate #define _COLOR_MARKS SP->_color_mks 2400Sstevel@tonic-gate 2410Sstevel@tonic-gate #define _NUMELEMENTS(x) (sizeof (x)/sizeof (x[0])) 2420Sstevel@tonic-gate 2430Sstevel@tonic-gate #ifdef _VR3_COMPAT_CODE 2440Sstevel@tonic-gate /* 2450Sstevel@tonic-gate * #define _TO_OCHTYPE(x) ((_ochtype)(((x&A_ATTRIBUTES)>>9)| \ 2460Sstevel@tonic-gate * (x&0x0000007FUL))) 2470Sstevel@tonic-gate */ 2480Sstevel@tonic-gate #define _TO_OCHTYPE(x) ((_ochtype)(((x&A_ATTRIBUTES)>>9)|(x&0177))) 2490Sstevel@tonic-gate #define _FROM_OCHTYPE(x) ((chtype) ((x&0177) | ((x&0177600)<<9))) 2500Sstevel@tonic-gate extern void (*_y16update)(WINDOW *, int, int, int, int); 2510Sstevel@tonic-gate #endif /* _VR3_COMPAT_CODE */ 2520Sstevel@tonic-gate 2530Sstevel@tonic-gate /* functions for screen updates */ 2540Sstevel@tonic-gate 2550Sstevel@tonic-gate extern int (*_setidln)(void); 2560Sstevel@tonic-gate extern int (*_useidln)(void); 2570Sstevel@tonic-gate extern int (*_quick_ptr)(WINDOW *, chtype); 2580Sstevel@tonic-gate extern int (_quick_echo)(WINDOW *, chtype); 2590Sstevel@tonic-gate 2600Sstevel@tonic-gate /* min/max functions */ 2610Sstevel@tonic-gate 2620Sstevel@tonic-gate #define _MIN(a, b) ((a) < (b) ? (a) : (b)) 2630Sstevel@tonic-gate #define _MAX(a, b) ((a) > (b) ? (a) : (b)) 2640Sstevel@tonic-gate 2650Sstevel@tonic-gate extern int (*_do_slk_ref)(void); 2660Sstevel@tonic-gate extern int (*_do_slk_tch)(void); 2670Sstevel@tonic-gate extern int (*_do_slk_noref)(void); 2680Sstevel@tonic-gate extern int _image(WINDOW *); 2690Sstevel@tonic-gate extern int _outch(char); 2700Sstevel@tonic-gate extern int _outwch(chtype); 2710Sstevel@tonic-gate extern int _chkinput(void); 2720Sstevel@tonic-gate extern int _curs_mbtowc(wchar_t *, const char *, size_t); 2730Sstevel@tonic-gate extern int _curs_wctomb(char *, wchar_t); 2740Sstevel@tonic-gate extern int _delay(int, int (*)(char)); 2750Sstevel@tonic-gate extern int _mbaddch(WINDOW *, chtype, chtype); 2760Sstevel@tonic-gate extern int _mbclrch(WINDOW *, int, int); 2770Sstevel@tonic-gate extern int _mbinsshift(WINDOW *, int), _mbvalid(WINDOW *); 2780Sstevel@tonic-gate extern int _padjust(WINDOW *, int, int, int, int, int, int); 2790Sstevel@tonic-gate extern int _prefresh(int (*)(WINDOW *), WINDOW *, int, int, int, 2800Sstevel@tonic-gate int, int, int); 2810Sstevel@tonic-gate extern int _overlap(WINDOW *, WINDOW *, int); 2820Sstevel@tonic-gate extern int _scr_all(char *, int); 2830Sstevel@tonic-gate extern int _slk_update(void); 2840Sstevel@tonic-gate extern int _tcsearch(char *, short [], char *[], int, int); 285*1219Sraf extern int _vsscanf(const char *, const char *, __va_list); 2860Sstevel@tonic-gate extern int force_doupdate(void); 2870Sstevel@tonic-gate extern int init_acs(void); 2880Sstevel@tonic-gate extern int mbscrw(int); 2890Sstevel@tonic-gate extern int mbeucw(int); 2900Sstevel@tonic-gate extern int scr_ll_dump(FILE *); 2910Sstevel@tonic-gate extern int scr_reset(FILE *, int); 2920Sstevel@tonic-gate extern int setkeymap(void); 2930Sstevel@tonic-gate extern int ttimeout(int); 2940Sstevel@tonic-gate extern int wadjcurspos(WINDOW *); 2950Sstevel@tonic-gate extern int wcscrw(wchar_t); 2960Sstevel@tonic-gate extern int wmbmove(WINDOW *, int, int); 2970Sstevel@tonic-gate 2980Sstevel@tonic-gate extern chtype tgetch(int); 2990Sstevel@tonic-gate 3000Sstevel@tonic-gate extern WINDOW *_makenew(int, int, int, int); 3010Sstevel@tonic-gate 3020Sstevel@tonic-gate extern void (*_slk_init)(void); 3030Sstevel@tonic-gate extern void (*_rip_init)(void); 3040Sstevel@tonic-gate extern void delkeymap(TERMINAL *); 3050Sstevel@tonic-gate extern void mbgetwidth(void); 3060Sstevel@tonic-gate extern void memSset(chtype *, chtype, int); 3070Sstevel@tonic-gate extern void _blast_keys(TERMINAL *); 3080Sstevel@tonic-gate extern void _init_costs(void); 3090Sstevel@tonic-gate extern void _init_HP_pair(short, short, short); 3100Sstevel@tonic-gate extern void _update_old_y_area(WINDOW *, int, int, int, int); 3110Sstevel@tonic-gate 3120Sstevel@tonic-gate extern char *tparm_p0(char *); 3130Sstevel@tonic-gate extern char *tparm_p1(char *, long); 3140Sstevel@tonic-gate extern char *tparm_p2(char *, long, long); 3150Sstevel@tonic-gate extern char *tparm_p3(char *, long, long, long); 3160Sstevel@tonic-gate extern char *tparm_p4(char *, long, long, long, long); 3170Sstevel@tonic-gate extern char *tparm_p7(char *, long, long, long, long, long, long, long); 3180Sstevel@tonic-gate 3190Sstevel@tonic-gate 3200Sstevel@tonic-gate extern char *infotocap(char *, int *); 3210Sstevel@tonic-gate extern char *_strcode2byte(wchar_t *, char *, int); 3220Sstevel@tonic-gate extern char *wmbinch(WINDOW *, int, int); 3230Sstevel@tonic-gate 3240Sstevel@tonic-gate #ifdef __cplusplus 3250Sstevel@tonic-gate } 3260Sstevel@tonic-gate #endif 3270Sstevel@tonic-gate 3280Sstevel@tonic-gate #endif /* _CURSHDR_H */ 329