xref: /titanic_44/usr/src/lib/libxcurses/src/libc/xcurses/private.h (revision 49b225e1cfa7bbf7738d4df0a03f18e3283426eb)
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, 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 <mks.h>
39 #include <curses.h>
40 
41 #ifndef M_CURSES_VERSION
42 #define M_CURSES_VERSION        "MKS XCurses"
43 #endif
44 
45 #ifndef M_TERM_NAME
46 #define M_TERM_NAME             "dumb"
47 #endif
48 
49 #ifndef M_TERMINFO_DIR
50 #define M_TERMINFO_DIR          "/usr/lib/terminfo"
51 #endif
52 
53 /*
54  * Interbyte timer value used for processing multibyte function keys.
55  */
56 #ifndef M_CURSES_INTERBYTE_TIME
57 #define M_CURSES_INTERBYTE_TIME		10
58 #endif
59 
60 /*
61  * Maximum number of lines that can be ripped off.
62  */
63 #ifndef M_CURSES_MAX_RIPOFFLINE
64 #define M_CURSES_MAX_RIPOFFLINE		5
65 #endif
66 
67 /*
68  * See copywin() and wrefresh() case 4.  It is unclear whether XPG4 V2
69  * disallows supporting case 4 (expanding characters straddling a window
70  * boundary).
71  */
72 #define M_CURSES_SENSIBLE_WINDOWS
73 
74 /*
75  * Enable typeahead() support.
76  */
77 #define M_CURSES_TYPEAHEAD
78 
79 /*
80  * Not everyone supports the latest version of the (draft) MSE.
81  */
82 #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199409L
83 #undef wcrtomb
84 #define wcrtomb(mb, wc, state)		wctomb(mb, wc)
85 #undef mbrtowc
86 #define mbrtowc(wc, mb, n, state)	mbtowc(wc, mb, n)
87 #endif
88 
89 /***
90  *** END OF CONFIGURABLE SECTION
91  ***/
92 
93 /*
94  * Constant WINDOW definition attributes.
95  */
96 #define W_IS_PAD	0x0001	/* Window is a pad. */
97 #define W_END_LINE	0x0002	/* End of line is the margin. */
98 #define W_FULL_LINE	0x0004	/* Line spans screen width. */
99 #define W_FULL_WINDOW	0x0008	/* Window is full screen. */
100 #define W_SCROLL_WINDOW	0x0010	/* Touches bottom-right corner */
101 
102 /*
103  * WINDOW state.
104  */
105 #define W_CLEAR_WINDOW	0x0020	/* clearok() clear screen next update. */
106 #define W_REDRAW_WINDOW 0x0040	/* wredrawln() use simple() next update. */
107 
108 /*
109  * Configurable WINDOW options.
110  */
111 #define W_FLUSH		0x0080	/* immedok() update when window changes. */
112 #define W_CAN_SCROLL	0x0100	/* scrollok() window can software scroll. */
113 #define W_LEAVE_CURSOR	0x0200	/* leaveok() don't fuss with the cursor. */
114 #define W_SYNC_UP	0x0400	/* syncok() update ancestors when changed. */
115 #define W_USE_KEYPAD	0x0800	/* keypad() enbles KEY_ processing. */
116 #define W_USE_TIMEOUT	0x1000	/* notimeout() disables the interbyte timer. */
117 #define W_CONFIG_MASK	0x1f80 	/* Mask of configurable flags. */
118 
119 /*
120  * Flags used in SCREEN.
121  */
122 #define S_ECHO		0x0001	/* Software echo enbled. */
123 #define S_ENDWIN	0x0002	/* Curses is in "shell" mode. */
124 #define S_INS_DEL_CHAR	0x0004	/* idcok() enabled for terminal (future). */
125 #define S_INS_DEL_LINE	0x0008	/* idlok() enabled for terminal. */
126 #define S_ISATTY	0x0010	/* _kfd is a terminal. */
127 #define S_USE_META	0x0020	/* meta() enabled. */
128 
129 typedef struct t_decode {
130 	struct t_decode *sibling;
131 	struct t_decode *child;
132 	short key;			/* KEY_ value or 0. */
133 	int ch;				/* Character found by this node. */
134 } t_decode;
135 
136 typedef struct {
137 	int top;			/* # of lines off the top. */
138 	int bottom;			/* # of lines off the bottom (-ve). */
139 	struct {
140 		int dy;			/* Distance from screen top/bottom. */
141 		int (*init)(WINDOW *, int);	/* Init. function for window. */
142 	} line[M_CURSES_MAX_RIPOFFLINE];
143 } t_rip;
144 
145 extern SCREEN *__m_screen;
146 extern int __m_slk_format;
147 extern short __m_keyindex[][2];
148 
149 #define ATTR_STATE	cur_term->_at
150 
151 extern void __m_trace(const char *, ...);
152 
153 #ifdef M_CURSES_TRACE
154 extern int __m_return_code(const char *, int);
155 extern int __m_return_int(const char *, int);
156 extern chtype __m_return_chtype(const char *, chtype);
157 extern void *__m_return_pointer(const char *, const void *);
158 extern void __m_return_void(const char *);
159 #else
160 #define __m_return_code(s, c)		(c)
161 #define __m_return_int(s, c)		(c)
162 #define __m_return_chtype(s, c)		(c)
163 #define __m_return_pointer(s, p)	(p)
164 #define __m_return_void(s)
165 #endif /* M_CURSES_TRACE */
166 
167 extern int __m_wc_cc(wint_t, cchar_t *);
168 extern int __m_mbs_cc(const char *, attr_t, short, cchar_t *);
169 extern int __m_wcs_cc(const wchar_t *, attr_t, short, cchar_t *);
170 extern int __m_acs_cc(chtype, cchar_t *);
171 extern int __m_wacs_cc(const cchar_t *, cchar_t *);
172 extern int __m_cc_mbs(const cchar_t *, char *, int);
173 
174 extern int __m_cc_sort(cchar_t *);
175 extern int __m_cc_width(const cchar_t *);
176 extern int __m_cc_write(const cchar_t *);
177 extern int __m_cc_first(WINDOW *, int, int);
178 extern int __m_cc_next(WINDOW *, int, int);
179 extern int __m_cc_islast(WINDOW *, int, int);
180 extern int __m_cc_expand(WINDOW *, int, int, int);
181 extern int __m_cc_erase(WINDOW *, int, int, int, int);
182 extern int __m_cc_compare(const cchar_t *, const cchar_t *, int);
183 extern int __m_cc_replace(WINDOW *, int, int, const cchar_t *, int);
184 extern int __m_cc_add(WINDOW *, int, int, const cchar_t *, int, int *, int *);
185 extern void __m_cc_hash(WINDOW *, unsigned long *, int);
186 
187 extern int __m_set_echo(int);
188 extern int __m_tty_get(struct termios *);
189 extern int __m_tty_set(struct termios *);
190 extern int __m_decode_init(t_decode **);
191 extern void __m_decode_free(t_decode **);
192 extern int __m_do_scroll(WINDOW *, int, int, int *, int *);
193 extern int __m_ptr_move(void **, unsigned, unsigned, unsigned, unsigned);
194 
195 extern int __m_doupdate_init(void);
196 extern int __m_wins_wch(WINDOW *, int, int, const cchar_t *, int *, int *);
197 extern int __m_cc_ins(WINDOW *, int, int, const cchar_t *);
198 extern void __m_mvcur_cost(void);
199 
200 /*
201  * Unique callback functions to initialize a SCREEN's wide_io_t structure,
202  * which is used by __m_wio_get().   The __xc_ denotes XCurses and is used
203  * instead of __m_ to avoid possible name conflicts else-where in MKS
204  * libraries and applications.  Note that wgetch() is used for the get
205  * function.
206  */
207 extern int __xc_feof(void *);
208 extern int __xc_ferror(void *);
209 extern void __xc_clearerr(void *);
210 extern int __xc_ungetc(int, void *);
211 
212 /*
213  * Input stack macros.
214  */
215 #define ISFULL()	(__m_screen->_unget._size <= __m_screen->_unget._count)
216 #define ISEMPTY()	(__m_screen->_unget._count <= 0)
217 #define DEC()		--__m_screen->_unget._count
218 #define INC()		__m_screen->_unget._count++
219 #define RESET()		__m_screen->_unget._count = 0
220 #define POP()		__m_screen->_unget._stack[DEC()]
221 #define PUSH(x)		(__m_screen->_unget._stack[INC()] = (x))
222 
223 #define WSYNC(w)	(((w)->_flags & W_SYNC_UP) ? wsyncup(w) : (void) OK)
224 #define WFLUSH(w)	(((w)->_flags & W_FLUSH) ? wrefresh(w) : OK)
225 
226 /* end */
227