diff options
| author | Eli Zaretskii | 1998-12-03 09:41:48 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 1998-12-03 09:41:48 +0000 |
| commit | 06b1ea13218022fc9a85a1b923abbc319b66a86d (patch) | |
| tree | c2b2216de2534914e191e6c10fbe44ad396931c1 /src | |
| parent | 6f855d6452fbff508a7b022350564a9f7955f7e9 (diff) | |
| download | emacs-06b1ea13218022fc9a85a1b923abbc319b66a86d.tar.gz emacs-06b1ea13218022fc9a85a1b923abbc319b66a86d.zip | |
(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).
Diffstat (limited to 'src')
| -rw-r--r-- | src/msdos.c | 54 |
1 files 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. */ | |||
| 29 | #include "lisp.h" | 29 | #include "lisp.h" |
| 30 | #include <stdio.h> | 30 | #include <stdio.h> |
| 31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
| 32 | #include <time.h> | ||
| 32 | #include <sys/param.h> | 33 | #include <sys/param.h> |
| 33 | #include <sys/time.h> | 34 | #include <sys/time.h> |
| 34 | #include <dos.h> | 35 | #include <dos.h> |
| @@ -332,6 +333,8 @@ static int startup_pos_X; | |||
| 332 | static int startup_pos_Y; | 333 | static int startup_pos_Y; |
| 333 | static unsigned char startup_screen_attrib; | 334 | static unsigned char startup_screen_attrib; |
| 334 | 335 | ||
| 336 | static clock_t startup_time; | ||
| 337 | |||
| 335 | static int term_setup_done; | 338 | static int term_setup_done; |
| 336 | 339 | ||
| 337 | /* Similar to the_only_frame. */ | 340 | /* Similar to the_only_frame. */ |
| @@ -993,7 +996,7 @@ IT_reset_terminal_modes (void) | |||
| 993 | /* Leave the video system in the same state as we found it, | 996 | /* Leave the video system in the same state as we found it, |
| 994 | as far as the blink/bright-background bit is concerned. */ | 997 | as far as the blink/bright-background bit is concerned. */ |
| 995 | maybe_enable_blinking (); | 998 | maybe_enable_blinking (); |
| 996 | 999 | ||
| 997 | /* We have a situation here. | 1000 | /* We have a situation here. |
| 998 | We cannot just do ScreenUpdate(startup_screen_buffer) because | 1001 | We cannot just do ScreenUpdate(startup_screen_buffer) because |
| 999 | the luser could have changed screen dimensions inside Emacs | 1002 | the luser could have changed screen dimensions inside Emacs |
| @@ -1007,27 +1010,34 @@ IT_reset_terminal_modes (void) | |||
| 1007 | is also restored within the visible dimensions. */ | 1010 | is also restored within the visible dimensions. */ |
| 1008 | 1011 | ||
| 1009 | ScreenAttrib = startup_screen_attrib; | 1012 | ScreenAttrib = startup_screen_attrib; |
| 1010 | ScreenClear (); | ||
| 1011 | if (screen_virtual_segment) | ||
| 1012 | dosv_refresh_virtual_screen (0, screen_size); | ||
| 1013 | |||
| 1014 | if (update_row_len > saved_row_len) | ||
| 1015 | update_row_len = saved_row_len; | ||
| 1016 | if (current_rows > startup_screen_size_Y) | ||
| 1017 | current_rows = startup_screen_size_Y; | ||
| 1018 | |||
| 1019 | if (termscript) | ||
| 1020 | fprintf (termscript, "<SCREEN RESTORED (dimensions=%dx%d)>\n", | ||
| 1021 | update_row_len / 2, current_rows); | ||
| 1022 | 1013 | ||
| 1023 | while (current_rows--) | 1014 | /* Don't restore the screen if we are exiting less than 2 seconds |
| 1015 | after startup: we might be crashing, and the screen might show | ||
| 1016 | some vital clues to what's wrong. */ | ||
| 1017 | if (clock () - startup_time >= 2*CLOCKS_PER_SEC) | ||
| 1024 | { | 1018 | { |
| 1025 | dosmemput (saved_row, update_row_len, display_row_start); | 1019 | ScreenClear (); |
| 1026 | if (screen_virtual_segment) | 1020 | if (screen_virtual_segment) |
| 1027 | dosv_refresh_virtual_screen (display_row_start - ScreenPrimary, | 1021 | dosv_refresh_virtual_screen (0, screen_size); |
| 1028 | update_row_len / 2); | 1022 | |
| 1029 | saved_row += saved_row_len; | 1023 | if (update_row_len > saved_row_len) |
| 1030 | display_row_start += to_next_row; | 1024 | update_row_len = saved_row_len; |
| 1025 | if (current_rows > startup_screen_size_Y) | ||
| 1026 | current_rows = startup_screen_size_Y; | ||
| 1027 | |||
| 1028 | if (termscript) | ||
| 1029 | fprintf (termscript, "<SCREEN RESTORED (dimensions=%dx%d)>\n", | ||
| 1030 | update_row_len / 2, current_rows); | ||
| 1031 | |||
| 1032 | while (current_rows--) | ||
| 1033 | { | ||
| 1034 | dosmemput (saved_row, update_row_len, display_row_start); | ||
| 1035 | if (screen_virtual_segment) | ||
| 1036 | dosv_refresh_virtual_screen (display_row_start - ScreenPrimary, | ||
| 1037 | update_row_len / 2); | ||
| 1038 | saved_row += saved_row_len; | ||
| 1039 | display_row_start += to_next_row; | ||
| 1040 | } | ||
| 1031 | } | 1041 | } |
| 1032 | if (startup_pos_X < cursor_pos_X) | 1042 | if (startup_pos_X < cursor_pos_X) |
| 1033 | cursor_pos_X = startup_pos_X; | 1043 | cursor_pos_X = startup_pos_X; |
| @@ -2890,6 +2900,12 @@ init_environment (argc, argv, skip_args) | |||
| 2890 | Qnil)), | 2900 | Qnil)), |
| 2891 | "While setting TMPDIR: "); | 2901 | "While setting TMPDIR: "); |
| 2892 | 2902 | ||
| 2903 | /* Note the startup time, so we know not to clear the screen if we | ||
| 2904 | exit immediately; see IT_reset_terminal_modes. | ||
| 2905 | (Yes, I know `clock' returns zero the first time it's called, but | ||
| 2906 | I do this anyway, in case some wiseguy changes that at some point.) */ | ||
| 2907 | startup_time = clock (); | ||
| 2908 | |||
| 2893 | /* Find our root from argv[0]. Assuming argv[0] is, say, | 2909 | /* Find our root from argv[0]. Assuming argv[0] is, say, |
| 2894 | "c:/emacs/bin/emacs.exe" our root will be "c:/emacs". */ | 2910 | "c:/emacs/bin/emacs.exe" our root will be "c:/emacs". */ |
| 2895 | root = alloca (MAXPATHLEN + 20); | 2911 | root = alloca (MAXPATHLEN + 20); |