aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey2005-12-23 03:00:55 +0000
committerKaroly Lorentey2005-12-23 03:00:55 +0000
commita712a8c33b63a0ea6775034f10a55d933c55fdeb (patch)
tree02ec4f5edde26c50885024b5cc91d729497b28ae /src
parentf35ca2fe35859b40b1b0ff15a1751aab4805d392 (diff)
downloademacs-a712a8c33b63a0ea6775034f10a55d933c55fdeb.tar.gz
emacs-a712a8c33b63a0ea6775034f10a55d933c55fdeb.zip
Don't let x_initialize break 8-bit input on ttys. (Reported by Joakim Verona.) Split `set-input-mode'.
* lisp/international/encoded-kb.el (encoded-kbd-setup-display): Use `set-input-meta-mode'. * lisp/linux.el (terminal-init-linux): Ditto. * src/keyboard.c (Fset_input_interrupt_mode, Fset_output_flow_control) (syms_of_keyboard): Defsubr them. (Fset_input_meta_mode, Fset_quit_char): New functions. (Fset_input_mode): Split to above functions. * lisp.h: EXFUN the new functions. * xterm.c (x_initialize): Use Fset_input_interrupt_mode. * macterm.c (mac_initialize): Ditto. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-457
Diffstat (limited to 'src')
-rw-r--r--src/keyboard.c222
-rw-r--r--src/lisp.h4
-rw-r--r--src/macterm.c2
-rw-r--r--src/xterm.c2
4 files changed, 175 insertions, 55 deletions
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 ()
10649 _longjmp (getcjmp, 1); 10649 _longjmp (getcjmp, 1);
10650} 10650}
10651 10651
10652DEFUN ("set-input-mode", Fset_input_mode, Sset_input_mode, 3, 4, 0, 10652DEFUN ("set-input-interrupt-mode", Fset_input_interrupt_mode, Sset_input_interrupt_mode, 1, 1, 0,
10653 doc: /* Set mode of reading keyboard input. 10653 doc: /* Set interrupt mode of reading keyboard input.
10654First arg INTERRUPT non-nil means use input interrupts; 10654If INTERRUPT is non-nil, Emacs will use input interrupts;
10655 nil means use CBREAK mode. 10655otherwise Emacs uses CBREAK mode.
10656Second arg FLOW non-nil means use ^S/^Q flow control for output to terminal 10656
10657 (no effect except in CBREAK mode).
10658Third arg META t means accept 8-bit input (for a Meta key).
10659 META nil means ignore the top bit, on the assumption it is parity.
10660 Otherwise, accept 8-bit input and don't use the top bit for Meta.
10661Optional fourth arg QUIT if non-nil specifies character to use for quitting.
10662See also `current-input-mode'. */) 10657See also `current-input-mode'. */)
10663 (interrupt, flow, meta, quit) 10658 (interrupt)
10664 Lisp_Object interrupt, flow, meta, quit; 10659 Lisp_Object interrupt;
10665{ 10660{
10666 /* XXX This function needs to be revised for multi-device support. 10661 int new_interrupt_input;
10667 Currently it compiles fine, but its semantics are wrong. It sets
10668 global parameters (e.g. interrupt_input) based on only the
10669 current frame's device. */
10670
10671 if (!NILP (quit)
10672 && (!INTEGERP (quit) || XINT (quit) < 0 || XINT (quit) > 0400))
10673 error ("set-input-mode: QUIT must be an ASCII character");
10674
10675#ifdef POLL_FOR_INPUT
10676 stop_polling ();
10677#endif
10678
10679#ifndef DOS_NT
10680 if (FRAME_TERMCAP_P (XFRAME (selected_frame)))
10681 /* this causes startup screen to be restored and messes with the mouse */
10682 reset_sys_modes (CURTTY ());
10683#endif
10684
10685#ifdef SIGIO 10662#ifdef SIGIO
10686/* Note SIGIO has been undef'd if FIONREAD is missing. */ 10663/* Note SIGIO has been undef'd if FIONREAD is missing. */
10687 if (FRAME_DEVICE (SELECTED_FRAME ())->read_socket_hook) 10664 if (x_display_list != NULL)
10688 { 10665 {
10689 /* When using X, don't give the user a real choice, 10666 /* When using X, don't give the user a real choice,
10690 because we haven't implemented the mechanisms to support it. */ 10667 because we haven't implemented the mechanisms to support it. */
10691#ifdef NO_SOCK_SIGIO 10668#ifdef NO_SOCK_SIGIO
10692 interrupt_input = 0; 10669 new_interrupt_input = 0;
10693#else /* not NO_SOCK_SIGIO */ 10670#else /* not NO_SOCK_SIGIO */
10694 interrupt_input = 1; 10671 new_interrupt_input = 1;
10695#endif /* NO_SOCK_SIGIO */ 10672#endif /* NO_SOCK_SIGIO */
10696 } 10673 }
10697 else 10674 else
10698 interrupt_input = !NILP (interrupt); 10675 new_interrupt_input = !NILP (interrupt);
10699#else /* not SIGIO */ 10676#else /* not SIGIO */
10700 interrupt_input = 0; 10677 new_interrupt_input = 0;
10701#endif /* not SIGIO */ 10678#endif /* not SIGIO */
10702 10679
10703/* Our VMS input only works by interrupts, as of now. */ 10680/* Our VMS input only works by interrupts, as of now. */
10704#ifdef VMS 10681#ifdef VMS
10705 interrupt_input = 1; 10682 new_interrupt_input = 1;
10683#endif
10684
10685 if (new_interrupt_input != interrupt_input)
10686 {
10687#ifdef POLL_FOR_INPUT
10688 stop_polling ();
10689#endif
10690#ifndef DOS_NT
10691 /* this causes startup screen to be restored and messes with the mouse */
10692 reset_all_sys_modes ();
10693#endif
10694 interrupt_input = new_interrupt_input;
10695#ifndef DOS_NT
10696 init_all_sys_modes ();
10706#endif 10697#endif
10707 10698
10708 if (FRAME_TERMCAP_P (XFRAME (selected_frame))) 10699#ifdef POLL_FOR_INPUT
10700 poll_suppress_count = 1;
10701 start_polling ();
10702#endif
10703 }
10704 return Qnil;
10705}
10706
10707DEFUN ("set-output-flow-control", Fset_output_flow_control, Sset_output_flow_control, 1, 2, 0,
10708 doc: /* Enable or disable ^S/^Q flow control for output to TERMINAL.
10709If FLOW is non-nil, flow control is enabled and you cannot use C-s or
10710C-q in key sequences.
10711
10712This setting only has an effect on tty display devices and only when
10713Emacs reads input in CBREAK mode; see `set-input-interrupt-mode'.
10714
10715See also `current-input-mode'. */)
10716 (flow, terminal)
10717 Lisp_Object flow, terminal;
10718{
10719 struct device *d = get_device (terminal, 1);
10720 struct tty_display_info *tty;
10721 if (d == NULL || d->type != output_termcap)
10722 return Qnil;
10723 tty = d->display_info.tty;
10724
10725 if (tty->flow_control != !NILP (flow))
10709 { 10726 {
10710 struct tty_display_info *tty = CURTTY (); 10727#ifndef DOS_NT
10728 /* this causes startup screen to be restored and messes with the mouse */
10729 reset_sys_modes (tty);
10730#endif
10731
10711 tty->flow_control = !NILP (flow); 10732 tty->flow_control = !NILP (flow);
10712 if (NILP (meta)) 10733
10713 tty->meta_key = 0; 10734#ifndef DOS_NT
10714 else if (EQ (meta, Qt)) 10735 init_sys_modes (tty);
10715 tty->meta_key = 1; 10736#endif
10716 else
10717 tty->meta_key = 2;
10718 } 10737 }
10738}
10739
10740DEFUN ("set-input-meta-mode", Fset_input_meta_mode, Sset_input_meta_mode, 1, 2, 0,
10741 doc: /* Enable or disable 8-bit input on TERMINAL.
10742If META is t, Emacs will accept 8-bit input, and interpret the 8th
10743bit as the Meta modifier.
10744
10745If META is nil, Emacs will ignore the top bit, on the assumption it is
10746parity.
10747
10748Otherwise, Emacs will accept and pass through 8-bit input without
10749specially interpreting the top bit.
10750
10751This setting only has an effect on tty display devices.
10719 10752
10720 if (!NILP (quit)) 10753Optional parameter TERMINAL specifies the tty display device to use.
10721 /* Don't let this value be out of range. */ 10754It may be a terminal id, a frame, or nil for the terminal used by the
10722 quit_char = XINT (quit) & (NILP (meta) ? 0177 : 0377); 10755currently selected frame.
10756
10757See also `current-input-mode'. */)
10758 (meta, terminal)
10759 Lisp_Object meta, terminal;
10760{
10761 struct device *d = get_device (terminal, 1);
10762 struct tty_display_info *tty;
10763 int new_meta;
10764
10765 if (d == NULL || d->type != output_termcap)
10766 return Qnil;
10767 tty = d->display_info.tty;
10768
10769 if (NILP (meta))
10770 new_meta = 0;
10771 else if (EQ (meta, Qt))
10772 new_meta = 1;
10773 else
10774 new_meta = 2;
10723 10775
10776 if (tty->meta_key != new_meta)
10777 {
10724#ifndef DOS_NT 10778#ifndef DOS_NT
10725 if (FRAME_TERMCAP_P (XFRAME (selected_frame))) 10779 /* this causes startup screen to be restored and messes with the mouse */
10726 init_sys_modes (CURTTY ()); 10780 reset_sys_modes (tty);
10727#endif 10781#endif
10728 10782
10729#ifdef POLL_FOR_INPUT 10783 tty->meta_key = new_meta;
10730 poll_suppress_count = 1; 10784
10731 start_polling (); 10785#ifndef DOS_NT
10786 init_sys_modes (tty);
10787#endif
10788 }
10789 return Qnil;
10790}
10791
10792DEFUN ("set-quit-char", Fset_quit_char, Sset_quit_char, 1, 1, 0,
10793 doc: /* Specify character used for quitting.
10794QUIT must be an ASCII character.
10795
10796This function only has an effect on the tty display on the controlling
10797tty of the Emacs process.
10798
10799See also `current-input-mode'. */)
10800 (quit)
10801 Lisp_Object quit;
10802{
10803 struct device *d = get_named_tty (NULL);
10804 struct tty_display_info *tty;
10805 if (d == NULL || d->type != output_termcap)
10806 return Qnil;
10807 tty = d->display_info.tty;
10808
10809#ifndef DOS_NT
10810 /* this causes startup screen to be restored and messes with the mouse */
10811 reset_sys_modes (tty);
10812#endif
10813
10814 if (NILP (quit) || !INTEGERP (quit) || XINT (quit) < 0 || XINT (quit) > 0400)
10815 error ("QUIT must be an ASCII character");
10816
10817 /* Don't let this value be out of range. */
10818 quit_char = XINT (quit) & (tty->meta_key == 0 ? 0177 : 0377);
10819
10820#ifndef DOS_NT
10821 init_sys_modes (tty);
10732#endif 10822#endif
10823
10824 return Qnil;
10825}
10826
10827DEFUN ("set-input-mode", Fset_input_mode, Sset_input_mode, 3, 4, 0,
10828 doc: /* Set mode of reading keyboard input.
10829First arg INTERRUPT non-nil means use input interrupts;
10830 nil means use CBREAK mode.
10831Second arg FLOW non-nil means use ^S/^Q flow control for output to terminal
10832 (no effect except in CBREAK mode).
10833Third arg META t means accept 8-bit input (for a Meta key).
10834 META nil means ignore the top bit, on the assumption it is parity.
10835 Otherwise, accept 8-bit input and don't use the top bit for Meta.
10836Optional fourth arg QUIT if non-nil specifies character to use for quitting.
10837See also `current-input-mode'. */)
10838 (interrupt, flow, meta, quit)
10839 Lisp_Object interrupt, flow, meta, quit;
10840{
10841 Fset_input_interrupt_mode (interrupt);
10842 Fset_output_flow_control (flow, Qnil);
10843 Fset_input_meta_mode (meta, Qnil);
10844 Fset_quit_char (quit);
10733 return Qnil; 10845 return Qnil;
10734} 10846}
10735 10847
@@ -11281,6 +11393,10 @@ syms_of_keyboard ()
11281 defsubr (&Stop_level); 11393 defsubr (&Stop_level);
11282 defsubr (&Sdiscard_input); 11394 defsubr (&Sdiscard_input);
11283 defsubr (&Sopen_dribble_file); 11395 defsubr (&Sopen_dribble_file);
11396 defsubr (&Sset_input_interrupt_mode);
11397 defsubr (&Sset_output_flow_control);
11398 defsubr (&Sset_input_meta_mode);
11399 defsubr (&Sset_quit_char);
11284 defsubr (&Sset_input_mode); 11400 defsubr (&Sset_input_mode);
11285 defsubr (&Scurrent_input_mode); 11401 defsubr (&Scurrent_input_mode);
11286 defsubr (&Sexecute_extended_command); 11402 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;
2939extern void discard_mouse_events P_ ((void)); 2939extern void discard_mouse_events P_ ((void));
2940EXFUN (Fevent_convert_list, 1); 2940EXFUN (Fevent_convert_list, 1);
2941EXFUN (Fread_key_sequence, 5); 2941EXFUN (Fread_key_sequence, 5);
2942EXFUN (Fset_input_interrupt_mode, 1);
2943EXFUN (Fset_output_flow_control, 2);
2944EXFUN (Fset_input_meta_mode, 2);
2945EXFUN (Fset_quit_char, 1);
2942EXFUN (Fset_input_mode, 4); 2946EXFUN (Fset_input_mode, 4);
2943extern int detect_input_pending P_ ((void)); 2947extern int detect_input_pending P_ ((void));
2944extern int detect_input_pending_ignore_squeezables P_ ((void)); 2948extern 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 ()
10630 any_help_event_p = 0; 10630 any_help_event_p = 0;
10631 10631
10632 /* Try to use interrupt input; if we can't, then start polling. */ 10632 /* Try to use interrupt input; if we can't, then start polling. */
10633 Fset_input_mode (Qt, Qnil, Qt, Qnil); 10633 Fset_input_interrupt_mode (Qt);
10634 10634
10635 BLOCK_INPUT; 10635 BLOCK_INPUT;
10636 10636
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 ()
10868#endif 10868#endif
10869 10869
10870 /* Try to use interrupt input; if we can't, then start polling. */ 10870 /* Try to use interrupt input; if we can't, then start polling. */
10871 Fset_input_mode (Qt, Qnil, Qt, Qnil); 10871 Fset_input_interrupt_mode (Qt);
10872 10872
10873#ifdef USE_X_TOOLKIT 10873#ifdef USE_X_TOOLKIT
10874 XtToolkitInitialize (); 10874 XtToolkitInitialize ();