diff options
| author | Dmitry Antipov | 2014-10-14 16:45:41 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2014-10-14 16:45:41 +0400 |
| commit | bb75cdf9c74ab19b75532da1f953233a47eedab4 (patch) | |
| tree | b8b4d07acaf36cdce7485fb459e7376975ebd5f7 /src | |
| parent | 5fa75d8eba2d43408fd7831dcfd69c21e31c21f3 (diff) | |
| download | emacs-bb75cdf9c74ab19b75532da1f953233a47eedab4.tar.gz emacs-bb75cdf9c74ab19b75532da1f953233a47eedab4.zip | |
Cleanup terminal handling code.
* dispextern.h (get_named_tty): Remove prototype but...
* termhooks.h (get_named_terminal): ...resurrect it under
more meaningful name.
(get_terminal): Likewise, but with...
(decode_live_terminal): ...this name.
(decode_tty_terminal): Add prototype.
* term.c (get_tty_terminal): Remove.
(get_named_tty): Remove.
(Ftty_display_color_p, Ftty_display_color_cells, Ftty_type)
(Fcontrolling_tty_p, Fsuspend_tty, Fresume_tty):
Use decode_tty_terminal.
(Ftty_no_underline, Ftty_top_frame): Use decode_live_terminal.
* terminal.c (get_terminal): Refactor to...
(decode_terminal, decode_live_terminal): ...new functions.
(decode_tty_terminal): Replacement for get_tty_terminal.
(get_named_terminal): Likewise for get_named_tty.
* coding.c (Fset_terminal_coding_system_internal)
(Fterminal_coding_system, Fset_keyboard_coding_system_internal):
(Fkeyboard_coding_system):
* composite.c (Fcomposition_get_gstring):
* dispnew.c (Fsend_string_to_terminal):
* frame.c (Fmake_terminal_frame):
* nsfns.m (check_ns_display_info):
* w32fns.c, xfns.c (check_x_display_info):
* xselect.c (frame_for_x_selection): Use decode_live_terminal.
* keyboard.c (handle_interrupt_signal, handle_interrupt)
(Fset_quit_char): Use get_named_terminal.
(Fset_output_flow_control, Fset_input_meta_mode):
Use decode_tty_terminal.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 33 | ||||
| -rw-r--r-- | src/coding.c | 8 | ||||
| -rw-r--r-- | src/composite.c | 2 | ||||
| -rw-r--r-- | src/dispextern.h | 1 | ||||
| -rw-r--r-- | src/dispnew.c | 5 | ||||
| -rw-r--r-- | src/frame.c | 2 | ||||
| -rw-r--r-- | src/keyboard.c | 18 | ||||
| -rw-r--r-- | src/nsfns.m | 4 | ||||
| -rw-r--r-- | src/term.c | 98 | ||||
| -rw-r--r-- | src/termhooks.h | 4 | ||||
| -rw-r--r-- | src/terminal.c | 95 | ||||
| -rw-r--r-- | src/w32fns.c | 2 | ||||
| -rw-r--r-- | src/xfns.c | 2 | ||||
| -rw-r--r-- | src/xselect.c | 2 |
14 files changed, 135 insertions, 141 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 3200a315daa..c1b7c6cc8c3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,36 @@ | |||
| 1 | 2014-10-14 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | Cleanup terminal handling code. | ||
| 4 | * dispextern.h (get_named_tty): Remove prototype but... | ||
| 5 | * termhooks.h (get_named_terminal): ...resurrect it under | ||
| 6 | more meaningful name. | ||
| 7 | (get_terminal): Likewise, but with... | ||
| 8 | (decode_live_terminal): ...this name. | ||
| 9 | (decode_tty_terminal): Add prototype. | ||
| 10 | * term.c (get_tty_terminal): Remove. | ||
| 11 | (get_named_tty): Remove. | ||
| 12 | (Ftty_display_color_p, Ftty_display_color_cells, Ftty_type) | ||
| 13 | (Fcontrolling_tty_p, Fsuspend_tty, Fresume_tty): | ||
| 14 | Use decode_tty_terminal. | ||
| 15 | (Ftty_no_underline, Ftty_top_frame): Use decode_live_terminal. | ||
| 16 | * terminal.c (get_terminal): Refactor to... | ||
| 17 | (decode_terminal, decode_live_terminal): ...new functions. | ||
| 18 | (decode_tty_terminal): Replacement for get_tty_terminal. | ||
| 19 | (get_named_terminal): Likewise for get_named_tty. | ||
| 20 | * coding.c (Fset_terminal_coding_system_internal) | ||
| 21 | (Fterminal_coding_system, Fset_keyboard_coding_system_internal): | ||
| 22 | (Fkeyboard_coding_system): | ||
| 23 | * composite.c (Fcomposition_get_gstring): | ||
| 24 | * dispnew.c (Fsend_string_to_terminal): | ||
| 25 | * frame.c (Fmake_terminal_frame): | ||
| 26 | * nsfns.m (check_ns_display_info): | ||
| 27 | * w32fns.c, xfns.c (check_x_display_info): | ||
| 28 | * xselect.c (frame_for_x_selection): Use decode_live_terminal. | ||
| 29 | * keyboard.c (handle_interrupt_signal, handle_interrupt) | ||
| 30 | (Fset_quit_char): Use get_named_terminal. | ||
| 31 | (Fset_output_flow_control, Fset_input_meta_mode): | ||
| 32 | Use decode_tty_terminal. | ||
| 33 | |||
| 1 | 2014-10-13 Eli Zaretskii <eliz@gnu.org> | 34 | 2014-10-13 Eli Zaretskii <eliz@gnu.org> |
| 2 | 35 | ||
| 3 | * w32term.h (ALIGN_STACK): Use _WIN64, not _W64, to distinguish | 36 | * w32term.h (ALIGN_STACK): Use _WIN64, not _W64, to distinguish |
diff --git a/src/coding.c b/src/coding.c index f63d710ce9a..e4b52f6db48 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -9759,7 +9759,7 @@ DEFUN ("set-terminal-coding-system-internal", Fset_terminal_coding_system_intern | |||
| 9759 | doc: /* Internal use only. */) | 9759 | doc: /* Internal use only. */) |
| 9760 | (Lisp_Object coding_system, Lisp_Object terminal) | 9760 | (Lisp_Object coding_system, Lisp_Object terminal) |
| 9761 | { | 9761 | { |
| 9762 | struct terminal *term = get_terminal (terminal, 1); | 9762 | struct terminal *term = decode_live_terminal (terminal); |
| 9763 | struct coding_system *terminal_coding = TERMINAL_TERMINAL_CODING (term); | 9763 | struct coding_system *terminal_coding = TERMINAL_TERMINAL_CODING (term); |
| 9764 | CHECK_SYMBOL (coding_system); | 9764 | CHECK_SYMBOL (coding_system); |
| 9765 | setup_coding_system (Fcheck_coding_system (coding_system), terminal_coding); | 9765 | setup_coding_system (Fcheck_coding_system (coding_system), terminal_coding); |
| @@ -9800,7 +9800,7 @@ frame's terminal device. */) | |||
| 9800 | (Lisp_Object terminal) | 9800 | (Lisp_Object terminal) |
| 9801 | { | 9801 | { |
| 9802 | struct coding_system *terminal_coding | 9802 | struct coding_system *terminal_coding |
| 9803 | = TERMINAL_TERMINAL_CODING (get_terminal (terminal, 1)); | 9803 | = TERMINAL_TERMINAL_CODING (decode_live_terminal (terminal)); |
| 9804 | Lisp_Object coding_system = CODING_ID_NAME (terminal_coding->id); | 9804 | Lisp_Object coding_system = CODING_ID_NAME (terminal_coding->id); |
| 9805 | 9805 | ||
| 9806 | /* For backward compatibility, return nil if it is `undecided'. */ | 9806 | /* For backward compatibility, return nil if it is `undecided'. */ |
| @@ -9812,7 +9812,7 @@ DEFUN ("set-keyboard-coding-system-internal", Fset_keyboard_coding_system_intern | |||
| 9812 | doc: /* Internal use only. */) | 9812 | doc: /* Internal use only. */) |
| 9813 | (Lisp_Object coding_system, Lisp_Object terminal) | 9813 | (Lisp_Object coding_system, Lisp_Object terminal) |
| 9814 | { | 9814 | { |
| 9815 | struct terminal *t = get_terminal (terminal, 1); | 9815 | struct terminal *t = decode_live_terminal (terminal); |
| 9816 | CHECK_SYMBOL (coding_system); | 9816 | CHECK_SYMBOL (coding_system); |
| 9817 | if (NILP (coding_system)) | 9817 | if (NILP (coding_system)) |
| 9818 | coding_system = Qno_conversion; | 9818 | coding_system = Qno_conversion; |
| @@ -9831,7 +9831,7 @@ DEFUN ("keyboard-coding-system", | |||
| 9831 | (Lisp_Object terminal) | 9831 | (Lisp_Object terminal) |
| 9832 | { | 9832 | { |
| 9833 | return CODING_ID_NAME (TERMINAL_KEYBOARD_CODING | 9833 | return CODING_ID_NAME (TERMINAL_KEYBOARD_CODING |
| 9834 | (get_terminal (terminal, 1))->id); | 9834 | (decode_live_terminal (terminal))->id); |
| 9835 | } | 9835 | } |
| 9836 | 9836 | ||
| 9837 | 9837 | ||
diff --git a/src/composite.c b/src/composite.c index 1b1960d1c4d..8982c904096 100644 --- a/src/composite.c +++ b/src/composite.c | |||
| @@ -1719,7 +1719,7 @@ should be ignored. */) | |||
| 1719 | if (! FONT_OBJECT_P (font_object)) | 1719 | if (! FONT_OBJECT_P (font_object)) |
| 1720 | { | 1720 | { |
| 1721 | struct coding_system *coding; | 1721 | struct coding_system *coding; |
| 1722 | struct terminal *terminal = get_terminal (font_object, 1); | 1722 | struct terminal *terminal = decode_live_terminal (font_object); |
| 1723 | 1723 | ||
| 1724 | coding = ((TERMINAL_TERMINAL_CODING (terminal)->common_flags | 1724 | coding = ((TERMINAL_TERMINAL_CODING (terminal)->common_flags |
| 1725 | & CODING_REQUIRE_ENCODING_MASK) | 1725 | & CODING_REQUIRE_ENCODING_MASK) |
diff --git a/src/dispextern.h b/src/dispextern.h index 81e36d7b3c6..228502ca06a 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -3500,7 +3500,6 @@ extern void calculate_costs (struct frame *); | |||
| 3500 | extern void produce_glyphs (struct it *); | 3500 | extern void produce_glyphs (struct it *); |
| 3501 | extern bool tty_capable_p (struct tty_display_info *, unsigned); | 3501 | extern bool tty_capable_p (struct tty_display_info *, unsigned); |
| 3502 | extern void set_tty_color_mode (struct tty_display_info *, struct frame *); | 3502 | extern void set_tty_color_mode (struct tty_display_info *, struct frame *); |
| 3503 | extern struct terminal *get_named_tty (const char *); | ||
| 3504 | extern void create_tty_output (struct frame *); | 3503 | extern void create_tty_output (struct frame *); |
| 3505 | extern struct terminal *init_tty (const char *, const char *, bool); | 3504 | extern struct terminal *init_tty (const char *, const char *, bool); |
| 3506 | extern void tty_append_glyph (struct it *); | 3505 | extern void tty_append_glyph (struct it *); |
diff --git a/src/dispnew.c b/src/dispnew.c index fbad0edc018..3ab8bcf3e64 100644 --- a/src/dispnew.c +++ b/src/dispnew.c | |||
| @@ -5611,16 +5611,13 @@ the currently selected frame. In batch mode, STRING is sent to stdout | |||
| 5611 | when TERMINAL is nil. */) | 5611 | when TERMINAL is nil. */) |
| 5612 | (Lisp_Object string, Lisp_Object terminal) | 5612 | (Lisp_Object string, Lisp_Object terminal) |
| 5613 | { | 5613 | { |
| 5614 | struct terminal *t = get_terminal (terminal, 1); | 5614 | struct terminal *t = decode_live_terminal (terminal); |
| 5615 | FILE *out; | 5615 | FILE *out; |
| 5616 | 5616 | ||
| 5617 | /* ??? Perhaps we should do something special for multibyte strings here. */ | 5617 | /* ??? Perhaps we should do something special for multibyte strings here. */ |
| 5618 | CHECK_STRING (string); | 5618 | CHECK_STRING (string); |
| 5619 | block_input (); | 5619 | block_input (); |
| 5620 | 5620 | ||
| 5621 | if (!t) | ||
| 5622 | error ("Unknown terminal device"); | ||
| 5623 | |||
| 5624 | if (t->type == output_initial) | 5621 | if (t->type == output_initial) |
| 5625 | out = stdout; | 5622 | out = stdout; |
| 5626 | else if (t->type != output_termcap && t->type != output_msdos_raw) | 5623 | else if (t->type != output_termcap && t->type != output_msdos_raw) |
diff --git a/src/frame.c b/src/frame.c index a3139173655..8fac06e2af7 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -964,7 +964,7 @@ affects all frames on the same terminal device. */) | |||
| 964 | if (CONSP (terminal)) | 964 | if (CONSP (terminal)) |
| 965 | { | 965 | { |
| 966 | terminal = XCDR (terminal); | 966 | terminal = XCDR (terminal); |
| 967 | t = get_terminal (terminal, 1); | 967 | t = decode_live_terminal (terminal); |
| 968 | } | 968 | } |
| 969 | #ifdef MSDOS | 969 | #ifdef MSDOS |
| 970 | if (t && t != the_only_display_info.terminal) | 970 | if (t && t != the_only_display_info.terminal) |
diff --git a/src/keyboard.c b/src/keyboard.c index 6730536dc1d..e8143f26681 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -10349,7 +10349,7 @@ static void | |||
| 10349 | handle_interrupt_signal (int sig) | 10349 | handle_interrupt_signal (int sig) |
| 10350 | { | 10350 | { |
| 10351 | /* See if we have an active terminal on our controlling tty. */ | 10351 | /* See if we have an active terminal on our controlling tty. */ |
| 10352 | struct terminal *terminal = get_named_tty ("/dev/tty"); | 10352 | struct terminal *terminal = get_named_terminal ("/dev/tty"); |
| 10353 | if (!terminal) | 10353 | if (!terminal) |
| 10354 | { | 10354 | { |
| 10355 | /* If there are no frames there, let's pretend that we are a | 10355 | /* If there are no frames there, let's pretend that we are a |
| @@ -10403,7 +10403,7 @@ handle_interrupt (bool in_signal_handler) | |||
| 10403 | cancel_echoing (); | 10403 | cancel_echoing (); |
| 10404 | 10404 | ||
| 10405 | /* XXX This code needs to be revised for multi-tty support. */ | 10405 | /* XXX This code needs to be revised for multi-tty support. */ |
| 10406 | if (!NILP (Vquit_flag) && get_named_tty ("/dev/tty")) | 10406 | if (!NILP (Vquit_flag) && get_named_terminal ("/dev/tty")) |
| 10407 | { | 10407 | { |
| 10408 | if (! in_signal_handler) | 10408 | if (! in_signal_handler) |
| 10409 | { | 10409 | { |
| @@ -10615,9 +10615,10 @@ Emacs reads input in CBREAK mode; see `set-input-interrupt-mode'. | |||
| 10615 | See also `current-input-mode'. */) | 10615 | See also `current-input-mode'. */) |
| 10616 | (Lisp_Object flow, Lisp_Object terminal) | 10616 | (Lisp_Object flow, Lisp_Object terminal) |
| 10617 | { | 10617 | { |
| 10618 | struct terminal *t = get_terminal (terminal, 1); | 10618 | struct terminal *t = decode_tty_terminal (terminal); |
| 10619 | struct tty_display_info *tty; | 10619 | struct tty_display_info *tty; |
| 10620 | if (t == NULL || (t->type != output_termcap && t->type != output_msdos_raw)) | 10620 | |
| 10621 | if (!t) | ||
| 10621 | return Qnil; | 10622 | return Qnil; |
| 10622 | tty = t->display_info.tty; | 10623 | tty = t->display_info.tty; |
| 10623 | 10624 | ||
| @@ -10657,11 +10658,11 @@ the currently selected frame. | |||
| 10657 | See also `current-input-mode'. */) | 10658 | See also `current-input-mode'. */) |
| 10658 | (Lisp_Object meta, Lisp_Object terminal) | 10659 | (Lisp_Object meta, Lisp_Object terminal) |
| 10659 | { | 10660 | { |
| 10660 | struct terminal *t = get_terminal (terminal, 1); | 10661 | struct terminal *t = decode_tty_terminal (terminal); |
| 10661 | struct tty_display_info *tty; | 10662 | struct tty_display_info *tty; |
| 10662 | int new_meta; | 10663 | int new_meta; |
| 10663 | 10664 | ||
| 10664 | if (t == NULL || (t->type != output_termcap && t->type != output_msdos_raw)) | 10665 | if (!t) |
| 10665 | return Qnil; | 10666 | return Qnil; |
| 10666 | tty = t->display_info.tty; | 10667 | tty = t->display_info.tty; |
| 10667 | 10668 | ||
| @@ -10698,9 +10699,10 @@ process. | |||
| 10698 | See also `current-input-mode'. */) | 10699 | See also `current-input-mode'. */) |
| 10699 | (Lisp_Object quit) | 10700 | (Lisp_Object quit) |
| 10700 | { | 10701 | { |
| 10701 | struct terminal *t = get_named_tty ("/dev/tty"); | 10702 | struct terminal *t = get_named_terminal ("/dev/tty"); |
| 10702 | struct tty_display_info *tty; | 10703 | struct tty_display_info *tty; |
| 10703 | if (t == NULL || (t->type != output_termcap && t->type != output_msdos_raw)) | 10704 | |
| 10705 | if (!t) | ||
| 10704 | return Qnil; | 10706 | return Qnil; |
| 10705 | tty = t->display_info.tty; | 10707 | tty = t->display_info.tty; |
| 10706 | 10708 | ||
diff --git a/src/nsfns.m b/src/nsfns.m index 5cf8387123e..a93b2724403 100644 --- a/src/nsfns.m +++ b/src/nsfns.m | |||
| @@ -133,7 +133,7 @@ check_ns_display_info (Lisp_Object object) | |||
| 133 | } | 133 | } |
| 134 | else if (TERMINALP (object)) | 134 | else if (TERMINALP (object)) |
| 135 | { | 135 | { |
| 136 | struct terminal *t = get_terminal (object, 1); | 136 | struct terminal *t = decode_live_terminal (object); |
| 137 | 137 | ||
| 138 | if (t->type != output_ns) | 138 | if (t->type != output_ns) |
| 139 | error ("Terminal %d is not a Nextstep display", t->id); | 139 | error ("Terminal %d is not a Nextstep display", t->id); |
| @@ -2541,7 +2541,7 @@ the attributes: | |||
| 2541 | Internal use only, use `display-monitor-attributes-list' instead. */) | 2541 | Internal use only, use `display-monitor-attributes-list' instead. */) |
| 2542 | (Lisp_Object terminal) | 2542 | (Lisp_Object terminal) |
| 2543 | { | 2543 | { |
| 2544 | struct terminal *term = get_terminal (terminal, 1); | 2544 | struct terminal *term = decode_live_terminal (terminal); |
| 2545 | NSArray *screens; | 2545 | NSArray *screens; |
| 2546 | NSUInteger i, n_monitors; | 2546 | NSUInteger i, n_monitors; |
| 2547 | struct MonitorInfo *monitors; | 2547 | struct MonitorInfo *monitors; |
diff --git a/src/term.c b/src/term.c index 572435bdd1a..0c36469f655 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -77,7 +77,6 @@ static void tty_turn_off_highlight (struct tty_display_info *); | |||
| 77 | static void tty_show_cursor (struct tty_display_info *); | 77 | static void tty_show_cursor (struct tty_display_info *); |
| 78 | static void tty_hide_cursor (struct tty_display_info *); | 78 | static void tty_hide_cursor (struct tty_display_info *); |
| 79 | static void tty_background_highlight (struct tty_display_info *tty); | 79 | static void tty_background_highlight (struct tty_display_info *tty); |
| 80 | static struct terminal *get_tty_terminal (Lisp_Object, bool); | ||
| 81 | static void clear_tty_hooks (struct terminal *terminal); | 80 | static void clear_tty_hooks (struct terminal *terminal); |
| 82 | static void set_tty_hooks (struct terminal *terminal); | 81 | static void set_tty_hooks (struct terminal *terminal); |
| 83 | static void dissociate_if_controlling_tty (int fd); | 82 | static void dissociate_if_controlling_tty (int fd); |
| @@ -2032,11 +2031,9 @@ selected frame's terminal). This function always returns nil if | |||
| 2032 | TERMINAL does not refer to a text terminal. */) | 2031 | TERMINAL does not refer to a text terminal. */) |
| 2033 | (Lisp_Object terminal) | 2032 | (Lisp_Object terminal) |
| 2034 | { | 2033 | { |
| 2035 | struct terminal *t = get_tty_terminal (terminal, 0); | 2034 | struct terminal *t = decode_tty_terminal (terminal); |
| 2036 | if (!t) | 2035 | |
| 2037 | return Qnil; | 2036 | return (t && t->display_info.tty->TN_max_colors > 0) ? Qt : Qnil; |
| 2038 | else | ||
| 2039 | return t->display_info.tty->TN_max_colors > 0 ? Qt : Qnil; | ||
| 2040 | } | 2037 | } |
| 2041 | 2038 | ||
| 2042 | /* Return the number of supported colors. */ | 2039 | /* Return the number of supported colors. */ |
| @@ -2049,11 +2046,9 @@ selected frame's terminal). This function always returns 0 if | |||
| 2049 | TERMINAL does not refer to a text terminal. */) | 2046 | TERMINAL does not refer to a text terminal. */) |
| 2050 | (Lisp_Object terminal) | 2047 | (Lisp_Object terminal) |
| 2051 | { | 2048 | { |
| 2052 | struct terminal *t = get_tty_terminal (terminal, 0); | 2049 | struct terminal *t = decode_tty_terminal (terminal); |
| 2053 | if (!t) | 2050 | |
| 2054 | return make_number (0); | 2051 | return make_number (t ? t->display_info.tty->TN_max_colors : 0); |
| 2055 | else | ||
| 2056 | return make_number (t->display_info.tty->TN_max_colors); | ||
| 2057 | } | 2052 | } |
| 2058 | 2053 | ||
| 2059 | #ifndef DOS_NT | 2054 | #ifndef DOS_NT |
| @@ -2168,52 +2163,6 @@ set_tty_color_mode (struct tty_display_info *tty, struct frame *f) | |||
| 2168 | 2163 | ||
| 2169 | #endif /* !DOS_NT */ | 2164 | #endif /* !DOS_NT */ |
| 2170 | 2165 | ||
| 2171 | |||
| 2172 | |||
| 2173 | /* Return the tty display object specified by TERMINAL. */ | ||
| 2174 | |||
| 2175 | static struct terminal * | ||
| 2176 | get_tty_terminal (Lisp_Object terminal, bool throw) | ||
| 2177 | { | ||
| 2178 | struct terminal *t = get_terminal (terminal, throw); | ||
| 2179 | |||
| 2180 | if (t && t->type != output_termcap && t->type != output_msdos_raw) | ||
| 2181 | { | ||
| 2182 | if (throw) | ||
| 2183 | error ("Device %d is not a termcap terminal device", t->id); | ||
| 2184 | else | ||
| 2185 | return NULL; | ||
| 2186 | } | ||
| 2187 | |||
| 2188 | return t; | ||
| 2189 | } | ||
| 2190 | |||
| 2191 | /* Return an active termcap device that uses the tty device with the | ||
| 2192 | given name. | ||
| 2193 | |||
| 2194 | This function ignores suspended devices. | ||
| 2195 | |||
| 2196 | Returns NULL if the named terminal device is not opened. */ | ||
| 2197 | |||
| 2198 | struct terminal * | ||
| 2199 | get_named_tty (const char *name) | ||
| 2200 | { | ||
| 2201 | struct terminal *t; | ||
| 2202 | |||
| 2203 | eassert (name); | ||
| 2204 | |||
| 2205 | for (t = terminal_list; t; t = t->next_terminal) | ||
| 2206 | { | ||
| 2207 | if ((t->type == output_termcap || t->type == output_msdos_raw) | ||
| 2208 | && !strcmp (t->display_info.tty->name, name) | ||
| 2209 | && TERMINAL_ACTIVE_P (t)) | ||
| 2210 | return t; | ||
| 2211 | } | ||
| 2212 | |||
| 2213 | return 0; | ||
| 2214 | } | ||
| 2215 | |||
| 2216 | |||
| 2217 | DEFUN ("tty-type", Ftty_type, Stty_type, 0, 1, 0, | 2166 | DEFUN ("tty-type", Ftty_type, Stty_type, 0, 1, 0, |
| 2218 | doc: /* Return the type of the tty device that TERMINAL uses. | 2167 | doc: /* Return the type of the tty device that TERMINAL uses. |
| 2219 | Returns nil if TERMINAL is not on a tty device. | 2168 | Returns nil if TERMINAL is not on a tty device. |
| @@ -2222,15 +2171,10 @@ TERMINAL can be a terminal object, a frame, or nil (meaning the | |||
| 2222 | selected frame's terminal). */) | 2171 | selected frame's terminal). */) |
| 2223 | (Lisp_Object terminal) | 2172 | (Lisp_Object terminal) |
| 2224 | { | 2173 | { |
| 2225 | struct terminal *t = get_terminal (terminal, 1); | 2174 | struct terminal *t = decode_tty_terminal (terminal); |
| 2226 | |||
| 2227 | if (t->type != output_termcap && t->type != output_msdos_raw) | ||
| 2228 | return Qnil; | ||
| 2229 | 2175 | ||
| 2230 | if (t->display_info.tty->type) | 2176 | return (t && t->display_info.tty->type |
| 2231 | return build_string (t->display_info.tty->type); | 2177 | ? build_string (t->display_info.tty->type) : Qnil); |
| 2232 | else | ||
| 2233 | return Qnil; | ||
| 2234 | } | 2178 | } |
| 2235 | 2179 | ||
| 2236 | DEFUN ("controlling-tty-p", Fcontrolling_tty_p, Scontrolling_tty_p, 0, 1, 0, | 2180 | DEFUN ("controlling-tty-p", Fcontrolling_tty_p, Scontrolling_tty_p, 0, 1, 0, |
| @@ -2241,13 +2185,9 @@ selected frame's terminal). This function always returns nil if | |||
| 2241 | TERMINAL is not on a tty device. */) | 2185 | TERMINAL is not on a tty device. */) |
| 2242 | (Lisp_Object terminal) | 2186 | (Lisp_Object terminal) |
| 2243 | { | 2187 | { |
| 2244 | struct terminal *t = get_terminal (terminal, 1); | 2188 | struct terminal *t = decode_tty_terminal (terminal); |
| 2245 | 2189 | ||
| 2246 | if ((t->type != output_termcap && t->type != output_msdos_raw) | 2190 | return (t && !strcmp (t->display_info.tty->name, DEV_TTY) ? Qt : Qnil); |
| 2247 | || strcmp (t->display_info.tty->name, DEV_TTY) != 0) | ||
| 2248 | return Qnil; | ||
| 2249 | else | ||
| 2250 | return Qt; | ||
| 2251 | } | 2191 | } |
| 2252 | 2192 | ||
| 2253 | DEFUN ("tty-no-underline", Ftty_no_underline, Stty_no_underline, 0, 1, 0, | 2193 | DEFUN ("tty-no-underline", Ftty_no_underline, Stty_no_underline, 0, 1, 0, |
| @@ -2261,7 +2201,7 @@ selected frame's terminal). This function always returns nil if | |||
| 2261 | TERMINAL does not refer to a text terminal. */) | 2201 | TERMINAL does not refer to a text terminal. */) |
| 2262 | (Lisp_Object terminal) | 2202 | (Lisp_Object terminal) |
| 2263 | { | 2203 | { |
| 2264 | struct terminal *t = get_terminal (terminal, 1); | 2204 | struct terminal *t = decode_live_terminal (terminal); |
| 2265 | 2205 | ||
| 2266 | if (t->type == output_termcap) | 2206 | if (t->type == output_termcap) |
| 2267 | t->display_info.tty->TS_enter_underline_mode = 0; | 2207 | t->display_info.tty->TS_enter_underline_mode = 0; |
| @@ -2276,7 +2216,7 @@ does not refer to a text terminal. Otherwise, it returns the | |||
| 2276 | top-most frame on the text terminal. */) | 2216 | top-most frame on the text terminal. */) |
| 2277 | (Lisp_Object terminal) | 2217 | (Lisp_Object terminal) |
| 2278 | { | 2218 | { |
| 2279 | struct terminal *t = get_terminal (terminal, 1); | 2219 | struct terminal *t = decode_live_terminal (terminal); |
| 2280 | 2220 | ||
| 2281 | if (t->type == output_termcap) | 2221 | if (t->type == output_termcap) |
| 2282 | return t->display_info.tty->top_frame; | 2222 | return t->display_info.tty->top_frame; |
| @@ -2306,11 +2246,11 @@ suspended. | |||
| 2306 | A suspended tty may be resumed by calling `resume-tty' on it. */) | 2246 | A suspended tty may be resumed by calling `resume-tty' on it. */) |
| 2307 | (Lisp_Object tty) | 2247 | (Lisp_Object tty) |
| 2308 | { | 2248 | { |
| 2309 | struct terminal *t = get_tty_terminal (tty, 1); | 2249 | struct terminal *t = decode_tty_terminal (tty); |
| 2310 | FILE *f; | 2250 | FILE *f; |
| 2311 | 2251 | ||
| 2312 | if (!t) | 2252 | if (!t) |
| 2313 | error ("Unknown tty device"); | 2253 | error ("Attempt to suspend a non-text terminal device"); |
| 2314 | 2254 | ||
| 2315 | f = t->display_info.tty->input; | 2255 | f = t->display_info.tty->input; |
| 2316 | 2256 | ||
| @@ -2366,15 +2306,15 @@ TTY may be a terminal object, a frame, or nil (meaning the selected | |||
| 2366 | frame's terminal). */) | 2306 | frame's terminal). */) |
| 2367 | (Lisp_Object tty) | 2307 | (Lisp_Object tty) |
| 2368 | { | 2308 | { |
| 2369 | struct terminal *t = get_tty_terminal (tty, 1); | 2309 | struct terminal *t = decode_tty_terminal (tty); |
| 2370 | int fd; | 2310 | int fd; |
| 2371 | 2311 | ||
| 2372 | if (!t) | 2312 | if (!t) |
| 2373 | error ("Unknown tty device"); | 2313 | error ("Attempt to resume a non-text terminal device"); |
| 2374 | 2314 | ||
| 2375 | if (!t->display_info.tty->input) | 2315 | if (!t->display_info.tty->input) |
| 2376 | { | 2316 | { |
| 2377 | if (get_named_tty (t->display_info.tty->name)) | 2317 | if (get_named_terminal (t->display_info.tty->name)) |
| 2378 | error ("Cannot resume display while another display is active on the same device"); | 2318 | error ("Cannot resume display while another display is active on the same device"); |
| 2379 | 2319 | ||
| 2380 | #ifdef MSDOS | 2320 | #ifdef MSDOS |
| @@ -4007,7 +3947,7 @@ init_tty (const char *name, const char *terminal_type, bool must_succeed) | |||
| 4007 | /* XXX Perhaps this should be made explicit by having init_tty | 3947 | /* XXX Perhaps this should be made explicit by having init_tty |
| 4008 | always create a new terminal and separating terminal and frame | 3948 | always create a new terminal and separating terminal and frame |
| 4009 | creation on Lisp level. */ | 3949 | creation on Lisp level. */ |
| 4010 | terminal = get_named_tty (name); | 3950 | terminal = get_named_terminal (name); |
| 4011 | if (terminal) | 3951 | if (terminal) |
| 4012 | return terminal; | 3952 | return terminal; |
| 4013 | 3953 | ||
diff --git a/src/termhooks.h b/src/termhooks.h index 8d85fba8af8..9cab853ed3d 100644 --- a/src/termhooks.h +++ b/src/termhooks.h | |||
| @@ -681,7 +681,9 @@ extern struct terminal *terminal_list; | |||
| 681 | (t->type == output_ns ? t->display_info.ns->name_list_element : Qnil) | 681 | (t->type == output_ns ? t->display_info.ns->name_list_element : Qnil) |
| 682 | #endif | 682 | #endif |
| 683 | 683 | ||
| 684 | extern struct terminal *get_terminal (Lisp_Object terminal, bool); | 684 | extern struct terminal *decode_live_terminal (Lisp_Object); |
| 685 | extern struct terminal *decode_tty_terminal (Lisp_Object); | ||
| 686 | extern struct terminal *get_named_terminal (const char *); | ||
| 685 | extern struct terminal *create_terminal (enum output_method, | 687 | extern struct terminal *create_terminal (enum output_method, |
| 686 | struct redisplay_interface *); | 688 | struct redisplay_interface *); |
| 687 | extern void delete_terminal (struct terminal *); | 689 | extern void delete_terminal (struct terminal *); |
diff --git a/src/terminal.c b/src/terminal.c index a827677a58d..0cd6a0bf602 100644 --- a/src/terminal.c +++ b/src/terminal.c | |||
| @@ -37,7 +37,9 @@ static int next_terminal_id; | |||
| 37 | /* The initial terminal device, created by initial_term_init. */ | 37 | /* The initial terminal device, created by initial_term_init. */ |
| 38 | struct terminal *initial_terminal; | 38 | struct terminal *initial_terminal; |
| 39 | 39 | ||
| 40 | Lisp_Object Qrun_hook_with_args; | ||
| 40 | static Lisp_Object Qterminal_live_p; | 41 | static Lisp_Object Qterminal_live_p; |
| 42 | static Lisp_Object Qdelete_terminal_functions; | ||
| 41 | 43 | ||
| 42 | static void delete_initial_terminal (struct terminal *); | 44 | static void delete_initial_terminal (struct terminal *); |
| 43 | 45 | ||
| @@ -194,34 +196,66 @@ ins_del_lines (struct frame *f, int vpos, int n) | |||
| 194 | (*FRAME_TERMINAL (f)->ins_del_lines_hook) (f, vpos, n); | 196 | (*FRAME_TERMINAL (f)->ins_del_lines_hook) (f, vpos, n); |
| 195 | } | 197 | } |
| 196 | 198 | ||
| 199 | /* Return the terminal object specified by TERMINAL. TERMINAL may | ||
| 200 | be a terminal object, a frame, or nil for the terminal device of | ||
| 201 | the current frame. If TERMINAL is neither from the above or the | ||
| 202 | resulting terminal object is deleted, return NULL. */ | ||
| 197 | 203 | ||
| 198 | 204 | static struct terminal * | |
| 199 | 205 | decode_terminal (Lisp_Object terminal) | |
| 200 | /* Return the terminal object specified by TERMINAL. TERMINAL may be | ||
| 201 | a terminal object, a frame, or nil for the terminal device of the | ||
| 202 | current frame. If THROW is false, return NULL for failure, | ||
| 203 | otherwise throw an error. */ | ||
| 204 | |||
| 205 | struct terminal * | ||
| 206 | get_terminal (Lisp_Object terminal, bool throw) | ||
| 207 | { | 206 | { |
| 208 | struct terminal *result = NULL; | 207 | struct terminal *t; |
| 209 | 208 | ||
| 210 | if (NILP (terminal)) | 209 | if (NILP (terminal)) |
| 211 | terminal = selected_frame; | 210 | terminal = selected_frame; |
| 211 | t = (TERMINALP (terminal) | ||
| 212 | ? XTERMINAL (terminal) | ||
| 213 | : FRAMEP (terminal) ? FRAME_TERMINAL (XFRAME (terminal)) : NULL); | ||
| 214 | return t && t->name ? t : NULL; | ||
| 215 | } | ||
| 212 | 216 | ||
| 213 | if (TERMINALP (terminal)) | 217 | /* Like above, but throw an error if TERMINAL is not valid or deleted. */ |
| 214 | result = XTERMINAL (terminal); | ||
| 215 | else if (FRAMEP (terminal)) | ||
| 216 | result = FRAME_TERMINAL (XFRAME (terminal)); | ||
| 217 | 218 | ||
| 218 | if (result && !result->name) | 219 | struct terminal * |
| 219 | result = NULL; | 220 | decode_live_terminal (Lisp_Object terminal) |
| 221 | { | ||
| 222 | struct terminal *t = decode_terminal (terminal); | ||
| 220 | 223 | ||
| 221 | if (result == NULL && throw) | 224 | if (!t) |
| 222 | wrong_type_argument (Qterminal_live_p, terminal); | 225 | wrong_type_argument (Qterminal_live_p, terminal); |
| 226 | return t; | ||
| 227 | } | ||
| 228 | |||
| 229 | /* Like decode_terminal, but ensure that the resulting terminal object refers | ||
| 230 | to a text-based terminal device. */ | ||
| 231 | |||
| 232 | struct terminal * | ||
| 233 | decode_tty_terminal (Lisp_Object terminal) | ||
| 234 | { | ||
| 235 | struct terminal *t = decode_live_terminal (terminal); | ||
| 223 | 236 | ||
| 224 | return result; | 237 | return (t->type == output_termcap || t->type == output_msdos_raw) ? t : NULL; |
| 238 | } | ||
| 239 | |||
| 240 | /* Return an active (not suspended) text-based terminal device that uses | ||
| 241 | the tty device with the given NAME, or NULL if the named terminal device | ||
| 242 | is not opened. */ | ||
| 243 | |||
| 244 | struct terminal * | ||
| 245 | get_named_terminal (const char *name) | ||
| 246 | { | ||
| 247 | struct terminal *t; | ||
| 248 | |||
| 249 | eassert (name); | ||
| 250 | |||
| 251 | for (t = terminal_list; t; t = t->next_terminal) | ||
| 252 | { | ||
| 253 | if ((t->type == output_termcap || t->type == output_msdos_raw) | ||
| 254 | && !strcmp (t->display_info.tty->name, name) | ||
| 255 | && TERMINAL_ACTIVE_P (t)) | ||
| 256 | return t; | ||
| 257 | } | ||
| 258 | return NULL; | ||
| 225 | } | 259 | } |
| 226 | 260 | ||
| 227 | /* Create a new terminal object of TYPE and add it to the terminal list. RIF | 261 | /* Create a new terminal object of TYPE and add it to the terminal list. RIF |
| @@ -308,8 +342,6 @@ delete_terminal (struct terminal *terminal) | |||
| 308 | } | 342 | } |
| 309 | } | 343 | } |
| 310 | 344 | ||
| 311 | Lisp_Object Qrun_hook_with_args; | ||
| 312 | static Lisp_Object Qdelete_terminal_functions; | ||
| 313 | DEFUN ("delete-terminal", Fdelete_terminal, Sdelete_terminal, 0, 2, 0, | 345 | DEFUN ("delete-terminal", Fdelete_terminal, Sdelete_terminal, 0, 2, 0, |
| 314 | doc: /* Delete TERMINAL by deleting all frames on it and closing the terminal. | 346 | doc: /* Delete TERMINAL by deleting all frames on it and closing the terminal. |
| 315 | TERMINAL may be a terminal object, a frame, or nil (meaning the | 347 | TERMINAL may be a terminal object, a frame, or nil (meaning the |
| @@ -319,7 +351,7 @@ Normally, you may not delete a display if all other displays are suspended, | |||
| 319 | but if the second argument FORCE is non-nil, you may do so. */) | 351 | but if the second argument FORCE is non-nil, you may do so. */) |
| 320 | (Lisp_Object terminal, Lisp_Object force) | 352 | (Lisp_Object terminal, Lisp_Object force) |
| 321 | { | 353 | { |
| 322 | struct terminal *t = get_terminal (terminal, 0); | 354 | struct terminal *t = decode_terminal (terminal); |
| 323 | 355 | ||
| 324 | if (!t) | 356 | if (!t) |
| 325 | return Qnil; | 357 | return Qnil; |
| @@ -380,9 +412,7 @@ sort of output terminal it uses. See the documentation of `framep' for | |||
| 380 | possible return values. */) | 412 | possible return values. */) |
| 381 | (Lisp_Object object) | 413 | (Lisp_Object object) |
| 382 | { | 414 | { |
| 383 | struct terminal *t; | 415 | struct terminal *t = decode_terminal (object); |
| 384 | |||
| 385 | t = get_terminal (object, 0); | ||
| 386 | 416 | ||
| 387 | if (!t) | 417 | if (!t) |
| 388 | return Qnil; | 418 | return Qnil; |
| @@ -429,8 +459,7 @@ TERMINAL may be a terminal object, a frame, or nil (meaning the | |||
| 429 | selected frame's terminal). */) | 459 | selected frame's terminal). */) |
| 430 | (Lisp_Object terminal) | 460 | (Lisp_Object terminal) |
| 431 | { | 461 | { |
| 432 | struct terminal *t | 462 | struct terminal *t = decode_live_terminal (terminal); |
| 433 | = TERMINALP (terminal) ? XTERMINAL (terminal) : get_terminal (terminal, 1); | ||
| 434 | 463 | ||
| 435 | return t->name ? build_string (t->name) : Qnil; | 464 | return t->name ? build_string (t->name) : Qnil; |
| 436 | } | 465 | } |
| @@ -467,9 +496,7 @@ TERMINAL can be a terminal object, a frame, or nil (meaning the | |||
| 467 | selected frame's terminal). */) | 496 | selected frame's terminal). */) |
| 468 | (Lisp_Object terminal) | 497 | (Lisp_Object terminal) |
| 469 | { | 498 | { |
| 470 | struct terminal *t | 499 | return Fcopy_alist (decode_live_terminal (terminal)->param_alist); |
| 471 | = TERMINALP (terminal) ? XTERMINAL (terminal) : get_terminal (terminal, 1); | ||
| 472 | return Fcopy_alist (t->param_alist); | ||
| 473 | } | 500 | } |
| 474 | 501 | ||
| 475 | DEFUN ("terminal-parameter", Fterminal_parameter, Sterminal_parameter, 2, 2, 0, | 502 | DEFUN ("terminal-parameter", Fterminal_parameter, Sterminal_parameter, 2, 2, 0, |
| @@ -478,12 +505,8 @@ TERMINAL can be a terminal object, a frame, or nil (meaning the | |||
| 478 | selected frame's terminal). */) | 505 | selected frame's terminal). */) |
| 479 | (Lisp_Object terminal, Lisp_Object parameter) | 506 | (Lisp_Object terminal, Lisp_Object parameter) |
| 480 | { | 507 | { |
| 481 | Lisp_Object value; | ||
| 482 | struct terminal *t | ||
| 483 | = TERMINALP (terminal) ? XTERMINAL (terminal) : get_terminal (terminal, 1); | ||
| 484 | CHECK_SYMBOL (parameter); | 508 | CHECK_SYMBOL (parameter); |
| 485 | value = Fcdr (Fassq (parameter, t->param_alist)); | 509 | return Fcdr (Fassq (parameter, decode_live_terminal (terminal)->param_alist)); |
| 486 | return value; | ||
| 487 | } | 510 | } |
| 488 | 511 | ||
| 489 | DEFUN ("set-terminal-parameter", Fset_terminal_parameter, | 512 | DEFUN ("set-terminal-parameter", Fset_terminal_parameter, |
| @@ -495,9 +518,7 @@ TERMINAL can be a terminal object, a frame or nil (meaning the | |||
| 495 | selected frame's terminal). */) | 518 | selected frame's terminal). */) |
| 496 | (Lisp_Object terminal, Lisp_Object parameter, Lisp_Object value) | 519 | (Lisp_Object terminal, Lisp_Object parameter, Lisp_Object value) |
| 497 | { | 520 | { |
| 498 | struct terminal *t | 521 | return store_terminal_param (decode_live_terminal (terminal), parameter, value); |
| 499 | = TERMINALP (terminal) ? XTERMINAL (terminal) : get_terminal (terminal, 1); | ||
| 500 | return store_terminal_param (t, parameter, value); | ||
| 501 | } | 522 | } |
| 502 | 523 | ||
| 503 | /* Initial frame has no device-dependent output data, but has | 524 | /* Initial frame has no device-dependent output data, but has |
diff --git a/src/w32fns.c b/src/w32fns.c index bfa69fb61cd..05da2a5c1d1 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -276,7 +276,7 @@ check_x_display_info (Lisp_Object object) | |||
| 276 | } | 276 | } |
| 277 | else if (TERMINALP (object)) | 277 | else if (TERMINALP (object)) |
| 278 | { | 278 | { |
| 279 | struct terminal *t = get_terminal (object, 1); | 279 | struct terminal *t = decode_live_terminal (object); |
| 280 | 280 | ||
| 281 | if (t->type != output_w32) | 281 | if (t->type != output_w32) |
| 282 | error ("Terminal %d is not a W32 display", t->id); | 282 | error ("Terminal %d is not a W32 display", t->id); |
diff --git a/src/xfns.c b/src/xfns.c index 7fd6d9070b2..5edb635b182 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -159,7 +159,7 @@ check_x_display_info (Lisp_Object object) | |||
| 159 | } | 159 | } |
| 160 | else if (TERMINALP (object)) | 160 | else if (TERMINALP (object)) |
| 161 | { | 161 | { |
| 162 | struct terminal *t = get_terminal (object, 1); | 162 | struct terminal *t = decode_live_terminal (object); |
| 163 | 163 | ||
| 164 | if (t->type != output_x_window) | 164 | if (t->type != output_x_window) |
| 165 | error ("Terminal %d is not an X display", t->id); | 165 | error ("Terminal %d is not an X display", t->id); |
diff --git a/src/xselect.c b/src/xselect.c index 9b57a95b26b..92e89822293 100644 --- a/src/xselect.c +++ b/src/xselect.c | |||
| @@ -1901,7 +1901,7 @@ frame_for_x_selection (Lisp_Object object) | |||
| 1901 | } | 1901 | } |
| 1902 | else if (TERMINALP (object)) | 1902 | else if (TERMINALP (object)) |
| 1903 | { | 1903 | { |
| 1904 | struct terminal *t = get_terminal (object, 1); | 1904 | struct terminal *t = decode_live_terminal (object); |
| 1905 | 1905 | ||
| 1906 | if (t->type == output_x_window) | 1906 | if (t->type == output_x_window) |
| 1907 | FOR_EACH_FRAME (tail, frame) | 1907 | FOR_EACH_FRAME (tail, frame) |