Skip to content

Commit

Permalink
Add static tabmode
Browse files Browse the repository at this point in the history
As requested by some developers, obsolete static mode has been added.
  • Loading branch information
H3rnand3zzz committed Nov 16, 2023
1 parent ed50f30 commit 097025b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
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 default|static|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 default|static|actlist", "Set the mode how the 'active tabs' are shown. Static mode is an obsolete mode that displays windows always from 1 to `max_tabs` without shifting displayed tabs." },
{ "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
2 changes: 1 addition & 1 deletion src/command/cmd_funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -6274,7 +6274,7 @@ 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)) {
if ((g_strcmp0(args[1], "default") == 0) || (g_strcmp0(args[1], "actlist") == 0) || (g_strcmp0(args[1], "static") == 0)) {
tabmode = args[1];
}
if (tabmode == NULL) {
Expand Down
13 changes: 8 additions & 5 deletions src/ui/statusbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ 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);
Expand Down Expand Up @@ -300,9 +300,12 @@ 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, "static") == 0;
_get_range_bounds(&start, &end, is_static);

pos = getmaxx(stdscr) - _tabs_width(start, end);
if (pos < 0) {
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 097025b

Please sign in to comment.