17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright (c) 1996, by Sun Microsystems, Inc. 247c478bd9Sstevel@tonic-gate * All rights reserved. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate /* 287c478bd9Sstevel@tonic-gate * private.h 297c478bd9Sstevel@tonic-gate * 307c478bd9Sstevel@tonic-gate * XCurses Library 317c478bd9Sstevel@tonic-gate * 327c478bd9Sstevel@tonic-gate * Copyright 1990, 1995 by Mortice Kern Systems Inc. All rights reserved. 337c478bd9Sstevel@tonic-gate * 347c478bd9Sstevel@tonic-gate */ 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #include <mks.h> 377c478bd9Sstevel@tonic-gate #include <curses.h> 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #ifndef M_CURSES_VERSION 407c478bd9Sstevel@tonic-gate #define M_CURSES_VERSION "MKS XCurses" 417c478bd9Sstevel@tonic-gate #endif 42*1da57d55SToomas Soome 437c478bd9Sstevel@tonic-gate #ifndef M_TERM_NAME 447c478bd9Sstevel@tonic-gate #define M_TERM_NAME "dumb" 457c478bd9Sstevel@tonic-gate #endif 46*1da57d55SToomas Soome 477c478bd9Sstevel@tonic-gate #ifndef M_TERMINFO_DIR 487c478bd9Sstevel@tonic-gate #define M_TERMINFO_DIR "/usr/lib/terminfo" 497c478bd9Sstevel@tonic-gate #endif 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate /* 527c478bd9Sstevel@tonic-gate * Interbyte timer value used for processing multibyte function keys. 537c478bd9Sstevel@tonic-gate */ 547c478bd9Sstevel@tonic-gate #ifndef M_CURSES_INTERBYTE_TIME 557c478bd9Sstevel@tonic-gate #define M_CURSES_INTERBYTE_TIME 10 567c478bd9Sstevel@tonic-gate #endif 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate /* 597c478bd9Sstevel@tonic-gate * Maximum number of lines that can be ripped off. 607c478bd9Sstevel@tonic-gate */ 61*1da57d55SToomas Soome #ifndef M_CURSES_MAX_RIPOFFLINE 627c478bd9Sstevel@tonic-gate #define M_CURSES_MAX_RIPOFFLINE 5 637c478bd9Sstevel@tonic-gate #endif 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate /* 667c478bd9Sstevel@tonic-gate * See copywin() and wrefresh() case 4. It is unclear whether XPG4 V2 67*1da57d55SToomas Soome * disallows supporting case 4 (expanding characters straddling a window 687c478bd9Sstevel@tonic-gate * boundary). 697c478bd9Sstevel@tonic-gate */ 707c478bd9Sstevel@tonic-gate #define M_CURSES_SENSIBLE_WINDOWS 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate /* 737c478bd9Sstevel@tonic-gate * Enable typeahead() support. 747c478bd9Sstevel@tonic-gate */ 757c478bd9Sstevel@tonic-gate #define M_CURSES_TYPEAHEAD 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate /* 787c478bd9Sstevel@tonic-gate * Not everyone supports the latest version of the (draft) MSE. 797c478bd9Sstevel@tonic-gate */ 807c478bd9Sstevel@tonic-gate #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199409L 817c478bd9Sstevel@tonic-gate #undef wcrtomb 827c478bd9Sstevel@tonic-gate #define wcrtomb(mb, wc, state) wctomb(mb, wc) 837c478bd9Sstevel@tonic-gate #undef mbrtowc 847c478bd9Sstevel@tonic-gate #define mbrtowc(wc, mb, n, state) mbtowc(wc, mb, n) 857c478bd9Sstevel@tonic-gate #endif 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate /*** 887c478bd9Sstevel@tonic-gate *** END OF CONFIGURABLE SECTION 897c478bd9Sstevel@tonic-gate ***/ 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate /* 927c478bd9Sstevel@tonic-gate * Constant WINDOW definition attributes. 937c478bd9Sstevel@tonic-gate */ 947c478bd9Sstevel@tonic-gate #define W_IS_PAD 0x0001 /* Window is a pad. */ 957c478bd9Sstevel@tonic-gate #define W_END_LINE 0x0002 /* End of line is the margin. */ 967c478bd9Sstevel@tonic-gate #define W_FULL_LINE 0x0004 /* Line spans screen width. */ 977c478bd9Sstevel@tonic-gate #define W_FULL_WINDOW 0x0008 /* Window is full screen. */ 987c478bd9Sstevel@tonic-gate #define W_SCROLL_WINDOW 0x0010 /* Touches bottom-right corner */ 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate /* 1017c478bd9Sstevel@tonic-gate * WINDOW state. 1027c478bd9Sstevel@tonic-gate */ 1037c478bd9Sstevel@tonic-gate #define W_CLEAR_WINDOW 0x0020 /* clearok() clear screen next update. */ 1047c478bd9Sstevel@tonic-gate #define W_REDRAW_WINDOW 0x0040 /* wredrawln() use simple() next update. */ 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate /* 1077c478bd9Sstevel@tonic-gate * Configurable WINDOW options. 1087c478bd9Sstevel@tonic-gate */ 109*1da57d55SToomas Soome #define W_FLUSH 0x0080 /* immedok() update when window changes. */ 1107c478bd9Sstevel@tonic-gate #define W_CAN_SCROLL 0x0100 /* scrollok() window can software scroll. */ 1117c478bd9Sstevel@tonic-gate #define W_LEAVE_CURSOR 0x0200 /* leaveok() don't fuss with the cursor. */ 1127c478bd9Sstevel@tonic-gate #define W_SYNC_UP 0x0400 /* syncok() update ancestors when changed. */ 1137c478bd9Sstevel@tonic-gate #define W_USE_KEYPAD 0x0800 /* keypad() enbles KEY_ processing. */ 1147c478bd9Sstevel@tonic-gate #define W_USE_TIMEOUT 0x1000 /* notimeout() disables the interbyte timer. */ 1157c478bd9Sstevel@tonic-gate #define W_CONFIG_MASK 0x1f80 /* Mask of configurable flags. */ 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate /* 1187c478bd9Sstevel@tonic-gate * Flags used in SCREEN. 1197c478bd9Sstevel@tonic-gate */ 1207c478bd9Sstevel@tonic-gate #define S_ECHO 0x0001 /* Software echo enbled. */ 1217c478bd9Sstevel@tonic-gate #define S_ENDWIN 0x0002 /* Curses is in "shell" mode. */ 1227c478bd9Sstevel@tonic-gate #define S_INS_DEL_CHAR 0x0004 /* idcok() enabled for terminal (future). */ 1237c478bd9Sstevel@tonic-gate #define S_INS_DEL_LINE 0x0008 /* idlok() enabled for terminal. */ 1247c478bd9Sstevel@tonic-gate #define S_ISATTY 0x0010 /* _kfd is a terminal. */ 1257c478bd9Sstevel@tonic-gate #define S_USE_META 0x0020 /* meta() enabled. */ 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate typedef struct t_decode { 1287c478bd9Sstevel@tonic-gate struct t_decode *sibling; 1297c478bd9Sstevel@tonic-gate struct t_decode *child; 1307c478bd9Sstevel@tonic-gate short key; /* KEY_ value or 0. */ 1317c478bd9Sstevel@tonic-gate int ch; /* Character found by this node. */ 1327c478bd9Sstevel@tonic-gate } t_decode; 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate typedef struct { 1357c478bd9Sstevel@tonic-gate int top; /* # of lines off the top. */ 1367c478bd9Sstevel@tonic-gate int bottom; /* # of lines off the bottom (-ve). */ 1377c478bd9Sstevel@tonic-gate struct { 1387c478bd9Sstevel@tonic-gate int dy; /* Distance from screen top/bottom. */ 1397c478bd9Sstevel@tonic-gate int (*init)(WINDOW *, int); /* Init. function for window. */ 1407c478bd9Sstevel@tonic-gate } line[M_CURSES_MAX_RIPOFFLINE]; 1417c478bd9Sstevel@tonic-gate } t_rip; 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate extern SCREEN *__m_screen; 1447c478bd9Sstevel@tonic-gate extern int __m_slk_format; 1457c478bd9Sstevel@tonic-gate extern short __m_keyindex[][2]; 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate #define ATTR_STATE cur_term->_at 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate extern void __m_trace(const char *, ...); 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate #ifdef M_CURSES_TRACE 1527c478bd9Sstevel@tonic-gate extern int __m_return_code(const char *, int); 1537c478bd9Sstevel@tonic-gate extern int __m_return_int(const char *, int); 1547c478bd9Sstevel@tonic-gate extern chtype __m_return_chtype(const char *, chtype); 1557c478bd9Sstevel@tonic-gate extern void *__m_return_pointer(const char *, const void *); 1567c478bd9Sstevel@tonic-gate extern void __m_return_void(const char *); 1577c478bd9Sstevel@tonic-gate #else 1587c478bd9Sstevel@tonic-gate #define __m_return_code(s, c) (c) 1597c478bd9Sstevel@tonic-gate #define __m_return_int(s, c) (c) 1607c478bd9Sstevel@tonic-gate #define __m_return_chtype(s, c) (c) 1617c478bd9Sstevel@tonic-gate #define __m_return_pointer(s, p) (p) 1627c478bd9Sstevel@tonic-gate #define __m_return_void(s) 1637c478bd9Sstevel@tonic-gate #endif /* M_CURSES_TRACE */ 1647c478bd9Sstevel@tonic-gate 1657c478bd9Sstevel@tonic-gate extern int __m_wc_cc(wint_t, cchar_t *); 1667c478bd9Sstevel@tonic-gate extern int __m_mbs_cc(const char *, attr_t, short, cchar_t *); 1677c478bd9Sstevel@tonic-gate extern int __m_wcs_cc(const wchar_t *, attr_t, short, cchar_t *); 1687c478bd9Sstevel@tonic-gate extern int __m_acs_cc(chtype, cchar_t *); 1697c478bd9Sstevel@tonic-gate extern int __m_wacs_cc(const cchar_t *, cchar_t *); 1707c478bd9Sstevel@tonic-gate extern int __m_cc_mbs(const cchar_t *, char *, int); 1717c478bd9Sstevel@tonic-gate 1727c478bd9Sstevel@tonic-gate extern int __m_cc_sort(cchar_t *); 1737c478bd9Sstevel@tonic-gate extern int __m_cc_width(const cchar_t *); 1747c478bd9Sstevel@tonic-gate extern int __m_cc_write(const cchar_t *); 1757c478bd9Sstevel@tonic-gate extern int __m_cc_first(WINDOW *, int, int); 1767c478bd9Sstevel@tonic-gate extern int __m_cc_next(WINDOW *, int, int); 1777c478bd9Sstevel@tonic-gate extern int __m_cc_islast(WINDOW *, int, int); 1787c478bd9Sstevel@tonic-gate extern int __m_cc_expand(WINDOW *, int, int, int); 1797c478bd9Sstevel@tonic-gate extern int __m_cc_erase(WINDOW *, int, int, int, int); 1807c478bd9Sstevel@tonic-gate extern int __m_cc_compare(const cchar_t *, const cchar_t *, int); 1817c478bd9Sstevel@tonic-gate extern int __m_cc_replace(WINDOW *, int, int, const cchar_t *, int); 1827c478bd9Sstevel@tonic-gate extern int __m_cc_add(WINDOW *, int, int, const cchar_t *, int, int *, int *); 1837c478bd9Sstevel@tonic-gate extern void __m_cc_hash(WINDOW *, unsigned long *, int); 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate extern int __m_set_echo(int); 1867c478bd9Sstevel@tonic-gate extern int __m_tty_get(struct termios *); 1877c478bd9Sstevel@tonic-gate extern int __m_tty_set(struct termios *); 1887c478bd9Sstevel@tonic-gate extern int __m_decode_init(t_decode **); 1897c478bd9Sstevel@tonic-gate extern void __m_decode_free(t_decode **); 1907c478bd9Sstevel@tonic-gate extern int __m_do_scroll(WINDOW *, int, int, int *, int *); 1917c478bd9Sstevel@tonic-gate extern int __m_ptr_move(void **, unsigned, unsigned, unsigned, unsigned); 1927c478bd9Sstevel@tonic-gate 1937c478bd9Sstevel@tonic-gate extern int __m_doupdate_init(void); 1947c478bd9Sstevel@tonic-gate extern int __m_wins_wch(WINDOW *, int, int, const cchar_t *, int *, int *); 1957c478bd9Sstevel@tonic-gate extern int __m_cc_ins(WINDOW *, int, int, const cchar_t *); 1967c478bd9Sstevel@tonic-gate extern void __m_mvcur_cost(void); 1977c478bd9Sstevel@tonic-gate 1987c478bd9Sstevel@tonic-gate /* 199*1da57d55SToomas Soome * Unique callback functions to initialize a SCREEN's wide_io_t structure, 200*1da57d55SToomas Soome * which is used by __m_wio_get(). The __xc_ denotes XCurses and is used 2017c478bd9Sstevel@tonic-gate * instead of __m_ to avoid possible name conflicts else-where in MKS 2027c478bd9Sstevel@tonic-gate * libraries and applications. Note that wgetch() is used for the get 2037c478bd9Sstevel@tonic-gate * function. 2047c478bd9Sstevel@tonic-gate */ 2057c478bd9Sstevel@tonic-gate extern int __xc_feof(void *); 2067c478bd9Sstevel@tonic-gate extern int __xc_ferror(void *); 2077c478bd9Sstevel@tonic-gate extern void __xc_clearerr(void *); 2087c478bd9Sstevel@tonic-gate extern int __xc_ungetc(int, void *); 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate /* 2117c478bd9Sstevel@tonic-gate * Input stack macros. 2127c478bd9Sstevel@tonic-gate */ 2137c478bd9Sstevel@tonic-gate #define ISFULL() (__m_screen->_unget._size <= __m_screen->_unget._count) 2147c478bd9Sstevel@tonic-gate #define ISEMPTY() (__m_screen->_unget._count <= 0) 2157c478bd9Sstevel@tonic-gate #define DEC() --__m_screen->_unget._count 2167c478bd9Sstevel@tonic-gate #define INC() __m_screen->_unget._count++ 2177c478bd9Sstevel@tonic-gate #define RESET() __m_screen->_unget._count = 0 2187c478bd9Sstevel@tonic-gate #define POP() __m_screen->_unget._stack[DEC()] 2197c478bd9Sstevel@tonic-gate #define PUSH(x) (__m_screen->_unget._stack[INC()] = (x)) 2207c478bd9Sstevel@tonic-gate 2217c478bd9Sstevel@tonic-gate #define WSYNC(w) (((w)->_flags & W_SYNC_UP) ? wsyncup(w) : (void) OK) 2227c478bd9Sstevel@tonic-gate #define WFLUSH(w) (((w)->_flags & W_FLUSH) ? wrefresh(w) : OK) 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate /* end */ 225