summaryrefslogtreecommitdiff
path: root/core/draw.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-25 08:30:30 -0300
committerGabriel Schneider <[email protected]>2026-11-25 08:47:11 -0300
commit58d7434f56a9fef3098cfc191fbd1cb32ec09cfb (patch)
treec69ff77501f3fdc5b308632c38ba29de2d9c968b /core/draw.zig
parent59e1178acaabaa5ef16ed829b854542c21394d6f (diff)
parenteb8ecb8a451ae32d590c42755614b801f9cc0c09 (diff)
downloadpardes-58d7434f56a9fef3098cfc191fbd1cb32ec09cfb.tar.gz
pardes-58d7434f56a9fef3098cfc191fbd1cb32ec09cfb.zip
walk UI M6: the polish round's P1 (vuzlwsvx eb8ecb8a451a: the tag out of rest D1, no dim D9, the delays D12, the right block D3, wrapping D2, a band over a terminal or a kind's pane drawn over its body, the band's height D6, drawing the band D5 in part, the trail at rest D8 in part, asking D13 in part, a load's band rows made again and the tag's rows held to MAX_TAG_ROWS) merged onto M5 (zqwxonrs 59e1178acaab), both on G3's kytxrnnk, resolved by meaning: P1's `// P2:` markers go to P2's roles: the spines a head's rows hang (TagState.Builder.row) and the spines in the rows a tag keeps from rest (draw.zig paintPaneTag) in the rule ink, where P1 drew them in the box's, and the word n walks in the roles' key ink, underlined (draw.zig, D8), where P1 drew it in the box's; one mechanism for dim text: P1's hints go through Builder.right as dim spans, P2's painter draws every dim span in the dim ink of the tag's ground (never the faint attribute), so P2's own dim hint spans in TagState (run, a sequence, rename, roll up, unroll) are P1's lines, and the forward steps, the fold `+N` and an unlit search word are drawn in that dim ink (where P1 kept the line numbers' ink); the spines still hang from the key cells: Builder.keyCells puts them first in every head (TagState, Pick, Prompt's key cell), right() moves spans without reordering them and row() puts its rule spans after, so M5's span-order fix holds under the right block (D3) and the act row (D2); Pick.head is P1's builder with the actions picker's branch (P3) beside the themes picker's, its hint `⏎ or 1-9 apply it · esc` a dim right-block hint, and P2's `|` and other sources' words dim in P1's one-row act row (the acts in the text ink; `.actions` never offered as a source); Prompt.head is P1's right block with P2's D14: an invalid pattern's reason in the err ink and what is shown meanwhile dim stand in the count's place (D3: the count never drops, so the reason is never dropped as a hint would be) and no hints; TagState's rolled level is P1's row-breaking (D2) over P2's registers (D11): the level's children are the registers holding something before it lays them out, so `+N ↓` counts registers not shown, each child its shown value, `⏎` dim; Band.zig: a list step's width is P1's (52 cells at most) with P2's meta counted in it, a row is P1's cutRow with P2's meta after it, only when the whole text and the meta fit (D5: the meta gives way before the text is cut); draw.zig's band cursor row: P1's tint across the `▶ ` lead (D5) on P2's selection ground, the lead's ground only so `▶` keeps the key ink (D4); P2's D7 with P1's D6: the preview's landing line sits ⌈rows/3⌉ down the body the band leaves (fsearch's ctrln: line 6 at body row 3 of 8 under a 5-row band); TESTS (the merge's choices): TagState "a rolled level breaks between its children only ..." asks its spines in the rule role, Trail "... the word n walks is underlined" asks it in the key ink, Band "a band is drawn in the theme's roles ..." asks the cursor's `▶` in the key ink on the selection ground; P1's Trail fold test asks the fold in the dim ink of the reading ground (it asked the line numbers' ink); goldens: the five that conflicted (find, fsearch, lookrange, lsp, selregex) regenerated and every changed row read against P1's: P2's D7 `▸` on a picker's landing line and its sentence on the notice row (find, fsearch, lsp), the message coming back on the notice row when the picker closes (find promoted and cancel, fsearch landed, lsp), P3's `1 message` for the walked pane's one entry (find), P2's D14 (fsearch: the `▪` marks gone, the hits on the hit ground #5e4923, `▸` in the key ink #bada9d), the third-of-the-body placement (fsearch ctrln), P2's inks (the reading tint #2c2c0f, the key ink #bada9d for key cells and the n word, the dim ink #79836f for the plain word and the hints where the faint attribute was, the notice row's dim #6f7d75: fsearch, lookrange, selregex); no other golden moved; core-test 1083/1254 (171 skipped), process-test 0 of 147 failed (3 skipped, gui-only)
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.zig99
1 files changed, 68 insertions, 31 deletions
diff --git a/core/draw.zig b/core/draw.zig
index 16dfde5e..a459e3e9 100644
--- a/core/draw.zig
+++ b/core/draw.zig
@@ -362,23 +362,16 @@ 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);
}
- // A tag out of rest: the other panes dim a little so the eye goes to
- // it, but a pane showing a preview (walk UI SPEC §3.6).
- if (TagState.hostOf(p)) |host| for (p.panes, 0..) |slot, id| {
- if (slot == null or id == host or v.tag_state.previewing.isSet(id)) continue;
- const r = v.rects[id];
- for (r.y..r.y + r.h) |y| for (r.x..r.x + r.w) |x| {
- s.at(@intCast(x), @intCast(y)).style.dim = true;
- };
- for ([_]*pardes.Layer{ &s.body_layers[id], &s.tag_layers[id] }) |layer| for (layer.cells[0 .. @as(usize, layer.cols) * layer.rows]) |*cell| {
- cell.style.dim = true;
- };
- };
-
try paintHeaders(p, s);
try paintNoticeRow(p, s);
@@ -513,7 +506,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.
@@ -704,6 +697,8 @@ fn joinCells(s: *Surface, x: u16, y: u16, cells: []const Cell, from: usize, w: u
}
fn tagTintRange(p: *const Pardes, pane: *const Pane, tag: []const u8, prefix_len: usize) ?struct { lo: usize, hi: usize } {
+ // Out of rest no name is shown (UX D1).
+ if (pardes.Trail.outOfRest(p, pane)) return null;
if (pane.isTerminal()) {
// `tag` is the first row; a prefix longer than it ran to a second.
var words = std.mem.tokenizeAny(u8, tag[@min(prefix_len, tag.len)..], " \t\r\n");
@@ -841,8 +836,9 @@ fn joinPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r
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.
- const rows = pane.tag_rows - pane.band_rows;
+ // 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;
@@ -893,13 +889,12 @@ 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 chrome = p.chromeTheme();
const tab = p.settings.tab;
- const rows = pane.band_rows;
const columns = @max(band.columns, 1);
// The walk UI's inks on this tag's ground (colors.Roles, UX DESIGN.md
// D4), and on its cursor row's selection.
@@ -930,7 +925,13 @@ fn joinBand(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: R
for (ln.parts) |part| {
const end = @min(columns, part.col + part.width);
const on = if (part.row.on) selected else inks;
- if (part.row.on and part.col < end) t.tint(part.col, row, end - part.col, selected.ground, selected.text);
+ // The cursor's row across its step's width, its lead too (UX
+ // D5), the lead's `▶` keeping the key ink (D4).
+ if (part.row.on and part.col < end) {
+ const lead = part.col -| 2;
+ t.tint(lead, row, part.col - lead, selected.ground, null);
+ t.tint(part.col, row, end - part.col, selected.ground, selected.text);
+ }
var c = part.col;
var b: usize = 0;
while (b < part.row.text.len and c < end) : (c += 1) {
@@ -968,7 +969,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;
@@ -984,7 +987,7 @@ fn joinBand(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: R
/// Bytes `lo` to `hi` of a tag's text in `ink`, over whichever of its
/// shown rows (`lines`, from shown row `top`, drawn at `x`, `y`, `w`
/// wide) they wrapped onto.
-fn inkTag(p: *Pardes, s: *Surface, shown: tagline.Shown, lines: []const []const u8, top: usize, x: u16, y: u16, w: u16, lo: usize, hi: usize, ink: [3]u8) void {
+fn inkTag(p: *Pardes, s: *Surface, shown: tagline.Shown, lines: []const []const u8, top: usize, x: u16, y: u16, w: u16, lo: usize, hi: usize, ink: [3]u8, under: bool) void {
const a = modal.positionAt(shown.text, shown.fromReal(lo));
const b = modal.positionAt(shown.text, shown.fromReal(hi));
var row = @max(a.row, top);
@@ -995,8 +998,11 @@ fn inkTag(p: *Pardes, s: *Surface, shown: tagline.Shown, lines: []const []const
var col = panes.File.rawDisplayCol(p.settings.tab, line, @min(from, line.len));
const end = panes.File.rawDisplayCol(p.settings.tab, line, @min(to, line.len));
const row_y = y + @as(u16, @intCast(row - top));
- while (col < end and col < w) : (col += 1)
- s.at(x + @as(u16, @intCast(col)), row_y).style.fg = .{ .rgb = ink };
+ while (col < end and col < w) : (col += 1) {
+ const style = &s.at(x + @as(u16, @intCast(col)), row_y).style;
+ style.fg = .{ .rgb = ink };
+ if (under) style.ul = .single;
+ }
}
}
@@ -1019,7 +1025,7 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
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 = pane.tag_rows - pane.band_rows;
+ 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));
@@ -1047,7 +1053,11 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
var lines: [MAX_TAG_ROWS][]const u8 = @splat("");
var split = std.mem.splitScalar(u8, shown.text, '\n');
for (0..top) |_| _ = split.next();
- for (lines[0..rows]) |*line| line.* = split.next() orelse "";
+ var nlines: usize = 0;
+ for (lines[0..rows]) |*line| {
+ line.* = split.next() orelse continue;
+ nlines += 1;
+ }
// The keyboard's caret, as a row and a byte offset in that row's
// line: in the tag's own text when the tag has the keyboard, in the
// path while a name is drafted.
@@ -1074,9 +1084,22 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
const start = @min(line.len, panes.File.rawAtDisplay(p.settings.tab, line, pane.tag_scroll));
_ = s.print(tx, tag_y + @as(u16, @intCast(row)), tw, line[start..], text_style);
}
+ // Out of rest the rows the tag keeps from rest under the head's own:
+ // the spines on through them, under the key cells (UX D5).
+ if (head) |h| if (top == 0 and nlines < rows and h.cells > 0) {
+ const first = lines[0];
+ for (h.spans[0..h.cells]) |cell| {
+ const at = prefix_len + cell.lo;
+ if (at > first.len) break;
+ const col = panes.File.rawDisplayCol(p.settings.tab, first, at);
+ if (col >= tw) break;
+ for (nlines..rows) |row| s.set(tx + @as(u16, @intCast(col)), tag_y + @as(u16, @intCast(row)), "│", .{ .fg = .{ .rgb = inks.rule }, .bg = .{ .rgb = tag_bg }, .font_role = .tagline });
+ }
+ };
// The pane's progress at its first row's right end, where the row has
- // room for it (SPEC §10.2).
- if (top == 0 and rows > 0) for (p.messages.live[0..p.messages.live_len]) |*said| {
+ // room for it (SPEC §10.2); out of rest the head's right block is
+ // there (UX D1).
+ if (top == 0 and rows > 0 and !pardes.Trail.outOfRest(p, pane)) for (p.messages.live[0..p.messages.live_len]) |*said| {
if (said.kind != .progress or said.pane != pane.serial) continue;
var buf: [Messages.LoggedMessage.cap + 8]u8 = undefined;
const text = std.fmt.bufPrint(&buf, "{s} {s}", .{ Messages.Kind.progress.glyph(), said.words() }) catch break;
@@ -1089,12 +1112,26 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
// wrapped onto.
const first_line = whole[0 .. std.mem.indexOfScalar(u8, whole, '\n') orelse whole.len];
if (tagTintRange(p, pane, first_line, prefix_len)) |name| if (name.lo < name.hi)
- inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, name.lo, @min(name.hi, first_line.len), if (active) chrome.tag_active_name_fg else chrome.tag_name_fg);
- // A walk's forward steps, after the name, dimmed (Trail.zig).
+ inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, name.lo, @min(name.hi, first_line.len), if (active) chrome.tag_active_name_fg else chrome.tag_name_fg, false);
+ // A walk's forward steps, after the name, dimmed (Trail.zig); its fold
+ // `+N` too; the word n walks underlined in the key ink (UX D8).
const ahead = tagline.forwardSpan(p, pane);
- if (ahead[0] < ahead[1]) inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, ahead[0], @min(ahead[1], first_line.len), inks.dim);
+ if (ahead[0] < ahead[1]) inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, ahead[0], @min(ahead[1], first_line.len), inks.dim, false);
+ if (pane.file != null and pane.trail.n > 0 and !pardes.Trail.outOfRest(p, pane)) {
+ const kept = tagline.folded(p, pane);
+ const t = &pane.trail;
+ const first: usize = @intFromBool(t.steps[0] == .owner);
+ if (t.isFolded(first, kept)) {
+ const fold = t.spanOf(first, kept);
+ inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, fold[0], @min(fold[1], first_line.len), inks.dim, false);
+ }
+ if (t.walked()) |i| if (!t.isFolded(i, kept)) {
+ const word = t.spanOf(i, kept);
+ inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, word[0], @min(word[1], first_line.len), chrome.roles.key, true);
+ };
+ }
// A search word its places no longer light, dimmed (Prompt.zig).
- if (pardes.Prompt.unlit(p, pane)) |span| inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, span[0], @min(span[1], first_line.len), inks.dim);
+ if (pardes.Prompt.unlit(p, pane)) |span| inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, span[0], @min(span[1], first_line.len), inks.dim, false);
// The head's keys in the key ink, its dimmed, underlined and struck
// words (TagState.Span), over whichever rows they wrapped onto.
if (head) |h| for (h.spans) |span| {