summaryrefslogtreecommitdiff
path: root/menus.c
diff options
context:
space:
mode:
authorMichael J. Chudobiak <mjc@avtechpulse.com>2012-12-11 15:47:38 -0500
committerMichael J. Chudobiak <mjc@avtechpulse.com>2012-12-11 15:47:38 -0500
commit685cccabe3159dc05d8df4ff7784aa6e6e8a5c79 (patch)
tree1d53d2bf94f3d080b21a955f4f8543e4f8d68be3 /menus.c
parent80cf1f9fc280652ec523bd8dda1092db48e6e327 (diff)
better construction of remote-mode string on main menu
Diffstat (limited to 'menus.c')
-rw-r--r--menus.c60
1 files changed, 34 insertions, 26 deletions
diff --git a/menus.c b/menus.c
index 7a161cf..40d4e87 100644
--- a/menus.c
+++ b/menus.c
@@ -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);