Bring back --with-sys-screenrc configure flag.
[screen-lua.git] / src / image.h
blobc10594932386f963fbda9ec81feeef91c5157838
1 /* Copyright (c) 2008, 2009
2 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
3 * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
4 * Micah Cowan (micah@cowan.name)
5 * Sadrul Habib Chowdhury (sadrul@users.sourceforge.net)
6 * Copyright (c) 1993-2002, 2003, 2005, 2006, 2007
7 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
8 * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
9 * Copyright (c) 1987 Oliver Laumann
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3, or (at your option)
14 * any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program (see the file COPYING); if not, see
23 * http://www.gnu.org/licenses/, or contact Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
26 ****************************************************************
27 * $Id$ GNU
31 #undef IFFONT
32 #undef IFCOLOR
34 #ifdef FONT
35 # define IFFONT(x) x
36 #else
37 # define IFFONT(x)
38 #endif
40 #ifdef COLOR
41 # define IFCOLOR(x) x
42 #else
43 # define IFCOLOR(x)
44 #endif
46 #if defined(COLOR) && defined(COLORS16) && defined(COLORS256)
47 # define IFCOLORX(x) x
48 #else
49 # define IFCOLORX(x)
50 #endif
52 #ifdef DW_CHARS
53 # define IFDWCHAR(x) x
54 #else
55 # define IFDWCHAR(x)
56 #endif
58 struct mchar {
59 unsigned char image;
60 unsigned char attr;
61 IFFONT( unsigned char font; )
62 IFCOLOR( unsigned char color; )
63 IFCOLORX(unsigned char colorx; )
64 IFDWCHAR(unsigned char mbcs; )
67 struct mline {
68 unsigned char *image;
69 unsigned char *attr;
70 IFFONT( unsigned char *font; )
71 IFCOLOR( unsigned char *color; )
72 IFCOLORX(unsigned char *colorx; )
77 #define save_mline(ml, n) do { \
78 bcopy((char *)(ml)->image, (char *)mline_old.image, (n)); \
79 bcopy((char *)(ml)->attr, (char *)mline_old.attr, (n)); \
80 IFFONT( bcopy((char *)(ml)->font, (char *)mline_old.font, (n)); ) \
81 IFCOLOR( bcopy((char *)(ml)->color, (char *)mline_old.color, (n)); ) \
82 IFCOLORX(bcopy((char *)(ml)->colorx, (char *)mline_old.colorx, (n)); ) \
83 } while (0)
85 #define bcopy_mline(ml, xf, xt, n) do { \
86 bcopy((char *)(ml)->image + (xf), (char *)(ml)->image + (xt), (n)); \
87 bcopy((char *)(ml)->attr + (xf), (char *)(ml)->attr + (xt), (n)); \
88 IFFONT( bcopy((char *)(ml)->font + (xf), (char *)(ml)->font + (xt), (n)); ) \
89 IFCOLOR( bcopy((char *)(ml)->color + (xf), (char *)(ml)->color + (xt), (n)); ) \
90 IFCOLORX(bcopy((char *)(ml)->colorx + (xf), (char *)(ml)->colorx + (xt), (n));) \
91 } while (0)
93 #define clear_mline(ml, x, n) do { \
94 bclear((char *)(ml)->image + (x), (n)); \
95 if ((ml)->attr != null) bzero((char *)(ml)->attr + (x), (n)); \
96 IFFONT( if ((ml)->font != null) bzero((char *)(ml)->font + (x), (n)); ) \
97 IFCOLOR( if ((ml)->color!= null) bzero((char *)(ml)->color + (x), (n)); ) \
98 IFCOLORX(if ((ml)->colorx!= null) bzero((char *)(ml)->colorx + (x), (n)); ) \
99 } while (0)
101 #define cmp_mline(ml1, ml2, x) ( \
102 (ml1)->image[x] == (ml2)->image[x] \
103 && (ml1)->attr[x] == (ml2)->attr[x] \
104 IFFONT( && (ml1)->font[x] == (ml2)->font[x] ) \
105 IFCOLOR( && (ml1)->color[x] == (ml2)->color[x] ) \
106 IFCOLORX(&& (ml1)->colorx[x] == (ml2)->colorx[x] ) \
109 #define cmp_mchar(mc1, mc2) ( \
110 (mc1)->image == (mc2)->image \
111 && (mc1)->attr == (mc2)->attr \
112 IFFONT( && (mc1)->font == (mc2)->font ) \
113 IFCOLOR( && (mc1)->color == (mc2)->color ) \
114 IFCOLORX(&& (mc1)->colorx == (mc2)->colorx ) \
117 #define cmp_mchar_mline(mc, ml, x) ( \
118 (mc)->image == (ml)->image[x] \
119 && (mc)->attr == (ml)->attr[x] \
120 IFFONT( && (mc)->font == (ml)->font[x] ) \
121 IFCOLOR( && (mc)->color == (ml)->color[x] ) \
122 IFCOLORX(&& (mc)->colorx == (ml)->colorx[x] ) \
125 #define copy_mchar2mline(mc, ml, x) do { \
126 (ml)->image[x] = (mc)->image; \
127 (ml)->attr[x] = (mc)->attr; \
128 IFFONT( (ml)->font[x] = (mc)->font; ) \
129 IFCOLOR( (ml)->color[x] = (mc)->color; ) \
130 IFCOLORX((ml)->colorx[x] = (mc)->colorx; ) \
131 } while (0)
133 #define copy_mline2mchar(mc, ml, x) do { \
134 (mc)->image = (ml)->image[x]; \
135 (mc)->attr = (ml)->attr[x]; \
136 IFFONT( (mc)->font = (ml)->font[x]; ) \
137 IFCOLOR( (mc)->color = (ml)->color[x]; ) \
138 IFCOLORX((mc)->colorx = (ml)->colorx[x]; ) \
139 IFDWCHAR((mc)->mbcs = 0; ) \
140 } while (0)
142 #ifdef COLOR
143 # ifdef COLORS16
144 # ifdef COLORS256
145 # define rend_getbg(mc) (((mc)->color & 0xf0) >> 4 | ((mc)->attr & A_BBG ? 0x100 : 0) | ((mc)->colorx & 0xf0))
146 # define rend_setbg(mc, c) ((mc)->color = ((mc)->color & 0x0f) | (c << 4 & 0xf0), (mc)->colorx = ((mc)->colorx & 0x0f) | (c & 0xf0), (mc)->attr = ((mc)->attr | A_BBG) ^ (c & 0x100 ? 0 : A_BBG))
147 # define rend_getfg(mc) (((mc)->color & 0x0f) | ((mc)->attr & A_BFG ? 0x100 : 0) | (((mc)->colorx & 0x0f) << 4))
148 # define rend_setfg(mc, c) ((mc)->color = ((mc)->color & 0xf0) | (c & 0x0f), (mc)->colorx = ((mc)->colorx & 0xf0) | ((c & 0xf0) >> 4), (mc)->attr = ((mc)->attr | A_BFG) ^ (c & 0x100 ? 0 : A_BFG))
149 # define rend_setdefault(mc) ((mc)->color = (mc)->colorx = 0, (mc)->attr &= ~(A_BBG|A_BFG))
150 # else
151 # define rend_getbg(mc) (((mc)->color & 0xf0) >> 4 | ((mc)->attr & A_BBG ? 0x100 : 0))
152 # define rend_setbg(mc, c) ((mc)->color = ((mc)->color & 0x0f) | (c << 4 & 0xf0), (mc)->attr = ((mc)->attr | A_BBG) ^ (c & 0x100 ? 0 : A_BBG))
153 # define rend_getfg(mc) (((mc)->color & 0x0f) | ((mc)->attr & A_BFG ? 0x100 : 0))
154 # define rend_setfg(mc, c) ((mc)->color = ((mc)->color & 0xf0) | (c & 0x0f), (mc)->attr = ((mc)->attr | A_BFG) ^ (c & 0x100 ? 0 : A_BFG))
155 # define rend_setdefault(mc) ((mc)->color = 0, (mc)->attr &= ~(A_BBG|A_BFG))
156 # endif
157 # define coli2e(c) ((((c) & 0x1f8) == 0x108 ? (c) ^ 0x108 : (c & 0xff)) ^ 9)
158 # define cole2i(c) ((c) >= 8 && (c) < 16 ? (c) ^ 0x109 : (c) ^ 9)
159 # else
160 # define rend_getbg(mc) (((mc)->color & 0xf0) >> 4)
161 # define rend_setbg(mc, c) ((mc)->color = ((mc)->color & 0x0f) | (c << 4 & 0xf0))
162 # define rend_getfg(mc) ((mc)->color & 0x0f)
163 # define rend_setfg(mc, c) ((mc)->color = ((mc)->color & 0xf0) | (c & 0x0f))
164 # define rend_setdefault(mc) ((mc)->color = 0)
165 # define coli2e(c) ((c) ^ 9)
166 # define cole2i(c) ((c) ^ 9)
167 # endif
168 #endif
170 enum
172 REND_BELL = 0,
173 REND_MONITOR,
174 REND_SILENCE,
175 NUM_RENDS