aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_tab_bar.py
diff options
context:
space:
mode:
authoruser <user@clank>2026-09-10 15:41:16 +0200
committeruser <user@clank>2026-09-10 15:41:16 +0200
commit881c9b4a5c7352daf4861bff5902936e9746f9f5 (patch)
treed57b4eb8ceaf3675236c2c31924eb89d900d8dc7 /tests/test_tab_bar.py
parenttabs: the strip can stand on its side (tab_bar_side left/right) (diff)
downloadslosh-881c9b4a5c7352daf4861bff5902936e9746f9f5.tar.gz
slosh-881c9b4a5c7352daf4861bff5902936e9746f9f5.tar.xz
slosh-881c9b4a5c7352daf4861bff5902936e9746f9f5.zip
sidebar: a row of air on top (tab_bar_pad), indicators under the labels' inset
One blank row above the first tab by default: a list starting in the very corner reads as cramped, and in compact mode the row lines the first tab up with the pane content inside the ring rather than with the ring's top line. The pad is where the drawing starts, not a layout fact -- the panes' rect is identical at pad 0 and pad 5, so tuning it repaints without reflowing anyone. The bottom indicators (pane count, prefix badge) move in one cell to sit under the labels' own leading space; flush at the edge column they read as misaligned on the left and collide with the compact ring's corner on the right.
Diffstat (limited to 'tests/test_tab_bar.py')
-rw-r--r--tests/test_tab_bar.py57
1 files changed, 41 insertions, 16 deletions
diff --git a/tests/test_tab_bar.py b/tests/test_tab_bar.py
index 5f466e1..842d421 100644
--- a/tests/test_tab_bar.py
+++ b/tests/test_tab_bar.py
@@ -33,21 +33,21 @@ def test_left_sidebar_reserves_columns():
with Session(SH, cols=90, rows=20, config=LEFT) as s:
s.settle(30)
snap = s.snapshot()
- # gap 1 (the default): the sidebar's first row is row 1, like the strip.
+ # gap 1 + tab_bar_pad 1 (the defaults): the first tab is row 2.
check(
"the first tab is a row in the sidebar",
- snap.hit_at(1, 1) == "tab:1",
- str(snap.hit_at(1, 1)),
+ snap.hit_at(1, 2) == "tab:1",
+ str(snap.hit_at(1, 2)),
)
check(
"the whole row is the target, not just the label",
- snap.hit_at(W - 1, 1) == "tab:1",
- str(snap.hit_at(W - 1, 1)),
+ snap.hit_at(W - 1, 2) == "tab:1",
+ str(snap.hit_at(W - 1, 2)),
)
check(
"the + sits on the row after the last tab",
- snap.hit_at(1, 2) == "newtab",
- str(snap.hit_at(1, 2)),
+ snap.hit_at(1, 3) == "newtab",
+ str(snap.hit_at(1, 3)),
)
p = s.pane(0)
check("panes give up the sidebar's columns", p["x"] >= W, str(p["x"]))
@@ -62,17 +62,17 @@ def test_left_sidebar_reserves_columns():
def test_sidebar_rows_click_like_the_strip():
with Session(SH, cols=90, rows=20, config=LEFT) as s:
s.settle(30)
- s.click(1, 2) # the + row: a new tab, which becomes the active one
+ s.click(1, 3) # the + row: a new tab, which becomes the active one
s.until(lambda _: len(s.tabs()) == 2)
check("the + row makes a tab", len(s.tabs()) == 2, str(len(s.tabs())))
check("...and it is the one you are in", s.tabs()[1]["active"], str(s.tabs()))
snap = s.snapshot()
check(
"the new tab is the next row down",
- snap.hit_at(1, 2) == "tab:2",
- str(snap.hit_at(1, 2)),
+ snap.hit_at(1, 3) == "tab:2",
+ str(snap.hit_at(1, 3)),
)
- s.click(1, 1) # the first tab's row
+ s.click(1, 2) # the first tab's row
s.until(lambda _: s.tabs()[0]["active"])
check("clicking a row selects that tab", s.tabs()[0]["active"], str(s.tabs()))
@@ -84,8 +84,8 @@ def test_right_sidebar_takes_the_other_edge():
x0 = 90 - W
check(
"the first tab is a row on the right edge",
- snap.hit_at(x0 + 1, 1) == "tab:1",
- str(snap.hit_at(x0 + 1, 1)),
+ snap.hit_at(x0 + 1, 2) == "tab:1",
+ str(snap.hit_at(x0 + 1, 2)),
)
p = s.pane(0)
check(
@@ -95,6 +95,30 @@ def test_right_sidebar_takes_the_other_edge():
)
+def test_pad_pushes_the_list_down():
+ pad = _cfg(f'tab_bar_side "left"\ntab_bar_width {W}\ntab_bar_pad 3\n')
+ with Session(SH, cols=90, rows=20, config=pad) as s:
+ s.settle(30)
+ snap = s.snapshot()
+ # gap 1 + pad 3: the first tab is on row 4, and the rows above are air.
+ check(
+ "the pad rows are not targets",
+ snap.hit_at(1, 1) is None and snap.hit_at(1, 3) is None,
+ f"{snap.hit_at(1, 1)} / {snap.hit_at(1, 3)}",
+ )
+ check(
+ "the first tab starts below the pad",
+ snap.hit_at(1, 4) == "tab:1",
+ str(snap.hit_at(1, 4)),
+ )
+ p = s.pane(0)
+ check(
+ "the pad is paint, not layout: panes keep their rows",
+ p["y"] <= 2,
+ str(p["y"]),
+ )
+
+
def test_narrow_terminal_falls_back_to_top():
# 40 < width + min_pane cols + 4: the sidebar would leave no room for the
# pane it is chrome for, so the strip goes back to the top row.
@@ -114,11 +138,11 @@ def test_growing_back_restores_the_sidebar():
with Session(SH, cols=40, rows=20, config=LEFT) as s:
s.settle(30)
s.resize(90, 20)
- s.until(lambda snap: snap.hit_at(1, 1) == "tab:1")
+ s.until(lambda snap: snap.hit_at(1, 2) == "tab:1")
check(
"a resize moves the bar without anyone storing state",
- s.snapshot().hit_at(1, 1) == "tab:1",
- str(s.snapshot().hit_at(1, 1)),
+ s.snapshot().hit_at(1, 2) == "tab:1",
+ str(s.snapshot().hit_at(1, 2)),
)
p = s.pane(0)
check("and the panes give the columns back", p["x"] >= W, str(p["x"]))
@@ -128,6 +152,7 @@ if __name__ == "__main__":
test_left_sidebar_reserves_columns()
test_sidebar_rows_click_like_the_strip()
test_right_sidebar_takes_the_other_edge()
+ test_pad_pushes_the_list_down()
test_narrow_terminal_falls_back_to_top()
test_growing_back_restores_the_sidebar()
sys.exit(report())