From 2306a735e781d9afc577af06d7cb0b001ee86bc1 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 26 Aug 2008 20:28:20 +0000 Subject: [PATCH] (internal_terminal_init): Most initializations done only once, especially initial_screen_colors[] and termscript open. --- src/ChangeLog | 5 ++ src/msdos.c | 131 ++++++++++++++++++++++++++------------------------ 2 files changed, 74 insertions(+), 62 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index ebf5013822b..efde56394c8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-08-26 Eli Zaretskii + + * msdos.c (internal_terminal_init): Most initializations done only + once, especially initial_screen_colors[] and termscript open. + 2008-08-26 Chong Yidong * eval.c (Fcondition_case): Doc fix. diff --git a/src/msdos.c b/src/msdos.c index 2b049a32ac1..ebbf2cd41e4 100644 --- a/src/msdos.c +++ b/src/msdos.c @@ -2414,6 +2414,7 @@ extern void init_frame_faces (FRAME_PTR); void internal_terminal_init () { + static int init_needed = 1; char *term = getenv ("TERM"), *colors; struct frame *sf = SELECTED_FRAME(); struct tty_display_info *tty; @@ -2438,76 +2439,82 @@ internal_terminal_init () } tty = FRAME_TTY (sf); - if (!tty->termscript && getenv ("EMACSTEST")) - tty->termscript = fopen (getenv ("EMACSTEST"), "wt"); - if (tty->termscript) + if (init_needed) { - time_t now = time (NULL); - struct tm *tnow = localtime (&now); - char tbuf[100]; + if (!tty->termscript && getenv ("EMACSTEST")) + tty->termscript = fopen (getenv ("EMACSTEST"), "wt"); + if (tty->termscript) + { + time_t now = time (NULL); + struct tm *tnow = localtime (&now); + char tbuf[100]; - strftime (tbuf, sizeof (tbuf) - 1, "%a %b %e %Y %H:%M:%S %Z", tnow); - fprintf (tty->termscript, "\nEmacs session started at %s\n", tbuf); - fprintf (tty->termscript, "=====================\n\n"); - } + strftime (tbuf, sizeof (tbuf) - 1, "%a %b %e %Y %H:%M:%S %Z", tnow); + fprintf (tty->termscript, "\nEmacs session started at %s\n", tbuf); + fprintf (tty->termscript, "=====================\n\n"); + } - Vinitial_window_system = current_kboard->Vwindow_system = Qpc; - Vwindow_system_version = make_number (23); /* RE Emacs version */ - sf->output_method = output_msdos_raw; - tty->terminal->type = output_msdos_raw; + Vinitial_window_system = Qpc; + Vwindow_system_version = make_number (23); /* RE Emacs version */ + tty->terminal->type = output_msdos_raw; - /* If Emacs was dumped on DOS/V machine, forget the stale VRAM address. */ - screen_old_address = 0; + /* If Emacs was dumped on DOS/V machine, forget the stale VRAM + address. */ + screen_old_address = 0; - /* Forget the stale screen colors as well. */ - initial_screen_colors[0] = initial_screen_colors[1] = -1; + /* Forget the stale screen colors as well. */ + initial_screen_colors[0] = initial_screen_colors[1] = -1; - FRAME_BACKGROUND_PIXEL (SELECTED_FRAME ()) = 7; /* White */ - FRAME_FOREGROUND_PIXEL (SELECTED_FRAME ()) = 0; /* Black */ - bright_bg (); - colors = getenv ("EMACSCOLORS"); - if (colors && strlen (colors) >= 2) - { - /* The colors use 4 bits each (we enable bright background). */ - if (isdigit (colors[0])) - colors[0] -= '0'; - else if (isxdigit (colors[0])) - colors[0] -= (isupper (colors[0]) ? 'A' : 'a') - 10; - if (colors[0] >= 0 && colors[0] < 16) - FRAME_FOREGROUND_PIXEL (SELECTED_FRAME ()) = colors[0]; - if (isdigit (colors[1])) - colors[1] -= '0'; - else if (isxdigit (colors[1])) - colors[1] -= (isupper (colors[1]) ? 'A' : 'a') - 10; - if (colors[1] >= 0 && colors[1] < 16) - FRAME_BACKGROUND_PIXEL (SELECTED_FRAME ()) = colors[1]; - } - the_only_display_info.mouse_face_mouse_frame = NULL; - the_only_display_info.mouse_face_deferred_gc = 0; - the_only_display_info.mouse_face_beg_row = - the_only_display_info.mouse_face_beg_col = -1; - the_only_display_info.mouse_face_end_row = - the_only_display_info.mouse_face_end_col = -1; - the_only_display_info.mouse_face_face_id = DEFAULT_FACE_ID; - the_only_display_info.mouse_face_window = Qnil; - the_only_display_info.mouse_face_mouse_x = - the_only_display_info.mouse_face_mouse_y = 0; - the_only_display_info.mouse_face_defer = 0; - the_only_display_info.mouse_face_hidden = 0; - - if (have_mouse) /* detected in dos_ttraw, which see */ - { - have_mouse = 1; /* enable mouse */ - mouse_visible = 0; - mouse_setup_buttons (mouse_button_count); - tty->terminal->mouse_position_hook = &mouse_get_pos; - mouse_init (); - } + FRAME_BACKGROUND_PIXEL (SELECTED_FRAME ()) = 7; /* White */ + FRAME_FOREGROUND_PIXEL (SELECTED_FRAME ()) = 0; /* Black */ + bright_bg (); + colors = getenv ("EMACSCOLORS"); + if (colors && strlen (colors) >= 2) + { + /* The colors use 4 bits each (we enable bright background). */ + if (isdigit (colors[0])) + colors[0] -= '0'; + else if (isxdigit (colors[0])) + colors[0] -= (isupper (colors[0]) ? 'A' : 'a') - 10; + if (colors[0] >= 0 && colors[0] < 16) + FRAME_FOREGROUND_PIXEL (SELECTED_FRAME ()) = colors[0]; + if (isdigit (colors[1])) + colors[1] -= '0'; + else if (isxdigit (colors[1])) + colors[1] -= (isupper (colors[1]) ? 'A' : 'a') - 10; + if (colors[1] >= 0 && colors[1] < 16) + FRAME_BACKGROUND_PIXEL (SELECTED_FRAME ()) = colors[1]; + } + the_only_display_info.mouse_face_mouse_frame = NULL; + the_only_display_info.mouse_face_deferred_gc = 0; + the_only_display_info.mouse_face_beg_row = + the_only_display_info.mouse_face_beg_col = -1; + the_only_display_info.mouse_face_end_row = + the_only_display_info.mouse_face_end_col = -1; + the_only_display_info.mouse_face_face_id = DEFAULT_FACE_ID; + the_only_display_info.mouse_face_window = Qnil; + the_only_display_info.mouse_face_mouse_x = + the_only_display_info.mouse_face_mouse_y = 0; + the_only_display_info.mouse_face_defer = 0; + the_only_display_info.mouse_face_hidden = 0; + + if (have_mouse) /* detected in dos_ttraw, which see */ + { + have_mouse = 1; /* enable mouse */ + mouse_visible = 0; + mouse_setup_buttons (mouse_button_count); + tty->terminal->mouse_position_hook = &mouse_get_pos; + mouse_init (); + } - if (tty->termscript && screen_size) - fprintf (tty->termscript, "\n", - screen_size_X, screen_size_Y); + if (tty->termscript && screen_size) + fprintf (tty->termscript, "\n", + screen_size_X, screen_size_Y); + init_needed = 0; + } + current_kboard->Vwindow_system = Qpc; + sf->output_method = output_msdos_raw; init_frame_faces (sf); #endif } -- 2.39.5