aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim F. Storm2001-12-01 01:34:24 +0000
committerKim F. Storm2001-12-01 01:34:24 +0000
commitd33c49e8795f8094ec2587e57203b1245af0d6ca (patch)
treefc8ffadc4438c8069cda1469aa9927ea2a2c6d00 /src
parent41c1bdd9bb12005260deaafb2c0f18a8e342fd4a (diff)
downloademacs-d33c49e8795f8094ec2587e57203b1245af0d6ca.tar.gz
emacs-d33c49e8795f8094ec2587e57203b1245af0d6ca.zip
Merged fringe width related changes from xterm.c.
Diffstat (limited to 'src')
-rw-r--r--src/w32term.c296
1 files changed, 198 insertions, 98 deletions
diff --git a/src/w32term.c b/src/w32term.c
index 9c0b0392424..af09b7b8554 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -84,9 +84,17 @@ enum fringe_bitmap_type
84 `indicate-empty-lines' is non-nil. */ 84 `indicate-empty-lines' is non-nil. */
85 85
86#define zv_width 8 86#define zv_width 8
87#define zv_height 8 87#define zv_height 72
88static unsigned short zv_bits[] = { 88#define zv_period 3
89 0x00, 0x00, 0x78, 0x78, 0x78, 0x78, 0x00, 0x00}; 89static unsigned char zv_bits[] = {
90 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
91 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
92 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
93 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
94 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
95 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
96 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
97 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00};
90static HBITMAP zv_bmp; 98static HBITMAP zv_bmp;
91 99
92/* An arrow like this: `<-'. */ 100/* An arrow like this: `<-'. */
@@ -400,7 +408,7 @@ static void x_erase_phys_cursor P_ ((struct window *));
400void x_display_cursor P_ ((struct window *w, int, int, int, int, int)); 408void x_display_cursor P_ ((struct window *w, int, int, int, int, int));
401void x_display_and_set_cursor P_ ((struct window *, int, int, int, int, int)); 409void x_display_and_set_cursor P_ ((struct window *, int, int, int, int, int));
402static void w32_draw_fringe_bitmap P_ ((struct window *, HDC hdc, struct glyph_row *, 410static void w32_draw_fringe_bitmap P_ ((struct window *, HDC hdc, struct glyph_row *,
403 enum fringe_bitmap_type)); 411 enum fringe_bitmap_type, int left_p));
404static void w32_clip_to_row P_ ((struct window *, struct glyph_row *, 412static void w32_clip_to_row P_ ((struct window *, struct glyph_row *,
405 HDC, int)); 413 HDC, int));
406static int x_phys_cursor_in_rect_p P_ ((struct window *, RECT *)); 414static int x_phys_cursor_in_rect_p P_ ((struct window *, RECT *));
@@ -810,16 +818,18 @@ x_after_update_window_line (desired_row)
810 drawn. */ 818 drawn. */
811 819
812static void 820static void
813w32_draw_fringe_bitmap (w, hdc, row, which) 821w32_draw_fringe_bitmap (w, hdc, row, which, left_p)
814 struct window *w; 822 struct window *w;
815 HDC hdc; 823 HDC hdc;
816 struct glyph_row *row; 824 struct glyph_row *row;
817 enum fringe_bitmap_type which; 825 enum fringe_bitmap_type which;
826 int left_p;
818{ 827{
819 struct frame *f = XFRAME (WINDOW_FRAME (w)); 828 struct frame *f = XFRAME (WINDOW_FRAME (w));
820 Window window = FRAME_W32_WINDOW (f); 829 Window window = FRAME_W32_WINDOW (f);
821 HDC compat_hdc; 830 HDC compat_hdc;
822 int x, y, wd, h, dy; 831 int x, y, wd, h, dy;
832 int b1, b2;
823 HBITMAP pixmap; 833 HBITMAP pixmap;
824 HANDLE horig_obj; 834 HANDLE horig_obj;
825 struct face *face; 835 struct face *face;
@@ -827,71 +837,118 @@ w32_draw_fringe_bitmap (w, hdc, row, which)
827 /* Must clip because of partially visible lines. */ 837 /* Must clip because of partially visible lines. */
828 w32_clip_to_row (w, row, hdc, 1); 838 w32_clip_to_row (w, row, hdc, 1);
829 839
840 /* Convert row to frame coordinates. */
841 y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
842
830 switch (which) 843 switch (which)
831 { 844 {
845 case NO_FRINGE_BITMAP:
846 wd = 0;
847 h = 0;
848 break;
849
832 case LEFT_TRUNCATION_BITMAP: 850 case LEFT_TRUNCATION_BITMAP:
833 wd = left_width; 851 wd = left_width;
834 h = left_height; 852 h = left_height;
835 pixmap = left_bmp; 853 pixmap = left_bmp;
836 x = (WINDOW_TO_FRAME_PIXEL_X (w, 0)
837 - wd
838 - (FRAME_X_LEFT_FRINGE_WIDTH (f) - wd) / 2);
839 break; 854 break;
840 855
841 case OVERLAY_ARROW_BITMAP: 856 case OVERLAY_ARROW_BITMAP:
842 wd = ov_width; 857 wd = ov_width;
843 h = ov_height; 858 h = ov_height;
844 pixmap = ov_bmp; 859 pixmap = ov_bmp;
845 x = (WINDOW_TO_FRAME_PIXEL_X (w, 0)
846 - wd
847 - (FRAME_X_LEFT_FRINGE_WIDTH (f) - wd) / 2);
848 break; 860 break;
849 861
850 case RIGHT_TRUNCATION_BITMAP: 862 case RIGHT_TRUNCATION_BITMAP:
851 wd = right_width; 863 wd = right_width;
852 h = right_height; 864 h = right_height;
853 pixmap = right_bmp; 865 pixmap = right_bmp;
854 x = window_box_right (w, -1);
855 x += (FRAME_X_RIGHT_FRINGE_WIDTH (f) - wd) / 2;
856 break; 866 break;
857 867
858 case CONTINUED_LINE_BITMAP: 868 case CONTINUED_LINE_BITMAP:
859 wd = continued_width; 869 wd = continued_width;
860 h = continued_height; 870 h = continued_height;
861 pixmap = continued_bmp; 871 pixmap = continued_bmp;
862 x = window_box_right (w, -1);
863 x += (FRAME_X_RIGHT_FRINGE_WIDTH (f) - wd) / 2;
864 break; 872 break;
865 873
866 case CONTINUATION_LINE_BITMAP: 874 case CONTINUATION_LINE_BITMAP:
867 wd = continuation_width; 875 wd = continuation_width;
868 h = continuation_height; 876 h = continuation_height;
869 pixmap = continuation_bmp; 877 pixmap = continuation_bmp;
870 x = (WINDOW_TO_FRAME_PIXEL_X (w, 0)
871 - wd
872 - (FRAME_X_LEFT_FRINGE_WIDTH (f) - wd) / 2);
873 break; 878 break;
874 879
875 case ZV_LINE_BITMAP: 880 case ZV_LINE_BITMAP:
876 wd = zv_width; 881 wd = zv_width;
877 h = zv_height; 882 h = zv_height - (y % zv_period);
878 pixmap = zv_bmp; 883 pixmap = zv_bmp;
879 x = (WINDOW_TO_FRAME_PIXEL_X (w, 0)
880 - wd
881 - (FRAME_X_LEFT_FRINGE_WIDTH (f) - wd) / 2);
882 break; 884 break;
883 885
884 default: 886 default:
885 abort (); 887 abort ();
886 } 888 }
887 889
888 /* Convert to frame coordinates. Set dy to the offset in the row to 890 /* Clip bitmap if too high. */
889 start drawing the bitmap. */ 891 if (h > row->height)
890 y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y); 892 h = row->height;
893
894 /* Set dy to the offset in the row to start drawing the bitmap. */
891 dy = (row->height - h) / 2; 895 dy = (row->height - h) / 2;
892 896
893 /* Draw the bitmap. */ 897 /* Draw the bitmap. */
894 face = FACE_FROM_ID (f, FRINGE_FACE_ID); 898 face = FACE_FROM_ID (f, FRINGE_FACE_ID);
899 PREPARE_FACE_FOR_DISPLAY (f, face);
900
901 /* Clear left fringe if no bitmap to draw or if bitmap doesn't fill
902 the fringe. */
903 b1 = -1;
904 if (left_p)
905 {
906 if (wd > FRAME_X_LEFT_FRINGE_WIDTH (f))
907 wd = FRAME_X_LEFT_FRINGE_WIDTH (f);
908 x = (WINDOW_TO_FRAME_PIXEL_X (w, 0)
909 - wd
910 - (FRAME_X_LEFT_FRINGE_WIDTH (f) - wd) / 2);
911 if (wd < FRAME_X_LEFT_FRINGE_WIDTH (f) || row->height > h)
912 {
913 /* If W has a vertical border to its left, don't draw over it. */
914 int border = ((XFASTINT (w->left) > 0
915 && !FRAME_HAS_VERTICAL_SCROLL_BARS (f))
916 ? 1 : 0);
917 b1 = (window_box_left (w, -1)
918 - FRAME_X_LEFT_FRINGE_WIDTH (f)
919 + border);
920 b2 = (FRAME_X_LEFT_FRINGE_WIDTH (f) - border);
921 }
922 }
923 else
924 {
925 if (wd > FRAME_X_RIGHT_FRINGE_WIDTH (f))
926 wd = FRAME_X_RIGHT_FRINGE_WIDTH (f);
927 x = (window_box_right (w, -1)
928 + (FRAME_X_RIGHT_FRINGE_WIDTH (f) - wd) / 2);
929 /* Clear right fringe if no bitmap to draw of if bitmap doesn't fill
930 the fringe. */
931 if (wd < FRAME_X_RIGHT_FRINGE_WIDTH (f) || row->height > h)
932 {
933 b1 = window_box_right (w, -1);
934 b2 = FRAME_X_RIGHT_FRINGE_WIDTH (f);
935 }
936 }
937
938 if (b1 >= 0)
939 {
940 int header_line_height = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
941
942 w32_fill_area (f, hdc, face->background,
943 b1,
944 WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height,
945 row->y)),
946 b2,
947 row->visible_height);
948 }
949
950 if (which == NO_FRINGE_BITMAP)
951 return;
895 952
896 compat_hdc = CreateCompatibleDC (hdc); 953 compat_hdc = CreateCompatibleDC (hdc);
897 SaveDC (hdc); 954 SaveDC (hdc);
@@ -900,7 +957,9 @@ w32_draw_fringe_bitmap (w, hdc, row, which)
900 SetTextColor (hdc, face->background); 957 SetTextColor (hdc, face->background);
901 SetBkColor (hdc, face->foreground); 958 SetBkColor (hdc, face->foreground);
902 959
903 BitBlt (hdc, x, y + dy, wd, h, compat_hdc, 0, 0, SRCCOPY); 960 BitBlt (hdc, x, y + dy, wd, h, compat_hdc, 0,
961 (which == ZV_LINE_BITMAP ? (row->y % zv_period) : 0),
962 SRCCOPY);
904 963
905 SelectObject (compat_hdc, horig_obj); 964 SelectObject (compat_hdc, horig_obj);
906 DeleteDC (compat_hdc); 965 DeleteDC (compat_hdc);
@@ -918,8 +977,6 @@ x_draw_row_fringe_bitmaps (w, row)
918{ 977{
919 struct frame *f = XFRAME (w->frame); 978 struct frame *f = XFRAME (w->frame);
920 enum fringe_bitmap_type bitmap; 979 enum fringe_bitmap_type bitmap;
921 struct face *face;
922 int header_line_height = -1;
923 HDC hdc; 980 HDC hdc;
924 981
925 xassert (interrupt_input_blocked); 982 xassert (interrupt_input_blocked);
@@ -929,81 +986,40 @@ x_draw_row_fringe_bitmaps (w, row)
929 if (row->visible_height <= 0) 986 if (row->visible_height <= 0)
930 return; 987 return;
931 988
932 face = FACE_FROM_ID (f, FRINGE_FACE_ID);
933 PREPARE_FACE_FOR_DISPLAY (f, face);
934
935 /* Decide which bitmap to draw in the left fringe. */
936 if (row->overlay_arrow_p)
937 bitmap = OVERLAY_ARROW_BITMAP;
938 else if (row->truncated_on_left_p)
939 bitmap = LEFT_TRUNCATION_BITMAP;
940 else if (MATRIX_ROW_CONTINUATION_LINE_P (row))
941 bitmap = CONTINUATION_LINE_BITMAP;
942 else if (row->indicate_empty_line_p)
943 bitmap = ZV_LINE_BITMAP;
944 else
945 bitmap = NO_FRINGE_BITMAP;
946
947 hdc = get_frame_dc (f); 989 hdc = get_frame_dc (f);
948 990
949 /* Clear left fringe if no bitmap to draw or if bitmap doesn't fill 991 if (FRAME_X_LEFT_FRINGE_WIDTH (f) != 0)
950 the fringe. */ 992 {
951 if (bitmap == NO_FRINGE_BITMAP 993 /* Decide which bitmap to draw in the left fringe. */
952 || FRAME_FRINGE_BITMAP_WIDTH (f) < FRAME_X_LEFT_FRINGE_WIDTH (f) 994 if (row->overlay_arrow_p)
953 || row->height > FRAME_FRINGE_BITMAP_HEIGHT (f)) 995 bitmap = OVERLAY_ARROW_BITMAP;
954 { 996 else if (row->truncated_on_left_p)
955 /* If W has a vertical border to its left, don't draw over it. */ 997 bitmap = LEFT_TRUNCATION_BITMAP;
956 int border = ((XFASTINT (w->left) > 0 998 else if (MATRIX_ROW_CONTINUATION_LINE_P (row))
957 && !FRAME_HAS_VERTICAL_SCROLL_BARS (f)) 999 bitmap = CONTINUATION_LINE_BITMAP;
958 ? 1 : 0); 1000 else if (row->indicate_empty_line_p)
959 int left = window_box_left (w, -1); 1001 bitmap = ZV_LINE_BITMAP;
960 1002 else
961 if (header_line_height < 0) 1003 bitmap = NO_FRINGE_BITMAP;
962 header_line_height = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
963
964 w32_fill_area (f, hdc, face->background,
965 left - FRAME_X_LEFT_FRINGE_WIDTH (f) + border,
966 WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height,
967 row->y)),
968 FRAME_X_LEFT_FRINGE_WIDTH (f) - border,
969 row->visible_height);
970 }
971
972 /* Draw the left bitmap. */
973 if (bitmap != NO_FRINGE_BITMAP)
974 w32_draw_fringe_bitmap (w, hdc, row, bitmap);
975 1004
976 /* Decide which bitmap to draw in the right fringe. */ 1005 w32_draw_fringe_bitmap (w, hdc, row, bitmap, 1);
977 if (row->truncated_on_right_p) 1006 }
978 bitmap = RIGHT_TRUNCATION_BITMAP;
979 else if (row->continued_p)
980 bitmap = CONTINUED_LINE_BITMAP;
981 else
982 bitmap = NO_FRINGE_BITMAP;
983 1007
984 /* Clear right fringe if no bitmap to draw of if bitmap doesn't fill 1008 if (FRAME_X_RIGHT_FRINGE_WIDTH (f) != 0)
985 the fringe. */
986 if (bitmap == NO_FRINGE_BITMAP
987 || FRAME_FRINGE_BITMAP_WIDTH (f) < FRAME_X_RIGHT_FRINGE_WIDTH (f)
988 || row->height > FRAME_FRINGE_BITMAP_HEIGHT (f))
989 { 1009 {
990 int right = window_box_right (w, -1); 1010 /* Decide which bitmap to draw in the right fringe. */
991 1011 if (row->truncated_on_right_p)
992 if (header_line_height < 0) 1012 bitmap = RIGHT_TRUNCATION_BITMAP;
993 header_line_height = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w); 1013 else if (row->continued_p)
1014 bitmap = CONTINUED_LINE_BITMAP;
1015 else if (row->indicate_empty_line_p && FRAME_X_LEFT_FRINGE_WIDTH (f) == 0)
1016 bitmap = ZV_LINE_BITMAP;
1017 else
1018 bitmap = NO_FRINGE_BITMAP;
994 1019
995 w32_fill_area (f, hdc, face->background, 1020 w32_draw_fringe_bitmap (w, hdc, row, bitmap, 0);
996 right,
997 WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height,
998 row->y)),
999 FRAME_X_RIGHT_FRINGE_WIDTH (f),
1000 row->visible_height);
1001 } 1021 }
1002 1022
1003 /* Draw the right bitmap. */
1004 if (bitmap != NO_FRINGE_BITMAP)
1005 w32_draw_fringe_bitmap (w, hdc, row, bitmap);
1006
1007 release_frame_dc (f, hdc); 1023 release_frame_dc (f, hdc);
1008} 1024}
1009 1025
@@ -4898,7 +4914,6 @@ x_draw_glyphs (w, x, row, area, start, end, hl, overlaps_p)
4898 /* X is relative to the left edge of W, without scroll bars 4914 /* X is relative to the left edge of W, without scroll bars
4899 or fringes. */ 4915 or fringes. */
4900 struct frame *f = XFRAME (WINDOW_FRAME (w)); 4916 struct frame *f = XFRAME (WINDOW_FRAME (w));
4901 /* int width = FRAME_FRINGE_WIDTH (f); */
4902 int window_left_x = WINDOW_LEFT_MARGIN (w) * CANON_X_UNIT (f); 4917 int window_left_x = WINDOW_LEFT_MARGIN (w) * CANON_X_UNIT (f);
4903 4918
4904 x += window_left_x; 4919 x += window_left_x;
@@ -9887,6 +9902,90 @@ x_new_fontset (f, fontsetname)
9887 return build_string (fontsetname); 9902 return build_string (fontsetname);
9888} 9903}
9889 9904
9905/* Compute actual fringe widths */
9906
9907void
9908x_compute_fringe_widths (f, redraw)
9909 struct frame *f;
9910 int redraw;
9911{
9912 int o_left = f->output_data.w32->left_fringe_width;
9913 int o_right = f->output_data.w32->right_fringe_width;
9914 int o_cols = f->output_data.w32->fringe_cols;
9915
9916 Lisp_Object left_fringe = Fassq (Qleft_fringe, f->param_alist);
9917 Lisp_Object right_fringe = Fassq (Qright_fringe, f->param_alist);
9918 int left_fringe_width, right_fringe_width;
9919
9920 if (!NILP (left_fringe))
9921 left_fringe = Fcdr (left_fringe);
9922 if (!NILP (right_fringe))
9923 right_fringe = Fcdr (right_fringe);
9924
9925 left_fringe_width = ((NILP (left_fringe) || !INTEGERP (left_fringe)) ? 8 :
9926 XINT (left_fringe));
9927 right_fringe_width = ((NILP (right_fringe) || !INTEGERP (right_fringe)) ? 8 :
9928 XINT (right_fringe));
9929
9930 if (left_fringe_width || right_fringe_width)
9931 {
9932 int left_wid = left_fringe_width >= 0 ? left_fringe_width : -left_fringe_width;
9933 int right_wid = right_fringe_width >= 0 ? right_fringe_width : -right_fringe_width;
9934 int conf_wid = left_wid + right_wid;
9935 int font_wid = FONT_WIDTH (f->output_data.w32->font);
9936 int cols = (left_wid + right_wid + font_wid-1) / font_wid;
9937 int real_wid = cols * font_wid;
9938 if (left_wid && right_wid)
9939 {
9940 if (left_fringe_width < 0)
9941 {
9942 /* Left fringe width is fixed, adjust right fringe if necessary */
9943 f->output_data.w32->left_fringe_width = left_wid;
9944 f->output_data.w32->right_fringe_width = real_wid - left_wid;
9945 }
9946 else if (right_fringe_width < 0)
9947 {
9948 /* Right fringe width is fixed, adjust left fringe if necessary */
9949 f->output_data.w32->left_fringe_width = real_wid - right_wid;
9950 f->output_data.w32->right_fringe_width = right_wid;
9951 }
9952 else
9953 {
9954 /* Adjust both fringes with an equal amount.
9955 Note that we are doing integer arithmetic here, so don't
9956 lose a pixel if the total width is an odd number. */
9957 int fill = real_wid - conf_wid;
9958 f->output_data.w32->left_fringe_width = left_wid + fill/2;
9959 f->output_data.w32->right_fringe_width = right_wid + fill - fill/2;
9960 }
9961 }
9962 else if (left_fringe_width)
9963 {
9964 f->output_data.w32->left_fringe_width = real_wid;
9965 f->output_data.w32->right_fringe_width = 0;
9966 }
9967 else
9968 {
9969 f->output_data.w32->left_fringe_width = 0;
9970 f->output_data.w32->right_fringe_width = real_wid;
9971 }
9972 f->output_data.w32->fringe_cols = cols;
9973 f->output_data.w32->fringes_extra = real_wid;
9974 }
9975 else
9976 {
9977 f->output_data.w32->left_fringe_width = 0;
9978 f->output_data.w32->right_fringe_width = 0;
9979 f->output_data.w32->fringe_cols = 0;
9980 f->output_data.w32->fringes_extra = 0;
9981 }
9982
9983 if (redraw && FRAME_VISIBLE_P (f))
9984 if (o_left != f->output_data.w32->left_fringe_width ||
9985 o_right != f->output_data.w32->right_fringe_width ||
9986 o_cols != f->output_data.w32->fringe_cols)
9987 redraw_frame (f);
9988}
9890 9989
9891/*********************************************************************** 9990/***********************************************************************
9892 TODO: W32 Input Methods 9991 TODO: W32 Input Methods
@@ -10020,8 +10119,9 @@ x_set_window_size (f, change_gravity, cols, rows)
10020 = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f) 10119 = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
10021 ? 0 10120 ? 0
10022 : (FRAME_SCROLL_BAR_COLS (f) * FONT_WIDTH (f->output_data.w32->font))); 10121 : (FRAME_SCROLL_BAR_COLS (f) * FONT_WIDTH (f->output_data.w32->font)));
10023 f->output_data.w32->fringes_extra 10122
10024 = FRAME_FRINGE_WIDTH (f); 10123 x_compute_fringe_widths (f, 0);
10124
10025 pixelwidth = CHAR_TO_PIXEL_WIDTH (f, cols); 10125 pixelwidth = CHAR_TO_PIXEL_WIDTH (f, cols);
10026 pixelheight = CHAR_TO_PIXEL_HEIGHT (f, rows); 10126 pixelheight = CHAR_TO_PIXEL_HEIGHT (f, rows);
10027 10127