summaryrefslogtreecommitdiff
path: root/core/Band.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-25 05:32:50 -0300
committerGabriel Schneider <[email protected]>2026-11-25 05:32:51 -0300
commit038a94400d668406ed5fab9ad8c00e064365dbb1 (patch)
tree6d79bf51a9b53e290a7cbf5736516c2536432024 /core/Band.zig
parent0e6c60d17dd5f0e48232a46096e3a7a92f8841cf (diff)
downloadpardes-038a94400d668406ed5fab9ad8c00e064365dbb1.tar.gz
pardes-038a94400d668406ed5fab9ad8c00e064365dbb1.zip
bindings, TagState, Band, draw: the registers as UX DESIGN.md D11 rules them: rolled, only the registers holding something (six of S's eleven items were `—`), each `key value` with its value in 20 cells at most (bindings.registerShown: its first line, a path cut from the left, `…proj/core/Query.zig`, where the useless end was cut before, other text from the right, `const best = rank(q…`, a newline that ends what shows said by a dim `⏎`, the value stopping there); unrolled, every register a row `key value` (the key bold in the key ink, the value in the text's, `—` for an empty one in the dim ink) with its name at the row's right end in the dim ink (Band.Row.meta), where the fixed name was at full ink and the value, the content, at 1.58:1; the doc step's verbs `p after P before R replace y into` dim with their letters bold in the key ink (Band.Row.keys; `next` gone); Band.Row.quiet, a byte range in the dim ink; TEST FIRST: bindings.zig's registers test holds D11 (fails on the parent at its rolled level, which shows `a const best = rank(q, nam… / —`): the rolled level with a path and a newline among its registers and the dim `⏎`, the unrolled rows, the empty register's `—` and the names in the dim ink, the verbs' letters bold in the key ink; core-test 1068/1238 (170 skipped)
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.zig31
1 files changed, 28 insertions, 3 deletions
diff --git a/core/Band.zig b/core/Band.zig
index e562da1d..5ddbe5af 100644
--- a/core/Band.zig
+++ b/core/Band.zig
@@ -59,6 +59,11 @@ pub const Row = struct {
/// Said at the row's right end in the dim ink, two cells off its text
/// at least, and the first to give way (UX D5): `in use`.
meta: []const u8 = "",
+ /// Its bytes `quiet[0]..quiet[1]` in the dim ink: an empty register's
+ /// `—`, a value's `⏎`.
+ quiet: [2]u16 = .{ 0, 0 },
+ /// Bytes that are keys, each in the key ink, bold: a register's verbs.
+ keys: []const u16 = &.{},
};
/// A column of rows. A level of more than 9 rows flows into two columns
@@ -221,6 +226,18 @@ fn helpSteps(band: *Band, p: *Pardes, arena: std.mem.Allocator, s: *const TagSta
band.add(try docStep(p, arena, at.root, at.path[0 .. at.path.len - 1], at.child));
}
+/// What a register's doc step offers next, its letters keys (UX D11).
+const verbs = "p after P before R replace y into";
+const verb_keys = blk: {
+ var out: [4]u16 = undefined;
+ var n: usize = 0;
+ for (0..verbs.len) |i| if (i == 0 or (i >= 2 and std.mem.eql(u8, verbs[i - 2 .. i], " "))) {
+ out[n] = i;
+ n += 1;
+ };
+ break :blk out;
+};
+
/// `"` unrolled (SPEC §9): the registers, a row each (its key, what it
/// is, its first line) around the cursor, or under `"a` its verbs; beside
/// them the value of the one on the cursor (or named) in full, as many of
@@ -238,17 +255,25 @@ fn registerSteps(band: *Band, p: *Pardes, arena: std.mem.Allocator, pane: *const
if (path.len > 0) band.add(try levelStep(arena, pane, level, at, used)) else {
const w = (Cursor{ .at = @intCast(at) }).window(@intCast(level.len));
const rows = try arena.alloc(Row, w.hi - w.lo);
+ // A row each (UX D11): `key value`, its name at the right; an
+ // empty one's `—` and a newline's `⏎` dim.
for (rows, w.lo..) |*row, i| {
const c = level[i];
const name = for (bindings.register_names) |r| {
if (r.key == c.key) break r.name;
} else "named";
+ const key = bindings.keyName(c.key);
+ const shown = try bindings.registerShown(arena, p.settings.tab, bindings.registerValue(p, c.key));
+ const text = try std.fmt.allocPrint(arena, "{s} {s}", .{ key, shown });
+ const quiet = if (std.mem.eql(u8, shown, "—")) key.len + 2 else if (std.mem.endsWith(u8, shown, "⏎")) text.len - "⏎".len else text.len;
row.* = .{
- .text = try std.fmt.allocPrint(arena, "{s} {s: <17} {s}{s}", .{ bindings.keyName(c.key), name, c.label, if (c.more) "…" else "" }),
+ .text = text,
.on = i == at,
- .key = 1,
+ .key = @intCast(key.len),
.under = c.key == used,
.index = @intCast(i),
+ .meta = name,
+ .quiet = .{ @intCast(quiet), @intCast(text.len) },
};
}
band.add(.{ .rows = rows });
@@ -274,7 +299,7 @@ fn registerSteps(band: *Band, p: *Pardes, arena: std.mem.Allocator, pane: *const
try rows.append(arena, .{ .text = look[0..end] });
rest = rest[end + 1 ..];
}
- if (path.len == 0) try rows.append(arena, .{ .text = "next p after P before R replace y into", .dim = true });
+ if (path.len == 0) try rows.append(arena, .{ .text = verbs, .dim = true, .keys = &verb_keys });
band.add(.{ .rows = rows.items, .doc = true });
}