aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim F. Storm2004-02-13 23:28:52 +0000
committerKim F. Storm2004-02-13 23:28:52 +0000
commit0881a0fd1488ffb9f916b24d9eecb5f95d758de0 (patch)
tree52743b415101a6e3d89c1c0e7323194747c3b2cf /src
parentdcd0c64591a4cd97cb5a23dea2bd1b12bacdbce7 (diff)
downloademacs-0881a0fd1488ffb9f916b24d9eecb5f95d758de0.tar.gz
emacs-0881a0fd1488ffb9f916b24d9eecb5f95d758de0.zip
(struct fringe_bitmap): Change member bits from char to
short to facilitate 16 bits wide bitmaps. Modify all standard bitmaps accordingly. (BYTES_PER_BITMAP_ROW, STANDARD_BITMAP_HEIGHT): New macros. (FRBITS): Use STANDARD_BITMAP_HEIGHT instead of just sizeof. (draw_fringe_bitmap): Ditto. (init_fringe_bitmap) [MAC_OS]: Don't bitswap. (init_fringe_bitmap) [HAVE_X_WINDOWS]: Enhance bitswapping to handle up to 16 bits wide bitmaps. (Fdefine_fringe_bitmap): Doc fix. Handle wider bitmaps.
Diffstat (limited to 'src')
-rw-r--r--src/fringe.c120
1 files changed, 73 insertions, 47 deletions
diff --git a/src/fringe.c b/src/fringe.c
index f6028d44dc8..0d05e15da32 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -73,7 +73,7 @@ enum fringe_bitmap_align
73 73
74struct fringe_bitmap 74struct fringe_bitmap
75{ 75{
76 unsigned char *bits; 76 unsigned short *bits;
77 unsigned height : 8; 77 unsigned height : 8;
78 unsigned width : 8; 78 unsigned width : 8;
79 unsigned period : 8; 79 unsigned period : 8;
@@ -99,7 +99,7 @@ struct fringe_bitmap
99 ...xx... 99 ...xx...
100 ...xx... 100 ...xx...
101*/ 101*/
102static unsigned char unknown_bits[] = { 102static unsigned short unknown_bits[] = {
103 0x3c, 0x7e, 0x7e, 0x0c, 0x18, 0x18, 0x00, 0x18, 0x18}; 103 0x3c, 0x7e, 0x7e, 0x0c, 0x18, 0x18, 0x00, 0x18, 0x18};
104 104
105/* An arrow like this: `<-'. */ 105/* An arrow like this: `<-'. */
@@ -113,7 +113,7 @@ static unsigned char unknown_bits[] = {
113 ..xx.... 113 ..xx....
114 ...xx... 114 ...xx...
115*/ 115*/
116static unsigned char left_arrow_bits[] = { 116static unsigned short left_arrow_bits[] = {
117 0x18, 0x30, 0x60, 0xfc, 0xfc, 0x60, 0x30, 0x18}; 117 0x18, 0x30, 0x60, 0xfc, 0xfc, 0x60, 0x30, 0x18};
118 118
119 119
@@ -128,7 +128,7 @@ static unsigned char left_arrow_bits[] = {
128 ....xx.. 128 ....xx..
129 ...xx... 129 ...xx...
130*/ 130*/
131static unsigned char right_arrow_bits[] = { 131static unsigned short right_arrow_bits[] = {
132 0x18, 0x0c, 0x06, 0x3f, 0x3f, 0x06, 0x0c, 0x18}; 132 0x18, 0x0c, 0x06, 0x3f, 0x3f, 0x06, 0x0c, 0x18};
133 133
134 134
@@ -143,7 +143,7 @@ static unsigned char right_arrow_bits[] = {
143 ...xx... 143 ...xx...
144 ...xx... 144 ...xx...
145*/ 145*/
146static unsigned char up_arrow_bits[] = { 146static unsigned short up_arrow_bits[] = {
147 0x18, 0x3c, 0x7e, 0xff, 0x18, 0x18, 0x18, 0x18}; 147 0x18, 0x3c, 0x7e, 0xff, 0x18, 0x18, 0x18, 0x18};
148 148
149 149
@@ -158,7 +158,7 @@ static unsigned char up_arrow_bits[] = {
158 ..xxxx.. 158 ..xxxx..
159 ...xx... 159 ...xx...
160*/ 160*/
161static unsigned char down_arrow_bits[] = { 161static unsigned short down_arrow_bits[] = {
162 0x18, 0x18, 0x18, 0x18, 0xff, 0x7e, 0x3c, 0x18}; 162 0x18, 0x18, 0x18, 0x18, 0xff, 0x7e, 0x3c, 0x18};
163 163
164/* Marker for continued lines. */ 164/* Marker for continued lines. */
@@ -172,7 +172,7 @@ static unsigned char down_arrow_bits[] = {
172 ..xxxx.. 172 ..xxxx..
173 ..xxxxx. 173 ..xxxxx.
174*/ 174*/
175static unsigned char continued_bits[] = { 175static unsigned short continued_bits[] = {
176 0x3c, 0x3e, 0x03, 0x27, 0x3f, 0x3e, 0x3c, 0x3e}; 176 0x3c, 0x3e, 0x03, 0x27, 0x3f, 0x3e, 0x3c, 0x3e};
177 177
178/* Marker for continuation lines. */ 178/* Marker for continuation lines. */
@@ -186,7 +186,7 @@ static unsigned char continued_bits[] = {
186 ..xxxx.. 186 ..xxxx..
187 .xxxxx.. 187 .xxxxx..
188*/ 188*/
189static unsigned char continuation_bits[] = { 189static unsigned short continuation_bits[] = {
190 0x3c, 0x7c, 0xc0, 0xe4, 0xfc, 0x7c, 0x3c, 0x7c}; 190 0x3c, 0x7c, 0xc0, 0xe4, 0xfc, 0x7c, 0x3c, 0x7c};
191 191
192/* Overlay arrow bitmap. A triangular arrow. */ 192/* Overlay arrow bitmap. A triangular arrow. */
@@ -200,7 +200,7 @@ static unsigned char continuation_bits[] = {
200 xxxx.... 200 xxxx....
201 xx...... 201 xx......
202*/ 202*/
203static unsigned char ov_bits[] = { 203static unsigned short ov_bits[] = {
204 0xc0, 0xf0, 0xf8, 0xfc, 0xfc, 0xf8, 0xf0, 0xc0}; 204 0xc0, 0xf0, 0xf8, 0xfc, 0xfc, 0xf8, 0xf0, 0xc0};
205 205
206#if 0 206#if 0
@@ -215,7 +215,7 @@ static unsigned char ov_bits[] = {
215 ....xxxx 215 ....xxxx
216 ......xx 216 ......xx
217*/ 217*/
218static unsigned char rev_ov_bits[] = { 218static unsigned short rev_ov_bits[] = {
219 0x03, 0x0f, 0x1f, 0x3f, 0x3f, 0x1f, 0x0f, 0x03}; 219 0x03, 0x0f, 0x1f, 0x3f, 0x3f, 0x1f, 0x0f, 0x03};
220#endif 220#endif
221 221
@@ -230,7 +230,7 @@ static unsigned char rev_ov_bits[] = {
230 xx...... 230 xx......
231 ........ 231 ........
232*/ 232*/
233static unsigned char top_left_angle_bits[] = { 233static unsigned short top_left_angle_bits[] = {
234 0xfc, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00}; 234 0xfc, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00};
235 235
236/* First line bitmap. An right-up angle. */ 236/* First line bitmap. An right-up angle. */
@@ -244,7 +244,7 @@ static unsigned char top_left_angle_bits[] = {
244 ......xx 244 ......xx
245 ........ 245 ........
246*/ 246*/
247static unsigned char top_right_angle_bits[] = { 247static unsigned short top_right_angle_bits[] = {
248 0x3f, 0x3f, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00}; 248 0x3f, 0x3f, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00};
249 249
250/* Last line bitmap. An left-down angle. */ 250/* Last line bitmap. An left-down angle. */
@@ -258,7 +258,7 @@ static unsigned char top_right_angle_bits[] = {
258 xxxxxx.. 258 xxxxxx..
259 xxxxxx.. 259 xxxxxx..
260*/ 260*/
261static unsigned char bottom_left_angle_bits[] = { 261static unsigned short bottom_left_angle_bits[] = {
262 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xfc}; 262 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xfc};
263 263
264/* Last line bitmap. An right-down angle. */ 264/* Last line bitmap. An right-down angle. */
@@ -272,7 +272,7 @@ static unsigned char bottom_left_angle_bits[] = {
272 ..xxxxxx 272 ..xxxxxx
273 ..xxxxxx 273 ..xxxxxx
274*/ 274*/
275static unsigned char bottom_right_angle_bits[] = { 275static unsigned short bottom_right_angle_bits[] = {
276 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x3f, 0x3f}; 276 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x3f, 0x3f};
277 277
278/* First/last line bitmap. An left bracket. */ 278/* First/last line bitmap. An left bracket. */
@@ -288,7 +288,7 @@ static unsigned char bottom_right_angle_bits[] = {
288 xxxxxx.. 288 xxxxxx..
289 xxxxxx.. 289 xxxxxx..
290*/ 290*/
291static unsigned char left_bracket_bits[] = { 291static unsigned short left_bracket_bits[] = {
292 0xfc, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xfc}; 292 0xfc, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xfc};
293 293
294/* First/last line bitmap. An right bracket. */ 294/* First/last line bitmap. An right bracket. */
@@ -304,7 +304,7 @@ static unsigned char left_bracket_bits[] = {
304 ..xxxxxx 304 ..xxxxxx
305 ..xxxxxx 305 ..xxxxxx
306*/ 306*/
307static unsigned char right_bracket_bits[] = { 307static unsigned short right_bracket_bits[] = {
308 0x3f, 0x3f, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x3f, 0x3f}; 308 0x3f, 0x3f, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x3f, 0x3f};
309 309
310/* Filled box cursor bitmap. A filled box; max 13 pixels high. */ 310/* Filled box cursor bitmap. A filled box; max 13 pixels high. */
@@ -323,7 +323,7 @@ static unsigned char right_bracket_bits[] = {
323 xxxxxxx. 323 xxxxxxx.
324 xxxxxxx. 324 xxxxxxx.
325*/ 325*/
326static unsigned char filled_box_cursor_bits[] = { 326static unsigned short filled_box_cursor_bits[] = {
327 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe}; 327 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
328 328
329/* Hollow box cursor bitmap. A hollow box; max 13 pixels high. */ 329/* Hollow box cursor bitmap. A hollow box; max 13 pixels high. */
@@ -342,7 +342,7 @@ static unsigned char filled_box_cursor_bits[] = {
342 x.....x. 342 x.....x.
343 xxxxxxx. 343 xxxxxxx.
344*/ 344*/
345static unsigned char hollow_box_cursor_bits[] = { 345static unsigned short hollow_box_cursor_bits[] = {
346 0xfe, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0xfe}; 346 0xfe, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0xfe};
347 347
348/* Bar cursor bitmap. A vertical bar; max 13 pixels high. */ 348/* Bar cursor bitmap. A vertical bar; max 13 pixels high. */
@@ -361,7 +361,7 @@ static unsigned char hollow_box_cursor_bits[] = {
361 xx...... 361 xx......
362 xx...... 362 xx......
363*/ 363*/
364static unsigned char bar_cursor_bits[] = { 364static unsigned short bar_cursor_bits[] = {
365 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0}; 365 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0};
366 366
367/* HBar cursor bitmap. A horisontal bar; 2 pixels high. */ 367/* HBar cursor bitmap. A horisontal bar; 2 pixels high. */
@@ -369,7 +369,7 @@ static unsigned char bar_cursor_bits[] = {
369 xxxxxxx. 369 xxxxxxx.
370 xxxxxxx. 370 xxxxxxx.
371*/ 371*/
372static unsigned char hbar_cursor_bits[] = { 372static unsigned short hbar_cursor_bits[] = {
373 0xfe, 0xfe}; 373 0xfe, 0xfe};
374 374
375 375
@@ -383,7 +383,7 @@ static unsigned char hbar_cursor_bits[] = {
383 ..xxxx.. 383 ..xxxx..
384 ........ 384 ........
385*/ 385*/
386static unsigned char zv_bits[] = { 386static unsigned short zv_bits[] = {
387 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 387 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
388 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 388 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
389 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 389 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
@@ -402,12 +402,14 @@ static unsigned char zv_bits[] = {
402 .x....x. 402 .x....x.
403 .xxxxxx. 403 .xxxxxx.
404*/ 404*/
405static unsigned char hollow_square_bits[] = { 405static unsigned short hollow_square_bits[] = {
406 0x7e, 0x42, 0x42, 0x42, 0x42, 0x7e}; 406 0x7e, 0x42, 0x42, 0x42, 0x42, 0x7e};
407 407
408 408
409#define BYTES_PER_BITMAP_ROW (sizeof (unsigned short))
410#define STANDARD_BITMAP_HEIGHT(bits) (sizeof (bits)/BYTES_PER_BITMAP_ROW)
411#define FRBITS(bits) bits, STANDARD_BITMAP_HEIGHT (bits)
409 412
410#define FRBITS(bits) bits, sizeof bits
411struct fringe_bitmap standard_bitmaps[MAX_STANDARD_FRINGE_BITMAPS] = 413struct fringe_bitmap standard_bitmaps[MAX_STANDARD_FRINGE_BITMAPS] =
412{ 414{
413 { NULL, 0, 0, 0, 0, 0 }, /* NO_FRINGE_BITMAP */ 415 { NULL, 0, 0, 0, 0, 0 }, /* NO_FRINGE_BITMAP */
@@ -604,7 +606,7 @@ draw_fringe_bitmap (w, row, left_p)
604 switch (w->phys_cursor_type) 606 switch (w->phys_cursor_type)
605 { 607 {
606 case HOLLOW_BOX_CURSOR: 608 case HOLLOW_BOX_CURSOR:
607 if (row->visible_height >= sizeof(hollow_box_cursor_bits)) 609 if (row->visible_height >= STANDARD_BITMAP_HEIGHT (hollow_box_cursor_bits))
608 cursor = HOLLOW_BOX_CURSOR_BITMAP; 610 cursor = HOLLOW_BOX_CURSOR_BITMAP;
609 else 611 else
610 cursor = HOLLOW_SQUARE_BITMAP; 612 cursor = HOLLOW_SQUARE_BITMAP;
@@ -1011,8 +1013,11 @@ If WHICH overrides a standard fringe bitmap, the original bitmap is restored. *
1011 1013
1012 1014
1013/* Initialize bitmap bit. 1015/* Initialize bitmap bit.
1014 On X and MAC, we bit-swap the built-in bitmaps. 1016
1015 On W32, there's no need to do this. 1017 On X, we bit-swap the built-in bitmaps and reduce bitmap
1018 from short to char array if width is <= 8 bits.
1019
1020 On W32 and MAC, there's no need to do this.
1016*/ 1021*/
1017 1022
1018void 1023void
@@ -1023,20 +1028,38 @@ init_fringe_bitmap (which, fb, once_p)
1023{ 1028{
1024 if (once_p || fb->dynamic) 1029 if (once_p || fb->dynamic)
1025 { 1030 {
1026#if defined (HAVE_X_WINDOWS) || defined (MAC_OS) 1031#if defined (HAVE_X_WINDOWS)
1027 unsigned char *bits = fb->bits; 1032 static unsigned char swap_nibble[16]
1033 = { 0x0, 0x8, 0x4, 0xc, /* 0000 1000 0100 1100 */
1034 0x2, 0xa, 0x6, 0xe, /* 0010 1010 0110 1110 */
1035 0x1, 0x9, 0x5, 0xd, /* 0001 1001 0101 1101 */
1036 0x3, 0xb, 0x7, 0xf }; /* 0011 1011 0111 1111 */
1037 unsigned short *bits = fb->bits;
1028 int j; 1038 int j;
1029 for (j = 0; j < fb->height; j++) 1039
1040 if (fb->width <= 8)
1041 {
1042 unsigned char *cbits = (unsigned char *)fb->bits;
1043 for (j = 0; j < fb->height; j++)
1044 {
1045 unsigned short b = *bits++;
1046 unsigned char c;
1047 c = (unsigned char)((swap_nibble[b & 0xf] << 4)
1048 | (swap_nibble[(b>>4) & 0xf]));
1049 *cbits++ = (c >> (8 - fb->width));
1050 }
1051 }
1052 else
1030 { 1053 {
1031 static unsigned char swap_nibble[16] 1054 for (j = 0; j < fb->height; j++)
1032 = { 0x0, 0x8, 0x4, 0xc, /* 0000 1000 0100 1100 */ 1055 {
1033 0x2, 0xa, 0x6, 0xe, /* 0010 1010 0110 1110 */ 1056 unsigned short b = *bits;
1034 0x1, 0x9, 0x5, 0xd, /* 0001 1001 0101 1101 */ 1057 b = (unsigned short)((swap_nibble[b & 0xf] << 12)
1035 0x3, 0xb, 0x7, 0xf }; /* 0011 1011 0111 1111 */ 1058 | (swap_nibble[(b>>4) & 0xf] << 8)
1036 1059 | (swap_nibble[(b>>8) & 0xf] << 4)
1037 unsigned char b = *bits; 1060 | (swap_nibble[(b>>12) & 0xf]));
1038 *bits++ = (unsigned short)((swap_nibble[b & 0xf]<<4) 1061 *bits++ = (b >> (16 - fb->width));
1039 | (swap_nibble[(b>>4) & 0xf])); 1062 }
1040 } 1063 }
1041#endif 1064#endif
1042 } 1065 }
@@ -1058,12 +1081,14 @@ init_fringe_bitmap (which, fb, once_p)
1058DEFUN ("define-fringe-bitmap", Fdefine_fringe_bitmap, Sdefine_fringe_bitmap, 1081DEFUN ("define-fringe-bitmap", Fdefine_fringe_bitmap, Sdefine_fringe_bitmap,
1059 1, 5, 0, 1082 1, 5, 0,
1060 doc: /* Define a fringe bitmap from BITS of height HEIGHT and width WIDTH. 1083 doc: /* Define a fringe bitmap from BITS of height HEIGHT and width WIDTH.
1061BITS is either a string or a vector. If HEIGHT is nil, use number of bytes 1084BITS is either a string or a vector of integers.
1062in BITS. If WIDTH is zero, default to 8. Optional forth arg ALIGN may be 1085HEIGHT is height of bitmap. If HEIGHT is nil, use length of BITS.
1063one of `top', `center', or `bottom', indicating the positioning of the 1086WIDTH must be an integer between 1 and 16, or nil which defaults to 8.
1064bitmap relative to the rows where it is used; the default is to center the 1087Optional forth arg ALIGN may be one of `top', `center', or `bottom',
1065bitmap. Fourth arg may also be a list (ALIGN PERIODIC) where 1088indicating the positioning of the bitmap relative to the rows where it
1066PERIODIC non-nil specifies that the bitmap should be repeated. 1089is used; the default is to center the bitmap. Fourth arg may also be a
1090list (ALIGN PERIODIC) where PERIODIC non-nil specifies that the bitmap
1091should be repeated.
1067Optional fifth argument WHICH is bitmap number to redefine. 1092Optional fifth argument WHICH is bitmap number to redefine.
1068Return new bitmap number, or nil of no more free bitmap slots. */) 1093Return new bitmap number, or nil of no more free bitmap slots. */)
1069 (bits, height, width, align, which) 1094 (bits, height, width, align, which)
@@ -1071,7 +1096,7 @@ Return new bitmap number, or nil of no more free bitmap slots. */)
1071{ 1096{
1072 Lisp_Object len; 1097 Lisp_Object len;
1073 int n, h, i, j; 1098 int n, h, i, j;
1074 unsigned char *b; 1099 unsigned short *b;
1075 struct fringe_bitmap fb, *xfb; 1100 struct fringe_bitmap fb, *xfb;
1076 int fill1 = 0, fill2 = 0; 1101 int fill1 = 0, fill2 = 0;
1077 1102
@@ -1152,8 +1177,9 @@ Return new bitmap number, or nil of no more free bitmap slots. */)
1152 1177
1153 fb.dynamic = 1; 1178 fb.dynamic = 1;
1154 1179
1155 xfb = (struct fringe_bitmap *)xmalloc (sizeof fb + fb.height); 1180 xfb = (struct fringe_bitmap *)xmalloc (sizeof fb
1156 fb.bits = b = (unsigned char *)(xfb+1); 1181 + fb.height * BYTES_PER_BITMAP_ROW);
1182 fb.bits = b = (unsigned short *)(xfb+1);
1157 bzero (b, fb.height); 1183 bzero (b, fb.height);
1158 1184
1159 j = 0; 1185 j = 0;