summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.multi-tty1
-rw-r--r--lisp/international/encoded-kb.el21
-rw-r--r--lisp/term/linux.el5
-rw-r--r--src/keyboard.c222
-rw-r--r--src/lisp.h4
-rw-r--r--src/macterm.c2
-rw-r--r--src/xterm.c2
7 files changed, 187 insertions, 70 deletions
diff --git a/README.multi-tty b/README.multi-tty
index 5cc5fbca320..c4e990e5b83 100644
--- a/README.multi-tty
+++ b/README.multi-tty
@@ -55,6 +55,7 @@ Kalle Olavi Niemitalo <kon@iki.fi>
Mark Plaksin <happy@mcplaksin.org>
Frank Ruell <stoerte@dreamwarrior.net>
Tom Schutzer-Weissmann <trmsw@yahoo.co.uk>
+Joakim Verona <joakim@verona.se>
Dan Waber <dwaber@logolalia.com>
and many others.
diff --git a/lisp/international/encoded-kb.el b/lisp/international/encoded-kb.el
index 25e8f478203..160dd8a8d68 100644
--- a/lisp/international/encoded-kb.el
+++ b/lisp/international/encoded-kb.el
@@ -276,25 +276,22 @@ DISPLAY may be a display id, a frame, or nil for the selected frame's display."
result)
(set-keymap-parent keymap local-key-translation-map)
(setq local-key-translation-map keymap)
- (unless (terminal-parameter nil 'encoded-kbd-saved-input-mode)
- (set-terminal-parameter nil 'encoded-kbd-saved-input-mode cim))
+ (unless (terminal-parameter nil 'encoded-kbd-saved-input-meta-mode)
+ (set-terminal-parameter nil 'encoded-kbd-saved-input-mode (nth 2 cim)))
(setq result (and coding (encoded-kbd-setup-keymap keymap coding)))
(if result
(when (and (eq result 8)
(memq (nth 2 cim) '(t nil)))
- (set-input-mode
- (nth 0 cim)
- (nth 1 cim)
- 'use-8th-bit
- (nth 3 cim)))
- (set-terminal-parameter nil 'encoded-kbd-saved-input-mode nil)
+ (set-input-meta-mode 'use-8th-bit))
+ (set-terminal-parameter nil 'encoded-kbd-saved-input-meta-mode nil)
(error "Unsupported coding system in Encoded-kbd mode: %S"
coding)))
;; We are turning off Encoded-kbd mode.
- (unless (equal (current-input-mode)
- (terminal-parameter nil 'encoded-kbd-saved-input-mode))
- (apply 'set-input-mode (terminal-parameter nil 'encoded-kbd-saved-input-mode)))
- (set-terminal-parameter nil 'saved-input-mode nil))))))
+ (when (and (terminal-parameter nil 'encoded-kbd-saved-input-meta-mode)
+ (not (equal (nth 2 (current-input-mode))
+ (terminal-parameter nil 'encoded-kbd-saved-input-meta-mode))))
+ (set-input-meta-mode (terminal-parameter nil 'encoded-kbd-saved-input-meta-mode)))
+ (set-terminal-parameter nil 'saved-input-meta-mode nil))))))
(provide 'encoded-kb)
diff --git a/lisp/term/linux.el b/lisp/term/linux.el
index 7fa9a96e9bd..449cd837089 100644
--- a/lisp/term/linux.el
+++ b/lisp/term/linux.el
@@ -13,9 +13,8 @@
;; Meta will continue to work, because the kernel
;; turns that into Escape.
- (let ((value (current-input-mode)))
- ;; The third arg only matters in that it is not t or nil.
- (set-input-mode (nth 0 value) (nth 1 value) 'iso-latin-1 (nth 3 value))))
+ ;; The arg only matters in that it is not t or nil.
+ (set-input-meta-mode 'iso-latin-1))
;;; arch-tag: 5d0c4f63-739b-4862-abf3-041fe42adb8f
;;; linux.el ends here
diff --git a/src/keyboard.c b/src/keyboard.c
index 2082abdf45b..e22d44a88ed 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -10649,87 +10649,199 @@ quit_throw_to_read_char ()
_longjmp (getcjmp, 1);
}
-DEFUN ("set-input-mode", Fset_input_mode, Sset_input_mode, 3, 4, 0,
- doc: /* Set mode of reading keyboard input.
-First arg INTERRUPT non-nil means use input interrupts;
- nil means use CBREAK mode.
-Second arg FLOW non-nil means use ^S/^Q flow control for output to terminal
- (no effect except in CBREAK mode).
-Third arg META t means accept 8-bit input (for a Meta key).
- META nil means ignore the top bit, on the assumption it is parity.
- Otherwise, accept 8-bit input and don't use the top bit for Meta.
-Optional fourth arg QUIT if non-nil specifies character to use for quitting.
+DEFUN ("set-input-interrupt-mode", Fset_input_interrupt_mode, Sset_input_interrupt_mode, 1, 1, 0,
+ doc: /* Set interrupt mode of reading keyboard input.
+If INTERRUPT is non-nil, Emacs will use input interrupts;
+otherwise Emacs uses CBREAK mode.
+
See also `current-input-mode'. */)
- (interrupt, flow, meta, quit)
- Lisp_Object interrupt, flow, meta, quit;
+ (interrupt)
+ Lisp_Object interrupt;
{
- /* XXX This function needs to be revised for multi-device support.
- Currently it compiles fine, but its semantics are wrong. It sets
- global parameters (e.g. interrupt_input) based on only the
- current frame's device. */
-
- if (!NILP (quit)
- && (!INTEGERP (quit) || XINT (quit) < 0 || XINT (quit) > 0400))
- error ("set-input-mode: QUIT must be an ASCII character");
-
-#ifdef POLL_FOR_INPUT
- stop_polling ();
-#endif
-
-#ifndef DOS_NT
- if (FRAME_TERMCAP_P (XFRAME (selected_frame)))
- /* this causes startup screen to be restored and messes with the mouse */
- reset_sys_modes (CURTTY ());
-#endif
-
+ int new_interrupt_input;
#ifdef SIGIO
/* Note SIGIO has been undef'd if FIONREAD is missing. */
- if (FRAME_DEVICE (SELECTED_FRAME ())->read_socket_hook)
+ if (x_display_list != NULL)
{
/* When using X, don't give the user a real choice,
because we haven't implemented the mechanisms to support it. */
#ifdef NO_SOCK_SIGIO
- interrupt_input = 0;
+ new_interrupt_input = 0;
#else /* not NO_SOCK_SIGIO */
- interrupt_input = 1;
+ new_interrupt_input = 1;
#endif /* NO_SOCK_SIGIO */
}
else
- interrupt_input = !NILP (interrupt);
+ new_interrupt_input = !NILP (interrupt);
#else /* not SIGIO */
- interrupt_input = 0;
+ new_interrupt_input = 0;
#endif /* not SIGIO */
/* Our VMS input only works by interrupts, as of now. */
#ifdef VMS
- interrupt_input = 1;
+ new_interrupt_input = 1;
+#endif
+
+ if (new_interrupt_input != interrupt_input)
+ {
+#ifdef POLL_FOR_INPUT
+ stop_polling ();
+#endif
+#ifndef DOS_NT
+ /* this causes startup screen to be restored and messes with the mouse */
+ reset_all_sys_modes ();
+#endif
+ interrupt_input = new_interrupt_input;
+#ifndef DOS_NT
+ init_all_sys_modes ();
#endif
- if (FRAME_TERMCAP_P (XFRAME (selected_frame)))
+#ifdef POLL_FOR_INPUT
+ poll_suppress_count = 1;
+ start_polling ();
+#endif
+ }
+ return Qnil;
+}
+
+DEFUN ("set-output-flow-control", Fset_output_flow_control, Sset_output_flow_control, 1, 2, 0,
+ doc: /* Enable or disable ^S/^Q flow control for output to TERMINAL.
+If FLOW is non-nil, flow control is enabled and you cannot use C-s or
+C-q in key sequences.
+
+This setting only has an effect on tty display devices and only when
+Emacs reads input in CBREAK mode; see `set-input-interrupt-mode'.
+
+See also `current-input-mode'. */)
+ (flow, terminal)
+ Lisp_Object flow, terminal;
+{
+ struct device *d = get_device (terminal, 1);
+ struct tty_display_info *tty;
+ if (d == NULL || d->type != output_termcap)
+ return Qnil;
+ tty = d->display_info.tty;
+
+ if (tty->flow_control != !NILP (flow))
{
- struct tty_display_info *tty = CURTTY ();
+#ifndef DOS_NT
+ /* this causes startup screen to be restored and messes with the mouse */
+ reset_sys_modes (tty);
+#endif
+
tty->flow_control = !NILP (flow);
- if (NILP (meta))
- tty->meta_key = 0;
- else if (EQ (meta, Qt))
- tty->meta_key = 1;
- else
- tty->meta_key = 2;
+
+#ifndef DOS_NT
+ init_sys_modes (tty);
+#endif
}
+}
+
+DEFUN ("set-input-meta-mode", Fset_input_meta_mode, Sset_input_meta_mode, 1, 2, 0,
+ doc: /* Enable or disable 8-bit input on TERMINAL.
+If META is t, Emacs will accept 8-bit input, and interpret the 8th
+bit as the Meta modifier.
+
+If META is nil, Emacs will ignore the top bit, on the assumption it is
+parity.
+
+Otherwise, Emacs will accept and pass through 8-bit input without
+specially interpreting the top bit.
+
+This setting only has an effect on tty display devices.
- if (!NILP (quit))
- /* Don't let this value be out of range. */
- quit_char = XINT (quit) & (NILP (meta) ? 0177 : 0377);
+Optional parameter TERMINAL specifies the tty display device to use.
+It may be a terminal id, a frame, or nil for the terminal used by the
+currently selected frame.
+
+See also `current-input-mode'. */)
+ (meta, terminal)
+ Lisp_Object meta, terminal;
+{
+ struct device *d = get_device (terminal, 1);
+ struct tty_display_info *tty;
+ int new_meta;
+
+ if (d == NULL || d->type != output_termcap)
+ return Qnil;
+ tty = d->display_info.tty;
+
+ if (NILP (meta))
+ new_meta = 0;
+ else if (EQ (meta, Qt))
+ new_meta = 1;
+ else
+ new_meta = 2;
+ if (tty->meta_key != new_meta)
+ {
#ifndef DOS_NT
- if (FRAME_TERMCAP_P (XFRAME (selected_frame)))
- init_sys_modes (CURTTY ());
+ /* this causes startup screen to be restored and messes with the mouse */
+ reset_sys_modes (tty);
#endif
-#ifdef POLL_FOR_INPUT
- poll_suppress_count = 1;
- start_polling ();
+ tty->meta_key = new_meta;
+
+#ifndef DOS_NT
+ init_sys_modes (tty);
+#endif
+ }
+ return Qnil;
+}
+
+DEFUN ("set-quit-char", Fset_quit_char, Sset_quit_char, 1, 1, 0,
+ doc: /* Specify character used for quitting.
+QUIT must be an ASCII character.
+
+This function only has an effect on the tty display on the controlling
+tty of the Emacs process.
+
+See also `current-input-mode'. */)
+ (quit)
+ Lisp_Object quit;
+{
+ struct device *d = get_named_tty (NULL);
+ struct tty_display_info *tty;
+ if (d == NULL || d->type != output_termcap)
+ return Qnil;
+ tty = d->display_info.tty;
+
+#ifndef DOS_NT
+ /* this causes startup screen to be restored and messes with the mouse */
+ reset_sys_modes (tty);
+#endif
+
+ if (NILP (quit) || !INTEGERP (quit) || XINT (quit) < 0 || XINT (quit) > 0400)
+ error ("QUIT must be an ASCII character");
+
+ /* Don't let this value be out of range. */
+ quit_char = XINT (quit) & (tty->meta_key == 0 ? 0177 : 0377);
+
+#ifndef DOS_NT
+ init_sys_modes (tty);
#endif
+
+ return Qnil;
+}
+
+DEFUN ("set-input-mode", Fset_input_mode, Sset_input_mode, 3, 4, 0,
+ doc: /* Set mode of reading keyboard input.
+First arg INTERRUPT non-nil means use input interrupts;
+ nil means use CBREAK mode.
+Second arg FLOW non-nil means use ^S/^Q flow control for output to terminal
+ (no effect except in CBREAK mode).
+Third arg META t means accept 8-bit input (for a Meta key).
+ META nil means ignore the top bit, on the assumption it is parity.
+ Otherwise, accept 8-bit input and don't use the top bit for Meta.
+Optional fourth arg QUIT if non-nil specifies character to use for quitting.
+See also `current-input-mode'. */)
+ (interrupt, flow, meta, quit)
+ Lisp_Object interrupt, flow, meta, quit;
+{
+ Fset_input_interrupt_mode (interrupt);
+ Fset_output_flow_control (flow, Qnil);
+ Fset_input_meta_mode (meta, Qnil);
+ Fset_quit_char (quit);
return Qnil;
}
@@ -11281,6 +11393,10 @@ syms_of_keyboard ()
defsubr (&Stop_level);
defsubr (&Sdiscard_input);
defsubr (&Sopen_dribble_file);
+ defsubr (&Sset_input_interrupt_mode);
+ defsubr (&Sset_output_flow_control);
+ defsubr (&Sset_input_meta_mode);
+ defsubr (&Sset_quit_char);
defsubr (&Sset_input_mode);
defsubr (&Scurrent_input_mode);
defsubr (&Sexecute_extended_command);
diff --git a/src/lisp.h b/src/lisp.h
index dd9992d08be..a18408bd1a6 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2939,6 +2939,10 @@ extern Lisp_Object Qvertical_scroll_bar;
extern void discard_mouse_events P_ ((void));
EXFUN (Fevent_convert_list, 1);
EXFUN (Fread_key_sequence, 5);
+EXFUN (Fset_input_interrupt_mode, 1);
+EXFUN (Fset_output_flow_control, 2);
+EXFUN (Fset_input_meta_mode, 2);
+EXFUN (Fset_quit_char, 1);
EXFUN (Fset_input_mode, 4);
extern int detect_input_pending P_ ((void));
extern int detect_input_pending_ignore_squeezables P_ ((void));
diff --git a/src/macterm.c b/src/macterm.c
index ae2942c4cf9..ba39450b4b4 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -10630,7 +10630,7 @@ mac_initialize ()
any_help_event_p = 0;
/* Try to use interrupt input; if we can't, then start polling. */
- Fset_input_mode (Qt, Qnil, Qt, Qnil);
+ Fset_input_interrupt_mode (Qt);
BLOCK_INPUT;
diff --git a/src/xterm.c b/src/xterm.c
index cf0c8176dd5..5da3f422f80 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -10868,7 +10868,7 @@ x_initialize ()
#endif
/* Try to use interrupt input; if we can't, then start polling. */
- Fset_input_mode (Qt, Qnil, Qt, Qnil);
+ Fset_input_interrupt_mode (Qt);
#ifdef USE_X_TOOLKIT
XtToolkitInitialize ();