commit 56168aa87af6918bce552d405f8e757349360b03 from: Omar Polo date: Wed Aug 18 16:49:46 2021 UTC add tab-bar-show option to control the tab bar rendering If tab-bar-show is -1 hide the tab bar permanently, if it's 0 show it unconditionally. If it's 1, show the bar only when there is more than one tab. commit - 3cea4ff5b5f444730267c4774f4217b6079fc71a commit + 56168aa87af6918bce552d405f8e757349360b03 blob - e7099ca9b0e80d74258336f5a07f922b7d38784e blob + 167ff546b01b58fee00760256ac5e7efd01a80b0 --- defaults.c +++ defaults.c @@ -38,6 +38,7 @@ int hide_pre_closing_line = 0; int hide_pre_context = 0; int olivetti_mode = 1; int set_title = 1; +int tab_bar_show = 1; struct lineprefix line_prefixes[] = { [LINE_TEXT] = { "", "" }, @@ -495,6 +496,13 @@ config_setvari(const char *var, int val) set_title = !!val; } else if (!strcmp(var, "autosave")) { autosave = val; + } else if (!strcmp(var, "tab-bar-show")) { + if (val < 0) + tab_bar_show = -1; + else if (val == 0) + tab_bar_show = 0; + else + tab_bar_show = 1; } else { return 0; } blob - 3bb7bee9fa10b99fdc77684477d6c89353acc874 blob + aae4fb1d66e38db84b8a314c42c74059183477e8 --- defaults.h +++ defaults.h @@ -29,6 +29,7 @@ extern int hide_pre_closing_line; extern int hide_pre_context; extern int olivetti_mode; extern int set_title; +extern int tab_bar_show; struct lineprefix { const char *prfx1; blob - 8a486a31ba1650d21b2ddd0e4213451a1905ad34 blob + 8532e8276791abb4bb8afa03438ae40d3b4b107d --- ui.c +++ ui.c @@ -74,6 +74,7 @@ static void update_loading_anim(int, short, void*); static void stop_loading_anim(struct tab*); static int should_rearrange_windows; +static int show_tab_bar; static int too_small; static int x_offset; @@ -294,12 +295,24 @@ handle_resize_nodelay(int s, short ev, void *d) rearrange_windows(); } +static inline int +should_show_tab_bar(void) +{ + if (tab_bar_show == -1) + return 0; + if (tab_bar_show == 0) + return 1; + + return TAILQ_NEXT(TAILQ_FIRST(&tabshead), tabs) != NULL; +} + static void rearrange_windows(void) { int lines; should_rearrange_windows = 0; + show_tab_bar = should_show_tab_bar(); lines = LINES; @@ -326,26 +339,31 @@ rearrange_windows(void) mvwin(modeline, --lines, 0); wresize(modeline, 1, COLS); - body_lines = --lines; + body_lines = show_tab_bar ? --lines : lines; body_cols = COLS; + /* + * Here we make the assumption that show_tab_bar is either 0 + * or 1, and reuse that as argument to mvwin. + */ if (side_window) { help_cols = 0.3 * COLS; help_lines = lines; - mvwin(help, 1, 0); + mvwin(help, show_tab_bar, 0); wresize(help, help_lines, help_cols); wrap_page(&helpwin, help_cols); body_cols = COLS - help_cols - 1; - mvwin(body, 1, help_cols); + mvwin(body, show_tab_bar, help_cols); } else - mvwin(body, 1, 0); + mvwin(body, show_tab_bar, 0); update_x_offset(); wresize(body, body_lines, body_cols); - wresize(tabline, 1, COLS); + if (show_tab_bar) + wresize(tabline, 1, COLS); wrap_page(¤t_tab->buffer, body_cols); redraw_tab(current_tab); @@ -879,7 +897,9 @@ redraw_tab(struct tab *tab) wnoutrefresh(help); } - redraw_tabline(); + if (show_tab_bar) + redraw_tabline(); + redraw_body(tab); redraw_modeline(tab); redraw_minibuffer(); @@ -1078,7 +1098,9 @@ ui_on_tab_loaded(struct tab *tab) stop_loading_anim(tab); message("Loaded %s", tab->hist_cur->h); - redraw_tabline(); + if (show_tab_bar) + redraw_tabline(); + wrefresh(tabline); place_cursor(0); }