about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2018-03-08 23:11:49 +0000
committerJames Booth <boothj5@gmail.com>2018-03-08 23:11:49 +0000
commita957c545d30750776e5b3307e71d4069e56a9ea5 (patch)
tree908e66be6668b743c9cf6f406c86defb27606d35 /src/ui
parent720dce866eb759a7b5ecdaff7c7d9ceeb6e2487c (diff)
downloadprofani-tty-a957c545d30750776e5b3307e71d4069e56a9ea5.tar.gz
Add max tabs preference for statusbar
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/console.c4
-rw-r--r--src/ui/statusbar.c112
2 files changed, 60 insertions, 56 deletions
diff --git a/src/ui/console.c b/src/ui/console.c
index 84e7b59b..a6948c5b 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1544,6 +1544,7 @@ cons_show_ui_prefs(void)
     cons_presence_setting();
     cons_inpblock_setting();
     cons_tlsshow_setting();
+    cons_statusbar_setting();
 
     cons_alert();
 }
@@ -1750,7 +1751,6 @@ cons_inpblock_setting(void)
 void
 cons_statusbar_setting(void)
 {
-    cons_winpos_setting();
     if (prefs_get_boolean(PREF_STATUSBAR_SHOW_EMPTY)) {
         cons_show("Show empty tabs (/statusbar)        : ON");
     } else {
@@ -1761,6 +1761,8 @@ cons_statusbar_setting(void)
     } else {
         cons_show("Show tab names (/statusbar)         : OFF");
     }
+    cons_show("Max tabs (/statusbar)               : %d", prefs_get_statusbartabs());
+
 }
 
 void
diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c
index ca8e8a47..d16e0660 100644
--- a/src/ui/statusbar.c
+++ b/src/ui/statusbar.c
@@ -63,24 +63,13 @@ typedef struct _status_bar_t {
     int current_tab;
 } StatusBar;
 
-#define MAX_TABS 10
-
 static GTimeZone *tz;
 static StatusBar *statusbar;
 static WINDOW *statusbar_win;
 
 static void _status_bar_draw(void);
-
-void
-_destroy_tab(StatusBarTab *tab)
-{
-    if (tab) {
-        if (tab->display_name) {
-            free(tab->display_name);
-        }
-        free(tab);
-    }
-}
+static void _destroy_tab(StatusBarTab *tab);
+static int _tabs_width(void);
 
 void
 status_bar_init(void)
@@ -241,47 +230,6 @@ status_bar_clear_message(void)
     _status_bar_draw();
 }
 
-static int
-_tabs_width(void)
-{
-    gboolean show_empty = prefs_get_boolean(PREF_STATUSBAR_SHOW_EMPTY);
-    gboolean show_name = prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME);
-
-    if (show_name) {
-        if (show_empty) {
-            int width = 4;
-            int i = 0;
-            for (i = 1; i <= MAX_TABS; i++) {
-                StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
-                if (tab) {
-                    width += strlen(tab->display_name);
-                    width += 4;
-                } else {
-                    width += 3;
-                }
-            }
-            return width;
-        } else {
-            int width = 4;
-            int i = 0;
-            for (i = 1; i <= MAX_TABS; i++) {
-                StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
-                if (tab) {
-                    width += strlen(tab->display_name);
-                    width += 4;
-                }
-            }
-            return width;
-        }
-    } else {
-        if (show_empty) {
-            return MAX_TABS * 3 + 4;
-        } else {
-            return g_hash_table_size(statusbar->tabs) * 3 + 4;
-        }
-    }
-}
-
 static void
 _status_bar_draw(void)
 {
@@ -339,9 +287,10 @@ _status_bar_draw(void)
 
     gboolean show_empty = prefs_get_boolean(PREF_STATUSBAR_SHOW_EMPTY);
     gboolean show_name = prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME);
+    gint max_tabs = prefs_get_statusbartabs();
 
     int i = 1;
-    for (i = 1; i <= MAX_TABS; i++) {
+    for (i = 1; i <= max_tabs; i++) {
         int display_num = i == 10 ? 0 : i;
 
         StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
@@ -409,3 +358,56 @@ _status_bar_draw(void)
     wnoutrefresh(statusbar_win);
     inp_put_back();
 }
+
+static void
+_destroy_tab(StatusBarTab *tab)
+{
+    if (tab) {
+        if (tab->display_name) {
+            free(tab->display_name);
+        }
+        free(tab);
+    }
+}
+
+static int
+_tabs_width(void)
+{
+    gboolean show_empty = prefs_get_boolean(PREF_STATUSBAR_SHOW_EMPTY);
+    gboolean show_name = prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME);
+    gint max_tabs = prefs_get_statusbartabs();
+
+    if (show_name) {
+        if (show_empty) {
+            int width = 4;
+            int i = 0;
+            for (i = 1; i <= max_tabs; i++) {
+                StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
+                if (tab) {
+                    width += strlen(tab->display_name);
+                    width += 4;
+                } else {
+                    width += 3;
+                }
+            }
+            return width;
+        } else {
+            int width = 4;
+            int i = 0;
+            for (i = 1; i <= max_tabs; i++) {
+                StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
+                if (tab) {
+                    width += strlen(tab->display_name);
+                    width += 4;
+                }
+            }
+            return width;
+        }
+    } else {
+        if (show_empty) {
+            return max_tabs * 3 + 4;
+        } else {
+            return g_hash_table_size(statusbar->tabs) * 3 + 4;
+        }
+    }
+}