aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog55
-rw-r--r--src/buffer.c2
-rw-r--r--src/dispextern.h4
-rw-r--r--src/editfns.c2
-rw-r--r--src/image.c4
-rw-r--r--src/insdel.c8
-rw-r--r--src/lisp.h2
-rw-r--r--src/s/sol2-6.h5
-rw-r--r--src/term.c88
-rw-r--r--src/xdisp.c503
-rw-r--r--src/xterm.c8
11 files changed, 442 insertions, 239 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 5f65301a7cd..ce03ac5ccda 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,58 @@
12004-03-26 Masatake YAMATO <jet@gyve.org>
2
3 * insdel.c (adjust_markers_for_insert): Call
4 fix_start_end_in_overlays.
5
6 * buffer.c (fix_start_end_in_overlays): Rename
7 fix_overlays_in_range.
8
9 * editfns.c (Ftranspose_regions): Likewise.
10
11 * lisp.h (top_level): Likewise.
12
132004-03-20 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
14
15 * xterm.c (handle_one_xevent): Do not pass key press events to
16 GTK.
17
182004-03-19 Richard M. Stallman <rms@gnu.org>
19
20 * s/sol2-6.h: Delete previous change.
21
222004-03-19 Kim F. Storm <storm@cua.dk>
23
24 * xdisp.c (move_it_in_display_line_to): Fix MOVE_TO_POS case when
25 to_charpos corresponds to newline in right fringe. Use local
26 BUFFER_POS_REACHED_P macro.
27
282004-03-19 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
29
30 * xdisp.c (calc_pixel_width_or_height): Add ifdef HAVE_WINDOW_SYSTEM
31 to compile on non-window system.
32
332004-03-19 Kim F. Storm <storm@cua.dk>
34
35 * dispextern.h (calc_pixel_width_or_height): Add prototype.
36
37 * image.c (Qcenter): Move to xdisp.c.
38
39 * xdisp.c (Qcenter): Declare here.
40 (syms_of_xdisp): intern and staticpro it.
41 (handle_single_display_prop): Allow space display property on all
42 platforms.
43 (display_mode_line): Set mode_line_p before displaying line.
44 (calc_pixel_width_or_height): Declare extern. Add separate :align-to
45 handling. Remove complex cases for fringes and scroll-bars.
46 Add left, right, and center alignment positions. Add text (area)
47 width/height. Return width or height for image specs.
48 (produce_stretch_glyph): Improve handling of :align-to. Is now
49 relative to left of text area by default, but other base offsets
50 can be specified -- also for text lines.
51
52 * term.c (produce_glyphs): Handle IT_STRETCH.
53 (produce_stretch_glyph): New function to handle space width and
54 align-to display properties on non-window systems.
55
12004-03-17 Stefan Monnier <monnier@iro.umontreal.ca> 562004-03-17 Stefan Monnier <monnier@iro.umontreal.ca>
2 57
3 * fileio.c (Fread_file_name): Set completion-ignore-case for 58 * fileio.c (Fread_file_name): Set completion-ignore-case for
diff --git a/src/buffer.c b/src/buffer.c
index 27b12845c50..08031a0d72b 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -3293,7 +3293,7 @@ adjust_overlays_for_delete (pos, length)
3293 If so, we'll reverse the endpoints. Can you think of anything 3293 If so, we'll reverse the endpoints. Can you think of anything
3294 better to do in this situation? */ 3294 better to do in this situation? */
3295void 3295void
3296fix_overlays_in_range (start, end) 3296fix_start_end_in_overlays (start, end)
3297 register int start, end; 3297 register int start, end;
3298{ 3298{
3299 Lisp_Object overlay; 3299 Lisp_Object overlay;
diff --git a/src/dispextern.h b/src/dispextern.h
index 96e89a48b05..7056519e7bf 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -74,7 +74,6 @@ typedef XImagePtr XImagePtr_or_DC;
74#define NativeRectangle int 74#define NativeRectangle int
75#endif 75#endif
76 76
77
78/* Structure forward declarations. Some are here because function 77/* Structure forward declarations. Some are here because function
79 prototypes below reference structure types before their definition 78 prototypes below reference structure types before their definition
80 in this file. Some are here because not every file including 79 in this file. Some are here because not every file including
@@ -2530,6 +2529,9 @@ extern struct frame *last_mouse_frame;
2530extern int last_tool_bar_item; 2529extern int last_tool_bar_item;
2531extern int mouse_autoselect_window; 2530extern int mouse_autoselect_window;
2532 2531
2532extern int calc_pixel_width_or_height P_ ((double *, struct it *, Lisp_Object,
2533 /* XFontStruct */ void *, int, int *));
2534
2533#ifdef HAVE_WINDOW_SYSTEM 2535#ifdef HAVE_WINDOW_SYSTEM
2534 2536
2535#if GLYPH_DEBUG 2537#if GLYPH_DEBUG
diff --git a/src/editfns.c b/src/editfns.c
index 51435af0bb2..df183155c4b 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -4157,7 +4157,7 @@ Transposing beyond buffer boundaries is an error. */)
4157 transpose_markers (start1, end1, start2, end2, 4157 transpose_markers (start1, end1, start2, end2,
4158 start1_byte, start1_byte + len1_byte, 4158 start1_byte, start1_byte + len1_byte,
4159 start2_byte, start2_byte + len2_byte); 4159 start2_byte, start2_byte + len2_byte);
4160 fix_overlays_in_range (start1, end2); 4160 fix_start_end_in_overlays (start1, end2);
4161 } 4161 }
4162 4162
4163 return Qnil; 4163 return Qnil;
diff --git a/src/image.c b/src/image.c
index 23777dca253..34db5e53367 100644
--- a/src/image.c
+++ b/src/image.c
@@ -606,6 +606,7 @@ Lisp_Object Qxbm;
606 606
607extern Lisp_Object QCwidth, QCheight, QCforeground, QCbackground, QCfile; 607extern Lisp_Object QCwidth, QCheight, QCforeground, QCbackground, QCfile;
608extern Lisp_Object QCdata, QCtype; 608extern Lisp_Object QCdata, QCtype;
609extern Lisp_Object Qcenter;
609Lisp_Object QCascent, QCmargin, QCrelief; 610Lisp_Object QCascent, QCmargin, QCrelief;
610Lisp_Object QCconversion, QCcolor_symbols, QCheuristic_mask; 611Lisp_Object QCconversion, QCcolor_symbols, QCheuristic_mask;
611Lisp_Object QCindex, QCmatrix, QCcolor_adjustment, QCmask; 612Lisp_Object QCindex, QCmatrix, QCcolor_adjustment, QCmask;
@@ -613,7 +614,6 @@ Lisp_Object QCindex, QCmatrix, QCcolor_adjustment, QCmask;
613/* Other symbols. */ 614/* Other symbols. */
614 615
615Lisp_Object Qlaplace, Qemboss, Qedge_detection, Qheuristic; 616Lisp_Object Qlaplace, Qemboss, Qedge_detection, Qheuristic;
616Lisp_Object Qcenter;
617 617
618/* Time in seconds after which images should be removed from the cache 618/* Time in seconds after which images should be removed from the cache
619 if not displayed. */ 619 if not displayed. */
@@ -7400,8 +7400,6 @@ syms_of_image ()
7400 staticpro (&Qedge_detection); 7400 staticpro (&Qedge_detection);
7401 Qheuristic = intern ("heuristic"); 7401 Qheuristic = intern ("heuristic");
7402 staticpro (&Qheuristic); 7402 staticpro (&Qheuristic);
7403 Qcenter = intern ("center");
7404 staticpro (&Qcenter);
7405 7403
7406 Qpostscript = intern ("postscript"); 7404 Qpostscript = intern ("postscript");
7407 staticpro (&Qpostscript); 7405 staticpro (&Qpostscript);
diff --git a/src/insdel.c b/src/insdel.c
index 88bf1ddd085..5e3f69161e0 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -441,9 +441,13 @@ adjust_markers_for_insert (from, from_byte, to, to_byte, before_markers)
441 } 441 }
442 442
443 /* Adjusting only markers whose insertion-type is t may result in 443 /* Adjusting only markers whose insertion-type is t may result in
444 disordered overlays in the slot `overlays_before'. */ 444 - disordered start and end in overlays, and
445 - disordered overlays in the slot `overlays_before' of current_buffer. */
445 if (adjusted) 446 if (adjusted)
446 fix_overlays_before (current_buffer, from, to); 447 {
448 fix_start_end_in_overlays(from, to);
449 fix_overlays_before (current_buffer, from, to);
450 }
447} 451}
448 452
449/* Adjust point for an insertion of NBYTES bytes, which are NCHARS characters. 453/* Adjust point for an insertion of NBYTES bytes, which are NCHARS characters.
diff --git a/src/lisp.h b/src/lisp.h
index cd873076602..2135f80f5e8 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2656,7 +2656,7 @@ EXFUN (Foverlay_start, 1);
2656EXFUN (Foverlay_end, 1); 2656EXFUN (Foverlay_end, 1);
2657extern void adjust_overlays_for_insert P_ ((EMACS_INT, EMACS_INT)); 2657extern void adjust_overlays_for_insert P_ ((EMACS_INT, EMACS_INT));
2658extern void adjust_overlays_for_delete P_ ((EMACS_INT, EMACS_INT)); 2658extern void adjust_overlays_for_delete P_ ((EMACS_INT, EMACS_INT));
2659extern void fix_overlays_in_range P_ ((int, int)); 2659extern void fix_start_end_in_overlays P_ ((int, int));
2660extern void report_overlay_modification P_ ((Lisp_Object, Lisp_Object, int, 2660extern void report_overlay_modification P_ ((Lisp_Object, Lisp_Object, int,
2661 Lisp_Object, Lisp_Object, Lisp_Object)); 2661 Lisp_Object, Lisp_Object, Lisp_Object));
2662extern int overlay_touches_p P_ ((int)); 2662extern int overlay_touches_p P_ ((int));
diff --git a/src/s/sol2-6.h b/src/s/sol2-6.h
index 3ba9ed1f5bd..a43443e48c2 100644
--- a/src/s/sol2-6.h
+++ b/src/s/sol2-6.h
@@ -7,10 +7,5 @@
7#define UNEXEC unexsol.o 7#define UNEXEC unexsol.o
8#endif 8#endif
9 9
10/* "Dennis McRitchie" <dmcr@Princeton.EDU> reported failures
11 with GNU ld without this. */
12
13#define LD_SWITCH_SYSTEM_TEMACS -znocombreloc
14
15/* arch-tag: 71ea3857-89dc-4395-9623-77964e6ed3ca 10/* arch-tag: 71ea3857-89dc-4395-9623-77964e6ed3ca
16 (do not change this comment) */ 11 (do not change this comment) */
diff --git a/src/term.c b/src/term.c
index f9d9dfce8c0..5d0c1fc7319 100644
--- a/src/term.c
+++ b/src/term.c
@@ -102,6 +102,10 @@ void delete_tty_output P_ ((struct frame *));
102 102
103#define OUTPUT1_IF(tty, a) do { if (a) emacs_tputs ((tty), a, 1, cmputc); } while (0) 103#define OUTPUT1_IF(tty, a) do { if (a) emacs_tputs ((tty), a, 1, cmputc); } while (0)
104 104
105/* Display space properties */
106
107extern Lisp_Object Qspace, QCalign_to, QCwidth;
108
105/* Function to use to ring the bell. */ 109/* Function to use to ring the bell. */
106 110
107Lisp_Object Vring_bell_function; 111Lisp_Object Vring_bell_function;
@@ -1493,6 +1497,7 @@ term_get_fkeys_1 ()
1493 ***********************************************************************/ 1497 ***********************************************************************/
1494 1498
1495static void append_glyph P_ ((struct it *)); 1499static void append_glyph P_ ((struct it *));
1500static void produce_stretch_glyph P_ ((struct it *));
1496 1501
1497 1502
1498/* Append glyphs to IT's glyph_row. Called from produce_glyphs for 1503/* Append glyphs to IT's glyph_row. Called from produce_glyphs for
@@ -1556,9 +1561,14 @@ produce_glyphs (it)
1556 /* If a hook is installed, let it do the work. */ 1561 /* If a hook is installed, let it do the work. */
1557 xassert (it->what == IT_CHARACTER 1562 xassert (it->what == IT_CHARACTER
1558 || it->what == IT_COMPOSITION 1563 || it->what == IT_COMPOSITION
1559 || it->what == IT_IMAGE
1560 || it->what == IT_STRETCH); 1564 || it->what == IT_STRETCH);
1561 1565
1566 if (it->what == IT_STRETCH)
1567 {
1568 produce_stretch_glyph (it);
1569 goto done;
1570 }
1571
1562 /* Nothing but characters are supported on terminal frames. For a 1572 /* Nothing but characters are supported on terminal frames. For a
1563 composition sequence, it->c is the first character of the 1573 composition sequence, it->c is the first character of the
1564 sequence. */ 1574 sequence. */
@@ -1632,6 +1642,7 @@ produce_glyphs (it)
1632 append_glyph (it); 1642 append_glyph (it);
1633 } 1643 }
1634 1644
1645 done:
1635 /* Advance current_x by the pixel width as a convenience for 1646 /* Advance current_x by the pixel width as a convenience for
1636 the caller. */ 1647 the caller. */
1637 if (it->area == TEXT_AREA) 1648 if (it->area == TEXT_AREA)
@@ -1641,6 +1652,81 @@ produce_glyphs (it)
1641} 1652}
1642 1653
1643 1654
1655/* Produce a stretch glyph for iterator IT. IT->object is the value
1656 of the glyph property displayed. The value must be a list
1657 `(space KEYWORD VALUE ...)' with the following KEYWORD/VALUE pairs
1658 being recognized:
1659
1660 1. `:width WIDTH' specifies that the space should be WIDTH *
1661 canonical char width wide. WIDTH may be an integer or floating
1662 point number.
1663
1664 2. `:align-to HPOS' specifies that the space should be wide enough
1665 to reach HPOS, a value in canonical character units. */
1666
1667static void
1668produce_stretch_glyph (it)
1669 struct it *it;
1670{
1671 /* (space :width WIDTH ...) */
1672 Lisp_Object prop, plist;
1673 int width = 0, align_to = -1;
1674 int zero_width_ok_p = 0;
1675 double tem;
1676
1677 /* List should start with `space'. */
1678 xassert (CONSP (it->object) && EQ (XCAR (it->object), Qspace));
1679 plist = XCDR (it->object);
1680
1681 /* Compute the width of the stretch. */
1682 if ((prop = Fplist_get (plist, QCwidth), !NILP (prop))
1683 && calc_pixel_width_or_height (&tem, it, prop, 0, 1, 0))
1684 {
1685 /* Absolute width `:width WIDTH' specified and valid. */
1686 zero_width_ok_p = 1;
1687 width = (int)(tem + 0.5);
1688 }
1689 else if ((prop = Fplist_get (plist, QCalign_to), !NILP (prop))
1690 && calc_pixel_width_or_height (&tem, it, prop, 0, 1, &align_to))
1691 {
1692 if (it->glyph_row == NULL || !it->glyph_row->mode_line_p)
1693 align_to = (align_to < 0
1694 ? 0
1695 : align_to - window_box_left_offset (it->w, TEXT_AREA));
1696 else if (align_to < 0)
1697 align_to = window_box_left_offset (it->w, TEXT_AREA);
1698 width = max (0, (int)(tem + 0.5) + align_to - it->current_x);
1699 zero_width_ok_p = 1;
1700 }
1701 else
1702 /* Nothing specified -> width defaults to canonical char width. */
1703 width = FRAME_COLUMN_WIDTH (it->f);
1704
1705 if (width <= 0 && (width < 0 || !zero_width_ok_p))
1706 width = 1;
1707
1708 if (width > 0 && it->glyph_row)
1709 {
1710 Lisp_Object o_object = it->object;
1711 Lisp_Object object = it->stack[it->sp - 1].string;
1712 int n = width;
1713 int c = it->c;
1714
1715 if (!STRINGP (object))
1716 object = it->w->buffer;
1717 it->object = object;
1718 it->c = ' ';
1719 it->pixel_width = it->len = 1;
1720 while (n--)
1721 append_glyph (it);
1722 it->object = o_object;
1723 it->c = c;
1724 }
1725 it->pixel_width = width;
1726 it->nglyphs = width;
1727}
1728
1729
1644/* Get information about special display element WHAT in an 1730/* Get information about special display element WHAT in an
1645 environment described by IT. WHAT is one of IT_TRUNCATION or 1731 environment described by IT. WHAT is one of IT_TRUNCATION or
1646 IT_CONTINUATION. Maybe produce glyphs for WHAT if IT has a 1732 IT_CONTINUATION. Maybe produce glyphs for WHAT if IT has a
diff --git a/src/xdisp.c b/src/xdisp.c
index 796c7d06ce8..8fd0763590a 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -301,6 +301,7 @@ extern Lisp_Object Qface, Qinvisible, Qwidth;
301Lisp_Object Vdisplay_pixels_per_inch; 301Lisp_Object Vdisplay_pixels_per_inch;
302Lisp_Object Qspace, QCalign_to, QCrelative_width, QCrelative_height; 302Lisp_Object Qspace, QCalign_to, QCrelative_width, QCrelative_height;
303Lisp_Object Qleft_margin, Qright_margin, Qspace_width, Qraise; 303Lisp_Object Qleft_margin, Qright_margin, Qspace_width, Qraise;
304Lisp_Object Qcenter;
304Lisp_Object Qmargin, Qpointer; 305Lisp_Object Qmargin, Qpointer;
305extern Lisp_Object Qheight; 306extern Lisp_Object Qheight;
306extern Lisp_Object QCwidth, QCheight, QCascent; 307extern Lisp_Object QCwidth, QCheight, QCascent;
@@ -3603,16 +3604,11 @@ handle_single_display_prop (it, prop, object, position,
3603 value = prop; 3604 value = prop;
3604 } 3605 }
3605 3606
3607 valid_p = (STRINGP (value)
3606#ifdef HAVE_WINDOW_SYSTEM 3608#ifdef HAVE_WINDOW_SYSTEM
3607 if (FRAME_TERMCAP_P (it->f)) 3609 || (!FRAME_TERMCAP_P (it->f) && valid_image_p (value))
3608 valid_p = STRINGP (value);
3609 else
3610 valid_p = (STRINGP (value)
3611 || (CONSP (value) && EQ (XCAR (value), Qspace))
3612 || valid_image_p (value));
3613#else /* not HAVE_WINDOW_SYSTEM */
3614 valid_p = STRINGP (value);
3615#endif /* not HAVE_WINDOW_SYSTEM */ 3610#endif /* not HAVE_WINDOW_SYSTEM */
3611 || (CONSP (value) && EQ (XCAR (value), Qspace)));
3616 3612
3617 if ((EQ (location, Qleft_margin) 3613 if ((EQ (location, Qleft_margin)
3618 || EQ (location, Qright_margin) 3614 || EQ (location, Qright_margin)
@@ -5594,15 +5590,18 @@ move_it_in_display_line_to (it, to_charpos, to_x, op)
5594 saved_glyph_row = it->glyph_row; 5590 saved_glyph_row = it->glyph_row;
5595 it->glyph_row = NULL; 5591 it->glyph_row = NULL;
5596 5592
5593#define BUFFER_POS_REACHED_P() \
5594 ((op & MOVE_TO_POS) != 0 \
5595 && BUFFERP (it->object) \
5596 && IT_CHARPOS (*it) >= to_charpos)
5597
5597 while (1) 5598 while (1)
5598 { 5599 {
5599 int x, i, ascent = 0, descent = 0; 5600 int x, i, ascent = 0, descent = 0;
5600 5601
5601 /* Stop when ZV or TO_CHARPOS reached. */ 5602 /* Stop when ZV or TO_CHARPOS reached. */
5602 if (!get_next_display_element (it) 5603 if (!get_next_display_element (it)
5603 || ((op & MOVE_TO_POS) != 0 5604 || BUFFER_POS_REACHED_P ())
5604 && BUFFERP (it->object)
5605 && IT_CHARPOS (*it) >= to_charpos))
5606 { 5605 {
5607 result = MOVE_POS_MATCH_OR_ZV; 5606 result = MOVE_POS_MATCH_OR_ZV;
5608 break; 5607 break;
@@ -5689,7 +5688,8 @@ move_it_in_display_line_to (it, to_charpos, to_x, op)
5689#ifdef HAVE_WINDOW_SYSTEM 5688#ifdef HAVE_WINDOW_SYSTEM
5690 if (IT_OVERFLOW_NEWLINE_INTO_FRINGE (it)) 5689 if (IT_OVERFLOW_NEWLINE_INTO_FRINGE (it))
5691 { 5690 {
5692 if (!get_next_display_element (it)) 5691 if (!get_next_display_element (it)
5692 || BUFFER_POS_REACHED_P ())
5693 { 5693 {
5694 result = MOVE_POS_MATCH_OR_ZV; 5694 result = MOVE_POS_MATCH_OR_ZV;
5695 break; 5695 break;
@@ -5761,7 +5761,8 @@ move_it_in_display_line_to (it, to_charpos, to_x, op)
5761#ifdef HAVE_WINDOW_SYSTEM 5761#ifdef HAVE_WINDOW_SYSTEM
5762 if (IT_OVERFLOW_NEWLINE_INTO_FRINGE (it)) 5762 if (IT_OVERFLOW_NEWLINE_INTO_FRINGE (it))
5763 { 5763 {
5764 if (!get_next_display_element (it)) 5764 if (!get_next_display_element (it)
5765 || BUFFER_POS_REACHED_P ())
5765 { 5766 {
5766 result = MOVE_POS_MATCH_OR_ZV; 5767 result = MOVE_POS_MATCH_OR_ZV;
5767 break; 5768 break;
@@ -5778,6 +5779,8 @@ move_it_in_display_line_to (it, to_charpos, to_x, op)
5778 } 5779 }
5779 } 5780 }
5780 5781
5782#undef BUFFER_POS_REACHED_P
5783
5781 /* Restore the iterator settings altered at the beginning of this 5784 /* Restore the iterator settings altered at the beginning of this
5782 function. */ 5785 function. */
5783 it->glyph_row = saved_glyph_row; 5786 it->glyph_row = saved_glyph_row;
@@ -15064,6 +15067,8 @@ display_mode_line (w, face_id, format)
15064 init_iterator (&it, w, -1, -1, NULL, face_id); 15067 init_iterator (&it, w, -1, -1, NULL, face_id);
15065 prepare_desired_row (it.glyph_row); 15068 prepare_desired_row (it.glyph_row);
15066 15069
15070 it.glyph_row->mode_line_p = 1;
15071
15067 if (! mode_line_inverse_video) 15072 if (! mode_line_inverse_video)
15068 /* Force the mode-line to be displayed in the default face. */ 15073 /* Force the mode-line to be displayed in the default face. */
15069 it.base_face_id = it.face_id = DEFAULT_FACE_ID; 15074 it.base_face_id = it.face_id = DEFAULT_FACE_ID;
@@ -15080,7 +15085,6 @@ display_mode_line (w, face_id, format)
15080 15085
15081 compute_line_metrics (&it); 15086 compute_line_metrics (&it);
15082 it.glyph_row->full_width_p = 1; 15087 it.glyph_row->full_width_p = 1;
15083 it.glyph_row->mode_line_p = 1;
15084 it.glyph_row->continued_p = 0; 15088 it.glyph_row->continued_p = 0;
15085 it.glyph_row->truncated_on_left_p = 0; 15089 it.glyph_row->truncated_on_left_p = 0;
15086 it.glyph_row->truncated_on_right_p = 0; 15090 it.glyph_row->truncated_on_right_p = 0;
@@ -16694,6 +16698,252 @@ invisible_p (propval, list)
16694 return 0; 16698 return 0;
16695} 16699}
16696 16700
16701/* Calculate a width or height in pixels from a specification using
16702 the following elements:
16703
16704 SPEC ::=
16705 NUM - a (fractional) multiple of the default font width/height
16706 (NUM) - specifies exactly NUM pixels
16707 UNIT - a fixed number of pixels, see below.
16708 ELEMENT - size of a display element in pixels, see below.
16709 (NUM . SPEC) - equals NUM * SPEC
16710 (+ SPEC SPEC ...) - add pixel values
16711 (- SPEC SPEC ...) - subtract pixel values
16712 (- SPEC) - negate pixel value
16713
16714 NUM ::=
16715 INT or FLOAT - a number constant
16716 SYMBOL - use symbol's (buffer local) variable binding.
16717
16718 UNIT ::=
16719 in - pixels per inch *)
16720 mm - pixels per 1/1000 meter *)
16721 cm - pixels per 1/100 meter *)
16722 width - width of current font in pixels.
16723 height - height of current font in pixels.
16724
16725 *) using the ratio(s) defined in display-pixels-per-inch.
16726
16727 ELEMENT ::=
16728
16729 left-fringe - left fringe width in pixels
16730 right-fringe - right fringe width in pixels
16731
16732 left-margin - left margin width in pixels
16733 right-margin - right margin width in pixels
16734
16735 scroll-bar - scroll-bar area width in pixels
16736
16737 Examples:
16738
16739 Pixels corresponding to 5 inches:
16740 (5 . in)
16741
16742 Total width of non-text areas on left side of window (if scroll-bar is on left):
16743 '(space :width (+ left-fringe left-margin scroll-bar))
16744
16745 Align to first text column (in header line):
16746 '(space :align-to 0)
16747
16748 Align to middle of text area minus half the width of variable `my-image'
16749 containing a loaded image:
16750 '(space :align-to (0.5 . (- text my-image)))
16751
16752 Width of left margin minus width of 1 character in the default font:
16753 '(space :width (- left-margin 1))
16754
16755 Width of left margin minus width of 2 characters in the current font:
16756 '(space :width (- left-margin (2 . width)))
16757
16758 Center 1 character over left-margin (in header line):
16759 '(space :align-to (+ left-margin (0.5 . left-margin) -0.5))
16760
16761 Different ways to express width of left fringe plus left margin minus one pixel:
16762 '(space :width (- (+ left-fringe left-margin) (1)))
16763 '(space :width (+ left-fringe left-margin (- (1))))
16764 '(space :width (+ left-fringe left-margin (-1)))
16765
16766*/
16767
16768#define NUMVAL(X) \
16769 ((INTEGERP (X) || FLOATP (X)) \
16770 ? XFLOATINT (X) \
16771 : - 1)
16772
16773int
16774calc_pixel_width_or_height (res, it, prop, font, width_p, align_to)
16775 double *res;
16776 struct it *it;
16777 Lisp_Object prop;
16778 void *font;
16779 int width_p, *align_to;
16780{
16781 double pixels;
16782
16783#define OK_PIXELS(val) ((*res = (double)(val)), 1)
16784#define OK_ALIGN_TO(val) ((*align_to = (int)(val)), 1)
16785
16786 if (NILP (prop))
16787 return OK_PIXELS (0);
16788
16789 if (SYMBOLP (prop))
16790 {
16791 if (SCHARS (SYMBOL_NAME (prop)) == 2)
16792 {
16793 char *unit = SDATA (SYMBOL_NAME (prop));
16794
16795 if (unit[0] == 'i' && unit[1] == 'n')
16796 pixels = 1.0;
16797 else if (unit[0] == 'm' && unit[1] == 'm')
16798 pixels = 25.4;
16799 else if (unit[0] == 'c' && unit[1] == 'm')
16800 pixels = 2.54;
16801 else
16802 pixels = 0;
16803 if (pixels > 0)
16804 {
16805 double ppi;
16806 if ((ppi = NUMVAL (Vdisplay_pixels_per_inch), ppi > 0)
16807 || (CONSP (Vdisplay_pixels_per_inch)
16808 && (ppi = (width_p
16809 ? NUMVAL (XCAR (Vdisplay_pixels_per_inch))
16810 : NUMVAL (XCDR (Vdisplay_pixels_per_inch))),
16811 ppi > 0)))
16812 return OK_PIXELS (ppi / pixels);
16813
16814 return 0;
16815 }
16816 }
16817
16818#ifdef HAVE_WINDOW_SYSTEM
16819 if (EQ (prop, Qheight))
16820 return OK_PIXELS (font ? FONT_HEIGHT ((XFontStruct *)font) : FRAME_LINE_HEIGHT (it->f));
16821 if (EQ (prop, Qwidth))
16822 return OK_PIXELS (font ? FONT_WIDTH ((XFontStruct *)font) : FRAME_COLUMN_WIDTH (it->f));
16823#else
16824 if (EQ (prop, Qheight) || EQ (prop, Qwidth))
16825 return OK_PIXELS (1);
16826#endif
16827
16828 if (EQ (prop, Qtext))
16829 return OK_PIXELS (width_p
16830 ? window_box_width (it->w, TEXT_AREA)
16831 : WINDOW_BOX_HEIGHT_NO_MODE_LINE (it->w));
16832
16833 if (align_to && *align_to < 0)
16834 {
16835 *res = 0;
16836 if (EQ (prop, Qleft))
16837 return OK_ALIGN_TO (window_box_left_offset (it->w, TEXT_AREA));
16838 if (EQ (prop, Qright))
16839 return OK_ALIGN_TO (window_box_right_offset (it->w, TEXT_AREA));
16840 if (EQ (prop, Qcenter))
16841 return OK_ALIGN_TO (window_box_left_offset (it->w, TEXT_AREA)
16842 + window_box_width (it->w, TEXT_AREA) / 2);
16843 if (EQ (prop, Qleft_fringe))
16844 return OK_ALIGN_TO (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (it->w)
16845 ? WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (it->w)
16846 : window_box_right_offset (it->w, LEFT_MARGIN_AREA));
16847 if (EQ (prop, Qright_fringe))
16848 return OK_ALIGN_TO (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (it->w)
16849 ? window_box_right_offset (it->w, RIGHT_MARGIN_AREA)
16850 : window_box_right_offset (it->w, TEXT_AREA));
16851 if (EQ (prop, Qleft_margin))
16852 return OK_ALIGN_TO (window_box_left_offset (it->w, LEFT_MARGIN_AREA));
16853 if (EQ (prop, Qright_margin))
16854 return OK_ALIGN_TO (window_box_left_offset (it->w, RIGHT_MARGIN_AREA));
16855 if (EQ (prop, Qscroll_bar))
16856 return OK_ALIGN_TO (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (it->w)
16857 ? 0
16858 : (window_box_right_offset (it->w, RIGHT_MARGIN_AREA)
16859 + (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (it->w)
16860 ? WINDOW_RIGHT_FRINGE_WIDTH (it->w)
16861 : 0)));
16862 }
16863 else
16864 {
16865 if (EQ (prop, Qleft_fringe))
16866 return OK_PIXELS (WINDOW_LEFT_FRINGE_WIDTH (it->w));
16867 if (EQ (prop, Qright_fringe))
16868 return OK_PIXELS (WINDOW_RIGHT_FRINGE_WIDTH (it->w));
16869 if (EQ (prop, Qleft_margin))
16870 return OK_PIXELS (WINDOW_LEFT_MARGIN_WIDTH (it->w));
16871 if (EQ (prop, Qright_margin))
16872 return OK_PIXELS (WINDOW_RIGHT_MARGIN_WIDTH (it->w));
16873 if (EQ (prop, Qscroll_bar))
16874 return OK_PIXELS (WINDOW_SCROLL_BAR_AREA_WIDTH (it->w));
16875 }
16876
16877 prop = Fbuffer_local_value (prop, it->w->buffer);
16878 }
16879
16880 if (INTEGERP (prop) || FLOATP (prop))
16881 {
16882 int base_unit = (width_p
16883 ? FRAME_COLUMN_WIDTH (it->f)
16884 : FRAME_LINE_HEIGHT (it->f));
16885 return OK_PIXELS (XFLOATINT (prop) * base_unit);
16886 }
16887
16888 if (CONSP (prop))
16889 {
16890 Lisp_Object car = XCAR (prop);
16891 Lisp_Object cdr = XCDR (prop);
16892
16893 if (SYMBOLP (car))
16894 {
16895#ifdef HAVE_WINDOW_SYSTEM
16896 if (valid_image_p (prop))
16897 {
16898 int id = lookup_image (it->f, prop);
16899 struct image *img = IMAGE_FROM_ID (it->f, id);
16900
16901 return OK_PIXELS (width_p ? img->width : img->height);
16902 }
16903#endif
16904 if (EQ (car, Qplus) || EQ (car, Qminus))
16905 {
16906 int first = 1;
16907 double px;
16908
16909 pixels = 0;
16910 while (CONSP (cdr))
16911 {
16912 if (!calc_pixel_width_or_height (&px, it, XCAR (cdr),
16913 font, width_p, align_to))
16914 return 0;
16915 if (first)
16916 pixels = (EQ (car, Qplus) ? px : -px), first = 0;
16917 else
16918 pixels += px;
16919 cdr = XCDR (cdr);
16920 }
16921 if (EQ (car, Qminus))
16922 pixels = -pixels;
16923 return OK_PIXELS (pixels);
16924 }
16925
16926 car = Fbuffer_local_value (car, it->w->buffer);
16927 }
16928
16929 if (INTEGERP (car) || FLOATP (car))
16930 {
16931 double fact;
16932 pixels = XFLOATINT (car);
16933 if (NILP (cdr))
16934 return OK_PIXELS (pixels);
16935 if (calc_pixel_width_or_height (&fact, it, cdr,
16936 font, width_p, align_to))
16937 return OK_PIXELS (pixels * fact);
16938 return 0;
16939 }
16940
16941 return 0;
16942 }
16943
16944 return 0;
16945}
16946
16697 16947
16698/*********************************************************************** 16948/***********************************************************************
16699 Glyph Display 16949 Glyph Display
@@ -17977,209 +18227,6 @@ append_stretch_glyph (it, object, width, height, ascent)
17977} 18227}
17978 18228
17979 18229
17980/* Calculate a width or height in pixels from a specification using
17981 the following elements:
17982
17983 SPEC ::=
17984 NUM - a (fractional) multiple of the default font width/height
17985 (NUM) - specifies exactly NUM pixels
17986 UNIT - a fixed number of pixels, see below.
17987 ELEMENT - size of a display element in pixels, see below.
17988 (NUM . SPEC) - equals NUM * SPEC
17989 (+ SPEC SPEC ...) - add pixel values
17990 (- SPEC SPEC ...) - subtract pixel values
17991 (- SPEC) - negate pixel value
17992
17993 NUM ::=
17994 INT or FLOAT - a number constant
17995 SYMBOL - use symbol's (buffer local) variable binding.
17996
17997 UNIT ::=
17998 in - pixels per inch *)
17999 mm - pixels per 1/1000 meter *)
18000 cm - pixels per 1/100 meter *)
18001 width - width of current font in pixels.
18002 height - height of current font in pixels.
18003
18004 *) using the ratio(s) defined in display-pixels-per-inch.
18005
18006 ELEMENT ::=
18007
18008 left-fringe - left fringe width in pixels
18009 (left-fringe . nil) - left fringe width if inside margins, else 0
18010 (left-fringe . t) - left fringe width if outside margins, else 0
18011
18012 right-fringe - right fringe width in pixels
18013 (right-fringe . nil) - right fringe width if inside margins, else 0
18014 (right-fringe . t) - right fringe width if outside margins, else 0
18015
18016 left-margin - left margin width in pixels
18017 right-margin - right margin width in pixels
18018
18019 scroll-bar - scroll-bar area width in pixels
18020 (scroll-bar . left) - scroll-bar width if on left, else 0
18021 (scroll-bar . right) - scroll-bar width if on right, else 0
18022
18023 Examples:
18024
18025 Pixels corresponding to 5 inches:
18026 (5 . in)
18027
18028 Total width of non-text areas on left side of window:
18029 (+ left-fringe left-margin (scroll-bar . left))
18030
18031 Total width of fringes if inside display margins:
18032 (+ (left-fringe) (right-fringe))
18033
18034 Width of left margin minus width of 1 character in the default font:
18035 (- left-margin 1)
18036
18037 Width of left margin minus width of 2 characters in the current font:
18038 (- left-margin (2 . width))
18039
18040 Width of left fringe plus left margin minus one pixel:
18041 (- (+ left-fringe left-margin) (1))
18042 (+ left-fringe left-margin (- (1)))
18043 (+ left-fringe left-margin (-1))
18044
18045*/
18046
18047#define NUMVAL(X) \
18048 ((INTEGERP (X) || FLOATP (X)) \
18049 ? XFLOATINT (X) \
18050 : - 1)
18051
18052static int
18053calc_pixel_width_or_height (res, it, prop, font, width_p)
18054 double *res;
18055 struct it *it;
18056 Lisp_Object prop;
18057 XFontStruct *font;
18058 int width_p;
18059{
18060 double pixels;
18061
18062#define OK_PIXELS(val) ((*res = (val)), 1)
18063
18064 if (SYMBOLP (prop))
18065 {
18066 if (SCHARS (SYMBOL_NAME (prop)) == 2)
18067 {
18068 char *unit = SDATA (SYMBOL_NAME (prop));
18069
18070 if (unit[0] == 'i' && unit[1] == 'n')
18071 pixels = 1.0;
18072 else if (unit[0] == 'm' && unit[1] == 'm')
18073 pixels = 25.4;
18074 else if (unit[0] == 'c' && unit[1] == 'm')
18075 pixels = 2.54;
18076 else
18077 pixels = 0;
18078 if (pixels > 0)
18079 {
18080 double ppi;
18081 if ((ppi = NUMVAL (Vdisplay_pixels_per_inch), ppi > 0)
18082 || (CONSP (Vdisplay_pixels_per_inch)
18083 && (ppi = (width_p
18084 ? NUMVAL (XCAR (Vdisplay_pixels_per_inch))
18085 : NUMVAL (XCDR (Vdisplay_pixels_per_inch))),
18086 ppi > 0)))
18087 return OK_PIXELS (ppi / pixels);
18088
18089 return 0;
18090 }
18091 }
18092
18093 if (EQ (prop, Qheight))
18094 return OK_PIXELS (font ? FONT_HEIGHT (font) : FRAME_LINE_HEIGHT (it->f));
18095 if (EQ (prop, Qwidth))
18096 return OK_PIXELS (font ? FONT_WIDTH (font) : FRAME_COLUMN_WIDTH (it->f));
18097 if (EQ (prop, Qleft_fringe))
18098 return OK_PIXELS (WINDOW_LEFT_FRINGE_WIDTH (it->w));
18099 if (EQ (prop, Qright_fringe))
18100 return OK_PIXELS (WINDOW_RIGHT_FRINGE_WIDTH (it->w));
18101 if (EQ (prop, Qleft_margin))
18102 return OK_PIXELS (WINDOW_LEFT_MARGIN_WIDTH (it->w));
18103 if (EQ (prop, Qright_margin))
18104 return OK_PIXELS (WINDOW_RIGHT_MARGIN_WIDTH (it->w));
18105 if (EQ (prop, Qscroll_bar))
18106 return OK_PIXELS (WINDOW_SCROLL_BAR_AREA_WIDTH (it->w));
18107
18108 prop = Fbuffer_local_value (prop, it->w->buffer);
18109 }
18110
18111 if (INTEGERP (prop) || FLOATP (prop))
18112 {
18113 int base_unit = (width_p
18114 ? FRAME_COLUMN_WIDTH (it->f)
18115 : FRAME_LINE_HEIGHT (it->f));
18116 return OK_PIXELS (XFLOATINT (prop) * base_unit);
18117 }
18118
18119 if (CONSP (prop))
18120 {
18121 Lisp_Object car = XCAR (prop);
18122 Lisp_Object cdr = XCDR (prop);
18123
18124 if (SYMBOLP (car))
18125 {
18126 if (EQ (car, Qplus) || EQ (car, Qminus))
18127 {
18128 int first = 1;
18129 double px;
18130
18131 pixels = 0;
18132 while (CONSP (cdr))
18133 {
18134 if (!calc_pixel_width_or_height (&px, it, XCAR (cdr), font, width_p))
18135 return 0;
18136 if (first)
18137 pixels = (EQ (car, Qplus) ? px : -px), first = 0;
18138 else
18139 pixels += px;
18140 cdr = XCDR (cdr);
18141 }
18142 if (EQ (car, Qminus))
18143 pixels = -pixels;
18144 return OK_PIXELS (pixels);
18145 }
18146
18147 if (EQ (car, Qleft_fringe))
18148 return OK_PIXELS ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (it->w)
18149 == !NILP (cdr))
18150 ? WINDOW_LEFT_FRINGE_WIDTH (it->w)
18151 : 0);
18152 if (EQ (car, Qright_fringe))
18153 return OK_PIXELS ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (it->w)
18154 == !NILP (cdr))
18155 ? WINDOW_RIGHT_FRINGE_WIDTH (it->w)
18156 : 0);
18157 if (EQ (car, Qscroll_bar))
18158 return OK_PIXELS ((WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (it->w)
18159 == EQ (cdr, Qleft))
18160 ? WINDOW_SCROLL_BAR_AREA_WIDTH (it->w)
18161 : 0);
18162
18163 car = Fbuffer_local_value (car, it->w->buffer);
18164 }
18165
18166 if (INTEGERP (car) || FLOATP (car))
18167 {
18168 double fact;
18169 pixels = XFLOATINT (car);
18170 if (NILP (cdr))
18171 return OK_PIXELS (pixels);
18172 if (calc_pixel_width_or_height (&fact, it, cdr, font, width_p))
18173 return OK_PIXELS (pixels * fact);
18174 return 0;
18175 }
18176
18177 return 0;
18178 }
18179
18180 return 0;
18181}
18182
18183/* Produce a stretch glyph for iterator IT. IT->object is the value 18230/* Produce a stretch glyph for iterator IT. IT->object is the value
18184 of the glyph property displayed. The value must be a list 18231 of the glyph property displayed. The value must be a list
18185 `(space KEYWORD VALUE ...)' with the following KEYWORD/VALUE pairs 18232 `(space KEYWORD VALUE ...)' with the following KEYWORD/VALUE pairs
@@ -18217,7 +18264,7 @@ produce_stretch_glyph (it)
18217{ 18264{
18218 /* (space :width WIDTH :height HEIGHT ...) */ 18265 /* (space :width WIDTH :height HEIGHT ...) */
18219 Lisp_Object prop, plist; 18266 Lisp_Object prop, plist;
18220 int width = 0, height = 0; 18267 int width = 0, height = 0, align_to = -1;
18221 int zero_width_ok_p = 0, zero_height_ok_p = 0; 18268 int zero_width_ok_p = 0, zero_height_ok_p = 0;
18222 int ascent = 0; 18269 int ascent = 0;
18223 double tem; 18270 double tem;
@@ -18232,7 +18279,7 @@ produce_stretch_glyph (it)
18232 18279
18233 /* Compute the width of the stretch. */ 18280 /* Compute the width of the stretch. */
18234 if ((prop = Fplist_get (plist, QCwidth), !NILP (prop)) 18281 if ((prop = Fplist_get (plist, QCwidth), !NILP (prop))
18235 && calc_pixel_width_or_height (&tem, it, prop, font, 1)) 18282 && calc_pixel_width_or_height (&tem, it, prop, font, 1, 0))
18236 { 18283 {
18237 /* Absolute width `:width WIDTH' specified and valid. */ 18284 /* Absolute width `:width WIDTH' specified and valid. */
18238 zero_width_ok_p = 1; 18285 zero_width_ok_p = 1;
@@ -18263,9 +18310,15 @@ produce_stretch_glyph (it)
18263 width = NUMVAL (prop) * it2.pixel_width; 18310 width = NUMVAL (prop) * it2.pixel_width;
18264 } 18311 }
18265 else if ((prop = Fplist_get (plist, QCalign_to), !NILP (prop)) 18312 else if ((prop = Fplist_get (plist, QCalign_to), !NILP (prop))
18266 && calc_pixel_width_or_height (&tem, it, prop, font, 1)) 18313 && calc_pixel_width_or_height (&tem, it, prop, font, 1, &align_to))
18267 { 18314 {
18268 width = max (0, (int)tem - it->current_x); 18315 if (it->glyph_row == NULL || !it->glyph_row->mode_line_p)
18316 align_to = (align_to < 0
18317 ? 0
18318 : align_to - window_box_left_offset (it->w, TEXT_AREA));
18319 else if (align_to < 0)
18320 align_to = window_box_left_offset (it->w, TEXT_AREA);
18321 width = max (0, (int)tem + align_to - it->current_x);
18269 zero_width_ok_p = 1; 18322 zero_width_ok_p = 1;
18270 } 18323 }
18271 else 18324 else
@@ -18277,7 +18330,7 @@ produce_stretch_glyph (it)
18277 18330
18278 /* Compute height. */ 18331 /* Compute height. */
18279 if ((prop = Fplist_get (plist, QCheight), !NILP (prop)) 18332 if ((prop = Fplist_get (plist, QCheight), !NILP (prop))
18280 && calc_pixel_width_or_height (&tem, it, prop, font, 0)) 18333 && calc_pixel_width_or_height (&tem, it, prop, font, 0, 0))
18281 { 18334 {
18282 height = (int)tem; 18335 height = (int)tem;
18283 zero_height_ok_p = 1; 18336 zero_height_ok_p = 1;
@@ -18298,7 +18351,7 @@ produce_stretch_glyph (it)
18298 NUMVAL (prop) > 0 && NUMVAL (prop) <= 100) 18351 NUMVAL (prop) > 0 && NUMVAL (prop) <= 100)
18299 ascent = height * NUMVAL (prop) / 100.0; 18352 ascent = height * NUMVAL (prop) / 100.0;
18300 else if (!NILP (prop) 18353 else if (!NILP (prop)
18301 && calc_pixel_width_or_height (&tem, it, prop, font, 0)) 18354 && calc_pixel_width_or_height (&tem, it, prop, font, 0, 0))
18302 ascent = min (max (0, (int)tem), height); 18355 ascent = min (max (0, (int)tem), height);
18303 else 18356 else
18304 ascent = (height * FONT_BASE (font)) / FONT_HEIGHT (font); 18357 ascent = (height * FONT_BASE (font)) / FONT_HEIGHT (font);
@@ -21522,6 +21575,8 @@ syms_of_xdisp ()
21522 staticpro (&Qleft_margin); 21575 staticpro (&Qleft_margin);
21523 Qright_margin = intern ("right-margin"); 21576 Qright_margin = intern ("right-margin");
21524 staticpro (&Qright_margin); 21577 staticpro (&Qright_margin);
21578 Qcenter = intern ("center");
21579 staticpro (&Qcenter);
21525 QCalign_to = intern (":align-to"); 21580 QCalign_to = intern (":align-to");
21526 staticpro (&QCalign_to); 21581 staticpro (&QCalign_to);
21527 QCrelative_width = intern (":relative-width"); 21582 QCrelative_width = intern (":relative-width");
diff --git a/src/xterm.c b/src/xterm.c
index 86feb9ccf57..a297faa2ac0 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -6225,6 +6225,14 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6225 Lisp_Object coding_system = Qlatin_1; 6225 Lisp_Object coding_system = Qlatin_1;
6226 Lisp_Object c; 6226 Lisp_Object c;
6227 6227
6228#ifdef USE_GTK
6229 /* Don't pass keys to GTK. A Tab will shift focus to the
6230 tool bar in GTK 2.4. Keys will still go to menus and
6231 dialogs because in that case popup_activated is TRUE
6232 (see above). */
6233 *finish = X_EVENT_DROP;
6234#endif
6235
6228 event.xkey.state 6236 event.xkey.state
6229 |= x_emacs_to_x_modifiers (FRAME_X_DISPLAY_INFO (f), 6237 |= x_emacs_to_x_modifiers (FRAME_X_DISPLAY_INFO (f),
6230 extra_keyboard_modifiers); 6238 extra_keyboard_modifiers);