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