diff options
| author | Kenichi Handa | 2004-04-16 12:51:06 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2004-04-16 12:51:06 +0000 |
| commit | 6b61353c0a0320ee15bb6488149735381fed62ec (patch) | |
| tree | e69adba60e504a5a37beb556ad70084de88a7aab /src/term.c | |
| parent | dc6a28319312fe81f7a1015e363174022313f0bd (diff) | |
| download | emacs-6b61353c0a0320ee15bb6488149735381fed62ec.tar.gz emacs-6b61353c0a0320ee15bb6488149735381fed62ec.zip | |
Sync to HEAD
Diffstat (limited to 'src/term.c')
| -rw-r--r-- | src/term.c | 127 |
1 files changed, 111 insertions, 16 deletions
diff --git a/src/term.c b/src/term.c index d4432a26316..609efcb8439 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -81,6 +81,10 @@ static void tty_hide_cursor P_ ((void)); | |||
| 81 | 81 | ||
| 82 | #define OUTPUT1_IF(a) do { if (a) tputs (a, 1, cmputc); } while (0) | 82 | #define OUTPUT1_IF(a) do { if (a) tputs (a, 1, cmputc); } while (0) |
| 83 | 83 | ||
| 84 | /* Display space properties */ | ||
| 85 | |||
| 86 | extern Lisp_Object Qspace, QCalign_to, QCwidth; | ||
| 87 | |||
| 84 | /* Function to use to ring the bell. */ | 88 | /* Function to use to ring the bell. */ |
| 85 | 89 | ||
| 86 | Lisp_Object Vring_bell_function; | 90 | Lisp_Object Vring_bell_function; |
| @@ -133,7 +137,7 @@ void (*insert_glyphs_hook) P_ ((struct glyph *, int)); | |||
| 133 | void (*write_glyphs_hook) P_ ((struct glyph *, int)); | 137 | void (*write_glyphs_hook) P_ ((struct glyph *, int)); |
| 134 | void (*delete_glyphs_hook) P_ ((int)); | 138 | void (*delete_glyphs_hook) P_ ((int)); |
| 135 | 139 | ||
| 136 | int (*read_socket_hook) P_ ((int, struct input_event *, int, int)); | 140 | int (*read_socket_hook) P_ ((int, int, struct input_event *)); |
| 137 | 141 | ||
| 138 | void (*frame_up_to_date_hook) P_ ((struct frame *)); | 142 | void (*frame_up_to_date_hook) P_ ((struct frame *)); |
| 139 | 143 | ||
| @@ -1584,6 +1588,7 @@ term_get_fkeys_1 () | |||
| 1584 | ***********************************************************************/ | 1588 | ***********************************************************************/ |
| 1585 | 1589 | ||
| 1586 | static void append_glyph P_ ((struct it *)); | 1590 | static void append_glyph P_ ((struct it *)); |
| 1591 | static void produce_stretch_glyph P_ ((struct it *)); | ||
| 1587 | 1592 | ||
| 1588 | 1593 | ||
| 1589 | /* Append glyphs to IT's glyph_row. Called from produce_glyphs for | 1594 | /* Append glyphs to IT's glyph_row. Called from produce_glyphs for |
| @@ -1647,9 +1652,14 @@ produce_glyphs (it) | |||
| 1647 | /* If a hook is installed, let it do the work. */ | 1652 | /* If a hook is installed, let it do the work. */ |
| 1648 | xassert (it->what == IT_CHARACTER | 1653 | xassert (it->what == IT_CHARACTER |
| 1649 | || it->what == IT_COMPOSITION | 1654 | || it->what == IT_COMPOSITION |
| 1650 | || it->what == IT_IMAGE | ||
| 1651 | || it->what == IT_STRETCH); | 1655 | || it->what == IT_STRETCH); |
| 1652 | 1656 | ||
| 1657 | if (it->what == IT_STRETCH) | ||
| 1658 | { | ||
| 1659 | produce_stretch_glyph (it); | ||
| 1660 | goto done; | ||
| 1661 | } | ||
| 1662 | |||
| 1653 | /* Nothing but characters are supported on terminal frames. For a | 1663 | /* Nothing but characters are supported on terminal frames. For a |
| 1654 | composition sequence, it->c is the first character of the | 1664 | composition sequence, it->c is the first character of the |
| 1655 | sequence. */ | 1665 | sequence. */ |
| @@ -1716,6 +1726,7 @@ produce_glyphs (it) | |||
| 1716 | append_glyph (it); | 1726 | append_glyph (it); |
| 1717 | } | 1727 | } |
| 1718 | 1728 | ||
| 1729 | done: | ||
| 1719 | /* Advance current_x by the pixel width as a convenience for | 1730 | /* Advance current_x by the pixel width as a convenience for |
| 1720 | the caller. */ | 1731 | the caller. */ |
| 1721 | if (it->area == TEXT_AREA) | 1732 | if (it->area == TEXT_AREA) |
| @@ -1725,6 +1736,81 @@ produce_glyphs (it) | |||
| 1725 | } | 1736 | } |
| 1726 | 1737 | ||
| 1727 | 1738 | ||
| 1739 | /* Produce a stretch glyph for iterator IT. IT->object is the value | ||
| 1740 | of the glyph property displayed. The value must be a list | ||
| 1741 | `(space KEYWORD VALUE ...)' with the following KEYWORD/VALUE pairs | ||
| 1742 | being recognized: | ||
| 1743 | |||
| 1744 | 1. `:width WIDTH' specifies that the space should be WIDTH * | ||
| 1745 | canonical char width wide. WIDTH may be an integer or floating | ||
| 1746 | point number. | ||
| 1747 | |||
| 1748 | 2. `:align-to HPOS' specifies that the space should be wide enough | ||
| 1749 | to reach HPOS, a value in canonical character units. */ | ||
| 1750 | |||
| 1751 | static void | ||
| 1752 | produce_stretch_glyph (it) | ||
| 1753 | struct it *it; | ||
| 1754 | { | ||
| 1755 | /* (space :width WIDTH ...) */ | ||
| 1756 | Lisp_Object prop, plist; | ||
| 1757 | int width = 0, align_to = -1; | ||
| 1758 | int zero_width_ok_p = 0; | ||
| 1759 | double tem; | ||
| 1760 | |||
| 1761 | /* List should start with `space'. */ | ||
| 1762 | xassert (CONSP (it->object) && EQ (XCAR (it->object), Qspace)); | ||
| 1763 | plist = XCDR (it->object); | ||
| 1764 | |||
| 1765 | /* Compute the width of the stretch. */ | ||
| 1766 | if ((prop = Fplist_get (plist, QCwidth), !NILP (prop)) | ||
| 1767 | && calc_pixel_width_or_height (&tem, it, prop, 0, 1, 0)) | ||
| 1768 | { | ||
| 1769 | /* Absolute width `:width WIDTH' specified and valid. */ | ||
| 1770 | zero_width_ok_p = 1; | ||
| 1771 | width = (int)(tem + 0.5); | ||
| 1772 | } | ||
| 1773 | else if ((prop = Fplist_get (plist, QCalign_to), !NILP (prop)) | ||
| 1774 | && calc_pixel_width_or_height (&tem, it, prop, 0, 1, &align_to)) | ||
| 1775 | { | ||
| 1776 | if (it->glyph_row == NULL || !it->glyph_row->mode_line_p) | ||
| 1777 | align_to = (align_to < 0 | ||
| 1778 | ? 0 | ||
| 1779 | : align_to - window_box_left_offset (it->w, TEXT_AREA)); | ||
| 1780 | else if (align_to < 0) | ||
| 1781 | align_to = window_box_left_offset (it->w, TEXT_AREA); | ||
| 1782 | width = max (0, (int)(tem + 0.5) + align_to - it->current_x); | ||
| 1783 | zero_width_ok_p = 1; | ||
| 1784 | } | ||
| 1785 | else | ||
| 1786 | /* Nothing specified -> width defaults to canonical char width. */ | ||
| 1787 | width = FRAME_COLUMN_WIDTH (it->f); | ||
| 1788 | |||
| 1789 | if (width <= 0 && (width < 0 || !zero_width_ok_p)) | ||
| 1790 | width = 1; | ||
| 1791 | |||
| 1792 | if (width > 0 && it->glyph_row) | ||
| 1793 | { | ||
| 1794 | Lisp_Object o_object = it->object; | ||
| 1795 | Lisp_Object object = it->stack[it->sp - 1].string; | ||
| 1796 | int n = width; | ||
| 1797 | int c = it->c; | ||
| 1798 | |||
| 1799 | if (!STRINGP (object)) | ||
| 1800 | object = it->w->buffer; | ||
| 1801 | it->object = object; | ||
| 1802 | it->c = ' '; | ||
| 1803 | it->pixel_width = it->len = 1; | ||
| 1804 | while (n--) | ||
| 1805 | append_glyph (it); | ||
| 1806 | it->object = o_object; | ||
| 1807 | it->c = c; | ||
| 1808 | } | ||
| 1809 | it->pixel_width = width; | ||
| 1810 | it->nglyphs = width; | ||
| 1811 | } | ||
| 1812 | |||
| 1813 | |||
| 1728 | /* Get information about special display element WHAT in an | 1814 | /* Get information about special display element WHAT in an |
| 1729 | environment described by IT. WHAT is one of IT_TRUNCATION or | 1815 | environment described by IT. WHAT is one of IT_TRUNCATION or |
| 1730 | IT_CONTINUATION. Maybe produce glyphs for WHAT if IT has a | 1816 | IT_CONTINUATION. Maybe produce glyphs for WHAT if IT has a |
| @@ -2048,6 +2134,10 @@ void | |||
| 2048 | tty_setup_colors (mode) | 2134 | tty_setup_colors (mode) |
| 2049 | int mode; | 2135 | int mode; |
| 2050 | { | 2136 | { |
| 2137 | /* Canonicalize all negative values of MODE. */ | ||
| 2138 | if (mode < -1) | ||
| 2139 | mode = -1; | ||
| 2140 | |||
| 2051 | switch (mode) | 2141 | switch (mode) |
| 2052 | { | 2142 | { |
| 2053 | case -1: /* no colors at all */ | 2143 | case -1: /* no colors at all */ |
| @@ -2090,7 +2180,7 @@ set_tty_color_mode (f, val) | |||
| 2090 | tty_color_mode_alist = Fintern_soft (build_string ("tty-color-mode-alist"), | 2180 | tty_color_mode_alist = Fintern_soft (build_string ("tty-color-mode-alist"), |
| 2091 | Qnil); | 2181 | Qnil); |
| 2092 | 2182 | ||
| 2093 | if (NATNUMP (val)) | 2183 | if (INTEGERP (val)) |
| 2094 | color_mode = val; | 2184 | color_mode = val; |
| 2095 | else | 2185 | else |
| 2096 | { | 2186 | { |
| @@ -2098,22 +2188,24 @@ set_tty_color_mode (f, val) | |||
| 2098 | color_mode_spec = Qnil; | 2188 | color_mode_spec = Qnil; |
| 2099 | else | 2189 | else |
| 2100 | color_mode_spec = Fassq (val, XSYMBOL (tty_color_mode_alist)->value); | 2190 | color_mode_spec = Fassq (val, XSYMBOL (tty_color_mode_alist)->value); |
| 2101 | current_mode_spec = assq_no_quit (Qtty_color_mode, f->param_alist); | ||
| 2102 | 2191 | ||
| 2103 | if (CONSP (color_mode_spec)) | 2192 | if (CONSP (color_mode_spec)) |
| 2104 | color_mode = XCDR (color_mode_spec); | 2193 | color_mode = XCDR (color_mode_spec); |
| 2105 | else | 2194 | else |
| 2106 | color_mode = Qnil; | 2195 | color_mode = Qnil; |
| 2107 | } | 2196 | } |
| 2197 | |||
| 2198 | current_mode_spec = assq_no_quit (Qtty_color_mode, f->param_alist); | ||
| 2199 | |||
| 2108 | if (CONSP (current_mode_spec)) | 2200 | if (CONSP (current_mode_spec)) |
| 2109 | current_mode = XCDR (current_mode_spec); | 2201 | current_mode = XCDR (current_mode_spec); |
| 2110 | else | 2202 | else |
| 2111 | current_mode = Qnil; | 2203 | current_mode = Qnil; |
| 2112 | if (NATNUMP (color_mode)) | 2204 | if (INTEGERP (color_mode)) |
| 2113 | mode = XINT (color_mode); | 2205 | mode = XINT (color_mode); |
| 2114 | else | 2206 | else |
| 2115 | mode = 0; /* meaning default */ | 2207 | mode = 0; /* meaning default */ |
| 2116 | if (NATNUMP (current_mode)) | 2208 | if (INTEGERP (current_mode)) |
| 2117 | old_mode = XINT (current_mode); | 2209 | old_mode = XINT (current_mode); |
| 2118 | else | 2210 | else |
| 2119 | old_mode = 0; | 2211 | old_mode = 0; |
| @@ -2141,7 +2233,8 @@ term_init (terminal_type) | |||
| 2141 | { | 2233 | { |
| 2142 | char *area; | 2234 | char *area; |
| 2143 | char **address = &area; | 2235 | char **address = &area; |
| 2144 | char buffer[2044]; | 2236 | char *buffer = NULL; |
| 2237 | int buffer_size = 4096; | ||
| 2145 | register char *p; | 2238 | register char *p; |
| 2146 | int status; | 2239 | int status; |
| 2147 | struct frame *sf = XFRAME (selected_frame); | 2240 | struct frame *sf = XFRAME (selected_frame); |
| @@ -2153,9 +2246,6 @@ term_init (terminal_type) | |||
| 2153 | 2246 | ||
| 2154 | area = (char *) xmalloc (2044); | 2247 | area = (char *) xmalloc (2044); |
| 2155 | 2248 | ||
| 2156 | if (area == 0) | ||
| 2157 | abort (); | ||
| 2158 | |||
| 2159 | FrameRows = FRAME_LINES (sf); | 2249 | FrameRows = FRAME_LINES (sf); |
| 2160 | FrameCols = FRAME_COLS (sf); | 2250 | FrameCols = FRAME_COLS (sf); |
| 2161 | specified_window = FRAME_LINES (sf); | 2251 | specified_window = FRAME_LINES (sf); |
| @@ -2184,6 +2274,7 @@ term_init (terminal_type) | |||
| 2184 | 2274 | ||
| 2185 | Wcm_clear (); | 2275 | Wcm_clear (); |
| 2186 | 2276 | ||
| 2277 | buffer = (char *) xmalloc (buffer_size); | ||
| 2187 | status = tgetent (buffer, terminal_type); | 2278 | status = tgetent (buffer, terminal_type); |
| 2188 | if (status < 0) | 2279 | if (status < 0) |
| 2189 | { | 2280 | { |
| @@ -2211,13 +2302,13 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | |||
| 2211 | terminal_type); | 2302 | terminal_type); |
| 2212 | #endif | 2303 | #endif |
| 2213 | } | 2304 | } |
| 2214 | #ifdef TERMINFO | 2305 | |
| 2215 | area = (char *) xmalloc (2044); | 2306 | #ifndef TERMINFO |
| 2216 | #else | 2307 | if (strlen (buffer) >= buffer_size) |
| 2217 | area = (char *) xmalloc (strlen (buffer)); | ||
| 2218 | #endif /* not TERMINFO */ | ||
| 2219 | if (area == 0) | ||
| 2220 | abort (); | 2308 | abort (); |
| 2309 | buffer_size = strlen (buffer); | ||
| 2310 | #endif | ||
| 2311 | area = (char *) xmalloc (buffer_size); | ||
| 2221 | 2312 | ||
| 2222 | TS_ins_line = tgetstr ("al", address); | 2313 | TS_ins_line = tgetstr ("al", address); |
| 2223 | TS_ins_multi_lines = tgetstr ("AL", address); | 2314 | TS_ins_multi_lines = tgetstr ("AL", address); |
| @@ -2550,6 +2641,8 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | |||
| 2550 | terminal_encode_buf_size = 1024; | 2641 | terminal_encode_buf_size = 1024; |
| 2551 | } | 2642 | } |
| 2552 | #endif /* WINDOWSNT */ | 2643 | #endif /* WINDOWSNT */ |
| 2644 | |||
| 2645 | xfree (buffer); | ||
| 2553 | } | 2646 | } |
| 2554 | 2647 | ||
| 2555 | /* VARARGS 1 */ | 2648 | /* VARARGS 1 */ |
| @@ -2585,3 +2678,5 @@ The function should accept no arguments. */); | |||
| 2585 | defsubr (&Stty_display_color_cells); | 2678 | defsubr (&Stty_display_color_cells); |
| 2586 | } | 2679 | } |
| 2587 | 2680 | ||
| 2681 | /* arch-tag: 498e7449-6f2e-45e2-91dd-b7d4ca488193 | ||
| 2682 | (do not change this comment) */ | ||