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
114typedef 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
121typedef 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
131extern SCREEN	*__m_screen;
132extern int	__m_slk_format;
133extern int	__m_slk_labels_on;
134extern const short	__m_keyindex[][2];
135
136extern const char	*boolnames[];
137extern const char	*boolcodes[];
138extern const char	*boolfnames[];
139extern const char	*numnames[];
140extern const char	*numcodes[];
141extern const char	*numfnames[];
142extern const char	*strnames[];
143extern const char	*strcodes[];
144extern 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
154extern int	__m_wc_cc(wint_t, cchar_t *);
155extern int	__m_mbs_cc(const char *, attr_t, short, cchar_t *);
156extern int	__m_wcs_cc(const wchar_t *, attr_t, short, cchar_t *);
157extern int	__m_acs_cc(chtype, cchar_t *);
158extern int	__m_wacs_cc(const cchar_t *, cchar_t *);
159extern int	__m_cc_mbs(const cchar_t *, char *, int);
160
161extern int	__m_cc_sort(cchar_t *);
162extern int	__m_cc_write(const cchar_t *);
163extern int	__m_cc_first(WINDOW *, int, int);
164extern int	__m_cc_next(WINDOW *, int, int);
165extern int	__m_cc_islast(WINDOW *, int, int);
166extern int	__m_cc_expand(WINDOW *, int, int, int);
167extern int	__m_cc_erase(WINDOW *, int, int, int, int);
168extern int	__m_cc_compare(const cchar_t *, const cchar_t *, int);
169extern int	__m_cc_replace(WINDOW *, int, int, const cchar_t *, int);
170extern int	__m_cc_add(WINDOW *, int, int, const cchar_t *, int,
171	int *, int *);
172#if defined(_LP64)
173extern void	__m_cc_hash(WINDOW *, unsigned int *, int);
174#else
175extern void	__m_cc_hash(WINDOW *, unsigned long *, int);
176#endif
177
178extern int	__m_set_echo(int);
179extern int	__m_tty_get(struct termios *);
180extern int	__m_tty_set(struct termios *);
181extern int	__m_decode_init(t_decode **);
182extern void	__m_decode_free(t_decode **);
183extern int	__m_do_scroll(WINDOW *, int, int, int *, int *);
184extern int	__m_ptr_move(void **, unsigned, unsigned, unsigned, unsigned);
185
186extern int	__m_doupdate_init(void);
187extern int	__m_wins_wch(WINDOW *, int, int, const cchar_t *, int *, int *);
188extern int	__m_cc_ins(WINDOW *, int, int, const cchar_t *);
189extern void	__m_mvcur_cost(void);
190
191extern int	__m_cc_modify(WINDOW *, int, int, const cchar_t *);
192extern int	__m_tty_set_prog_mode(void);
193extern int	__m_tputs(const char *, int, int (*)(int));
194extern int	__m_slk_clear(int);
195extern int	__m_cc_add_k(WINDOW *, int, int, const cchar_t *,
196	int, int *, int *);
197extern int	__m_cc_equal(const cchar_t *, const cchar_t *);
198extern void	__m_touch_locs(WINDOW *, int, int, int);
199extern int	__m_wadd_wch(WINDOW *, const cchar_t *);
200extern void	__m_slk_doupdate(void);
201extern int	__m_outc(int);
202extern int	__m_tty_wc(int, wchar_t *);
203extern int	__m_chtype_cc(chtype, cchar_t *);
204extern chtype	__m_cc_chtype(const cchar_t *);
205extern int	__m_copywin(const WINDOW *, WINDOW *, int);
206extern WINDOW	*__m_newwin(WINDOW *, int, int, int, int);
207extern int	__m_putchar(int);
208extern int	__m_mvcur(int, int, int, int, int (*)(int));
209extern int	__m_read_terminfo(const char *, TERMINAL *);
210extern int	__m_setupterm(char *, int, int, int *);
211
212extern int	pollTypeahead(void);
213extern int	wistombs(char *, const wint_t *, int);
214extern int	wistowcs(wchar_t *, const wint_t *, int);
215
216extern 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 */
225extern int	__xc_feof(void *);
226extern int	__xc_ferror(void *);
227extern void	__xc_clearerr(void *);
228extern int	__xc_ungetc(int, void *);
229
230/*
231 * Input stack macros replaced by these functions.
232 */
233extern void	iqAdd(unsigned int ch);
234extern void	iqPush(unsigned int ch);
235extern int	iqIsEmpty(void);
236extern void	iqReset(void);
237extern 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