about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-05-21 16:04:26 +0200
committerMichael Vetter <jubalh@iodoru.org>2020-05-21 16:15:14 +0200
commitcb78ee46656972a5481ad0241fb50dc0e0d02413 (patch)
tree8d4b45ec8345324320bfaf13ee2208b9035041c6
parente41ae21bea63484645c0ef5f98e870bd80bc1c8c (diff)
downloadprofani-tty-cb78ee46656972a5481ad0241fb50dc0e0d02413.tar.gz
Make option to allow hiding windows with no messages in statusbar
`statusbar.show.read` can be set to false in the config.
`/statusbar show|hide read`.

Implement https://github.com/profanity-im/profanity/issues/1285
-rw-r--r--src/command/cmd_ac.c1
-rw-r--r--src/command/cmd_defs.c6
-rw-r--r--src/command/cmd_funcs.c12
-rw-r--r--src/config/preferences.c4
-rw-r--r--src/config/preferences.h1
-rw-r--r--src/ui/console.c28
-rw-r--r--src/ui/statusbar.c16
7 files changed, 55 insertions, 13 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c
index e0d5f577..3c9daaee 100644
--- a/src/command/cmd_ac.c
+++ b/src/command/cmd_ac.c
@@ -955,6 +955,7 @@ cmd_ac_init(void)
     statusbar_show_ac = autocomplete_new();
     autocomplete_add(statusbar_show_ac, "name");
     autocomplete_add(statusbar_show_ac, "number");
+    autocomplete_add(statusbar_show_ac, "read");
 
     status_ac = autocomplete_new();
     autocomplete_add(status_ac, "set");
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index e6d3f969..8c67d307 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -1343,8 +1343,8 @@ static struct cmd_t command_defs[] =
         CMD_TAGS(
             CMD_TAG_UI)
         CMD_SYN(
-            "/statusbar show name|number",
-            "/statusbar hide name|number",
+            "/statusbar show name|number|read",
+            "/statusbar hide name|number|read",
             "/statusbar maxtabs <value>",
             "/statusbar tablen <value>",
             "/statusbar self user|barejid|fulljid|off",
@@ -1359,6 +1359,7 @@ static struct cmd_t command_defs[] =
             { "tablen <value>",             "Set the maximum number of characters to show as the tab name, 0 sets to unlimited." },
             { "show|hide name",             "Show or hide names in tabs." },
             { "show|hide number",           "Show or hide numbers in tabs." },
+            { "show|hide read",             "Show or hide inactive tabs." },
             { "self user|barejid|fulljid",  "Show account user name, barejid, fulljid as status bar title." },
             { "self off",                   "Disable showing self as status bar title." },
             { "chat user|jid",              "Show users name, or the fulljid if no nick is present for chat tabs." },
@@ -1370,6 +1371,7 @@ static struct cmd_t command_defs[] =
             "/statusbar tablen 5",
             "/statusbar self user",
             "/statusbar chat jid",
+            "/statusbar hide read",
             "/statusbar hide name")
     },
 
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 580494e2..758d356f 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -6070,6 +6070,12 @@ cmd_statusbar(ProfWin *window, const char *const command, gchar **args)
             ui_resize();
             return TRUE;
         }
+        if (g_strcmp0(args[1], "read") == 0) {
+            prefs_set_boolean(PREF_STATUSBAR_SHOW_READ, TRUE);
+            cons_show("Enabled showing inactive tabs.");
+            ui_resize();
+            return TRUE;
+        }
         cons_bad_cmd_usage(command);
         return TRUE;
     }
@@ -6097,6 +6103,12 @@ cmd_statusbar(ProfWin *window, const char *const command, gchar **args)
             ui_resize();
             return TRUE;
         }
+        if (g_strcmp0(args[1], "read") == 0) {
+            prefs_set_boolean(PREF_STATUSBAR_SHOW_READ, FALSE);
+            cons_show("Disabled showing inactive tabs.");
+            ui_resize();
+            return TRUE;
+        }
         cons_bad_cmd_usage(command);
         return TRUE;
     }
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 3821f024..10e406b2 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -1750,6 +1750,7 @@ _get_group(preference_t pref)
         case PREF_OCCUPANTS_COLOR_NICK:
         case PREF_STATUSBAR_SHOW_NAME:
         case PREF_STATUSBAR_SHOW_NUMBER:
+        case PREF_STATUSBAR_SHOW_READ:
         case PREF_STATUSBAR_SELF:
         case PREF_STATUSBAR_CHAT:
         case PREF_STATUSBAR_ROOM:
@@ -2051,6 +2052,8 @@ _get_key(preference_t pref)
             return "statusbar.show.name";
         case PREF_STATUSBAR_SHOW_NUMBER:
             return "statusbar.show.number";
+        case PREF_STATUSBAR_SHOW_READ:
+            return "statusbar.show.read";
         case PREF_STATUSBAR_SELF:
             return "statusbar.self";
         case PREF_STATUSBAR_CHAT:
@@ -2122,6 +2125,7 @@ _get_default_boolean(preference_t pref)
         case PREF_BOOKMARK_INVITE:
         case PREF_ROOM_LIST_CACHE:
         case PREF_STATUSBAR_SHOW_NUMBER:
+        case PREF_STATUSBAR_SHOW_READ:
         case PREF_REVEAL_OS:
         case PREF_CORRECTION_ALLOW:
         case PREF_RECEIPTS_SEND:
diff --git a/src/config/preferences.h b/src/config/preferences.h
index fc6eeafc..5a38bfec 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -159,6 +159,7 @@ typedef enum {
     PREF_ROOM_LIST_CACHE,
     PREF_STATUSBAR_SHOW_NAME,
     PREF_STATUSBAR_SHOW_NUMBER,
+    PREF_STATUSBAR_SHOW_READ,
     PREF_STATUSBAR_SELF,
     PREF_STATUSBAR_CHAT,
     PREF_STATUSBAR_ROOM,
diff --git a/src/ui/console.c b/src/ui/console.c
index ce963c8c..4a1c58d4 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1795,39 +1795,45 @@ void
 cons_statusbar_setting(void)
 {
     if (prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME)) {
-        cons_show("Show tab names (/statusbar)         : ON");
+        cons_show("Show tab names (/statusbar)                 : ON");
     } else {
-        cons_show("Show tab names (/statusbar)         : OFF");
+        cons_show("Show tab names (/statusbar)                 : OFF");
     }
     if (prefs_get_boolean(PREF_STATUSBAR_SHOW_NUMBER)) {
-        cons_show("Show tab numbers (/statusbar)       : ON");
+        cons_show("Show tab numbers (/statusbar)               : ON");
     } else {
-        cons_show("Show tab numbers (/statusbar)       : OFF");
+        cons_show("Show tab numbers (/statusbar)               : OFF");
     }
 
-    cons_show("Max tabs (/statusbar)               : %d", prefs_get_statusbartabs());
+    if (prefs_get_boolean(PREF_STATUSBAR_SHOW_NUMBER)) {
+        cons_show("Show tab with no actions (/statusbar)       : ON");
+    } else {
+        cons_show("Show tab with no actions (/statusbar)       : OFF");
+    }
+
+    cons_show("Max tabs (/statusbar)                       : %d", prefs_get_statusbartabs());
 
     gint pref_len = prefs_get_statusbartablen();
     if (pref_len == 0) {
-        cons_show("Max tab length (/statusbar)         : OFF");
+        cons_show("Max tab length (/statusbar)                 : OFF");
     } else {
-        cons_show("Max tab length (/statusbar)         : %d", pref_len);
+        cons_show("Max tab length (/statusbar)                 : %d", pref_len);
     }
 
     char *pref_self = prefs_get_string(PREF_STATUSBAR_SELF);
     if (g_strcmp0(pref_self, "off") == 0) {
-        cons_show("Self statusbar display (/statusbar) : OFF");
+        cons_show("Self statusbar display (/statusbar)         : OFF");
     } else {
-        cons_show("Self statusbar display (/statusbar) : %s", pref_self);
+        cons_show("Self statusbar display (/statusbar)         : %s", pref_self);
     }
     prefs_free_string(pref_self);
 
     char *pref_chat = prefs_get_string(PREF_STATUSBAR_CHAT);
-    cons_show("Chat tab display (/statusbar)       : %s", pref_chat);
+    cons_show("Chat tab display (/statusbar)               : %s", pref_chat);
     prefs_free_string(pref_chat);
 
     char *pref_room = prefs_get_string(PREF_STATUSBAR_ROOM);
-    cons_show("Room tab display (/statusbar)       : %s", pref_room);
+    cons_show("Room tab display (/statusbar)               : %s", pref_room);
     prefs_free_string(pref_room);
 }
 
diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c
index 94ec13f8..4119ad10 100644
--- a/src/ui/statusbar.c
+++ b/src/ui/statusbar.c
@@ -371,6 +371,11 @@ _status_bar_draw_tab(StatusBarTab *tab, int pos, int num)
 
     gboolean show_number = prefs_get_boolean(PREF_STATUSBAR_SHOW_NUMBER);
     gboolean show_name = prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME);
+    gboolean show_read = prefs_get_boolean(PREF_STATUSBAR_SHOW_READ);
+
+    // dont show this
+    if (!show_read && !is_current && !tab->highlight)
+        return pos;
 
     pos = _status_bar_draw_bracket(is_current, pos, "[");
 
@@ -515,6 +520,7 @@ _tabs_width(void)
 {
     gboolean show_number = prefs_get_boolean(PREF_STATUSBAR_SHOW_NUMBER);
     gboolean show_name = prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME);
+    gboolean show_read = prefs_get_boolean(PREF_STATUSBAR_SHOW_READ);
     gint max_tabs = prefs_get_statusbartabs();
 
     if (show_name && show_number) {
@@ -523,6 +529,11 @@ _tabs_width(void)
         for (i = 1; i <= max_tabs; i++) {
             StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
             if (tab) {
+                gboolean is_current = i == statusbar->current_tab;
+                // dont calculate this in because not shown
+                if (!show_read && !is_current && !tab->highlight)
+                    continue;
+
                 char *display_name = _display_name(tab);
                 width += utf8_display_len(display_name);
                 width += 4;
@@ -538,6 +549,11 @@ _tabs_width(void)
         for (i = 1; i <= max_tabs; i++) {
             StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
             if (tab) {
+                gboolean is_current = i == statusbar->current_tab;
+                // dont calculate this in because not shown
+                if (!show_read && !is_current && !tab->highlight)
+                    continue;
+
                 char *display_name = _display_name(tab);
                 width += utf8_display_len(display_name);
                 width += 2;