about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/command/cmd_ac.c13
-rw-r--r--src/command/cmd_defs.c3
-rw-r--r--src/command/cmd_funcs.c15
-rw-r--r--src/config/preferences.c5
-rw-r--r--src/config/preferences.h1
-rw-r--r--src/ui/console.c12
-rw-r--r--src/ui/statusbar.c132
7 files changed, 135 insertions, 46 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c
index 0cc4a170..bb204935 100644
--- a/src/command/cmd_ac.c
+++ b/src/command/cmd_ac.c
@@ -265,6 +265,7 @@ static Autocomplete statusbar_self_ac;
 static Autocomplete statusbar_chat_ac;
 static Autocomplete statusbar_room_ac;
 static Autocomplete statusbar_show_ac;
+static Autocomplete statusbar_tabmode_ac;
 static Autocomplete clear_ac;
 static Autocomplete invite_ac;
 static Autocomplete status_ac;
@@ -1030,6 +1031,7 @@ cmd_ac_init(void)
     autocomplete_add(statusbar_ac, "hide");
     autocomplete_add(statusbar_ac, "maxtabs");
     autocomplete_add(statusbar_ac, "tablen");
+    autocomplete_add(statusbar_ac, "tabmode");
     autocomplete_add(statusbar_ac, "self");
     autocomplete_add(statusbar_ac, "chat");
     autocomplete_add(statusbar_ac, "room");
@@ -1058,6 +1060,10 @@ cmd_ac_init(void)
     autocomplete_add(statusbar_show_ac, "number");
     autocomplete_add(statusbar_show_ac, "read");
 
+    statusbar_tabmode_ac = autocomplete_new();
+    autocomplete_add(statusbar_tabmode_ac, "actlist");
+    autocomplete_add(statusbar_tabmode_ac, "default");
+
     status_ac = autocomplete_new();
     autocomplete_add(status_ac, "set");
     autocomplete_add(status_ac, "get");
@@ -1678,6 +1684,7 @@ cmd_ac_reset(ProfWin* window)
     autocomplete_reset(statusbar_chat_ac);
     autocomplete_reset(statusbar_room_ac);
     autocomplete_reset(statusbar_show_ac);
+    autocomplete_reset(statusbar_tabmode_ac);
     autocomplete_reset(clear_ac);
     autocomplete_reset(invite_ac);
     autocomplete_reset(status_ac);
@@ -1864,6 +1871,7 @@ cmd_ac_uninit(void)
     autocomplete_free(statusbar_chat_ac);
     autocomplete_free(statusbar_room_ac);
     autocomplete_free(statusbar_show_ac);
+    autocomplete_free(statusbar_tabmode_ac);
     autocomplete_free(clear_ac);
     autocomplete_free(invite_ac);
     autocomplete_free(status_ac);
@@ -4110,6 +4118,11 @@ _statusbar_autocomplete(ProfWin* window, const char* const input, gboolean previ
         return found;
     }
 
+    found = autocomplete_param_with_ac(input, "/statusbar tabmode", statusbar_tabmode_ac, TRUE, previous);
+    if (found) {
+        return found;
+    }
+
     found = autocomplete_param_with_ac(input, "/statusbar room", statusbar_room_ac, TRUE, previous);
 
     return found;
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index d204db3b..fd90fdca 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -1293,6 +1293,7 @@ static const struct cmd_t command_defs[] = {
               "/statusbar hide name|number|read",
               "/statusbar maxtabs <value>",
               "/statusbar tablen <value>",
+              "/statusbar tabmode default|actlist",
               "/statusbar self user|barejid|fulljid|off",
               "/statusbar chat user|jid",
               "/statusbar room room|jid",
@@ -1303,6 +1304,7 @@ static const struct cmd_t command_defs[] = {
       CMD_ARGS(
               { "maxtabs <value>", "Set the maximum number of tabs to display, <value> must be between 0 and 10." },
               { "tablen <value>", "Set the maximum number of characters to show as the tab name, 0 sets to unlimited." },
+              { "tabmode default|actlist", "Set the mode how the 'active tabs' are shown." },
               { "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." },
@@ -1315,6 +1317,7 @@ static const struct cmd_t command_defs[] = {
       CMD_EXAMPLES(
               "/statusbar maxtabs 8",
               "/statusbar tablen 5",
+              "/statusbar tabmode actlist",
               "/statusbar self user",
               "/statusbar chat jid",
               "/statusbar hide read",
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 919b7ddb..9dcd4f3d 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -6341,6 +6341,21 @@ cmd_statusbar(ProfWin* window, const char* const command, gchar** args)
         }
     }
 
+    if (g_strcmp0(args[0], "tabmode") == 0) {
+        char* tabmode = NULL;
+        if ((g_strcmp0(args[1], "default") == 0) || (g_strcmp0(args[1], "actlist") == 0)) {
+            tabmode = args[1];
+        }
+        if (tabmode == NULL) {
+            cons_bad_cmd_usage(command);
+            return TRUE;
+        }
+        prefs_set_string(PREF_STATUSBAR_TABMODE, tabmode);
+        cons_show("Using \"%s\" tabmode for statusbar.", tabmode);
+        ui_resize();
+        return TRUE;
+    }
+
     if (g_strcmp0(args[0], "self") == 0) {
         if (g_strcmp0(args[1], "barejid") == 0) {
             prefs_set_string(PREF_STATUSBAR_SELF, "barejid");
diff --git a/src/config/preferences.c b/src/config/preferences.c
index f15952cd..2d975e39 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -1813,6 +1813,7 @@ _get_group(preference_t pref)
     case PREF_STATUSBAR_SELF:
     case PREF_STATUSBAR_CHAT:
     case PREF_STATUSBAR_ROOM:
+    case PREF_STATUSBAR_TABMODE:
     case PREF_TITLEBAR_MUC_TITLE_JID:
     case PREF_TITLEBAR_MUC_TITLE_NAME:
     case PREF_SLASH_GUARD:
@@ -2136,6 +2137,8 @@ _get_key(preference_t pref)
         return "statusbar.chat";
     case PREF_STATUSBAR_ROOM:
         return "statusbar.room";
+    case PREF_STATUSBAR_TABMODE:
+        return "statusbar.tabmode";
     case PREF_OMEMO_LOG:
         return "log";
     case PREF_OMEMO_POLICY:
@@ -2300,6 +2303,8 @@ _get_default_string(preference_t pref)
         return "user";
     case PREF_STATUSBAR_ROOM:
         return "room";
+    case PREF_STATUSBAR_TABMODE:
+        return "default";
     case PREF_OMEMO_LOG:
         return "on";
     case PREF_OMEMO_POLICY:
diff --git a/src/config/preferences.h b/src/config/preferences.h
index ca8acea4..ecb28485 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -186,6 +186,7 @@ typedef enum {
     PREF_STROPHE_SM_ENABLED,
     PREF_STROPHE_SM_RESEND,
     PREF_VCARD_PHOTO_CMD,
+    PREF_STATUSBAR_TABMODE,
 } preference_t;
 
 typedef struct prof_alias_t
diff --git a/src/ui/console.c b/src/ui/console.c
index f34f6f03..948de003 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -2005,21 +2005,21 @@ cons_statusbar_setting(void)
         cons_show("Max tab length (/statusbar)                 : %d", pref_len);
     }
 
-    char* pref_self = prefs_get_string(PREF_STATUSBAR_SELF);
+    auto_gchar gchar* pref_self = prefs_get_string(PREF_STATUSBAR_SELF);
     if (g_strcmp0(pref_self, "off") == 0) {
         cons_show("Self statusbar display (/statusbar)         : OFF");
     } else {
         cons_show("Self statusbar display (/statusbar)         : %s", pref_self);
     }
-    g_free(pref_self);
 
-    char* pref_chat = prefs_get_string(PREF_STATUSBAR_CHAT);
+    auto_gchar gchar* pref_chat = prefs_get_string(PREF_STATUSBAR_CHAT);
     cons_show("Chat tab display (/statusbar)               : %s", pref_chat);
-    g_free(pref_chat);
 
-    char* pref_room = prefs_get_string(PREF_STATUSBAR_ROOM);
+    auto_gchar gchar* pref_room = prefs_get_string(PREF_STATUSBAR_ROOM);
     cons_show("Room tab display (/statusbar)               : %s", pref_room);
-    g_free(pref_room);
+
+    auto_gchar gchar* pref_tabmode = prefs_get_string(PREF_STATUSBAR_TABMODE);
+    cons_show("Tab mode (/statusbar)                       : %s", pref_tabmode);
 }
 
 void
diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c
index e447e7d5..38d28c31 100644
--- a/src/ui/statusbar.c
+++ b/src/ui/statusbar.c
@@ -79,14 +79,15 @@ static StatusBar* statusbar;
 static WINDOW* statusbar_win;
 
 static int _status_bar_draw_time(int pos);
-static void _status_bar_draw_maintext(int pos);
-static int _status_bar_draw_bracket(gboolean current, int pos, char* ch);
+static int _status_bar_draw_maintext(int pos);
+static int _status_bar_draw_bracket(gboolean current, int pos, const char* ch);
 static int _status_bar_draw_extended_tabs(int pos);
 static int _status_bar_draw_tab(StatusBarTab* tab, int pos, int num);
 static void _destroy_tab(StatusBarTab* tab);
 static int _tabs_width(void);
 static char* _display_name(StatusBarTab* tab);
 static gboolean _extended_new(void);
+static gboolean _tabmode_is_actlist(void);
 
 void
 status_bar_init(void)
@@ -289,21 +290,59 @@ status_bar_draw(void)
 
     pos = _status_bar_draw_time(pos);
 
-    _status_bar_draw_maintext(pos);
+    pos = _status_bar_draw_maintext(pos);
 
-    pos = getmaxx(stdscr) - _tabs_width();
-    if (pos < 0) {
-        pos = 0;
-    }
-    gint max_tabs = prefs_get_statusbartabs();
-    for (int i = 1; i <= max_tabs; i++) {
-        StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
-        if (tab) {
-            pos = _status_bar_draw_tab(tab, pos, i);
+    if (!_tabmode_is_actlist()) {
+        pos = getmaxx(stdscr) - _tabs_width();
+        if (pos < 0) {
+            pos = 0;
+        }
+        gint max_tabs = prefs_get_statusbartabs();
+        for (int i = 1; i <= max_tabs; i++) {
+            StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
+            if (tab) {
+                pos = _status_bar_draw_tab(tab, pos, i);
+            }
         }
-    }
 
-    _status_bar_draw_extended_tabs(pos);
+        _status_bar_draw_extended_tabs(pos);
+    } else {
+        pos++;
+        guint print_act = 0;
+        guint tabnum = g_hash_table_size(statusbar->tabs);
+        for (guint i = 1; i <= tabnum; ++i) {
+            StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
+            if (tab && tab->highlight) {
+                print_act++;
+            }
+        }
+        if (print_act) {
+            pos = _status_bar_draw_bracket(FALSE, pos, "[");
+            mvwprintw(statusbar_win, 0, pos, "Act: ");
+            pos += 5;
+            int status_attrs = theme_attrs(THEME_STATUS_NEW);
+
+            wattron(statusbar_win, status_attrs);
+            for (guint i = 1; i <= tabnum && print_act; ++i) {
+                StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
+                if (tab && tab->highlight) {
+                    if (print_act == 1) {
+                        mvwprintw(statusbar_win, 0, pos, "%d", i);
+                        pos++;
+                    } else {
+                        mvwprintw(statusbar_win, 0, pos, "%d,", i);
+                        pos += 2;
+                    }
+                    for (guint limit = 10; i >= limit; limit *= 10) {
+                        pos++;
+                    }
+                    print_act--;
+                }
+            }
+            wattroff(statusbar_win, status_attrs);
+            pos = _status_bar_draw_bracket(FALSE, pos, "]");
+        }
+    }
 
     wnoutrefresh(statusbar_win);
     inp_put_back();
@@ -410,7 +449,7 @@ _status_bar_draw_tab(StatusBarTab* tab, int pos, int num)
 }
 
 static int
-_status_bar_draw_bracket(gboolean current, int pos, char* ch)
+_status_bar_draw_bracket(gboolean current, int pos, const char* ch)
 {
     int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET);
     wattron(statusbar_win, bracket_attrs);
@@ -466,39 +505,52 @@ _status_bar_draw_time(int pos)
     return pos;
 }
 
-static void
+static gboolean
+_tabmode_is_actlist(void)
+{
+    auto_char char* tabmode = prefs_get_string(PREF_STATUSBAR_TABMODE);
+    return g_strcmp0(tabmode, "actlist") == 0;
+}
+
+static int
 _status_bar_draw_maintext(int pos)
 {
+    const char* maintext = NULL;
+    auto_jid Jid* jidp = NULL;
+    auto_char char* self = prefs_get_string(PREF_STATUSBAR_SELF);
     if (statusbar->prompt) {
         mvwprintw(statusbar_win, 0, pos, "%s", statusbar->prompt);
-        return;
+        return utf8_display_len(statusbar->prompt);
+    } else if (g_strcmp0(self, "off") == 0) {
+        return pos;
+    } else if (statusbar->fulljid) {
+        jidp = jid_create(statusbar->fulljid);
+        if (g_strcmp0(self, "user") == 0) {
+            maintext = jidp->localpart;
+        } else if (g_strcmp0(self, "barejid") == 0) {
+            maintext = jidp->barejid;
+        } else {
+            maintext = statusbar->fulljid;
+        }
     }
 
-    gboolean stop = FALSE;
-
-    if (statusbar->fulljid) {
-        char* pref = prefs_get_string(PREF_STATUSBAR_SELF);
-
-        if (g_strcmp0(pref, "off") == 0) {
-            stop = true;
-        } else if (g_strcmp0(pref, "user") == 0) {
-            Jid* jidp = jid_create(statusbar->fulljid);
-            mvwprintw(statusbar_win, 0, pos, "%s", jidp->localpart);
-            jid_destroy(jidp);
-            stop = true;
-        } else if (g_strcmp0(pref, "barejid") == 0) {
-            Jid* jidp = jid_create(statusbar->fulljid);
-            mvwprintw(statusbar_win, 0, pos, "%s", jidp->barejid);
-            jid_destroy(jidp);
-            stop = true;
-        }
+    if (maintext == NULL) {
+        return pos;
+    }
 
-        g_free(pref);
-        if (stop) {
-            return;
-        }
-        mvwprintw(statusbar_win, 0, pos, "%s", statusbar->fulljid);
+    gboolean actlist_tabmode = _tabmode_is_actlist();
+    auto_gchar gchar* maintext_ = NULL;
+    if (actlist_tabmode) {
+        pos = _status_bar_draw_bracket(FALSE, pos, "[");
+        maintext_ = g_strdup_printf("%d:%s", statusbar->current_tab, maintext);
+        maintext = maintext_;
     }
+    mvwprintw(statusbar_win, 0, pos, "%s", maintext);
+    pos += utf8_display_len(maintext);
+    if (actlist_tabmode) {
+        pos = _status_bar_draw_bracket(FALSE, pos, "]");
+    }
+    return pos;
 }
 
 static void