]> git.eshelyaron.com Git - emacs.git/commitdiff
(get_line_height_property): New function extracted from
authorKim F. Storm <storm@cua.dk>
Thu, 30 Dec 2004 18:01:59 +0000 (18:01 +0000)
committerKim F. Storm <storm@cua.dk>
Thu, 30 Dec 2004 18:01:59 +0000 (18:01 +0000)
original calc_line_height_property.
(calc_line_height_property): Rework.  Handle t and (nil . ratio).
(x_produce_glyphs): Use them to handle line-height and
line-spacing according to new height spec.
(Qtotal): Remove.
(syms_of_xdisp): Remove defsubr and intern for Qtotal.

src/xdisp.c

index faa0dfc21231dcbca7ba9c28edb475bf094c441e..952c7110755d4fa8204927c97a383034b1a2b3bf 100644 (file)
@@ -308,7 +308,7 @@ Lisp_Object Qleft_margin, Qright_margin, Qspace_width, Qraise;
 Lisp_Object Qslice;
 Lisp_Object Qcenter;
 Lisp_Object Qmargin, Qpointer;
-Lisp_Object Qline_height, Qtotal;
+Lisp_Object Qline_height;
 extern Lisp_Object Qheight;
 extern Lisp_Object QCwidth, QCheight, QCascent;
 extern Lisp_Object Qscroll_bar;
@@ -3290,7 +3290,7 @@ handle_display_prop (it)
 {
   Lisp_Object prop, object;
   struct text_pos *position;
-  /* Nonzero if some property replaces the display of the text itself.  */ 
+  /* Nonzero if some property replaces the display of the text itself.  */
   int display_replaced_p = 0;
 
   if (STRINGP (it->string))
@@ -3455,7 +3455,7 @@ handle_single_display_spec (it, spec, object, position,
     {
       if (FRAME_TERMCAP_P (it->f) || FRAME_MSDOS_P (it->f))
        return 0;
-      
+
       it->font_height = XCAR (XCDR (spec));
       if (!NILP (it->font_height))
        {
@@ -18791,24 +18791,16 @@ produce_stretch_glyph (it)
   take_vertical_position_into_account (it);
 }
 
-/* Calculate line-height and line-spacing properties.
-   An integer value specifies explicit pixel value.
-   A float value specifies relative value to current face height.
-   A cons (float . face-name) specifies relative value to
-   height of specified face font.
-
-   Returns height in pixels, or nil.  */
+/* Get line-height and line-spacing property at point.
+   If line-height has format (HEIGHT TOTAL), return TOTAL
+   in TOTAL_HEIGHT.  */
 
 static Lisp_Object
-calc_line_height_property (it, prop, font, boff, total)
+get_line_height_property (it, prop)
      struct it *it;
      Lisp_Object prop;
-     XFontStruct *font;
-     int boff, *total;
 {
   Lisp_Object position, val;
-  Lisp_Object face_name = Qnil;
-  int ascent, descent, height, override;
 
   if (STRINGP (it->object))
     position = make_number (IT_STRING_CHARPOS (*it));
@@ -18817,33 +18809,44 @@ calc_line_height_property (it, prop, font, boff, total)
   else
     return Qnil;
 
-  val = Fget_char_property (position, prop, it->object);
+  return Fget_char_property (position, prop, it->object);
+}
 
-  if (NILP (val))
-    return val;
+/* Calculate line-height and line-spacing properties.
+   An integer value specifies explicit pixel value.
+   A float value specifies relative value to current face height.
+   A cons (float . face-name) specifies relative value to
+   height of specified face font.
 
-  if (total && CONSP (val) && EQ (XCAR (val), Qtotal))
-    {
-      *total = 1;
-      val = XCDR (val);
-    }
+   Returns height in pixels, or nil.  */
 
-  if (INTEGERP (val))
+
+static Lisp_Object
+calc_line_height_property (it, val, font, boff, override)
+     struct it *it;
+     Lisp_Object val;
+     XFontStruct *font;
+     int boff, override;
+{
+  Lisp_Object face_name = Qnil;
+  int ascent, descent, height;
+
+  if (NILP (val) || INTEGERP (val) || (override && EQ (val, Qt)))
     return val;
 
   if (CONSP (val))
     {
-      face_name = XCDR (val);
-      val = XCAR (val);
-    }
-  else if (SYMBOLP (val))
-    {
-      face_name = val;
-      val = Qnil;
+      face_name = XCAR (val);
+      val = XCDR (val);
+      if (!NUMBERP (val))
+       val = make_number (1);
+      if (NILP (face_name))
+       {
+         height = it->ascent + it->descent;
+         goto scale;
+       }
     }
 
-  override = EQ (prop, Qline_height);
-
   if (NILP (face_name))
     {
       font = FRAME_FONT (it->f);
@@ -18885,6 +18888,8 @@ calc_line_height_property (it, prop, font, boff, total)
     }
 
   height = ascent + descent;
+
+ scale:
   if (FLOATP (val))
     height = (int)(XFLOAT_DATA (val) * height);
   else if (INTEGERP (val))
@@ -19097,12 +19102,20 @@ x_produce_glyphs (it)
             increase that height */
 
          Lisp_Object height;
+         Lisp_Object total_height = Qnil;
 
          it->override_ascent = -1;
          it->pixel_width = 0;
          it->nglyphs = 0;
 
-         height = calc_line_height_property(it, Qline_height, font, boff, 0);
+         height = get_line_height_property(it, Qline_height);
+         /* Split (line-height total-height) list */
+         if (CONSP (height) && CONSP (XCDR (height)))
+           {
+             total_height = XCAR (XCDR (height));
+             height = XCAR (height);
+           }
+         height = calc_line_height_property(it, height, font, boff, 1);
 
          if (it->override_ascent >= 0)
            {
@@ -19116,7 +19129,7 @@ x_produce_glyphs (it)
              it->descent = FONT_DESCENT (font) - boff;
            }
 
-         if (EQ (height, make_number(0)))
+         if (EQ (height, Qt))
            {
              if (it->descent > it->max_descent)
                {
@@ -19152,11 +19165,17 @@ x_produce_glyphs (it)
                  && XINT (height) > it->ascent + it->descent)
                it->ascent = XINT (height) - it->descent;
 
-             spacing = calc_line_height_property(it, Qline_spacing, font, boff, &total);
+             if (!NILP (total_height))
+               spacing = calc_line_height_property(it, total_height, font, boff, 0);
+             else
+               {
+                 spacing = get_line_height_property(it, Qline_spacing);
+                 spacing = calc_line_height_property(it, spacing, font, boff, 0);
+               }
              if (INTEGERP (spacing))
                {
                  extra_line_spacing = XINT (spacing);
-                 if (total)
+                 if (!NILP (total_height))
                    extra_line_spacing -= (it->phys_ascent + it->phys_descent);
                }
            }
@@ -22174,8 +22193,6 @@ syms_of_xdisp ()
   staticpro (&Qcenter);
   Qline_height = intern ("line-height");
   staticpro (&Qline_height);
-  Qtotal = intern ("total");
-  staticpro (&Qtotal);
   QCalign_to = intern (":align-to");
   staticpro (&QCalign_to);
   QCrelative_width = intern (":relative-width");