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