summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-25 06:06:54 -0300
committerGabriel Schneider <[email protected]>2026-11-25 06:09:08 -0300
commit5c897d00fe064cf8463ef76ea804b0aff6b62f0a (patch)
tree94650db0d887b1c5cbf1ff7aba492b7c036b791c
parent1d440373e90516ace8e45e8e64f2e4ae5d4a4773 (diff)
downloadpardes-5c897d00fe064cf8463ef76ea804b0aff6b62f0a.tar.gz
pardes-5c897d00fe064cf8463ef76ea804b0aff6b62f0a.zip
Band, Core, draw, mouse, layout: a band over a terminal or a kind's pane is drawn over its body's top rows, so a transient state never resizes a pty or a kind's view (walk UI polish P1, G3's finding; UX DESIGN.md D6's borrowing and R3, drawn never written, my reading of D5/D6 for these bodies): a band's rows came out of the pane's body in every pane (Core.sync `tag_rows += band_rows`), so `:` or SPC Down in a terminal resized its pty smaller and back, the shell redrew under it and left its prompt row blank (tagnav's row 6 `$ `, ttytaken's prompt line moved two columns), and a PDF's view was re-sized each time; now Band.over (a terminal, a kind's pane) keeps its `band_rows` at 0, the pane's size the user's alone, and the band is painted after every pane's body (draw.render, Band.shownRows: what the band wants held to the body's rows) at the body's first row, its layer's viewport there; mouse.bandPoint reads the same rows; layout.floorRows borrows nothing for it; joinBand takes its rows; TEST FIRST: TagState.zig "a band over a terminal is drawn over its body's top rows: its pty keeps its size across the band's open and close" (a shell: SPC Down, then `:`: band_rows 0, the tag's rows, the pty's rows and columns as at rest, the band layer at the body's top, no resize_pty effect after Esc; on the parent it fails at band_rows: the band's rows were the body's); the terminal test of rolled levels loses its key-cell-alone step (D12 took that state away); core-test 1066/1237 (171 skipped), shell-test's terminal tests 12/12; process-test: tagnav and ttytaken regenerated and read: tagnav's tty-on and column-tag snaps have the shell's `$ ` on row 6 again (G2's golden), ttytaken's at-prompt row 5 is ` echo TAKEN''ONE` again (main's; E2's two-column shift was the resize's redraw); a user met it at every `:` or band in a terminal
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
-rw-r--r--core/Band.zig16
-rw-r--r--core/Core.zig3
-rw-r--r--core/TagState.zig42
-rw-r--r--core/draw.zig15
-rw-r--r--core/layout.zig2
-rw-r--r--core/mouse.zig5
-rw-r--r--test/snapshots/tagnav.golden2
-rw-r--r--test/snapshots/ttytaken.golden2
8 files changed, 72 insertions, 15 deletions
diff --git a/core/Band.zig b/core/Band.zig
index 0d4891aa..07c2f83d 100644
--- a/core/Band.zig
+++ b/core/Band.zig
@@ -113,6 +113,22 @@ pub fn takes(p: *Pardes, id: usize) u16 {
return @max(doc_rows, levelRows(n));
}
+/// A terminal's and a kind's band is drawn over the top rows of its body
+/// (UX D6's borrowing, R3: drawn, never written): a transient state never
+/// resizes a pty under a program or a kind's view (a PDF's), whose size
+/// only the user's resize changes. Their `band_rows` stay 0.
+pub fn over(pane: *const Pane) bool {
+ return pane.isTerminal() or pane.addon != null;
+}
+
+/// The rows pane `id`'s band is drawn on: those it takes from the layout,
+/// or over a terminal's or a kind's body, as many of its body rows as the
+/// band wants.
+pub fn shownRows(p: *Pardes, pane: *const Pane, id: usize) u16 {
+ if (pane.band_rows > 0 or !over(pane) or pane.collapsed) return pane.band_rows;
+ return @min(takes(p, id), p.view().rects[id].h -| pane.tag_rows);
+}
+
fn levelRows(n: u16) u16 {
return if (n > one_column) (n + 1) / 2 else n;
}
diff --git a/core/Core.zig b/core/Core.zig
index e43f9e83..26860365 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -2062,7 +2062,8 @@ pub fn sync(p: *Pardes) void {
} else pane.tag_top = 0;
// The band unrolled under the tag's text pushes the body down:
// the tag's rows, as everything under them counts them.
- pane.band_rows = if (pane.collapsed) 0 else @min(pardes.Band.takes(p, id), r.h -| pane.tag_rows);
+ // A terminal's or a kind's is drawn over its body instead (Band.over).
+ pane.band_rows = if (pane.collapsed or pardes.Band.over(pane)) 0 else @min(pardes.Band.takes(p, id), r.h -| pane.tag_rows);
pane.tag_rows += pane.band_rows;
const cols = @max(1, r.w -| config.GUTTER);
// The tag steals the top rows. The pty is what the pane shows
diff --git a/core/TagState.zig b/core/TagState.zig
index 18fd5fac..c364451a 100644
--- a/core/TagState.zig
+++ b/core/TagState.zig
@@ -1178,12 +1178,6 @@ test "a terminal's rolled level keeps its tag rows at every width, C-w's as SPC'
p.sync();
const rows, const tag_rows = .{ pane.rows, pane.tag_rows };
p.update(.{ .key = root });
- // Its key cell alone, before the level shows: shorter than the
- // tag's own text, the rows it had.
- p.sync();
- try std.testing.expect(hostOf(p) == shell);
- try std.testing.expectEqual(tag_rows, pane.tag_rows);
- try std.testing.expectEqual(rows, pane.rows);
p.advance(p.clock.now_ns);
p.clock.now_ns = p.view().tag_state.due_ns;
p.sync();
@@ -1193,6 +1187,42 @@ test "a terminal's rolled level keeps its tag rows at every width, C-w's as SPC'
};
}
+test "a band over a terminal is drawn over its body's top rows: its pty keeps its size across the band's open and close" {
+ if (pardes.Term.ops == null) return error.SkipZigTest; // a shell
+ const Key = pardes.Key;
+ const p = try Pardes.init(std.testing.allocator, .{ .file = "mise.toml", .cols = 100, .rows = 30 });
+ defer p.deinit();
+ _ = pardes.exec.spawnTty(p, 0);
+ const shell = p.view().active;
+ const pane = p.panes[shell].?;
+ pane.body.mode = .normal;
+ p.sync();
+ while (p.nextEffect()) |_| {}
+ const rows, const cols, const tag_rows = .{ pane.rows, pane.cols, pane.tag_rows };
+ var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer frame.deinit();
+ // SPC unrolled, then `:`'s rows (the tagnav case): a band each, over
+ // the body; no resize of the pty while it is open, nor when it goes.
+ for ([_][]const Key{ &.{ .{ .cp = ' ' }, .{ .cp = Key.down } }, &.{.{ .cp = ':' }} }) |keys| {
+ for (keys) |k| p.update(.{ .key = k });
+ p.sync();
+ try std.testing.expect(hostOf(p) == shell);
+ try std.testing.expectEqual(@as(u16, 0), pane.band_rows);
+ try std.testing.expectEqual(tag_rows, pane.tag_rows);
+ try std.testing.expectEqual(rows, pane.rows);
+ try std.testing.expectEqual(cols, pane.cols);
+ _ = frame.reset(.retain_capacity);
+ _ = try p.render(frame.allocator());
+ const layer = &p.surface.tag_layers[pardes.BAND_LAYER];
+ try std.testing.expect(layer.kind == .band and layer.rows > 0);
+ try std.testing.expectEqual(p.bodyTop(pane, p.view().rects[shell]), layer.viewport.y);
+ p.update(.{ .key = .{ .cp = Key.escape } });
+ p.sync();
+ try std.testing.expectEqual(rows, pane.rows);
+ while (p.nextEffect()) |e| try std.testing.expect(e != .resize_pty);
+ }
+}
+
test "a tag out of rest keeps its rows at rest at least: a level shorter than its own text moves no body up" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 40, .rows = 30 });
defer p.deinit();
diff --git a/core/draw.zig b/core/draw.zig
index 17ac7514..f69f83c6 100644
--- a/core/draw.zig
+++ b/core/draw.zig
@@ -357,6 +357,12 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface {
s.body_layers[id].rows = 0;
try renderPane(p, s, arena, pane, v.rects[id], id, id == v.active);
}
+ // A band over a terminal's or a kind's body (Band.over), drawn after
+ // the body it covers.
+ if (TagState.hostOf(p)) |id| if (p.panes[id]) |pane| if (pane.band_rows == 0) {
+ const rows = pardes.Band.shownRows(p, pane, id);
+ if (rows > 0) try joinBand(p, s, arena, pane, v.rects[id], id, id == v.active, rows);
+ };
// Each notice once, as a tag layer, and the grid's chip a copy of it.
for (s.regionList()) |region| {
if (region.kind == .notice) try joinNotice(p, s, arena, region);
@@ -495,7 +501,7 @@ fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r:
try joinPaneTag(p, s, arena, pane, r, id, active);
// The keyboard is in the head's field: its caret, not the body's.
const head_caret = if (typing) s.cursor else null;
- if (pane.band_rows > 0) try joinBand(p, s, arena, pane, r, id, active);
+ if (pane.band_rows > 0) try joinBand(p, s, arena, pane, r, id, active, pane.band_rows);
// Folded panes retain their body state, but neither body pixels nor
// its cursor belong outside the one-row tag rectangle.
@@ -868,14 +874,13 @@ fn joinPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r
/// layer at the tagline's pitch, a row to a line, and copied into the
/// grid: the spines and steps in the tag's tint, the keys in the key ink,
/// the cursor's row tinted as a selection.
-fn joinBand(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize, active: bool) !void {
+fn joinBand(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize, active: bool, rows: u16) !void {
const layer = &s.tag_layers[pardes.BAND_LAYER];
if (r.w <= TAG_TEXT_INSET) return;
const band = (try pardes.Band.of(p, arena, pane, id)) orelse return;
const th = p.theme();
const chrome = p.chromeTheme();
const tab = p.settings.tab;
- const rows = pane.band_rows;
const columns = @max(band.columns, 1);
const bg = tagGround(p, pane, active);
const fg = if (active) chrome.tag_active_fg else chrome.tag_fg;
@@ -921,7 +926,9 @@ fn joinBand(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: R
const count = @as(usize, columns) * rows;
if (layer.cells.len != count) layer.cells = try p.gpa.realloc(layer.cells, count);
@memcpy(layer.cells, storage);
- const y0 = p.tagTop(pane, r) + (pane.tag_rows - rows);
+ // Under the tag's text rows; a terminal's or a kind's over its body's
+ // top rows (Band.over).
+ const y0 = p.tagTop(pane, r) + (pane.tag_rows - pane.band_rows);
layer.kind = .band;
layer.id = @intCast(id);
layer.serial = pane.serial;
diff --git a/core/layout.zig b/core/layout.zig
index 0a773cab..de12294b 100644
--- a/core/layout.zig
+++ b/core/layout.zig
@@ -1476,7 +1476,7 @@ pub fn compute(p: *Pardes) void {
/// (walk UI SPEC §3.6).
fn floorRows(p: *Pardes, id: usize) u16 {
const pane = p.panes[id] orelse return 0;
- const band = pardes.Band.takes(p, id);
+ const band = if (pardes.Band.over(pane)) 0 else pardes.Band.takes(p, id);
if (band > 0) return @max(1, pane.tag_rows -| pane.band_rows) + band + 4;
return if (pane.isTerminal()) @max(1, pane.tag_rows) + min_body_rows else 1;
}
diff --git a/core/mouse.zig b/core/mouse.zig
index 89a8c5c6..6516ea71 100644
--- a/core/mouse.zig
+++ b/core/mouse.zig
@@ -914,10 +914,11 @@ fn bandPoint(p: *Pardes, mcol: u16, mrow: u16) ?BandPoint {
if (v.pointer_tag_hit) |hit| return if (hit.kind == .band) .{ .id = hit.id, .line = hit.line, .col = hit.col } else null;
const id = paneAt(p, mcol, mrow) orelse return null;
const pane = p.panes[id].?;
- if (pane.band_rows == 0) return null;
+ const rows = pardes.Band.shownRows(p, pane, id);
+ if (rows == 0) return null;
const r = v.rects[id];
const top = p.tagTop(pane, r) + (pane.tag_rows - pane.band_rows);
- if (mrow < top or mrow >= top + pane.band_rows or mcol < r.x + TAG_TEXT_INSET) return null;
+ if (mrow < top or mrow >= top + rows or mcol < r.x + TAG_TEXT_INSET) return null;
return .{ .id = id, .line = mrow - top, .col = mcol - (r.x + TAG_TEXT_INSET) };
}
diff --git a/test/snapshots/tagnav.golden b/test/snapshots/tagnav.golden
index 9bf061bc..1039c40a 100644
--- a/test/snapshots/tagnav.golden
+++ b/test/snapshots/tagnav.golden
@@ -42,12 +42,14 @@
== snap tty-on grid=100x31 cursor=54,6
|2: /tmp/pardes-snap/tagnav/cwd/w.txt Save Term Coll$ /tmp/pardes-snap/tagnav/cwd Term+bash Save Mode
|4: 1 alpha $ ls
+|6: 3 gamma $
|30: ✓ /tmp/pardes-snap/tagnav/cwd/w.txt Window 5 messages · SPC h m
== snap tty-tag grid=100x31 cursor=95,2
== snap tty-restored grid=100x31 cursor=54,6
== snap column-tag grid=100x31 cursor=2,1
|2: /tmp/pardes-snap/tagnav/cwd/w.txt Save Term Coll /tmp/pardes-snap/tagnav/cwd Term+bash Save Mode
|4: 1 alpha ls
+|6: 3 gamma
|30: ✓ /tmp/pardes-snap/tagnav/cwd/w.txt Up 8 messages · SPC h m
== snap column-word grid=100x31 cursor=5,1
== snap workspace-tag grid=100x31 cursor=2,0
diff --git a/test/snapshots/ttytaken.golden b/test/snapshots/ttytaken.golden
index a2011891..337072f1 100644
--- a/test/snapshots/ttytaken.golden
+++ b/test/snapshots/ttytaken.golden
@@ -32,7 +32,7 @@
| /tmp/pardes-snap/ttytaken/cwd
== snap at-prompt grid=210x31 cursor=4,5
|2: /tmp/pardes-snap/ttytaken/cwd Term+bash Save Mode Filter Collapse Del @`echo TAKEN''ONE`
-|5: echo TAKEN''ONE
+|5: echo TAKEN''ONE
|6: TAKENONE
|30: ✓ @p1 Exec 1 message · SPC h m
== snap paging grid=210x31 cursor=9,29