diff options
| author | Kim F. Storm | 2004-03-19 00:43:16 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2004-03-19 00:43:16 +0000 |
| commit | da06e4d71b0b5f9522126f180bd4888771995608 (patch) | |
| tree | 4adc466f47718637b8bd356b5ccc957d045791ee /src | |
| parent | f46c2affad936c9b31862956f2328e4dd0eb2d1c (diff) | |
| download | emacs-da06e4d71b0b5f9522126f180bd4888771995608.tar.gz emacs-da06e4d71b0b5f9522126f180bd4888771995608.zip | |
(Qcenter): Declare here.
(syms_of_xdisp): intern and staticpro it.
(handle_single_display_prop): Allow space display property on all
platforms.
(display_mode_line): Set mode_line_p before displaying line.
(calc_pixel_width_or_height): Declare extern. Add separate :align-to
handling. Remove complex cases for fringes and scroll-bars.
Add left, right, and center alignment positions. Add text (area)
width/height. Return width or height for image specs.
(produce_stretch_glyph): Improve handling of :align-to. Is now
relative to left of text area by default, but other base offsets
can be specified -- also for text lines.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 485 |
1 files changed, 266 insertions, 219 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 11327e13102..1ba274d1312 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -301,6 +301,7 @@ extern Lisp_Object Qface, Qinvisible, Qwidth; | |||
| 301 | Lisp_Object Vdisplay_pixels_per_inch; | 301 | Lisp_Object Vdisplay_pixels_per_inch; |
| 302 | Lisp_Object Qspace, QCalign_to, QCrelative_width, QCrelative_height; | 302 | Lisp_Object Qspace, QCalign_to, QCrelative_width, QCrelative_height; |
| 303 | Lisp_Object Qleft_margin, Qright_margin, Qspace_width, Qraise; | 303 | Lisp_Object Qleft_margin, Qright_margin, Qspace_width, Qraise; |
| 304 | Lisp_Object Qcenter; | ||
| 304 | Lisp_Object Qmargin, Qpointer; | 305 | Lisp_Object Qmargin, Qpointer; |
| 305 | extern Lisp_Object Qheight; | 306 | extern Lisp_Object Qheight; |
| 306 | extern Lisp_Object QCwidth, QCheight, QCascent; | 307 | extern Lisp_Object QCwidth, QCheight, QCascent; |
| @@ -3607,16 +3608,11 @@ handle_single_display_prop (it, prop, object, position, | |||
| 3607 | value = prop; | 3608 | value = prop; |
| 3608 | } | 3609 | } |
| 3609 | 3610 | ||
| 3611 | valid_p = (STRINGP (value) | ||
| 3610 | #ifdef HAVE_WINDOW_SYSTEM | 3612 | #ifdef HAVE_WINDOW_SYSTEM |
| 3611 | if (FRAME_TERMCAP_P (it->f)) | 3613 | || (!FRAME_TERMCAP_P (it->f) && valid_image_p (value)) |
| 3612 | valid_p = STRINGP (value); | ||
| 3613 | else | ||
| 3614 | valid_p = (STRINGP (value) | ||
| 3615 | || (CONSP (value) && EQ (XCAR (value), Qspace)) | ||
| 3616 | || valid_image_p (value)); | ||
| 3617 | #else /* not HAVE_WINDOW_SYSTEM */ | ||
| 3618 | valid_p = STRINGP (value); | ||
| 3619 | #endif /* not HAVE_WINDOW_SYSTEM */ | 3614 | #endif /* not HAVE_WINDOW_SYSTEM */ |
| 3615 | || (CONSP (value) && EQ (XCAR (value), Qspace))); | ||
| 3620 | 3616 | ||
| 3621 | if ((EQ (location, Qleft_margin) | 3617 | if ((EQ (location, Qleft_margin) |
| 3622 | || EQ (location, Qright_margin) | 3618 | || EQ (location, Qright_margin) |
| @@ -15065,6 +15061,8 @@ display_mode_line (w, face_id, format) | |||
| 15065 | init_iterator (&it, w, -1, -1, NULL, face_id); | 15061 | init_iterator (&it, w, -1, -1, NULL, face_id); |
| 15066 | prepare_desired_row (it.glyph_row); | 15062 | prepare_desired_row (it.glyph_row); |
| 15067 | 15063 | ||
| 15064 | it.glyph_row->mode_line_p = 1; | ||
| 15065 | |||
| 15068 | if (! mode_line_inverse_video) | 15066 | if (! mode_line_inverse_video) |
| 15069 | /* Force the mode-line to be displayed in the default face. */ | 15067 | /* Force the mode-line to be displayed in the default face. */ |
| 15070 | it.base_face_id = it.face_id = DEFAULT_FACE_ID; | 15068 | it.base_face_id = it.face_id = DEFAULT_FACE_ID; |
| @@ -15081,7 +15079,6 @@ display_mode_line (w, face_id, format) | |||
| 15081 | 15079 | ||
| 15082 | compute_line_metrics (&it); | 15080 | compute_line_metrics (&it); |
| 15083 | it.glyph_row->full_width_p = 1; | 15081 | it.glyph_row->full_width_p = 1; |
| 15084 | it.glyph_row->mode_line_p = 1; | ||
| 15085 | it.glyph_row->continued_p = 0; | 15082 | it.glyph_row->continued_p = 0; |
| 15086 | it.glyph_row->truncated_on_left_p = 0; | 15083 | it.glyph_row->truncated_on_left_p = 0; |
| 15087 | it.glyph_row->truncated_on_right_p = 0; | 15084 | it.glyph_row->truncated_on_right_p = 0; |
| @@ -16695,6 +16692,251 @@ invisible_p (propval, list) | |||
| 16695 | return 0; | 16692 | return 0; |
| 16696 | } | 16693 | } |
| 16697 | 16694 | ||
| 16695 | /* Calculate a width or height in pixels from a specification using | ||
| 16696 | the following elements: | ||
| 16697 | |||
| 16698 | SPEC ::= | ||
| 16699 | NUM - a (fractional) multiple of the default font width/height | ||
| 16700 | (NUM) - specifies exactly NUM pixels | ||
| 16701 | UNIT - a fixed number of pixels, see below. | ||
| 16702 | ELEMENT - size of a display element in pixels, see below. | ||
| 16703 | (NUM . SPEC) - equals NUM * SPEC | ||
| 16704 | (+ SPEC SPEC ...) - add pixel values | ||
| 16705 | (- SPEC SPEC ...) - subtract pixel values | ||
| 16706 | (- SPEC) - negate pixel value | ||
| 16707 | |||
| 16708 | NUM ::= | ||
| 16709 | INT or FLOAT - a number constant | ||
| 16710 | SYMBOL - use symbol's (buffer local) variable binding. | ||
| 16711 | |||
| 16712 | UNIT ::= | ||
| 16713 | in - pixels per inch *) | ||
| 16714 | mm - pixels per 1/1000 meter *) | ||
| 16715 | cm - pixels per 1/100 meter *) | ||
| 16716 | width - width of current font in pixels. | ||
| 16717 | height - height of current font in pixels. | ||
| 16718 | |||
| 16719 | *) using the ratio(s) defined in display-pixels-per-inch. | ||
| 16720 | |||
| 16721 | ELEMENT ::= | ||
| 16722 | |||
| 16723 | left-fringe - left fringe width in pixels | ||
| 16724 | right-fringe - right fringe width in pixels | ||
| 16725 | |||
| 16726 | left-margin - left margin width in pixels | ||
| 16727 | right-margin - right margin width in pixels | ||
| 16728 | |||
| 16729 | scroll-bar - scroll-bar area width in pixels | ||
| 16730 | |||
| 16731 | Examples: | ||
| 16732 | |||
| 16733 | Pixels corresponding to 5 inches: | ||
| 16734 | (5 . in) | ||
| 16735 | |||
| 16736 | Total width of non-text areas on left side of window (if scroll-bar is on left): | ||
| 16737 | '(space :width (+ left-fringe left-margin scroll-bar)) | ||
| 16738 | |||
| 16739 | Align to first text column (in header line): | ||
| 16740 | '(space :align-to 0) | ||
| 16741 | |||
| 16742 | Align to middle of text area minus half the width of variable `my-image' | ||
| 16743 | containing a loaded image: | ||
| 16744 | '(space :align-to (0.5 . (- text my-image))) | ||
| 16745 | |||
| 16746 | Width of left margin minus width of 1 character in the default font: | ||
| 16747 | '(space :width (- left-margin 1)) | ||
| 16748 | |||
| 16749 | Width of left margin minus width of 2 characters in the current font: | ||
| 16750 | '(space :width (- left-margin (2 . width))) | ||
| 16751 | |||
| 16752 | Center 1 character over left-margin (in header line): | ||
| 16753 | '(space :align-to (+ left-margin (0.5 . left-margin) -0.5)) | ||
| 16754 | |||
| 16755 | Different ways to express width of left fringe plus left margin minus one pixel: | ||
| 16756 | '(space :width (- (+ left-fringe left-margin) (1))) | ||
| 16757 | '(space :width (+ left-fringe left-margin (- (1)))) | ||
| 16758 | '(space :width (+ left-fringe left-margin (-1))) | ||
| 16759 | |||
| 16760 | */ | ||
| 16761 | |||
| 16762 | #define NUMVAL(X) \ | ||
| 16763 | ((INTEGERP (X) || FLOATP (X)) \ | ||
| 16764 | ? XFLOATINT (X) \ | ||
| 16765 | : - 1) | ||
| 16766 | |||
| 16767 | int | ||
| 16768 | calc_pixel_width_or_height (res, it, prop, font, width_p, align_to) | ||
| 16769 | double *res; | ||
| 16770 | struct it *it; | ||
| 16771 | Lisp_Object prop; | ||
| 16772 | void *font; | ||
| 16773 | int width_p, *align_to; | ||
| 16774 | { | ||
| 16775 | double pixels; | ||
| 16776 | |||
| 16777 | #define OK_PIXELS(val) ((*res = (double)(val)), 1) | ||
| 16778 | #define OK_ALIGN_TO(val) ((*align_to = (int)(val)), 1) | ||
| 16779 | |||
| 16780 | if (NILP (prop)) | ||
| 16781 | return OK_PIXELS (0); | ||
| 16782 | |||
| 16783 | if (SYMBOLP (prop)) | ||
| 16784 | { | ||
| 16785 | if (SCHARS (SYMBOL_NAME (prop)) == 2) | ||
| 16786 | { | ||
| 16787 | char *unit = SDATA (SYMBOL_NAME (prop)); | ||
| 16788 | |||
| 16789 | if (unit[0] == 'i' && unit[1] == 'n') | ||
| 16790 | pixels = 1.0; | ||
| 16791 | else if (unit[0] == 'm' && unit[1] == 'm') | ||
| 16792 | pixels = 25.4; | ||
| 16793 | else if (unit[0] == 'c' && unit[1] == 'm') | ||
| 16794 | pixels = 2.54; | ||
| 16795 | else | ||
| 16796 | pixels = 0; | ||
| 16797 | if (pixels > 0) | ||
| 16798 | { | ||
| 16799 | double ppi; | ||
| 16800 | if ((ppi = NUMVAL (Vdisplay_pixels_per_inch), ppi > 0) | ||
| 16801 | || (CONSP (Vdisplay_pixels_per_inch) | ||
| 16802 | && (ppi = (width_p | ||
| 16803 | ? NUMVAL (XCAR (Vdisplay_pixels_per_inch)) | ||
| 16804 | : NUMVAL (XCDR (Vdisplay_pixels_per_inch))), | ||
| 16805 | ppi > 0))) | ||
| 16806 | return OK_PIXELS (ppi / pixels); | ||
| 16807 | |||
| 16808 | return 0; | ||
| 16809 | } | ||
| 16810 | } | ||
| 16811 | |||
| 16812 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 16813 | if (EQ (prop, Qheight)) | ||
| 16814 | return OK_PIXELS (font ? FONT_HEIGHT ((XFontStruct *)font) : FRAME_LINE_HEIGHT (it->f)); | ||
| 16815 | if (EQ (prop, Qwidth)) | ||
| 16816 | return OK_PIXELS (font ? FONT_WIDTH ((XFontStruct *)font) : FRAME_COLUMN_WIDTH (it->f)); | ||
| 16817 | #else | ||
| 16818 | if (EQ (prop, Qheight) || EQ (prop, Qwidth)) | ||
| 16819 | return OK_PIXELS (1); | ||
| 16820 | #endif | ||
| 16821 | |||
| 16822 | if (EQ (prop, Qtext)) | ||
| 16823 | return OK_PIXELS (width_p | ||
| 16824 | ? window_box_width (it->w, TEXT_AREA) | ||
| 16825 | : WINDOW_BOX_HEIGHT_NO_MODE_LINE (it->w)); | ||
| 16826 | |||
| 16827 | if (align_to && *align_to < 0) | ||
| 16828 | { | ||
| 16829 | *res = 0; | ||
| 16830 | if (EQ (prop, Qleft)) | ||
| 16831 | return OK_ALIGN_TO (window_box_left_offset (it->w, TEXT_AREA)); | ||
| 16832 | if (EQ (prop, Qright)) | ||
| 16833 | return OK_ALIGN_TO (window_box_right_offset (it->w, TEXT_AREA)); | ||
| 16834 | if (EQ (prop, Qcenter)) | ||
| 16835 | return OK_ALIGN_TO (window_box_left_offset (it->w, TEXT_AREA) | ||
| 16836 | + window_box_width (it->w, TEXT_AREA) / 2); | ||
| 16837 | if (EQ (prop, Qleft_fringe)) | ||
| 16838 | return OK_ALIGN_TO (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (it->w) | ||
| 16839 | ? WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (it->w) | ||
| 16840 | : window_box_right_offset (it->w, LEFT_MARGIN_AREA)); | ||
| 16841 | if (EQ (prop, Qright_fringe)) | ||
| 16842 | return OK_ALIGN_TO (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (it->w) | ||
| 16843 | ? window_box_right_offset (it->w, RIGHT_MARGIN_AREA) | ||
| 16844 | : window_box_right_offset (it->w, TEXT_AREA)); | ||
| 16845 | if (EQ (prop, Qleft_margin)) | ||
| 16846 | return OK_ALIGN_TO (window_box_left_offset (it->w, LEFT_MARGIN_AREA)); | ||
| 16847 | if (EQ (prop, Qright_margin)) | ||
| 16848 | return OK_ALIGN_TO (window_box_left_offset (it->w, RIGHT_MARGIN_AREA)); | ||
| 16849 | if (EQ (prop, Qscroll_bar)) | ||
| 16850 | return OK_ALIGN_TO (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (it->w) | ||
| 16851 | ? 0 | ||
| 16852 | : (window_box_right_offset (it->w, RIGHT_MARGIN_AREA) | ||
| 16853 | + (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (it->w) | ||
| 16854 | ? WINDOW_RIGHT_FRINGE_WIDTH (it->w) | ||
| 16855 | : 0))); | ||
| 16856 | } | ||
| 16857 | else | ||
| 16858 | { | ||
| 16859 | if (EQ (prop, Qleft_fringe)) | ||
| 16860 | return OK_PIXELS (WINDOW_LEFT_FRINGE_WIDTH (it->w)); | ||
| 16861 | if (EQ (prop, Qright_fringe)) | ||
| 16862 | return OK_PIXELS (WINDOW_RIGHT_FRINGE_WIDTH (it->w)); | ||
| 16863 | if (EQ (prop, Qleft_margin)) | ||
| 16864 | return OK_PIXELS (WINDOW_LEFT_MARGIN_WIDTH (it->w)); | ||
| 16865 | if (EQ (prop, Qright_margin)) | ||
| 16866 | return OK_PIXELS (WINDOW_RIGHT_MARGIN_WIDTH (it->w)); | ||
| 16867 | if (EQ (prop, Qscroll_bar)) | ||
| 16868 | return OK_PIXELS (WINDOW_SCROLL_BAR_AREA_WIDTH (it->w)); | ||
| 16869 | } | ||
| 16870 | |||
| 16871 | prop = Fbuffer_local_value (prop, it->w->buffer); | ||
| 16872 | } | ||
| 16873 | |||
| 16874 | if (INTEGERP (prop) || FLOATP (prop)) | ||
| 16875 | { | ||
| 16876 | int base_unit = (width_p | ||
| 16877 | ? FRAME_COLUMN_WIDTH (it->f) | ||
| 16878 | : FRAME_LINE_HEIGHT (it->f)); | ||
| 16879 | return OK_PIXELS (XFLOATINT (prop) * base_unit); | ||
| 16880 | } | ||
| 16881 | |||
| 16882 | if (CONSP (prop)) | ||
| 16883 | { | ||
| 16884 | Lisp_Object car = XCAR (prop); | ||
| 16885 | Lisp_Object cdr = XCDR (prop); | ||
| 16886 | |||
| 16887 | if (SYMBOLP (car)) | ||
| 16888 | { | ||
| 16889 | if (valid_image_p (prop)) | ||
| 16890 | { | ||
| 16891 | int id = lookup_image (it->f, prop); | ||
| 16892 | struct image *img = IMAGE_FROM_ID (it->f, id); | ||
| 16893 | |||
| 16894 | return OK_PIXELS (width_p ? img->width : img->height); | ||
| 16895 | } | ||
| 16896 | |||
| 16897 | if (EQ (car, Qplus) || EQ (car, Qminus)) | ||
| 16898 | { | ||
| 16899 | int first = 1; | ||
| 16900 | double px; | ||
| 16901 | |||
| 16902 | pixels = 0; | ||
| 16903 | while (CONSP (cdr)) | ||
| 16904 | { | ||
| 16905 | if (!calc_pixel_width_or_height (&px, it, XCAR (cdr), | ||
| 16906 | font, width_p, align_to)) | ||
| 16907 | return 0; | ||
| 16908 | if (first) | ||
| 16909 | pixels = (EQ (car, Qplus) ? px : -px), first = 0; | ||
| 16910 | else | ||
| 16911 | pixels += px; | ||
| 16912 | cdr = XCDR (cdr); | ||
| 16913 | } | ||
| 16914 | if (EQ (car, Qminus)) | ||
| 16915 | pixels = -pixels; | ||
| 16916 | return OK_PIXELS (pixels); | ||
| 16917 | } | ||
| 16918 | |||
| 16919 | car = Fbuffer_local_value (car, it->w->buffer); | ||
| 16920 | } | ||
| 16921 | |||
| 16922 | if (INTEGERP (car) || FLOATP (car)) | ||
| 16923 | { | ||
| 16924 | double fact; | ||
| 16925 | pixels = XFLOATINT (car); | ||
| 16926 | if (NILP (cdr)) | ||
| 16927 | return OK_PIXELS (pixels); | ||
| 16928 | if (calc_pixel_width_or_height (&fact, it, cdr, | ||
| 16929 | font, width_p, align_to)) | ||
| 16930 | return OK_PIXELS (pixels * fact); | ||
| 16931 | return 0; | ||
| 16932 | } | ||
| 16933 | |||
| 16934 | return 0; | ||
| 16935 | } | ||
| 16936 | |||
| 16937 | return 0; | ||
| 16938 | } | ||
| 16939 | |||
| 16698 | 16940 | ||
| 16699 | /*********************************************************************** | 16941 | /*********************************************************************** |
| 16700 | Glyph Display | 16942 | Glyph Display |
| @@ -17978,209 +18220,6 @@ append_stretch_glyph (it, object, width, height, ascent) | |||
| 17978 | } | 18220 | } |
| 17979 | 18221 | ||
| 17980 | 18222 | ||
| 17981 | /* Calculate a width or height in pixels from a specification using | ||
| 17982 | the following elements: | ||
| 17983 | |||
| 17984 | SPEC ::= | ||
| 17985 | NUM - a (fractional) multiple of the default font width/height | ||
| 17986 | (NUM) - specifies exactly NUM pixels | ||
| 17987 | UNIT - a fixed number of pixels, see below. | ||
| 17988 | ELEMENT - size of a display element in pixels, see below. | ||
| 17989 | (NUM . SPEC) - equals NUM * SPEC | ||
| 17990 | (+ SPEC SPEC ...) - add pixel values | ||
| 17991 | (- SPEC SPEC ...) - subtract pixel values | ||
| 17992 | (- SPEC) - negate pixel value | ||
| 17993 | |||
| 17994 | NUM ::= | ||
| 17995 | INT or FLOAT - a number constant | ||
| 17996 | SYMBOL - use symbol's (buffer local) variable binding. | ||
| 17997 | |||
| 17998 | UNIT ::= | ||
| 17999 | in - pixels per inch *) | ||
| 18000 | mm - pixels per 1/1000 meter *) | ||
| 18001 | cm - pixels per 1/100 meter *) | ||
| 18002 | width - width of current font in pixels. | ||
| 18003 | height - height of current font in pixels. | ||
| 18004 | |||
| 18005 | *) using the ratio(s) defined in display-pixels-per-inch. | ||
| 18006 | |||
| 18007 | ELEMENT ::= | ||
| 18008 | |||
| 18009 | left-fringe - left fringe width in pixels | ||
| 18010 | (left-fringe . nil) - left fringe width if inside margins, else 0 | ||
| 18011 | (left-fringe . t) - left fringe width if outside margins, else 0 | ||
| 18012 | |||
| 18013 | right-fringe - right fringe width in pixels | ||
| 18014 | (right-fringe . nil) - right fringe width if inside margins, else 0 | ||
| 18015 | (right-fringe . t) - right fringe width if outside margins, else 0 | ||
| 18016 | |||
| 18017 | left-margin - left margin width in pixels | ||
| 18018 | right-margin - right margin width in pixels | ||
| 18019 | |||
| 18020 | scroll-bar - scroll-bar area width in pixels | ||
| 18021 | (scroll-bar . left) - scroll-bar width if on left, else 0 | ||
| 18022 | (scroll-bar . right) - scroll-bar width if on right, else 0 | ||
| 18023 | |||
| 18024 | Examples: | ||
| 18025 | |||
| 18026 | Pixels corresponding to 5 inches: | ||
| 18027 | (5 . in) | ||
| 18028 | |||
| 18029 | Total width of non-text areas on left side of window: | ||
| 18030 | (+ left-fringe left-margin (scroll-bar . left)) | ||
| 18031 | |||
| 18032 | Total width of fringes if inside display margins: | ||
| 18033 | (+ (left-fringe) (right-fringe)) | ||
| 18034 | |||
| 18035 | Width of left margin minus width of 1 character in the default font: | ||
| 18036 | (- left-margin 1) | ||
| 18037 | |||
| 18038 | Width of left margin minus width of 2 characters in the current font: | ||
| 18039 | (- left-margin (2 . width)) | ||
| 18040 | |||
| 18041 | Width of left fringe plus left margin minus one pixel: | ||
| 18042 | (- (+ left-fringe left-margin) (1)) | ||
| 18043 | (+ left-fringe left-margin (- (1))) | ||
| 18044 | (+ left-fringe left-margin (-1)) | ||
| 18045 | |||
| 18046 | */ | ||
| 18047 | |||
| 18048 | #define NUMVAL(X) \ | ||
| 18049 | ((INTEGERP (X) || FLOATP (X)) \ | ||
| 18050 | ? XFLOATINT (X) \ | ||
| 18051 | : - 1) | ||
| 18052 | |||
| 18053 | static int | ||
| 18054 | calc_pixel_width_or_height (res, it, prop, font, width_p) | ||
| 18055 | double *res; | ||
| 18056 | struct it *it; | ||
| 18057 | Lisp_Object prop; | ||
| 18058 | XFontStruct *font; | ||
| 18059 | int width_p; | ||
| 18060 | { | ||
| 18061 | double pixels; | ||
| 18062 | |||
| 18063 | #define OK_PIXELS(val) ((*res = (val)), 1) | ||
| 18064 | |||
| 18065 | if (SYMBOLP (prop)) | ||
| 18066 | { | ||
| 18067 | if (SCHARS (SYMBOL_NAME (prop)) == 2) | ||
| 18068 | { | ||
| 18069 | char *unit = SDATA (SYMBOL_NAME (prop)); | ||
| 18070 | |||
| 18071 | if (unit[0] == 'i' && unit[1] == 'n') | ||
| 18072 | pixels = 1.0; | ||
| 18073 | else if (unit[0] == 'm' && unit[1] == 'm') | ||
| 18074 | pixels = 25.4; | ||
| 18075 | else if (unit[0] == 'c' && unit[1] == 'm') | ||
| 18076 | pixels = 2.54; | ||
| 18077 | else | ||
| 18078 | pixels = 0; | ||
| 18079 | if (pixels > 0) | ||
| 18080 | { | ||
| 18081 | double ppi; | ||
| 18082 | if ((ppi = NUMVAL (Vdisplay_pixels_per_inch), ppi > 0) | ||
| 18083 | || (CONSP (Vdisplay_pixels_per_inch) | ||
| 18084 | && (ppi = (width_p | ||
| 18085 | ? NUMVAL (XCAR (Vdisplay_pixels_per_inch)) | ||
| 18086 | : NUMVAL (XCDR (Vdisplay_pixels_per_inch))), | ||
| 18087 | ppi > 0))) | ||
| 18088 | return OK_PIXELS (ppi / pixels); | ||
| 18089 | |||
| 18090 | return 0; | ||
| 18091 | } | ||
| 18092 | } | ||
| 18093 | |||
| 18094 | if (EQ (prop, Qheight)) | ||
| 18095 | return OK_PIXELS (font ? FONT_HEIGHT (font) : FRAME_LINE_HEIGHT (it->f)); | ||
| 18096 | if (EQ (prop, Qwidth)) | ||
| 18097 | return OK_PIXELS (font ? FONT_WIDTH (font) : FRAME_COLUMN_WIDTH (it->f)); | ||
| 18098 | if (EQ (prop, Qleft_fringe)) | ||
| 18099 | return OK_PIXELS (WINDOW_LEFT_FRINGE_WIDTH (it->w)); | ||
| 18100 | if (EQ (prop, Qright_fringe)) | ||
| 18101 | return OK_PIXELS (WINDOW_RIGHT_FRINGE_WIDTH (it->w)); | ||
| 18102 | if (EQ (prop, Qleft_margin)) | ||
| 18103 | return OK_PIXELS (WINDOW_LEFT_MARGIN_WIDTH (it->w)); | ||
| 18104 | if (EQ (prop, Qright_margin)) | ||
| 18105 | return OK_PIXELS (WINDOW_RIGHT_MARGIN_WIDTH (it->w)); | ||
| 18106 | if (EQ (prop, Qscroll_bar)) | ||
| 18107 | return OK_PIXELS (WINDOW_SCROLL_BAR_AREA_WIDTH (it->w)); | ||
| 18108 | |||
| 18109 | prop = Fbuffer_local_value (prop, it->w->buffer); | ||
| 18110 | } | ||
| 18111 | |||
| 18112 | if (INTEGERP (prop) || FLOATP (prop)) | ||
| 18113 | { | ||
| 18114 | int base_unit = (width_p | ||
| 18115 | ? FRAME_COLUMN_WIDTH (it->f) | ||
| 18116 | : FRAME_LINE_HEIGHT (it->f)); | ||
| 18117 | return OK_PIXELS (XFLOATINT (prop) * base_unit); | ||
| 18118 | } | ||
| 18119 | |||
| 18120 | if (CONSP (prop)) | ||
| 18121 | { | ||
| 18122 | Lisp_Object car = XCAR (prop); | ||
| 18123 | Lisp_Object cdr = XCDR (prop); | ||
| 18124 | |||
| 18125 | if (SYMBOLP (car)) | ||
| 18126 | { | ||
| 18127 | if (EQ (car, Qplus) || EQ (car, Qminus)) | ||
| 18128 | { | ||
| 18129 | int first = 1; | ||
| 18130 | double px; | ||
| 18131 | |||
| 18132 | pixels = 0; | ||
| 18133 | while (CONSP (cdr)) | ||
| 18134 | { | ||
| 18135 | if (!calc_pixel_width_or_height (&px, it, XCAR (cdr), font, width_p)) | ||
| 18136 | return 0; | ||
| 18137 | if (first) | ||
| 18138 | pixels = (EQ (car, Qplus) ? px : -px), first = 0; | ||
| 18139 | else | ||
| 18140 | pixels += px; | ||
| 18141 | cdr = XCDR (cdr); | ||
| 18142 | } | ||
| 18143 | if (EQ (car, Qminus)) | ||
| 18144 | pixels = -pixels; | ||
| 18145 | return OK_PIXELS (pixels); | ||
| 18146 | } | ||
| 18147 | |||
| 18148 | if (EQ (car, Qleft_fringe)) | ||
| 18149 | return OK_PIXELS ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (it->w) | ||
| 18150 | == !NILP (cdr)) | ||
| 18151 | ? WINDOW_LEFT_FRINGE_WIDTH (it->w) | ||
| 18152 | : 0); | ||
| 18153 | if (EQ (car, Qright_fringe)) | ||
| 18154 | return OK_PIXELS ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (it->w) | ||
| 18155 | == !NILP (cdr)) | ||
| 18156 | ? WINDOW_RIGHT_FRINGE_WIDTH (it->w) | ||
| 18157 | : 0); | ||
| 18158 | if (EQ (car, Qscroll_bar)) | ||
| 18159 | return OK_PIXELS ((WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (it->w) | ||
| 18160 | == EQ (cdr, Qleft)) | ||
| 18161 | ? WINDOW_SCROLL_BAR_AREA_WIDTH (it->w) | ||
| 18162 | : 0); | ||
| 18163 | |||
| 18164 | car = Fbuffer_local_value (car, it->w->buffer); | ||
| 18165 | } | ||
| 18166 | |||
| 18167 | if (INTEGERP (car) || FLOATP (car)) | ||
| 18168 | { | ||
| 18169 | double fact; | ||
| 18170 | pixels = XFLOATINT (car); | ||
| 18171 | if (NILP (cdr)) | ||
| 18172 | return OK_PIXELS (pixels); | ||
| 18173 | if (calc_pixel_width_or_height (&fact, it, cdr, font, width_p)) | ||
| 18174 | return OK_PIXELS (pixels * fact); | ||
| 18175 | return 0; | ||
| 18176 | } | ||
| 18177 | |||
| 18178 | return 0; | ||
| 18179 | } | ||
| 18180 | |||
| 18181 | return 0; | ||
| 18182 | } | ||
| 18183 | |||
| 18184 | /* Produce a stretch glyph for iterator IT. IT->object is the value | 18223 | /* Produce a stretch glyph for iterator IT. IT->object is the value |
| 18185 | of the glyph property displayed. The value must be a list | 18224 | of the glyph property displayed. The value must be a list |
| 18186 | `(space KEYWORD VALUE ...)' with the following KEYWORD/VALUE pairs | 18225 | `(space KEYWORD VALUE ...)' with the following KEYWORD/VALUE pairs |
| @@ -18218,7 +18257,7 @@ produce_stretch_glyph (it) | |||
| 18218 | { | 18257 | { |
| 18219 | /* (space :width WIDTH :height HEIGHT ...) */ | 18258 | /* (space :width WIDTH :height HEIGHT ...) */ |
| 18220 | Lisp_Object prop, plist; | 18259 | Lisp_Object prop, plist; |
| 18221 | int width = 0, height = 0; | 18260 | int width = 0, height = 0, align_to = -1; |
| 18222 | int zero_width_ok_p = 0, zero_height_ok_p = 0; | 18261 | int zero_width_ok_p = 0, zero_height_ok_p = 0; |
| 18223 | int ascent = 0; | 18262 | int ascent = 0; |
| 18224 | double tem; | 18263 | double tem; |
| @@ -18233,7 +18272,7 @@ produce_stretch_glyph (it) | |||
| 18233 | 18272 | ||
| 18234 | /* Compute the width of the stretch. */ | 18273 | /* Compute the width of the stretch. */ |
| 18235 | if ((prop = Fplist_get (plist, QCwidth), !NILP (prop)) | 18274 | if ((prop = Fplist_get (plist, QCwidth), !NILP (prop)) |
| 18236 | && calc_pixel_width_or_height (&tem, it, prop, font, 1)) | 18275 | && calc_pixel_width_or_height (&tem, it, prop, font, 1, 0)) |
| 18237 | { | 18276 | { |
| 18238 | /* Absolute width `:width WIDTH' specified and valid. */ | 18277 | /* Absolute width `:width WIDTH' specified and valid. */ |
| 18239 | zero_width_ok_p = 1; | 18278 | zero_width_ok_p = 1; |
| @@ -18264,9 +18303,15 @@ produce_stretch_glyph (it) | |||
| 18264 | width = NUMVAL (prop) * it2.pixel_width; | 18303 | width = NUMVAL (prop) * it2.pixel_width; |
| 18265 | } | 18304 | } |
| 18266 | else if ((prop = Fplist_get (plist, QCalign_to), !NILP (prop)) | 18305 | else if ((prop = Fplist_get (plist, QCalign_to), !NILP (prop)) |
| 18267 | && calc_pixel_width_or_height (&tem, it, prop, font, 1)) | 18306 | && calc_pixel_width_or_height (&tem, it, prop, font, 1, &align_to)) |
| 18268 | { | 18307 | { |
| 18269 | width = max (0, (int)tem - it->current_x); | 18308 | if (it->glyph_row == NULL || !it->glyph_row->mode_line_p) |
| 18309 | align_to = (align_to < 0 | ||
| 18310 | ? 0 | ||
| 18311 | : align_to - window_box_left_offset (it->w, TEXT_AREA)); | ||
| 18312 | else if (align_to < 0) | ||
| 18313 | align_to = window_box_left_offset (it->w, TEXT_AREA); | ||
| 18314 | width = max (0, (int)tem + align_to - it->current_x); | ||
| 18270 | zero_width_ok_p = 1; | 18315 | zero_width_ok_p = 1; |
| 18271 | } | 18316 | } |
| 18272 | else | 18317 | else |
| @@ -18278,7 +18323,7 @@ produce_stretch_glyph (it) | |||
| 18278 | 18323 | ||
| 18279 | /* Compute height. */ | 18324 | /* Compute height. */ |
| 18280 | if ((prop = Fplist_get (plist, QCheight), !NILP (prop)) | 18325 | if ((prop = Fplist_get (plist, QCheight), !NILP (prop)) |
| 18281 | && calc_pixel_width_or_height (&tem, it, prop, font, 0)) | 18326 | && calc_pixel_width_or_height (&tem, it, prop, font, 0, 0)) |
| 18282 | { | 18327 | { |
| 18283 | height = (int)tem; | 18328 | height = (int)tem; |
| 18284 | zero_height_ok_p = 1; | 18329 | zero_height_ok_p = 1; |
| @@ -18299,7 +18344,7 @@ produce_stretch_glyph (it) | |||
| 18299 | NUMVAL (prop) > 0 && NUMVAL (prop) <= 100) | 18344 | NUMVAL (prop) > 0 && NUMVAL (prop) <= 100) |
| 18300 | ascent = height * NUMVAL (prop) / 100.0; | 18345 | ascent = height * NUMVAL (prop) / 100.0; |
| 18301 | else if (!NILP (prop) | 18346 | else if (!NILP (prop) |
| 18302 | && calc_pixel_width_or_height (&tem, it, prop, font, 0)) | 18347 | && calc_pixel_width_or_height (&tem, it, prop, font, 0, 0)) |
| 18303 | ascent = min (max (0, (int)tem), height); | 18348 | ascent = min (max (0, (int)tem), height); |
| 18304 | else | 18349 | else |
| 18305 | ascent = (height * FONT_BASE (font)) / FONT_HEIGHT (font); | 18350 | ascent = (height * FONT_BASE (font)) / FONT_HEIGHT (font); |
| @@ -21523,6 +21568,8 @@ syms_of_xdisp () | |||
| 21523 | staticpro (&Qleft_margin); | 21568 | staticpro (&Qleft_margin); |
| 21524 | Qright_margin = intern ("right-margin"); | 21569 | Qright_margin = intern ("right-margin"); |
| 21525 | staticpro (&Qright_margin); | 21570 | staticpro (&Qright_margin); |
| 21571 | Qcenter = intern ("center"); | ||
| 21572 | staticpro (&Qcenter); | ||
| 21526 | QCalign_to = intern (":align-to"); | 21573 | QCalign_to = intern (":align-to"); |
| 21527 | staticpro (&QCalign_to); | 21574 | staticpro (&QCalign_to); |
| 21528 | QCrelative_width = intern (":relative-width"); | 21575 | QCrelative_width = intern (":relative-width"); |