From 60c5196e62175458615117aab397aaac9ccda5a1 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 31 Dec 1999 19:02:09 -0500 Subject: fix initial menu write delay due to slow regex compilation --- menus.c | 106 ++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 53 insertions(+), 53 deletions(-) (limited to 'menus.c') diff --git a/menus.c b/menus.c index 0602a34..3c574ec 100644 --- a/menus.c +++ b/menus.c @@ -242,7 +242,9 @@ void Update_Main_Menu_If_Visible(void) void Show_Main_Menu(void) { - if (!globals.Sys.startup_complete) return; + if (!globals.Sys.startup_complete) { + return; + } static GStaticMutex mutex = G_STATIC_MUTEX_INIT; g_static_mutex_lock (&mutex); // can be triggered simultaneously by local or remote users @@ -271,6 +273,51 @@ void Show_Main_Menu(void) globals.MenuStatus.Nonstd_Display=NO; + // update remote/local info before starting screen writes, to avoid + // odd-looking pauses + update_remote_mode(); + GString *raw_str = g_string_new (""); + + if (!VXI_OR_GPIB_LOCK_ACTIVE) { + raw_str = g_string_append (raw_str, "LOCAL+"); + } + if (globals.Remote.gpib_remote) { + raw_str = g_string_append (raw_str, "GPIB+"); + } + if (globals.Remote.terminal_connections > 0) { + g_string_append_printf (raw_str, "%dTER", globals.Remote.terminal_connections); + } + if (globals.Remote.vxi_connections > 0) { + g_string_append_printf (raw_str, "%dVXI", globals.Remote.vxi_connections); + } + gchar *step1 = g_strdup (raw_str->str); + g_string_free (raw_str, TRUE); + + // remove semicolon at end + gchar *step2 = conditional_regex_replace (TRUE, step1, "\\+$", ""); + g_free (step1); + + // shorten as required + gchar *step3 = conditional_regex_replace (strlen(step2) > LCD_col_width, step2, "LOCAL", "LO"); + g_free (step2); + + // shorten as required + gchar *step4 = conditional_regex_replace (strlen(step3) > LCD_col_width, step3, "TER", "T"); + g_free (step3); + + // shorten as required + gchar *step5 = conditional_regex_replace (strlen(step4) > LCD_col_width, step4, "GPIB", "GP"); + g_free (step4); + + // shorten as required + gchar *step6 = conditional_regex_replace (strlen(step5) > LCD_col_width, step5, "VXI", "V"); + g_free (step5); + + // finish + gchar *ctrl_str = g_strdup (step6); + g_free (step6); + + /* fill in unused cursor columns */ for (i=0; i<(menu_cursor_pos % LCD_max_entries_per_page); ++i) { LCD_row=i % LCD_rows; @@ -877,53 +924,6 @@ void Show_Main_Menu(void) LCD_row=LCD_entry % LCD_rows; LCD_col=((LCD_entry % LCD_max_entries_per_page) / LCD_rows) * LCD_col_width + 1; - update_remote_mode(); - - GString *raw_str = g_string_new (""); - - if (!VXI_OR_GPIB_LOCK_ACTIVE) { - raw_str = g_string_append (raw_str, "LOCAL+"); - } - - if (globals.Remote.gpib_remote) { - raw_str = g_string_append (raw_str, "GPIB+"); - } - - if (globals.Remote.terminal_connections > 0) { - g_string_append_printf (raw_str, "%dTER", globals.Remote.terminal_connections); - } - - if (globals.Remote.vxi_connections > 0) { - g_string_append_printf (raw_str, "%dVXI", globals.Remote.vxi_connections); - } - - gchar *step1 = g_strdup (raw_str->str); - g_string_free (raw_str, TRUE); - - // remove semicolon at end - gchar *step2 = conditional_regex_replace (TRUE, step1, "\\+$", ""); - g_free (step1); - - // shorten as required - gchar *step3 = conditional_regex_replace (strlen(step2) > LCD_col_width, step2, "LOCAL", "LO"); - g_free (step2); - - // shorten as required - gchar *step4 = conditional_regex_replace (strlen(step3) > LCD_col_width, step3, "TER", "T"); - g_free (step3); - - // shorten as required - gchar *step5 = conditional_regex_replace (strlen(step4) > LCD_col_width, step4, "GPIB", "GP"); - g_free (step4); - - // shorten as required - gchar *step6 = conditional_regex_replace (strlen(step5) > LCD_col_width, step5, "VXI", "V"); - g_free (step5); - - // finish - gchar *ctrl_str = g_strdup (step6); - g_free (step6); - if (Menu_Is_Item_Visible(LCD_entry)) { LCD_write_padded_spaces(LCD_row,LCD_col,ctrl_str,LCD_col_width); } @@ -1780,19 +1780,19 @@ static void Submenu_Display(int change_selection) mode_name = g_strdup("Save Settings"); break; case mode_load_0: - case mode_save_0: + case mode_save_0: mode_name = g_strdup("Storage 0"); break; case mode_load_1: - case mode_save_1: + case mode_save_1: mode_name = g_strdup("Storage 1"); break; case mode_load_2: - case mode_save_2: + case mode_save_2: mode_name = g_strdup("Storage 2"); break; case mode_load_3: - case mode_save_3: + case mode_save_3: mode_name = g_strdup("Storage 3"); break; case mode_change_rs232: @@ -1811,7 +1811,7 @@ static void Submenu_Display(int change_selection) } break; case mode_zout_min: - mode_name = g_strdup_printf ("Zout = %d\xf4", globals.Flash.zout_min[channel]); + mode_name = g_strdup_printf ("Zout = %d\xf4", globals.Flash.zout_min[channel]); if (globals.ChannelState[channel].zout==globals.Flash.zout_min[channel]) { current_operating_mode=i; } -- cgit