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