emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r105619: Fix bug #9402 with :align-to


From: Eli Zaretskii
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r105619: Fix bug #9402 with :align-to on TTY frames.
Date: Tue, 30 Aug 2011 20:32:44 +0300
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 105619
fixes bug(s): http://debbugs.gnu.org/9402
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Tue 2011-08-30 20:32:44 +0300
message:
  Fix bug #9402 with :align-to on TTY frames.
  
   src/xdisp.c (produce_stretch_glyph): No longer static, compiled also
   when HAVE_WINDOW_SYSTEM is not defined.  Support both GUI and TTY
   frames.  Call tty_append_glyph in the TTY case.  (Bug#9402)
   src/term.c (tty_append_glyph): New function.
   (produce_stretch_glyph): Static function and its prototype deleted.
   src/dispextern.h (produce_stretch_glyph, tty_append_glyph): Add
   prototypes.
modified:
  src/ChangeLog
  src/dispextern.h
  src/term.c
  src/xdisp.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2011-08-29 03:34:25 +0000
+++ b/src/ChangeLog     2011-08-30 17:32:44 +0000
@@ -1,3 +1,15 @@
+2011-08-30  Eli Zaretskii  <address@hidden>
+
+       * xdisp.c (produce_stretch_glyph): No longer static, compiled also
+       when HAVE_WINDOW_SYSTEM is not defined.  Support both GUI and TTY
+       frames.  Call tty_append_glyph in the TTY case.  (Bug#9402)
+
+       * term.c (tty_append_glyph): New function.
+       (produce_stretch_glyph): Static function and its prototype deleted.
+
+       * dispextern.h (produce_stretch_glyph, tty_append_glyph): Add
+       prototypes.
+
 2011-08-29  Paul Eggert  <address@hidden>
 
        * image.c (parse_image_spec): Check for nonnegative, not for positive,

=== modified file 'src/dispextern.h'
--- a/src/dispextern.h  2011-08-25 19:06:56 +0000
+++ b/src/dispextern.h  2011-08-30 17:32:44 +0000
@@ -3043,6 +3043,8 @@
                                             int, int *);
 extern EMACS_INT compute_display_string_end (EMACS_INT,
                                             struct bidi_string_data *);
+extern void produce_stretch_glyph (struct it *);
+
 
 #ifdef HAVE_WINDOW_SYSTEM
 
@@ -3337,6 +3339,7 @@
 EXFUN (Ftty_type, 1);
 extern void create_tty_output (struct frame *);
 extern struct terminal *init_tty (const char *, const char *, int);
+extern void tty_append_glyph (struct it *);
 
 
 /* Defined in scroll.c */

=== modified file 'src/term.c'
--- a/src/term.c        2011-08-28 20:45:55 +0000
+++ b/src/term.c        2011-08-30 17:32:44 +0000
@@ -1440,7 +1440,6 @@
                       Character Display Information
  ***********************************************************************/
 static void append_glyph (struct it *);
-static void produce_stretch_glyph (struct it *);
 static void append_composite_glyph (struct it *);
 static void produce_composite_glyph (struct it *);
 static void append_glyphless_glyph (struct it *, int, const char *);
@@ -1512,6 +1511,14 @@
     }
 }
 
+/* For external use.  */
+void
+tty_append_glyph (struct it *it)
+{
+  append_glyph (it);
+}
+
+
 /* Produce glyphs for the display element described by IT.  *IT
    specifies what we want to produce a glyph for (character, image, ...),
    and where in the glyph matrix we currently are (glyph row and hpos).
@@ -1638,83 +1645,6 @@
   it->descent = it->max_descent = it->phys_descent = it->max_phys_descent = 1;
 }
 
-
-/* Produce a stretch glyph for iterator IT.  IT->object is the value
-   of the glyph property displayed.  The value must be a list
-   `(space KEYWORD VALUE ...)' with the following KEYWORD/VALUE pairs
-   being recognized:
-
-   1. `:width WIDTH' specifies that the space should be WIDTH *
-   canonical char width wide.  WIDTH may be an integer or floating
-   point number.
-
-   2. `:align-to HPOS' specifies that the space should be wide enough
-   to reach HPOS, a value in canonical character units.  */
-
-static void
-produce_stretch_glyph (struct it *it)
-{
-  /* (space :width WIDTH ...)  */
-  Lisp_Object prop, plist;
-  int width = 0, align_to = -1;
-  int zero_width_ok_p = 0;
-  double tem;
-
-  /* List should start with `space'.  */
-  xassert (CONSP (it->object) && EQ (XCAR (it->object), Qspace));
-  plist = XCDR (it->object);
-
-  /* Compute the width of the stretch.  */
-  if ((prop = Fplist_get (plist, QCwidth), !NILP (prop))
-      && calc_pixel_width_or_height (&tem, it, prop, 0, 1, 0))
-    {
-      /* Absolute width `:width WIDTH' specified and valid.  */
-      zero_width_ok_p = 1;
-      width = (int)(tem + 0.5);
-    }
-  else if ((prop = Fplist_get (plist, QCalign_to), !NILP (prop))
-          && calc_pixel_width_or_height (&tem, it, prop, 0, 1, &align_to))
-    {
-      if (it->glyph_row == NULL || !it->glyph_row->mode_line_p)
-       align_to = (align_to < 0
-                   ? 0
-                   : align_to - window_box_left_offset (it->w, TEXT_AREA));
-      else if (align_to < 0)
-       align_to = window_box_left_offset (it->w, TEXT_AREA);
-      width = max (0, (int)(tem + 0.5) + align_to - it->current_x);
-      zero_width_ok_p = 1;
-    }
-  else
-    /* Nothing specified -> width defaults to canonical char width.  */
-    width = FRAME_COLUMN_WIDTH (it->f);
-
-  if (width <= 0 && (width < 0 || !zero_width_ok_p))
-    width = 1;
-
-  if (width > 0 && it->line_wrap != TRUNCATE
-      && it->current_x + width > it->last_visible_x)
-    width = it->last_visible_x - it->current_x - 1;
-
-  if (width > 0 && it->glyph_row)
-    {
-      Lisp_Object o_object = it->object;
-      Lisp_Object object = it->stack[it->sp - 1].string;
-      int n = width;
-
-      if (!STRINGP (object))
-       object = it->w->buffer;
-      it->object = object;
-      it->char_to_display = ' ';
-      it->pixel_width = it->len = 1;
-      while (n--)
-       append_glyph (it);
-      it->object = o_object;
-    }
-  it->pixel_width = width;
-  it->nglyphs = width;
-}
-
-
 /* Append glyphs to IT's glyph_row for the composition IT->cmp_id.
    Called from produce_composite_glyph for terminal frames if
    IT->glyph_row != NULL.  IT->face_id contains the character's

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2011-08-27 18:11:49 +0000
+++ b/src/xdisp.c       2011-08-30 17:32:44 +0000
@@ -23086,6 +23086,7 @@
     IT_EXPAND_MATRIX_WIDTH (it, area);
 }
 
+#endif /* HAVE_WINDOW_SYSTEM */
 
 /* Produce a stretch glyph for iterator IT.  IT->object is the value
    of the glyph property displayed.  The value must be a list
@@ -23118,19 +23119,28 @@
    of the stretch should be used for the ascent of the stretch.
    ASCENT must be in the range 0 <= ASCENT <= 100.  */
 
-static void
+void
 produce_stretch_glyph (struct it *it)
 {
   /* (space :width WIDTH :height HEIGHT ...)  */
   Lisp_Object prop, plist;
   int width = 0, height = 0, align_to = -1;
-  int zero_width_ok_p = 0, zero_height_ok_p = 0;
+  int zero_width_ok_p = 0;
   int ascent = 0;
   double tem;
-  struct face *face = FACE_FROM_ID (it->f, it->face_id);
-  struct font *font = face->font ? face->font : FRAME_FONT (it->f);
-
-  PREPARE_FACE_FOR_DISPLAY (it->f, face);
+  struct face *face = NULL;
+  struct font *font = NULL;
+
+#ifdef HAVE_WINDOW_SYSTEM
+  int zero_height_ok_p = 0;
+
+  if (FRAME_WINDOW_P (it->f))
+    {
+      face = FACE_FROM_ID (it->f, it->face_id);
+      font = face->font ? face->font : FRAME_FONT (it->f);
+      PREPARE_FACE_FOR_DISPLAY (it->f, face);
+    }
+#endif
 
   /* List should start with `space'.  */
   xassert (CONSP (it->object) && EQ (XCAR (it->object), Qspace));
@@ -23144,8 +23154,9 @@
       zero_width_ok_p = 1;
       width = (int)tem;
     }
-  else if (prop = Fplist_get (plist, QCrelative_width),
-          NUMVAL (prop) > 0)
+#ifdef HAVE_WINDOW_SYSTEM
+  else if (FRAME_WINDOW_P (it->f)
+          && (prop = Fplist_get (plist, QCrelative_width), NUMVAL (prop) > 0))
     {
       /* Relative width `:relative-width FACTOR' specified and valid.
         Compute the width of the characters having the `glyph'
@@ -23168,6 +23179,7 @@
       x_produce_glyphs (&it2);
       width = NUMVAL (prop) * it2.pixel_width;
     }
+#endif /* HAVE_WINDOW_SYSTEM */
   else if ((prop = Fplist_get (plist, QCalign_to), !NILP (prop))
           && calc_pixel_width_or_height (&tem, it, prop, font, 1, &align_to))
     {
@@ -23187,54 +23199,78 @@
   if (width <= 0 && (width < 0 || !zero_width_ok_p))
     width = 1;
 
+#ifdef HAVE_WINDOW_SYSTEM
   /* Compute height.  */
-  if ((prop = Fplist_get (plist, QCheight), !NILP (prop))
-      && calc_pixel_width_or_height (&tem, it, prop, font, 0, 0))
+  if (FRAME_WINDOW_P (it->f))
     {
-      height = (int)tem;
-      zero_height_ok_p = 1;
+      if ((prop = Fplist_get (plist, QCheight), !NILP (prop))
+         && calc_pixel_width_or_height (&tem, it, prop, font, 0, 0))
+       {
+         height = (int)tem;
+         zero_height_ok_p = 1;
+       }
+      else if (prop = Fplist_get (plist, QCrelative_height),
+              NUMVAL (prop) > 0)
+       height = FONT_HEIGHT (font) * NUMVAL (prop);
+      else
+       height = FONT_HEIGHT (font);
+
+      if (height <= 0 && (height < 0 || !zero_height_ok_p))
+       height = 1;
+
+      /* Compute percentage of height used for ascent.  If
+        `:ascent ASCENT' is present and valid, use that.  Otherwise,
+        derive the ascent from the font in use.  */
+      if (prop = Fplist_get (plist, QCascent),
+          NUMVAL (prop) > 0 && NUMVAL (prop) <= 100)
+       ascent = height * NUMVAL (prop) / 100.0;
+      else if (!NILP (prop)
+              && calc_pixel_width_or_height (&tem, it, prop, font, 0, 0))
+       ascent = min (max (0, (int)tem), height);
+      else
+       ascent = (height * FONT_BASE (font)) / FONT_HEIGHT (font);
     }
-  else if (prop = Fplist_get (plist, QCrelative_height),
-          NUMVAL (prop) > 0)
-    height = FONT_HEIGHT (font) * NUMVAL (prop);
   else
-    height = FONT_HEIGHT (font);
-
-  if (height <= 0 && (height < 0 || !zero_height_ok_p))
+#endif /* HAVE_WINDOW_SYSTEM */
     height = 1;
 
-  /* Compute percentage of height used for ascent.  If
-     `:ascent ASCENT' is present and valid, use that.  Otherwise,
-     derive the ascent from the font in use.  */
-  if (prop = Fplist_get (plist, QCascent),
-      NUMVAL (prop) > 0 && NUMVAL (prop) <= 100)
-    ascent = height * NUMVAL (prop) / 100.0;
-  else if (!NILP (prop)
-          && calc_pixel_width_or_height (&tem, it, prop, font, 0, 0))
-    ascent = min (max (0, (int)tem), height);
-  else
-    ascent = (height * FONT_BASE (font)) / FONT_HEIGHT (font);
-
   if (width > 0 && it->line_wrap != TRUNCATE
       && it->current_x + width > it->last_visible_x)
     width = it->last_visible_x - it->current_x - 1;
 
   if (width > 0 && height > 0 && it->glyph_row)
     {
+      Lisp_Object o_object = it->object;
       Lisp_Object object = it->stack[it->sp - 1].string;
+      int n = width;
+
       if (!STRINGP (object))
        object = it->w->buffer;
-      append_stretch_glyph (it, object, width, height, ascent);
+#ifdef HAVE_WINDOW_SYSTEM
+      if (FRAME_WINDOW_P (it->f))
+       {
+         append_stretch_glyph (it, object, width, height, ascent);
+         it->ascent = it->phys_ascent = ascent;
+         it->descent = it->phys_descent = height - it->ascent;
+         it->nglyphs = width > 0 && height > 0 ? 1 : 0;
+         take_vertical_position_into_account (it);
+       }
+      else
+#endif
+       {
+         it->object = object;
+         it->char_to_display = ' ';
+         it->pixel_width = it->len = 1;
+         while (n--)
+           tty_append_glyph (it);
+         it->object = o_object;
+         it->pixel_width = width;
+       }
     }
-
-  it->pixel_width = width;
-  it->ascent = it->phys_ascent = ascent;
-  it->descent = it->phys_descent = height - it->ascent;
-  it->nglyphs = width > 0 && height > 0 ? 1 : 0;
-
-  take_vertical_position_into_account (it);
 }
 
+#ifdef HAVE_WINDOW_SYSTEM
+
 /* Calculate line-height and line-spacing properties.
    An integer value specifies explicit pixel value.
    A float value specifies relative value to current face height.


reply via email to

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