1 /*
2  * @(#)terminal.h	1.6 (Berkeley) 07/17/87
3  */
4 
5 #define	INCLUDED_TERMINAL
6 
7 /*
8  * In the situation where we have a copy of the terminal screen in front
9  * of us, here are some macros to deal with them.
10  */
11 
12 #define TermAttributes(x)	(TermIsStartField(x)? GetTerminal(x)&0xff : \
13 				    GetTerminal(WhereTermAttrByte(x))&0xff)
14 #define TermIsStartField(x)	((GetTerminal(x)&ATTR_MASK) == ATTR_MASK)
15 #define TermNewField(p,a)	SetTerminal(p, (a)|ATTR_MASK)
16 #define TermDeleteField(p)	SetTerminal(p, 0)
17 #define TermIsNonDisplay(x)	\
18 		    ((TermAttributes(x)&ATTR_DSPD_MASK) == ATTR_DSPD_NONDISPLAY)
19 #define TermIsHighlighted(x) \
20 		(((TermAttributes(x)&ATTR_DSPD_MASK) == ATTR_DSPD_HIGH) \
21 				    && !TermIsStartField(x))
22 
23 #define TerminalCharacterAttr(c,p,a)	(IsNonDisplayAttr(a) ? ' ':c)
24 #define TerminalCharacter(c,p)	TerminalCharacterAttr(c,p,FieldAttributes(p))
25 
26 #define NeedToRedisplayFields(p) ((TermIsNonDisplay(p) != IsNonDisplay(p)) || \
27 				(TermIsHighlighted(p) != IsHighlighted(p)))
28 #define NeedToRedisplayFieldsAttr(p,c) ( \
29 			(TermIsNonDisplay(p) != IsNonDisplayAttr(c)) || \
30 			(TermIsHighlighted(p) != IsHighlightedAttr(c)))
31 
32 #define NotVisuallyCompatibleAttributes(p,c,d) ( \
33 			(IsNonDisplayAttr(c) != IsNonDisplayAttr(d)) || \
34 			(IsHighlightedAttr(c) != IsHighlightedAttr(d)))
35 
36 #define NeedToRedisplayAttr(c,p,a) \
37 			((c != GetTerminal(p)) || NeedToRedisplayFieldsAttr(p,a))
38 #define NeedToRedisplay(c,p)	NeedToRedisplayAttr(c,p,FieldAttributes(p))
39 
40 
41 #define GetTerminal(i)		GetGeneric(i, Terminal)
42 #define GetTerminalPointer(p)	GetGenericPointer(p)
43 #define SetTerminal(i,c)	SetGeneric(i,c,Terminal)
44