Mercurial > emacs
diff src/dispnew.c @ 90533:8a8e69664178
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 343-356)
- Update from CVS
- Update for ERC 5.1.3.
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 113-115)
- Merge from emacs--devo--0
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-90
author | Miles Bader <miles@gnu.org> |
---|---|
date | Wed, 19 Jul 2006 00:42:56 +0000 |
parents | 138ce2701550 db54d1f64f25 |
children | a1a25ac6c88a |
line wrap: on
line diff
--- a/src/dispnew.c Fri Jul 14 02:25:53 2006 +0000 +++ b/src/dispnew.c Wed Jul 19 00:42:56 2006 +0000 @@ -6481,31 +6481,43 @@ /* This is just like wait_reading_process_output, except that - it does the redisplay. - - It's also much like Fsit_for, except that it can be used for - waiting for input as well. */ + it does redisplay. + + TIMEOUT is number of seconds to wait (float or integer). + READING is 1 if reading input. + If DO_DISPLAY is >0 display process output while waiting. + If DO_DISPLAY is >1 perform an initial redisplay before waiting. +*/ Lisp_Object -sit_for (sec, usec, reading, display, initial_display) - int sec, usec, reading, display, initial_display; +sit_for (timeout, reading, do_display) + Lisp_Object timeout; + int reading, do_display; { - int preempt = (sec > 0) || (sec == 0 && usec >= 0); - - swallow_events (display); - - if ((detect_input_pending_run_timers (display) && preempt) + int sec, usec; + + swallow_events (do_display); + + if ((detect_input_pending_run_timers (do_display)) || !NILP (Vexecuting_kbd_macro)) return Qnil; - if (initial_display) + if (do_display >= 2) + redisplay_preserve_echo_area (2); + + if (INTEGERP (timeout)) { - int count = SPECPDL_INDEX (); - if (!preempt) - specbind (Qredisplay_dont_pause, Qt); - redisplay_preserve_echo_area (2); - unbind_to (count, Qnil); + sec = XINT (timeout); + usec = 0; } + else if (FLOATP (timeout)) + { + double seconds = XFLOAT_DATA (timeout); + sec = (int) seconds; + usec = (int) ((seconds - sec) * 1000000); + } + else + wrong_type_argument (Qnumberp, timeout); if (sec == 0 && usec == 0) return Qt; @@ -6514,63 +6526,34 @@ gobble_input (0); #endif - wait_reading_process_output (sec, usec, reading ? -1 : 1, display, + wait_reading_process_output (sec, usec, reading ? -1 : 1, do_display, Qnil, NULL, 0); return detect_input_pending () ? Qnil : Qt; } -DEFUN ("sit-for", Fsit_for, Ssit_for, 1, 3, 0, - doc: /* Perform redisplay, then wait for SECONDS seconds or until input is available. -SECONDS may be a floating-point value, meaning that you can wait for a -fraction of a second. -\(Not all operating systems support waiting for a fraction of a second.) -Optional arg NODISP non-nil means don't redisplay, just wait for input. -Redisplay is preempted as always if input arrives, and does not happen -if input is available before it starts. -Value is t if waited the full time with no input arriving. - -Redisplay will occur even when input is available if SECONDS is negative. - -An obsolete but still supported form is -\(sit-for SECONDS &optional MILLISECONDS NODISP) -Where the optional arg MILLISECONDS specifies an additional wait period, -in milliseconds; this was useful when Emacs was built without -floating point support. -usage: (sit-for SECONDS &optional NODISP OLD-NODISP) */) - -/* The `old-nodisp' stuff is there so that the arglist has the correct - length. Otherwise, `defdvice' will redefine it with fewer args. */ - (seconds, milliseconds, nodisp) - Lisp_Object seconds, milliseconds, nodisp; +DEFUN ("redisplay", Fredisplay, Sredisplay, 0, 1, 0, + doc: /* Perform redisplay if no input is available. +If optional arg FORCE is non-nil or `redisplay-dont-pause' is non-nil, +perform a full redisplay even if input is available. */) + (force) + Lisp_Object force; { - int sec, usec; - - if (NILP (nodisp) && !NUMBERP (milliseconds)) - { /* New style. */ - nodisp = milliseconds; - milliseconds = Qnil; - } - - if (NILP (milliseconds)) - XSETINT (milliseconds, 0); - else - CHECK_NUMBER (milliseconds); - usec = XINT (milliseconds) * 1000; - - { - double duration = extract_float (seconds); - sec = (int) duration; - usec += (duration - sec) * 1000000; - } - -#ifndef EMACS_HAS_USECS - if (usec != 0 && sec == 0) - error ("Millisecond `sit-for' not supported on %s", SYSTEM_TYPE); -#endif - - return sit_for (sec, usec, 0, NILP (nodisp), NILP (nodisp)); + int count; + + swallow_events (1); + if ((detect_input_pending_run_timers (1) + && NILP (force) && !redisplay_dont_pause) + || !NILP (Vexecuting_kbd_macro)) + return Qnil; + + count = SPECPDL_INDEX (); + if (!NILP (force) && !redisplay_dont_pause) + specbind (Qredisplay_dont_pause, Qt); + redisplay_preserve_echo_area (2); + unbind_to (count, Qnil); + return Qt; } @@ -6828,9 +6811,15 @@ For types defined in VMS, use set term /device=TYPE.\n\ For types not defined in VMS, use define emacs_term \"TYPE\".\n\ \(The quotation marks are necessary since terminal types are lower case.)\n"); -#else - fprintf (stderr, "Please set the environment variable TERM; see tset(1).\n"); -#endif +#else /* not VMS */ + +#ifdef HAVE_WINDOW_SYSTEM + if (! inhibit_window_system) + fprintf (stderr, "Please set the environment variable DISPLAY or TERM (see `tset').\n"); + else +#endif /* HAVE_WINDOW_SYSTEM */ + fprintf (stderr, "Please set the environment variable TERM; see `tset'.\n"); +#endif /* not VMS */ exit (1); } @@ -6960,7 +6949,7 @@ defsubr (&Sframe_or_buffer_changed_p); defsubr (&Sopen_termscript); defsubr (&Sding); - defsubr (&Ssit_for); + defsubr (&Sredisplay); defsubr (&Ssleep_for); defsubr (&Ssend_string_to_terminal); defsubr (&Sinternal_show_cursor);