summaryrefslogtreecommitdiff
path: root/core/draw.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-25 21:19:37 -0300
committerGabriel Schneider <[email protected]>2026-11-25 21:57:19 -0300
commit8e1526a71a74447cbba9f5487ef72d9feccfc0ed (patch)
treeca10fd5a4f2d2cffbb3a78299b4d6434395b56bf /core/draw.zig
parent1e8787e0b2eb3eaa4991a5160f6e5c35ba6f132e (diff)
downloadpardes-8e1526a71a74447cbba9f5487ef72d9feccfc0ed.tar.gz
pardes-8e1526a71a74447cbba9f5487ef72d9feccfc0ed.zip
Band, sync, draw, layout, mouse, File: the text stays put under the band: out of rest a tag keeps exactly its rows at rest, and its head's rows past them and the band under it are drawn over the top rows of its body, which never moves, wraps or resizes for them (UX DESIGN I1, on the user's "the other editors when there's new ui on top of the text it doesn't scroll ... I think we should do that, no?"); THE OLD WAY: the band pushed the body down (Pardes.sync grew `tag_rows` by `band_rows` and the head's rows), so every row of the text jumped by the band's height on SPC Down, Help, `:`, the registers, a rolled level of three rows, and back on Esc, while a terminal's and a kind's band was a second path drawn over its body (Band.over, Band.shownRows); THE CHANGE: Band.covered (from the state alone, as takes is) says where a tag out of rest is drawn: its head's rows, the band under them (as many as the pane has; a picker's keeping D6's body under it), and `over`, those past the tag's own rows; sync keeps the tag's rows at rest (the terminal special case is every pane's now) and puts `over` in the pane's view (SessionView.covered) for File.show; draw.render draws the host's tag and band after every body, one path for every pane, the grip's column beside the covered rows on the tag's ground, a caret under them hidden until rest; layout.floorRows borrows for a level, Help, `:` or the registers only the rows its head and band need (a picker and code actions keep D6's 60 % / 6 rows; a terminal's and a kind's size stay their user's); mouse.bandPoint gives a covered row to the band (a head's row over the body: B2/B3 on its word as on the tag's first row, B1 nothing); File.show counts the covered rows like the context rows, so what a state shows (a prompt's current hit, C-r's) is put in the rows left visible, a target already there not moved; TagState's rolled level of a terminal takes its three rows too (over the pty, which keeps its size); `band_rows` goes from Pane and PaneView (the dump: SessionView.covered and Pick.previewed come); W1'S READING (I1 is silent on a landing near a file's top): a picker's preview starts under its band (Pick.previewing: from the first place it shows in its landing pane, the band takes its rows from that body, as before), since Find lands on line 1 and a band over the body's top hid the file's first eleven lines and the landing line; before its first row, and after Esc, the pane's own text is where it was; the GUI's tag rule goes under the head's rows as under the band's (gui.zig paneDecor); TESTS (FIRST, where the old behaviour was asserted, inverted): Band.zig "SPC Down unrolls ... drawn over the top rows of the body, which stays where it was" (was "the body pushed down and never drawn over"), "out of rest the body stays where it was ..." (a rolled level, SPC Down, Help, `:`, the registers and a picker before it previews: every row of text under the rows drawn over it on its screen row at rest, the same first row, size and scroll; Esc leaves the body's rows as at rest), "a level's band covers what it needs ..." (no borrow where head and band fit, exactly head + band where they do not), "a covered row belongs to the band ..." (B1 on a band row over the body moves the level's cursor, on a head's row over it touches no body); Pick.zig "a picker's preview starts under its band ..." (in a reading pane: its text stays before the first row; line 60 at ⌈visible/3⌉ under the band, line 1 on the row right under it; Esc: its own text where it was); Prompt.zig "a search's current hit under C-r's band is put in the rows the band leaves the body ..."; the tests that read `band_rows` read Band.covered; body_layer's D10 test: `g`'s first-line target is under the rolled level's rows now (I2's named cost); GOLDENS re-recorded, every moved row: leader (spc, unmapped: the one line of cmds.txt stays on row 3 under the level's second row instead of row 5, the caret on it hidden), find (nomatch, topbar: a picker with nothing to preview leaves here.txt's line 1 on row 3 under the band instead of row 8; cancel: row 8 no longer listed as changed), ttyhelp (leaderworks: Help's band over the +Help pane's text, whose rows 10-20 keep the previous snap's text instead of moving down seven rows); a user saw the text jump on every SPC Down, Help, `:` with rows, registers Down and a rolled level wider than its tag; core-test 1115/1287 (172 skipped: +3), shell-test 1335/1338 (3 skipped: +3), pane-test 183/184, behaviour-test 280/280 and --replay 20 seeds 0 failures, process-test 0 of 147 failed (3 skipped; 3 goldens re-recorded), term-test 17/17, kitty-test 45/45; the dump fuzz at 40,000 join seeds and 40,000 + 1,779 image seeds 11/11; the soak `replicas -- --clients 5 --rtt 30,80,207`: diverged 0, unequal 0, quiet checks 580/0 480/0 675/0, unlisted stops 0, the corpus 22 of 22 scenes the same, no leak; load 1.2 to 10.9
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/draw.zig')
-rw-r--r--core/draw.zig72
1 files changed, 43 insertions, 29 deletions
diff --git a/core/draw.zig b/core/draw.zig
index 8f690e8e..2553d5be 100644
--- a/core/draw.zig
+++ b/core/draw.zig
@@ -362,11 +362,26 @@ 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);
+ // A tag out of rest after every body (UX DESIGN I1): its head and its
+ // band past its own rows are drawn over the top rows of its body,
+ // which stay where they were; beside them the grip's column on the
+ // tag's ground, and a caret under them hidden until rest.
+ if (TagState.hostOf(p)) |id| if (p.panes[id]) |pane| if (v.rects[id].w > config.GUTTER and v.rects[id].h > 0) {
+ const r = v.rects[id];
+ const at = pardes.Band.covered(p, pane, id);
+ const y = p.tagTop(pane, r) + pane.tag_rows;
+ const rows = @min(at.over, r.h -| pane.tag_rows);
+ if (rows > 0) {
+ s.fill(r.x, y, config.GUTTER, rows, .{ .bg = .{ .rgb = tagGround(p, pane, id == v.active) }, .font_role = .tagline });
+ if (s.cursor) |c| if (c.x >= r.x and c.x < r.x + r.w and c.y >= y and c.y < y + rows) {
+ s.cursor = null;
+ };
+ if (s.body_layers[id].cursor) |c| if (pane.file != null and c.y < panes.File.coveredRows(pane)) {
+ s.body_layers[id].cursor = null;
+ };
+ }
+ try joinPaneTag(p, s, arena, pane, r, id, id == v.active, at.text);
+ if (at.band > 0) try joinBand(p, s, arena, pane, r, id, id == v.active, at);
};
// Each notice once, as a tag layer, and the grid's chip a copy of it.
for (s.regionList()) |region| {
@@ -503,10 +518,8 @@ fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r:
.tty => config.tag_tty,
}, box_style);
- 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, pane.band_rows);
+ // Out of rest its tag is drawn after the bodies, over its own (render).
+ if (!pardes.Trail.outOfRest(p, pane)) try joinPaneTag(p, s, arena, pane, r, id, active, @min(pane.tag_rows, MAX_TAG_ROWS));
// Folded panes retain their body state, but neither body pixels nor
// its cursor belong outside the one-row tag rectangle.
@@ -541,9 +554,11 @@ fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r:
}
try body_layer.joinBody(p, s, arena, pane, r, id, active, rail.*);
+ // The keyboard is in the head's field: its caret (render), not the
+ // body's.
if (typing) {
s.body_layers[id].cursor = null;
- s.cursor = head_caret;
+ s.cursor = null;
}
if (pane.layers.heat > 0) @import("jj.zig").railHeat(p, s, pane, id, rail.rect);
// A terminal panned to its cursor in a view shorter than it: an arrow
@@ -830,19 +845,18 @@ fn renderHeaderLayer(p: *Pardes, layer: *pardes.Layer, kind: TagKind, id: u16, v
}
}
-/// A pane's tag rows, painted once into their layer, a row to a line, and
-/// copied into the grid; the grid's caret where the layer has it.
-fn joinPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize, active: bool) !void {
+/// A pane's tag's `rows` text rows (MAX_TAG_ROWS at most; out of rest its
+/// head's, Band.covered, past its own rows over its body), painted once
+/// into their layer, a row to a line, and copied into the grid; the grid's
+/// caret where the layer has it.
+fn joinPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize, active: bool, rows: u16) !void {
const v = p.view();
const capacity = layout.tagCapacity(p, r.w -| TAG_TEXT_INSET);
// Too narrow for a layer: only the grid's gap cell.
- if (r.w <= TAG_TEXT_INSET) return paintPaneTag(p, s, arena, pane, r, id, active);
+ if (r.w <= TAG_TEXT_INSET) return paintPaneTag(p, s, arena, pane, r, id, active, rows);
const chrome = p.chromeTheme();
const region = s.region(.tag, id).?;
const tag = (try tagline.shownTag(p, arena, pane)).text;
- // The tag's text rows; the band's under them are its own layer. A
- // tag's own are MAX_TAG_ROWS at most (Pardes.sync).
- const rows = @min(pane.tag_rows -| pane.band_rows, MAX_TAG_ROWS);
// As wide as the widest row it shows, and never narrower than its
// viewport.
var widest: usize = 0;
@@ -854,7 +868,7 @@ fn joinPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r
const storage = try arena.alloc(Cell, pitch * rows);
@memset(storage, .{});
var temporary: Surface = .{ .cols = columns + TAG_TEXT_INSET, .rows = rows, .cells = storage, .tab = p.settings.tab };
- try paintPaneTag(p, &temporary, arena, pane, .{ .x = 0, .y = 0, .w = columns + TAG_TEXT_INSET, .h = rows }, id, active);
+ try paintPaneTag(p, &temporary, arena, pane, .{ .x = 0, .y = 0, .w = columns + TAG_TEXT_INSET, .h = rows }, id, active, rows);
// Window mode (layout.windowKey): the outlined pane's tag in the
// selection's colours.
if (v.window_pick == id) {
@@ -889,12 +903,14 @@ fn joinPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r
}
}
-/// The band under pane `id`'s tag text (Band.zig), painted once into its
-/// 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, rows: u16) !void {
+/// The band under pane `id`'s tag text (Band.zig), its `drawn.band` rows
+/// under the head's `drawn.text`, painted once into its 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, drawn: pardes.Band.Covered) !void {
const layer = &s.tag_layers[pardes.BAND_LAYER];
+ const rows = drawn.band;
if (r.w <= TAG_TEXT_INSET) return;
const band = (try pardes.Band.of(p, arena, pane, id)) orelse return;
const chrome = p.chromeTheme();
@@ -973,9 +989,8 @@ 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);
- // 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);
+ // Under the head's rows, over the body's top ones (Band.covered).
+ const y0 = p.tagTop(pane, r) + drawn.text;
layer.kind = .band;
layer.id = @intCast(id);
layer.serial = pane.serial;
@@ -1023,13 +1038,12 @@ fn groundOf(p: *Pardes, pane: *const Pane, active: bool) colors.TagGround {
return if (active) .focused else .plain;
}
-fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize, active: bool) !void {
+fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize, active: bool, rows: u16) !void {
const th = p.theme();
const chrome = p.chromeTheme();
const tx = r.x + @min(TAG_TEXT_INSET, r.w);
const tw = r.w -| TAG_TEXT_INSET;
const tag_y = p.tagTop(pane, r);
- const rows = @min(pane.tag_rows -| pane.band_rows, MAX_TAG_ROWS);
const page_rgb = th.bg orelse th.tag_bg;
// Focus is visible along the tag without changing its live text grid.
const inks = chrome.roles.on(groundOf(p, pane, active));
@@ -1839,7 +1853,7 @@ test "a tag out of rest draws its keys bold in the key ink and its hint in the d
p.sync();
const s = try p.render(a);
const r = p.view().rects[p.view().active];
- const row = s.cells[@as(usize, r.y) * s.cols ..][0 .. @as(usize, s.cols) * (pane.tag_rows - pane.band_rows)];
+ const row = s.cells[@as(usize, r.y) * s.cols ..][0 .. @as(usize, s.cols) * pardes.Band.covered(p, pane, p.view().active).text];
const Row = struct {
fn find(cells: []const Cell, word: []const u8) ?usize {
var at: usize = 0;