emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/xdisp.c [lexbind]


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/src/xdisp.c [lexbind]
Date: Wed, 08 Dec 2004 18:57:12 -0500

Index: emacs/src/xdisp.c
diff -c emacs/src/xdisp.c:1.754.2.39 emacs/src/xdisp.c:1.754.2.40
*** emacs/src/xdisp.c:1.754.2.39        Wed Dec  8 23:31:37 2004
--- emacs/src/xdisp.c   Wed Dec  8 23:36:22 2004
***************
*** 342,347 ****
--- 342,352 ----
  
  Lisp_Object Qtrailing_whitespace;
  
+ /* Name and number of the face used to highlight escape glyphs.  */
+ 
+ Lisp_Object Qescape_glyph;
+ int escape_glyph_face;
+ 
  /* The symbol `image' which is the car of the lists used to represent
     images in Lisp.  */
  
***************
*** 807,813 ****
  
  /* Function prototypes.  */
  
! static void setup_for_ellipsis P_ ((struct it *));
  static void mark_window_display_accurate_1 P_ ((struct window *, int));
  static int single_display_prop_string_p P_ ((Lisp_Object, Lisp_Object));
  static int display_prop_string_p P_ ((Lisp_Object, Lisp_Object));
--- 812,818 ----
  
  /* Function prototypes.  */
  
! static void setup_for_ellipsis P_ ((struct it *, int));
  static void mark_window_display_accurate_1 P_ ((struct window *, int));
  static int single_display_prop_string_p P_ ((Lisp_Object, Lisp_Object));
  static int display_prop_string_p P_ ((Lisp_Object, Lisp_Object));
***************
*** 3227,3233 ****
              it->stack[it->sp - 1].display_ellipsis_p = display_ellipsis_p;
            }
          else if (display_ellipsis_p)
!           setup_for_ellipsis (it);
        }
      }
  
--- 3232,3238 ----
              it->stack[it->sp - 1].display_ellipsis_p = display_ellipsis_p;
            }
          else if (display_ellipsis_p)
!           setup_for_ellipsis (it, 0);
        }
      }
  
***************
*** 3235,3248 ****
  }
  
  
! /* Make iterator IT return `...' next.  */
  
  static void
! setup_for_ellipsis (it)
       struct it *it;
  {
!   if (it->dp
!       && VECTORP (DISP_INVIS_VECTOR (it->dp)))
      {
        struct Lisp_Vector *v = XVECTOR (DISP_INVIS_VECTOR (it->dp));
        it->dpvec = v->contents;
--- 3240,3256 ----
  }
  
  
! /* Make iterator IT return `...' next.
!    Replaces LEN characters from buffer.  */
  
  static void
! setup_for_ellipsis (it, len)
       struct it *it;
+      int len;
  {
!   /* Use the display table definition for `...'.  Invalid glyphs
!      will be handled by the method returning elements from dpvec.  */
!   if (it->dp && VECTORP (DISP_INVIS_VECTOR (it->dp)))
      {
        struct Lisp_Vector *v = XVECTOR (DISP_INVIS_VECTOR (it->dp));
        it->dpvec = v->contents;
***************
*** 3255,3266 ****
        it->dpend = default_invis_vector + 3;
      }
  
!   /* The ellipsis display does not replace the display of the
!      character at the new position.  Indicate this by setting
!      IT->dpvec_char_len to zero.  */
!   it->dpvec_char_len = 0;
! 
    it->current.dpvec_index = 0;
    it->method = next_element_from_display_vector;
  }
  
--- 3263,3274 ----
        it->dpend = default_invis_vector + 3;
      }
  
!   it->dpvec_char_len = len;
    it->current.dpvec_index = 0;
+ 
+   /* Remember the current face id in case glyphs specify faces.
+      IT's face is restored in set_iterator_to_next.  */
+   it->saved_face_id = it->face_id;
    it->method = next_element_from_display_vector;
  }
  
***************
*** 3575,3581 ****
              || EQ (XCAR (prop), Qright_fringe))
          && CONSP (XCDR (prop)))
        {
!         unsigned face_id = DEFAULT_FACE_ID;
          int fringe_bitmap;
  
          /* Save current settings of IT so that we can restore them
--- 3583,3589 ----
              || EQ (XCAR (prop), Qright_fringe))
          && CONSP (XCDR (prop)))
        {
!         int face_id = DEFAULT_FACE_ID;
          int fringe_bitmap;
  
          /* Save current settings of IT so that we can restore them
***************
*** 3594,3603 ****
          if (CONSP (XCDR (XCDR (prop))))
            {
              Lisp_Object face_name = XCAR (XCDR (XCDR (prop)));
! 
!             face_id = lookup_named_face (it->f, face_name, 'A');
!             if (face_id < 0)
!               return 0;
            }
  
          push_it (it);
--- 3602,3610 ----
          if (CONSP (XCDR (XCDR (prop))))
            {
              Lisp_Object face_name = XCAR (XCDR (XCDR (prop)));
!             int face_id2 = lookup_named_face (it->f, face_name, 'A', 0);
!             if (face_id2 >= 0)
!               face_id = face_id2;
            }
  
          push_it (it);
***************
*** 4049,4055 ****
        /* If we have to display `...' for invisible text, set
         the iterator up for that.  */
        if (display_ellipsis_p)
!       setup_for_ellipsis (it);
      }
    else
      {
--- 4056,4062 ----
        /* If we have to display `...' for invisible text, set
         the iterator up for that.  */
        if (display_ellipsis_p)
!       setup_for_ellipsis (it, 0);
      }
    else
      {
***************
*** 4841,4847 ****
       we hit the end of what we iterate over.  Performance note: the
       function pointer `method' used here turns out to be faster than
       using a sequence of if-statements.  */
!   int success_p = (*it->method) (it);
  
    if (it->what == IT_CHARACTER)
      {
--- 4848,4857 ----
       we hit the end of what we iterate over.  Performance note: the
       function pointer `method' used here turns out to be faster than
       using a sequence of if-statements.  */
!   int success_p;
! 
!  get_next:
!   success_p = (*it->method) (it);
  
    if (it->what == IT_CHARACTER)
      {
***************
*** 4873,4886 ****
                  it->dpvec = v->contents;
                  it->dpend = v->contents + v->size;
                  it->current.dpvec_index = 0;
                  it->method = next_element_from_display_vector;
-                 success_p = get_next_display_element (it);
                }
              else
                {
                  set_iterator_to_next (it, 0);
-                 success_p = get_next_display_element (it);
                }
            }
  
          /* Translate control characters into `\003' or `^C' form.
--- 4883,4896 ----
                  it->dpvec = v->contents;
                  it->dpend = v->contents + v->size;
                  it->current.dpvec_index = 0;
+                 it->saved_face_id = it->face_id;
                  it->method = next_element_from_display_vector;
                }
              else
                {
                  set_iterator_to_next (it, 0);
                }
+             goto get_next;
            }
  
          /* Translate control characters into `\003' or `^C' form.
***************
*** 4916,4921 ****
--- 4926,4947 ----
                 IT->ctl_chars with glyphs for what we have to
                 display.  Then, set IT->dpvec to these glyphs.  */
              GLYPH g;
+             int ctl_len;
+             int face_id = escape_glyph_face;
+ 
+             /* Find the face id if `escape-glyph' unless we recently did.  */
+             if (face_id < 0)
+               {
+                 Lisp_Object tem = Fget (Qescape_glyph, Qface);
+                 if (INTEGERP (tem))
+                   face_id = XINT (tem);
+                 else
+                   face_id = 0;
+                 /* If there's overflow, use 0 instead.  */
+                 if (FAST_GLYPH_FACE (FAST_MAKE_GLYPH (0, face_id)) != face_id)
+                   face_id = 0;
+                 escape_glyph_face = face_id;
+               }
  
              if (it->c < 128 && it->ctl_arrow_p)
                {
***************
*** 4925,4943 ****
                      && GLYPH_CHAR_VALID_P (XINT (DISP_CTRL_GLYPH (it->dp))))
                    g = XINT (DISP_CTRL_GLYPH (it->dp));
                  else
!                   g = FAST_MAKE_GLYPH ('^', 0);
                  XSETINT (it->ctl_chars[0], g);
  
!                 g = FAST_MAKE_GLYPH (it->c ^ 0100, 0);
                  XSETINT (it->ctl_chars[1], g);
! 
!                 /* Set up IT->dpvec and return first character from it.  */
!                 it->dpvec_char_len = it->len;
!                 it->dpvec = it->ctl_chars;
!                 it->dpend = it->dpvec + 2;
!                 it->current.dpvec_index = 0;
!                 it->method = next_element_from_display_vector;
!                 get_next_display_element (it);
                }
              else
                {
--- 4951,4962 ----
                      && GLYPH_CHAR_VALID_P (XINT (DISP_CTRL_GLYPH (it->dp))))
                    g = XINT (DISP_CTRL_GLYPH (it->dp));
                  else
!                   g = FAST_MAKE_GLYPH ('^', face_id);
                  XSETINT (it->ctl_chars[0], g);
  
!                 g = FAST_MAKE_GLYPH (it->c ^ 0100, face_id);
                  XSETINT (it->ctl_chars[1], g);
!                 ctl_len = 2;
                }
              else
                {
***************
*** 4952,4958 ****
                      && GLYPH_CHAR_VALID_P (XFASTINT (DISP_ESCAPE_GLYPH 
(it->dp))))
                    escape_glyph = XFASTINT (DISP_ESCAPE_GLYPH (it->dp));
                  else
!                   escape_glyph = FAST_MAKE_GLYPH ('\\', 0);
  
                  if (SINGLE_BYTE_CHAR_P (it->c))
                    str[0] = it->c, len = 1;
--- 4971,4977 ----
                      && GLYPH_CHAR_VALID_P (XFASTINT (DISP_ESCAPE_GLYPH 
(it->dp))))
                    escape_glyph = XFASTINT (DISP_ESCAPE_GLYPH (it->dp));
                  else
!                   escape_glyph = FAST_MAKE_GLYPH ('\\', face_id);
  
                  if (SINGLE_BYTE_CHAR_P (it->c))
                    str[0] = it->c, len = 1;
***************
*** 4979,5001 ****
                      XSETINT (it->ctl_chars[i * 4], escape_glyph);
                      /* Insert three more glyphs into IT->ctl_chars for
                         the octal display of the character.  */
!                     g = FAST_MAKE_GLYPH (((str[i] >> 6) & 7) + '0', 0);
                      XSETINT (it->ctl_chars[i * 4 + 1], g);
!                     g = FAST_MAKE_GLYPH (((str[i] >> 3) & 7) + '0', 0);
                      XSETINT (it->ctl_chars[i * 4 + 2], g);
!                     g = FAST_MAKE_GLYPH ((str[i] & 7) + '0', 0);
                      XSETINT (it->ctl_chars[i * 4 + 3], g);
                    }
! 
!                 /* Set up IT->dpvec and return the first character
!                      from it.  */
!                 it->dpvec_char_len = it->len;
!                 it->dpvec = it->ctl_chars;
!                 it->dpend = it->dpvec + len * 4;
!                 it->current.dpvec_index = 0;
!                 it->method = next_element_from_display_vector;
!                 get_next_display_element (it);
                }
            }
        }
  
--- 4998,5024 ----
                      XSETINT (it->ctl_chars[i * 4], escape_glyph);
                      /* Insert three more glyphs into IT->ctl_chars for
                         the octal display of the character.  */
!                     g = FAST_MAKE_GLYPH (((str[i] >> 6) & 7) + '0',
!                                          face_id);
                      XSETINT (it->ctl_chars[i * 4 + 1], g);
!                     g = FAST_MAKE_GLYPH (((str[i] >> 3) & 7) + '0',
!                                          face_id);
                      XSETINT (it->ctl_chars[i * 4 + 2], g);
!                     g = FAST_MAKE_GLYPH ((str[i] & 7) + '0',
!                                          face_id);
                      XSETINT (it->ctl_chars[i * 4 + 3], g);
                    }
!                 ctl_len = len * 4;
                }
+ 
+             /* Set up IT->dpvec and return first character from it.  */
+             it->dpvec_char_len = it->len;
+             it->dpvec = it->ctl_chars;
+             it->dpend = it->dpvec + ctl_len;
+             it->current.dpvec_index = 0;
+             it->saved_face_id = it->face_id;
+             it->method = next_element_from_display_vector;
+             goto get_next;
            }
        }
  
***************
*** 5185,5195 ****
               && IT_STRING_CHARPOS (*it) >= 0));
  }
  
- 
  /* Load IT's display element fields with information about the next
     display element which comes from a display table entry or from the
     result of translating a control character to one of the forms `^C'
!    or `\003'.  IT->dpvec holds the glyphs to return as characters.  */
  
  static int
  next_element_from_display_vector (it)
--- 5208,5221 ----
               && IT_STRING_CHARPOS (*it) >= 0));
  }
  
  /* Load IT's display element fields with information about the next
     display element which comes from a display table entry or from the
     result of translating a control character to one of the forms `^C'
!    or `\003'.
! 
!    IT->dpvec holds the glyphs to return as characters.
!    IT->saved_face_id holds the face id before the display vector--
!    it is restored into IT->face_idin set_iterator_to_next.  */
  
  static int
  next_element_from_display_vector (it)
***************
*** 5198,5207 ****
    /* Precondition.  */
    xassert (it->dpvec && it->current.dpvec_index >= 0);
  
-   /* Remember the current face id in case glyphs specify faces.
-      IT's face is restored in set_iterator_to_next.  */
-   it->saved_face_id = it->face_id;
- 
    if (INTEGERP (*it->dpvec)
        && GLYPH_CHAR_VALID_P (XFASTINT (*it->dpvec)))
      {
--- 5224,5229 ----
***************
*** 5385,5412 ****
       struct it *it;
  {
    if (it->selective_display_ellipsis_p)
!     {
!       if (it->dp && VECTORP (DISP_INVIS_VECTOR (it->dp)))
!       {
!         /* Use the display table definition for `...'.  Invalid glyphs
!            will be handled by the method returning elements from dpvec.  */
!         struct Lisp_Vector *v = XVECTOR (DISP_INVIS_VECTOR (it->dp));
!         it->dpvec_char_len = it->len;
!         it->dpvec = v->contents;
!         it->dpend = v->contents + v->size;
!         it->current.dpvec_index = 0;
!         it->method = next_element_from_display_vector;
!       }
!       else
!       {
!         /* Use default `...' which is stored in default_invis_vector.  */
!         it->dpvec_char_len = it->len;
!         it->dpvec = default_invis_vector;
!         it->dpend = default_invis_vector + 3;
!         it->current.dpvec_index = 0;
!         it->method = next_element_from_display_vector;
!       }
!     }
    else
      {
        /* The face at the current position may be different from the
--- 5407,5413 ----
       struct it *it;
  {
    if (it->selective_display_ellipsis_p)
!     setup_for_ellipsis (it, it->len);
    else
      {
        /* The face at the current position may be different from the
***************
*** 11600,11605 ****
--- 11601,11609 ----
    *w->desired_matrix->method = 0;
  #endif
  
+   /* Force this to be looked up again for each redisp of each window.  */
+   escape_glyph_face = -1;
+ 
    specbind (Qinhibit_point_motion_hooks, Qt);
  
    reconsider_clip_changes (w, buffer);
***************
*** 14532,14538 ****
                  && glyph->u.ch == ' '))
          && trailing_whitespace_p (glyph->charpos))
        {
!         int face_id = lookup_named_face (f, Qtrailing_whitespace, 0);
  
          while (glyph >= start
                 && BUFFERP (glyph->object)
--- 14536,14544 ----
                  && glyph->u.ch == ' '))
          && trailing_whitespace_p (glyph->charpos))
        {
!         int face_id = lookup_named_face (f, Qtrailing_whitespace, 0, 0);
!         if (face_id < 0)
!           return;
  
          while (glyph >= start
                 && BUFFERP (glyph->object)
***************
*** 14625,14632 ****
       hscrolled.  This may stop at an x-position < IT->first_visible_x
       if the first glyph is partially visible or if we hit a line end.  */
    if (it->current_x < it->first_visible_x)
!     move_it_in_display_line_to (it, ZV, it->first_visible_x,
!                               MOVE_TO_POS | MOVE_TO_X);
  
    /* Get the initial row height.  This is either the height of the
       text hscrolled, if there is any, or zero.  */
--- 14631,14640 ----
       hscrolled.  This may stop at an x-position < IT->first_visible_x
       if the first glyph is partially visible or if we hit a line end.  */
    if (it->current_x < it->first_visible_x)
!     {
!       move_it_in_display_line_to (it, ZV, it->first_visible_x,
!                                 MOVE_TO_POS | MOVE_TO_X);
!     }
  
    /* Get the initial row height.  This is either the height of the
       text hscrolled, if there is any, or zero.  */
***************
*** 14955,14966 ****
                {
                  if (!get_next_display_element (it))
                    {
- #ifdef HAVE_WINDOW_SYSTEM
                      it->continuation_lines_width = 0;
                      row->ends_at_zv_p = 1;
                      row->exact_window_width_line_p = 1;
                      break;
- #endif /* HAVE_WINDOW_SYSTEM */
                    }
                  if (ITERATOR_AT_END_OF_LINE_P (it))
                    {
--- 14963,14972 ----
***************
*** 18269,18274 ****
--- 18275,18293 ----
    return x_reached;
  }
  
+ /* Expand row matrix if too narrow.  Don't expand if area
+    is not present.  */
+ 
+ #define IT_EXPAND_MATRIX_WIDTH(it, area)              \
+   {                                                   \
+     if (!fonts_changed_p                              \
+       && (it->glyph_row->glyphs[area]                 \
+           < it->glyph_row->glyphs[area + 1]))         \
+       {                                                       \
+       it->w->ncols_scale_factor++;                    \
+       fonts_changed_p = 1;                            \
+       }                                                       \
+   }
  
  /* Store one glyph for IT->char_to_display in IT->glyph_row.
     Called from x_produce_glyphs when IT->glyph_row is non-null.  */
***************
*** 18306,18316 ****
        glyph->font_type = FONT_TYPE_UNKNOWN;
        ++it->glyph_row->used[area];
      }
!   else if (!fonts_changed_p)
!     {
!       it->w->ncols_scale_factor++;
!       fonts_changed_p = 1;
!     }
  }
  
  /* Store one glyph for the composition IT->cmp_id in IT->glyph_row.
--- 18325,18332 ----
        glyph->font_type = FONT_TYPE_UNKNOWN;
        ++it->glyph_row->used[area];
      }
!   else
!     IT_EXPAND_MATRIX_WIDTH (it, area);
  }
  
  /* Store one glyph for the composition IT->cmp_id in IT->glyph_row.
***************
*** 18348,18358 ****
        glyph->font_type = FONT_TYPE_UNKNOWN;
        ++it->glyph_row->used[area];
      }
!   else if (!fonts_changed_p)
!     {
!       it->w->ncols_scale_factor++;
!       fonts_changed_p = 1;
!     }
  }
  
  
--- 18364,18371 ----
        glyph->font_type = FONT_TYPE_UNKNOWN;
        ++it->glyph_row->used[area];
      }
!   else
!     IT_EXPAND_MATRIX_WIDTH (it, area);
  }
  
  
***************
*** 18522,18532 ****
          glyph->font_type = FONT_TYPE_UNKNOWN;
          ++it->glyph_row->used[area];
        }
!       else if (!fonts_changed_p)
!       {
!         it->w->ncols_scale_factor++;
!         fonts_changed_p = 1;
!       }
      }
  }
  
--- 18535,18542 ----
          glyph->font_type = FONT_TYPE_UNKNOWN;
          ++it->glyph_row->used[area];
        }
!       else
!       IT_EXPAND_MATRIX_WIDTH (it, area);
      }
  }
  
***************
*** 18570,18580 ****
        glyph->font_type = FONT_TYPE_UNKNOWN;
        ++it->glyph_row->used[area];
      }
!   else if (!fonts_changed_p)
!     {
!       it->w->ncols_scale_factor++;
!       fonts_changed_p = 1;
!     }
  }
  
  
--- 18580,18587 ----
        glyph->font_type = FONT_TYPE_UNKNOWN;
        ++it->glyph_row->used[area];
      }
!   else
!     IT_EXPAND_MATRIX_WIDTH (it, area);
  }
  
  
***************
*** 18805,18811 ****
        struct face *face;
        struct font_info *font_info;
  
!       face_id = lookup_named_face (it->f, face_name, ' ');
        if (face_id < 0)
        return make_number (-1);
  
--- 18812,18818 ----
        struct face *face;
        struct font_info *font_info;
  
!       face_id = lookup_named_face (it->f, face_name, ' ', 0);
        if (face_id < 0)
        return make_number (-1);
  
***************
*** 20117,20122 ****
--- 20124,20130 ----
      {
        int x, y;
        int header_line_height = WINDOW_HEADER_LINE_HEIGHT (w);
+       int width;
  
        cursor_glyph = get_phys_cursor_glyph (w);
        if (cursor_glyph == NULL)
***************
*** 20124,20132 ****
  
        x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x);
        y = WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height, 
cursor_row->y));
  
!       rif->clear_frame_area (f, x, y,
!                            cursor_glyph->pixel_width, 
cursor_row->visible_height);
      }
  
    /* Erase the cursor by redrawing the character underneath it.  */
--- 20132,20141 ----
  
        x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x);
        y = WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height, 
cursor_row->y));
+       width = min (cursor_glyph->pixel_width,
+                  window_box_width (w, TEXT_AREA) - w->phys_cursor.x);
  
!       rif->clear_frame_area (f, x, y, width, cursor_row->visible_height);
      }
  
    /* Erase the cursor by redrawing the character underneath it.  */
***************
*** 20947,20959 ****
        /* If we're on a string with `help-echo' text property, arrange
         for the help to be displayed.  This is done by setting the
         global variable help_echo_string to the help string.  */
!       help = Fget_text_property (pos, Qhelp_echo, string);
!       if (!NILP (help))
        {
!         help_echo_string = help;
!         XSETWINDOW (help_echo_window, w);
!         help_echo_object = string;
!         help_echo_pos = charpos;
        }
  
        if (NILP (pointer))
--- 20956,20971 ----
        /* If we're on a string with `help-echo' text property, arrange
         for the help to be displayed.  This is done by setting the
         global variable help_echo_string to the help string.  */
!       if (NILP (help))
        {
!         help = Fget_text_property (pos, Qhelp_echo, string);
!         if (!NILP (help))
!           {
!             help_echo_string = help;
!             XSETWINDOW (help_echo_window, w);
!             help_echo_object = string;
!             help_echo_pos = charpos;
!           }
        }
  
        if (NILP (pointer))
***************
*** 22159,22164 ****
--- 22171,22178 ----
    staticpro (&Qfontification_functions);
    Qtrailing_whitespace = intern ("trailing-whitespace");
    staticpro (&Qtrailing_whitespace);
+   Qescape_glyph = intern ("escape-glyph");
+   staticpro (&Qescape_glyph);
    Qimage = intern ("image");
    staticpro (&Qimage);
    QCmap = intern (":map");




reply via email to

[Prev in Thread] Current Thread [Next in Thread]