xref: /titanic_41/usr/src/lib/libcurses/screen/curshdr.h (revision 88f8b78a88cbdc6d8c1af5c3e54bc49d25095c98)
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 1997 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1988 AT&T	*/
28 /*	  All Rights Reserved	*/
29 
30 /*
31  * University Copyright- Copyright (c) 1982, 1986, 1988
32  * The Regents of the University of California
33  * All Rights Reserved
34  *
35  * University Acknowledgment- Portions of this document are derived from
36  * software developed by the University of California, Berkeley, and its
37  * contributors.
38  */
39 
40 #ifndef _CURSHDR_H
41 #define	_CURSHDR_H
42 
43 #pragma ident	"%Z%%M%	%I%	%E% SMI"
44 
45 #ifdef	__cplusplus
46 extern "C" {
47 #endif
48 
49 #define	_NOHASH		(-1)	/* if the hash value is unknown */
50 #define	_REDRAW		(-2)	/* if line need redrawn */
51 #define	_BLANK		(-3)	/* if line is blank */
52 #define	_THASH		(123)	/* base hash if clash with other hashes */
53 #define	_KEY		(01)
54 #define	_MACRO		(02)
55 
56 #define	_INPUTPENDING	cur_term->_iwait
57 #define	_PUTS(x, y)	(void) tputs(x, y, _outch)
58 #define	_VIDS(na, oa)	(vidupdate((na), (oa), _outch), curscr->_attrs = (na))
59 #define	_ONINSERT()	(_PUTS(enter_insert_mode, 1), SP->phys_irm = TRUE)
60 #define	_OFFINSERT()	(_PUTS(exit_insert_mode, 1), SP->phys_irm = FALSE)
61 #define	_STRNOTEQ(a, b)	(a == NULL ? (b != NULL) : \
62 			    (b == NULL ? 1 : strcmp(a, b)))
63 
64 /*
65  * IC and IL overheads and costs should be set to this
66  * value if the corresponding feature is missing
67  */
68 
69 #define	LARGECOST	500
70 
71 typedef	struct
72 {
73     short	icfixed;		/* Insert char fixed overhead */
74     short	dcfixed;		/* Delete char fixed overhead */
75     short	Insert_character;
76     short	Delete_character;
77     short	Cursor_home;
78     short	Cursor_to_ll;
79     short	Cursor_left;
80     short	Cursor_right;
81     short	Cursor_down;
82     short	Cursor_up;
83     short	Carriage_return;
84     short	Tab;
85     short	Back_tab;
86     short	Clr_eol;
87     short	Clr_bol;
88     short	Parm_ich;
89     short	Parm_dch;
90     short	Parm_left_cursor;
91     short	Parm_up_cursor;
92     short	Parm_down_cursor;
93     short	Parm_right_cursor;
94     short	Cursor_address;
95     short	Row_address;
96 } COSTS;
97 
98 #define	_COST(field)	(SP->term_costs.field)
99 
100 /* Soft label keys */
101 
102 #define	LABMAX	16	/* max number of labels allowed */
103 #define	LABLEN	8	/* max length of each label */
104 
105 typedef	struct
106 {
107     WINDOW	*_win;		/* the window to display labels */
108     char	_ldis[LABMAX][LABLEN+1]; /* labels suitable to display */
109     char	_lval[LABMAX][LABLEN+1]; /* labels' true values */
110     short	_labx[LABMAX];	/* where to display labels */
111     short	_num;		/* actual number of labels */
112     short	_len;		/* real length of labels */
113     bool	_changed;	/* TRUE if some labels changed */
114     bool	_lch[LABMAX];	/* change status */
115 } SLK_MAP;
116 
117 struct	screen
118 {
119     unsigned	fl_echoit : 1;	/* in software echo mode */
120     unsigned	fl_endwin : 2;	/* has called endwin */
121     unsigned	fl_meta : 1;	/* in meta mode */
122     unsigned	fl_nonl : 1;	/* do not xlate input \r-> \n */
123     unsigned	yesidln : 1;	/* has idln capabilities */
124     unsigned	dmode : 1;	/* Terminal has delete mode */
125     unsigned	imode : 1;	/* Terminal has insert mode */
126     unsigned	ichok : 1;	/* Terminal can insert characters */
127     unsigned	dchok : 1;	/* Terminal can delete characters */
128     unsigned	sid_equal : 1;	/* enter insert and delete mode equal */
129     unsigned	eid_equal : 1;	/* exit insert and delete mode equal */
130     unsigned	phys_irm : 1;	/* in insert mode or not */
131     long	baud;		/* baud rate of this tty */
132     short	kp_state;	/* 1 iff keypad is on, else 0 */
133     short	Yabove;		/* How many lines are above stdscr */
134     short	lsize;		/* How many lines decided by newscreen */
135     short	csize;		/* How many columns decided by newscreen */
136     short	tsize;		/* How big is a tab decided by newscreen */
137     WINDOW	*std_scr;	/* primary output screen */
138     WINDOW	*cur_scr;	/* what's physically on the screen */
139     WINDOW	*virt_scr;	/* what's virtually on the screen */
140     int		*cur_hash;	/* hash table of curscr */
141     int		*virt_hash;	/* hash table of virtscr */
142     TERMINAL	*tcap;		/* TERMINFO info */
143     FILE	*term_file;	/* File to write on for output. */
144     FILE	*input_file;	/* Where to get keyboard input */
145     SLK_MAP	*slk;		/* Soft label information */
146     char	**_mks;		/* marks, only used with xhp terminals */
147     COSTS	term_costs;	/* costs of various capabilities */
148     SGTTY	save_tty_buf;	/* saved termio state of this tty */
149 #ifdef	SYSV
150     SGTTYS	save_tty_bufs;	/* saved termios state of this tty */
151 #endif
152     char	**_color_mks;	/* marks, only used with color xhp terminals */
153     unsigned long  _trap_mbe;		/* trap these mouse button events    */
154     unsigned long  _map_mbe_to_key;	/* map selected buttons on top of    */
155 					/* slk's to function keys */
156 };
157 
158 extern	SCREEN	*SP;
159 extern	WINDOW	*_virtscr;
160 
161 #ifdef	DEBUG
162 #ifndef	outf
163 extern	FILE	*outf;
164 #endif	/* outf */
165 #endif	/* DEBUG */
166 
167 extern	short	cswidth[],	/* byte size of multi-byte chars */
168 		_curs_scrwidth[];	/* display size */
169 extern	short	_csmax,
170 		_scrmax;
171 extern	bool	_mbtrue;
172 
173 #define	MBIT		0200		/* indicator for a multi-byte char */
174 #define	CBIT		002000000000	/* indicator for a continuing col */
175 #define	RBYTE(x)	((x) & 0377)
176 #define	LBYTE(x)	(((x) >> 8) & 0177)
177 #define	ISMBIT(x)	((x) & MBIT)
178 #define	SETMBIT(x)	((x) |= MBIT)
179 #define	CLRMBIT(x)	((x) &= ~MBIT)
180 #define	ISCBIT(x)	((x) & CBIT)
181 #define	SETCBIT(x)	((x) |= CBIT)
182 #define	CLRCBIT(x)	((x) &= ~CBIT)
183 #define	TYPE(x)		((x) == SS2 ? 1 : (x) == SS3 ? 2 : ISMBIT(x) ? 0 : 3)
184 #define	TRIM		037777777777	/* 0xFFFFFFFF */
185 
186 /* terminfo magic number */
187 #define	MAGNUM	0432
188 
189 /* curses screen dump magic number */
190 #define	SVR2_DUMP_MAGIC_NUMBER	0433
191 #define	SVR3_DUMP_MAGIC_NUMBER	0434
192 
193 /* Getting the baud rate is different on the two systems. */
194 
195 #ifdef	SYSV
196 #define	_BR(x)	(x.c_cflag & CBAUD)
197 #define	_BRS(x)	(cfgetospeed(&x))
198 #include	<values.h>
199 #else	/* SYSV */
200 #define	BITSPERBYTE	8
201 #define	MAXINT		32767
202 #define	_BR(x)	(x.sg_ispeed)
203 #endif	/* SYSV */
204 
205 #define	_BLNKCHAR	' '
206 #define	_CTRL(c)	(c | 0100)
207 #define	_ATTR(c)	((c) & A_ATTRIBUTES)
208 #define	_CHAR(c)	((c) & A_CHARTEXT)
209 
210 /*
211  *	combine CHAR par of the character with the attributes of the window.
212  *	Two points: 1) If character is blank, usebackground instead
213  *		    2) If character contains color, delete color from
214  *			window attribute.
215  */
216 
217 #define	_WCHAR(w, c)    (_CHAR((c) == _BLNKCHAR ? (w)->_bkgd : (c))| \
218 			    (((c) & A_COLOR) ? ((w)->_attrs & ~A_COLOR) : \
219 			    ((w)->_attrs)))
220 
221 #define	_DARKCHAR(c)	((c) != _BLNKCHAR)
222 #define	_UNCTRL(c)	((c) ^ 0100)
223 
224 /* blank lines info of curscr */
225 #define	_BEGNS		curscr->_firstch
226 #define	_ENDNS		curscr->_lastch
227 
228 /* hash tables */
229 #define	_CURHASH	SP->cur_hash
230 #define	_VIRTHASH	SP->virt_hash
231 
232 /* top/bot line changed */
233 #define	_VIRTTOP	_virtscr->_parx
234 #define	_VIRTBOT	_virtscr->_pary
235 
236 /* video marks */
237 #define	_MARKS		SP->_mks
238 #define	_COLOR_MARKS	SP->_color_mks
239 
240 #define	_NUMELEMENTS(x)	(sizeof (x)/sizeof (x[0]))
241 
242 #ifdef	_VR3_COMPAT_CODE
243 /*
244  * #define	_TO_OCHTYPE(x)		((_ochtype)(((x&A_ATTRIBUTES)>>9)| \
245  * 						(x&0x0000007FUL)))
246  */
247 #define	_TO_OCHTYPE(x)		((_ochtype)(((x&A_ATTRIBUTES)>>9)|(x&0177)))
248 #define	_FROM_OCHTYPE(x)	((chtype) ((x&0177) | ((x&0177600)<<9)))
249 extern	void	(*_y16update)(WINDOW *, int, int, int, int);
250 #endif	/* _VR3_COMPAT_CODE */
251 
252 /* functions for screen updates */
253 
254 extern	int	(*_setidln)(void);
255 extern	int	(*_useidln)(void);
256 extern	int	(*_quick_ptr)(WINDOW *, chtype);
257 extern	int	(_quick_echo)(WINDOW *, chtype);
258 
259 /* min/max functions */
260 
261 #define	_MIN(a, b)	((a) < (b) ? (a) : (b))
262 #define	_MAX(a, b)	((a) > (b) ? (a) : (b))
263 
264 extern	int	(*_do_slk_ref)(void);
265 extern	int	(*_do_slk_tch)(void);
266 extern	int	(*_do_slk_noref)(void);
267 extern	int	_image(WINDOW *);
268 extern	int	_outch(char);
269 extern	int	_outwch(chtype);
270 extern	int	_chkinput(void);
271 extern	int	_curs_mbtowc(wchar_t *, const char *, size_t);
272 extern	int	_curs_wctomb(char *, wchar_t);
273 extern	int	_delay(int, int (*)(char));
274 extern	int	_mbaddch(WINDOW *, chtype, chtype);
275 extern	int	_mbclrch(WINDOW *, int, int);
276 extern	int	_mbinsshift(WINDOW *, int), _mbvalid(WINDOW *);
277 extern	int	_padjust(WINDOW *, int, int, int, int, int, int);
278 extern	int	_prefresh(int (*)(WINDOW *), WINDOW *, int, int, int,
279 		int, int, int);
280 extern	int	_overlap(WINDOW *, WINDOW *, int);
281 extern	int	_scr_all(char *, int);
282 extern	int	_slk_update(void);
283 extern	int	_tcsearch(char *, short [], char *[], int, int);
284 extern	int	_vsscanf(char *, char *, __va_list);
285 extern	int	force_doupdate(void);
286 extern	int	init_acs(void);
287 extern	int	mbscrw(int);
288 extern	int	mbeucw(int);
289 extern	int	scr_ll_dump(FILE *);
290 extern	int	scr_reset(FILE *, int);
291 extern	int	setkeymap(void);
292 extern	int	ttimeout(int);
293 extern	int	wadjcurspos(WINDOW *);
294 extern	int	wcscrw(wchar_t);
295 extern	int	wmbmove(WINDOW *, int, int);
296 
297 extern	chtype	tgetch(int);
298 
299 extern	WINDOW	*_makenew(int, int, int, int);
300 
301 extern	void	(*_slk_init)(void);
302 extern	void	(*_rip_init)(void);
303 extern	void	delkeymap(TERMINAL *);
304 extern	void	mbgetwidth(void);
305 extern	void	memSset(chtype *, chtype, int);
306 extern	void	_blast_keys(TERMINAL *);
307 extern	void	_init_costs(void);
308 extern	void	_init_HP_pair(short, short, short);
309 extern	void	_update_old_y_area(WINDOW *, int, int, int, int);
310 
311 extern	char    *tparm_p0(char *);
312 extern	char    *tparm_p1(char *, long);
313 extern	char    *tparm_p2(char *, long, long);
314 extern	char    *tparm_p3(char *, long, long, long);
315 extern	char    *tparm_p4(char *, long, long, long, long);
316 extern	char    *tparm_p7(char *, long, long, long, long, long, long, long);
317 
318 
319 extern	char	*infotocap(char *, int *);
320 extern	char	*_strcode2byte(wchar_t *, char *, int);
321 extern	char	*wmbinch(WINDOW *, int, int);
322 
323 #ifdef	__cplusplus
324 }
325 #endif
326 
327 #endif	/* _CURSHDR_H */
328