1 /* $NetBSD: terminal.h,v 1.4 1998/03/04 13:16:09 christos Exp $ */
4 * Copyright (c) 1988 The Regents of the University of California.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * from: @(#)terminal.h 4.3 (Berkeley) 4/26/91
34 #define INCLUDED_TERMINAL
37 * In the situation where we have a copy of the terminal screen in front
38 * of us, here are some macros to deal with them.
41 #define TermAttributes(x) (TermIsStartField(x)? GetTerminal(x)&0xff : \
42 GetTerminal(WhereTermAttrByte(x))&0xff)
43 #define TermIsStartField(x) ((GetTerminal(x)&ATTR_MASK) == ATTR_MASK)
44 #define TermNewField(p,a) SetTerminal(p, (a)|ATTR_MASK)
45 #define TermDeleteField(p) SetTerminal(p, 0)
46 #define TermIsNonDisplay(x) \
47 ((TermAttributes(x)&ATTR_DSPD_MASK) == ATTR_DSPD_NONDISPLAY)
48 #define TermIsHighlighted(x) \
49 (((TermAttributes(x)&ATTR_DSPD_MASK) == ATTR_DSPD_HIGH) \
50 && !TermIsStartField(x))
52 #define TerminalCharacterAttr(c,p,a) (IsNonDisplayAttr(a) ? ' ':c)
53 #define TerminalCharacter(c,p) TerminalCharacterAttr(c,p,FieldAttributes(p))
56 * Is the screen formatted? Some algorithms change depending
57 * on whether there are any attribute bytes lying around.
59 #define TerminalFormattedScreen() \
60 ((WhereTermAttrByte(0) != 0) || ((GetTerminal(0)&ATTR_MASK) == ATTR_MASK))
62 #define NeedToRedisplayFields(p) ((TermIsNonDisplay(p) != IsNonDisplay(p)) || \
63 (TermIsHighlighted(p) != IsHighlighted(p)))
64 #define NeedToRedisplayFieldsAttr(p,c) ( \
65 (TermIsNonDisplay(p) != IsNonDisplayAttr(c)) || \
66 (TermIsHighlighted(p) != IsHighlightedAttr(c)))
68 #define NotVisuallyCompatibleAttributes(p,c,d) ( \
69 (IsNonDisplayAttr(c) != IsNonDisplayAttr(d)) || \
70 (IsHighlightedAttr(c) != IsHighlightedAttr(d)))
72 #define NeedToRedisplayAttr(c,p,a) \
73 ((c != GetTerminal(p)) || NeedToRedisplayFieldsAttr(p,a))
74 #define NeedToRedisplay(c,p) NeedToRedisplayAttr(c,p,FieldAttributes(p))
77 #define GetTerminal(i) GetGeneric(i, Terminal)
78 #define GetTerminalPointer(p) GetGenericPointer(p)
79 #define SetTerminal(i,c) SetGeneric(i,c,Terminal)