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