summaryrefslogtreecommitdiff
path: root/core/Band.zig
diff options
context:
space:
mode:
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 });
}