/[emacs]/emacs/src/xterm.c
ViewVC logotype

Diff of /emacs/src/xterm.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.689 by gerd, Wed Nov 28 17:07:59 2001 UTC revision 1.690 by kfstorm, Sat Dec 1 01:22:27 2001 UTC
# Line 172  enum fringe_bitmap_type Line 172  enum fringe_bitmap_type
172     `indicate-empty-lines' is non-nil.  */     `indicate-empty-lines' is non-nil.  */
173    
174  #define zv_width 8  #define zv_width 8
175  #define zv_height 8  #define zv_height 72
176    #define zv_period 3
177  static unsigned char zv_bits[] = {  static unsigned char zv_bits[] = {
178     0x00, 0x00, 0x1e, 0x1e, 0x1e, 0x1e, 0x00, 0x00};    0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
179      0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
180      0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
181      0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
182      0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
183      0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
184      0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
185      0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00};
186    
187  /* An arrow like this: `<-'.  */  /* An arrow like this: `<-'.  */
188    
# Line 462  static void x_update_window_cursor P_ (( Line 470  static void x_update_window_cursor P_ ((
470  static void x_erase_phys_cursor P_ ((struct window *));  static void x_erase_phys_cursor P_ ((struct window *));
471  void x_display_and_set_cursor P_ ((struct window *, int, int, int, int, int));  void x_display_and_set_cursor P_ ((struct window *, int, int, int, int, int));
472  static void x_draw_fringe_bitmap P_ ((struct window *, struct glyph_row *,  static void x_draw_fringe_bitmap P_ ((struct window *, struct glyph_row *,
473                                        enum fringe_bitmap_type));                                        enum fringe_bitmap_type, int left_p));
474    
475  static void x_clip_to_row P_ ((struct window *, struct glyph_row *,  static void x_clip_to_row P_ ((struct window *, struct glyph_row *,
476                                 GC, int));                                 GC, int));
# Line 817  x_after_update_window_line (desired_row) Line 825  x_after_update_window_line (desired_row)
825     drawn.  */     drawn.  */
826    
827  static void  static void
828  x_draw_fringe_bitmap (w, row, which)  x_draw_fringe_bitmap (w, row, which, left_p)
829       struct window *w;       struct window *w;
830       struct glyph_row *row;       struct glyph_row *row;
831       enum fringe_bitmap_type which;       enum fringe_bitmap_type which;
832         int left_p;
833  {  {
834    struct frame *f = XFRAME (WINDOW_FRAME (w));    struct frame *f = XFRAME (WINDOW_FRAME (w));
835    Display *display = FRAME_X_DISPLAY (f);    Display *display = FRAME_X_DISPLAY (f);
836    Window window = FRAME_X_WINDOW (f);    Window window = FRAME_X_WINDOW (f);
837    int x, y, wd, h, dy;    int x, y, wd, h, dy;
838      int b1, b2;
839    unsigned char *bits;    unsigned char *bits;
840    Pixmap pixmap;    Pixmap pixmap;
841    GC gc = f->output_data.x->normal_gc;    GC gc = f->output_data.x->normal_gc;
# Line 835  x_draw_fringe_bitmap (w, row, which) Line 845  x_draw_fringe_bitmap (w, row, which)
845    /* Must clip because of partially visible lines.  */    /* Must clip because of partially visible lines.  */
846    x_clip_to_row (w, row, gc, 1);    x_clip_to_row (w, row, gc, 1);
847    
848      /* Convert row to frame coordinates.  */
849      y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
850    
851    switch (which)    switch (which)
852      {      {
853        case NO_FRINGE_BITMAP:
854          wd = 0;
855          h = 0;
856          break;
857    
858      case LEFT_TRUNCATION_BITMAP:      case LEFT_TRUNCATION_BITMAP:
859        wd = left_width;        wd = left_width;
860        h = left_height;        h = left_height;
861        bits = left_bits;        bits = left_bits;
       x = (WINDOW_TO_FRAME_PIXEL_X (w, 0)  
            - wd  
            - (FRAME_X_LEFT_FRINGE_WIDTH (f) - wd) / 2);  
862        break;        break;
863                
864      case OVERLAY_ARROW_BITMAP:      case OVERLAY_ARROW_BITMAP:
865        wd = left_width;        wd = ov_width;
866        h = left_height;        h = ov_height;
867        bits = ov_bits;        bits = ov_bits;
       x = (WINDOW_TO_FRAME_PIXEL_X (w, 0)  
            - wd  
            - (FRAME_X_LEFT_FRINGE_WIDTH (f) - wd) / 2);  
868        break;        break;
869                
870      case RIGHT_TRUNCATION_BITMAP:      case RIGHT_TRUNCATION_BITMAP:
871        wd = right_width;        wd = right_width;
872        h = right_height;        h = right_height;
873        bits = right_bits;        bits = right_bits;
       x = window_box_right (w, -1);  
       x += (FRAME_X_RIGHT_FRINGE_WIDTH (f) - wd) / 2;  
874        break;        break;
875    
876      case CONTINUED_LINE_BITMAP:      case CONTINUED_LINE_BITMAP:
877        wd = right_width;        wd = continued_width;
878        h = right_height;        h = continued_height;
879        bits = continued_bits;        bits = continued_bits;
       x = window_box_right (w, -1);  
       x += (FRAME_X_RIGHT_FRINGE_WIDTH (f) - wd) / 2;  
880        break;        break;
881                
882      case CONTINUATION_LINE_BITMAP:      case CONTINUATION_LINE_BITMAP:
883        wd = continuation_width;        wd = continuation_width;
884        h = continuation_height;        h = continuation_height;
885        bits = continuation_bits;        bits = continuation_bits;
       x = (WINDOW_TO_FRAME_PIXEL_X (w, 0)  
            - wd  
            - (FRAME_X_LEFT_FRINGE_WIDTH (f) - wd) / 2);  
886        break;        break;
887    
888      case ZV_LINE_BITMAP:      case ZV_LINE_BITMAP:
889        wd = zv_width;        wd = zv_width;
890        h = zv_height;        h = zv_height - (y % zv_period);
891        bits = zv_bits;        bits = zv_bits + (y % zv_period);
       x = (WINDOW_TO_FRAME_PIXEL_X (w, 0)  
            - wd  
            - (FRAME_X_LEFT_FRINGE_WIDTH (f) - wd) / 2);  
892        break;        break;
893    
894      default:      default:
895        abort ();        abort ();
896      }      }
897    
898    /* Convert to frame coordinates.  Set dy to the offset in the row to    /* Clip bitmap if too high.  */
899       start drawing the bitmap.  */    if (h > row->height)
900    y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);      h = row->height;
901    
902      /* Set dy to the offset in the row to start drawing the bitmap.  */
903    dy = (row->height - h) / 2;    dy = (row->height - h) / 2;
904    
905      face = FACE_FROM_ID (f, FRINGE_FACE_ID);
906      PREPARE_FACE_FOR_DISPLAY (f, face);
907    
908      /* Clear left fringe if no bitmap to draw or if bitmap doesn't fill
909         the fringe.  */
910      b1 = -1;
911      if (left_p)
912        {
913          if (wd > FRAME_X_LEFT_FRINGE_WIDTH (f))
914            wd = FRAME_X_LEFT_FRINGE_WIDTH (f);
915          x = (WINDOW_TO_FRAME_PIXEL_X (w, 0)
916               - wd
917               - (FRAME_X_LEFT_FRINGE_WIDTH (f) - wd) / 2);
918          if (wd < FRAME_X_LEFT_FRINGE_WIDTH (f) || row->height > h)
919            {
920              /* If W has a vertical border to its left, don't draw over it.  */
921              int border = ((XFASTINT (w->left) > 0
922                             && !FRAME_HAS_VERTICAL_SCROLL_BARS (f))
923                            ? 1 : 0);
924              b1 = (window_box_left (w, -1)
925                    - FRAME_X_LEFT_FRINGE_WIDTH (f)
926                    + border);
927              b2 = (FRAME_X_LEFT_FRINGE_WIDTH (f) - border);
928            }
929        }
930      else
931        {
932          if (wd > FRAME_X_RIGHT_FRINGE_WIDTH (f))
933            wd = FRAME_X_RIGHT_FRINGE_WIDTH (f);
934          x = (window_box_right (w, -1)
935               + (FRAME_X_RIGHT_FRINGE_WIDTH (f) - wd) / 2);
936          /* Clear right fringe if no bitmap to draw of if bitmap doesn't fill
937             the fringe.  */
938          if (wd < FRAME_X_RIGHT_FRINGE_WIDTH (f) || row->height > h)
939            {
940              b1 = window_box_right (w, -1);
941              b2 = FRAME_X_RIGHT_FRINGE_WIDTH (f);
942            }
943        }
944    
945      if (b1 >= 0)
946        {
947          int header_line_height = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
948          
949          /* In case the same realized face is used for fringes and
950             for something displayed in the text (e.g. face `region' on
951             mono-displays, the fill style may have been changed to
952             FillSolid in x_draw_glyph_string_background.  */
953          if (face->stipple)
954            XSetFillStyle (display, face->gc, FillOpaqueStippled);
955          else
956            XSetForeground (display, face->gc, face->background);
957          
958          XFillRectangle (display, window, face->gc,
959                          b1,
960                          WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height,
961                                                           row->y)),
962                          b2,
963                          row->visible_height);
964          if (!face->stipple)
965            XSetForeground (display, face->gc, face->foreground);
966        }
967    
968      if (which == NO_FRINGE_BITMAP)
969        return;
970    
971    /* Draw the bitmap.  I believe these small pixmaps can be cached    /* Draw the bitmap.  I believe these small pixmaps can be cached
972       by the server.  */       by the server.  */
   face = FACE_FROM_ID (f, FRINGE_FACE_ID);  
973    pixmap = XCreatePixmapFromBitmapData (display, window, bits, wd, h,    pixmap = XCreatePixmapFromBitmapData (display, window, bits, wd, h,
974                                          face->foreground,                                          face->foreground,
975                                          face->background, depth);                                          face->background, depth);
# Line 920  x_draw_row_fringe_bitmaps (w, row) Line 989  x_draw_row_fringe_bitmaps (w, row)
989  {  {
990    struct frame *f = XFRAME (w->frame);    struct frame *f = XFRAME (w->frame);
991    enum fringe_bitmap_type bitmap;    enum fringe_bitmap_type bitmap;
   struct face *face;  
   int header_line_height = -1;  
992    
993    xassert (interrupt_input_blocked);    xassert (interrupt_input_blocked);
994    
# Line 930  x_draw_row_fringe_bitmaps (w, row) Line 997  x_draw_row_fringe_bitmaps (w, row)
997    if (row->visible_height <= 0)    if (row->visible_height <= 0)
998      return;      return;
999    
1000    face = FACE_FROM_ID (f, FRINGE_FACE_ID);    if (FRAME_X_LEFT_FRINGE_WIDTH (f) != 0)
1001    PREPARE_FACE_FOR_DISPLAY (f, face);      {
1002          /* Decide which bitmap to draw in the left fringe.  */
1003    /* Decide which bitmap to draw in the left fringe.  */        if (row->overlay_arrow_p)
1004    if (row->overlay_arrow_p)          bitmap = OVERLAY_ARROW_BITMAP;
1005      bitmap = OVERLAY_ARROW_BITMAP;        else if (row->truncated_on_left_p)
1006    else if (row->truncated_on_left_p)          bitmap = LEFT_TRUNCATION_BITMAP;
1007      bitmap = LEFT_TRUNCATION_BITMAP;        else if (MATRIX_ROW_CONTINUATION_LINE_P (row))
1008    else if (MATRIX_ROW_CONTINUATION_LINE_P (row))          bitmap = CONTINUATION_LINE_BITMAP;
1009      bitmap = CONTINUATION_LINE_BITMAP;        else if (row->indicate_empty_line_p)
1010    else if (row->indicate_empty_line_p)          bitmap = ZV_LINE_BITMAP;
     bitmap = ZV_LINE_BITMAP;  
   else  
     bitmap = NO_FRINGE_BITMAP;  
   
   /* Clear left fringe if no bitmap to draw or if bitmap doesn't fill  
      the fringe.  */  
   if (bitmap == NO_FRINGE_BITMAP  
       || FRAME_FRINGE_BITMAP_WIDTH (f) < FRAME_X_LEFT_FRINGE_WIDTH (f)  
       || row->height > FRAME_FRINGE_BITMAP_HEIGHT (f))  
     {  
       /* If W has a vertical border to its left, don't draw over it.  */  
       int border = ((XFASTINT (w->left) > 0  
                      && !FRAME_HAS_VERTICAL_SCROLL_BARS (f))  
                     ? 1 : 0);  
       int left = window_box_left (w, -1);  
   
       if (header_line_height < 0)  
         header_line_height = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);  
         
       /* In case the same realized face is used for fringes and  
          for something displayed in the text (e.g. face `region' on  
          mono-displays, the fill style may have been changed to  
          FillSolid in x_draw_glyph_string_background.  */  
       if (face->stipple)  
         XSetFillStyle (FRAME_X_DISPLAY (f), face->gc, FillOpaqueStippled);  
1011        else        else
1012          XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->background);          bitmap = NO_FRINGE_BITMAP;
         
       XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),  
                       face->gc,  
                       (left  
                        - FRAME_X_LEFT_FRINGE_WIDTH (f)  
                        + border),  
                       WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height,  
                                                        row->y)),  
                       FRAME_X_LEFT_FRINGE_WIDTH (f) - border,  
                       row->visible_height);  
       if (!face->stipple)  
         XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->foreground);  
     }  
1013    
1014    /* Draw the left bitmap.  */        x_draw_fringe_bitmap (w, row, bitmap, 1);
1015    if (bitmap != NO_FRINGE_BITMAP)      }
     x_draw_fringe_bitmap (w, row, bitmap);  
   
   /* Decide which bitmap to draw in the right fringe.  */  
   if (row->truncated_on_right_p)  
     bitmap = RIGHT_TRUNCATION_BITMAP;  
   else if (row->continued_p)  
     bitmap = CONTINUED_LINE_BITMAP;  
   else  
     bitmap = NO_FRINGE_BITMAP;  
1016    
1017    /* Clear right fringe if no bitmap to draw of if bitmap doesn't fill    if (FRAME_X_RIGHT_FRINGE_WIDTH (f) != 0)
      the fringe.  */  
   if (bitmap == NO_FRINGE_BITMAP  
       || FRAME_FRINGE_BITMAP_WIDTH (f) < FRAME_X_RIGHT_FRINGE_WIDTH (f)  
       || row->height > FRAME_FRINGE_BITMAP_HEIGHT (f))  
1018      {      {
1019        int right = window_box_right (w, -1);        /* Decide which bitmap to draw in the right fringe.  */
1020          if (row->truncated_on_right_p)
1021        if (header_line_height < 0)          bitmap = RIGHT_TRUNCATION_BITMAP;
1022          header_line_height = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);        else if (row->continued_p)
1023            bitmap = CONTINUED_LINE_BITMAP;
1024        /* In case the same realized face is used for fringes and        else if (row->indicate_empty_line_p && FRAME_X_LEFT_FRINGE_WIDTH (f) == 0)
1025           for something displayed in the text (e.g. face `region' on          bitmap = ZV_LINE_BITMAP;
          mono-displays, the fill style may have been changed to  
          FillSolid in x_draw_glyph_string_background.  */  
       if (face->stipple)  
         XSetFillStyle (FRAME_X_DISPLAY (f), face->gc, FillOpaqueStippled);  
1026        else        else
1027          XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->background);          bitmap = NO_FRINGE_BITMAP;
       XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),  
                       face->gc,  
                       right,  
                       WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height,  
                                                        row->y)),  
                       FRAME_X_RIGHT_FRINGE_WIDTH (f),  
                       row->visible_height);  
       if (!face->stipple)  
         XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->foreground);  
     }  
1028    
1029    /* Draw the right bitmap.  */        x_draw_fringe_bitmap (w, row, bitmap, 0);
1030    if (bitmap != NO_FRINGE_BITMAP)      }
     x_draw_fringe_bitmap (w, row, bitmap);  
1031  }  }
1032    
1033    
# Line 5064  x_draw_glyphs (w, x, row, area, start, e Line 5065  x_draw_glyphs (w, x, row, area, start, e
5065        /* X is relative to the left edge of W, without scroll bars        /* X is relative to the left edge of W, without scroll bars
5066           or fringes.  */           or fringes.  */
5067        struct frame *f = XFRAME (w->frame);        struct frame *f = XFRAME (w->frame);
       /* int width = FRAME_FRINGE_WIDTH (f);  */  
5068        int window_left_x = WINDOW_LEFT_MARGIN (w) * CANON_X_UNIT (f);        int window_left_x = WINDOW_LEFT_MARGIN (w) * CANON_X_UNIT (f);
5069    
5070        x += window_left_x;        x += window_left_x;
# Line 12099  x_new_font (f, fontname) Line 12099  x_new_font (f, fontname)
12099    f->output_data.x->font = (XFontStruct *) (fontp->font);    f->output_data.x->font = (XFontStruct *) (fontp->font);
12100    f->output_data.x->baseline_offset = fontp->baseline_offset;    f->output_data.x->baseline_offset = fontp->baseline_offset;
12101    f->output_data.x->fontset = -1;    f->output_data.x->fontset = -1;
12102      
12103      x_compute_fringe_widths (f, 1);
12104    
12105    /* Compute the scroll bar width in character columns.  */    /* Compute the scroll bar width in character columns.  */
12106    if (f->scroll_bar_pixel_width > 0)    if (f->scroll_bar_pixel_width > 0)
12107      {      {
# Line 12177  x_new_fontset (f, fontsetname) Line 12179  x_new_fontset (f, fontsetname)
12179    return build_string (fontsetname);    return build_string (fontsetname);
12180  }  }
12181    
12182    /* Compute actual fringe widths */
12183    
12184    void
12185    x_compute_fringe_widths (f, redraw)
12186         struct frame *f;
12187         int redraw;
12188    {
12189      int o_left = f->output_data.x->left_fringe_width;
12190      int o_right = f->output_data.x->right_fringe_width;
12191      int o_cols = f->output_data.x->fringe_cols;
12192    
12193      Lisp_Object left_fringe = Fassq (Qleft_fringe, f->param_alist);
12194      Lisp_Object right_fringe = Fassq (Qright_fringe, f->param_alist);
12195      int left_fringe_width, right_fringe_width;
12196    
12197      if (!NILP (left_fringe))
12198        left_fringe = Fcdr (left_fringe);
12199      if (!NILP (right_fringe))
12200        right_fringe = Fcdr (right_fringe);
12201    
12202      left_fringe_width = ((NILP (left_fringe) || !INTEGERP (left_fringe)) ? 8 :
12203                           XINT (left_fringe));
12204      right_fringe_width = ((NILP (right_fringe) || !INTEGERP (right_fringe)) ? 8 :
12205                            XINT (right_fringe));
12206    
12207      if (left_fringe_width || right_fringe_width)
12208        {
12209          int left_wid = left_fringe_width >= 0 ? left_fringe_width : -left_fringe_width;
12210          int right_wid = right_fringe_width >= 0 ? right_fringe_width : -right_fringe_width;
12211          int conf_wid = left_wid + right_wid;
12212          int font_wid = FONT_WIDTH (f->output_data.x->font);
12213          int cols = (left_wid + right_wid + font_wid-1) / font_wid;
12214          int real_wid = cols * font_wid;
12215          if (left_wid && right_wid)
12216            {
12217              if (left_fringe_width < 0)
12218                {
12219                  /* Left fringe width is fixed, adjust right fringe if necessary */
12220                  f->output_data.x->left_fringe_width = left_wid;
12221                  f->output_data.x->right_fringe_width = real_wid - left_wid;
12222                }
12223              else if (right_fringe_width < 0)
12224                {
12225                  /* Right fringe width is fixed, adjust left fringe if necessary */
12226                  f->output_data.x->left_fringe_width = real_wid - right_wid;
12227                  f->output_data.x->right_fringe_width = right_wid;
12228                }
12229              else
12230                {
12231                  /* Adjust both fringes with an equal amount.
12232                     Note that we are doing integer arithmetic here, so don't
12233                     lose a pixel if the total width is an odd number.  */
12234                  int fill = real_wid - conf_wid;
12235                  f->output_data.x->left_fringe_width = left_wid + fill/2;
12236                  f->output_data.x->right_fringe_width = right_wid + fill - fill/2;
12237                }
12238            }
12239          else if (left_fringe_width)
12240            {
12241              f->output_data.x->left_fringe_width = real_wid;
12242              f->output_data.x->right_fringe_width = 0;
12243            }
12244          else
12245            {
12246              f->output_data.x->left_fringe_width = 0;
12247              f->output_data.x->right_fringe_width = real_wid;
12248            }
12249          f->output_data.x->fringe_cols = cols;
12250          f->output_data.x->fringes_extra = real_wid;
12251        }
12252      else
12253        {
12254          f->output_data.x->left_fringe_width = 0;
12255          f->output_data.x->right_fringe_width = 0;
12256          f->output_data.x->fringe_cols = 0;
12257          f->output_data.x->fringes_extra = 0;
12258        }
12259    
12260      if (redraw && FRAME_VISIBLE_P (f))
12261        if (o_left != f->output_data.x->left_fringe_width ||
12262            o_right != f->output_data.x->right_fringe_width ||
12263            o_cols != f->output_data.x->fringe_cols)
12264          redraw_frame (f);
12265    }
12266    
12267  /***********************************************************************  /***********************************************************************
12268                             X Input Methods                             X Input Methods
# Line 12567  x_set_window_size_1 (f, change_gravity, Line 12653  x_set_window_size_1 (f, change_gravity,
12653         : FRAME_SCROLL_BAR_PIXEL_WIDTH (f) > 0         : FRAME_SCROLL_BAR_PIXEL_WIDTH (f) > 0
12654         ? FRAME_SCROLL_BAR_PIXEL_WIDTH (f)         ? FRAME_SCROLL_BAR_PIXEL_WIDTH (f)
12655         : (FRAME_SCROLL_BAR_COLS (f) * FONT_WIDTH (f->output_data.x->font)));         : (FRAME_SCROLL_BAR_COLS (f) * FONT_WIDTH (f->output_data.x->font)));
12656    f->output_data.x->fringes_extra  
12657      = FRAME_FRINGE_WIDTH (f);    x_compute_fringe_widths (f, 0);
12658    
12659    pixelwidth = CHAR_TO_PIXEL_WIDTH (f, cols);    pixelwidth = CHAR_TO_PIXEL_WIDTH (f, cols);
12660    pixelheight = CHAR_TO_PIXEL_HEIGHT (f, rows);    pixelheight = CHAR_TO_PIXEL_HEIGHT (f, rows);
12661    

Legend:
Removed from v.1.689  
changed lines
  Added in v.1.690

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26