diff options
author | Jim Blandy <jimb@redhat.com> | 1992-11-16 00:45:02 +0000 |
---|---|---|
committer | Jim Blandy <jimb@redhat.com> | 1992-11-16 00:45:02 +0000 |
commit | e37c080581f5517697c6fc8fbabd626e1ca69b74 (patch) | |
tree | 1a92bd3eb41515db3df82a601311fdadb7c29c00 /src | |
parent | 8f805655d50508e04b80e5cd37b5f4f40b4098c7 (diff) | |
download | emacs-e37c080581f5517697c6fc8fbabd626e1ca69b74.tar.gz emacs-e37c080581f5517697c6fc8fbabd626e1ca69b74.tar.bz2 emacs-e37c080581f5517697c6fc8fbabd626e1ca69b74.zip |
* lread.c: #include "keyboard.h".
(Fread_char, Fread_char_exclusive): Don't signal an
error for or throw away switch-frame events; instead, put them off
until after we've found a character we can respond to.
Rename unread_command_char to unread_command_event; it has
subtly different semantics now, and we should use
`make-obsolete-variable' to warn people.
* lread.c (Fread_char): Change reference.
Diffstat (limited to 'src')
-rw-r--r-- | src/lread.c | 80 |
1 files changed, 66 insertions, 14 deletions
diff --git a/src/lread.c b/src/lread.c index 0a5c0b2b940..ded35fa780a 100644 --- a/src/lread.c +++ b/src/lread.c @@ -32,6 +32,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "buffer.h" #include "paths.h" #include "commands.h" +#include "keyboard.h" #endif #ifdef lint @@ -164,20 +165,48 @@ DEFUN ("read-char", Fread_char, Sread_char, 0, 0, 0, "Read a character from the command input (keyboard or macro).\n\ It is returned as a number.\n\ If the user generates an event which is not a character (i.e. a mouse\n\ -click or function key event), `read-char' signals an error. If you\n\ -want to read non-character events, or ignore them, call `read-event'\n\ -or `read-char-exclusive' instead.") +click or function key event), `read-char' signals an error. As an\n\ +exception, switch-frame events are put off until non-ASCII events can\n\ +be read.\n\ +If you want to read non-character events, or ignore them, call\n\ +`read-event' or `read-char-exclusive' instead.") () { register Lisp_Object val; #ifndef standalone - val = read_char (0, 0, 0, Qnil, 0); - if (XTYPE (val) != Lisp_Int) - { - unread_command_char = val; - error ("Object read was not a character"); - } + { + register Lisp_Object delayed_switch_frame; + + delayed_switch_frame = Qnil; + + for (;;) + { + val = read_char (0, 0, 0, Qnil, 0); + + /* switch-frame events are put off until after the next ASCII + character. This is better than signalling an error just + because the last characters were typed to a separate + minibuffer frame, for example. Eventually, some code which + can deal with switch-frame events will read it and process + it. */ + if (EVENT_HAS_PARAMETERS (val) + && EQ (EVENT_HEAD (val), Qswitch_frame)) + delayed_switch_frame = val; + else + break; + } + + if (! NILP (delayed_switch_frame)) + unread_switch_frame = delayed_switch_frame; + + /* Only ASCII characters are acceptable. */ + if (XTYPE (val) != Lisp_Int) + { + unread_command_event = val; + error ("Object read was not a character"); + } + } #else val = getchar (); #endif @@ -203,11 +232,34 @@ It is returned as a number. Non character events are ignored.") register Lisp_Object val; #ifndef standalone - do - { - val = read_char (0, 0, 0, Qnil, 0); - } - while (XTYPE (val) != Lisp_Int); + { + Lisp_Object delayed_switch_frame; + + delayed_switch_frame = Qnil; + + for (;;) + { + val = read_char (0, 0, 0, Qnil, 0); + + if (XTYPE (val) == Lisp_Int) + break; + + /* switch-frame events are put off until after the next ASCII + character. This is better than signalling an error just + because the last characters were typed to a separate + minibuffer frame, for example. Eventually, some code which + can deal with switch-frame events will read it and process + it. */ + else if (EVENT_HAS_PARAMETERS (val) + && EQ (EVENT_HEAD (val), Qswitch_frame)) + delayed_switch_frame = val; + + /* Drop everything else. */ + } + + if (! NILP (delayed_switch_frame)) + unread_switch_frame = delayed_switch_frame; + } #else val = getchar (); #endif |