1 /*
2  *	$XConsortium: ptyx.h /main/66 1995/12/09 08:58:41 kaleb $
3  *	$Id: ptyx.h,v 6.2 1996/07/02 05:01:31 kagotani Rel $
4  */
5 #ifdef KTERM
6 #include "kterm.h"
7 #endif /* KTERM */
8 
9 /*
10  * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
11  *
12  *                         All Rights Reserved
13  *
14  * Permission to use, copy, modify, and distribute this software and its
15  * documentation for any purpose and without fee is hereby granted,
16  * provided that the above copyright notice appear in all copies and that
17  * both that copyright notice and this permission notice appear in
18  * supporting documentation, and that the name of Digital Equipment
19  * Corporation not be used in advertising or publicity pertaining to
20  * distribution of the software without specific, written prior permission.
21  *
22  *
23  * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
24  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
25  * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
26  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
27  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
28  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
29  * SOFTWARE.
30  */
31 
32 /* ptyx.h */
33 /* @(#)ptyx.h	X10/6.6	11/10/86 */
34 
35 #include <X11/IntrinsicP.h>
36 #include <X11/Xmu/Misc.h>	/* For Max() and Min(). */
37 #include <X11/Xfuncs.h>
38 #include <X11/Xosdefs.h>
39 
40 /* Extra Xlib definitions */
41 #define AllButtonsUp(detail, ignore)  (\
42 		((ignore) == Button1) ? \
43 				(((detail)&(Button2Mask|Button3Mask)) == 0) \
44 				: \
45 		 (((ignore) == Button2) ? \
46 		  		(((detail)&(Button1Mask|Button3Mask)) == 0) \
47 				: \
48 		  		(((detail)&(Button1Mask|Button2Mask)) == 0)) \
49 		)
50 
51 #define MAX_COLS	200
52 #define MAX_ROWS	128
53 
54 /*
55 ** System V definitions
56 */
57 
58 #ifdef SYSV
59 #ifdef X_NOT_POSIX
60 #ifndef CRAY
61 #define	dup2(fd1,fd2)	((fd1 == fd2) ? fd1 : \
62 				(close(fd2), fcntl(fd1, F_DUPFD, fd2)))
63 #endif
64 #endif
65 #endif /* SYSV */
66 
67 /*
68 ** allow for mobility of the pty master/slave directories
69 */
70 #ifndef PTYDEV
71 #ifdef hpux
72 #define	PTYDEV		"/dev/ptym/ptyxx"
73 #else	/* !hpux */
74 #ifndef __osf__
75 #define	PTYDEV		"/dev/ptyxx"
76 #endif
77 #endif	/* !hpux */
78 #endif	/* !PTYDEV */
79 
80 #ifndef TTYDEV
81 #ifdef hpux
82 #define TTYDEV		"/dev/pty/ttyxx"
83 #else	/* !hpux */
84 #ifdef __osf__
85 #define TTYDEV		"/dev/ttydirs/xxx/xxxxxxxxxxxxxx"
86 #else
87 #define	TTYDEV		"/dev/ttyxx"
88 #endif
89 #endif	/* !hpux */
90 #endif	/* !TTYDEV */
91 
92 #ifndef PTYCHAR1
93 #ifdef hpux
94 #define PTYCHAR1	"zyxwvutsrqp"
95 #else	/* !hpux */
96 #define	PTYCHAR1	"pqrstuvwxyzPQRSTUVWXYZ"
97 #endif	/* !hpux */
98 #endif	/* !PTYCHAR1 */
99 
100 #ifndef PTYCHAR2
101 #ifdef hpux
102 #define	PTYCHAR2	"fedcba9876543210"
103 #else	/* !hpux */
104 #ifdef __FreeBSD__
105 #define	PTYCHAR2	"0123456789abcdefghijklmnopqrstuv"
106 #else
107 #define	PTYCHAR2	"0123456789abcdef"
108 #endif
109 #endif	/* !hpux */
110 #endif	/* !PTYCHAR2 */
111 
112 #ifndef TTYFORMAT
113 #ifdef CRAY
114 #define TTYFORMAT "/dev/ttyp%03d"
115 #else
116 #define TTYFORMAT "/dev/ttyp%d"
117 #endif
118 #endif
119 
120 #ifndef PTYFORMAT
121 #ifdef CRAY
122 #define PTYFORMAT "/dev/pty/%03d"
123 #else
124 #define PTYFORMAT "/dev/ptyp%d"
125 #endif
126 #endif
127 
128 #ifndef MAXPTTYS
129 #ifdef CRAY
130 #define MAXPTTYS 256
131 #else
132 #define MAXPTTYS 2048
133 #endif
134 #endif
135 
136 /* Until the translation manager comes along, I have to do my own translation of
137  * mouse events into the proper routines. */
138 
139 typedef enum {NORMAL, LEFTEXTENSION, RIGHTEXTENSION} EventMode;
140 
141 /*
142  * The origin of a screen is 0, 0.  Therefore, the number of rows
143  * on a screen is screen->max_row + 1, and similarly for columns.
144  */
145 
146 typedef unsigned char Char;		/* to support 8 bit chars */
147 
148 #ifdef KTERM
149 #include "gset.h" /* uses Boolean and Char */
150 #endif /* KTERM */
151 
152 #ifdef KTERM
153 typedef struct {
154 	Char gset;
155 	Char code;
156 # ifdef KTERM_COLOR
157 	unsigned short attr;
158 # else /* !KTERM_COLOR */
159 	Char attr;
160 # endif /* !KTERM_COLOR */
161 } Bchr; /* char for screen buffers */
162 typedef Bchr **ScrnBuf;
163 
164 typedef struct {
165 	Char gset;
166 	Char code;
167 } Ichr; /* char for interchanging with other processes */
168 #else /* !KTERM */
169 typedef Char **ScrnBuf;
170 #endif /* !KTERM */
171 
172 /*
173  * ANSI emulation.
174  */
175 #define INQ	0x05
176 #define	FF	0x0C			/* C0, C1 control names		*/
177 #define	LS1	0x0E
178 #define	LS0	0x0F
179 #define	CAN	0x18
180 #define	SUB	0x1A
181 #define	ESC	0x1B
182 #define US	0x1F
183 #define	DEL	0x7F
184 #define HTS     ('H'+0x40)
185 #define	SS2	0x8E
186 #define	SS3	0x8F
187 #define	DCS	0x90
188 #define	OLDID	0x9A			/* ESC Z			*/
189 #define	CSI	0x9B
190 #define	ST	0x9C
191 #define	OSC	0x9D
192 #define	PM	0x9E
193 #define	APC	0x9F
194 #define	RDEL	0xFF
195 
196 #define NMENUFONTS 9			/* entries in fontMenu */
197 
198 #define	NBOX	5			/* Number of Points in box	*/
199 #define	NPARAM	10			/* Max. parameters		*/
200 
201 #define	MINHILITE	32
202 
203 typedef struct {
204 	unsigned char	a_type;
205 	unsigned char	a_pintro;
206 	unsigned char	a_final;
207 	unsigned char	a_inters;
208 	char	a_nparam;		/* # of parameters		*/
209 	char	a_dflt[NPARAM];		/* Default value flags		*/
210 	short	a_param[NPARAM];	/* Parameters			*/
211 	char	a_nastyf;		/* Error flag			*/
212 } ANSI;
213 
214 typedef struct {
215 	int		row;
216 	int		col;
217 	unsigned	flags;	/* Vt100 saves graphics rendition. Ugh! */
218 	char		curgl;
219 	char		curgr;
220 #ifdef KTERM
221 	Char		gsets[4];
222 #else /* !KTERM */
223 	char		gsets[4];
224 #endif /* !KTERM */
225 } SavedCursor;
226 
227 #ifndef KTERM_NOTEK
228 #define TEK_FONT_LARGE 0
229 #define TEK_FONT_2 1
230 #define TEK_FONT_3 2
231 #define TEK_FONT_SMALL 3
232 #define	TEKNUMFONTS 4
233 
234 /* Actually there are 5 types of lines, but four are non-solid lines */
235 #define	TEKNUMLINES	4
236 
237 typedef struct {
238 	int	x;
239 	int	y;
240 	int	fontsize;
241 	int	linetype;
242 } Tmodes;
243 
244 typedef struct {
245 	int Twidth;
246 	int Theight;
247 } T_fontsize;
248 
249 typedef struct {
250 	short *bits;
251 	int x;
252 	int y;
253 	int width;
254 	int height;
255 } BitmapBits;
256 #endif /* !KTERM_NOTEK */
257 
258 #define	SAVELINES		64      /* default # lines to save      */
259 #define SCROLLLINES 1			/* default # lines to scroll    */
260 
261 #ifdef KTERM
262 # define LINESPACE	0		/* default space between lines	*/
263 #endif /* KTERM */
264 #ifdef KTERM_XIM
265 # define EUCJPLOCALE	"ja_JP.eucJP,ja_JP.ujis,ja_JP.EUC,japanese.euc,Japanese-EUC,ja,japan"
266 #endif /* KTERM_XIM */
267 
268 typedef struct {
269 /* These parameters apply to both windows */
270 	Display		*display;	/* X display for screen		*/
271 	int		respond;	/* socket for responses
272 					   (position report, etc.)	*/
273 	long		pid;		/* pid of process on far side   */
274 	int		uid;		/* user id of actual person	*/
275 	int		gid;		/* group id of actual person	*/
276 #ifdef KTERM
277 	GC		_normalGC[FCNT];
278 	GC		_reverseGC[FCNT];
279 	GC		_normalboldGC[FCNT];
280 	GC		_reverseboldGC[FCNT];
281 	GC		_cursorGC[FCNT];
282 	GC		_reversecursorGC[FCNT];
283 # define normalGC		_normalGC[fnum]
284 # define reverseGC		_reverseGC[fnum]
285 # define normalboldGC		_normalboldGC[fnum]
286 # define reverseboldGC		_reverseboldGC[fnum]
287 # define cursorGC		_cursorGC[fnum]
288 # define reversecursorGC	_reversecursorGC[fnum]
289 #else /* !KTERM */
290 	GC		normalGC;	/* normal painting		*/
291 	GC		reverseGC;	/* reverse painting		*/
292 	GC		normalboldGC;	/* normal painting, bold font	*/
293 	GC		reverseboldGC;	/* reverse painting, bold font	*/
294 	GC		cursorGC;	/* normal cursor painting	*/
295 	GC		reversecursorGC;/* reverse cursor painting	*/
296 #endif /* !KTERM */
297 	GC		cursoroutlineGC;/* for painting lines around    */
298 	Pixel		foreground;	/* foreground color		*/
299 	Pixel		cursorcolor;	/* Cursor color			*/
300 	Pixel		mousecolor;	/* Mouse color			*/
301 	Pixel		mousecolorback;	/* Mouse color background	*/
302 #ifdef KTERM_COLOR
303 #ifndef COLOR_16
304 	Pixel		textcolor[8];	/* text colors			*/
305 #else
306 	Pixel		textcolor[16];	/* text colors			*/
307 #endif
308 #endif /* KTERM_COLOR */
309 	int		border;		/* inner border			*/
310 	Cursor		arrow;		/* arrow cursor			*/
311 	unsigned short	send_mouse_pos;	/* user wants mouse transition  */
312 					/* and position information	*/
313 	int		select;		/* xterm selected		*/
314 	Boolean		visualbell;	/* visual bell mode		*/
315 	Boolean		allowSendEvents;/* SendEvent mode		*/
316 	Boolean		grabbedKbd;	/* keyboard is grabbed		*/
317 #ifdef ALLOWLOGGING
318 	int		logging;	/* logging mode			*/
319 	int		logfd;		/* file descriptor of log	*/
320 	char		*logfile;	/* log file name		*/
321 	unsigned char	*logstart;	/* current start of log buffer	*/
322 #endif
323 	int		inhibit;	/* flags for inhibiting changes	*/
324 
325 /* VT window parameters */
326 	struct {
327 		Window	window;		/* X window id			*/
328 		int	width;		/* width of columns		*/
329 		int	height;		/* height of rows		*/
330 		int	fullwidth;	/* full width of window		*/
331 		int	fullheight;	/* full height of window	*/
332 		int	f_width;	/* width of fonts in pixels	*/
333 		int	f_height;	/* height of fonts in pixels	*/
334 	} fullVwin;
335 	Cursor pointer_cursor;		/* pointer cursor in window	*/
336 
337 	/* Terminal fonts must be of the same size and of fixed width */
338 #ifdef KTERM
339 	XFontStruct	*_fnt_norm[FCNT];
340 	XFontStruct	*_fnt_bold[FCNT];
341 	XPoint		*_box[FCNT];
342 # define fnt_norm		_fnt_norm[fnum]
343 # define fnt_bold		_fnt_bold[fnum]
344 # define box			_box[fnum]
345 	int		linespace;	/* space between lines		*/
346 	int		max_ascent;
347 	int		max_descent;
348 	Pixmap		*graphics;
349 #else /* !KTERM */
350 	XFontStruct	*fnt_norm;	/* normal font of terminal	*/
351 	XFontStruct	*fnt_bold;	/* bold font of terminal	*/
352 	int		enbolden;	/* overstrike for bold font	*/
353 	XPoint		*box;		/* draw unselected cursor	*/
354 #endif /* !KTERM */
355 
356 	int		cursor_state;	/* ON or OFF			*/
357 	int		cursor_set;	/* requested state		*/
358 	int		cursor_col;	/* previous cursor column	*/
359 	int		cursor_row;	/* previous cursor row		*/
360 	int		cur_col;	/* current cursor column	*/
361 	int		cur_row;	/* current cursor row		*/
362 	int		max_col;	/* rightmost column		*/
363 	int		max_row;	/* bottom row			*/
364 	int		top_marg;	/* top line of scrolling region */
365 	int		bot_marg;	/* bottom line of  "	    "	*/
366 	Widget		scrollWidget;	/* pointer to scrollbar struct	*/
367 	int		scrollbar;	/* if > 0, width of scrollbar, and
368 						scrollbar is showing	*/
369 	int		topline;	/* line number of top, <= 0	*/
370 	int		savedlines;     /* number of lines that've been saved */
371 	int		savelines;	/* number of lines off top to save */
372 	int		scrolllines;	/* number of lines to button scroll */
373 	Boolean		scrollttyoutput; /* scroll to bottom on tty output */
374 	Boolean		scrollkey;	/* scroll to bottom on key	*/
375 
376 	ScrnBuf		buf;		/* ptr to visible screen buf (main) */
377 	ScrnBuf		allbuf;		/* screen buffer (may include
378 					   lines scrolled off top)	*/
379 	char		*sbuf_address;	/* main screen memory address   */
380 	ScrnBuf		altbuf;		/* alternate screen buffer	*/
381 	char		*abuf_address;	/* alternate screen memory address */
382 	Boolean		alternate;	/* true if using alternate buf	*/
383 	unsigned short	do_wrap;	/* true if cursor in last column
384 					    and character just output    */
385 	int		incopy;		/* 0 idle; 1 XCopyArea issued;
386 					    -1 first GraphicsExpose seen,
387 					    but last not seen		*/
388 	int		copy_src_x;	/* params from last XCopyArea ... */
389 	int		copy_src_y;
390 	unsigned int	copy_width;
391 	unsigned int	copy_height;
392 	int		copy_dest_x;
393 	int		copy_dest_y;
394 	Boolean		c132;		/* allow change to 132 columns	*/
395 	Boolean		curses;		/* kludge line wrap for more	*/
396 	Boolean		hp_ll_bc;	/* kludge HP-style ll for xdb	*/
397 	Boolean		marginbell;	/* true if margin bell on	*/
398 	int		nmarginbell;	/* columns from right margin	*/
399 	int		bellarmed;	/* cursor below bell margin	*/
400 	Boolean 	multiscroll;	/* true if multi-scroll		*/
401 	int		scrolls;	/* outstanding scroll count,
402 					    used only with multiscroll	*/
403 	SavedCursor	sc;		/* data for restore cursor	*/
404 	int		save_modes[19];	/* save dec private modes	*/
405 #ifdef STATUSLINE
406 	int	 	statusheight;	/* status line height		*/
407 	Boolean 	instatus;	/* cursor in status line	*/
408 	SavedCursor 	statussc;	/* status line restore cursor	*/
409 	Boolean 	reversestatus;	/* status line reversed		*/
410 #endif /* STATUSLINE */
411 
412 	/* Improved VT100 emulation stuff.				*/
413 #ifdef KTERM
414 	Char		gsets[4];	/* G0 through G3.		*/
415 #else /* !KTERM */
416 	char		gsets[4];	/* G0 through G3.		*/
417 #endif /* !KTERM */
418 	char		curgl;		/* Current GL setting.		*/
419 	char		curgr;		/* Current GR setting.		*/
420 	char		curss;		/* Current single shift.	*/
421 	int		scroll_amt;	/* amount to scroll		*/
422 	int		refresh_amt;	/* amount to refresh		*/
423 	Boolean		jumpscroll;	/* whether we should jumpscroll */
424 	Boolean         always_highlight; /* whether to highlight cursor */
425 
426 #ifndef KTERM_NOTEK
427 /* Tektronix window parameters */
428 	GC		TnormalGC;	/* normal painting		*/
429 	GC		TcursorGC;	/* normal cursor painting	*/
430 	Pixel		Tforeground;	/* foreground color		*/
431 	Pixel		Tbackground;	/* Background color		*/
432 	Pixel		Tcursorcolor;	/* Cursor color			*/
433 	int		Tcolor;		/* colors used			*/
434 	Boolean		Vshow;		/* VT window showing		*/
435 	Boolean		Tshow;		/* Tek window showing		*/
436 	Boolean		waitrefresh;	/* postpone refresh		*/
437 	struct {
438 		Window	window;		/* X window id			*/
439 		int	width;		/* width of columns		*/
440 		int	height;		/* height of rows		*/
441 		int	fullwidth;	/* full width of window		*/
442 		int	fullheight;	/* full height of window	*/
443 		double	tekscale;	/* scale factor Tek -> vs100	*/
444 	} fullTwin;
445 	int		xorplane;	/* z plane for inverts		*/
446 	GC		linepat[TEKNUMLINES]; /* line patterns		*/
447 	Boolean		TekEmu;		/* true if Tektronix emulation	*/
448 	int		cur_X;		/* current x			*/
449 	int		cur_Y;		/* current y			*/
450 	Tmodes		cur;		/* current tek modes		*/
451 	Tmodes		page;		/* starting tek modes on page	*/
452 	int		margin;		/* 0 -> margin 1, 1 -> margin 2	*/
453 	int		pen;		/* current Tektronix pen 0=up, 1=dn */
454 	char		*TekGIN;	/* nonzero if Tektronix GIN mode*/
455 	int		gin_terminator; /* Tek strap option */
456 #endif /* !KTERM_NOTEK */
457 
458 	int		multiClickTime;	 /* time between multiclick selects */
459 	int		bellSuppressTime; /* msecs after Bell before another allowed */
460 	Boolean		bellInProgress; /* still ringing/flashing prev bell? */
461 	char		*charClass;	/* for overriding word selection */
462 	Boolean		cutNewline;	/* whether or not line cut has \n */
463 	Boolean		cutToBeginningOfLine;  /* line cuts to BOL? */
464 #ifdef KTERM
465 	Ichr		*selection;	/* the current selection */
466 #else /* !KTERM */
467 	char		*selection;	/* the current selection */
468 #endif /* !KTERM */
469 	int		selection_size; /* size of allocated buffer */
470 	int		selection_length; /* number of significant bytes */
471 	Time		selection_time;	/* latest event timestamp */
472 	int		startHRow, startHCol, /* highlighted text */
473 			endHRow, endHCol,
474 			startHCoord, endHCoord;
475 	Atom*		selection_atoms; /* which selections we own */
476 	Cardinal	sel_atoms_size;	/*  how many atoms allocated */
477 	Cardinal	selection_count; /* how many atoms in use */
478 	Boolean		input_eight_bits;/* use 8th bit instead of ESC prefix */
479 	Boolean		output_eight_bits; /* honor all bits or strip */
480 	Pixmap		menu_item_bitmap;	/* mask for checking items */
481 #ifdef KTERM_NOTEK
482 	Widget		mainMenu, vtMenu, fontMenu;
483 #else /* !KTERM_NOTEK */
484 	Widget		mainMenu, vtMenu, tekMenu, fontMenu;
485 #endif /* !KTERM_NOTEK */
486 #ifdef KTERM
487 	Boolean		dynamic_font_load; /* load fonts on demand */
488 	char*		menu_font_list[NMENUFONTS];
489 	char*		menu_bfont_list[NMENUFONTS];
490 	char*		_menu_font_names[FCNT][NMENUFONTS];
491 	char*		_menu_bfont_names[FCNT][NMENUFONTS];
492 # define menu_font_names	_menu_font_names[fnum]
493 # define menu_bfont_names	_menu_bfont_names[fnum]
494 #else /* !KTERM */
495 	char*		menu_font_names[NMENUFONTS];
496 #endif /* !KTERM */
497 	int		menu_font_number;
498 	XIC		xic;
499 #ifdef KTERM_XIM
500 	XIMStyle	xicstyle;
501 	XFontSet	xicfontset;
502 	Boolean		imregistered;
503 #ifdef INTHEFUTURE
504 	Boolean		imserverdied;
505 	char		**modifier_list;
506 #endif
507 #endif /* KTERM_XIM */
508 } TScreen;
509 
510 #ifndef KTERM_NOTEK
511 typedef struct _TekPart {
512     XFontStruct *Tfont[TEKNUMFONTS];
513     int		tobaseline[TEKNUMFONTS]; /* top to baseline for each font */
514     char	*initial_font;		/* large, 2, 3, small */
515     char	*gin_terminator_str;	/* ginTerminator resource */
516 } TekPart;
517 #endif /* !KTERM_NOTEK */
518 
519 
520 
521 /* meaning of bits in screen.select flag */
522 #define	INWINDOW	01	/* the mouse is in one of the windows */
523 #define	FOCUS		02	/* one of the windows is the focus window */
524 
525 #define MULTICLICKTIME 250	/* milliseconds */
526 
527 typedef struct
528 {
529 	unsigned	flags;
530 } TKeyboard;
531 
532 typedef struct _Misc {
533     char *geo_metry;
534     char *T_geometry;
535 #ifndef KTERM
536     char *f_n;
537     char *f_b;
538 #endif /* !KTERM */
539 #ifdef ALLOWLOGGING
540     Boolean log_on;
541 #endif
542     Boolean login_shell;
543     Boolean re_verse;
544     int resizeGravity;
545     Boolean reverseWrap;
546     Boolean autoWrap;
547     Boolean logInhibit;
548     Boolean signalInhibit;
549 #ifndef KTERM_NOTEK
550     Boolean tekInhibit;
551 #endif /* !KTERM_NOTEK */
552     Boolean scrollbar;
553     Boolean titeInhibit;
554 #ifndef KTERM_NOTEK
555     Boolean tekSmall;	/* start tek window in small size */
556 #endif /* !KTERM_NOTEK */
557     Boolean appcursorDefault;
558     Boolean appkeypadDefault;
559 #ifdef KTERM_KANJIMODE
560     char *k_m;
561 #endif /* KTERM_KANJIMODE */
562 #ifdef KTERM_XIM
563     char* eucjp_locale;
564 #endif /* !KTERM_XIM */
565     char* input_method;
566     char* preedit_type;
567     Boolean open_im;
568     Boolean shared_ic;
569 #ifdef STATUSLINE
570     Boolean statusline;
571     Boolean statusnormal;
572 #endif /* STATUSLINE */
573 } Misc;
574 
575 #ifdef KTERM_NOTEK
576 typedef struct {int foo;} XtermClassPart;
577 #else /* !KTERM_NOTEK */
578 typedef struct {int foo;} XtermClassPart, TekClassPart;
579 #endif /* !KTERM_NOTEK */
580 
581 typedef struct _XtermClassRec {
582     CoreClassPart  core_class;
583     XtermClassPart xterm_class;
584 } XtermClassRec;
585 
586 #ifndef KTERM_NOTEK
587 typedef struct _TekClassRec {
588     CoreClassPart core_class;
589     TekClassPart tek_class;
590 } TekClassRec;
591 #endif /* !KTERM_NOTEK */
592 
593 /* define masks for flags */
594 #define CAPS_LOCK	0x01
595 #define KYPD_APL	0x02
596 #define CURSOR_APL	0x04
597 
598 
599 #define N_MARGINBELL	10
600 #define MAX_TABS	320
601 #define TAB_ARRAY_SIZE	10	/* number of ints to provide MAX_TABS bits */
602 
603 typedef unsigned Tabs [TAB_ARRAY_SIZE];
604 
605 typedef struct _XtermWidgetRec {
606     CorePart	core;
607     TKeyboard	keyboard;	/* terminal keyboard		*/
608     TScreen	screen;		/* terminal screen		*/
609     unsigned	flags;		/* mode flags			*/
610     unsigned	initflags;	/* initial mode flags		*/
611     Tabs	tabs;		/* tabstops of the terminal	*/
612     Misc	misc;		/* miscellaneous parameters	*/
613 } XtermWidgetRec, *XtermWidget;
614 
615 #ifndef KTERM_NOTEK
616 typedef struct _TekWidgetRec {
617     CorePart core;
618     TekPart tek;
619 } TekWidgetRec, *TekWidget;
620 #endif /* !KTERM_NOTEK */
621 
622 #define BUF_SIZE 4096
623 
624 /*
625  * terminal flags
626  * There are actually two namespaces mixed together here.
627  * One is the set of flags that can go in screen->buf attributes
628  * and which must fit in a char.
629  * The other is the global setting stored in
630  * term->flags and screen->save_modes.  This need only fit in an unsigned.
631  */
632 
633 #ifdef KTERM_COLOR
634 #define	ATTRIBUTES	0xff07	/* mask: user-visible attributes */
635 #else /* !KTERM_COLOR */
636 #define	ATTRIBUTES	0x07	/* mask: user-visible attributes */
637 #endif /* !KTERM_COLOR */
638 /* global flags and character flags (visible character attributes) */
639 #define INVERSE		0x01	/* invert the characters to be output */
640 #define UNDERLINE	0x02	/* true if underlining */
641 #define BOLD		0x04
642 /* character flags (internal attributes) */
643 #define LINEWRAPPED	0x08	/* used on the first character in a
644 				 * line to indicate that it wraps onto
645 				 * the next line so we can tell the
646 				 * difference between lines that have
647 				 * wrapped around and lines that have
648 				 * ended naturally with a CR at column
649 				 * max_col.
650 				 */
651 #define CHARDRAWN	0x10    /* a character has been drawn here on the
652 				   screen.  Used to distinguish blanks from
653 				   empty parts of the screen when selecting */
654 #ifdef KTERM_COLOR
655 #define FORECOLORED	0x0800
656 #define FORECOLORMASK	0x0700
657 #define FORECOLOR(c)	((c) << 8)
658 #define FORECOLORNUM(f)	(((f) & FORECOLORMASK) >> 8)
659 #define BACKCOLORED	0x8000
660 #define BACKCOLORMASK	0x7000
661 #define BACKCOLOR(c)	((c) << 12)
662 #define BACKCOLORNUM(f)	(((f) & BACKCOLORMASK) >> 12)
663 #ifdef COLOR_16
664 #undef FORECOLORNUM
665 #undef BACKCOLORNUM
666 #define FORECOLORNUM(f)	((((f) & FORECOLORMASK) >> 8) + (((f) & BOLD)?0:8))
667 #define BACKCOLORNUM(f)	((((f) & BACKCOLORMASK) >> 12) + (((f) & BOLD)?8:8))
668 #endif
669 #endif /* KTERM_COLOR */
670 /* global flags */
671 #ifdef KTERM
672 #define WRAPAROUND	0x40000		/* true if auto wraparound mode */
673 #define	REVERSEWRAP	0x80000		/* true if reverse wraparound mode */
674 #define REVERSE_VIDEO	0x100000	/* true if screen white on black */
675 #define LINEFEED	0x200000	/* true if in auto linefeed mode */
676 #define ORIGIN		0x400000	/* true if in origin mode */
677 #define INSERT		0x800000	/* true if in insert mode */
678 #define SMOOTHSCROLL	0x1000000	/* true if in smooth scroll mode */
679 #define IN132COLUMNS	0x2000000	/* true if in 132 column mode */
680 #ifdef KTERM_KANJIMODE
681 #define	EUC_KANJI	0x4000000	/* true if in EUC mode */
682 #define	SJIS_KANJI	0x8000000	/* true if in SJIS mode */
683 #define UTF8_KANJI      0x10000000      /* true if in UTF8 mode */
684 #endif /* KTERM_KANJIMODE */
685 #else /* !KTERM */
686 #define WRAPAROUND	0x400	/* true if auto wraparound mode */
687 #define	REVERSEWRAP	0x800	/* true if reverse wraparound mode */
688 #define REVERSE_VIDEO	0x1000	/* true if screen white on black */
689 #define LINEFEED	0x2000	/* true if in auto linefeed mode */
690 #define ORIGIN		0x4000	/* true if in origin mode */
691 #define INSERT		0x8000	/* true if in insert mode */
692 #define SMOOTHSCROLL	0x10000	/* true if in smooth scroll mode */
693 #define IN132COLUMNS	0x20000	/* true if in 132 column mode */
694 #endif /* !KTERM */
695 
696 
697 #define VWindow(screen)		(screen->fullVwin.window)
698 #define VShellWindow		term->core.parent->core.window
699 #define TextWindow(screen)      (screen->fullVwin.window)
700 #ifndef KTERM_NOTEK
701 #define TWindow(screen)		(screen->fullTwin.window)
702 #define TShellWindow		tekWidget->core.parent->core.window
703 #endif /* !KTERM_NOTEK */
704 #define Width(screen)		(screen->fullVwin.width)
705 #define Height(screen)		(screen->fullVwin.height)
706 #define FullWidth(screen)	(screen->fullVwin.fullwidth)
707 #define FullHeight(screen)	(screen->fullVwin.fullheight)
708 #define FontWidth(screen)	(screen->fullVwin.f_width)
709 #ifdef KTERM
710 #define FontHeight(screen)	(screen->fullVwin.f_height + screen->linespace)
711 #else /* !KTERM */
712 #define FontHeight(screen)	(screen->fullVwin.f_height)
713 #endif /* !KTERM */
714 #ifndef KTERM_NOTEK
715 #define TWidth(screen)		(screen->fullTwin.width)
716 #define THeight(screen)		(screen->fullTwin.height)
717 #define TFullWidth(screen)	(screen->fullTwin.fullwidth)
718 #define TFullHeight(screen)	(screen->fullTwin.fullheight)
719 #define TekScale(screen)	(screen->fullTwin.tekscale)
720 #endif /* !KTERM_NOTEK */
721 
722 #define CursorX(screen,col) ((col) * FontWidth(screen) + screen->border \
723 			+ screen->scrollbar)
724 #ifdef STATUSLINE
725 #define CursorY(screen,row) ((row)>screen->max_row \
726 	? (row) * FontHeight(screen) + screen->border * 2 + 1 \
727 	: ((row) - screen->topline) * FontHeight(screen) + screen->border)
728 #else /* !STATUSLINE */
729 #define CursorY(screen,row) ((((row) - screen->topline) * FontHeight(screen)) \
730 			+ screen->border)
731 #endif /* !STATUSLINE */
732 
733 #define	TWINDOWEVENTS	(KeyPressMask | ExposureMask | ButtonPressMask |\
734 			 ButtonReleaseMask | StructureNotifyMask |\
735 			 EnterWindowMask | LeaveWindowMask | FocusChangeMask)
736 
737 #define	WINDOWEVENTS	(TWINDOWEVENTS | PointerMotionMask)
738 
739 
740 #ifndef KTERM_NOTEK
741 #define TEK_LINK_BLOCK_SIZE 1024
742 
743 typedef struct Tek_Link
744 {
745 	struct Tek_Link	*next;	/* pointer to next TekLink in list
746 				   NULL <=> this is last TekLink */
747 	short fontsize;		/* character size, 0-3 */
748 	short count;		/* number of chars in data */
749 	char *ptr;		/* current pointer into data */
750 	char data [TEK_LINK_BLOCK_SIZE];
751 } TekLink;
752 #endif /* !KTERM_NOTEK */
753 
754 /* flags for cursors */
755 #define	OFF		0
756 #define	ON		1
757 #define	CLEAR		0
758 #define	TOGGLE		1
759 
760 /* flags for inhibit */
761 #ifdef ALLOWLOGGING
762 #define	I_LOG		0x01
763 #endif
764 #define	I_SIGNAL	0x02
765 #ifndef KTERM_NOTEK
766 #define	I_TEK		0x04
767 #endif /* !KTERM_NOTEK */
768 
769 extern Cursor make_colored_cursor();
770 extern int GetBytesAvailable();
771 extern void first_map_occurred();
772 extern int kill_process_group();
773