Mercurial > emacs
comparison src/fringe.c @ 69049:28b3892bfcda
(enum fringe_bitmap_type): Remove. Change all uses
to use `int'.
(NO_FRINGE_BITMAP, UNDEF_FRINGE_BITMAP, MAX_STANDARD_FRINGE_BITMAPS):
Define explicitly.
(Qtruncation, Qcontinuation, Qempty_line, Qtop_bottom)
(Qhollow_small): New variables.
(syms_of_fringe): Intern and staticpro them.
(question_mark_bits): Rename from unknown_bits.
(left_curly_arrow_bits): Rename from continuation_bits.
(right_curly_arrow_bits): Rename from continued_bits.
(left_triangle_bits): Rename from ov_bits.
(right_triangle_bits): Added.
(filled_rectangle_bits): Rename from filled_box_cursor_bits.
(hollow_rectangle_bits): Rename from hollow_box_cursor_bits.
(filled_square_bits): Added.
(vertical_bar_bits): Rename from bar_cursor_bits.
(horisontal_bar_bits): Rename from hbar_cursor_bits.
(empty_line_bits): Rename from zv_bits.
(standard_bitmaps): Update to use new names.
(draw_fringe_bitmap_1): Make static.
(get_logical_cursor_bitmap, get_logical_fringe_bitmap): New functions
to map from logical cursors and indicators to physical bitmaps.
(draw_fringe_bitmap): Resolve fringe cursor and overlay-arrow
bitmaps using symbol names instead of bitmap numbers.
(update_window_fringes): Use logical indicator symbol names
instead of bitmap numbers for logical. Add bitmap cache.
(LEFT_FRINGE, RIGHT_FRINGE): New helper macros.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Mon, 20 Feb 2006 22:14:22 +0000 |
parents | 3bd95f4f2941 |
children | fb4f4719e18b |
comparison
equal
deleted
inserted
replaced
69048:7e644ce20468 | 69049:28b3892bfcda |
---|---|
47 loading fringe.el. | 47 loading fringe.el. |
48 */ | 48 */ |
49 | 49 |
50 Lisp_Object Vfringe_bitmaps; | 50 Lisp_Object Vfringe_bitmaps; |
51 | 51 |
52 enum fringe_bitmap_type | 52 /* Fringe bitmaps are represented in three different ways: |
53 { | 53 |
54 NO_FRINGE_BITMAP = 0, | 54 Logical bitmaps are used internally to denote things like |
55 UNDEF_FRINGE_BITMAP, | 55 'end-of-buffer', 'left-truncation', 'overlay-arrow', etc. |
56 LEFT_TRUNCATION_BITMAP, | 56 |
57 RIGHT_TRUNCATION_BITMAP, | 57 Physical bitmaps specify the visual appearence of the bitmap, |
58 UP_ARROW_BITMAP, | 58 e.g. 'bottom-left-angle', 'left-arrow', 'left-triangle', etc. |
59 DOWN_ARROW_BITMAP, | 59 User defined bitmaps are physical bitmaps. |
60 CONTINUED_LINE_BITMAP, | 60 |
61 CONTINUATION_LINE_BITMAP, | 61 Internally, fringe bitmaps for a specific display row are |
62 OVERLAY_ARROW_BITMAP, | 62 represented as a simple integer that is used as an index |
63 TOP_LEFT_ANGLE_BITMAP, | 63 into the table of all defined bitmaps. This index is stored |
64 TOP_RIGHT_ANGLE_BITMAP, | 64 in the `fringe' property of the physical bitmap symbol. |
65 BOTTOM_LEFT_ANGLE_BITMAP, | 65 |
66 BOTTOM_RIGHT_ANGLE_BITMAP, | 66 Logical bitmaps are mapped to physical bitmaps through the |
67 LEFT_BRACKET_BITMAP, | 67 buffer-local `fringe-indicator-alist' variable. |
68 RIGHT_BRACKET_BITMAP, | 68 |
69 FILLED_BOX_CURSOR_BITMAP, | 69 Each element of this alist is a cons (LOGICAL . PHYSICAL) |
70 HOLLOW_BOX_CURSOR_BITMAP, | 70 mapping a logical bitmap to a physical bitmap. |
71 HOLLOW_SQUARE_BITMAP, | 71 PHYSICAL is either a symbol to use in both left and right fringe, |
72 BAR_CURSOR_BITMAP, | 72 or a cons of two symbols (LEFT . RIGHT) denoting different |
73 HBAR_CURSOR_BITMAP, | 73 bitmaps to use in left and right fringe. |
74 ZV_LINE_BITMAP, | 74 |
75 MAX_STANDARD_FRINGE_BITMAPS | 75 LOGICAL is first looked up in the window's buffer's buffer-local |
76 }; | 76 value of the fringe-indicator-alist variable, and if not present, |
77 in the global value of fringe-indicator-alist. | |
78 | |
79 If LOGICAL is not present in either alist, or the PHYSICAL value | |
80 found is nil, no bitmap is shown for the logical bitmap. | |
81 | |
82 The `left-fringe' and `right-fringe' display properties | |
83 must specify physical bitmap symbols. | |
84 */ | |
85 | |
86 extern Lisp_Object Qunknown; | |
87 Lisp_Object Qtruncation, Qcontinuation, Qoverlay_arrow; | |
88 Lisp_Object Qempty_line, Qtop_bottom; | |
89 extern Lisp_Object Qbar, Qhbar, Qbox, Qhollow; | |
90 Lisp_Object Qhollow_small; | |
77 | 91 |
78 enum fringe_bitmap_align | 92 enum fringe_bitmap_align |
79 { | 93 { |
80 ALIGN_BITMAP_CENTER = 0, | 94 ALIGN_BITMAP_CENTER = 0, |
81 ALIGN_BITMAP_TOP, | 95 ALIGN_BITMAP_TOP, |
108 ...xx... | 122 ...xx... |
109 ........ | 123 ........ |
110 ...xx... | 124 ...xx... |
111 ...xx... | 125 ...xx... |
112 */ | 126 */ |
113 static unsigned short unknown_bits[] = { | 127 static unsigned short question_mark_bits[] = { |
114 0x3c, 0x7e, 0x7e, 0x0c, 0x18, 0x18, 0x00, 0x18, 0x18}; | 128 0x3c, 0x7e, 0x7e, 0x0c, 0x18, 0x18, 0x00, 0x18, 0x18}; |
115 | 129 |
116 /* An arrow like this: `<-'. */ | 130 /* An arrow like this: `<-'. */ |
117 /* | 131 /* |
118 ...xx... | 132 ...xx... |
170 ...xx... | 184 ...xx... |
171 */ | 185 */ |
172 static unsigned short down_arrow_bits[] = { | 186 static unsigned short down_arrow_bits[] = { |
173 0x18, 0x18, 0x18, 0x18, 0xff, 0x7e, 0x3c, 0x18}; | 187 0x18, 0x18, 0x18, 0x18, 0xff, 0x7e, 0x3c, 0x18}; |
174 | 188 |
189 /* Marker for continuation lines. */ | |
190 /* | |
191 ..xxxx.. | |
192 .xxxxx.. | |
193 xx...... | |
194 xxx..x.. | |
195 xxxxxx.. | |
196 .xxxxx.. | |
197 ..xxxx.. | |
198 .xxxxx.. | |
199 */ | |
200 static unsigned short left_curly_arrow_bits[] = { | |
201 0x3c, 0x7c, 0xc0, 0xe4, 0xfc, 0x7c, 0x3c, 0x7c}; | |
202 | |
175 /* Marker for continued lines. */ | 203 /* Marker for continued lines. */ |
176 /* | 204 /* |
177 ..xxxx.. | 205 ..xxxx.. |
178 ..xxxxx. | 206 ..xxxxx. |
179 ......xx | 207 ......xx |
181 ..xxxxxx | 209 ..xxxxxx |
182 ..xxxxx. | 210 ..xxxxx. |
183 ..xxxx.. | 211 ..xxxx.. |
184 ..xxxxx. | 212 ..xxxxx. |
185 */ | 213 */ |
186 static unsigned short continued_bits[] = { | 214 static unsigned short right_curly_arrow_bits[] = { |
187 0x3c, 0x3e, 0x03, 0x27, 0x3f, 0x3e, 0x3c, 0x3e}; | 215 0x3c, 0x3e, 0x03, 0x27, 0x3f, 0x3e, 0x3c, 0x3e}; |
188 | 216 |
189 /* Marker for continuation lines. */ | 217 /* Reverse Overlay arrow bitmap. A triangular arrow. */ |
190 /* | 218 /* |
191 ..xxxx.. | 219 ......xx |
192 .xxxxx.. | 220 ....xxxx |
193 xx...... | 221 ...xxxxx |
194 xxx..x.. | 222 ..xxxxxx |
195 xxxxxx.. | 223 ..xxxxxx |
196 .xxxxx.. | 224 ...xxxxx |
197 ..xxxx.. | 225 ....xxxx |
198 .xxxxx.. | 226 ......xx |
199 */ | 227 */ |
200 static unsigned short continuation_bits[] = { | 228 static unsigned short left_triangle_bits[] = { |
201 0x3c, 0x7c, 0xc0, 0xe4, 0xfc, 0x7c, 0x3c, 0x7c}; | 229 0x03, 0x0f, 0x1f, 0x3f, 0x3f, 0x1f, 0x0f, 0x03}; |
202 | 230 |
203 /* Overlay arrow bitmap. A triangular arrow. */ | 231 /* Overlay arrow bitmap. A triangular arrow. */ |
204 /* | 232 /* |
205 xx...... | 233 xx...... |
206 xxxx.... | 234 xxxx.... |
209 xxxxxx.. | 237 xxxxxx.. |
210 xxxxx... | 238 xxxxx... |
211 xxxx.... | 239 xxxx.... |
212 xx...... | 240 xx...... |
213 */ | 241 */ |
214 static unsigned short ov_bits[] = { | 242 static unsigned short right_triangle_bits[] = { |
215 0xc0, 0xf0, 0xf8, 0xfc, 0xfc, 0xf8, 0xf0, 0xc0}; | 243 0xc0, 0xf0, 0xf8, 0xfc, 0xfc, 0xf8, 0xf0, 0xc0}; |
216 | |
217 #if 0 | |
218 /* Reverse Overlay arrow bitmap. A triangular arrow. */ | |
219 /* | |
220 ......xx | |
221 ....xxxx | |
222 ...xxxxx | |
223 ..xxxxxx | |
224 ..xxxxxx | |
225 ...xxxxx | |
226 ....xxxx | |
227 ......xx | |
228 */ | |
229 static unsigned short rev_ov_bits[] = { | |
230 0x03, 0x0f, 0x1f, 0x3f, 0x3f, 0x1f, 0x0f, 0x03}; | |
231 #endif | |
232 | 244 |
233 /* First line bitmap. An top-left angle. */ | 245 /* First line bitmap. An top-left angle. */ |
234 /* | 246 /* |
235 xxxxxx.. | 247 xxxxxx.. |
236 xxxxxx.. | 248 xxxxxx.. |
332 xxxxxxx. | 344 xxxxxxx. |
333 xxxxxxx. | 345 xxxxxxx. |
334 xxxxxxx. | 346 xxxxxxx. |
335 xxxxxxx. | 347 xxxxxxx. |
336 */ | 348 */ |
337 static unsigned short filled_box_cursor_bits[] = { | 349 static unsigned short filled_rectangle_bits[] = { |
338 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe}; | 350 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe}; |
339 | 351 |
340 /* Hollow box cursor bitmap. A hollow box; max 13 pixels high. */ | 352 /* Hollow box cursor bitmap. A hollow box; max 13 pixels high. */ |
341 /* | 353 /* |
342 xxxxxxx. | 354 xxxxxxx. |
351 x.....x. | 363 x.....x. |
352 x.....x. | 364 x.....x. |
353 x.....x. | 365 x.....x. |
354 xxxxxxx. | 366 xxxxxxx. |
355 */ | 367 */ |
356 static unsigned short hollow_box_cursor_bits[] = { | 368 static unsigned short hollow_rectangle_bits[] = { |
357 0xfe, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0xfe}; | 369 0xfe, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0xfe}; |
358 | 370 |
371 /* Hollow square bitmap. */ | |
372 /* | |
373 .xxxxxx. | |
374 .x....x. | |
375 .x....x. | |
376 .x....x. | |
377 .x....x. | |
378 .xxxxxx. | |
379 */ | |
380 static unsigned short hollow_square_bits[] = { | |
381 0x7e, 0x42, 0x42, 0x42, 0x42, 0x7e}; | |
382 | |
383 /* Filled square bitmap. */ | |
384 /* | |
385 .xxxxxx. | |
386 .xxxxxx. | |
387 .xxxxxx. | |
388 .xxxxxx. | |
389 .xxxxxx. | |
390 .xxxxxx. | |
391 */ | |
392 static unsigned short filled_square_bits[] = { | |
393 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e}; | |
394 | |
359 /* Bar cursor bitmap. A vertical bar; max 13 pixels high. */ | 395 /* Bar cursor bitmap. A vertical bar; max 13 pixels high. */ |
360 /* | 396 /* |
361 xx...... | 397 xx...... |
362 xx...... | 398 xx...... |
363 xx...... | 399 xx...... |
370 xx...... | 406 xx...... |
371 xx...... | 407 xx...... |
372 xx...... | 408 xx...... |
373 xx...... | 409 xx...... |
374 */ | 410 */ |
375 static unsigned short bar_cursor_bits[] = { | 411 static unsigned short vertical_bar_bits[] = { |
376 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0}; | 412 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0}; |
377 | 413 |
378 /* HBar cursor bitmap. A horisontal bar; 2 pixels high. */ | 414 /* HBar cursor bitmap. A horisontal bar; 2 pixels high. */ |
379 /* | 415 /* |
380 xxxxxxx. | 416 xxxxxxx. |
381 xxxxxxx. | 417 xxxxxxx. |
382 */ | 418 */ |
383 static unsigned short hbar_cursor_bits[] = { | 419 static unsigned short horisontal_bar_bits[] = { |
384 0xfe, 0xfe}; | 420 0xfe, 0xfe}; |
385 | 421 |
386 | 422 |
387 /* Bitmap drawn to indicate lines not displaying text if | 423 /* Bitmap drawn to indicate lines not displaying text if |
388 `indicate-empty-lines' is non-nil. */ | 424 `indicate-empty-lines' is non-nil. */ |
392 ........ | 428 ........ |
393 ........ | 429 ........ |
394 ..xxxx.. | 430 ..xxxx.. |
395 ........ | 431 ........ |
396 */ | 432 */ |
397 static unsigned short zv_bits[] = { | 433 static unsigned short empty_line_bits[] = { |
398 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, | 434 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, |
399 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, | 435 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, |
400 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, | 436 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, |
401 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, | 437 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, |
402 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, | 438 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, |
403 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, | 439 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, |
404 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, | 440 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, |
405 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00}; | 441 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00}; |
406 | 442 |
407 /* Hollow square bitmap. */ | |
408 /* | |
409 .xxxxxx. | |
410 .x....x. | |
411 .x....x. | |
412 .x....x. | |
413 .x....x. | |
414 .xxxxxx. | |
415 */ | |
416 static unsigned short hollow_square_bits[] = { | |
417 0x7e, 0x42, 0x42, 0x42, 0x42, 0x7e}; | |
418 | |
419 | 443 |
420 #define BYTES_PER_BITMAP_ROW (sizeof (unsigned short)) | 444 #define BYTES_PER_BITMAP_ROW (sizeof (unsigned short)) |
421 #define STANDARD_BITMAP_HEIGHT(bits) (sizeof (bits)/BYTES_PER_BITMAP_ROW) | 445 #define STANDARD_BITMAP_HEIGHT(bits) (sizeof (bits)/BYTES_PER_BITMAP_ROW) |
422 #define FRBITS(bits) bits, STANDARD_BITMAP_HEIGHT (bits) | 446 #define FRBITS(bits) bits, STANDARD_BITMAP_HEIGHT (bits) |
423 | 447 |
424 struct fringe_bitmap standard_bitmaps[MAX_STANDARD_FRINGE_BITMAPS] = | 448 /* NOTE: The order of these bitmaps must match the sequence |
449 used in fringe.el to define the corresponding symbols. */ | |
450 | |
451 struct fringe_bitmap standard_bitmaps[] = | |
425 { | 452 { |
426 { NULL, 0, 0, 0, 0, 0 }, /* NO_FRINGE_BITMAP */ | 453 { NULL, 0, 0, 0, 0, 0 }, /* NO_FRINGE_BITMAP */ |
427 { FRBITS (unknown_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, | 454 { FRBITS (question_mark_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, |
428 { FRBITS (left_arrow_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, | 455 { FRBITS (left_arrow_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, |
429 { FRBITS (right_arrow_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, | 456 { FRBITS (right_arrow_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, |
430 { FRBITS (up_arrow_bits), 8, 0, ALIGN_BITMAP_TOP, 0 }, | 457 { FRBITS (up_arrow_bits), 8, 0, ALIGN_BITMAP_TOP, 0 }, |
431 { FRBITS (down_arrow_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 }, | 458 { FRBITS (down_arrow_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 }, |
432 { FRBITS (continued_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, | 459 { FRBITS (left_curly_arrow_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, |
433 { FRBITS (continuation_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, | 460 { FRBITS (right_curly_arrow_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, |
434 { FRBITS (ov_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, | 461 { FRBITS (left_triangle_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, |
462 { FRBITS (right_triangle_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, | |
435 { FRBITS (top_left_angle_bits), 8, 0, ALIGN_BITMAP_TOP, 0 }, | 463 { FRBITS (top_left_angle_bits), 8, 0, ALIGN_BITMAP_TOP, 0 }, |
436 { FRBITS (top_right_angle_bits), 8, 0, ALIGN_BITMAP_TOP, 0 }, | 464 { FRBITS (top_right_angle_bits), 8, 0, ALIGN_BITMAP_TOP, 0 }, |
437 { FRBITS (bottom_left_angle_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 }, | 465 { FRBITS (bottom_left_angle_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 }, |
438 { FRBITS (bottom_right_angle_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 }, | 466 { FRBITS (bottom_right_angle_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 }, |
439 { FRBITS (left_bracket_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, | 467 { FRBITS (left_bracket_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, |
440 { FRBITS (right_bracket_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, | 468 { FRBITS (right_bracket_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, |
441 { FRBITS (filled_box_cursor_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, | 469 { FRBITS (filled_rectangle_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, |
442 { FRBITS (hollow_box_cursor_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, | 470 { FRBITS (hollow_rectangle_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, |
471 { FRBITS (filled_square_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, | |
443 { FRBITS (hollow_square_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, | 472 { FRBITS (hollow_square_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, |
444 { FRBITS (bar_cursor_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, | 473 { FRBITS (vertical_bar_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, |
445 { FRBITS (hbar_cursor_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 }, | 474 { FRBITS (horisontal_bar_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 }, |
446 { FRBITS (zv_bits), 8, 3, ALIGN_BITMAP_TOP, 0 }, | 475 { FRBITS (empty_line_bits), 8, 3, ALIGN_BITMAP_TOP, 0 }, |
447 }; | 476 }; |
477 | |
478 #define NO_FRINGE_BITMAP 0 | |
479 #define UNDEF_FRINGE_BITMAP 1 | |
480 #define MAX_STANDARD_FRINGE_BITMAPS (sizeof(standard_bitmaps)/sizeof(standard_bitmaps[0])) | |
448 | 481 |
449 static struct fringe_bitmap **fringe_bitmaps; | 482 static struct fringe_bitmap **fringe_bitmaps; |
450 static Lisp_Object *fringe_faces; | 483 static Lisp_Object *fringe_faces; |
451 static int max_fringe_bitmaps; | 484 static int max_fringe_bitmaps; |
452 | 485 |
514 determines the vertical position at which the bitmap has to be | 547 determines the vertical position at which the bitmap has to be |
515 drawn. | 548 drawn. |
516 LEFT_P is 1 for left fringe, 0 for right fringe. | 549 LEFT_P is 1 for left fringe, 0 for right fringe. |
517 */ | 550 */ |
518 | 551 |
519 void | 552 static void |
520 draw_fringe_bitmap_1 (w, row, left_p, overlay, which) | 553 draw_fringe_bitmap_1 (w, row, left_p, overlay, which) |
521 struct window *w; | 554 struct window *w; |
522 struct glyph_row *row; | 555 struct glyph_row *row; |
523 int left_p, overlay; | 556 int left_p, overlay; |
524 enum fringe_bitmap_type which; | 557 int which; |
525 { | 558 { |
526 struct frame *f = XFRAME (WINDOW_FRAME (w)); | 559 struct frame *f = XFRAME (WINDOW_FRAME (w)); |
527 struct draw_fringe_bitmap_params p; | 560 struct draw_fringe_bitmap_params p; |
528 struct fringe_bitmap *fb; | 561 struct fringe_bitmap *fb; |
529 int period; | 562 int period; |
654 } | 687 } |
655 | 688 |
656 rif->draw_fringe_bitmap (w, row, &p); | 689 rif->draw_fringe_bitmap (w, row, &p); |
657 } | 690 } |
658 | 691 |
692 static int | |
693 get_logical_cursor_bitmap (w, cursor) | |
694 struct window *w; | |
695 Lisp_Object cursor; | |
696 { | |
697 Lisp_Object cmap, bm = Qnil; | |
698 | |
699 if ((cmap = XBUFFER (w->buffer)->fringe_cursor_alist), !NILP (cmap)) | |
700 { | |
701 bm = Fassq (cursor, cmap); | |
702 if (CONSP (bm)) | |
703 { | |
704 if ((bm = XCDR (bm)), NILP (bm)) | |
705 return NO_FRINGE_BITMAP; | |
706 return lookup_fringe_bitmap (bm); | |
707 } | |
708 } | |
709 if (EQ (cmap, buffer_defaults.fringe_cursor_alist)) | |
710 return NO_FRINGE_BITMAP; | |
711 bm = Fassq (cursor, buffer_defaults.fringe_cursor_alist); | |
712 if (!CONSP (bm) || ((bm = XCDR (bm)), NILP (bm))) | |
713 return NO_FRINGE_BITMAP; | |
714 return lookup_fringe_bitmap (bm); | |
715 } | |
716 | |
717 static int | |
718 get_logical_fringe_bitmap (w, bitmap, right_p, partial_p) | |
719 struct window *w; | |
720 Lisp_Object bitmap; | |
721 int right_p, partial_p; | |
722 { | |
723 Lisp_Object cmap, bm1 = Qnil, bm2 = Qnil, bm; | |
724 int ln1 = 0, ln2 = 0; | |
725 int ix1 = right_p; | |
726 int ix2 = ix1 + (partial_p ? 2 : 0); | |
727 | |
728 /* Lookup in buffer-local fringe-indicator-alist before global alist. | |
729 | |
730 Elements are: | |
731 BITMAP -- use for all | |
732 (L R) -- use for left right (whether partial or not) | |
733 (L R PL PR) -- use for left rigth partial-left partial-right | |
734 If any value in local binding is not present or t, use global value. | |
735 | |
736 If partial, lookup partial bitmap in default value if not found here. | |
737 If not partial, or no partial spec is present, use non-partial bitmap. */ | |
738 | |
739 if ((cmap = XBUFFER (w->buffer)->fringe_indicator_alist), !NILP (cmap)) | |
740 { | |
741 bm1 = Fassq (bitmap, cmap); | |
742 if (CONSP (bm1)) | |
743 { | |
744 if ((bm1 = XCDR (bm1)), NILP (bm1)) | |
745 return NO_FRINGE_BITMAP; | |
746 if (CONSP (bm1)) | |
747 { | |
748 ln1 = XINT (Flength (bm1)); | |
749 if (partial_p) | |
750 { | |
751 if (ln1 > ix2) | |
752 { | |
753 bm = Fnth (make_number (ix2), bm1); | |
754 if (!EQ (bm, Qt)) | |
755 goto found; | |
756 } | |
757 } | |
758 else | |
759 { | |
760 if (ln1 > ix1) | |
761 { | |
762 bm = Fnth (make_number (ix1), bm1); | |
763 if (!EQ (bm, Qt)) | |
764 goto found; | |
765 } | |
766 } | |
767 } | |
768 else if ((bm = bm1, !EQ (bm, Qt))) | |
769 goto found; | |
770 } | |
771 } | |
772 | |
773 if (!EQ (cmap, buffer_defaults.fringe_indicator_alist) | |
774 && !NILP (buffer_defaults.fringe_indicator_alist)) | |
775 { | |
776 bm2 = Fassq (bitmap, buffer_defaults.fringe_indicator_alist); | |
777 if (CONSP (bm2)) | |
778 { | |
779 if ((bm2 = XCDR (bm2)), !NILP (bm2)) | |
780 { | |
781 if (CONSP (bm2)) | |
782 { | |
783 ln2 = XINT (Flength (bm2)); | |
784 if (partial_p) | |
785 { | |
786 if (ln2 > ix2) | |
787 { | |
788 bm = Fnth (make_number (ix2), bm2); | |
789 if (!EQ (bm, Qt)) | |
790 goto found; | |
791 } | |
792 } | |
793 } | |
794 } | |
795 } | |
796 } | |
797 | |
798 if (ln1 > ix1) | |
799 { | |
800 bm = Fnth (make_number (ix1), bm1); | |
801 if (!EQ (bm, Qt)) | |
802 goto found; | |
803 } | |
804 | |
805 if (ln2 > ix1) | |
806 { | |
807 bm = Fnth (make_number (ix1), bm2); | |
808 if (!EQ (bm, Qt)) | |
809 goto found; | |
810 return NO_FRINGE_BITMAP; | |
811 } | |
812 else if ((bm = bm2, NILP (bm))) | |
813 return NO_FRINGE_BITMAP; | |
814 | |
815 found: | |
816 return lookup_fringe_bitmap (bm); | |
817 } | |
818 | |
819 | |
659 void | 820 void |
660 draw_fringe_bitmap (w, row, left_p) | 821 draw_fringe_bitmap (w, row, left_p) |
661 struct window *w; | 822 struct window *w; |
662 struct glyph_row *row; | 823 struct glyph_row *row; |
663 int left_p; | 824 int left_p; |
664 { | 825 { |
665 int overlay = 0; | 826 int overlay = 0; |
666 | 827 |
667 if (!left_p && row->cursor_in_fringe_p) | 828 if (!left_p && row->cursor_in_fringe_p) |
668 { | 829 { |
669 int cursor = NO_FRINGE_BITMAP; | 830 Lisp_Object cursor = Qnil; |
670 | 831 |
671 switch (w->phys_cursor_type) | 832 switch (w->phys_cursor_type) |
672 { | 833 { |
673 case HOLLOW_BOX_CURSOR: | 834 case HOLLOW_BOX_CURSOR: |
674 if (row->visible_height >= STANDARD_BITMAP_HEIGHT (hollow_box_cursor_bits)) | 835 if (row->visible_height >= STANDARD_BITMAP_HEIGHT (hollow_rectangle_bits)) |
675 cursor = HOLLOW_BOX_CURSOR_BITMAP; | 836 cursor = Qhollow; |
676 else | 837 else |
677 cursor = HOLLOW_SQUARE_BITMAP; | 838 cursor = Qhollow_small; |
678 break; | 839 break; |
679 case FILLED_BOX_CURSOR: | 840 case FILLED_BOX_CURSOR: |
680 cursor = FILLED_BOX_CURSOR_BITMAP; | 841 cursor = Qbox; |
681 break; | 842 break; |
682 case BAR_CURSOR: | 843 case BAR_CURSOR: |
683 cursor = BAR_CURSOR_BITMAP; | 844 cursor = Qbar; |
684 break; | 845 break; |
685 case HBAR_CURSOR: | 846 case HBAR_CURSOR: |
686 cursor = HBAR_CURSOR_BITMAP; | 847 cursor = Qhbar; |
687 break; | 848 break; |
688 case NO_CURSOR: | 849 case NO_CURSOR: |
689 default: | 850 default: |
690 w->phys_cursor_on_p = 0; | 851 w->phys_cursor_on_p = 0; |
691 row->cursor_in_fringe_p = 0; | 852 row->cursor_in_fringe_p = 0; |
692 break; | 853 break; |
693 } | 854 } |
694 if (cursor != NO_FRINGE_BITMAP) | 855 if (!NILP (cursor)) |
695 { | 856 { |
696 draw_fringe_bitmap_1 (w, row, 0, 2, cursor); | 857 int bm = get_logical_cursor_bitmap (w, cursor); |
697 overlay = cursor == FILLED_BOX_CURSOR_BITMAP ? 3 : 1; | 858 if (bm != NO_FRINGE_BITMAP) |
859 { | |
860 draw_fringe_bitmap_1 (w, row, 0, 2, bm); | |
861 overlay = EQ (cursor, Qbox) ? 3 : 1; | |
862 } | |
698 } | 863 } |
699 } | 864 } |
700 | 865 |
701 draw_fringe_bitmap_1 (w, row, left_p, overlay, NO_FRINGE_BITMAP); | 866 draw_fringe_bitmap_1 (w, row, left_p, overlay, NO_FRINGE_BITMAP); |
702 | 867 |
703 if (left_p && row->overlay_arrow_bitmap != NO_FRINGE_BITMAP) | 868 if (left_p && row->overlay_arrow_bitmap != NO_FRINGE_BITMAP) |
704 draw_fringe_bitmap_1 (w, row, 1, 1, | 869 draw_fringe_bitmap_1 (w, row, 1, 1, |
705 (row->overlay_arrow_bitmap < 0 | 870 (row->overlay_arrow_bitmap < 0 |
706 ? OVERLAY_ARROW_BITMAP | 871 ? get_logical_cursor_bitmap (w, Qoverlay_arrow) |
707 : row->overlay_arrow_bitmap)); | 872 : row->overlay_arrow_bitmap)); |
708 } | 873 } |
709 | 874 |
710 | 875 |
711 /* Draw fringe bitmaps for glyph row ROW on window W. Call this | 876 /* Draw fringe bitmaps for glyph row ROW on window W. Call this |
793 int redraw_p = 0; | 958 int redraw_p = 0; |
794 Lisp_Object boundary_top = Qnil, boundary_bot = Qnil; | 959 Lisp_Object boundary_top = Qnil, boundary_bot = Qnil; |
795 Lisp_Object arrow_top = Qnil, arrow_bot = Qnil; | 960 Lisp_Object arrow_top = Qnil, arrow_bot = Qnil; |
796 Lisp_Object empty_pos; | 961 Lisp_Object empty_pos; |
797 Lisp_Object ind = Qnil; | 962 Lisp_Object ind = Qnil; |
963 #define MAX_BITMAP_CACHE (8*4) | |
964 int bitmap_cache[MAX_BITMAP_CACHE]; | |
798 | 965 |
799 if (w->pseudo_window_p) | 966 if (w->pseudo_window_p) |
800 return 0; | 967 return 0; |
801 | 968 |
802 if (!MINI_WINDOW_P (w) | 969 if (!MINI_WINDOW_P (w) |
878 | 1045 |
879 empty_pos = XBUFFER (w->buffer)->indicate_empty_lines; | 1046 empty_pos = XBUFFER (w->buffer)->indicate_empty_lines; |
880 if (!NILP (empty_pos) && !EQ (empty_pos, Qright)) | 1047 if (!NILP (empty_pos) && !EQ (empty_pos, Qright)) |
881 empty_pos = WINDOW_LEFT_FRINGE_WIDTH (w) == 0 ? Qright : Qleft; | 1048 empty_pos = WINDOW_LEFT_FRINGE_WIDTH (w) == 0 ? Qright : Qleft; |
882 | 1049 |
1050 for (y = 0; y < MAX_BITMAP_CACHE; y++) | |
1051 bitmap_cache[y] = -1; | |
1052 | |
1053 #define LEFT_FRINGE(cache, which, partial_p) \ | |
1054 (bitmap_cache[cache*4+partial_p] >= 0 \ | |
1055 ? bitmap_cache[cache*4+partial_p] \ | |
1056 : (bitmap_cache[cache*4+partial_p] = \ | |
1057 get_logical_fringe_bitmap (w, which, 0, partial_p))) | |
1058 | |
1059 #define RIGHT_FRINGE(cache, which, partial_p) \ | |
1060 (bitmap_cache[cache*4+2+partial_p] >= 0 \ | |
1061 ? bitmap_cache[cache*4+2+partial_p] \ | |
1062 : (bitmap_cache[cache*4+2+partial_p] = \ | |
1063 get_logical_fringe_bitmap (w, which, 1, partial_p))) | |
1064 | |
1065 | |
883 for (y = 0, rn = 0; | 1066 for (y = 0, rn = 0; |
884 y < yb && rn < nrows; | 1067 y < yb && rn < nrows; |
885 y += row->height, rn++) | 1068 y += row->height, rn++) |
886 { | 1069 { |
887 enum fringe_bitmap_type left, right; | 1070 int left, right; |
888 unsigned left_face_id, right_face_id; | 1071 unsigned left_face_id, right_face_id; |
889 | 1072 |
890 row = w->desired_matrix->rows + rn; | 1073 row = w->desired_matrix->rows + rn; |
891 cur = w->current_matrix->rows + rn; | 1074 cur = w->current_matrix->rows + rn; |
892 if (!row->enabled_p) | 1075 if (!row->enabled_p) |
901 { | 1084 { |
902 left = row->left_user_fringe_bitmap; | 1085 left = row->left_user_fringe_bitmap; |
903 left_face_id = row->left_user_fringe_face_id; | 1086 left_face_id = row->left_user_fringe_face_id; |
904 } | 1087 } |
905 else if (row->truncated_on_left_p) | 1088 else if (row->truncated_on_left_p) |
906 left = LEFT_TRUNCATION_BITMAP; | 1089 left = LEFT_FRINGE(0, Qtruncation, 0); |
907 else if (row->indicate_bob_p && EQ (boundary_top, Qleft)) | 1090 else if (row->indicate_bob_p && EQ (boundary_top, Qleft)) |
908 left = ((row->indicate_eob_p && EQ (boundary_bot, Qleft)) | 1091 left = ((row->indicate_eob_p && EQ (boundary_bot, Qleft)) |
909 ? (row->ends_at_zv_p | 1092 ? LEFT_FRINGE (1, Qtop_bottom, row->ends_at_zv_p) |
910 ? TOP_RIGHT_ANGLE_BITMAP : LEFT_BRACKET_BITMAP) | 1093 : LEFT_FRINGE (2, Qtop, 0)); |
911 : TOP_LEFT_ANGLE_BITMAP); | |
912 else if (row->indicate_eob_p && EQ (boundary_bot, Qleft)) | 1094 else if (row->indicate_eob_p && EQ (boundary_bot, Qleft)) |
913 left = (row->ends_at_zv_p | 1095 left = LEFT_FRINGE (3, Qbottom, row->ends_at_zv_p); |
914 ? TOP_RIGHT_ANGLE_BITMAP : BOTTOM_LEFT_ANGLE_BITMAP); | |
915 else if (MATRIX_ROW_CONTINUATION_LINE_P (row)) | 1096 else if (MATRIX_ROW_CONTINUATION_LINE_P (row)) |
916 left = CONTINUATION_LINE_BITMAP; | 1097 left = LEFT_FRINGE (4, Qcontinuation, 0); |
917 else if (row->indicate_empty_line_p && EQ (empty_pos, Qleft)) | 1098 else if (row->indicate_empty_line_p && EQ (empty_pos, Qleft)) |
918 left = ZV_LINE_BITMAP; | 1099 left = LEFT_FRINGE (5, Qempty_line, 0); |
919 else if (row->indicate_top_line_p && EQ (arrow_top, Qleft)) | 1100 else if (row->indicate_top_line_p && EQ (arrow_top, Qleft)) |
920 left = UP_ARROW_BITMAP; | 1101 left = LEFT_FRINGE (6, Qup, 0); |
921 else if (row->indicate_bottom_line_p && EQ (arrow_bot, Qleft)) | 1102 else if (row->indicate_bottom_line_p && EQ (arrow_bot, Qleft)) |
922 left = DOWN_ARROW_BITMAP; | 1103 left = LEFT_FRINGE (7, Qdown, 0); |
923 else | 1104 else |
924 left = NO_FRINGE_BITMAP; | 1105 left = NO_FRINGE_BITMAP; |
925 | 1106 |
926 /* Decide which bitmap to draw in the right fringe. */ | 1107 /* Decide which bitmap to draw in the right fringe. */ |
927 if (WINDOW_RIGHT_FRINGE_WIDTH (w) == 0) | 1108 if (WINDOW_RIGHT_FRINGE_WIDTH (w) == 0) |
930 { | 1111 { |
931 right = row->right_user_fringe_bitmap; | 1112 right = row->right_user_fringe_bitmap; |
932 right_face_id = row->right_user_fringe_face_id; | 1113 right_face_id = row->right_user_fringe_face_id; |
933 } | 1114 } |
934 else if (row->truncated_on_right_p) | 1115 else if (row->truncated_on_right_p) |
935 right = RIGHT_TRUNCATION_BITMAP; | 1116 right = RIGHT_FRINGE (0, Qtruncation, 0); |
936 else if (row->indicate_bob_p && EQ (boundary_top, Qright)) | 1117 else if (row->indicate_bob_p && EQ (boundary_top, Qright)) |
937 right = ((row->indicate_eob_p && EQ (boundary_bot, Qright)) | 1118 right = ((row->indicate_eob_p && EQ (boundary_bot, Qright)) |
938 ? (row->ends_at_zv_p | 1119 ? RIGHT_FRINGE (1, Qtop_bottom, row->ends_at_zv_p) |
939 ? TOP_LEFT_ANGLE_BITMAP : RIGHT_BRACKET_BITMAP) | 1120 : RIGHT_FRINGE (2, Qtop, 0)); |
940 : TOP_RIGHT_ANGLE_BITMAP); | |
941 else if (row->indicate_eob_p && EQ (boundary_bot, Qright)) | 1121 else if (row->indicate_eob_p && EQ (boundary_bot, Qright)) |
942 right = (row->ends_at_zv_p | 1122 right = RIGHT_FRINGE (3, Qbottom, row->ends_at_zv_p); |
943 ? TOP_LEFT_ANGLE_BITMAP : BOTTOM_RIGHT_ANGLE_BITMAP); | |
944 else if (row->continued_p) | 1123 else if (row->continued_p) |
945 right = CONTINUED_LINE_BITMAP; | 1124 right = RIGHT_FRINGE (4, Qcontinuation, 0); |
946 else if (row->indicate_top_line_p && EQ (arrow_top, Qright)) | 1125 else if (row->indicate_top_line_p && EQ (arrow_top, Qright)) |
947 right = UP_ARROW_BITMAP; | 1126 right = RIGHT_FRINGE (6, Qup, 0); |
948 else if (row->indicate_bottom_line_p && EQ (arrow_bot, Qright)) | 1127 else if (row->indicate_bottom_line_p && EQ (arrow_bot, Qright)) |
949 right = DOWN_ARROW_BITMAP; | 1128 right = RIGHT_FRINGE (7, Qdown, 0); |
950 else if (row->indicate_empty_line_p && EQ (empty_pos, Qright)) | 1129 else if (row->indicate_empty_line_p && EQ (empty_pos, Qright)) |
951 right = ZV_LINE_BITMAP; | 1130 right = RIGHT_FRINGE (5, Qempty_line, 0); |
952 else | 1131 else |
953 right = NO_FRINGE_BITMAP; | 1132 right = NO_FRINGE_BITMAP; |
954 | 1133 |
955 if (row->y != cur->y | 1134 if (row->y != cur->y |
956 || row->visible_height != cur->visible_height | 1135 || row->visible_height != cur->visible_height |
1148 On W32 and MAC (little endian), there's no need to do this. | 1327 On W32 and MAC (little endian), there's no need to do this. |
1149 */ | 1328 */ |
1150 | 1329 |
1151 void | 1330 void |
1152 init_fringe_bitmap (which, fb, once_p) | 1331 init_fringe_bitmap (which, fb, once_p) |
1153 enum fringe_bitmap_type which; | 1332 int which; |
1154 struct fringe_bitmap *fb; | 1333 struct fringe_bitmap *fb; |
1155 int once_p; | 1334 int once_p; |
1156 { | 1335 { |
1157 if (once_p || fb->dynamic) | 1336 if (once_p || fb->dynamic) |
1158 { | 1337 { |
1434 ***********************************************************************/ | 1613 ***********************************************************************/ |
1435 | 1614 |
1436 void | 1615 void |
1437 syms_of_fringe () | 1616 syms_of_fringe () |
1438 { | 1617 { |
1618 Qtruncation = intern ("truncation"); | |
1619 staticpro (&Qtruncation); | |
1620 Qcontinuation = intern ("continuation"); | |
1621 staticpro (&Qcontinuation); | |
1622 Qoverlay_arrow = intern ("overlay-arrow"); | |
1623 staticpro (&Qoverlay_arrow); | |
1624 Qempty_line = intern ("empty-line"); | |
1625 staticpro (&Qempty_line); | |
1626 Qtop_bottom = intern ("top-bottom"); | |
1627 staticpro (&Qtop_bottom); | |
1628 Qhollow_small = intern ("hollow-small"); | |
1629 staticpro (&Qhollow_small); | |
1630 | |
1439 defsubr (&Sdestroy_fringe_bitmap); | 1631 defsubr (&Sdestroy_fringe_bitmap); |
1440 defsubr (&Sdefine_fringe_bitmap); | 1632 defsubr (&Sdefine_fringe_bitmap); |
1441 defsubr (&Sfringe_bitmaps_at_pos); | 1633 defsubr (&Sfringe_bitmaps_at_pos); |
1442 defsubr (&Sset_fringe_bitmap_face); | 1634 defsubr (&Sset_fringe_bitmap_face); |
1443 | 1635 |
1471 /* Initialize this module when Emacs starts. */ | 1663 /* Initialize this module when Emacs starts. */ |
1472 | 1664 |
1473 void | 1665 void |
1474 init_fringe_once () | 1666 init_fringe_once () |
1475 { | 1667 { |
1476 enum fringe_bitmap_type bt; | 1668 int bt; |
1477 | 1669 |
1478 for (bt = NO_FRINGE_BITMAP + 1; bt < MAX_STANDARD_FRINGE_BITMAPS; bt++) | 1670 for (bt = NO_FRINGE_BITMAP + 1; bt < MAX_STANDARD_FRINGE_BITMAPS; bt++) |
1479 init_fringe_bitmap(bt, &standard_bitmaps[bt], 1); | 1671 init_fringe_bitmap(bt, &standard_bitmaps[bt], 1); |
1480 } | 1672 } |
1481 | 1673 |
1501 #ifdef HAVE_NTGUI | 1693 #ifdef HAVE_NTGUI |
1502 | 1694 |
1503 void | 1695 void |
1504 w32_init_fringe () | 1696 w32_init_fringe () |
1505 { | 1697 { |
1506 enum fringe_bitmap_type bt; | 1698 int bt; |
1507 | 1699 |
1508 if (!rif) | 1700 if (!rif) |
1509 return; | 1701 return; |
1510 | 1702 |
1511 for (bt = NO_FRINGE_BITMAP + 1; bt < MAX_STANDARD_FRINGE_BITMAPS; bt++) | 1703 for (bt = NO_FRINGE_BITMAP + 1; bt < MAX_STANDARD_FRINGE_BITMAPS; bt++) |