Mercurial > emacs
changeset 59214:39392e702267
(get_line_height_property): New function extracted from
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.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Thu, 30 Dec 2004 18:01:59 +0000 |
parents | 2c1e7ea9063e |
children | 97d4823c4f08 |
files | src/xdisp.c |
diffstat | 1 files changed, 60 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/src/xdisp.c Thu Dec 30 18:01:43 2004 +0000 +++ b/src/xdisp.c Thu Dec 30 18:01:59 2004 +0000 @@ -308,7 +308,7 @@ 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 @@ { 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 @@ { 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 @@ 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,32 +18809,43 @@ else return Qnil; - val = Fget_char_property (position, prop, it->object); - - if (NILP (val)) - return val; - - if (total && CONSP (val) && EQ (XCAR (val), Qtotal)) - { - *total = 1; - val = XCDR (val); - } - - if (INTEGERP (val)) + return Fget_char_property (position, prop, it->object); +} + +/* 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. */ + + +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; - } - - override = EQ (prop, Qline_height); + 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; + } + } if (NILP (face_name)) { @@ -18885,6 +18888,8 @@ } height = ascent + descent; + + scale: if (FLOATP (val)) height = (int)(XFLOAT_DATA (val) * height); else if (INTEGERP (val)) @@ -19097,12 +19102,20 @@ 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 @@ 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 @@ && 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 @@ 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");