Mercurial > emacs
comparison src/fringe.c @ 57246:36ab9b017a42
(update_window_fringes): Handle new formats of
indicate-buffer-boundaries (symbol or alist). No longer
allow a simple cons.
(Ffringe_bitmaps_at_pos): Use nil value for no bitmap.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Mon, 27 Sep 2004 13:28:23 +0000 |
parents | 256374267423 |
children | 36eef73e00fa |
comparison
equal
deleted
inserted
replaced
57245:8c66fdb3c3ba | 57246:36ab9b017a42 |
---|---|
30 #include "blockinput.h" | 30 #include "blockinput.h" |
31 | 31 |
32 #ifdef HAVE_WINDOW_SYSTEM | 32 #ifdef HAVE_WINDOW_SYSTEM |
33 | 33 |
34 extern Lisp_Object Qtop, Qbottom, Qcenter; | 34 extern Lisp_Object Qtop, Qbottom, Qcenter; |
35 extern Lisp_Object Qup, Qdown, Qleft, Qright; | |
35 | 36 |
36 /* Non-nil means that newline may flow into the right fringe. */ | 37 /* Non-nil means that newline may flow into the right fringe. */ |
37 | 38 |
38 Lisp_Object Voverflow_newline_into_fringe; | 39 Lisp_Object Voverflow_newline_into_fringe; |
39 | 40 |
704 struct glyph_row *row, *cur = 0; | 705 struct glyph_row *row, *cur = 0; |
705 int yb = window_text_bottom_y (w); | 706 int yb = window_text_bottom_y (w); |
706 int rn, nrows = w->current_matrix->nrows; | 707 int rn, nrows = w->current_matrix->nrows; |
707 int y; | 708 int y; |
708 int redraw_p = 0; | 709 int redraw_p = 0; |
709 Lisp_Object ind; | 710 Lisp_Object boundary_top = Qnil, boundary_bot = Qnil; |
710 int boundary_pos = 0, arrow_pos = 0; | 711 Lisp_Object arrow_top = Qnil, arrow_bot = Qnil; |
711 int empty_pos = 0; | 712 Lisp_Object empty_pos; |
713 Lisp_Object ind = Qnil; | |
712 | 714 |
713 if (w->pseudo_window_p) | 715 if (w->pseudo_window_p) |
714 return 0; | 716 return 0; |
715 | 717 |
716 if (!MINI_WINDOW_P (w) | 718 if (!MINI_WINDOW_P (w) |
717 && (ind = XBUFFER (w->buffer)->indicate_buffer_boundaries, !NILP (ind))) | 719 && (ind = XBUFFER (w->buffer)->indicate_buffer_boundaries, !NILP (ind))) |
718 { | 720 { |
721 if (EQ (ind, Qleft) || EQ (ind, Qright)) | |
722 boundary_top = boundary_bot = arrow_top = arrow_bot = ind; | |
723 else if (CONSP (ind) && CONSP (XCAR (ind))) | |
724 { | |
725 Lisp_Object pos; | |
726 if (pos = Fassq (Qt, ind), !NILP (pos)) | |
727 boundary_top = boundary_bot = arrow_top = arrow_bot = XCDR (pos); | |
728 if (pos = Fassq (Qtop, ind), !NILP (pos)) | |
729 boundary_top = XCDR (pos); | |
730 if (pos = Fassq (Qbottom, ind), !NILP (pos)) | |
731 boundary_bot = XCDR (pos); | |
732 if (pos = Fassq (Qup, ind), !NILP (pos)) | |
733 arrow_top = XCDR (pos); | |
734 if (pos = Fassq (Qdown, ind), !NILP (pos)) | |
735 arrow_bot = XCDR (pos); | |
736 } | |
737 else | |
738 ind = Qnil; | |
739 } | |
740 | |
741 if (!NILP (ind)) | |
742 { | |
719 int do_eob = 1, do_bob = 1; | 743 int do_eob = 1, do_bob = 1; |
720 Lisp_Object arrows; | |
721 | |
722 if (CONSP (ind)) | |
723 arrows = XCDR (ind), ind = XCAR (ind); | |
724 else | |
725 arrows = ind; | |
726 | |
727 if (EQ (ind, Qleft)) | |
728 boundary_pos = -1; | |
729 else if (EQ (ind, Qright)) | |
730 boundary_pos = 1; | |
731 | |
732 if (EQ (arrows, Qleft)) | |
733 arrow_pos = -1; | |
734 else if (EQ (arrows, Qright)) | |
735 arrow_pos = 1; | |
736 | 744 |
737 for (y = 0, rn = 0; | 745 for (y = 0, rn = 0; |
738 y < yb && rn < nrows; | 746 y < yb && rn < nrows; |
739 y += row->height, ++rn) | 747 y += row->height, ++rn) |
740 { | 748 { |
751 indicate_bottom_line_p = row->indicate_bottom_line_p; | 759 indicate_bottom_line_p = row->indicate_bottom_line_p; |
752 | 760 |
753 row->indicate_bob_p = row->indicate_top_line_p = 0; | 761 row->indicate_bob_p = row->indicate_top_line_p = 0; |
754 row->indicate_eob_p = row->indicate_bottom_line_p = 0; | 762 row->indicate_eob_p = row->indicate_bottom_line_p = 0; |
755 | 763 |
756 if (!NILP (ind) | 764 if (!NILP (boundary_top) |
757 && MATRIX_ROW_START_CHARPOS (row) <= BUF_BEGV (XBUFFER (w->buffer))) | 765 && MATRIX_ROW_START_CHARPOS (row) <= BUF_BEGV (XBUFFER (w->buffer))) |
758 row->indicate_bob_p = do_bob, do_bob = 0; | 766 row->indicate_bob_p = do_bob, do_bob = 0; |
759 else if (!NILP (arrows) | 767 else if (!NILP (arrow_top) |
760 && (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0) == rn) | 768 && (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0) == rn) |
761 row->indicate_top_line_p = 1; | 769 row->indicate_top_line_p = 1; |
762 | 770 |
763 if (!NILP (ind) | 771 if (!NILP (boundary_bot) |
764 && MATRIX_ROW_END_CHARPOS (row) >= BUF_ZV (XBUFFER (w->buffer))) | 772 && MATRIX_ROW_END_CHARPOS (row) >= BUF_ZV (XBUFFER (w->buffer))) |
765 row->indicate_eob_p = do_eob, do_eob = 0; | 773 row->indicate_eob_p = do_eob, do_eob = 0; |
766 else if (!NILP (arrows) | 774 else if (!NILP (arrow_bot) |
767 && y + row->height >= yb) | 775 && y + row->height >= yb) |
768 row->indicate_bottom_line_p = 1; | 776 row->indicate_bottom_line_p = 1; |
769 | 777 |
770 if (indicate_bob_p != row->indicate_bob_p | 778 if (indicate_bob_p != row->indicate_bob_p |
771 || indicate_top_line_p != row->indicate_top_line_p | 779 || indicate_top_line_p != row->indicate_top_line_p |
773 || indicate_bottom_line_p != row->indicate_bottom_line_p) | 781 || indicate_bottom_line_p != row->indicate_bottom_line_p) |
774 row->redraw_fringe_bitmaps_p = 1; | 782 row->redraw_fringe_bitmaps_p = 1; |
775 } | 783 } |
776 } | 784 } |
777 | 785 |
778 if (EQ (XBUFFER (w->buffer)->indicate_empty_lines, Qright)) | 786 empty_pos = XBUFFER (w->buffer)->indicate_empty_lines; |
779 empty_pos = 1; | 787 if (!NILP (empty_pos) && !EQ (empty_pos, Qright)) |
780 else if (EQ (XBUFFER (w->buffer)->indicate_empty_lines, Qleft)) | 788 empty_pos = WINDOW_LEFT_FRINGE_WIDTH (w) == 0 ? Qright : Qleft; |
781 empty_pos = -1; | |
782 | 789 |
783 for (y = 0, rn = 0; | 790 for (y = 0, rn = 0; |
784 y < yb && rn < nrows; | 791 y < yb && rn < nrows; |
785 y += row->height, rn++) | 792 y += row->height, rn++) |
786 { | 793 { |
800 else if (row->left_user_fringe_bitmap != NO_FRINGE_BITMAP) | 807 else if (row->left_user_fringe_bitmap != NO_FRINGE_BITMAP) |
801 { | 808 { |
802 left = row->left_user_fringe_bitmap; | 809 left = row->left_user_fringe_bitmap; |
803 left_face_id = row->left_user_fringe_face_id; | 810 left_face_id = row->left_user_fringe_face_id; |
804 } | 811 } |
805 else if (row->indicate_bob_p && boundary_pos <= 0) | 812 else if (row->indicate_bob_p && EQ (boundary_top, Qleft)) |
806 left = ((row->indicate_eob_p && boundary_pos < 0) | 813 left = ((row->indicate_eob_p && EQ (boundary_bot, Qleft)) |
807 ? LEFT_BRACKET_BITMAP : TOP_LEFT_ANGLE_BITMAP); | 814 ? LEFT_BRACKET_BITMAP : TOP_LEFT_ANGLE_BITMAP); |
808 else if (row->indicate_eob_p && boundary_pos < 0) | 815 else if (row->indicate_eob_p && EQ (boundary_bot, Qleft)) |
809 left = BOTTOM_LEFT_ANGLE_BITMAP; | 816 left = BOTTOM_LEFT_ANGLE_BITMAP; |
810 else if (row->truncated_on_left_p) | 817 else if (row->truncated_on_left_p) |
811 left = LEFT_TRUNCATION_BITMAP; | 818 left = LEFT_TRUNCATION_BITMAP; |
812 else if (MATRIX_ROW_CONTINUATION_LINE_P (row)) | 819 else if (MATRIX_ROW_CONTINUATION_LINE_P (row)) |
813 left = CONTINUATION_LINE_BITMAP; | 820 left = CONTINUATION_LINE_BITMAP; |
814 else if (row->indicate_empty_line_p && empty_pos <= 0) | 821 else if (row->indicate_empty_line_p && EQ (empty_pos, Qleft)) |
815 left = ZV_LINE_BITMAP; | 822 left = ZV_LINE_BITMAP; |
816 else if (row->indicate_top_line_p && arrow_pos <= 0) | 823 else if (row->indicate_top_line_p && EQ (arrow_top, Qleft)) |
817 left = UP_ARROW_BITMAP; | 824 left = UP_ARROW_BITMAP; |
818 else if (row->indicate_bottom_line_p && arrow_pos < 0) | 825 else if (row->indicate_bottom_line_p && EQ (arrow_bot, Qleft)) |
819 left = DOWN_ARROW_BITMAP; | 826 left = DOWN_ARROW_BITMAP; |
820 else | 827 else |
821 left = NO_FRINGE_BITMAP; | 828 left = NO_FRINGE_BITMAP; |
822 | 829 |
823 /* Decide which bitmap to draw in the right fringe. */ | 830 /* Decide which bitmap to draw in the right fringe. */ |
826 else if (row->right_user_fringe_bitmap != NO_FRINGE_BITMAP) | 833 else if (row->right_user_fringe_bitmap != NO_FRINGE_BITMAP) |
827 { | 834 { |
828 right = row->right_user_fringe_bitmap; | 835 right = row->right_user_fringe_bitmap; |
829 right_face_id = row->right_user_fringe_face_id; | 836 right_face_id = row->right_user_fringe_face_id; |
830 } | 837 } |
831 else if (row->indicate_bob_p && boundary_pos > 0) | 838 else if (row->indicate_bob_p && EQ (boundary_top, Qright)) |
832 right = ((row->indicate_eob_p && boundary_pos >= 0) | 839 right = ((row->indicate_eob_p && EQ (boundary_bot, Qright)) |
833 ? RIGHT_BRACKET_BITMAP : TOP_RIGHT_ANGLE_BITMAP); | 840 ? RIGHT_BRACKET_BITMAP : TOP_RIGHT_ANGLE_BITMAP); |
834 else if (row->indicate_eob_p && boundary_pos >= 0) | 841 else if (row->indicate_eob_p && EQ (boundary_bot, Qright)) |
835 right = BOTTOM_RIGHT_ANGLE_BITMAP; | 842 right = BOTTOM_RIGHT_ANGLE_BITMAP; |
836 else if (row->truncated_on_right_p) | 843 else if (row->truncated_on_right_p) |
837 right = RIGHT_TRUNCATION_BITMAP; | 844 right = RIGHT_TRUNCATION_BITMAP; |
838 else if (row->continued_p) | 845 else if (row->continued_p) |
839 right = CONTINUED_LINE_BITMAP; | 846 right = CONTINUED_LINE_BITMAP; |
840 else if (row->indicate_top_line_p && arrow_pos > 0) | 847 else if (row->indicate_top_line_p && EQ (arrow_top, Qright)) |
841 right = UP_ARROW_BITMAP; | 848 right = UP_ARROW_BITMAP; |
842 else if (row->indicate_bottom_line_p && arrow_pos >= 0) | 849 else if (row->indicate_bottom_line_p && EQ (arrow_bot, Qright)) |
843 right = DOWN_ARROW_BITMAP; | 850 right = DOWN_ARROW_BITMAP; |
844 else if (row->indicate_empty_line_p | 851 else if (row->indicate_empty_line_p && EQ (empty_pos, Qright)) |
845 && (empty_pos > 0 | |
846 || (WINDOW_LEFT_FRINGE_WIDTH (w) == 0 && empty_pos == 0))) | |
847 right = ZV_LINE_BITMAP; | 852 right = ZV_LINE_BITMAP; |
848 else | 853 else |
849 right = NO_FRINGE_BITMAP; | 854 right = NO_FRINGE_BITMAP; |
850 | 855 |
851 if (force_p | 856 if (force_p |
1245 0, 2, 0, | 1250 0, 2, 0, |
1246 doc: /* Return fringe bitmaps of row containing position POS in window WINDOW. | 1251 doc: /* Return fringe bitmaps of row containing position POS in window WINDOW. |
1247 If WINDOW is nil, use selected window. If POS is nil, use value of point | 1252 If WINDOW is nil, use selected window. If POS is nil, use value of point |
1248 in that window. Return value is a cons (LEFT . RIGHT) where LEFT and RIGHT | 1253 in that window. Return value is a cons (LEFT . RIGHT) where LEFT and RIGHT |
1249 are the fringe bitmap numbers for the bitmaps in the left and right fringe, | 1254 are the fringe bitmap numbers for the bitmaps in the left and right fringe, |
1250 resp. Return nil if POS is not visible in WINDOW. */) | 1255 resp. If left or right fringe is empty, the corresponding element is nil. |
1256 Return nil if POS is not visible in WINDOW. */) | |
1251 (pos, window) | 1257 (pos, window) |
1252 Lisp_Object pos, window; | 1258 Lisp_Object pos, window; |
1253 { | 1259 { |
1254 struct window *w; | 1260 struct window *w; |
1255 struct buffer *old_buffer = NULL; | 1261 struct buffer *old_buffer = NULL; |
1272 textpos = XMARKER (w->pointm)->charpos; | 1278 textpos = XMARKER (w->pointm)->charpos; |
1273 | 1279 |
1274 row = MATRIX_FIRST_TEXT_ROW (w->current_matrix); | 1280 row = MATRIX_FIRST_TEXT_ROW (w->current_matrix); |
1275 row = row_containing_pos (w, textpos, row, NULL, 0); | 1281 row = row_containing_pos (w, textpos, row, NULL, 0); |
1276 if (row) | 1282 if (row) |
1277 return Fcons (make_number (row->left_fringe_bitmap), | 1283 return Fcons ((row->left_fringe_bitmap == NO_FRINGE_BITMAP |
1278 make_number (row->right_fringe_bitmap)); | 1284 ? Qnil : make_number (row->left_fringe_bitmap)), |
1285 (row->right_fringe_bitmap == NO_FRINGE_BITMAP | |
1286 ? Qnil : make_number (row->right_fringe_bitmap))); | |
1279 else | 1287 else |
1280 return Qnil; | 1288 return Qnil; |
1281 } | 1289 } |
1282 | 1290 |
1283 | 1291 |