add /statusbar tabmode actlist

The existing way how active tabs are displayed didn't allow showing more
than 10 tabs. This patch adds a mode where the statusbar shows a
comma-separated list of tabs which were active since the last time viewed.
This view is inspired by how `irssi` shows the active tabs, therefore
it is also called `actlist`.

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
This commit is contained in:
Steffen Jaeckel
2023-04-03 18:37:23 +02:00
parent 5f078f95f2
commit 0cf79848e9
7 changed files with 136 additions and 47 deletions

View File

@@ -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;

View File

@@ -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",

View File

@@ -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");