summaryrefslogtreecommitdiff
path: root/core/Band.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-26 09:40:17 -0300
committerGabriel Schneider <[email protected]>2026-11-26 10:28:44 -0300
commit8d90edcec1ba432d0f67ecc3a79eb6bf193369ff (patch)
tree2adbc108fb6d5076f9dba35afe850d14644ff801 /core/Band.zig
parent8959b031dc330b4da21c0e89e0831d6fadbcd757 (diff)
downloadpardes-8d90edcec1ba432d0f67ecc3a79eb6bf193369ff.tar.gz
pardes-8d90edcec1ba432d0f67ecc3a79eb6bf193369ff.zip
TagState, tagline, Band, draw, layout, mouse, Pick, Trail, Core: out of rest a pane's tag stays exactly as at rest and what the keyboard drives hangs under it, the head on the row under the tag's rows, then the band (UX DESIGN M, binding; the user, looking at a picker started in an empty pane whose tag had become `^ ␣ f Find ascii 1/1`: "doesn't it make sense to the search just show below the tagline instead of being search tagline then results?", then "Keep consistent, idk, yes"): for every state the keyboard drives (rolled and unrolled levels, `"`, Help, describe-key, every picker, every text prompt, `:`, rename, code actions) the tag keeps its mark, owner, trail, path, Keep, computed words and own text, its rows and its wrapping, the box alone saying `^` while typing; THE WAY IT WAS: the head (TagState.head) was the tag's text after a cut-down prefix (D1's owner and newest step, tagline.pathPrefix's out-of-rest branch, Trail's `.newest` part), so the path, Keep and the user's text left the screen while you typed, the key cells sat on the tag's row for a level and jumped with it, and a picker's preview in a reading pane would have named the previewed file had the path stayed; THE CHANGE: TagState.head is the head alone, laid out from the tag's text column on rows of its own (Builder's `lead` gone), and TagState.asking the question a tag says, which stays in the tag (UX D13, M1: questions unchanged); tagline.shownTail is the question or the own text in every state, pathPrefix the path in every state (the out-of-rest branch and Trail's `.newest` part, `newest_cells` and the `cut` buffers deleted); a pane a picker previews in names its own file, the one Pick.showText set aside (tagline.named, tagWords, and Trail.reading asking the same file, so its tint, Keep and words are the rest ones); a pane made for the picker (it has no rest) shows its owner's word alone, `‹@pN ›` (M3; P1's reading 2 reversed); Band.covered is the tag's rows at rest, then the head's rows, then the band's, `over` = head + band (no rows the head reused: M4), layout.headRows the head's own rows and floorRows the tag's rows plus the head's and the band's (a head that does not fit borrows from its column as a band does); draw.zig joinBand paints the head's rows as the band layer's first rows (its spans' inks moved there from paintPaneTag, its caret the band layer's cursor), the band's under them, the spines from the head's key cells on its own row; render draws the host's tag with its rest rows; mouse: a press on a tag out of rest ends its state as Esc does and then does what it does at rest (M3; a pane made for a picker goes with it and the press with it), bandPoint reads the head's rows as the band layer's first, and B1 in the head's field puts the field's caret there; edit.zig refuses an edit of a tag only while it asks; RUN (TEST FIRST): five new tests, each failing on the base (M2, 8959b031dc33) and passing now: TagState "out of rest a tag is drawn as at rest, the head hanging under it ..." (a `.list` picker in a reading pane that walked near.txt -> far.txt: the tag's rows cell for cell as at rest but the box, its path far.txt while the body previews near.txt, the head `␣ l Refs ... 1/1` on the next row, its count the row's last cells, the band under it; Esc, the rows as before: failed on the base at the tag text, `near.txt:2 › ␣ l Refs ...`), TagState "the key cells are one thing growing on the row under the tag ..." (`␣`, `␣ f`, `␣ f Find` in the same cells of the row under a two-row tag: failed on the base, `␣` on the tag's row), TagState "a click that gives the keyboard to another pane ends a level ...; one in the level's own tag ends it too, then does what it does there at rest ..." (was "... one in the level's own tag keeps it"; B1 on the tag's own word ends SPC's level and gives the tag the keyboard, B2 on `Wrap` ends Help and toggles wrap: failed on the base, the level kept), Pick "a pane made for a picker has no rest: its tag is its owner's word alone, `‹@pN ›` ..." (B3 on it: the picker ends, the made pane goes, nothing under the press looked at: failed on the base, its tag `␣ f Find ...`), Command ": hangs its field under the tag, which stays as at rest; `:` on the empty field gives the keyboard to that tag's own text right above it ..." (failed on the base, the tag text `: ...`); the expectations that read the head through the tag's text read it from TagState.head now (TagState's testTag, Prompt's and Command's headOf, Pick's headOf; bindings, Messages, lsp/Ask, Trail, Band, draw, views: ~40), and the ones that read a body's first row while a prompt is up read the rows under the head's (Prompt's `/`, `s`, `|` tests, body_layer's current-place test, Ask's rename); views' short-column picker test runs at 15 rows (the head's row is one more covered row: at 12 the band had none left); the process test msg waits for the second reload by the notice row's `×2` (the pane's one line is under the `s` prompt's head now); AND A FAULT THIS MADE VISIBLE: code actions drew their edit's ghost lines from the body's top under a band drawn over it (Pick.previewing was a place's preview alone), so an edit on the first rows of a file was under the band; with the head's row one more covered row, test/behaviour/language_servers.zig's "SPC l a lists the server's code actions ..." failed (`let x = sum(1, 2);` at line 4 under the head and a 4-row band, not on the screen); THE FIX: code actions' body is their preview from the first (UX DESIGN I1: "a picker and code actions (whose body is the preview) keep D6"): Pick.previewing is true for them, so the body starts under the head and the band as a picker's preview does; the behaviour test passes now; GATES (Debug tui, this change): core-test 1166/1340 (174 skipped; M2's gate 1155/1329), shell-test 1381/1384 (3 skipped), behaviour-test 287/287 and --replay 287/287, pane-test 184/185 (1 skipped), term-test 17/17, kitty-test 45/45 (these three before the code-actions fix and two renames), process-test 8 of 149 failed (3 skipped): exactly the goldens with a frame out of rest (find, fsearch, leader, lsp, msg, pipe, selregex, ttyhelp), re-recorded and explained by the next change; the dump does not change (no pane or view field); no frame or perf gate (the user's rule of 2026-11-26); load 4.2 to 14.3
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/Band.zig')
-rw-r--r--core/Band.zig95
1 files changed, 49 insertions, 46 deletions
diff --git a/core/Band.zig b/core/Band.zig
index d60e9831..6e8f9589 100644
--- a/core/Band.zig
+++ b/core/Band.zig
@@ -1,10 +1,11 @@
//! The band (walk UI, pick-ui SPEC.md §3.6): rows hanging under a pane's
-//! tag while it is out of rest, in the tag's tint, drawn over the top rows
-//! of its body, which stay where they were (UX DESIGN I1): the tag
-//! unrolled. Its steps stand side by side, each a column of rows
-//! (a level, Help's rows, a doc; later a picker's acts and sources, a
-//! prompt's history, the registers), a one-cell rule between them, right
-//! of a spine under each of the head's key cells.
+//! head (TagState.head, the row under its tag) while it is out of rest, in
+//! the tag's tint, drawn over the top rows of its body, which stay where
+//! they were (UX DESIGN I1, M2): the tag unrolled. Its steps stand side by
+//! side, each a column of rows (a level, Help's rows, a doc; later a
+//! picker's acts and sources, a prompt's history, the registers), a
+//! one-cell rule between them, right of a spine under each of the head's
+//! key cells.
//!
//! Derived from the live view's state each time it is asked (`of`), never
//! stored (the coordinator's R2): the layout reads its height (`takes`,
@@ -136,24 +137,25 @@ pub fn takes(p: *Pardes, id: usize) u16 {
return @max(doc_rows, levelRows(n));
}
-/// Where pane `id`'s tag out of rest is drawn, in rows from its top (UX
-/// DESIGN I1): its head's text (`text`, the rows its own text keeps from
-/// rest at least where no band hangs under it) and the band under that
-/// (`band`), as many as the pane has; `over` of them past the tag's own
-/// rows (`tag_rows`, its rows at rest), drawn over the top rows of its
-/// body, which never move for them. A picker's band keeps a body of
-/// `body_rows` under it (UX D6), any other state only the pane's rows.
-/// Asked of the state alone, as `takes` is: the layout, the frame and a
-/// click ask it of the same step.
-pub const Covered = struct { text: u16, band: u16, over: u16 };
+/// Where pane `id`'s head and band hang out of rest, in rows from its top
+/// (UX DESIGN I1, M2): under its tag's rows (`tag`, its rows at rest, which
+/// no state changes), its head's (`head`), then the band's (`band`), as
+/// many as the pane has under its tag; `over` the two, drawn over the top
+/// rows of its body, which never move for them. A picker's band keeps a
+/// body of `body_rows` under it (UX D6), any other state only the pane's
+/// rows. Asked of the state alone, as `takes` is: the layout, the frame and
+/// a click ask it of the same step.
+pub const Covered = struct { tag: u16, head: u16, band: u16, over: u16 };
pub fn covered(p: *Pardes, pane: *const Pane, id: usize) Covered {
- if (pane.collapsed or TagState.hostOf(p) != id) return .{ .text = pane.tag_rows, .band = 0, .over = 0 };
+ if (pane.collapsed or TagState.hostOf(p) != id) return .{ .tag = pane.tag_rows, .head = 0, .band = 0, .over = 0 };
const h = p.view().rects[id].h;
- const text = @min(layout.headRows(p, id), h);
+ // As Pardes.sync sets `tag_rows` (a picker's preview adds the rows
+ // over it to them).
+ const tag = @min(layout.wantedTagRows(p, id), pardes.MAX_TAG_ROWS, @max(pardes.BOX_H, h -| 1));
+ const head = @min(layout.headRows(p, id), h -| tag);
const keep: u16 = if (p.view().tag_state.kind == .pick) body_rows else 0;
- const band = @min(takes(p, id), h -| text -| keep);
- const shown = if (band > 0) text else @min(@max(text, pane.tag_rows), pardes.MAX_TAG_ROWS);
- return .{ .text = shown, .band = band, .over = (shown + band) -| pane.tag_rows };
+ const band = @min(takes(p, id), h -| tag -| head -| keep);
+ return .{ .tag = tag, .head = head, .band = band, .over = head + band };
}
fn levelRows(n: u16) u16 {
@@ -494,14 +496,12 @@ fn place(band: *Band, p: *Pardes, arena: std.mem.Allocator, pane: *Pane, id: usi
}
/// The display columns of the head's key cells: a spine hangs under each,
-/// through the tag's rows under them and the band's (UX D5).
+/// through the head's rows under them and the band's (UX D5).
fn findSpines(band: *Band, p: *Pardes, arena: std.mem.Allocator, pane: *Pane, id: usize) !void {
const h = (try TagState.head(p, arena, pane)) orelse return;
- const whole = try tagline.tagText(p, arena, pane);
- const shown = try tagline.wrapTag(p.settings.tab, arena, whole, tagline.tagWidth(p, id));
- const lead = whole.len - h.text.len;
+ const shown = try tagline.wrapTag(p.settings.tab, arena, h.text, tagline.tagWidth(p, id));
for (h.spans[0..h.cells]) |span| {
- const at = modal.positionAt(shown.text, shown.fromReal(lead + span.lo));
+ const at = modal.positionAt(shown.text, shown.fromReal(span.lo));
if (band.nspines == max_spines) return;
band.spines[band.nspines] = @intCast(File.rawDisplayCol(p.settings.tab, modal.lineSlice(shown.text, at.row), at.col));
band.nspines += 1;
@@ -680,7 +680,7 @@ fn layerRow(arena: std.mem.Allocator, layer: *const pardes.Layer, row: usize) ![
return out.items;
}
-test "a narrow band gives way and keeps its spines: the doc goes, the steps start two cells right of the last spine, no row past the band's edge; the band starts on the row under the head, in the rows the tag keeps from rest" {
+test "a narrow band gives way and keeps its spines: the doc goes, the steps start two cells right of the last spine, no row past the band's edge; the band starts on the row under the head, which hangs under the tag's rows at rest (UX DESIGN M2)" {
const Key = pardes.Key;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 44, .rows = 30 });
defer p.deinit();
@@ -702,23 +702,24 @@ test "a narrow band gives way and keeps its spines: the doc goes, the steps star
try std.testing.expectEqual(@as(u8, 1), band.nsteps);
try std.testing.expectEqual(band.spines[1] + 2, band.steps[0].x);
for (0..band.height) |y| try std.testing.expect(File.displayWidth(p.settings.tab, (try band.line(a, p.settings.tab, @intCast(y))).text) <= band.columns);
- // The band on the row under the head's one, in the row the tag keeps
- // from rest (UX E3): never a blank row between the head and its rows,
- // the body under whichever is lower.
+ // The head on the row under the tag's rows, the band on the row under
+ // it: never a blank row between them, the body under them.
const s = try p.render(a);
const r = p.view().rects[id];
const tag_y = p.tagTop(pane, r);
const at = covered(p, pane, id);
- try std.testing.expectEqual(@as(u16, 1), at.text);
+ try std.testing.expectEqual(@as(u16, 1), at.head);
+ try std.testing.expectEqual(rest, at.tag);
try std.testing.expectEqual(rest, pane.tag_rows);
- try std.testing.expectEqual((1 + band.height) -| rest, at.over);
- try std.testing.expectEqual(tag_y + 1, bandLayer(p, id).?.viewport.y);
- for (band.spines[0..band.nspines]) |col| try std.testing.expectEqualStrings("│", s.at(r.x + pardes.TAG_TEXT_INSET + col, tag_y + 1).grapheme());
- try std.testing.expect(std.mem.indexOf(u8, try layerRow(a, bandLayer(p, id).?, 0), "▶") != null);
+ try std.testing.expectEqual(1 + band.height, at.over);
+ try std.testing.expectEqual(tag_y + rest, bandLayer(p, id).?.viewport.y);
+ for (band.spines[0..band.nspines]) |col| try std.testing.expectEqualStrings("│", s.at(r.x + pardes.TAG_TEXT_INSET + col, tag_y + rest + 1).grapheme());
+ try std.testing.expect(std.mem.startsWith(u8, try layerRow(a, bandLayer(p, id).?, 0), "Help ␣ l "));
+ try std.testing.expect(std.mem.indexOf(u8, try layerRow(a, bandLayer(p, id).?, 1), "▶") != null);
p.update(.{ .key = .{ .cp = Key.escape } });
}
-test "out of rest with no band, the rows a tag keeps from rest stay blank: a spine hangs only where a band row is" {
+test "out of rest with no band, the tag's rows are its rows at rest: no spine hangs in them (UX DESIGN M1)" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 44, .rows = 30 });
defer p.deinit();
const pane = try p.setTestFile("one\n");
@@ -874,25 +875,27 @@ test "SPC Down unrolls the level into a band under the tag's text, drawn over th
_ = frame.reset(.retain_capacity);
const s = try p.render(frame.allocator());
const layer = bandLayer(p, id).?;
- try std.testing.expectEqual(p.tagTop(pane, r) + at.text, layer.viewport.y);
- try std.testing.expectEqual(at.band, layer.viewport.h);
+ try std.testing.expectEqual(p.tagTop(pane, r) + at.tag, layer.viewport.y);
+ try std.testing.expectEqual(at.over, layer.viewport.h);
// The body region starts where it did at rest: the band is over it.
const body = s.region(.body, id).?;
try std.testing.expectEqual(body_top, body.rect.y);
try std.testing.expect(layer.viewport.y + layer.viewport.h > body.rect.y);
- const first = try layerRow(frame.allocator(), layer, 0);
+ const first = try layerRow(frame.allocator(), layer, at.head);
try std.testing.expect(std.mem.indexOf(u8, first, "│") != null);
try std.testing.expect(std.mem.indexOf(u8, first, "▶ b buffer…") != null);
// The grid has the same rows, where the layer is, the body's under
// them drawn first: its last covered row is the band's.
var grid: std.ArrayList(u8) = .empty;
- for (s.cells[@as(usize, layer.viewport.y) * s.cols ..][layer.viewport.x..][0..layer.viewport.w]) |cell| try grid.appendSlice(frame.allocator(), cell.grapheme());
+ for (s.cells[@as(usize, layer.viewport.y + at.head) * s.cols ..][layer.viewport.x..][0..layer.viewport.w]) |cell| try grid.appendSlice(frame.allocator(), cell.grapheme());
try std.testing.expect(std.mem.indexOf(u8, grid.items, "▶ b buffer…") != null);
const spine = (try of(p, frame.allocator(), pane, id)).?.spines[0];
try std.testing.expectEqualStrings("│", s.at(r.x + pardes.TAG_TEXT_INSET + spine, layer.viewport.y + layer.viewport.h - 1).grapheme());
- // The head names the level and says how to roll it up.
- const head = try tagline.tagText(p, frame.allocator(), pane);
+ // The head, the layer's first row, names the level and says how to roll
+ // it up.
+ const head = (try TagState.head(p, frame.allocator(), pane)).?.text;
try std.testing.expect(std.mem.startsWith(u8, head, "␣ SPC ") and std.mem.endsWith(u8, head, " ↑ roll up · ? field · esc"));
+ try std.testing.expect(std.mem.startsWith(u8, try layerRow(frame.allocator(), layer, 0), "␣ SPC "));
// Down moves the cursor; Up back to the first row, then rolls up.
p.update(.{ .key = .{ .cp = Key.down } });
try std.testing.expectEqual(@as(u8, 'c'), p.view().tag_state.hi);
@@ -931,7 +934,7 @@ test "a level's band covers what it needs: its pane keeps its rows where its hea
p.update(.{ .key = .{ .cp = Key.down } });
const pane = p.panes[low].?;
const at = covered(p, pane, low);
- const need = at.text + at.band;
+ const need = at.tag + at.over;
try std.testing.expect(at.band == takes(p, low) and need <= before[low].h);
try std.testing.expectEqualDeep(before, p.view().rects);
p.update(.{ .key = .{ .cp = Key.escape } });
@@ -1215,7 +1218,7 @@ test "a covered row belongs to the band: a click on a band row over the body mov
const band = (try of(p, frame.allocator(), pane, id)).?;
// The band's last row, over the body: its first step's row there.
const row: u16 = at.band - 1;
- const y = p.tagTop(pane, r) + at.text + row;
+ const y = p.tagTop(pane, r) + at.tag + at.head + row;
try std.testing.expect(y >= body_top);
const ln = try band.line(frame.allocator(), p.settings.tab, row);
const part = ln.parts[0];
@@ -1238,8 +1241,8 @@ test "a covered row belongs to the band: a click on a band row over the body mov
p.clock.now_ns = p.view().tag_state.due_ns;
p.sync();
const rolled = covered(p, pane, id);
- try std.testing.expect(rolled.band == 0 and rolled.text > pane.tag_rows);
- const hy = p.tagTop(pane, r) + rolled.text - 1;
+ try std.testing.expect(rolled.band == 0 and rolled.head > 1);
+ const hy = p.tagTop(pane, r) + rolled.tag + rolled.head - 1;
try std.testing.expect(hy >= body_top);
const hx = r.x + pardes.TAG_TEXT_INSET + 6;
p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = hx, .row = hy } });