diff options
| author | Karl Heuer | 1995-12-19 20:57:15 +0000 |
|---|---|---|
| committer | Karl Heuer | 1995-12-19 20:57:15 +0000 |
| commit | 382cafff99c5655c9598d3fc44455aca81c00918 (patch) | |
| tree | 70f8f3681bf191cdf30f8c4b1f0ec8ee4edd5e09 /src | |
| parent | 600a5f71e6ccb20a5f74c41bdd0475d61066f94b (diff) | |
| download | emacs-382cafff99c5655c9598d3fc44455aca81c00918.tar.gz emacs-382cafff99c5655c9598d3fc44455aca81c00918.zip | |
(check_timer): get rid of the DOS-specific menubar clock
feature; call `display-time-filter' from time.el to display time
on the modeline instead. This makes `display-time' work under DOS.
(abort): use our own function instead of the one from the library
which reverts the console device to cooked mode.
(syms_of_msdos): `dos-display-time'--a new variable for
communicating with `display-time'.
Diffstat (limited to 'src')
| -rw-r--r-- | src/msdos.c | 101 |
1 files changed, 57 insertions, 44 deletions
diff --git a/src/msdos.c b/src/msdos.c index 075f8bfa50b..13be3e89f07 100644 --- a/src/msdos.c +++ b/src/msdos.c | |||
| @@ -2387,66 +2387,66 @@ setpriority (x,y,z) int x,y,z; { return 0; } | |||
| 2387 | sigsetmask (x) int x; { return 0; } | 2387 | sigsetmask (x) int x; { return 0; } |
| 2388 | unrequest_sigio () {} | 2388 | unrequest_sigio () {} |
| 2389 | 2389 | ||
| 2390 | int run_dos_timer_hooks = 0; | ||
| 2391 | |||
| 2392 | #ifndef HAVE_SELECT | 2390 | #ifndef HAVE_SELECT |
| 2393 | #include "sysselect.h" | 2391 | #include "sysselect.h" |
| 2394 | 2392 | ||
| 2395 | static int last_ti_sec = -1; | 2393 | static struct time last_time = {120, 120, 120, 120}; |
| 2396 | static int dos_menubar_clock_displayed = 0; | 2394 | static int modeline_time_displayed = 0; |
| 2395 | |||
| 2396 | Lisp_Object Vdos_display_time; | ||
| 2397 | 2397 | ||
| 2398 | static void | 2398 | static void |
| 2399 | check_timer (t) | 2399 | check_timer (t) |
| 2400 | struct time *t; | 2400 | struct time *t; |
| 2401 | { | 2401 | { |
| 2402 | int sec, min, hour, hund; | ||
| 2403 | |||
| 2402 | gettime (t); | 2404 | gettime (t); |
| 2403 | 2405 | sec = t->ti_sec; | |
| 2404 | if (t->ti_sec == last_ti_sec) | 2406 | hund = t->ti_hund; |
| 2407 | hour = t->ti_hour; | ||
| 2408 | min = t->ti_min; | ||
| 2409 | |||
| 2410 | /* Any chance of not getting here 24 hours or more since last time? */ | ||
| 2411 | if (hour == last_time.ti_hour | ||
| 2412 | && min == last_time.ti_min | ||
| 2413 | && sec == last_time.ti_sec) | ||
| 2405 | return; | 2414 | return; |
| 2406 | last_ti_sec = t->ti_sec; | ||
| 2407 | 2415 | ||
| 2408 | if (!NILP (Vdos_menubar_clock)) | 2416 | if (!NILP (Vdos_display_time)) |
| 2409 | { | 2417 | { |
| 2410 | char clock_str[16]; | 2418 | int interval; |
| 2411 | int len; | 2419 | Lisp_Object dti = XSYMBOL (Fintern_soft (build_string ("display-time-interval"), Qnil))->value; |
| 2412 | int min = t->ti_min; | 2420 | int delta_time = ((hour - last_time.ti_hour) * 3600 |
| 2413 | int hour = t->ti_hour; | 2421 | + (min - last_time.ti_min) * 60 |
| 2414 | 2422 | + (sec - last_time.ti_sec)); | |
| 2415 | if (dos_timezone_offset) | 2423 | |
| 2416 | { | 2424 | /* Who knows what the user may put into `display-time-interval'? */ |
| 2417 | int tz = dos_timezone_offset; | 2425 | if (!INTEGERP (dti) || (interval = XINT (dti)) <= 0) |
| 2418 | min -= tz % 60; | 2426 | interval = 60; |
| 2419 | if (min < 0) | 2427 | |
| 2420 | min += 60, hour--; | 2428 | /* When it's time to renew the display, fake a `wakeup' call. */ |
| 2421 | else | 2429 | if (!modeline_time_displayed /* first time */ |
| 2422 | if (min >= 60) | 2430 | || delta_time >= interval /* or if we were busy for a long time */ |
| 2423 | min -= 60, hour++; | 2431 | || interval == 1 /* and every `interval' seconds hence */ |
| 2424 | 2432 | || interval == 60 && sec == 0 /* (usual cases first) */ | |
| 2425 | if ((hour -= (tz / 60)) < 0) | 2433 | || (hour * 3600 + min * 60 + sec) % interval == 0) |
| 2426 | hour += 24; | 2434 | call2 (intern ("display-time-filter"), Qnil, |
| 2427 | else | 2435 | build_string ("Wake up!\n")); |
| 2428 | hour %= 24; | 2436 | |
| 2429 | } | 2437 | modeline_time_displayed = 1; |
| 2430 | |||
| 2431 | if ((dos_country_info[0x11] & 0x01) == 0) /* 12 hour clock */ | ||
| 2432 | { | ||
| 2433 | hour %= 12; | ||
| 2434 | if (hour == 0) hour = 12; | ||
| 2435 | } | ||
| 2436 | |||
| 2437 | len = sprintf (clock_str, "%2d.%02d.%02d", hour, min, t->ti_sec); | ||
| 2438 | dos_direct_output (0, screen_size_X - len - 1, clock_str, len); | ||
| 2439 | dos_menubar_clock_displayed = 1; | ||
| 2440 | } | 2438 | } |
| 2441 | else if (dos_menubar_clock_displayed) | 2439 | else if (modeline_time_displayed) |
| 2442 | { | 2440 | { |
| 2443 | /* Erase last displayed time. */ | 2441 | modeline_time_displayed = 0; |
| 2444 | dos_direct_output (0, screen_size_X - 9, " ", 8); | 2442 | Fset (intern ("display-time-string"), build_string ("")); |
| 2445 | dos_menubar_clock_displayed = 0; | 2443 | |
| 2444 | /* Force immediate redisplay of modelines. */ | ||
| 2445 | update_mode_lines++; | ||
| 2446 | redisplay_preserve_echo_area (); | ||
| 2446 | } | 2447 | } |
| 2447 | 2448 | ||
| 2448 | if (!NILP (Vdos_timer_hooks)) | 2449 | last_time = *t; |
| 2449 | run_dos_timer_hooks++; | ||
| 2450 | } | 2450 | } |
| 2451 | 2451 | ||
| 2452 | /* Only event queue is checked. */ | 2452 | /* Only event queue is checked. */ |
| @@ -2584,6 +2584,15 @@ dos_abort (file, line) | |||
| 2584 | ScreenSetCursor (2, 0); | 2584 | ScreenSetCursor (2, 0); |
| 2585 | abort (); | 2585 | abort (); |
| 2586 | } | 2586 | } |
| 2587 | #else | ||
| 2588 | void | ||
| 2589 | abort () | ||
| 2590 | { | ||
| 2591 | dos_ttcooked (); | ||
| 2592 | ScreenSetCursor (10, 0); | ||
| 2593 | cputs ("\r\n\nEmacs aborted!\r\n"); | ||
| 2594 | exit (2); | ||
| 2595 | } | ||
| 2587 | #endif | 2596 | #endif |
| 2588 | 2597 | ||
| 2589 | syms_of_msdos () | 2598 | syms_of_msdos () |
| @@ -2592,6 +2601,10 @@ syms_of_msdos () | |||
| 2592 | staticpro (&recent_doskeys); | 2601 | staticpro (&recent_doskeys); |
| 2593 | 2602 | ||
| 2594 | defsubr (&Srecent_doskeys); | 2603 | defsubr (&Srecent_doskeys); |
| 2604 | |||
| 2605 | DEFVAR_LISP ("dos-display-time", &Vdos_display_time, | ||
| 2606 | "*When non-nil, `display-time' is in effect on DOS systems."); | ||
| 2607 | Vdos_display_time = Qnil; | ||
| 2595 | } | 2608 | } |
| 2596 | 2609 | ||
| 2597 | #endif /* MSDOS */ | 2610 | #endif /* MSDOS */ |