(map-keymap): Definition deleted.
[emacs.git] / src / fringe.c
blob6ebbb334bbb52c3eb6a9dfd8ea2628762420129e
1 /* Fringe handling (split from xdisp.c).
2 Copyright (C) 1985,86,87,88,93,94,95,97,98,99,2000,01,02,03,04
3 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 #include <config.h>
23 #include <stdio.h>
25 #include "lisp.h"
26 #include "frame.h"
27 #include "window.h"
28 #include "dispextern.h"
29 #include "buffer.h"
30 #include "blockinput.h"
32 #ifdef HAVE_WINDOW_SYSTEM
34 extern Lisp_Object Qfringe;
35 extern Lisp_Object Qtop, Qbottom, Qcenter;
36 extern Lisp_Object Qup, Qdown, Qleft, Qright;
38 /* Non-nil means that newline may flow into the right fringe. */
40 Lisp_Object Voverflow_newline_into_fringe;
42 /* List of known fringe bitmap symbols.
44 The fringe bitmap number is stored in the `fringe' property on
45 those symbols. Names for the built-in bitmaps are installed by
46 loading fringe.el.
49 Lisp_Object Vfringe_bitmaps;
51 enum fringe_bitmap_type
53 NO_FRINGE_BITMAP = 0,
54 UNDEF_FRINGE_BITMAP,
55 LEFT_TRUNCATION_BITMAP,
56 RIGHT_TRUNCATION_BITMAP,
57 UP_ARROW_BITMAP,
58 DOWN_ARROW_BITMAP,
59 CONTINUED_LINE_BITMAP,
60 CONTINUATION_LINE_BITMAP,
61 OVERLAY_ARROW_BITMAP,
62 TOP_LEFT_ANGLE_BITMAP,
63 TOP_RIGHT_ANGLE_BITMAP,
64 BOTTOM_LEFT_ANGLE_BITMAP,
65 BOTTOM_RIGHT_ANGLE_BITMAP,
66 LEFT_BRACKET_BITMAP,
67 RIGHT_BRACKET_BITMAP,
68 FILLED_BOX_CURSOR_BITMAP,
69 HOLLOW_BOX_CURSOR_BITMAP,
70 HOLLOW_SQUARE_BITMAP,
71 BAR_CURSOR_BITMAP,
72 HBAR_CURSOR_BITMAP,
73 ZV_LINE_BITMAP,
74 MAX_STANDARD_FRINGE_BITMAPS
77 enum fringe_bitmap_align
79 ALIGN_BITMAP_CENTER = 0,
80 ALIGN_BITMAP_TOP,
81 ALIGN_BITMAP_BOTTOM
84 struct fringe_bitmap
86 unsigned short *bits;
87 unsigned height : 8;
88 unsigned width : 8;
89 unsigned period : 8;
90 unsigned align : 2;
91 unsigned dynamic : 1;
95 /***********************************************************************
96 Fringe bitmaps
97 ***********************************************************************/
99 /* Undefined bitmap. A question mark. */
101 ..xxxx..
102 .xxxxxx.
103 xx....xx
104 xx....xx
105 ....xx..
106 ...xx...
107 ...xx...
108 ........
109 ...xx...
110 ...xx...
112 static unsigned short unknown_bits[] = {
113 0x3c, 0x7e, 0x7e, 0x0c, 0x18, 0x18, 0x00, 0x18, 0x18};
115 /* An arrow like this: `<-'. */
117 ...xx...
118 ..xx....
119 .xx.....
120 xxxxxx..
121 xxxxxx..
122 .xx.....
123 ..xx....
124 ...xx...
126 static unsigned short left_arrow_bits[] = {
127 0x18, 0x30, 0x60, 0xfc, 0xfc, 0x60, 0x30, 0x18};
130 /* Right truncation arrow bitmap `->'. */
132 ...xx...
133 ....xx..
134 .....xx.
135 ..xxxxxx
136 ..xxxxxx
137 .....xx.
138 ....xx..
139 ...xx...
141 static unsigned short right_arrow_bits[] = {
142 0x18, 0x0c, 0x06, 0x3f, 0x3f, 0x06, 0x0c, 0x18};
145 /* Up arrow bitmap. */
147 ...xx...
148 ..xxxx..
149 .xxxxxx.
150 xxxxxxxx
151 ...xx...
152 ...xx...
153 ...xx...
154 ...xx...
156 static unsigned short up_arrow_bits[] = {
157 0x18, 0x3c, 0x7e, 0xff, 0x18, 0x18, 0x18, 0x18};
160 /* Down arrow bitmap. */
162 ...xx...
163 ...xx...
164 ...xx...
165 ...xx...
166 xxxxxxxx
167 .xxxxxx.
168 ..xxxx..
169 ...xx...
171 static unsigned short down_arrow_bits[] = {
172 0x18, 0x18, 0x18, 0x18, 0xff, 0x7e, 0x3c, 0x18};
174 /* Marker for continued lines. */
176 ..xxxx..
177 ..xxxxx.
178 ......xx
179 ..x..xxx
180 ..xxxxxx
181 ..xxxxx.
182 ..xxxx..
183 ..xxxxx.
185 static unsigned short continued_bits[] = {
186 0x3c, 0x3e, 0x03, 0x27, 0x3f, 0x3e, 0x3c, 0x3e};
188 /* Marker for continuation lines. */
190 ..xxxx..
191 .xxxxx..
192 xx......
193 xxx..x..
194 xxxxxx..
195 .xxxxx..
196 ..xxxx..
197 .xxxxx..
199 static unsigned short continuation_bits[] = {
200 0x3c, 0x7c, 0xc0, 0xe4, 0xfc, 0x7c, 0x3c, 0x7c};
202 /* Overlay arrow bitmap. A triangular arrow. */
204 xx......
205 xxxx....
206 xxxxx...
207 xxxxxx..
208 xxxxxx..
209 xxxxx...
210 xxxx....
211 xx......
213 static unsigned short ov_bits[] = {
214 0xc0, 0xf0, 0xf8, 0xfc, 0xfc, 0xf8, 0xf0, 0xc0};
216 #if 0
217 /* Reverse Overlay arrow bitmap. A triangular arrow. */
219 ......xx
220 ....xxxx
221 ...xxxxx
222 ..xxxxxx
223 ..xxxxxx
224 ...xxxxx
225 ....xxxx
226 ......xx
228 static unsigned short rev_ov_bits[] = {
229 0x03, 0x0f, 0x1f, 0x3f, 0x3f, 0x1f, 0x0f, 0x03};
230 #endif
232 /* First line bitmap. An top-left angle. */
234 xxxxxx..
235 xxxxxx..
236 xx......
237 xx......
238 xx......
239 xx......
240 xx......
241 ........
243 static unsigned short top_left_angle_bits[] = {
244 0xfc, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00};
246 /* First line bitmap. An right-up angle. */
248 ..xxxxxx
249 ..xxxxxx
250 ......xx
251 ......xx
252 ......xx
253 ......xx
254 ......xx
255 ........
257 static unsigned short top_right_angle_bits[] = {
258 0x3f, 0x3f, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00};
260 /* Last line bitmap. An left-down angle. */
262 ........
263 xx......
264 xx......
265 xx......
266 xx......
267 xx......
268 xxxxxx..
269 xxxxxx..
271 static unsigned short bottom_left_angle_bits[] = {
272 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xfc};
274 /* Last line bitmap. An right-down angle. */
276 ........
277 ......xx
278 ......xx
279 ......xx
280 ......xx
281 ......xx
282 ..xxxxxx
283 ..xxxxxx
285 static unsigned short bottom_right_angle_bits[] = {
286 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x3f, 0x3f};
288 /* First/last line bitmap. An left bracket. */
290 xxxxxx..
291 xxxxxx..
292 xx......
293 xx......
294 xx......
295 xx......
296 xx......
297 xx......
298 xxxxxx..
299 xxxxxx..
301 static unsigned short left_bracket_bits[] = {
302 0xfc, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xfc};
304 /* First/last line bitmap. An right bracket. */
306 ..xxxxxx
307 ..xxxxxx
308 ......xx
309 ......xx
310 ......xx
311 ......xx
312 ......xx
313 ......xx
314 ..xxxxxx
315 ..xxxxxx
317 static unsigned short right_bracket_bits[] = {
318 0x3f, 0x3f, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x3f, 0x3f};
320 /* Filled box cursor bitmap. A filled box; max 13 pixels high. */
322 xxxxxxx.
323 xxxxxxx.
324 xxxxxxx.
325 xxxxxxx.
326 xxxxxxx.
327 xxxxxxx.
328 xxxxxxx.
329 xxxxxxx.
330 xxxxxxx.
331 xxxxxxx.
332 xxxxxxx.
333 xxxxxxx.
334 xxxxxxx.
336 static unsigned short filled_box_cursor_bits[] = {
337 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
339 /* Hollow box cursor bitmap. A hollow box; max 13 pixels high. */
341 xxxxxxx.
342 x.....x.
343 x.....x.
344 x.....x.
345 x.....x.
346 x.....x.
347 x.....x.
348 x.....x.
349 x.....x.
350 x.....x.
351 x.....x.
352 x.....x.
353 xxxxxxx.
355 static unsigned short hollow_box_cursor_bits[] = {
356 0xfe, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0xfe};
358 /* Bar cursor bitmap. A vertical bar; max 13 pixels high. */
360 xx......
361 xx......
362 xx......
363 xx......
364 xx......
365 xx......
366 xx......
367 xx......
368 xx......
369 xx......
370 xx......
371 xx......
372 xx......
374 static unsigned short bar_cursor_bits[] = {
375 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0};
377 /* HBar cursor bitmap. A horisontal bar; 2 pixels high. */
379 xxxxxxx.
380 xxxxxxx.
382 static unsigned short hbar_cursor_bits[] = {
383 0xfe, 0xfe};
386 /* Bitmap drawn to indicate lines not displaying text if
387 `indicate-empty-lines' is non-nil. */
389 ........
390 ..xxxx..
391 ........
392 ........
393 ..xxxx..
394 ........
396 static unsigned short zv_bits[] = {
397 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
398 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
399 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
400 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
401 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
402 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
403 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
404 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00};
406 /* Hollow square bitmap. */
408 .xxxxxx.
409 .x....x.
410 .x....x.
411 .x....x.
412 .x....x.
413 .xxxxxx.
415 static unsigned short hollow_square_bits[] = {
416 0x7e, 0x42, 0x42, 0x42, 0x42, 0x7e};
419 #define BYTES_PER_BITMAP_ROW (sizeof (unsigned short))
420 #define STANDARD_BITMAP_HEIGHT(bits) (sizeof (bits)/BYTES_PER_BITMAP_ROW)
421 #define FRBITS(bits) bits, STANDARD_BITMAP_HEIGHT (bits)
423 struct fringe_bitmap standard_bitmaps[MAX_STANDARD_FRINGE_BITMAPS] =
425 { NULL, 0, 0, 0, 0, 0 }, /* NO_FRINGE_BITMAP */
426 { FRBITS (unknown_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
427 { FRBITS (left_arrow_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
428 { FRBITS (right_arrow_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
429 { FRBITS (up_arrow_bits), 8, 0, ALIGN_BITMAP_TOP, 0 },
430 { FRBITS (down_arrow_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 },
431 { FRBITS (continued_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
432 { FRBITS (continuation_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
433 { FRBITS (ov_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
434 { FRBITS (top_left_angle_bits), 8, 0, ALIGN_BITMAP_TOP, 0 },
435 { FRBITS (top_right_angle_bits), 8, 0, ALIGN_BITMAP_TOP, 0 },
436 { FRBITS (bottom_left_angle_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 },
437 { FRBITS (bottom_right_angle_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 },
438 { FRBITS (left_bracket_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
439 { FRBITS (right_bracket_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
440 { FRBITS (filled_box_cursor_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
441 { FRBITS (hollow_box_cursor_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
442 { FRBITS (hollow_square_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
443 { FRBITS (bar_cursor_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 },
444 { FRBITS (hbar_cursor_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 },
445 { FRBITS (zv_bits), 8, 3, ALIGN_BITMAP_TOP, 0 },
448 static struct fringe_bitmap **fringe_bitmaps;
449 static unsigned *fringe_faces;
450 static int max_fringe_bitmaps;
452 static int max_used_fringe_bitmap = MAX_STANDARD_FRINGE_BITMAPS;
455 /* Lookup bitmap number for symbol BITMAP.
456 Return 0 if not a bitmap. */
459 lookup_fringe_bitmap (bitmap)
460 Lisp_Object bitmap;
462 int bn;
464 bitmap = Fget (bitmap, Qfringe);
465 if (!INTEGERP (bitmap))
466 return 0;
468 bn = XINT (bitmap);
469 if (bn > NO_FRINGE_BITMAP
470 && bn < max_used_fringe_bitmap
471 && (bn < MAX_STANDARD_FRINGE_BITMAPS
472 || fringe_bitmaps[bn] != NULL))
473 return bn;
475 return 0;
478 /* Get fringe bitmap name for bitmap number BN.
480 Found by traversing Vfringe_bitmaps comparing BN to the
481 fringe property for each symbol.
483 Return BN if not found in Vfringe_bitmaps. */
485 static Lisp_Object
486 get_fringe_bitmap_name (bn)
487 int bn;
489 Lisp_Object bitmaps;
490 Lisp_Object num;
492 /* Zero means no bitmap -- return nil. */
493 if (bn <= 0)
494 return Qnil;
496 bitmaps = Vfringe_bitmaps;
497 num = make_number (bn);
499 while (CONSP (bitmaps))
501 Lisp_Object bitmap = XCAR (bitmaps);
502 if (EQ (num, Fget (bitmap, Qfringe)))
503 return bitmap;
504 bitmaps = XCDR (bitmaps);
507 return num;
511 /* Draw the bitmap WHICH in one of the left or right fringes of
512 window W. ROW is the glyph row for which to display the bitmap; it
513 determines the vertical position at which the bitmap has to be
514 drawn.
515 LEFT_P is 1 for left fringe, 0 for right fringe.
518 void
519 draw_fringe_bitmap_1 (w, row, left_p, overlay, which)
520 struct window *w;
521 struct glyph_row *row;
522 int left_p, overlay;
523 enum fringe_bitmap_type which;
525 struct frame *f = XFRAME (WINDOW_FRAME (w));
526 struct draw_fringe_bitmap_params p;
527 struct fringe_bitmap *fb;
528 int period;
529 int face_id = DEFAULT_FACE_ID;
531 p.cursor_p = 0;
532 p.overlay_p = (overlay & 1) == 1;
533 p.cursor_p = (overlay & 2) == 2;
535 if (which != NO_FRINGE_BITMAP)
538 else if (left_p)
540 which = row->left_fringe_bitmap;
541 face_id = row->left_fringe_face_id;
543 else
545 which = row->right_fringe_bitmap;
546 face_id = row->right_fringe_face_id;
549 if (face_id == DEFAULT_FACE_ID)
550 face_id = fringe_faces[which];
552 fb = fringe_bitmaps[which];
553 if (fb == NULL)
554 fb = &standard_bitmaps[which < MAX_STANDARD_FRINGE_BITMAPS
555 ? which : UNDEF_FRINGE_BITMAP];
557 period = fb->period;
559 /* Convert row to frame coordinates. */
560 p.y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
562 p.which = which;
563 p.bits = fb->bits;
564 p.wd = fb->width;
566 p.h = fb->height;
567 p.dh = (period > 0 ? (p.y % period) : 0);
568 p.h -= p.dh;
569 /* Clip bitmap if too high. */
570 if (p.h > row->height)
571 p.h = row->height;
573 p.face = FACE_FROM_ID (f, face_id);
575 if (p.face == NULL)
577 /* Why does this happen? ++kfs */
578 return;
581 PREPARE_FACE_FOR_DISPLAY (f, p.face);
583 /* Clear left fringe if no bitmap to draw or if bitmap doesn't fill
584 the fringe. */
585 p.bx = -1;
586 if (left_p)
588 int wd = WINDOW_LEFT_FRINGE_WIDTH (w);
589 int x = window_box_left (w, (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
590 ? LEFT_MARGIN_AREA
591 : TEXT_AREA));
592 if (p.wd > wd)
593 p.wd = wd;
594 p.x = x - p.wd - (wd - p.wd) / 2;
596 if (p.wd < wd || row->height > p.h)
598 /* If W has a vertical border to its left, don't draw over it. */
599 wd -= ((!WINDOW_LEFTMOST_P (w)
600 && !WINDOW_HAS_VERTICAL_SCROLL_BAR (w))
601 ? 1 : 0);
602 p.bx = x - wd;
603 p.nx = wd;
606 else
608 int x = window_box_right (w,
609 (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
610 ? RIGHT_MARGIN_AREA
611 : TEXT_AREA));
612 int wd = WINDOW_RIGHT_FRINGE_WIDTH (w);
613 if (p.wd > wd)
614 p.wd = wd;
615 p.x = x + (wd - p.wd) / 2;
616 /* Clear right fringe if no bitmap to draw of if bitmap doesn't fill
617 the fringe. */
618 if (p.wd < wd || row->height > p.h)
620 p.bx = x;
621 p.nx = wd;
625 if (p.bx >= 0)
627 int header_line_height = WINDOW_HEADER_LINE_HEIGHT (w);
629 p.by = WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height, row->y));
630 p.ny = row->visible_height;
633 /* Adjust y to the offset in the row to start drawing the bitmap. */
634 switch (fb->align)
636 case ALIGN_BITMAP_CENTER:
637 p.y += (row->height - p.h) / 2;
638 break;
639 case ALIGN_BITMAP_BOTTOM:
640 p.h = fb->height;
641 p.y += (row->visible_height - p.h);
642 break;
643 case ALIGN_BITMAP_TOP:
644 break;
647 rif->draw_fringe_bitmap (w, row, &p);
650 void
651 draw_fringe_bitmap (w, row, left_p)
652 struct window *w;
653 struct glyph_row *row;
654 int left_p;
656 int overlay = 0;
658 if (!left_p && row->cursor_in_fringe_p)
660 int cursor = NO_FRINGE_BITMAP;
662 switch (w->phys_cursor_type)
664 case HOLLOW_BOX_CURSOR:
665 if (row->visible_height >= STANDARD_BITMAP_HEIGHT (hollow_box_cursor_bits))
666 cursor = HOLLOW_BOX_CURSOR_BITMAP;
667 else
668 cursor = HOLLOW_SQUARE_BITMAP;
669 break;
670 case FILLED_BOX_CURSOR:
671 cursor = FILLED_BOX_CURSOR_BITMAP;
672 break;
673 case BAR_CURSOR:
674 cursor = BAR_CURSOR_BITMAP;
675 break;
676 case HBAR_CURSOR:
677 cursor = HBAR_CURSOR_BITMAP;
678 break;
679 case NO_CURSOR:
680 default:
681 w->phys_cursor_on_p = 0;
682 row->cursor_in_fringe_p = 0;
683 break;
685 if (cursor != NO_FRINGE_BITMAP)
687 draw_fringe_bitmap_1 (w, row, 0, 2, cursor);
688 overlay = cursor == FILLED_BOX_CURSOR_BITMAP ? 3 : 1;
692 draw_fringe_bitmap_1 (w, row, left_p, overlay, NO_FRINGE_BITMAP);
694 if (left_p && row->overlay_arrow_p)
695 draw_fringe_bitmap_1 (w, row, 1, 1,
696 (w->overlay_arrow_bitmap
697 ? w->overlay_arrow_bitmap
698 : OVERLAY_ARROW_BITMAP));
702 /* Draw fringe bitmaps for glyph row ROW on window W. Call this
703 function with input blocked. */
705 void
706 draw_row_fringe_bitmaps (w, row)
707 struct window *w;
708 struct glyph_row *row;
710 xassert (interrupt_input_blocked);
712 /* If row is completely invisible, because of vscrolling, we
713 don't have to draw anything. */
714 if (row->visible_height <= 0)
715 return;
717 if (WINDOW_LEFT_FRINGE_WIDTH (w) != 0)
718 draw_fringe_bitmap (w, row, 1);
720 if (WINDOW_RIGHT_FRINGE_WIDTH (w) != 0)
721 draw_fringe_bitmap (w, row, 0);
724 /* Draw the fringes of window W. Only fringes for rows marked for
725 update in redraw_fringe_bitmaps_p are drawn.
727 Return >0 if left or right fringe was redrawn in any way.
729 If NO_FRINGE is non-zero, also return >0 if either fringe has zero width.
731 A return value >0 indicates that the vertical line between windows
732 needs update (as it may be drawn in the fringe).
736 draw_window_fringes (w, no_fringe)
737 struct window *w;
738 int no_fringe;
740 struct glyph_row *row;
741 int yb = window_text_bottom_y (w);
742 int nrows = w->current_matrix->nrows;
743 int y = 0, rn;
744 int updated = 0;
746 if (w->pseudo_window_p)
747 return 0;
749 /* Must draw line if no fringe */
750 if (no_fringe
751 && (WINDOW_LEFT_FRINGE_WIDTH (w) == 0
752 || WINDOW_RIGHT_FRINGE_WIDTH (w) == 0))
753 updated++;
755 for (y = 0, rn = 0, row = w->current_matrix->rows;
756 y < yb && rn < nrows;
757 y += row->height, ++row, ++rn)
759 if (!row->redraw_fringe_bitmaps_p)
760 continue;
761 draw_row_fringe_bitmaps (w, row);
762 row->redraw_fringe_bitmaps_p = 0;
763 updated++;
766 return updated;
770 /* Recalculate the bitmaps to show in the fringes of window W.
771 If FORCE_P is 0, only mark rows with modified bitmaps for update in
772 redraw_fringe_bitmaps_p; else mark all rows for update. */
775 update_window_fringes (w, force_p)
776 struct window *w;
777 int force_p;
779 struct glyph_row *row, *cur = 0;
780 int yb = window_text_bottom_y (w);
781 int rn, nrows = w->current_matrix->nrows;
782 int y;
783 int redraw_p = 0;
784 Lisp_Object boundary_top = Qnil, boundary_bot = Qnil;
785 Lisp_Object arrow_top = Qnil, arrow_bot = Qnil;
786 Lisp_Object empty_pos;
787 Lisp_Object ind = Qnil;
789 if (w->pseudo_window_p)
790 return 0;
792 if (!MINI_WINDOW_P (w)
793 && (ind = XBUFFER (w->buffer)->indicate_buffer_boundaries, !NILP (ind)))
795 if (EQ (ind, Qleft) || EQ (ind, Qright))
796 boundary_top = boundary_bot = arrow_top = arrow_bot = ind;
797 else if (CONSP (ind) && CONSP (XCAR (ind)))
799 Lisp_Object pos;
800 if (pos = Fassq (Qt, ind), !NILP (pos))
801 boundary_top = boundary_bot = arrow_top = arrow_bot = XCDR (pos);
802 if (pos = Fassq (Qtop, ind), !NILP (pos))
803 boundary_top = XCDR (pos);
804 if (pos = Fassq (Qbottom, ind), !NILP (pos))
805 boundary_bot = XCDR (pos);
806 if (pos = Fassq (Qup, ind), !NILP (pos))
807 arrow_top = XCDR (pos);
808 if (pos = Fassq (Qdown, ind), !NILP (pos))
809 arrow_bot = XCDR (pos);
811 else
812 ind = Qnil;
815 if (!NILP (ind))
817 int do_eob = 1, do_bob = 1;
819 for (y = 0, rn = 0;
820 y < yb && rn < nrows;
821 y += row->height, ++rn)
823 unsigned indicate_bob_p, indicate_top_line_p;
824 unsigned indicate_eob_p, indicate_bottom_line_p;
826 row = w->desired_matrix->rows + rn;
827 if (!row->enabled_p)
828 row = w->current_matrix->rows + rn;
830 indicate_bob_p = row->indicate_bob_p;
831 indicate_top_line_p = row->indicate_top_line_p;
832 indicate_eob_p = row->indicate_eob_p;
833 indicate_bottom_line_p = row->indicate_bottom_line_p;
835 row->indicate_bob_p = row->indicate_top_line_p = 0;
836 row->indicate_eob_p = row->indicate_bottom_line_p = 0;
838 if (!NILP (boundary_top)
839 && MATRIX_ROW_START_CHARPOS (row) <= BUF_BEGV (XBUFFER (w->buffer)))
840 row->indicate_bob_p = do_bob, do_bob = 0;
841 else if (!NILP (arrow_top)
842 && (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0) == rn)
843 row->indicate_top_line_p = 1;
845 if (!NILP (boundary_bot)
846 && MATRIX_ROW_END_CHARPOS (row) >= BUF_ZV (XBUFFER (w->buffer)))
847 row->indicate_eob_p = do_eob, do_eob = 0;
848 else if (!NILP (arrow_bot)
849 && y + row->height >= yb)
850 row->indicate_bottom_line_p = 1;
852 if (indicate_bob_p != row->indicate_bob_p
853 || indicate_top_line_p != row->indicate_top_line_p
854 || indicate_eob_p != row->indicate_eob_p
855 || indicate_bottom_line_p != row->indicate_bottom_line_p)
856 row->redraw_fringe_bitmaps_p = 1;
860 empty_pos = XBUFFER (w->buffer)->indicate_empty_lines;
861 if (!NILP (empty_pos) && !EQ (empty_pos, Qright))
862 empty_pos = WINDOW_LEFT_FRINGE_WIDTH (w) == 0 ? Qright : Qleft;
864 for (y = 0, rn = 0;
865 y < yb && rn < nrows;
866 y += row->height, rn++)
868 enum fringe_bitmap_type left, right;
869 unsigned left_face_id, right_face_id;
871 row = w->desired_matrix->rows + rn;
872 cur = w->current_matrix->rows + rn;
873 if (!row->enabled_p)
874 row = cur;
876 left_face_id = right_face_id = DEFAULT_FACE_ID;
878 /* Decide which bitmap to draw in the left fringe. */
879 if (WINDOW_LEFT_FRINGE_WIDTH (w) == 0)
880 left = NO_FRINGE_BITMAP;
881 else if (row->left_user_fringe_bitmap != NO_FRINGE_BITMAP)
883 left = row->left_user_fringe_bitmap;
884 left_face_id = row->left_user_fringe_face_id;
886 else if (row->indicate_bob_p && EQ (boundary_top, Qleft))
887 left = ((row->indicate_eob_p && EQ (boundary_bot, Qleft))
888 ? LEFT_BRACKET_BITMAP : TOP_LEFT_ANGLE_BITMAP);
889 else if (row->indicate_eob_p && EQ (boundary_bot, Qleft))
890 left = BOTTOM_LEFT_ANGLE_BITMAP;
891 else if (row->truncated_on_left_p)
892 left = LEFT_TRUNCATION_BITMAP;
893 else if (MATRIX_ROW_CONTINUATION_LINE_P (row))
894 left = CONTINUATION_LINE_BITMAP;
895 else if (row->indicate_empty_line_p && EQ (empty_pos, Qleft))
896 left = ZV_LINE_BITMAP;
897 else if (row->indicate_top_line_p && EQ (arrow_top, Qleft))
898 left = UP_ARROW_BITMAP;
899 else if (row->indicate_bottom_line_p && EQ (arrow_bot, Qleft))
900 left = DOWN_ARROW_BITMAP;
901 else
902 left = NO_FRINGE_BITMAP;
904 /* Decide which bitmap to draw in the right fringe. */
905 if (WINDOW_RIGHT_FRINGE_WIDTH (w) == 0)
906 right = NO_FRINGE_BITMAP;
907 else if (row->right_user_fringe_bitmap != NO_FRINGE_BITMAP)
909 right = row->right_user_fringe_bitmap;
910 right_face_id = row->right_user_fringe_face_id;
912 else if (row->indicate_bob_p && EQ (boundary_top, Qright))
913 right = ((row->indicate_eob_p && EQ (boundary_bot, Qright))
914 ? RIGHT_BRACKET_BITMAP : TOP_RIGHT_ANGLE_BITMAP);
915 else if (row->indicate_eob_p && EQ (boundary_bot, Qright))
916 right = BOTTOM_RIGHT_ANGLE_BITMAP;
917 else if (row->truncated_on_right_p)
918 right = RIGHT_TRUNCATION_BITMAP;
919 else if (row->continued_p)
920 right = CONTINUED_LINE_BITMAP;
921 else if (row->indicate_top_line_p && EQ (arrow_top, Qright))
922 right = UP_ARROW_BITMAP;
923 else if (row->indicate_bottom_line_p && EQ (arrow_bot, Qright))
924 right = DOWN_ARROW_BITMAP;
925 else if (row->indicate_empty_line_p && EQ (empty_pos, Qright))
926 right = ZV_LINE_BITMAP;
927 else
928 right = NO_FRINGE_BITMAP;
930 if (force_p
931 || row->y != cur->y
932 || row->visible_height != cur->visible_height
933 || row->ends_at_zv_p != cur->ends_at_zv_p
934 || left != cur->left_fringe_bitmap
935 || right != cur->right_fringe_bitmap
936 || left_face_id != cur->left_fringe_face_id
937 || right_face_id != cur->right_fringe_face_id
938 || cur->redraw_fringe_bitmaps_p)
940 redraw_p = row->redraw_fringe_bitmaps_p = cur->redraw_fringe_bitmaps_p = 1;
941 cur->left_fringe_bitmap = left;
942 cur->right_fringe_bitmap = right;
943 cur->left_fringe_face_id = left_face_id;
944 cur->right_fringe_face_id = right_face_id;
947 if (row->overlay_arrow_p != cur->overlay_arrow_p)
949 redraw_p = row->redraw_fringe_bitmaps_p = cur->redraw_fringe_bitmaps_p = 1;
950 cur->overlay_arrow_p = row->overlay_arrow_p;
953 row->left_fringe_bitmap = left;
954 row->right_fringe_bitmap = right;
955 row->left_fringe_face_id = left_face_id;
956 row->right_fringe_face_id = right_face_id;
958 if (rn > 0 && row->redraw_fringe_bitmaps_p)
959 row[-1].redraw_fringe_bitmaps_p = cur[-1].redraw_fringe_bitmaps_p = 1;
962 return redraw_p;
966 /* Compute actual fringe widths for frame F.
968 If REDRAW is 1, redraw F if the fringe settings was actually
969 modified and F is visible.
971 Since the combined left and right fringe must occupy an integral
972 number of columns, we may need to add some pixels to each fringe.
973 Typically, we add an equal amount (+/- 1 pixel) to each fringe,
974 but a negative width value is taken literally (after negating it).
976 We never make the fringes narrower than specified.
979 void
980 compute_fringe_widths (f, redraw)
981 struct frame *f;
982 int redraw;
984 int o_left = FRAME_LEFT_FRINGE_WIDTH (f);
985 int o_right = FRAME_RIGHT_FRINGE_WIDTH (f);
986 int o_cols = FRAME_FRINGE_COLS (f);
988 Lisp_Object left_fringe = Fassq (Qleft_fringe, f->param_alist);
989 Lisp_Object right_fringe = Fassq (Qright_fringe, f->param_alist);
990 int left_fringe_width, right_fringe_width;
992 if (!NILP (left_fringe))
993 left_fringe = Fcdr (left_fringe);
994 if (!NILP (right_fringe))
995 right_fringe = Fcdr (right_fringe);
997 left_fringe_width = ((NILP (left_fringe) || !INTEGERP (left_fringe)) ? 8 :
998 XINT (left_fringe));
999 right_fringe_width = ((NILP (right_fringe) || !INTEGERP (right_fringe)) ? 8 :
1000 XINT (right_fringe));
1002 if (left_fringe_width || right_fringe_width)
1004 int left_wid = left_fringe_width >= 0 ? left_fringe_width : -left_fringe_width;
1005 int right_wid = right_fringe_width >= 0 ? right_fringe_width : -right_fringe_width;
1006 int conf_wid = left_wid + right_wid;
1007 int font_wid = FRAME_COLUMN_WIDTH (f);
1008 int cols = (left_wid + right_wid + font_wid-1) / font_wid;
1009 int real_wid = cols * font_wid;
1010 if (left_wid && right_wid)
1012 if (left_fringe_width < 0)
1014 /* Left fringe width is fixed, adjust right fringe if necessary */
1015 FRAME_LEFT_FRINGE_WIDTH (f) = left_wid;
1016 FRAME_RIGHT_FRINGE_WIDTH (f) = real_wid - left_wid;
1018 else if (right_fringe_width < 0)
1020 /* Right fringe width is fixed, adjust left fringe if necessary */
1021 FRAME_LEFT_FRINGE_WIDTH (f) = real_wid - right_wid;
1022 FRAME_RIGHT_FRINGE_WIDTH (f) = right_wid;
1024 else
1026 /* Adjust both fringes with an equal amount.
1027 Note that we are doing integer arithmetic here, so don't
1028 lose a pixel if the total width is an odd number. */
1029 int fill = real_wid - conf_wid;
1030 FRAME_LEFT_FRINGE_WIDTH (f) = left_wid + fill/2;
1031 FRAME_RIGHT_FRINGE_WIDTH (f) = right_wid + fill - fill/2;
1034 else if (left_fringe_width)
1036 FRAME_LEFT_FRINGE_WIDTH (f) = real_wid;
1037 FRAME_RIGHT_FRINGE_WIDTH (f) = 0;
1039 else
1041 FRAME_LEFT_FRINGE_WIDTH (f) = 0;
1042 FRAME_RIGHT_FRINGE_WIDTH (f) = real_wid;
1044 FRAME_FRINGE_COLS (f) = cols;
1046 else
1048 FRAME_LEFT_FRINGE_WIDTH (f) = 0;
1049 FRAME_RIGHT_FRINGE_WIDTH (f) = 0;
1050 FRAME_FRINGE_COLS (f) = 0;
1053 if (redraw && FRAME_VISIBLE_P (f))
1054 if (o_left != FRAME_LEFT_FRINGE_WIDTH (f) ||
1055 o_right != FRAME_RIGHT_FRINGE_WIDTH (f) ||
1056 o_cols != FRAME_FRINGE_COLS (f))
1057 redraw_frame (f);
1061 /* Free resources used by a user-defined bitmap. */
1063 void
1064 destroy_fringe_bitmap (n)
1065 int n;
1067 struct fringe_bitmap **fbp;
1069 fringe_faces[n] = FRINGE_FACE_ID;
1071 fbp = &fringe_bitmaps[n];
1072 if (*fbp && (*fbp)->dynamic)
1074 if (rif && rif->destroy_fringe_bitmap)
1075 rif->destroy_fringe_bitmap (n);
1076 xfree (*fbp);
1077 *fbp = NULL;
1080 while (max_used_fringe_bitmap > MAX_STANDARD_FRINGE_BITMAPS
1081 && fringe_bitmaps[max_used_fringe_bitmap - 1] == NULL)
1082 max_used_fringe_bitmap--;
1086 DEFUN ("destroy-fringe-bitmap", Fdestroy_fringe_bitmap, Sdestroy_fringe_bitmap,
1087 1, 1, 0,
1088 doc: /* Destroy fringe bitmap BITMAP.
1089 If BITMAP overrides a standard fringe bitmap, the original bitmap is restored. */)
1090 (bitmap)
1091 Lisp_Object bitmap;
1093 int n;
1095 CHECK_SYMBOL (bitmap);
1096 n = lookup_fringe_bitmap (bitmap);
1097 if (!n)
1098 return Qnil;
1100 destroy_fringe_bitmap (n);
1102 if (n >= MAX_STANDARD_FRINGE_BITMAPS)
1104 Vfringe_bitmaps = Fdelq (bitmap, Vfringe_bitmaps);
1105 /* It would be better to remove the fringe property. */
1106 Fput (bitmap, Qfringe, Qnil);
1109 return Qnil;
1113 /* Initialize bitmap bit.
1115 On X, we bit-swap the built-in bitmaps and reduce bitmap
1116 from short to char array if width is <= 8 bits.
1118 On MAC with big-endian CPU, we need to byte-swap each short.
1120 On W32 and MAC (little endian), there's no need to do this.
1123 void
1124 init_fringe_bitmap (which, fb, once_p)
1125 enum fringe_bitmap_type which;
1126 struct fringe_bitmap *fb;
1127 int once_p;
1129 if (once_p || fb->dynamic)
1131 #if defined (HAVE_X_WINDOWS)
1132 static unsigned char swap_nibble[16]
1133 = { 0x0, 0x8, 0x4, 0xc, /* 0000 1000 0100 1100 */
1134 0x2, 0xa, 0x6, 0xe, /* 0010 1010 0110 1110 */
1135 0x1, 0x9, 0x5, 0xd, /* 0001 1001 0101 1101 */
1136 0x3, 0xb, 0x7, 0xf }; /* 0011 1011 0111 1111 */
1137 unsigned short *bits = fb->bits;
1138 int j;
1140 if (fb->width <= 8)
1142 unsigned char *cbits = (unsigned char *)fb->bits;
1143 for (j = 0; j < fb->height; j++)
1145 unsigned short b = *bits++;
1146 unsigned char c;
1147 c = (unsigned char)((swap_nibble[b & 0xf] << 4)
1148 | (swap_nibble[(b>>4) & 0xf]));
1149 *cbits++ = (c >> (8 - fb->width));
1152 else
1154 for (j = 0; j < fb->height; j++)
1156 unsigned short b = *bits;
1157 b = (unsigned short)((swap_nibble[b & 0xf] << 12)
1158 | (swap_nibble[(b>>4) & 0xf] << 8)
1159 | (swap_nibble[(b>>8) & 0xf] << 4)
1160 | (swap_nibble[(b>>12) & 0xf]));
1161 *bits++ = (b >> (16 - fb->width));
1164 #endif /* HAVE_X_WINDOWS */
1166 #if defined (MAC_OS) && defined (WORDS_BIG_ENDIAN)
1167 unsigned short *bits = fb->bits;
1168 int j;
1169 for (j = 0; j < fb->height; j++)
1171 unsigned short b = *bits;
1172 *bits++ = ((b >> 8) & 0xff) | ((b & 0xff) << 8);
1174 #endif /* MAC_OS && WORDS_BIG_ENDIAN */
1177 if (!once_p)
1179 destroy_fringe_bitmap (which);
1181 if (rif && rif->define_fringe_bitmap)
1182 rif->define_fringe_bitmap (which, fb->bits, fb->height, fb->width);
1184 fringe_bitmaps[which] = fb;
1185 if (which >= max_used_fringe_bitmap)
1186 max_used_fringe_bitmap = which + 1;
1191 DEFUN ("define-fringe-bitmap", Fdefine_fringe_bitmap, Sdefine_fringe_bitmap,
1192 2, 5, 0,
1193 doc: /* Define fringe bitmap BITMAP from BITS of size HEIGHT x WIDTH.
1194 BITMAP is a symbol or string naming the new fringe bitmap.
1195 BITS is either a string or a vector of integers.
1196 HEIGHT is height of bitmap. If HEIGHT is nil, use length of BITS.
1197 WIDTH must be an integer between 1 and 16, or nil which defaults to 8.
1198 Optional fifth arg ALIGN may be one of `top', `center', or `bottom',
1199 indicating the positioning of the bitmap relative to the rows where it
1200 is used; the default is to center the bitmap. Fourth arg may also be a
1201 list (ALIGN PERIODIC) where PERIODIC non-nil specifies that the bitmap
1202 should be repeated.
1203 If BITMAP already exists, the existing definition is replaced. */)
1204 (bitmap, bits, height, width, align)
1205 Lisp_Object bitmap, bits, height, width, align;
1207 int n, h, i, j;
1208 unsigned short *b;
1209 struct fringe_bitmap fb, *xfb;
1210 int fill1 = 0, fill2 = 0;
1212 CHECK_SYMBOL (bitmap);
1214 if (STRINGP (bits))
1215 h = SCHARS (bits);
1216 else if (VECTORP (bits))
1217 h = XVECTOR (bits)->size;
1218 else
1219 bits = wrong_type_argument (Qsequencep, bits);
1221 if (NILP (height))
1222 fb.height = h;
1223 else
1225 CHECK_NUMBER (height);
1226 fb.height = min (XINT (height), 255);
1227 if (fb.height > h)
1229 fill1 = (fb.height - h) / 2;
1230 fill2 = fb.height - h - fill1;
1234 if (NILP (width))
1235 fb.width = 8;
1236 else
1238 CHECK_NUMBER (width);
1239 fb.width = min (XINT (width), 255);
1242 fb.period = 0;
1243 fb.align = ALIGN_BITMAP_CENTER;
1245 if (CONSP (align))
1247 Lisp_Object period = XCDR (align);
1248 if (CONSP (period))
1250 period = XCAR (period);
1251 if (!NILP (period))
1253 fb.period = fb.height;
1254 fb.height = 255;
1257 align = XCAR (align);
1259 if (EQ (align, Qtop))
1260 fb.align = ALIGN_BITMAP_TOP;
1261 else if (EQ (align, Qbottom))
1262 fb.align = ALIGN_BITMAP_BOTTOM;
1263 else if (!NILP (align) && !EQ (align, Qcenter))
1264 error ("Bad align argument");
1266 n = lookup_fringe_bitmap (bitmap);
1267 if (!n)
1269 if (max_used_fringe_bitmap < max_fringe_bitmaps)
1270 n = max_used_fringe_bitmap++;
1271 else
1273 for (n = MAX_STANDARD_FRINGE_BITMAPS;
1274 n < max_fringe_bitmaps;
1275 n++)
1276 if (fringe_bitmaps[n] == NULL)
1277 break;
1279 if (n == max_fringe_bitmaps)
1281 if ((max_fringe_bitmaps + 20) > MAX_FRINGE_BITMAPS)
1282 error ("No free fringe bitmap slots");
1284 i = max_fringe_bitmaps;
1285 max_fringe_bitmaps += 20;
1286 fringe_bitmaps
1287 = ((struct fringe_bitmap **)
1288 xrealloc (fringe_bitmaps, max_fringe_bitmaps * sizeof (struct fringe_bitmap *)));
1289 fringe_faces
1290 = (unsigned *) xrealloc (fringe_faces, max_fringe_bitmaps * sizeof (unsigned));
1292 for (; i < max_fringe_bitmaps; i++)
1294 fringe_bitmaps[i] = NULL;
1295 fringe_faces[i] = FRINGE_FACE_ID;
1300 Vfringe_bitmaps = Fcons (bitmap, Vfringe_bitmaps);
1301 Fput (bitmap, Qfringe, make_number (n));
1304 fb.dynamic = 1;
1306 xfb = (struct fringe_bitmap *) xmalloc (sizeof fb
1307 + fb.height * BYTES_PER_BITMAP_ROW);
1308 fb.bits = b = (unsigned short *) (xfb + 1);
1309 bzero (b, fb.height);
1311 j = 0;
1312 while (j < fb.height)
1314 for (i = 0; i < fill1 && j < fb.height; i++)
1315 b[j++] = 0;
1316 for (i = 0; i < h && j < fb.height; i++)
1318 Lisp_Object elt = Faref (bits, make_number (i));
1319 b[j++] = NUMBERP (elt) ? XINT (elt) : 0;
1321 for (i = 0; i < fill2 && j < fb.height; i++)
1322 b[j++] = 0;
1325 *xfb = fb;
1327 init_fringe_bitmap (n, xfb, 0);
1329 return bitmap;
1332 DEFUN ("set-fringe-bitmap-face", Fset_fringe_bitmap_face, Sset_fringe_bitmap_face,
1333 1, 2, 0,
1334 doc: /* Set face for fringe bitmap BITMAP to FACE.
1335 If FACE is nil, reset face to default fringe face. */)
1336 (bitmap, face)
1337 Lisp_Object bitmap, face;
1339 int n;
1340 int face_id;
1342 CHECK_SYMBOL (bitmap);
1343 n = lookup_fringe_bitmap (bitmap);
1344 if (!n)
1345 error ("Undefined fringe bitmap");
1347 if (!NILP (face))
1349 face_id = lookup_named_face (SELECTED_FRAME (), face, 'A');
1350 if (face_id < 0)
1351 error ("No such face");
1353 else
1354 face_id = FRINGE_FACE_ID;
1356 fringe_faces[n] = face_id;
1358 return Qnil;
1361 DEFUN ("fringe-bitmaps-at-pos", Ffringe_bitmaps_at_pos, Sfringe_bitmaps_at_pos,
1362 0, 2, 0,
1363 doc: /* Return fringe bitmaps of row containing position POS in window WINDOW.
1364 If WINDOW is nil, use selected window. If POS is nil, use value of point
1365 in that window. Return value is a list (LEFT RIGHT OV), where LEFT
1366 is the symbol for the bitmap in the left fringe (or nil if no bitmap),
1367 RIGHT is similar for the right fringe, and OV is non-nil if there is an
1368 overlay arrow in the left fringe.
1369 Return nil if POS is not visible in WINDOW. */)
1370 (pos, window)
1371 Lisp_Object pos, window;
1373 struct window *w;
1374 struct glyph_row *row;
1375 int textpos;
1377 if (NILP (window))
1378 window = selected_window;
1379 CHECK_WINDOW (window);
1380 w = XWINDOW (window);
1382 if (!NILP (pos))
1384 CHECK_NUMBER_COERCE_MARKER (pos);
1385 textpos = XINT (pos);
1387 else if (w == XWINDOW (selected_window))
1388 textpos = PT;
1389 else
1390 textpos = XMARKER (w->pointm)->charpos;
1392 row = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
1393 row = row_containing_pos (w, textpos, row, NULL, 0);
1394 if (row)
1395 return list3 (get_fringe_bitmap_name (row->left_fringe_bitmap),
1396 get_fringe_bitmap_name (row->right_fringe_bitmap),
1397 (row->overlay_arrow_p ? Qt : Qnil));
1398 else
1399 return Qnil;
1403 /***********************************************************************
1404 Initialization
1405 ***********************************************************************/
1407 void
1408 syms_of_fringe ()
1410 defsubr (&Sdestroy_fringe_bitmap);
1411 defsubr (&Sdefine_fringe_bitmap);
1412 defsubr (&Sfringe_bitmaps_at_pos);
1413 defsubr (&Sset_fringe_bitmap_face);
1415 DEFVAR_LISP ("overflow-newline-into-fringe", &Voverflow_newline_into_fringe,
1416 doc: /* *Non-nil means that newline may flow into the right fringe.
1417 This means that display lines which are exactly as wide as the window
1418 (not counting the final newline) will only occupy one screen line, by
1419 showing (or hiding) the final newline in the right fringe; when point
1420 is at the final newline, the cursor is shown in the right fringe.
1421 If nil, also continue lines which are exactly as wide as the window. */);
1422 Voverflow_newline_into_fringe = Qt;
1424 DEFVAR_LISP ("fringe-bitmaps", &Vfringe_bitmaps,
1425 doc: /* List of fringe bitmap symbols.
1426 You must (require 'fringe) to use fringe bitmap symbols in your programs." */);
1427 Vfringe_bitmaps = Qnil;
1430 /* Initialize this module when Emacs starts. */
1432 void
1433 init_fringe_once ()
1435 enum fringe_bitmap_type bt;
1437 for (bt = NO_FRINGE_BITMAP + 1; bt < MAX_STANDARD_FRINGE_BITMAPS; bt++)
1438 init_fringe_bitmap(bt, &standard_bitmaps[bt], 1);
1441 void
1442 init_fringe ()
1444 int i;
1446 max_fringe_bitmaps = MAX_STANDARD_FRINGE_BITMAPS + 20;
1448 fringe_bitmaps
1449 = (struct fringe_bitmap **) xmalloc (max_fringe_bitmaps * sizeof (struct fringe_bitmap *));
1450 fringe_faces
1451 = (unsigned *) xmalloc (max_fringe_bitmaps * sizeof (unsigned));
1453 for (i = 0; i < max_fringe_bitmaps; i++)
1455 fringe_bitmaps[i] = NULL;
1456 fringe_faces[i] = FRINGE_FACE_ID;
1460 #ifdef HAVE_NTGUI
1462 void
1463 w32_init_fringe ()
1465 enum fringe_bitmap_type bt;
1467 if (!rif)
1468 return;
1470 for (bt = NO_FRINGE_BITMAP + 1; bt < MAX_STANDARD_FRINGE_BITMAPS; bt++)
1472 struct fringe_bitmap *fb = &standard_bitmaps[bt];
1473 rif->define_fringe_bitmap (bt, fb->bits, fb->height, fb->width);
1477 void
1478 w32_reset_fringes ()
1480 /* Destroy row bitmaps. */
1481 int bt;
1483 if (!rif)
1484 return;
1486 for (bt = NO_FRINGE_BITMAP + 1; bt < max_used_fringe_bitmap; bt++)
1487 rif->destroy_fringe_bitmap (bt);
1490 #endif /* HAVE_NTGUI */
1492 #endif /* HAVE_WINDOW_SYSTEM */
1494 /* arch-tag: 04596920-43eb-473d-b319-82712338162d
1495 (do not change this comment) */