1 /*- 2 * Copyright (c) 1988, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)terminal.h 8.1 (Berkeley) 06/06/93 8 */ 9 10 #define INCLUDED_TERMINAL 11 12 /* 13 * In the situation where we have a copy of the terminal screen in front 14 * of us, here are some macros to deal with them. 15 */ 16 17 #define TermAttributes(x) (TermIsStartField(x)? GetTerminal(x)&0xff : \ 18 GetTerminal(WhereTermAttrByte(x))&0xff) 19 #define TermIsStartField(x) ((GetTerminal(x)&ATTR_MASK) == ATTR_MASK) 20 #define TermNewField(p,a) SetTerminal(p, (a)|ATTR_MASK) 21 #define TermDeleteField(p) SetTerminal(p, 0) 22 #define TermIsNonDisplay(x) \ 23 ((TermAttributes(x)&ATTR_DSPD_MASK) == ATTR_DSPD_NONDISPLAY) 24 #define TermIsHighlighted(x) \ 25 (((TermAttributes(x)&ATTR_DSPD_MASK) == ATTR_DSPD_HIGH) \ 26 && !TermIsStartField(x)) 27 28 #define TerminalCharacterAttr(c,p,a) (IsNonDisplayAttr(a) ? ' ':c) 29 #define TerminalCharacter(c,p) TerminalCharacterAttr(c,p,FieldAttributes(p)) 30 31 /* 32 * Is the screen formatted? Some algorithms change depending 33 * on whether there are any attribute bytes lying around. 34 */ 35 #define TerminalFormattedScreen() \ 36 ((WhereTermAttrByte(0) != 0) || ((GetTerminal(0)&ATTR_MASK) == ATTR_MASK)) 37 38 #define NeedToRedisplayFields(p) ((TermIsNonDisplay(p) != IsNonDisplay(p)) || \ 39 (TermIsHighlighted(p) != IsHighlighted(p))) 40 #define NeedToRedisplayFieldsAttr(p,c) ( \ 41 (TermIsNonDisplay(p) != IsNonDisplayAttr(c)) || \ 42 (TermIsHighlighted(p) != IsHighlightedAttr(c))) 43 44 #define NotVisuallyCompatibleAttributes(p,c,d) ( \ 45 (IsNonDisplayAttr(c) != IsNonDisplayAttr(d)) || \ 46 (IsHighlightedAttr(c) != IsHighlightedAttr(d))) 47 48 #define NeedToRedisplayAttr(c,p,a) \ 49 ((c != GetTerminal(p)) || NeedToRedisplayFieldsAttr(p,a)) 50 #define NeedToRedisplay(c,p) NeedToRedisplayAttr(c,p,FieldAttributes(p)) 51 52 53 #define GetTerminal(i) GetGeneric(i, Terminal) 54 #define GetTerminalPointer(p) GetGenericPointer(p) 55 #define SetTerminal(i,c) SetGeneric(i,c,Terminal) 56