diff options
| author | Kim F. Storm | 2004-12-30 18:01:59 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2004-12-30 18:01:59 +0000 |
| commit | 99c71e5140cba1db3ee3712f24ff4cc9e9bf6e11 (patch) | |
| tree | c1eeaf5de9da39381032f0ef48499df6b58c630d /src | |
| parent | 1225f637fbc401bc87d78338f3565d95f6cdd582 (diff) | |
| download | emacs-99c71e5140cba1db3ee3712f24ff4cc9e9bf6e11.tar.gz emacs-99c71e5140cba1db3ee3712f24ff4cc9e9bf6e11.zip | |
(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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 95 |
1 files changed, 56 insertions, 39 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index faa0dfc2123..952c7110755 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -308,7 +308,7 @@ Lisp_Object Qleft_margin, Qright_margin, Qspace_width, Qraise; | |||
| 308 | Lisp_Object Qslice; | 308 | Lisp_Object Qslice; |
| 309 | Lisp_Object Qcenter; | 309 | Lisp_Object Qcenter; |
| 310 | Lisp_Object Qmargin, Qpointer; | 310 | Lisp_Object Qmargin, Qpointer; |
| 311 | Lisp_Object Qline_height, Qtotal; | 311 | Lisp_Object Qline_height; |
| 312 | extern Lisp_Object Qheight; | 312 | extern Lisp_Object Qheight; |
| 313 | extern Lisp_Object QCwidth, QCheight, QCascent; | 313 | extern Lisp_Object QCwidth, QCheight, QCascent; |
| 314 | extern Lisp_Object Qscroll_bar; | 314 | extern Lisp_Object Qscroll_bar; |
| @@ -3290,7 +3290,7 @@ handle_display_prop (it) | |||
| 3290 | { | 3290 | { |
| 3291 | Lisp_Object prop, object; | 3291 | Lisp_Object prop, object; |
| 3292 | struct text_pos *position; | 3292 | struct text_pos *position; |
| 3293 | /* Nonzero if some property replaces the display of the text itself. */ | 3293 | /* Nonzero if some property replaces the display of the text itself. */ |
| 3294 | int display_replaced_p = 0; | 3294 | int display_replaced_p = 0; |
| 3295 | 3295 | ||
| 3296 | if (STRINGP (it->string)) | 3296 | if (STRINGP (it->string)) |
| @@ -3455,7 +3455,7 @@ handle_single_display_spec (it, spec, object, position, | |||
| 3455 | { | 3455 | { |
| 3456 | if (FRAME_TERMCAP_P (it->f) || FRAME_MSDOS_P (it->f)) | 3456 | if (FRAME_TERMCAP_P (it->f) || FRAME_MSDOS_P (it->f)) |
| 3457 | return 0; | 3457 | return 0; |
| 3458 | 3458 | ||
| 3459 | it->font_height = XCAR (XCDR (spec)); | 3459 | it->font_height = XCAR (XCDR (spec)); |
| 3460 | if (!NILP (it->font_height)) | 3460 | if (!NILP (it->font_height)) |
| 3461 | { | 3461 | { |
| @@ -18791,24 +18791,16 @@ produce_stretch_glyph (it) | |||
| 18791 | take_vertical_position_into_account (it); | 18791 | take_vertical_position_into_account (it); |
| 18792 | } | 18792 | } |
| 18793 | 18793 | ||
| 18794 | /* Calculate line-height and line-spacing properties. | 18794 | /* Get line-height and line-spacing property at point. |
| 18795 | An integer value specifies explicit pixel value. | 18795 | If line-height has format (HEIGHT TOTAL), return TOTAL |
| 18796 | A float value specifies relative value to current face height. | 18796 | in TOTAL_HEIGHT. */ |
| 18797 | A cons (float . face-name) specifies relative value to | ||
| 18798 | height of specified face font. | ||
| 18799 | |||
| 18800 | Returns height in pixels, or nil. */ | ||
| 18801 | 18797 | ||
| 18802 | static Lisp_Object | 18798 | static Lisp_Object |
| 18803 | calc_line_height_property (it, prop, font, boff, total) | 18799 | get_line_height_property (it, prop) |
| 18804 | struct it *it; | 18800 | struct it *it; |
| 18805 | Lisp_Object prop; | 18801 | Lisp_Object prop; |
| 18806 | XFontStruct *font; | ||
| 18807 | int boff, *total; | ||
| 18808 | { | 18802 | { |
| 18809 | Lisp_Object position, val; | 18803 | Lisp_Object position, val; |
| 18810 | Lisp_Object face_name = Qnil; | ||
| 18811 | int ascent, descent, height, override; | ||
| 18812 | 18804 | ||
| 18813 | if (STRINGP (it->object)) | 18805 | if (STRINGP (it->object)) |
| 18814 | position = make_number (IT_STRING_CHARPOS (*it)); | 18806 | position = make_number (IT_STRING_CHARPOS (*it)); |
| @@ -18817,33 +18809,44 @@ calc_line_height_property (it, prop, font, boff, total) | |||
| 18817 | else | 18809 | else |
| 18818 | return Qnil; | 18810 | return Qnil; |
| 18819 | 18811 | ||
| 18820 | val = Fget_char_property (position, prop, it->object); | 18812 | return Fget_char_property (position, prop, it->object); |
| 18813 | } | ||
| 18821 | 18814 | ||
| 18822 | if (NILP (val)) | 18815 | /* Calculate line-height and line-spacing properties. |
| 18823 | return val; | 18816 | An integer value specifies explicit pixel value. |
| 18817 | A float value specifies relative value to current face height. | ||
| 18818 | A cons (float . face-name) specifies relative value to | ||
| 18819 | height of specified face font. | ||
| 18824 | 18820 | ||
| 18825 | if (total && CONSP (val) && EQ (XCAR (val), Qtotal)) | 18821 | Returns height in pixels, or nil. */ |
| 18826 | { | ||
| 18827 | *total = 1; | ||
| 18828 | val = XCDR (val); | ||
| 18829 | } | ||
| 18830 | 18822 | ||
| 18831 | if (INTEGERP (val)) | 18823 | |
| 18824 | static Lisp_Object | ||
| 18825 | calc_line_height_property (it, val, font, boff, override) | ||
| 18826 | struct it *it; | ||
| 18827 | Lisp_Object val; | ||
| 18828 | XFontStruct *font; | ||
| 18829 | int boff, override; | ||
| 18830 | { | ||
| 18831 | Lisp_Object face_name = Qnil; | ||
| 18832 | int ascent, descent, height; | ||
| 18833 | |||
| 18834 | if (NILP (val) || INTEGERP (val) || (override && EQ (val, Qt))) | ||
| 18832 | return val; | 18835 | return val; |
| 18833 | 18836 | ||
| 18834 | if (CONSP (val)) | 18837 | if (CONSP (val)) |
| 18835 | { | 18838 | { |
| 18836 | face_name = XCDR (val); | 18839 | face_name = XCAR (val); |
| 18837 | val = XCAR (val); | 18840 | val = XCDR (val); |
| 18838 | } | 18841 | if (!NUMBERP (val)) |
| 18839 | else if (SYMBOLP (val)) | 18842 | val = make_number (1); |
| 18840 | { | 18843 | if (NILP (face_name)) |
| 18841 | face_name = val; | 18844 | { |
| 18842 | val = Qnil; | 18845 | height = it->ascent + it->descent; |
| 18846 | goto scale; | ||
| 18847 | } | ||
| 18843 | } | 18848 | } |
| 18844 | 18849 | ||
| 18845 | override = EQ (prop, Qline_height); | ||
| 18846 | |||
| 18847 | if (NILP (face_name)) | 18850 | if (NILP (face_name)) |
| 18848 | { | 18851 | { |
| 18849 | font = FRAME_FONT (it->f); | 18852 | font = FRAME_FONT (it->f); |
| @@ -18885,6 +18888,8 @@ calc_line_height_property (it, prop, font, boff, total) | |||
| 18885 | } | 18888 | } |
| 18886 | 18889 | ||
| 18887 | height = ascent + descent; | 18890 | height = ascent + descent; |
| 18891 | |||
| 18892 | scale: | ||
| 18888 | if (FLOATP (val)) | 18893 | if (FLOATP (val)) |
| 18889 | height = (int)(XFLOAT_DATA (val) * height); | 18894 | height = (int)(XFLOAT_DATA (val) * height); |
| 18890 | else if (INTEGERP (val)) | 18895 | else if (INTEGERP (val)) |
| @@ -19097,12 +19102,20 @@ x_produce_glyphs (it) | |||
| 19097 | increase that height */ | 19102 | increase that height */ |
| 19098 | 19103 | ||
| 19099 | Lisp_Object height; | 19104 | Lisp_Object height; |
| 19105 | Lisp_Object total_height = Qnil; | ||
| 19100 | 19106 | ||
| 19101 | it->override_ascent = -1; | 19107 | it->override_ascent = -1; |
| 19102 | it->pixel_width = 0; | 19108 | it->pixel_width = 0; |
| 19103 | it->nglyphs = 0; | 19109 | it->nglyphs = 0; |
| 19104 | 19110 | ||
| 19105 | height = calc_line_height_property(it, Qline_height, font, boff, 0); | 19111 | height = get_line_height_property(it, Qline_height); |
| 19112 | /* Split (line-height total-height) list */ | ||
| 19113 | if (CONSP (height) && CONSP (XCDR (height))) | ||
| 19114 | { | ||
| 19115 | total_height = XCAR (XCDR (height)); | ||
| 19116 | height = XCAR (height); | ||
| 19117 | } | ||
| 19118 | height = calc_line_height_property(it, height, font, boff, 1); | ||
| 19106 | 19119 | ||
| 19107 | if (it->override_ascent >= 0) | 19120 | if (it->override_ascent >= 0) |
| 19108 | { | 19121 | { |
| @@ -19116,7 +19129,7 @@ x_produce_glyphs (it) | |||
| 19116 | it->descent = FONT_DESCENT (font) - boff; | 19129 | it->descent = FONT_DESCENT (font) - boff; |
| 19117 | } | 19130 | } |
| 19118 | 19131 | ||
| 19119 | if (EQ (height, make_number(0))) | 19132 | if (EQ (height, Qt)) |
| 19120 | { | 19133 | { |
| 19121 | if (it->descent > it->max_descent) | 19134 | if (it->descent > it->max_descent) |
| 19122 | { | 19135 | { |
| @@ -19152,11 +19165,17 @@ x_produce_glyphs (it) | |||
| 19152 | && XINT (height) > it->ascent + it->descent) | 19165 | && XINT (height) > it->ascent + it->descent) |
| 19153 | it->ascent = XINT (height) - it->descent; | 19166 | it->ascent = XINT (height) - it->descent; |
| 19154 | 19167 | ||
| 19155 | spacing = calc_line_height_property(it, Qline_spacing, font, boff, &total); | 19168 | if (!NILP (total_height)) |
| 19169 | spacing = calc_line_height_property(it, total_height, font, boff, 0); | ||
| 19170 | else | ||
| 19171 | { | ||
| 19172 | spacing = get_line_height_property(it, Qline_spacing); | ||
| 19173 | spacing = calc_line_height_property(it, spacing, font, boff, 0); | ||
| 19174 | } | ||
| 19156 | if (INTEGERP (spacing)) | 19175 | if (INTEGERP (spacing)) |
| 19157 | { | 19176 | { |
| 19158 | extra_line_spacing = XINT (spacing); | 19177 | extra_line_spacing = XINT (spacing); |
| 19159 | if (total) | 19178 | if (!NILP (total_height)) |
| 19160 | extra_line_spacing -= (it->phys_ascent + it->phys_descent); | 19179 | extra_line_spacing -= (it->phys_ascent + it->phys_descent); |
| 19161 | } | 19180 | } |
| 19162 | } | 19181 | } |
| @@ -22174,8 +22193,6 @@ syms_of_xdisp () | |||
| 22174 | staticpro (&Qcenter); | 22193 | staticpro (&Qcenter); |
| 22175 | Qline_height = intern ("line-height"); | 22194 | Qline_height = intern ("line-height"); |
| 22176 | staticpro (&Qline_height); | 22195 | staticpro (&Qline_height); |
| 22177 | Qtotal = intern ("total"); | ||
| 22178 | staticpro (&Qtotal); | ||
| 22179 | QCalign_to = intern (":align-to"); | 22196 | QCalign_to = intern (":align-to"); |
| 22180 | staticpro (&QCalign_to); | 22197 | staticpro (&QCalign_to); |
| 22181 | QCrelative_width = intern (":relative-width"); | 22198 | QCrelative_width = intern (":relative-width"); |