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