1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright (c) 1996-1999 by Sun Microsystems, Inc. 24*7c478bd9Sstevel@tonic-gate * All rights reserved. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* 28*7c478bd9Sstevel@tonic-gate * private.h 29*7c478bd9Sstevel@tonic-gate * 30*7c478bd9Sstevel@tonic-gate * XCurses Library 31*7c478bd9Sstevel@tonic-gate * 32*7c478bd9Sstevel@tonic-gate * Copyright 1990, 1995 by Mortice Kern Systems Inc. All rights reserved. 33*7c478bd9Sstevel@tonic-gate * 34*7c478bd9Sstevel@tonic-gate */ 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h> 37*7c478bd9Sstevel@tonic-gate #include <mks.h> 38*7c478bd9Sstevel@tonic-gate #include <curses.h> 39*7c478bd9Sstevel@tonic-gate #include <termios.h> 40*7c478bd9Sstevel@tonic-gate #include <unctrl.h> 41*7c478bd9Sstevel@tonic-gate 42*7c478bd9Sstevel@tonic-gate #define M_TERM_NAME "unknown" 43*7c478bd9Sstevel@tonic-gate 44*7c478bd9Sstevel@tonic-gate /* 45*7c478bd9Sstevel@tonic-gate * Interbyte timer value used for processing multibyte function keys. 46*7c478bd9Sstevel@tonic-gate */ 47*7c478bd9Sstevel@tonic-gate #ifndef M_CURSES_INTERBYTE_TIME 48*7c478bd9Sstevel@tonic-gate #define M_CURSES_INTERBYTE_TIME 10 49*7c478bd9Sstevel@tonic-gate #endif 50*7c478bd9Sstevel@tonic-gate 51*7c478bd9Sstevel@tonic-gate /* 52*7c478bd9Sstevel@tonic-gate * Maximum number of lines that can be ripped off. 53*7c478bd9Sstevel@tonic-gate */ 54*7c478bd9Sstevel@tonic-gate #ifndef M_CURSES_MAX_RIPOFFLINE 55*7c478bd9Sstevel@tonic-gate #define M_CURSES_MAX_RIPOFFLINE 5 56*7c478bd9Sstevel@tonic-gate #endif 57*7c478bd9Sstevel@tonic-gate 58*7c478bd9Sstevel@tonic-gate /* 59*7c478bd9Sstevel@tonic-gate * See copywin() and wrefresh() case 4. It is unclear whether XPG4 V2 60*7c478bd9Sstevel@tonic-gate * disallows supporting case 4 (expanding characters straddling a window 61*7c478bd9Sstevel@tonic-gate * boundary). 62*7c478bd9Sstevel@tonic-gate */ 63*7c478bd9Sstevel@tonic-gate #define M_CURSES_SENSIBLE_WINDOWS 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate /* 66*7c478bd9Sstevel@tonic-gate * Enable typeahead() support. 67*7c478bd9Sstevel@tonic-gate */ 68*7c478bd9Sstevel@tonic-gate /* using unget buffer as typeahead buffer too */ 69*7c478bd9Sstevel@tonic-gate #define M_TYPEAHEAD_SIZE 200 70*7c478bd9Sstevel@tonic-gate 71*7c478bd9Sstevel@tonic-gate /* 72*7c478bd9Sstevel@tonic-gate * END OF CONFIGURABLE SECTION 73*7c478bd9Sstevel@tonic-gate */ 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gate /* 76*7c478bd9Sstevel@tonic-gate * Constant WINDOW definition attributes. 77*7c478bd9Sstevel@tonic-gate */ 78*7c478bd9Sstevel@tonic-gate #define W_IS_PAD 0x0001 /* Window is a pad. */ 79*7c478bd9Sstevel@tonic-gate #define W_END_LINE 0x0002 /* End of line is the margin. */ 80*7c478bd9Sstevel@tonic-gate #define W_FULL_LINE 0x0004 /* Line spans screen width. */ 81*7c478bd9Sstevel@tonic-gate #define W_FULL_WINDOW 0x0008 /* Window is full screen. */ 82*7c478bd9Sstevel@tonic-gate #define W_SCROLL_WINDOW 0x0010 /* Touches bottom-right corner */ 83*7c478bd9Sstevel@tonic-gate 84*7c478bd9Sstevel@tonic-gate /* 85*7c478bd9Sstevel@tonic-gate * WINDOW state. 86*7c478bd9Sstevel@tonic-gate */ 87*7c478bd9Sstevel@tonic-gate #define W_CLEAR_WINDOW 0x0020 /* clearok() clear screen next update. */ 88*7c478bd9Sstevel@tonic-gate #define W_REDRAW_WINDOW 0x0040 /* wredrawln() use simple() next update. */ 89*7c478bd9Sstevel@tonic-gate 90*7c478bd9Sstevel@tonic-gate /* 91*7c478bd9Sstevel@tonic-gate * Configurable WINDOW options. 92*7c478bd9Sstevel@tonic-gate */ 93*7c478bd9Sstevel@tonic-gate #define W_FLUSH 0x0080 /* immedok() update when window changes. */ 94*7c478bd9Sstevel@tonic-gate #define W_CAN_SCROLL 0x0100 /* scrollok() window can software scroll. */ 95*7c478bd9Sstevel@tonic-gate #define W_LEAVE_CURSOR 0x0200 /* leaveok() don't fuss with the cursor. */ 96*7c478bd9Sstevel@tonic-gate #define W_SYNC_UP 0x0400 /* syncok() update ancestors when changed. */ 97*7c478bd9Sstevel@tonic-gate #define W_USE_KEYPAD 0x0800 /* keypad() enbles KEY_ processing. */ 98*7c478bd9Sstevel@tonic-gate #define W_USE_TIMEOUT 0x1000 /* notimeout() disables the interbyte timer. */ 99*7c478bd9Sstevel@tonic-gate #define W_CONFIG_MASK 0x1f80 /* Mask of configurable flags. */ 100*7c478bd9Sstevel@tonic-gate 101*7c478bd9Sstevel@tonic-gate /* 102*7c478bd9Sstevel@tonic-gate * Flags used in SCREEN. 103*7c478bd9Sstevel@tonic-gate */ 104*7c478bd9Sstevel@tonic-gate #define S_ECHO 0x0001 /* Software echo enbled. */ 105*7c478bd9Sstevel@tonic-gate #define S_ENDWIN 0x0002 /* Curses is in "shell" mode. */ 106*7c478bd9Sstevel@tonic-gate #define S_INS_DEL_CHAR 0x0004 /* idcok() enabled for terminal (future). */ 107*7c478bd9Sstevel@tonic-gate #define S_INS_DEL_LINE 0x0008 /* idlok() enabled for terminal. */ 108*7c478bd9Sstevel@tonic-gate #define S_ISATTY 0x0010 /* _kfd is a terminal. */ 109*7c478bd9Sstevel@tonic-gate #define S_USE_META 0x0020 /* meta() enabled. */ 110*7c478bd9Sstevel@tonic-gate #define S_TYPEAHEAD_OK 0x0040 /* typeahead flag */ 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate typedef struct t_decode { 113*7c478bd9Sstevel@tonic-gate struct t_decode *sibling; 114*7c478bd9Sstevel@tonic-gate struct t_decode *child; 115*7c478bd9Sstevel@tonic-gate short key; /* KEY_ value or 0. */ 116*7c478bd9Sstevel@tonic-gate int ch; /* Character found by this node. */ 117*7c478bd9Sstevel@tonic-gate } t_decode; 118*7c478bd9Sstevel@tonic-gate 119*7c478bd9Sstevel@tonic-gate typedef struct { 120*7c478bd9Sstevel@tonic-gate int top; /* # of lines off the top. */ 121*7c478bd9Sstevel@tonic-gate int bottom; /* # of lines off the bottom (-ve). */ 122*7c478bd9Sstevel@tonic-gate struct { 123*7c478bd9Sstevel@tonic-gate int dy; /* Distance from screen top/bottom. */ 124*7c478bd9Sstevel@tonic-gate int (*init)(WINDOW *, int); /* Init. function for window. */ 125*7c478bd9Sstevel@tonic-gate int created; 126*7c478bd9Sstevel@tonic-gate } line[M_CURSES_MAX_RIPOFFLINE]; 127*7c478bd9Sstevel@tonic-gate } t_rip; 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate extern SCREEN *__m_screen; 130*7c478bd9Sstevel@tonic-gate extern int __m_slk_format; 131*7c478bd9Sstevel@tonic-gate extern int __m_slk_labels_on; 132*7c478bd9Sstevel@tonic-gate extern const short __m_keyindex[][2]; 133*7c478bd9Sstevel@tonic-gate 134*7c478bd9Sstevel@tonic-gate extern const char *boolnames[]; 135*7c478bd9Sstevel@tonic-gate extern const char *boolcodes[]; 136*7c478bd9Sstevel@tonic-gate extern const char *boolfnames[]; 137*7c478bd9Sstevel@tonic-gate extern const char *numnames[]; 138*7c478bd9Sstevel@tonic-gate extern const char *numcodes[]; 139*7c478bd9Sstevel@tonic-gate extern const char *numfnames[]; 140*7c478bd9Sstevel@tonic-gate extern const char *strnames[]; 141*7c478bd9Sstevel@tonic-gate extern const char *strcodes[]; 142*7c478bd9Sstevel@tonic-gate extern const char *strfnames[]; 143*7c478bd9Sstevel@tonic-gate 144*7c478bd9Sstevel@tonic-gate #define ATTR_STATE cur_term->_at 145*7c478bd9Sstevel@tonic-gate 146*7c478bd9Sstevel@tonic-gate #define PTERMIOS(x) ((struct termios *)(cur_term->x)) 147*7c478bd9Sstevel@tonic-gate 148*7c478bd9Sstevel@tonic-gate #define __m_cc_width(cc) wcwidth((cc)->_wc[0]) 149*7c478bd9Sstevel@tonic-gate 150*7c478bd9Sstevel@tonic-gate #define TPUTS(a, b, c) tputs(a, b, c) 151*7c478bd9Sstevel@tonic-gate 152*7c478bd9Sstevel@tonic-gate extern int __m_wc_cc(wint_t, cchar_t *); 153*7c478bd9Sstevel@tonic-gate extern int __m_mbs_cc(const char *, attr_t, short, cchar_t *); 154*7c478bd9Sstevel@tonic-gate extern int __m_wcs_cc(const wchar_t *, attr_t, short, cchar_t *); 155*7c478bd9Sstevel@tonic-gate extern int __m_acs_cc(chtype, cchar_t *); 156*7c478bd9Sstevel@tonic-gate extern int __m_wacs_cc(const cchar_t *, cchar_t *); 157*7c478bd9Sstevel@tonic-gate extern int __m_cc_mbs(const cchar_t *, char *, int); 158*7c478bd9Sstevel@tonic-gate 159*7c478bd9Sstevel@tonic-gate extern int __m_cc_sort(cchar_t *); 160*7c478bd9Sstevel@tonic-gate extern int __m_cc_write(const cchar_t *); 161*7c478bd9Sstevel@tonic-gate extern int __m_cc_first(WINDOW *, int, int); 162*7c478bd9Sstevel@tonic-gate extern int __m_cc_next(WINDOW *, int, int); 163*7c478bd9Sstevel@tonic-gate extern int __m_cc_islast(WINDOW *, int, int); 164*7c478bd9Sstevel@tonic-gate extern int __m_cc_expand(WINDOW *, int, int, int); 165*7c478bd9Sstevel@tonic-gate extern int __m_cc_erase(WINDOW *, int, int, int, int); 166*7c478bd9Sstevel@tonic-gate extern int __m_cc_compare(const cchar_t *, const cchar_t *, int); 167*7c478bd9Sstevel@tonic-gate extern int __m_cc_replace(WINDOW *, int, int, const cchar_t *, int); 168*7c478bd9Sstevel@tonic-gate extern int __m_cc_add(WINDOW *, int, int, const cchar_t *, int, 169*7c478bd9Sstevel@tonic-gate int *, int *); 170*7c478bd9Sstevel@tonic-gate #if defined(_LP64) 171*7c478bd9Sstevel@tonic-gate extern void __m_cc_hash(WINDOW *, unsigned int *, int); 172*7c478bd9Sstevel@tonic-gate #else 173*7c478bd9Sstevel@tonic-gate extern void __m_cc_hash(WINDOW *, unsigned long *, int); 174*7c478bd9Sstevel@tonic-gate #endif 175*7c478bd9Sstevel@tonic-gate 176*7c478bd9Sstevel@tonic-gate extern int __m_set_echo(int); 177*7c478bd9Sstevel@tonic-gate extern int __m_tty_get(struct termios *); 178*7c478bd9Sstevel@tonic-gate extern int __m_tty_set(struct termios *); 179*7c478bd9Sstevel@tonic-gate extern int __m_decode_init(t_decode **); 180*7c478bd9Sstevel@tonic-gate extern void __m_decode_free(t_decode **); 181*7c478bd9Sstevel@tonic-gate extern int __m_do_scroll(WINDOW *, int, int, int *, int *); 182*7c478bd9Sstevel@tonic-gate extern int __m_ptr_move(void **, unsigned, unsigned, unsigned, unsigned); 183*7c478bd9Sstevel@tonic-gate 184*7c478bd9Sstevel@tonic-gate extern int __m_doupdate_init(void); 185*7c478bd9Sstevel@tonic-gate extern int __m_wins_wch(WINDOW *, int, int, const cchar_t *, int *, int *); 186*7c478bd9Sstevel@tonic-gate extern int __m_cc_ins(WINDOW *, int, int, const cchar_t *); 187*7c478bd9Sstevel@tonic-gate extern void __m_mvcur_cost(void); 188*7c478bd9Sstevel@tonic-gate 189*7c478bd9Sstevel@tonic-gate extern int __m_cc_modify(WINDOW *, int, int, const cchar_t *); 190*7c478bd9Sstevel@tonic-gate extern int __m_tty_set_prog_mode(void); 191*7c478bd9Sstevel@tonic-gate extern int __m_tputs(const char *, int, int (*)(int)); 192*7c478bd9Sstevel@tonic-gate extern int __m_slk_clear(int); 193*7c478bd9Sstevel@tonic-gate extern int __m_cc_add_k(WINDOW *, int, int, const cchar_t *, 194*7c478bd9Sstevel@tonic-gate int, int *, int *); 195*7c478bd9Sstevel@tonic-gate extern int __m_cc_equal(const cchar_t *, const cchar_t *); 196*7c478bd9Sstevel@tonic-gate extern void __m_touch_locs(WINDOW *, int, int, int); 197*7c478bd9Sstevel@tonic-gate extern int __m_wadd_wch(WINDOW *, const cchar_t *); 198*7c478bd9Sstevel@tonic-gate extern void __m_slk_doupdate(void); 199*7c478bd9Sstevel@tonic-gate extern int __m_outc(int); 200*7c478bd9Sstevel@tonic-gate extern int __m_tty_wc(int, wchar_t *); 201*7c478bd9Sstevel@tonic-gate extern int __m_chtype_cc(chtype, cchar_t *); 202*7c478bd9Sstevel@tonic-gate extern chtype __m_cc_chtype(const cchar_t *); 203*7c478bd9Sstevel@tonic-gate extern int __m_copywin(const WINDOW *, WINDOW *, int); 204*7c478bd9Sstevel@tonic-gate extern WINDOW *__m_newwin(WINDOW *, int, int, int, int); 205*7c478bd9Sstevel@tonic-gate extern int __m_putchar(int); 206*7c478bd9Sstevel@tonic-gate extern int __m_mvcur(int, int, int, int, int (*)(int)); 207*7c478bd9Sstevel@tonic-gate extern int __m_read_terminfo(const char *, TERMINAL *); 208*7c478bd9Sstevel@tonic-gate extern int __m_setupterm(char *, int, int, int *); 209*7c478bd9Sstevel@tonic-gate 210*7c478bd9Sstevel@tonic-gate extern int pollTypeahead(void); 211*7c478bd9Sstevel@tonic-gate extern int wistombs(char *, const wint_t *, int); 212*7c478bd9Sstevel@tonic-gate extern int wistowcs(wchar_t *, const wint_t *, int); 213*7c478bd9Sstevel@tonic-gate 214*7c478bd9Sstevel@tonic-gate extern void wtouchln_hard(WINDOW *, int, int); 215*7c478bd9Sstevel@tonic-gate 216*7c478bd9Sstevel@tonic-gate /* 217*7c478bd9Sstevel@tonic-gate * Unique callback functions to initialize a SCREEN's wide_io_t structure, 218*7c478bd9Sstevel@tonic-gate * which is used by __m_wio_get(). The __xc_ denotes XCurses and is used 219*7c478bd9Sstevel@tonic-gate * instead of __m_ to avoid possible name conflicts else-where in MKS 220*7c478bd9Sstevel@tonic-gate * libraries and applications. Note that wgetch() is used for the get 221*7c478bd9Sstevel@tonic-gate * function. 222*7c478bd9Sstevel@tonic-gate */ 223*7c478bd9Sstevel@tonic-gate extern int __xc_feof(void *); 224*7c478bd9Sstevel@tonic-gate extern int __xc_ferror(void *); 225*7c478bd9Sstevel@tonic-gate extern void __xc_clearerr(void *); 226*7c478bd9Sstevel@tonic-gate extern int __xc_ungetc(int, void *); 227*7c478bd9Sstevel@tonic-gate 228*7c478bd9Sstevel@tonic-gate /* 229*7c478bd9Sstevel@tonic-gate * Input stack macros replaced by these functions. 230*7c478bd9Sstevel@tonic-gate */ 231*7c478bd9Sstevel@tonic-gate extern void iqAdd(unsigned int ch); 232*7c478bd9Sstevel@tonic-gate extern void iqPush(unsigned int ch); 233*7c478bd9Sstevel@tonic-gate extern int iqIsEmpty(void); 234*7c478bd9Sstevel@tonic-gate extern void iqReset(void); 235*7c478bd9Sstevel@tonic-gate extern int iqPull(void); 236*7c478bd9Sstevel@tonic-gate 237*7c478bd9Sstevel@tonic-gate #define WSYNC(w) \ 238*7c478bd9Sstevel@tonic-gate if ((w)->_flags & W_SYNC_UP) {\ 239*7c478bd9Sstevel@tonic-gate wsyncup(w);\ 240*7c478bd9Sstevel@tonic-gate } 241*7c478bd9Sstevel@tonic-gate #define WFLUSH(w) (((w)->_flags & W_FLUSH) ? wrefresh(w) : OK) 242*7c478bd9Sstevel@tonic-gate 243*7c478bd9Sstevel@tonic-gate /* end */ 244