diff options
| author | Kim F. Storm | 2004-03-19 00:42:48 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2004-03-19 00:42:48 +0000 |
| commit | f46c2affad936c9b31862956f2328e4dd0eb2d1c (patch) | |
| tree | e11e57dac641c2eb60695e28b86fc7a22c29dfb8 /src | |
| parent | e1dfec150b4fab26b70456ad7fcbdc1561430ec5 (diff) | |
| download | emacs-f46c2affad936c9b31862956f2328e4dd0eb2d1c.tar.gz emacs-f46c2affad936c9b31862956f2328e4dd0eb2d1c.zip | |
(produce_glyphs): Handle IT_STRETCH.
(produce_stretch_glyph): New function to handle space width and
align-to display properties on non-window systems.
Diffstat (limited to 'src')
| -rw-r--r-- | src/term.c | 88 |
1 files changed, 87 insertions, 1 deletions
diff --git a/src/term.c b/src/term.c index 317318eb8bf..dc0e51cdf81 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -79,6 +79,10 @@ static void tty_hide_cursor P_ ((void)); | |||
| 79 | 79 | ||
| 80 | #define OUTPUT1_IF(a) do { if (a) tputs (a, 1, cmputc); } while (0) | 80 | #define OUTPUT1_IF(a) do { if (a) tputs (a, 1, cmputc); } while (0) |
| 81 | 81 | ||
| 82 | /* Display space properties */ | ||
| 83 | |||
| 84 | extern Lisp_Object Qspace, QCalign_to, QCwidth; | ||
| 85 | |||
| 82 | /* Function to use to ring the bell. */ | 86 | /* Function to use to ring the bell. */ |
| 83 | 87 | ||
| 84 | Lisp_Object Vring_bell_function; | 88 | Lisp_Object Vring_bell_function; |
| @@ -1595,6 +1599,7 @@ term_get_fkeys_1 () | |||
| 1595 | ***********************************************************************/ | 1599 | ***********************************************************************/ |
| 1596 | 1600 | ||
| 1597 | static void append_glyph P_ ((struct it *)); | 1601 | static void append_glyph P_ ((struct it *)); |
| 1602 | static void produce_stretch_glyph P_ ((struct it *)); | ||
| 1598 | 1603 | ||
| 1599 | 1604 | ||
| 1600 | /* Append glyphs to IT's glyph_row. Called from produce_glyphs for | 1605 | /* Append glyphs to IT's glyph_row. Called from produce_glyphs for |
| @@ -1658,9 +1663,14 @@ produce_glyphs (it) | |||
| 1658 | /* If a hook is installed, let it do the work. */ | 1663 | /* If a hook is installed, let it do the work. */ |
| 1659 | xassert (it->what == IT_CHARACTER | 1664 | xassert (it->what == IT_CHARACTER |
| 1660 | || it->what == IT_COMPOSITION | 1665 | || it->what == IT_COMPOSITION |
| 1661 | || it->what == IT_IMAGE | ||
| 1662 | || it->what == IT_STRETCH); | 1666 | || it->what == IT_STRETCH); |
| 1663 | 1667 | ||
| 1668 | if (it->what == IT_STRETCH) | ||
| 1669 | { | ||
| 1670 | produce_stretch_glyph (it); | ||
| 1671 | goto done; | ||
| 1672 | } | ||
| 1673 | |||
| 1664 | /* Nothing but characters are supported on terminal frames. For a | 1674 | /* Nothing but characters are supported on terminal frames. For a |
| 1665 | composition sequence, it->c is the first character of the | 1675 | composition sequence, it->c is the first character of the |
| 1666 | sequence. */ | 1676 | sequence. */ |
| @@ -1734,6 +1744,7 @@ produce_glyphs (it) | |||
| 1734 | append_glyph (it); | 1744 | append_glyph (it); |
| 1735 | } | 1745 | } |
| 1736 | 1746 | ||
| 1747 | done: | ||
| 1737 | /* Advance current_x by the pixel width as a convenience for | 1748 | /* Advance current_x by the pixel width as a convenience for |
| 1738 | the caller. */ | 1749 | the caller. */ |
| 1739 | if (it->area == TEXT_AREA) | 1750 | if (it->area == TEXT_AREA) |
| @@ -1743,6 +1754,81 @@ produce_glyphs (it) | |||
| 1743 | } | 1754 | } |
| 1744 | 1755 | ||
| 1745 | 1756 | ||
| 1757 | /* Produce a stretch glyph for iterator IT. IT->object is the value | ||
| 1758 | of the glyph property displayed. The value must be a list | ||
| 1759 | `(space KEYWORD VALUE ...)' with the following KEYWORD/VALUE pairs | ||
| 1760 | being recognized: | ||
| 1761 | |||
| 1762 | 1. `:width WIDTH' specifies that the space should be WIDTH * | ||
| 1763 | canonical char width wide. WIDTH may be an integer or floating | ||
| 1764 | point number. | ||
| 1765 | |||
| 1766 | 2. `:align-to HPOS' specifies that the space should be wide enough | ||
| 1767 | to reach HPOS, a value in canonical character units. */ | ||
| 1768 | |||
| 1769 | static void | ||
| 1770 | produce_stretch_glyph (it) | ||
| 1771 | struct it *it; | ||
| 1772 | { | ||
| 1773 | /* (space :width WIDTH ...) */ | ||
| 1774 | Lisp_Object prop, plist; | ||
| 1775 | int width = 0, align_to = -1; | ||
| 1776 | int zero_width_ok_p = 0; | ||
| 1777 | double tem; | ||
| 1778 | |||
| 1779 | /* List should start with `space'. */ | ||
| 1780 | xassert (CONSP (it->object) && EQ (XCAR (it->object), Qspace)); | ||
| 1781 | plist = XCDR (it->object); | ||
| 1782 | |||
| 1783 | /* Compute the width of the stretch. */ | ||
| 1784 | if ((prop = Fplist_get (plist, QCwidth), !NILP (prop)) | ||
| 1785 | && calc_pixel_width_or_height (&tem, it, prop, 0, 1, 0)) | ||
| 1786 | { | ||
| 1787 | /* Absolute width `:width WIDTH' specified and valid. */ | ||
| 1788 | zero_width_ok_p = 1; | ||
| 1789 | width = (int)(tem + 0.5); | ||
| 1790 | } | ||
| 1791 | else if ((prop = Fplist_get (plist, QCalign_to), !NILP (prop)) | ||
| 1792 | && calc_pixel_width_or_height (&tem, it, prop, 0, 1, &align_to)) | ||
| 1793 | { | ||
| 1794 | if (it->glyph_row == NULL || !it->glyph_row->mode_line_p) | ||
| 1795 | align_to = (align_to < 0 | ||
| 1796 | ? 0 | ||
| 1797 | : align_to - window_box_left_offset (it->w, TEXT_AREA)); | ||
| 1798 | else if (align_to < 0) | ||
| 1799 | align_to = window_box_left_offset (it->w, TEXT_AREA); | ||
| 1800 | width = max (0, (int)(tem + 0.5) + align_to - it->current_x); | ||
| 1801 | zero_width_ok_p = 1; | ||
| 1802 | } | ||
| 1803 | else | ||
| 1804 | /* Nothing specified -> width defaults to canonical char width. */ | ||
| 1805 | width = FRAME_COLUMN_WIDTH (it->f); | ||
| 1806 | |||
| 1807 | if (width <= 0 && (width < 0 || !zero_width_ok_p)) | ||
| 1808 | width = 1; | ||
| 1809 | |||
| 1810 | if (width > 0 && it->glyph_row) | ||
| 1811 | { | ||
| 1812 | Lisp_Object o_object = it->object; | ||
| 1813 | Lisp_Object object = it->stack[it->sp - 1].string; | ||
| 1814 | int n = width; | ||
| 1815 | int c = it->c; | ||
| 1816 | |||
| 1817 | if (!STRINGP (object)) | ||
| 1818 | object = it->w->buffer; | ||
| 1819 | it->object = object; | ||
| 1820 | it->c = ' '; | ||
| 1821 | it->pixel_width = it->len = 1; | ||
| 1822 | while (n--) | ||
| 1823 | append_glyph (it); | ||
| 1824 | it->object = o_object; | ||
| 1825 | it->c = c; | ||
| 1826 | } | ||
| 1827 | it->pixel_width = width; | ||
| 1828 | it->nglyphs = width; | ||
| 1829 | } | ||
| 1830 | |||
| 1831 | |||
| 1746 | /* Get information about special display element WHAT in an | 1832 | /* Get information about special display element WHAT in an |
| 1747 | environment described by IT. WHAT is one of IT_TRUNCATION or | 1833 | environment described by IT. WHAT is one of IT_TRUNCATION or |
| 1748 | IT_CONTINUATION. Maybe produce glyphs for WHAT if IT has a | 1834 | IT_CONTINUATION. Maybe produce glyphs for WHAT if IT has a |