Skip to content

Commit

Permalink
Make statusbar actlist respect the /statusbar show setting
Browse files Browse the repository at this point in the history
This lets users use the actlist and decide if they want to see name or
numbers.

Fix #1974
  • Loading branch information
jubalh committed Jun 19, 2024
1 parent 57c8969 commit f8723cc
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/ui/statusbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ 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, gboolean is_static);
static int _status_bar_draw_tab(StatusBarTab* tab, int pos, int num);
static int _status_bar_draw_tab(StatusBarTab* tab, int pos, int num, gboolean include_brackets);
static int _status_bar_draw_tabs(int pos);
static void _destroy_tab(StatusBarTab* tab);
static int _tabs_width(int start, int end);
Expand Down Expand Up @@ -317,7 +317,7 @@ _status_bar_draw_tabs(int pos)
for (int i = start; i <= end; i++) {
StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
if (tab) {
pos = _status_bar_draw_tab(tab, pos, i);
pos = _status_bar_draw_tab(tab, pos, i, TRUE);
}
}

Expand All @@ -342,14 +342,9 @@ _status_bar_draw_tabs(int pos)
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 = _status_bar_draw_tab(tab, pos, i, FALSE);
if (print_act > 1) {
mvwprintw(statusbar_win, 0, pos, ",");
pos++;
}
print_act--;
Expand Down Expand Up @@ -429,7 +424,7 @@ _status_bar_draw_extended_tabs(int pos, gboolean prefix, int start, int end, gbo
}

static int
_status_bar_draw_tab(StatusBarTab* tab, int pos, int num)
_status_bar_draw_tab(StatusBarTab* tab, int pos, int num, gboolean include_brackets)
{
gboolean is_current = num == statusbar->current_tab;

Expand All @@ -441,7 +436,9 @@ _status_bar_draw_tab(StatusBarTab* tab, int pos, int num)
if (!show_read && !is_current && !tab->highlight)
return pos;

pos = _status_bar_draw_bracket(is_current, pos, "[");
if (include_brackets) {
pos = _status_bar_draw_bracket(is_current, pos, "[");
}

int status_attrs;
if (is_current) {
Expand All @@ -468,7 +465,9 @@ _status_bar_draw_tab(StatusBarTab* tab, int pos, int num)
}
wattroff(statusbar_win, status_attrs);

pos = _status_bar_draw_bracket(is_current, pos, "]");
if (include_brackets) {
pos = _status_bar_draw_bracket(is_current, pos, "]");
}

return pos;
}
Expand Down

0 comments on commit f8723cc

Please sign in to comment.