From 06b1ea13218022fc9a85a1b923abbc319b66a86d Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 3 Dec 1998 09:41:48 +0000 Subject: [PATCH] (init_environment): Record the time we started up. (IT_reset_terminal_modes): Don't restore the screen if we exit too fast after startup (aka crash). --- src/msdos.c | 54 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/src/msdos.c b/src/msdos.c index f70c196c012..5ca21f37225 100644 --- a/src/msdos.c +++ b/src/msdos.c @@ -29,6 +29,7 @@ Boston, MA 02111-1307, USA. */ #include "lisp.h" #include #include +#include #include #include #include @@ -332,6 +333,8 @@ static int startup_pos_X; static int startup_pos_Y; static unsigned char startup_screen_attrib; +static clock_t startup_time; + static int term_setup_done; /* Similar to the_only_frame. */ @@ -993,7 +996,7 @@ IT_reset_terminal_modes (void) /* Leave the video system in the same state as we found it, as far as the blink/bright-background bit is concerned. */ maybe_enable_blinking (); - + /* We have a situation here. We cannot just do ScreenUpdate(startup_screen_buffer) because the luser could have changed screen dimensions inside Emacs @@ -1007,27 +1010,34 @@ IT_reset_terminal_modes (void) is also restored within the visible dimensions. */ ScreenAttrib = startup_screen_attrib; - ScreenClear (); - if (screen_virtual_segment) - dosv_refresh_virtual_screen (0, screen_size); - - if (update_row_len > saved_row_len) - update_row_len = saved_row_len; - if (current_rows > startup_screen_size_Y) - current_rows = startup_screen_size_Y; - - if (termscript) - fprintf (termscript, "\n", - update_row_len / 2, current_rows); - while (current_rows--) + /* Don't restore the screen if we are exiting less than 2 seconds + after startup: we might be crashing, and the screen might show + some vital clues to what's wrong. */ + if (clock () - startup_time >= 2*CLOCKS_PER_SEC) { - dosmemput (saved_row, update_row_len, display_row_start); + ScreenClear (); if (screen_virtual_segment) - dosv_refresh_virtual_screen (display_row_start - ScreenPrimary, - update_row_len / 2); - saved_row += saved_row_len; - display_row_start += to_next_row; + dosv_refresh_virtual_screen (0, screen_size); + + if (update_row_len > saved_row_len) + update_row_len = saved_row_len; + if (current_rows > startup_screen_size_Y) + current_rows = startup_screen_size_Y; + + if (termscript) + fprintf (termscript, "\n", + update_row_len / 2, current_rows); + + while (current_rows--) + { + dosmemput (saved_row, update_row_len, display_row_start); + if (screen_virtual_segment) + dosv_refresh_virtual_screen (display_row_start - ScreenPrimary, + update_row_len / 2); + saved_row += saved_row_len; + display_row_start += to_next_row; + } } if (startup_pos_X < cursor_pos_X) cursor_pos_X = startup_pos_X; @@ -2890,6 +2900,12 @@ init_environment (argc, argv, skip_args) Qnil)), "While setting TMPDIR: "); + /* Note the startup time, so we know not to clear the screen if we + exit immediately; see IT_reset_terminal_modes. + (Yes, I know `clock' returns zero the first time it's called, but + I do this anyway, in case some wiseguy changes that at some point.) */ + startup_time = clock (); + /* Find our root from argv[0]. Assuming argv[0] is, say, "c:/emacs/bin/emacs.exe" our root will be "c:/emacs". */ root = alloca (MAXPATHLEN + 20); -- 2.39.2