diff options
| author | Peter Geissler <peter@haxx.in> | 2026-09-20 20:23:23 +0200 |
|---|---|---|
| committer | Peter Geissler <peter@haxx.in> | 2026-09-20 20:23:23 +0200 |
| commit | 07e1adf1124657aaea4fa32874282812281e4889 (patch) | |
| tree | ab63600e4438260e3e5c650bc711645fe21d066a /src | |
| parent | sidebar: a status can have more than one row (tab_bar_status_lines) (diff) | |
| download | slosh-07e1adf1124657aaea4fa32874282812281e4889.tar.gz slosh-07e1adf1124657aaea4fa32874282812281e4889.tar.xz slosh-07e1adf1124657aaea4fa32874282812281e4889.zip | |
sidebar: air between tabs (tab_gap)
A tab carrying three rows of wrapped status and the tab under it carrying
three more read as one column of text: the labels are in there, but the list
has stopped looking like a list. tab_gap is the blank rows between them, 0 by
default, which is exactly what the sidebar has always drawn.
It is the space *between* tabs and nothing else. Above the first tab is
tab_bar_pad's and before the button is newtab_pad's, so the gap is applied
before each label except the first and none of the three is ever paid twice.
Given up a row at a time when the list is short of room, ahead of every label
and the button, which is the same order the pad and the statuses already
follow: a gap that pushed a tab off the bottom would be spacing costing you
the thing it spaces. Paint rather than layout, so tuning it repaints without
reflowing any pane. Sidebars only -- the top strip is one row, and the space
between tabs there is the label's own padding.
Diffstat (limited to 'src')
| -rw-r--r-- | src/app_draw.c | 17 | ||||
| -rw-r--r-- | src/config.c | 6 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/app_draw.c b/src/app_draw.c index 863b7f0..a363143 100644 --- a/src/app_draw.c +++ b/src/app_draw.c @@ -2188,6 +2188,23 @@ void draw_tab_sidebar(app_t *a, screen_t *s) { uint16_t btn_rows = (CFG.newtab_button && cells(CFG.newtab_mark)) ? (uint16_t)1 : (uint16_t)0; for (size_t i = 0; i < a->ntabs && y < limit; i++) { + /* Air between one tab and the next. Before the label rather than after + * the statuses, so it is the gap between two tabs and not a trailing + * margin under the last one -- the space before the first is + * tab_bar_pad's and the space before the button is newtab_pad's, and + * neither should be paid twice. + * + * Given up a row at a time when the list is short of room, ahead of + * anything that means something: a gap that pushed a tab off the bottom + * would be spacing costing you the thing it spaces. */ + if (i) { + uint16_t g = CFG.tab_gap; + /* This tab's own label, the ones after it, and the button. */ + uint16_t need = (uint16_t)(a->ntabs - i + btn_rows); + while (g && (uint16_t)(y + g + need) > limit) g--; + y = (uint16_t)(y + g); + if (y >= limit) break; + } draw_tab_cell(a, s, i, cx, y, cw, dragging_pane); y++; if (!cap) continue; diff --git a/src/config.c b/src/config.c index f3662fd..b9e3c29 100644 --- a/src/config.c +++ b/src/config.c @@ -954,6 +954,7 @@ void config_defaults(config_t *c) { * a gap nobody asked for. Still there for a bare sidebar, or for anyone * who wants room at the top for a borderless window's own buttons. */ c->tab_bar_pad = 0; + c->tab_gap = 0; /* flush, the way the list has always read */ /* Three is enough for "the build, the tests, and one more thing" without a * chatty tab pushing the list off the bottom. */ c->tab_bar_status = 3; @@ -1686,6 +1687,8 @@ char *config_render(const config_t *c) { c->tab_bar_width); cb_add(&b, "tab_bar_pad %u // blank rows above a sidebar's tabs\n", c->tab_bar_pad); + cb_add(&b, "tab_gap %u // blank rows between a sidebar's tabs\n", + c->tab_gap); cb_add(&b, "tab_bar_status %u // pane status rows under each tab, 0 = off\n", c->tab_bar_status); @@ -2017,6 +2020,7 @@ static const char *const KNOWN_TOP[] = { "tab_bar_status", "tab_bar_status_lines", "tab_bar_width", + "tab_gap", "theme", "title_align", "title_inset", @@ -2229,6 +2233,8 @@ static bool load_into(config_t *c, const char *path, int depth, char *err, c->tab_bar_width); c->tab_bar_pad = (uint16_t)kdl_arg_int(kdl_child(root, "tab_bar_pad"), 0, c->tab_bar_pad); + c->tab_gap = + (uint16_t)kdl_arg_int(kdl_child(root, "tab_gap"), 0, c->tab_gap); c->tab_bar_status = (uint16_t)kdl_arg_int(kdl_child(root, "tab_bar_status"), 0, c->tab_bar_status); c->tab_bar_status_lines = (uint16_t)kdl_arg_int( |
