/* Keyboard and mouse input; editor command loop.
- Copyright (C) 1985, 1986, 1987, 1988, 1989 Free Software Foundation, Inc.
+ Copyright (C) 1985, 1986, 1987, 1988, 1989, 1992 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include <setjmp.h>
#include <errno.h>
-#include "emacssignal.h"
-
-extern int errno;
-
-/* Get FIONREAD, if it is available. */
-#ifdef USG
-#include <termio.h>
-#include <fcntl.h>
-#else /* not USG */
#ifndef VMS
#include <sys/ioctl.h>
-#endif /* not VMS */
-#endif /* not USG */
-
-/* UNIPLUS systems may have FIONREAD. */
-#ifdef UNIPLUS
-#include <sys.ioctl.h>
#endif
+#include "syssignal.h"
+#include "systerm.h"
+#include "systime.h"
+
+extern int errno;
+
#ifdef HAVE_X_WINDOWS
extern Lisp_Object Vmouse_grabbed;
/* Last size recorded for a current buffer which is not a minibuffer. */
static int last_non_minibuf_size;
-/* Number of idle seconds before an auto-save. */
+/* Number of idle seconds before an auto-save and garbage collection. */
static Lisp_Object Vauto_save_timeout;
/* Total number of times read_char has returned. */
Lisp_Object Qvertical_split;
-/* Address (if not 0) of word to zero out if a SIGIO interrupt happens. */
-long *input_available_clear_word;
+/* Address (if not 0) of EMACS_TIME to zero out if a SIGIO interrupt
+ happens. */
+EMACS_TIME *input_available_clear_time;
/* Nonzero means use SIGIO interrupts; zero means use CBREAK mode.
Default is 1 if INTERRUPT_INPUT is defined. */
/* nonzero means use ^S/^Q for flow control. */
int flow_control;
-#ifndef BSD4_1
-#define sigfree() sigsetmask (SIGEMPTYMASK)
-#define sigholdx(sig) sigsetmask (sigmask (sig))
-#define sigblockx(sig) sigblock (sigmask (sig))
-#define sigunblockx(sig) sigblock (SIGEMPTYMASK)
-#define sigpausex(sig) sigpause (0)
-#endif /* not BSD4_1 */
-
-#ifdef BSD4_1
-#define SIGIO SIGTINT
-/* sigfree and sigholdx are in sysdep.c */
-#define sigblockx(sig) sighold (sig)
-#define sigunblockx(sig) sigrelse (sig)
-#define sigpausex(sig) sigpause (sig)
-#endif /* BSD4_1 */
-
/* Allow m- file to inhibit use of FIONREAD. */
#ifdef BROKEN_FIONREAD
#undef FIONREAD
||
(dp && (XTYPE (dp->contents[lose]) != Lisp_String
|| XSTRING (dp->contents[lose])->size == sizeof (GLYPH))))
- && (SCREEN_CURSOR_X (selected_screen)
- != SCREEN_WIDTH (selected_screen) - 1)
&& (XFASTINT (XWINDOW (selected_window)->last_modified)
>= MODIFF)
&& (XFASTINT (XWINDOW (selected_window)->last_point)
||
(dp && (XTYPE (dp->contents[lose]) != Lisp_String
|| XSTRING (dp->contents[lose])->size == sizeof (GLYPH))))
- && (SCREEN_CURSOR_X (selected_screen) != 0)
&& (XFASTINT (XWINDOW (selected_window)->last_modified)
>= MODIFF)
&& (XFASTINT (XWINDOW (selected_window)->last_point)
Fundo_boundary ();
Fcommand_execute (cmd, Qnil);
- directly_done: ;
}
+ directly_done: ;
/* If there is a prefix argument,
1) We don't want last_command to be ``universal-argument''
}
/* Save outer setjmp data, in case called recursively. */
- bcopy (getcjmp, save_jump, sizeof getcjmp);
+ save_getcjmp (save_jump);
stop_polling ();
if (_setjmp (getcjmp))
{
XSET (c, Lisp_Int, quit_char);
-
- /* Returning quit_char from this function represents a
- resolution to the quit request, so clear the quit flag.
- This prevents us from returning quit_char many times
- for the same quit request. */
- Vquit_flag = Qnil;
-
- waiting_for_input = 0;
- input_available_clear_word = 0;
+#ifdef MULTI_SCREEN
+ XSET (Vlast_event_screen, Lisp_Screen, selected_screen);
+#endif
goto non_reread;
}
{
Lisp_Object tem0;
- tem0 = Fsit_for (make_number (echo_keystrokes), Qnil, Qt);
+ tem0 = sit_for (echo_keystrokes, 0, 1, 1);
if (EQ (tem0, Qt))
echo ();
}
{
Lisp_Object tem0;
int delay = delay_level * XFASTINT (Vauto_save_timeout) / 4;
- tem0 = Fsit_for (make_number (delay), Qnil, Qt);
+ tem0 = sit_for (delay, 0, 1, 1);
if (EQ (tem0, Qt))
{
jmp_buf temp;
non_reread:
- bcopy (save_jump, getcjmp, sizeof getcjmp);
+ restore_getcjmp (save_jump);
start_polling ();
DEFUN ("track-mouse", Ftrack_mouse, Strack_mouse, 0, UNEVALLED, 0,
"Evaluate BODY with mouse movement and button release events enabled.\n\
-Within a track-mouse, read-event reports mouse movement and button releases;\n\
-otherwise, they are ignored.")
+Within a `track-mouse', mouse motion and button releases generate input\n\
+events that you can read with `read-event'.\n\
+Normally, these occurrences don't generate events.")
(args)
Lisp_Object args;
{
will set Vlast_event_screen again, so this is safe to do. */
extern SIGTYPE interrupt_signal ();
XSET (Vlast_event_screen, Lisp_Screen, event->screen);
- last_event_timestamp = XINT (event->timestamp);
+ last_event_timestamp = event->timestamp;
interrupt_signal ();
return;
}
#endif /* SIGIO */
if (EVENT_QUEUES_EMPTY)
{
-#ifdef subprocesses
- wait_reading_process_input (0, 0, -1, 1);
-#else
-/* Note SIGIO has been undef'd if FIONREAD is missing. */
-#ifdef SIGIO
- if (interrupt_input)
- {
- sigblockx (SIGIO);
- set_waiting_for_input (0);
- while (EVENT_QUEUES_EMPTY)
- sigpausex (SIGIO);
- clear_waiting_for_input ();
- sigunblockx (SIGIO);
- }
-#else
- interrupt_input = 0;
-#endif /* not SIGIO */
-#endif /* subprocesses */
+ Lisp_Object minus_one;
+
+ XSET (minus_one, Lisp_Int, -1);
+ wait_reading_process_input (0, 0, minus_one, 1);
if (!interrupt_input && EVENT_QUEUES_EMPTY)
{
#ifdef SIGIO
if (interrupt_input)
{
- SIGMASKTYPE mask = sigblockx (SIGIO);
+ SIGMASKTYPE mask;
+ mask = sigblockx (SIGIO);
read_avail_input (expected);
sigsetmask (mask);
}
sigisheld (SIGIO);
#endif
- if (input_available_clear_word)
- *input_available_clear_word = 0;
+ if (input_available_clear_time)
+ EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0);
while (1)
{
{
fkey_next =
get_keyelt (access_keymap (fkey_map, keybuf[fkey_end++]));
-
/* If keybuf[fkey_start..fkey_next] is bound in the
- function key map and it's a suffix, replace it with
- the binding and restart. */
+ function key map and it's a suffix of the current
+ sequence (i.e. fkey_next == t), replace it with
+ the binding and restart with fkey_start at the end. */
if (XTYPE (fkey_next) == Lisp_Vector
&& fkey_end == t)
{
fkey_map = get_keymap_1 (fkey_next, 0);
- /* If we no longer have a bound suffix, advance
- the start of the function key suffix and continue
- scanning from there. */
+ /* If we no longer have a bound suffix, try a new positions for
+ fkey_start. */
if (NILP (fkey_map))
{
fkey_end = ++fkey_start;
while (1)
{
- final = cmd;
- while (XTYPE (final) == Lisp_Symbol)
- {
- if (EQ (Qunbound, XSYMBOL (final)->function))
- Fsymbol_function (final); /* Get an error! */
- final = XSYMBOL (final)->function;
- }
+ final = Findirect_function (cmd);
if (CONSP (final) && (tem = Fcar (final), EQ (tem, Qautoload)))
do_autoload (final, cmd);
return input_pending;
}
+/* This is called in some cases before a possible quit.
+ It cases the next call to detect_input_pending to recompute input_pending.
+ So calling this function unnecessarily can't do any harm. */
+clear_input_pending ()
+{
+ input_pending = 0;
+}
+
DEFUN ("input-pending-p", Finput_pending_p, Sinput_pending_p, 0, 0, 0,
"T if command input is currently available with no waiting.\n\
Actually, the value is nil only if we can be sure that no input is available.")
#endif /* BSD and not BSD4_1 */
}
\f
-set_waiting_for_input (word_to_clear)
- long *word_to_clear;
+set_waiting_for_input (time_to_clear)
+ EMACS_TIME *time_to_clear;
{
- input_available_clear_word = word_to_clear;
+ input_available_clear_time = time_to_clear;
/* Tell interrupt_signal to throw back to read_char, */
waiting_for_input = 1;
{
/* Tell interrupt_signal not to throw back to read_char, */
waiting_for_input = 0;
- input_available_clear_word = 0;
+ input_available_clear_time = 0;
}
/* This routine is called at interrupt level in response to C-G.
quit_error_check ();
sigfree ();
/* Prevent another signal from doing this before we finish. */
- waiting_for_input = 0;
+ clear_waiting_for_input ();
input_pending = 0;
#if 0
DEFVAR_LISP ("auto-save-timeout", &Vauto_save_timeout,
"*Number of seconds idle time before auto-save.\n\
-Zero or nil means disable auto-saving due to idleness.");
+Zero or nil means disable auto-saving due to idleness.\n\
+After auto-saving due to this many seconds of idle time,\n\
+Emacs also does a garbage collection if that seems to be warranted."
XFASTINT (Vauto_save_timeout) = 30;
DEFVAR_INT ("echo-keystrokes", &echo_keystrokes,