aboutsummaryrefslogtreecommitdiffstats
path: root/src/term.c
diff options
context:
space:
mode:
authorKenichi Handa2012-07-17 07:25:00 +0900
committerKenichi Handa2012-07-17 07:25:00 +0900
commit69c41c4070c86baac11a627e9c3d366420aeb7cc (patch)
treee07fda92570b5e4f264c9a7869b57960940008f0 /src/term.c
parent8c536f15bf95916d56bb50495d22b7da7e09fff9 (diff)
parent758e556a7ab8f61c007e34310ba399a9aaf15362 (diff)
downloademacs-69c41c4070c86baac11a627e9c3d366420aeb7cc.tar.gz
emacs-69c41c4070c86baac11a627e9c3d366420aeb7cc.zip
merge trunk
Diffstat (limited to 'src/term.c')
-rw-r--r--src/term.c190
1 files changed, 69 insertions, 121 deletions
diff --git a/src/term.c b/src/term.c
index 3d7a677374c..4d73f896d21 100644
--- a/src/term.c
+++ b/src/term.c
@@ -24,6 +24,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
24#include <ctype.h> 24#include <ctype.h>
25#include <errno.h> 25#include <errno.h>
26#include <sys/file.h> 26#include <sys/file.h>
27#include <sys/time.h>
27#include <unistd.h> 28#include <unistd.h>
28#include <signal.h> 29#include <signal.h>
29#include <setjmp.h> 30#include <setjmp.h>
@@ -32,8 +33,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
32#include "termchar.h" 33#include "termchar.h"
33#include "termopts.h" 34#include "termopts.h"
34#include "tparam.h" 35#include "tparam.h"
35#include "buffer.h"
36#include "character.h" 36#include "character.h"
37#include "buffer.h"
37#include "charset.h" 38#include "charset.h"
38#include "coding.h" 39#include "coding.h"
39#include "composite.h" 40#include "composite.h"
@@ -85,11 +86,11 @@ static void clear_tty_hooks (struct terminal *terminal);
85static void set_tty_hooks (struct terminal *terminal); 86static void set_tty_hooks (struct terminal *terminal);
86static void dissociate_if_controlling_tty (int fd); 87static void dissociate_if_controlling_tty (int fd);
87static void delete_tty (struct terminal *); 88static void delete_tty (struct terminal *);
88static void maybe_fatal (int must_succeed, struct terminal *terminal, 89static _Noreturn void maybe_fatal (int must_succeed, struct terminal *terminal,
89 const char *str1, const char *str2, ...) 90 const char *str1, const char *str2, ...)
90 NO_RETURN ATTRIBUTE_FORMAT_PRINTF (3, 5) ATTRIBUTE_FORMAT_PRINTF (4, 5); 91 ATTRIBUTE_FORMAT_PRINTF (3, 5) ATTRIBUTE_FORMAT_PRINTF (4, 5);
91static void vfatal (const char *str, va_list ap) 92static _Noreturn void vfatal (const char *str, va_list ap)
92 NO_RETURN ATTRIBUTE_FORMAT_PRINTF (1, 0); 93 ATTRIBUTE_FORMAT_PRINTF (1, 0);
93 94
94 95
95#define OUTPUT(tty, a) \ 96#define OUTPUT(tty, a) \
@@ -122,12 +123,11 @@ enum no_color_bit
122 NC_STANDOUT = 1 << 0, 123 NC_STANDOUT = 1 << 0,
123 NC_UNDERLINE = 1 << 1, 124 NC_UNDERLINE = 1 << 1,
124 NC_REVERSE = 1 << 2, 125 NC_REVERSE = 1 << 2,
125 NC_BLINK = 1 << 3, 126 NC_ITALIC = 1 << 3,
126 NC_DIM = 1 << 4, 127 NC_DIM = 1 << 4,
127 NC_BOLD = 1 << 5, 128 NC_BOLD = 1 << 5,
128 NC_INVIS = 1 << 6, 129 NC_INVIS = 1 << 6,
129 NC_PROTECT = 1 << 7, 130 NC_PROTECT = 1 << 7
130 NC_ALT_CHARSET = 1 << 8
131}; 131};
132 132
133/* internal state */ 133/* internal state */
@@ -1459,7 +1459,7 @@ append_glyph (struct it *it)
1459 struct glyph *glyph, *end; 1459 struct glyph *glyph, *end;
1460 int i; 1460 int i;
1461 1461
1462 xassert (it->glyph_row); 1462 eassert (it->glyph_row);
1463 glyph = (it->glyph_row->glyphs[it->area] 1463 glyph = (it->glyph_row->glyphs[it->area]
1464 + it->glyph_row->used[it->area]); 1464 + it->glyph_row->used[it->area]);
1465 end = it->glyph_row->glyphs[1 + it->area]; 1465 end = it->glyph_row->glyphs[1 + it->area];
@@ -1546,7 +1546,7 @@ produce_glyphs (struct it *it)
1546 /* If a hook is installed, let it do the work. */ 1546 /* If a hook is installed, let it do the work. */
1547 1547
1548 /* Nothing but characters are supported on terminal frames. */ 1548 /* Nothing but characters are supported on terminal frames. */
1549 xassert (it->what == IT_CHARACTER 1549 eassert (it->what == IT_CHARACTER
1550 || it->what == IT_COMPOSITION 1550 || it->what == IT_COMPOSITION
1551 || it->what == IT_STRETCH 1551 || it->what == IT_STRETCH
1552 || it->what == IT_GLYPHLESS); 1552 || it->what == IT_GLYPHLESS);
@@ -1633,7 +1633,7 @@ produce_glyphs (struct it *it)
1633 { 1633 {
1634 Lisp_Object acronym = lookup_glyphless_char_display (-1, it); 1634 Lisp_Object acronym = lookup_glyphless_char_display (-1, it);
1635 1635
1636 xassert (it->what == IT_GLYPHLESS); 1636 eassert (it->what == IT_GLYPHLESS);
1637 produce_glyphless_glyph (it, 1, acronym); 1637 produce_glyphless_glyph (it, 1, acronym);
1638 } 1638 }
1639 } 1639 }
@@ -1657,7 +1657,7 @@ append_composite_glyph (struct it *it)
1657{ 1657{
1658 struct glyph *glyph; 1658 struct glyph *glyph;
1659 1659
1660 xassert (it->glyph_row); 1660 eassert (it->glyph_row);
1661 glyph = it->glyph_row->glyphs[it->area] + it->glyph_row->used[it->area]; 1661 glyph = it->glyph_row->glyphs[it->area] + it->glyph_row->used[it->area];
1662 if (glyph < it->glyph_row->glyphs[1 + it->area]) 1662 if (glyph < it->glyph_row->glyphs[1 + it->area])
1663 { 1663 {
@@ -1749,7 +1749,7 @@ append_glyphless_glyph (struct it *it, int face_id, const char *str)
1749 struct glyph *glyph, *end; 1749 struct glyph *glyph, *end;
1750 int i; 1750 int i;
1751 1751
1752 xassert (it->glyph_row); 1752 eassert (it->glyph_row);
1753 glyph = it->glyph_row->glyphs[it->area] + it->glyph_row->used[it->area]; 1753 glyph = it->glyph_row->glyphs[it->area] + it->glyph_row->used[it->area];
1754 end = it->glyph_row->glyphs[1 + it->area]; 1754 end = it->glyph_row->glyphs[1 + it->area];
1755 1755
@@ -1851,8 +1851,7 @@ produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym)
1851 len = 1; 1851 len = 1;
1852 else if (len > 4) 1852 else if (len > 4)
1853 len = 4; 1853 len = 4;
1854 sprintf (buf, "[%.*s]", len, str); 1854 len = sprintf (buf, "[%.*s]", len, str);
1855 len += 2;
1856 str = buf; 1855 str = buf;
1857 } 1856 }
1858 else 1857 else
@@ -1872,7 +1871,7 @@ produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym)
1872 } 1871 }
1873 else 1872 else
1874 { 1873 {
1875 xassert (it->glyphless_method == GLYPHLESS_DISPLAY_HEX_CODE); 1874 eassert (it->glyphless_method == GLYPHLESS_DISPLAY_HEX_CODE);
1876 len = (it->c < 0x10000 ? sprintf (buf, "\\u%04X", it->c) 1875 len = (it->c < 0x10000 ? sprintf (buf, "\\u%04X", it->c)
1877 : it->c <= MAX_UNICODE_CHAR ? sprintf (buf, "\\U%06X", it->c) 1876 : it->c <= MAX_UNICODE_CHAR ? sprintf (buf, "\\U%06X", it->c)
1878 : sprintf (buf, "\\x%06X", it->c)); 1877 : sprintf (buf, "\\x%06X", it->c));
@@ -1886,67 +1885,6 @@ produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym)
1886 append_glyphless_glyph (it, face_id, str); 1885 append_glyphless_glyph (it, face_id, str);
1887} 1886}
1888 1887
1889
1890/* Get information about special display element WHAT in an
1891 environment described by IT. WHAT is one of IT_TRUNCATION or
1892 IT_CONTINUATION. Maybe produce glyphs for WHAT if IT has a
1893 non-null glyph_row member. This function ensures that fields like
1894 face_id, c, len of IT are left untouched. */
1895
1896void
1897produce_special_glyphs (struct it *it, enum display_element_type what)
1898{
1899 struct it temp_it;
1900 Lisp_Object gc;
1901 GLYPH glyph;
1902
1903 temp_it = *it;
1904 temp_it.dp = NULL;
1905 temp_it.what = IT_CHARACTER;
1906 temp_it.len = 1;
1907 temp_it.object = make_number (0);
1908 memset (&temp_it.current, 0, sizeof temp_it.current);
1909
1910 if (what == IT_CONTINUATION)
1911 {
1912 /* Continuation glyph. For R2L lines, we mirror it by hand. */
1913 if (it->bidi_it.paragraph_dir == R2L)
1914 SET_GLYPH_FROM_CHAR (glyph, '/');
1915 else
1916 SET_GLYPH_FROM_CHAR (glyph, '\\');
1917 if (it->dp
1918 && (gc = DISP_CONTINUE_GLYPH (it->dp), GLYPH_CODE_P (gc)))
1919 {
1920 /* FIXME: Should we mirror GC for R2L lines? */
1921 SET_GLYPH_FROM_GLYPH_CODE (glyph, gc);
1922 spec_glyph_lookup_face (XWINDOW (it->window), &glyph);
1923 }
1924 }
1925 else if (what == IT_TRUNCATION)
1926 {
1927 /* Truncation glyph. */
1928 SET_GLYPH_FROM_CHAR (glyph, '$');
1929 if (it->dp
1930 && (gc = DISP_TRUNC_GLYPH (it->dp), GLYPH_CODE_P (gc)))
1931 {
1932 /* FIXME: Should we mirror GC for R2L lines? */
1933 SET_GLYPH_FROM_GLYPH_CODE (glyph, gc);
1934 spec_glyph_lookup_face (XWINDOW (it->window), &glyph);
1935 }
1936 }
1937 else
1938 abort ();
1939
1940 temp_it.c = temp_it.char_to_display = GLYPH_CHAR (glyph);
1941 temp_it.face_id = GLYPH_FACE (glyph);
1942 temp_it.len = CHAR_BYTES (temp_it.c);
1943
1944 produce_glyphs (&temp_it);
1945 it->pixel_width = temp_it.pixel_width;
1946 it->nglyphs = temp_it.pixel_width;
1947}
1948
1949
1950 1888
1951/*********************************************************************** 1889/***********************************************************************
1952 Faces 1890 Faces
@@ -2022,17 +1960,16 @@ turn_on_face (struct frame *f, int face_id)
2022 if (face->tty_bold_p && MAY_USE_WITH_COLORS_P (tty, NC_BOLD)) 1960 if (face->tty_bold_p && MAY_USE_WITH_COLORS_P (tty, NC_BOLD))
2023 OUTPUT1_IF (tty, tty->TS_enter_bold_mode); 1961 OUTPUT1_IF (tty, tty->TS_enter_bold_mode);
2024 1962
2025 if (face->tty_dim_p && MAY_USE_WITH_COLORS_P (tty, NC_DIM)) 1963 if (face->tty_italic_p && MAY_USE_WITH_COLORS_P (tty, NC_ITALIC))
2026 OUTPUT1_IF (tty, tty->TS_enter_dim_mode); 1964 {
2027 1965 if (tty->TS_enter_italic_mode)
2028 /* Alternate charset and blinking not yet used. */ 1966 OUTPUT1 (tty, tty->TS_enter_italic_mode);
2029 if (face->tty_alt_charset_p 1967 else
2030 && MAY_USE_WITH_COLORS_P (tty, NC_ALT_CHARSET)) 1968 /* Italics mode is unavailable on many terminals. In that
2031 OUTPUT1_IF (tty, tty->TS_enter_alt_charset_mode); 1969 case, map slant to dimmed text; we want italic text to
2032 1970 appear different and dimming is not otherwise used. */
2033 if (face->tty_blinking_p 1971 OUTPUT1 (tty, tty->TS_enter_dim_mode);
2034 && MAY_USE_WITH_COLORS_P (tty, NC_BLINK)) 1972 }
2035 OUTPUT1_IF (tty, tty->TS_enter_blink_mode);
2036 1973
2037 if (face->tty_underline_p && MAY_USE_WITH_COLORS_P (tty, NC_UNDERLINE)) 1974 if (face->tty_underline_p && MAY_USE_WITH_COLORS_P (tty, NC_UNDERLINE))
2038 OUTPUT1_IF (tty, tty->TS_enter_underline_mode); 1975 OUTPUT1_IF (tty, tty->TS_enter_underline_mode);
@@ -2069,7 +2006,7 @@ turn_off_face (struct frame *f, int face_id)
2069 struct face *face = FACE_FROM_ID (f, face_id); 2006 struct face *face = FACE_FROM_ID (f, face_id);
2070 struct tty_display_info *tty = FRAME_TTY (f); 2007 struct tty_display_info *tty = FRAME_TTY (f);
2071 2008
2072 xassert (face != NULL); 2009 eassert (face != NULL);
2073 2010
2074 if (tty->TS_exit_attribute_mode) 2011 if (tty->TS_exit_attribute_mode)
2075 { 2012 {
@@ -2077,27 +2014,19 @@ turn_off_face (struct frame *f, int face_id)
2077 half-bright, reverse-video, standout, underline. It may or 2014 half-bright, reverse-video, standout, underline. It may or
2078 may not turn off alt-char-mode. */ 2015 may not turn off alt-char-mode. */
2079 if (face->tty_bold_p 2016 if (face->tty_bold_p
2080 || face->tty_dim_p 2017 || face->tty_italic_p
2081 || face->tty_reverse_p 2018 || face->tty_reverse_p
2082 || face->tty_alt_charset_p
2083 || face->tty_blinking_p
2084 || face->tty_underline_p) 2019 || face->tty_underline_p)
2085 { 2020 {
2086 OUTPUT1_IF (tty, tty->TS_exit_attribute_mode); 2021 OUTPUT1_IF (tty, tty->TS_exit_attribute_mode);
2087 if (strcmp (tty->TS_exit_attribute_mode, tty->TS_end_standout_mode) == 0) 2022 if (strcmp (tty->TS_exit_attribute_mode, tty->TS_end_standout_mode) == 0)
2088 tty->standout_mode = 0; 2023 tty->standout_mode = 0;
2089 } 2024 }
2090
2091 if (face->tty_alt_charset_p)
2092 OUTPUT_IF (tty, tty->TS_exit_alt_charset_mode);
2093 } 2025 }
2094 else 2026 else
2095 { 2027 {
2096 /* If we don't have "me" we can only have those appearances 2028 /* If we don't have "me" we can only have those appearances
2097 that have exit sequences defined. */ 2029 that have exit sequences defined. */
2098 if (face->tty_alt_charset_p)
2099 OUTPUT_IF (tty, tty->TS_exit_alt_charset_mode);
2100
2101 if (face->tty_underline_p) 2030 if (face->tty_underline_p)
2102 OUTPUT_IF (tty, tty->TS_exit_underline_mode); 2031 OUTPUT_IF (tty, tty->TS_exit_underline_mode);
2103 } 2032 }
@@ -2128,8 +2057,7 @@ tty_capable_p (struct tty_display_info *tty, unsigned int caps,
2128 TTY_CAPABLE_P_TRY (tty, TTY_CAP_UNDERLINE, tty->TS_enter_underline_mode, NC_UNDERLINE); 2057 TTY_CAPABLE_P_TRY (tty, TTY_CAP_UNDERLINE, tty->TS_enter_underline_mode, NC_UNDERLINE);
2129 TTY_CAPABLE_P_TRY (tty, TTY_CAP_BOLD, tty->TS_enter_bold_mode, NC_BOLD); 2058 TTY_CAPABLE_P_TRY (tty, TTY_CAP_BOLD, tty->TS_enter_bold_mode, NC_BOLD);
2130 TTY_CAPABLE_P_TRY (tty, TTY_CAP_DIM, tty->TS_enter_dim_mode, NC_DIM); 2059 TTY_CAPABLE_P_TRY (tty, TTY_CAP_DIM, tty->TS_enter_dim_mode, NC_DIM);
2131 TTY_CAPABLE_P_TRY (tty, TTY_CAP_BLINK, tty->TS_enter_blink_mode, NC_BLINK); 2060 TTY_CAPABLE_P_TRY (tty, TTY_CAP_ITALIC, tty->TS_enter_italic_mode, NC_ITALIC);
2132 TTY_CAPABLE_P_TRY (tty, TTY_CAP_ALT_CHARSET, tty->TS_enter_alt_charset_mode, NC_ALT_CHARSET);
2133 2061
2134 /* We can do it! */ 2062 /* We can do it! */
2135 return 1; 2063 return 1;
@@ -2143,7 +2071,7 @@ DEFUN ("tty-display-color-p", Ftty_display_color_p, Stty_display_color_p,
2143 2071
2144TERMINAL can be a terminal object, a frame, or nil (meaning the 2072TERMINAL can be a terminal object, a frame, or nil (meaning the
2145selected frame's terminal). This function always returns nil if 2073selected frame's terminal). This function always returns nil if
2146TERMINAL does not refer to a text-only terminal. */) 2074TERMINAL does not refer to a text terminal. */)
2147 (Lisp_Object terminal) 2075 (Lisp_Object terminal)
2148{ 2076{
2149 struct terminal *t = get_tty_terminal (terminal, 0); 2077 struct terminal *t = get_tty_terminal (terminal, 0);
@@ -2160,7 +2088,7 @@ DEFUN ("tty-display-color-cells", Ftty_display_color_cells,
2160 2088
2161TERMINAL can be a terminal object, a frame, or nil (meaning the 2089TERMINAL can be a terminal object, a frame, or nil (meaning the
2162selected frame's terminal). This function always returns 0 if 2090selected frame's terminal). This function always returns 0 if
2163TERMINAL does not refer to a text-only terminal. */) 2091TERMINAL does not refer to a text terminal. */)
2164 (Lisp_Object terminal) 2092 (Lisp_Object terminal)
2165{ 2093{
2166 struct terminal *t = get_tty_terminal (terminal, 0); 2094 struct terminal *t = get_tty_terminal (terminal, 0);
@@ -2382,7 +2310,7 @@ no effect if used on a non-tty terminal.
2382 2310
2383TERMINAL can be a terminal object, a frame or nil (meaning the 2311TERMINAL can be a terminal object, a frame or nil (meaning the
2384selected frame's terminal). This function always returns nil if 2312selected frame's terminal). This function always returns nil if
2385TERMINAL does not refer to a text-only terminal. */) 2313TERMINAL does not refer to a text terminal. */)
2386 (Lisp_Object terminal) 2314 (Lisp_Object terminal)
2387{ 2315{
2388 struct terminal *t = get_terminal (terminal, 1); 2316 struct terminal *t = get_terminal (terminal, 1);
@@ -2392,6 +2320,21 @@ TERMINAL does not refer to a text-only terminal. */)
2392 return Qnil; 2320 return Qnil;
2393} 2321}
2394 2322
2323DEFUN ("tty-top-frame", Ftty_top_frame, Stty_top_frame, 0, 1, 0,
2324 doc: /* Return the topmost terminal frame on TERMINAL.
2325TERMINAL can be a terminal object, a frame or nil (meaning the
2326selected frame's terminal). This function returns nil if TERMINAL
2327does not refer to a text terminal. Otherwise, it returns the
2328top-most frame on the text terminal. */)
2329 (Lisp_Object terminal)
2330{
2331 struct terminal *t = get_terminal (terminal, 1);
2332
2333 if (t->type == output_termcap)
2334 return t->display_info.tty->top_frame;
2335 return Qnil;
2336}
2337
2395 2338
2396 2339
2397DEFUN ("suspend-tty", Fsuspend_tty, Ssuspend_tty, 0, 1, 0, 2340DEFUN ("suspend-tty", Fsuspend_tty, Ssuspend_tty, 0, 1, 0,
@@ -2607,6 +2550,18 @@ term_mouse_movement (FRAME_PTR frame, Gpm_Event *event)
2607 return 0; 2550 return 0;
2608} 2551}
2609 2552
2553/* Return the Time that corresponds to T. Wrap around on overflow. */
2554static Time
2555timeval_to_Time (struct timeval const *t)
2556{
2557 Time s_1000, ms;
2558
2559 s_1000 = t->tv_sec;
2560 s_1000 *= 1000;
2561 ms = t->tv_usec / 1000;
2562 return s_1000 + ms;
2563}
2564
2610/* Return the current position of the mouse. 2565/* Return the current position of the mouse.
2611 2566
2612 Set *f to the frame the mouse is in, or zero if the mouse is in no 2567 Set *f to the frame the mouse is in, or zero if the mouse is in no
@@ -2626,7 +2581,6 @@ term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window,
2626 Lisp_Object *y, Time *timeptr) 2581 Lisp_Object *y, Time *timeptr)
2627{ 2582{
2628 struct timeval now; 2583 struct timeval now;
2629 Time sec, usec;
2630 2584
2631 *fp = SELECTED_FRAME (); 2585 *fp = SELECTED_FRAME ();
2632 (*fp)->mouse_moved = 0; 2586 (*fp)->mouse_moved = 0;
@@ -2637,9 +2591,7 @@ term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window,
2637 XSETINT (*x, last_mouse_x); 2591 XSETINT (*x, last_mouse_x);
2638 XSETINT (*y, last_mouse_y); 2592 XSETINT (*y, last_mouse_y);
2639 gettimeofday(&now, 0); 2593 gettimeofday(&now, 0);
2640 sec = now.tv_sec; 2594 *timeptr = timeval_to_Time (&now);
2641 usec = now.tv_usec;
2642 *timeptr = (sec * 1000) + (usec / 1000);
2643} 2595}
2644 2596
2645/* Prepare a mouse-event in *RESULT for placement in the input queue. 2597/* Prepare a mouse-event in *RESULT for placement in the input queue.
@@ -2663,7 +2615,7 @@ term_mouse_click (struct input_event *result, Gpm_Event *event,
2663 } 2615 }
2664 } 2616 }
2665 gettimeofday(&now, 0); 2617 gettimeofday(&now, 0);
2666 result->timestamp = (now.tv_sec * 1000) + (now.tv_usec / 1000); 2618 result->timestamp = timeval_to_Time (&now);
2667 2619
2668 if (event->type & GPM_UP) 2620 if (event->type & GPM_UP)
2669 result->modifiers = up_modifier; 2621 result->modifiers = up_modifier;
@@ -2845,14 +2797,11 @@ DEFUN ("gpm-mouse-stop", Fgpm_mouse_stop, Sgpm_mouse_stop,
2845void 2797void
2846create_tty_output (struct frame *f) 2798create_tty_output (struct frame *f)
2847{ 2799{
2848 struct tty_output *t; 2800 struct tty_output *t = xzalloc (sizeof *t);
2849 2801
2850 if (! FRAME_TERMCAP_P (f)) 2802 if (! FRAME_TERMCAP_P (f))
2851 abort (); 2803 abort ();
2852 2804
2853 t = xmalloc (sizeof (struct tty_output));
2854 memset (t, 0, sizeof (struct tty_output));
2855
2856 t->display_info = FRAME_TERMINAL (f)->display_info.tty; 2805 t->display_info = FRAME_TERMINAL (f)->display_info.tty;
2857 2806
2858 f->output_data.tty = t; 2807 f->output_data.tty = t;
@@ -3052,9 +3001,8 @@ init_tty (const char *name, const char *terminal_type, int must_succeed)
3052 been_here = 1; 3001 been_here = 1;
3053 tty = &the_only_display_info; 3002 tty = &the_only_display_info;
3054#else 3003#else
3055 tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info)); 3004 tty = xzalloc (sizeof *tty);
3056#endif 3005#endif
3057 memset (tty, 0, sizeof (struct tty_display_info));
3058 tty->next = tty_list; 3006 tty->next = tty_list;
3059 tty_list = tty; 3007 tty_list = tty;
3060 3008
@@ -3062,7 +3010,7 @@ init_tty (const char *name, const char *terminal_type, int must_succeed)
3062 terminal->display_info.tty = tty; 3010 terminal->display_info.tty = tty;
3063 tty->terminal = terminal; 3011 tty->terminal = terminal;
3064 3012
3065 tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); 3013 tty->Wcm = xmalloc (sizeof *tty->Wcm);
3066 Wcm_clear (tty); 3014 Wcm_clear (tty);
3067 3015
3068 encode_terminal_src_size = 0; 3016 encode_terminal_src_size = 0;
@@ -3123,7 +3071,7 @@ init_tty (const char *name, const char *terminal_type, int must_succeed)
3123 3071
3124 Wcm_clear (tty); 3072 Wcm_clear (tty);
3125 3073
3126 tty->termcap_term_buffer = (char *) xmalloc (buffer_size); 3074 tty->termcap_term_buffer = xmalloc (buffer_size);
3127 3075
3128 /* On some systems, tgetent tries to access the controlling 3076 /* On some systems, tgetent tries to access the controlling
3129 terminal. */ 3077 terminal. */
@@ -3164,7 +3112,7 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\
3164 abort (); 3112 abort ();
3165 buffer_size = strlen (tty->termcap_term_buffer); 3113 buffer_size = strlen (tty->termcap_term_buffer);
3166#endif 3114#endif
3167 tty->termcap_strings_buffer = area = (char *) xmalloc (buffer_size); 3115 tty->termcap_strings_buffer = area = xmalloc (buffer_size);
3168 tty->TS_ins_line = tgetstr ("al", address); 3116 tty->TS_ins_line = tgetstr ("al", address);
3169 tty->TS_ins_multi_lines = tgetstr ("AL", address); 3117 tty->TS_ins_multi_lines = tgetstr ("AL", address);
3170 tty->TS_bell = tgetstr ("bl", address); 3118 tty->TS_bell = tgetstr ("bl", address);
@@ -3222,8 +3170,8 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\
3222 tty->TS_enter_underline_mode = tgetstr ("us", address); 3170 tty->TS_enter_underline_mode = tgetstr ("us", address);
3223 tty->TS_exit_underline_mode = tgetstr ("ue", address); 3171 tty->TS_exit_underline_mode = tgetstr ("ue", address);
3224 tty->TS_enter_bold_mode = tgetstr ("md", address); 3172 tty->TS_enter_bold_mode = tgetstr ("md", address);
3173 tty->TS_enter_italic_mode = tgetstr ("ZH", address);
3225 tty->TS_enter_dim_mode = tgetstr ("mh", address); 3174 tty->TS_enter_dim_mode = tgetstr ("mh", address);
3226 tty->TS_enter_blink_mode = tgetstr ("mb", address);
3227 tty->TS_enter_reverse_mode = tgetstr ("mr", address); 3175 tty->TS_enter_reverse_mode = tgetstr ("mr", address);
3228 tty->TS_enter_alt_charset_mode = tgetstr ("as", address); 3176 tty->TS_enter_alt_charset_mode = tgetstr ("as", address);
3229 tty->TS_exit_alt_charset_mode = tgetstr ("ae", address); 3177 tty->TS_exit_alt_charset_mode = tgetstr ("ae", address);
@@ -3332,7 +3280,7 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\
3332 tty->mouse_highlight.mouse_face_window = Qnil; 3280 tty->mouse_highlight.mouse_face_window = Qnil;
3333#endif 3281#endif
3334 3282
3335 terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); 3283 terminal->kboard = xmalloc (sizeof *terminal->kboard);
3336 init_kboard (terminal->kboard); 3284 init_kboard (terminal->kboard);
3337 KVAR (terminal->kboard, Vwindow_system) = Qnil; 3285 KVAR (terminal->kboard, Vwindow_system) = Qnil;
3338 terminal->kboard->next_kboard = all_kboards; 3286 terminal->kboard->next_kboard = all_kboards;
@@ -3592,7 +3540,6 @@ delete_tty (struct terminal *terminal)
3592 xfree (tty->termcap_strings_buffer); 3540 xfree (tty->termcap_strings_buffer);
3593 xfree (tty->termcap_term_buffer); 3541 xfree (tty->termcap_term_buffer);
3594 3542
3595 memset (tty, 0, sizeof (struct tty_display_info));
3596 xfree (tty); 3543 xfree (tty);
3597} 3544}
3598 3545
@@ -3649,6 +3596,7 @@ bigger, or it may make it blink, or it may do nothing at all. */);
3649 defsubr (&Stty_no_underline); 3596 defsubr (&Stty_no_underline);
3650 defsubr (&Stty_type); 3597 defsubr (&Stty_type);
3651 defsubr (&Scontrolling_tty_p); 3598 defsubr (&Scontrolling_tty_p);
3599 defsubr (&Stty_top_frame);
3652 defsubr (&Ssuspend_tty); 3600 defsubr (&Ssuspend_tty);
3653 defsubr (&Sresume_tty); 3601 defsubr (&Sresume_tty);
3654#ifdef HAVE_GPM 3602#ifdef HAVE_GPM