diff options
Diffstat (limited to 'menus.c')
-rw-r--r-- | menus.c | 60 |
1 files changed, 34 insertions, 26 deletions
@@ -898,36 +898,44 @@ 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; - gchar *ctrl_str = NULL; - update_remote_mode(); - switch (globals.Remote.mode) { - case (RM_NOT_TERM | RM_NOT_REM | RM_NOT_LOCK): - case (RM_NOT_TERM | RM_NOT_REM | RM_LOCK): - ctrl_str = g_strdup ("LOCAL"); - break; - case (RM_NOT_TERM | RM_REM | RM_NOT_LOCK): - ctrl_str = g_strdup ("LOCAL+GPIB"); - break; - case (RM_NOT_TERM | RM_REM | RM_LOCK): - ctrl_str = g_strdup ("GPIB"); - break; - case (RM_TERM | RM_NOT_REM | RM_NOT_LOCK): - case (RM_TERM | RM_NOT_REM | RM_LOCK): - ctrl_str = g_strdup_printf ("LOCAL+%dTER", globals.Remote.terminal_connections); - break; - case (RM_TERM | RM_REM | RM_NOT_LOCK): - ctrl_str = g_strdup_printf ("LO+GPIB+%dTER", globals.Remote.terminal_connections); - break; - case (RM_TERM | RM_REM | RM_LOCK): - ctrl_str = g_strdup_printf ("GPIB+%dTER", globals.Remote.terminal_connections); - break; - default: - ctrl_str = g_strdup ("LOCAL"); - break; + GString *raw_str = g_string_new (""); + + if (!GPIB_REMOTE_AND_LOCKED) { + raw_str = g_string_append (raw_str, "LOCAL+"); } + if (globals.Remote.mode & RM_REM) { + raw_str = g_string_append (raw_str, "GPIB+"); + } + + if (globals.Remote.mode & RM_TERM) { + g_string_append_printf (raw_str, "%dTER", globals.Remote.terminal_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(step2) > LCD_col_width, step3, "TER", "T"); + g_free (step3); + + // shorten as required + gchar *step5 = conditional_regex_replace (strlen(step2) > LCD_col_width, step4, "GPIB", "GP"); + g_free (step4); + + // finish + gchar *ctrl_str = g_strdup (step5); + g_free (step5); if (Menu_Is_Item_Visible(LCD_entry)) { LCD_write_padded_spaces(LCD_row,LCD_col,ctrl_str,LCD_col_width); |