Skip to content

Commit

Permalink
Separate new paging mode in a setting, return static as a default
Browse files Browse the repository at this point in the history
Separate it on `dynamic` mode, as opposed to `static` (ex `default`).

Despite usefulness of the solution,
it was not approved to be a new default.

Vote (link below) amongst users has shown inconclusive result
and it was not representative, as it had low number of participants.
#1912 (comment)
  • Loading branch information
H3rnand3zzz committed Nov 20, 2023
1 parent ed50f30 commit ad2f7e2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
3 changes: 2 additions & 1 deletion src/command/cmd_ac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,8 @@ cmd_ac_init(void)

statusbar_tabmode_ac = autocomplete_new();
autocomplete_add(statusbar_tabmode_ac, "actlist");
autocomplete_add(statusbar_tabmode_ac, "default");
autocomplete_add(statusbar_tabmode_ac, "dynamic");
autocomplete_add(statusbar_tabmode_ac, "static");

status_ac = autocomplete_new();
autocomplete_add(status_ac, "set");
Expand Down
4 changes: 2 additions & 2 deletions src/command/cmd_defs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ static const struct cmd_t command_defs[] = {
"/statusbar hide name|number|read",
"/statusbar maxtabs <value>",
"/statusbar tablen <value>",
"/statusbar tabmode default|actlist",
"/statusbar tabmode static|dynamic|actlist",
"/statusbar self user|barejid|fulljid|off",
"/statusbar chat user|jid",
"/statusbar room title bookmark|jid|localpart|name",
Expand All @@ -1300,7 +1300,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." },
{ "tabmode static|dynamic|actlist", "Set the mode tabs are shown. `dynamic` is a mode that modernizes paging by displaying tabs around current tab. `actlist` setting shows only active tabs. `static` setting always shows tabs in 1 to max_tabs range." },
{ "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." },
Expand Down
7 changes: 2 additions & 5 deletions src/command/cmd_funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -6273,14 +6273,11 @@ 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) {
if ((g_strcmp0(args[1], "static") != 0) && (g_strcmp0(args[1], "actlist") != 0) && (g_strcmp0(args[1], "dynamic") != 0)) {
cons_bad_cmd_usage(command);
return TRUE;
}
char* tabmode = args[1];
prefs_set_string(PREF_STATUSBAR_TABMODE, tabmode);
cons_show("Using \"%s\" tabmode for statusbar.", tabmode);
ui_resize();
Expand Down
2 changes: 1 addition & 1 deletion src/config/preferences.c
Original file line number Diff line number Diff line change
Expand Up @@ -2276,7 +2276,7 @@ _get_default_string(preference_t pref)
case PREF_STATUSBAR_ROOM_TITLE:
return "name";
case PREF_STATUSBAR_TABMODE:
return "default";
return "static";
case PREF_TITLEBAR_MUC_TITLE:
return "name";
case PREF_OMEMO_LOG:
Expand Down
23 changes: 13 additions & 10 deletions src/ui/statusbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ static GTimeZone* tz;
static StatusBar* statusbar;
static WINDOW* statusbar_win;

void _get_range_bounds(int* start, int* end);
void _get_range_bounds(int* start, int* end, gboolean is_static);
static int _status_bar_draw_time(int pos);
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, gboolean prefix, int start, int end);
static int _status_bar_draw_extended_tabs(int pos, gboolean prefix, int start, int end, gboolean is_static);
static int _status_bar_draw_tab(StatusBarTab* tab, int pos, int num);
static int _status_bar_draw_tabs(int pos);
static void _destroy_tab(StatusBarTab* tab);
Expand Down Expand Up @@ -300,16 +300,19 @@ status_bar_draw(void)
static int
_status_bar_draw_tabs(int pos)
{
if (!_tabmode_is_actlist()) {
auto_gchar gchar* tabmode = prefs_get_string(PREF_STATUSBAR_TABMODE);

if (g_strcmp0(tabmode, "actlist") != 0) {
int start, end;
_get_range_bounds(&start, &end);
gboolean is_static = g_strcmp0(tabmode, "dynamic") != 0;
_get_range_bounds(&start, &end, is_static);

pos = getmaxx(stdscr) - _tabs_width(start, end);
if (pos < 0) {
pos = 0;
}

pos = _status_bar_draw_extended_tabs(pos, TRUE, start, end);
pos = _status_bar_draw_extended_tabs(pos, TRUE, start, end, is_static);

for (int i = start; i <= end; i++) {
StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
Expand All @@ -318,7 +321,7 @@ _status_bar_draw_tabs(int pos)
}
}

pos = _status_bar_draw_extended_tabs(pos, FALSE, start, end);
pos = _status_bar_draw_extended_tabs(pos, FALSE, start, end, is_static);
} else {
pos++;
guint print_act = 0;
Expand Down Expand Up @@ -384,7 +387,7 @@ _has_new_msgs_beyond_range_on_side(gboolean left_side, int display_tabs_start, i
}

static int
_status_bar_draw_extended_tabs(int pos, gboolean prefix, int start, int end)
_status_bar_draw_extended_tabs(int pos, gboolean prefix, int start, int end, gboolean is_static)
{
gint max_tabs = prefs_get_statusbartabs();
if (max_tabs == 0) {
Expand All @@ -402,7 +405,7 @@ _status_bar_draw_extended_tabs(int pos, gboolean prefix, int start, int end)
if (!prefix && end > opened_tabs - 1) {
return pos;
}
gboolean is_current = FALSE;
gboolean is_current = is_static && statusbar->current_tab > max_tabs;

pos = _status_bar_draw_bracket(is_current, pos, "[");

Expand Down Expand Up @@ -712,7 +715,7 @@ _display_name(StatusBarTab* tab)
}

void
_get_range_bounds(int* start, int* end)
_get_range_bounds(int* start, int* end, gboolean is_static)
{
int current_tab = statusbar->current_tab;
gint display_range = prefs_get_statusbartabs();
Expand All @@ -722,7 +725,7 @@ _get_range_bounds(int* start, int* end)
if (total_tabs <= display_range) {
*start = 1;
*end = total_tabs;
} else if (current_tab - side_range <= 1) {
} else if (current_tab - side_range <= 1 || is_static) {
*start = 1;
*end = display_range;
} else if (current_tab + side_range >= total_tabs) {
Expand Down

0 comments on commit ad2f7e2

Please sign in to comment.