Mercurial > emacs
changeset 23815:fe9557bb7056
(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).
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Thu, 03 Dec 1998 09:41:48 +0000 |
parents | 3229c65a13c5 |
children | b9e50ca20168 |
files | src/msdos.c |
diffstat | 1 files changed, 36 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/src/msdos.c Thu Dec 03 09:41:09 1998 +0000 +++ b/src/msdos.c Thu Dec 03 09:41:48 1998 +0000 @@ -29,6 +29,7 @@ #include "lisp.h" #include <stdio.h> #include <stdlib.h> +#include <time.h> #include <sys/param.h> #include <sys/time.h> #include <dos.h> @@ -332,6 +333,8 @@ 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 @@ /* 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 @@ 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, "<SCREEN RESTORED (dimensions=%dx%d)>\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, "<SCREEN RESTORED (dimensions=%dx%d)>\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 @@ 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);