Commit 06b1ea13 authored by Eli Zaretskii's avatar Eli Zaretskii

(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).
parent 6f855d64
......@@ -29,6 +29,7 @@ Boston, MA 02111-1307, USA. */
#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_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, "<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 @@ 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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment