diff options
| -rw-r--r-- | core/Band.zig | 3 | ||||
| -rw-r--r-- | core/Command.zig | 16 | ||||
| -rw-r--r-- | core/Pick.zig | 24 | ||||
| -rw-r--r-- | core/Prompt.zig | 46 | ||||
| -rw-r--r-- | core/TagState.zig | 174 | ||||
| -rw-r--r-- | test/snapshots/find.golden | 10 | ||||
| -rw-r--r-- | test/snapshots/fsearch.golden | 46 | ||||
| -rw-r--r-- | test/snapshots/lsp.golden | 6 | ||||
| -rw-r--r-- | test/snapshots/msg.golden | 10 | ||||
| -rw-r--r-- | test/snapshots/pipe.golden | 2 | ||||
| -rw-r--r-- | test/snapshots/selregex.golden | 10 | ||||
| -rw-r--r-- | test/snapshots/ttyhelp.golden | 2 |
12 files changed, 263 insertions, 86 deletions
diff --git a/core/Band.zig b/core/Band.zig index 31205d87..024b6be4 100644 --- a/core/Band.zig +++ b/core/Band.zig @@ -555,7 +555,8 @@ test "SPC Down unrolls the level into a band under the tag's text, the body push 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()); try std.testing.expect(std.mem.indexOf(u8, grid.items, "▶ b buffer…") != null); // The head names the level and says how to roll it up. - try std.testing.expect(std.mem.endsWith(u8, try tagline.tagText(p, frame.allocator(), pane), "␣ SPC ↑ roll up · ? field · esc")); + const head = try tagline.tagText(p, frame.allocator(), pane); + try std.testing.expect(std.mem.startsWith(u8, head, "␣ SPC ") and std.mem.endsWith(u8, head, " ↑ roll up · ? field · esc")); // 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); diff --git a/core/Command.zig b/core/Command.zig index 334d49a2..908358de 100644 --- a/core/Command.zig +++ b/core/Command.zig @@ -659,8 +659,22 @@ fn tagOf(p: *Pardes) ![]const u8 { return tagline.tagText(p, p.scratch.allocator(), p.panes[p.view().active].?); } +/// Whether `needle` is in `hay`, a run of two spaces or more in either read +/// as two: a right block's padding is its row's (UX D3). fn has(hay: []const u8, needle: []const u8) bool { - return std.mem.indexOf(u8, hay, needle) != null; + var in: [8192]u8 = undefined; + var of: [1024]u8 = undefined; + return std.mem.indexOf(u8, squeezed(hay, &in), squeezed(needle, &of)) != null; +} + +fn squeezed(s: []const u8, buf: []u8) []const u8 { + var n: usize = 0; + for (s, 0..) |c, i| { + if (c == ' ' and i >= 2 and s[i - 1] == ' ' and s[i - 2] == ' ') continue; + buf[n] = c; + n += 1; + } + return buf[0..n]; } /// Band row `y`'s text under the live view's active pane. diff --git a/core/Pick.zig b/core/Pick.zig index 321b16b7..8fcc5945 100644 --- a/core/Pick.zig +++ b/core/Pick.zig @@ -563,8 +563,9 @@ fn rowAt(p: *Pardes, pk: *const Pick, arena: std.mem.Allocator, i: usize) !Row { pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?TagState.Head { const pk = live(p) orelse return null; const s = &p.view().tag_state; - var text: std.ArrayList(u8) = .empty; - var spans: std.ArrayList(TagState.Span) = .empty; + var b = try TagState.Builder.of(p, arena, pane); + const text = &b.text; + const spans = &b.spans; var cells: [4][2]u32 = undefined; var ncells: usize = 0; // SPC's cell, then its keys': `␣ f`. @@ -581,16 +582,22 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?TagState.Head { if (pk.spine == .edit) try text.print(arena, "{s} | Edit ", .{pk.query.slice()}); const caret: u32 = @intCast(text.items.len + s.field.caret); try text.appendSlice(arena, s.field.text()); + // The count at the row's right end (UX D3): `cursor/matches`, `0` with + // none, ` •M` marked. + const counted = text.items.len; const n = count(p, pk); - try text.print(arena, " {d}/{d}", .{ if (n == 0) 0 else s.rows.at + 1, n }); + if (n == 0) try text.append(arena, '0') else try text.print(arena, "{d}/{d}", .{ s.rows.at + 1, n }); if (pk.marks.items.len > 0) try text.print(arena, " •{d}", .{pk.marks.items.len}); if (pk.names.busy() or p.stream.busyFor(pk.id)) try text.appendSlice(arena, " ⋯"); // Themes have no acts and no other sources: no second row. if (pk.source == .themes) { - try text.appendSlice(arena, " ⏎ wear it · esc"); + const hints = text.items.len; + try b.styled("⏎ wear it · esc", .dim); + try b.right(counted, hints); for (cells[0..ncells]) |c| try spans.append(arena, .{ .lo = c[0], .hi = c[1], .style = .key }); return .{ .text = text.items, .spans = spans.items, .cells = @intCast(ncells), .caret = caret }; } + try b.right(counted, text.items.len); // The second row: the spines go on through it from the key cells, // then the other sources' words, each switching to it. try text.append(arena, '\n'); @@ -1528,7 +1535,8 @@ test "a picker from a held pane unrolls in a reader made for it: its rows in the const tag = try tagOf(p, a, reader); // Out of rest no path (UX D1): not the previewed file's, not Keep; // the head starts the tag's text. - try std.testing.expect(std.mem.startsWith(u8, tag, "␣ f Find pick 1/1\n")); + const first = tag[0..std.mem.indexOfScalar(u8, tag, '\n').?]; + try std.testing.expect(std.mem.startsWith(u8, first, "␣ f Find pick ") and std.mem.endsWith(u8, first, " 1/1")); try std.testing.expect(std.mem.indexOf(u8, tag, "│ Walk Look Split Newcol Grep Edit Copy Keep Drop | Grep Recent Panes Symbols All Jumplist") != null); // The body previews the row's file, after a frame of its own. p.update(.tick); @@ -1570,7 +1578,8 @@ test "a picker's keys: Tab marks and moves, M-a all and none, C-SPC refines and try std.testing.expectEqual(@as(u16, 2), s.rows.at); var frame = std.heap.ArenaAllocator.init(std.testing.allocator); defer frame.deinit(); - try std.testing.expect(std.mem.indexOf(u8, try tagOf(p, frame.allocator(), id), " Refs 3/4 •1\n") != null); + const refs = try tagOf(p, frame.allocator(), id); + try std.testing.expect(std.mem.indexOf(u8, refs, " Refs ") != null and std.mem.indexOf(u8, refs, " 3/4 •1\n") != null); p.update(.{ .key = .{ .cp = 'a', .alt = true } }); try std.testing.expectEqual(@as(usize, 4), pk.marks.items.len); p.update(.{ .key = .{ .cp = 'a', .alt = true } }); @@ -1588,7 +1597,8 @@ test "a picker's keys: Tab marks and moves, M-a all and none, C-SPC refines and settle(p); try std.testing.expectEqual(@as(usize, 1), count(p, pk)); _ = frame.reset(.retain_capacity); - try std.testing.expect(std.mem.indexOf(u8, try tagOf(p, frame.allocator(), id), " Refs alpha | w 1/1\n") != null); + const refined = try tagOf(p, frame.allocator(), id); + try std.testing.expect(std.mem.indexOf(u8, refined, " Refs alpha | w ") != null and std.mem.indexOf(u8, refined, " 1/1\n") != null); // Backspace twice: the `w` goes, then the refinement, its query back. p.update(.{ .key = .{ .cp = Key.backspace } }); p.update(.{ .key = .{ .cp = Key.backspace } }); diff --git a/core/Prompt.zig b/core/Prompt.zig index 10886606..27b59649 100644 --- a/core/Prompt.zig +++ b/core/Prompt.zig @@ -1062,9 +1062,10 @@ fn strike(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, line: i32, lo_: pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !TagState.Head { const s = &p.view().tag_state; const pr = &s.prompt; - var text: std.ArrayList(u8) = .empty; - var spans: std.ArrayList(TagState.Span) = .empty; - try styled(arena, &text, &spans, info.get(pr.op).cell, .key); + var b = try TagState.Builder.of(p, arena, pane); + const text = &b.text; + const spans = &b.spans; + try styled(arena, text, spans, info.get(pr.op).cell, .key); try text.append(arena, ' '); const caret: u32 = @intCast(text.items.len + s.field.caret); const line = s.field.text(); @@ -1074,20 +1075,25 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !TagState.Head { var w: std.Io.Writer = .fixed(&buf); const said = if (pr.op == .command) Command.plainWord(p, &w, line) else plainWord(&w, pr.op, line) catch null; if (said) |verb| { - try styled(arena, &text, &spans, try std.fmt.allocPrint(arena, " = {s}", .{verb}), .dim); + try styled(arena, text, spans, try std.fmt.allocPrint(arena, " = {s}", .{verb}), .dim); try text.print(arena, " {s}", .{w.buffered()}); } + } + // The count and the hints at the row's right end (UX D3). + const at = text.items.len; + if (line.len > 0) { if (pr.bad) { try text.appendSlice(arena, " "); - try styled(arena, &text, &spans, regexMessage(line), .err); + try styled(arena, text, spans, regexMessage(line), .err); try text.print(arena, " · the {d} from before shown, dimmed", .{@as(usize, pane.body.nsel) + 1}); } else if (behavior(pr.op) != null) { - try pipeCount(p, arena, &text, &spans, pane, pr, line); - } else try count(arena, &text, pane, pr); + try pipeCount(p, arena, text, spans, pane, pr, line); + } else try count(arena, text, pane, pr); } - if (pr.op == .command) try Command.count(p, arena, &text); - try text.appendSlice(arena, " "); - try styled(arena, &text, &spans, info.get(pr.op).hint, .dim); + if (pr.op == .command) try Command.count(p, arena, text); + const hints = text.items.len; + try styled(arena, text, spans, info.get(pr.op).hint, .dim); + try b.right(at, hints); return .{ .text = text.items, .spans = spans.items, .cells = 1, .caret = caret }; } @@ -1115,7 +1121,7 @@ fn count(arena: std.mem.Allocator, text: *std.ArrayList(u8), pane: *Pane, pr: *c // Round the end from where it began. const c = at orelse return; const origin = set.origin(pane); - if (if (pr.op == .search) hits[c].start < origin else hits[c].start > origin) try text.appendSlice(arena, " · wrapped"); + if (if (pr.op == .search) hits[c].start < origin else hits[c].start > origin) try text.appendSlice(arena, " ↻"); }, .select, .split => if (pr.found == 0) try text.appendSlice(arena, " 0") @@ -1255,8 +1261,22 @@ fn tagOf(p: *Pardes) ![]const u8 { return tagline.tagText(p, p.scratch.allocator(), p.panes[p.view().active].?); } +/// Whether `needle` is in `hay`, a run of two spaces or more in either read +/// as two: a right block's padding is its row's (UX D3). fn has(hay: []const u8, needle: []const u8) bool { - return std.mem.indexOf(u8, hay, needle) != null; + var in: [8192]u8 = undefined; + var of: [1024]u8 = undefined; + return std.mem.indexOf(u8, squeezed(hay, &in), squeezed(needle, &of)) != null; +} + +fn squeezed(s: []const u8, buf: []u8) []const u8 { + var n: usize = 0; + for (s, 0..) |c, i| { + if (c == ' ' and i >= 2 and s[i - 1] == ' ' and s[i - 2] == ' ') continue; + buf[n] = c; + n += 1; + } + return buf[0..n]; } test "s asks in the tag's head: its key cell, the field, the plain word and the count, the selections live in the body; no match is 0, a pattern that is no regex keeps the last result dimmed and says why, Esc puts them back" { @@ -1269,7 +1289,7 @@ test "s asks in the tag's head: its key cell, the field, the plain word and the try std.testing.expectEqual(TagState.Kind.prompt, p.view().tag_state.kind); // No chip on the notice band: the prompt is the tag's. try std.testing.expectEqual(Pane.Prompt.none, pane.prompt); - try std.testing.expect(std.mem.endsWith(u8, try tagOf(p), "s ⏎ select · M-⏎ as a list · C-r history · esc")); + try std.testing.expect(has(try tagOf(p), "s ⏎ select · M-⏎ as a list · C-r history · esc")); typeKeys(p, "self"); try std.testing.expect(has(try tagOf(p), "s self = Exec Edit x/self/ 2 selections in 3 lines ⏎ select")); try std.testing.expectEqual(@as(u16, 1), pane.body.nsel); diff --git a/core/TagState.zig b/core/TagState.zig index 96c5b9b1..d70edf47 100644 --- a/core/TagState.zig +++ b/core/TagState.zig @@ -466,22 +466,106 @@ pub const Head = struct { caret: ?u32 = null, }; -const Builder = struct { +/// A head as it is built: its text and spans, laid out against the tag's +/// rows (UX D2, D3). +pub const Builder = struct { arena: std.mem.Allocator, text: std.ArrayList(u8) = .empty, spans: std.ArrayList(Span) = .empty, cells: u8 = 0, + /// The cells of a row of the tag, and those before the head on its + /// first row (the owner's and the newest step's words). + width: usize = 0, + lead: usize = 0, + tab: u16 = 8, - fn put(b: *Builder, s: []const u8) !void { + /// A head for pane `pane`'s tag, out of rest in the live view. + pub fn of(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !Builder { + const prefix = try tagline.prefixIn(p, arena, pane); + const id = panes.paneIdOf(p, pane) orelse 0; + return .{ .arena = arena, .width = tagline.tagWidth(p, id), .lead = panes.File.displayWidth(p.settings.tab, prefix), .tab = p.settings.tab }; + } + + pub fn put(b: *Builder, s: []const u8) !void { try b.text.appendSlice(b.arena, s); } - fn styled(b: *Builder, s: []const u8, style: Style) !void { + pub fn styled(b: *Builder, s: []const u8, style: Style) !void { const lo: u32 = @intCast(b.text.items.len); try b.text.appendSlice(b.arena, s); try b.spans.append(b.arena, .{ .lo = lo, .hi = @intCast(b.text.items.len), .style = style }); } + + /// The cells the row being built takes so far, the prefix's before the + /// first row's. + pub fn col(b: *const Builder) usize { + const items = b.text.items; + const nl = std.mem.lastIndexOfScalar(u8, items, '\n') orelse return b.lead + panes.File.displayWidth(b.tab, items); + return panes.File.displayWidth(b.tab, items[nl + 1 ..]); + } + + /// The right block (UX D3): what was put from byte `count` on (the + /// count) and from byte `hints` on (the hints) moved to the right end of + /// their row, its last cell the row's last, two spaces between them and + /// at least two before; so it never moves while the field grows toward + /// it. Hints that do not fit go whole, first; the count never does (a + /// head with no room for it runs past its row). + pub fn right(b: *Builder, count: usize, hints: usize) !void { + var h = hints; + b.cut(h, h + spaces(b.text.items[h..])); + const lead_c = spaces(b.text.items[count..h]); + b.cut(count, count + lead_c); + h -= lead_c; + while (h > count and b.text.items[h - 1] == ' ') : (h -= 1) b.cut(h - 1, h); + const items = b.text.items; + const row = if (std.mem.lastIndexOfScalar(u8, items[0..count], '\n')) |nl| nl + 1 else 0; + const left = panes.File.displayWidth(b.tab, items[row..count]) + if (row == 0) b.lead else 0; + var trail: usize = 0; + while (trail < count - row and items[count - 1 - trail] == ' ') trail += 1; + const cw = panes.File.displayWidth(b.tab, items[count..h]); + var hw = panes.File.displayWidth(b.tab, items[h..]); + const between: usize = if (cw > 0) 2 else 0; + if (hw > 0 and left + (2 -| trail) + cw + between + hw > b.width) { + b.text.shrinkRetainingCapacity(h); + var kept: usize = 0; + for (b.spans.items) |span| if (span.lo < h) { + b.spans.items[kept] = span; + kept += 1; + }; + b.spans.shrinkRetainingCapacity(kept); + hw = 0; + } + if (cw + hw == 0) return; + if (cw > 0 and hw > 0) try b.insert(h, 2); + const used = left + cw + (if (cw > 0 and hw > 0) between else 0) + hw; + try b.insert(count, if (used + (2 -| trail) <= b.width) b.width - used else 2 -| trail); + } + + /// `n` spaces put in at byte `at`, the spans after it moved with them. + fn insert(b: *Builder, at: usize, n: usize) !void { + const blank = try b.arena.alloc(u8, n); + @memset(blank, ' '); + try b.text.insertSlice(b.arena, at, blank); + for (b.spans.items) |*span| if (span.lo >= at) { + span.lo += @intCast(n); + span.hi += @intCast(n); + }; + } + + /// Bytes `lo` to `hi` taken out (blanks: no span starts in them). + fn cut(b: *Builder, lo: usize, hi: usize) void { + if (hi <= lo) return; + b.text.replaceRangeAssumeCapacity(lo, hi - lo, &.{}); + for (b.spans.items) |*span| if (span.lo >= hi) { + span.lo -= @intCast(hi - lo); + span.hi -= @intCast(hi - lo); + }; + } + + fn spaces(s: []const u8) usize { + return s.len - std.mem.trimStart(u8, s, " ").len; + } /// The keys typed as 2-cell key cells: the root's, then each key. - fn keyCells(b: *Builder, root: Root, path: []const u8) !void { + pub fn keyCells(b: *Builder, root: Root, path: []const u8) !void { try b.styled(bindings.info.get(root).cell, .key); try b.put(" "); for (path) |k| { @@ -490,7 +574,7 @@ const Builder = struct { } b.cells = @intCast(b.spans.items.len); } - fn done(b: *const Builder) Head { + pub fn done(b: *const Builder) Head { return .{ .text = b.text.items, .spans = b.spans.items, .cells = b.cells }; } }; @@ -502,11 +586,11 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?Head { if (p.panes[id] != pane) return asking(p, arena, pane); const v = p.view(); const s = &v.tag_state; - var b: Builder = .{ .arena = arena }; + var b = try Builder.of(p, arena, pane); switch (s.kind) { .rest => {}, - // `Help`, its scope's keys, the field, its count: - // `Help ␣ l hov 2/17` (out of rest the head starts the tag's + // `Help`, its scope's keys, the field, its count at the row's end: + // `Help ␣ l hov 2/17` (out of rest the head starts the tag's // text, after the owner's and the newest step's words: UX D1). .help => { try b.put("Help "); @@ -514,7 +598,9 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?Head { var h = b.done(); h.caret = @intCast(b.text.items.len + s.field.caret); try b.put(s.field.text()); - try b.text.print(arena, " {d}/{d}", .{ s.nhits, s.ntotal }); + const count = b.text.items.len; + if (s.nhits == 0) try b.put("0") else try b.text.print(arena, "{d}/{d}", .{ s.rows.at + 1, s.nhits }); + try b.right(count, b.text.items.len); h.text = b.text.items; h.spans = b.spans.items; return h; @@ -542,9 +628,16 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?Head { try b.put(" "); try b.put(c.label); }; - try b.put(" ⏎ run · esc"); + const hints = b.text.items.len; + try b.styled("⏎ run · esc", .dim); + try b.right(hints, hints); } else try b.put("…"); - } else try b.put("… press a key or a sequence · esc"); + } else { + try b.put("…"); + const hints = b.text.items.len; + try b.styled("press a key or a sequence · esc", .dim); + try b.right(hints, hints); + } return b.done(); }, .pick => return @import("Pick.zig").head(p, arena, pane), @@ -558,7 +651,9 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?Head { var h = b.done(); h.caret = @intCast(b.text.items.len + s.field.caret); try b.put(s.field.text()); - try b.put(" ⏎ rename · esc"); + const hints = b.text.items.len; + try b.styled("⏎ rename · esc", .dim); + try b.right(hints, hints); h.text = b.text.items; h.spans = b.spans.items; return h; @@ -569,7 +664,9 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?Head { const node = bindings.nodeAt(cur.root, cur.path) orelse return b.done(); if (s.unrolled) { try b.put(if (cur.path.len == 0) bindings.info.get(cur.root).label else node.label); - try b.put(" ↑ roll up · ? field · esc"); + const hints = b.text.items.len; + try b.styled("↑ roll up · ? field · esc", .dim); + try b.right(hints, hints); return b.done(); } try b.styled("▸", .key); @@ -688,6 +785,57 @@ test "SPC changes nothing in the tag until its level shows 250 ms on, its keys o try std.testing.expect(p.view().tag_state.root == null); } +fn firstRow(tag: []const u8) []const u8 { + return tag[0 .. std.mem.indexOfScalar(u8, tag, '\n') orelse tag.len]; +} + +test "the right block: the count `cursor/matches` at the row's right end, fixed while the field grows; the hints after it, dim, dropped whole where the row has no room" { + const Key = pardes.Key; + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 60, .rows = 30 }); + defer p.deinit(); + _ = try p.setTestFile("one\n"); + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + const a = frame.allocator(); + const tab = p.settings.tab; + const width = tagline.tagWidth(p, p.view().active); + p.update(.{ .key = .{ .cp = ' ' } }); + p.update(.{ .key = .{ .cp = '?' } }); + const s = &p.view().tag_state; + var row = firstRow(try testTag(p, a)); + try std.testing.expect(std.mem.startsWith(u8, row, "Help ")); + try std.testing.expectEqual(width, panes.File.displayWidth(tab, row)); + try std.testing.expect(std.mem.endsWith(u8, row, try std.fmt.allocPrint(a, " 1/{d}", .{s.nhits}))); + // Typed into: the field grows toward the count, which stays put. + for ("wr") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } }); + row = firstRow(try testTag(p, a)); + try std.testing.expect(std.mem.startsWith(u8, row, "Help wr ") and s.nhits > 1); + try std.testing.expectEqual(width, panes.File.displayWidth(tab, row)); + try std.testing.expect(std.mem.endsWith(u8, row, try std.fmt.allocPrint(a, " 1/{d}", .{s.nhits}))); + // The cursor's row is the count's first number. + p.update(.{ .key = .{ .cp = Key.down } }); + try std.testing.expect(std.mem.endsWith(u8, firstRow(try testTag(p, a)), try std.fmt.allocPrint(a, " 2/{d}", .{s.nhits}))); + p.update(.{ .key = .{ .cp = Key.escape } }); + // Unrolled: the hints at the row's end, dim. + p.update(.{ .key = .{ .cp = ' ' } }); + p.update(.{ .key = .{ .cp = Key.down } }); + row = firstRow(try testTag(p, a)); + try std.testing.expect(std.mem.startsWith(u8, row, "␣ SPC ")); + try std.testing.expect(std.mem.endsWith(u8, row, " ↑ roll up · ? field · esc")); + try std.testing.expectEqual(width, panes.File.displayWidth(tab, row)); + const h = (try head(p, a, p.panes[p.view().active].?)).?; + const last = h.spans[h.spans.len - 1]; + try std.testing.expect(last.style == .dim and last.hi == h.text.len); + p.update(.{ .key = .{ .cp = Key.escape } }); + // Where the row has no room for them, the hints go whole. + const narrow = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 24, .rows = 30 }); + defer narrow.deinit(); + _ = try narrow.setTestFile("one\n"); + narrow.update(.{ .key = .{ .cp = ' ' } }); + narrow.update(.{ .key = .{ .cp = Key.down } }); + try std.testing.expectEqualStrings("␣ SPC", firstRow(try testTag(narrow, a))); +} + test "a leaf run from a level is remembered: underlined there, and said on the line under it" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 30 }); defer p.deinit(); diff --git a/test/snapshots/find.golden b/test/snapshots/find.golden index 8cef240d..83fd76dc 100644 --- a/test/snapshots/find.golden +++ b/test/snapshots/find.golden @@ -41,7 +41,7 @@ | | /tmp/pardes-snap/find/cwd/here.txt:1 == snap armed grid=120x41 cursor=11,2 -|2: ^ ␣ f Find 1/5 +|2: ^ ␣ f Find 1/5 |3: │ │ Walk Look Split Newcol Grep Edit Copy Keep Drop | Grep Recent Panes Symbols All Jumplist |4: │ │ ▶ here.txt |5: │ │ other.txt @@ -51,7 +51,7 @@ |9: 1 Find zqm |40: ✓ /tmp/pardes-snap/find/cwd/here.txt Find 1 message · SPC h m == snap typing grid=120x41 cursor=14,2 -|2: ^ ␣ f Find zqm 1/3 +|2: ^ ␣ f Find zqm 1/3 |4: │ │ ▶ zqmark-alpha.txt |5: │ │ sub/ZQMARK-beta.txt |6: │ │ sub/nest/zqmark-gamma.txt @@ -59,7 +59,7 @@ |8: │ │ |9: 1 alpha body == snap next grid=120x41 cursor=14,2 -|2: ^ ␣ f Find zqm 2/3 +|2: ^ ␣ f Find zqm 2/3 |4: │ │ zqmark-alpha.txt |5: │ │ ▶ sub/ZQMARK-beta.txt |9: 1 beta body @@ -73,7 +73,7 @@ |8: |9: == snap nomatch grid=120x41 cursor=30,2 -|2: ^ Find zqm 2/3 › ␣ f Find zzqq 0/0 +|2: ^ Find zqm 2/3 › ␣ f Find zzqq 0 |3: │ │ Walk Look Split Newcol Grep Edit Copy Keep Drop | Grep Recent Panes Symbols All Jumplist |4: │ │ nothing matches |5: │ │ @@ -86,7 +86,7 @@ |5: |6: == snap topbar grid=120x41 cursor=29,2 -|2: ^ Find zqm 2/3 › ␣ f Find bod 0/0 +|2: ^ Find zqm 2/3 › ␣ f Find bod 0 |3: │ │ Walk Look Split Newcol Grep Edit Copy Keep Drop | Grep Recent Panes Symbols All Jumplist |4: │ │ nothing matches |5: │ │ diff --git a/test/snapshots/fsearch.golden b/test/snapshots/fsearch.golden index bf8957df..dd1d34e5 100644 --- a/test/snapshots/fsearch.golden +++ b/test/snapshots/fsearch.golden @@ -31,22 +31,12 @@ | | · @p1 a copy of the terminal's text: Tab or B2 runs it; what the program draws next replaces it (Ctrl-b types to the program) 1 message · SPC h m == snap slash grid=180x31 cursor=101,16 -|16: /tmp/pardes-snap/fsearch/cwd Term+bash Save Mode Filter Collapse Del ^ ‹@p1 › / ⏎ land · M-⏎ as a list · C-r history · esc +|16: /tmp/pardes-snap/fsearch/cwd Term+bash Save Mode Filter Collapse Del ^ ‹@p1 › / ⏎ land · M-⏎ as a list · C-r history · esc == snap typing grid=180x31 cursor=105,16 -|16: /tmp/pardes-snap/fsearch/cwd Term+bash Save Mode Filter Collapse Del ^ ‹@p1 › / MARK = Look /MARK/ 1/3 · 3 lines ⏎ land · M-⏎ as a list · C-r history · es -|17: ls c -|18: g.txt 1 l1 -|19: 2▸MARK a -|20: 3 l3 -|21: 4 l4 -|22: 5 l5 -|23: 6▪MARK b -|24: 7 l7 -|25: 8 l8 -|26: 9 l9 -|27: 10▪MARK c -|28: 11 l11 -|29: 12 l12 +|16: /tmp/pardes-snap/fsearch/cwd Term+bash Save Mode Filter Collapse Del ^ ‹@p1 › / MARK = Look /MARK/ 1/3 · 3 lines ⏎ land · M-⏎ as a list · C-r history · esc +|18: g.txt 2▸MARK a +|22: 6▪MARK b +|26: 10▪MARK c == style typing grid=180x31 |0: 0-1 d,#1d2824, 2-179 #b2c3b8,#1d2824, |1: 0-1 d,#887455, 2-89 #b2c3b8,#1d2824, 90-91 #b2c3b8,#887455, 92-179 #becfc4,#314738, @@ -64,23 +54,23 @@ |13: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-179 d,#0d1410, |14: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-179 d,#0d1410, |15: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-179 d,#0d1410, -|16: 0-1 d,#496656, 2-30 #b2c3b8,#1d2824, 31-40 #d3b0d9,#1d2824, 41-89 #b2c3b8,#1d2824, 90-91 #000000,#add38a, 92-98 #becfc4,#2c2819, 99-99 #add38a,#2c2819,b 100-100 #add38a,#2c2819, 101-104 #becfc4,#2c2819, 105-112 #becfc4,#2c2819,f 113-138 #becfc4,#2c2819, 139-179 #becfc4,#2c2819,f -|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-91 #e5eee5,#2c2819, 92-92 #becfc4,#2c2819,f 93-179 #becfc4,#2c2819, -|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 #e5eee5,#e5eee5, 91-94 #e5eee5,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, -|19: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-94 d,#0d1410,b 95-95 #616f64,#0d1410,b 96-96 #add38a,#0d1410,b 97-100 #f5f7ee,#3c614a, 101-101 #f5f7ee,#0d1410, 102-179 #e5eee5,#0d1410, +|16: 0-1 d,#496656, 2-30 #b2c3b8,#1d2824, 31-40 #d3b0d9,#1d2824, 41-89 #b2c3b8,#1d2824, 90-91 #000000,#add38a, 92-98 #becfc4,#2c2819, 99-99 #add38a,#2c2819,b 100-100 #add38a,#2c2819, 101-104 #becfc4,#2c2819, 105-112 #becfc4,#2c2819,f 113-137 #becfc4,#2c2819, 138-179 #becfc4,#2c2819,f +|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 #e5eee5,#608269, 91-94 #e5eee5,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 #e5eee5,#e5eee5, 91-91 #e5eee5,#0d1410, 92-94 #e5eee5,#0d1410,b 95-95 #616f64,#0d1410,b 96-96 #add38a,#0d1410,b 97-100 #f5f7ee,#3c614a, 101-101 #f5f7ee,#0d1410, 102-179 #e5eee5,#0d1410, +|19: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, |20: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, |21: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, -|22: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#5e4923, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, -|23: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-94 d,#0d1410, 95-95 #59675c,#0d1410, 96-96 #add38a,#0d1410, 97-100 #e5eee5,#352e19, 101-179 #e5eee5,#0d1410, +|22: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#5e4923, 91-94 d,#0d1410, 95-95 #59675c,#0d1410, 96-96 #add38a,#0d1410, 97-100 #e5eee5,#352e19, 101-179 #e5eee5,#0d1410, +|23: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, |24: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, |25: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, -|26: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, -|27: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#5e4923, 91-93 d,#0d1410, 94-95 #59675c,#0d1410, 96-96 #add38a,#0d1410, 97-100 #e5eee5,#352e19, 101-179 #e5eee5,#0d1410, +|26: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#5e4923, 91-93 d,#0d1410, 94-95 #59675c,#0d1410, 96-96 #add38a,#0d1410, 97-100 #e5eee5,#352e19, 101-179 #e5eee5,#0d1410, +|27: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-93 d,#0d1410, 94-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, |28: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-93 d,#0d1410, 94-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, -|29: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-93 d,#0d1410, 94-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, +|29: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-179 d,#0d1410, |30: 0-1 d,#1d2824, 2-179 #67756e,#1d2824, == snap list grid=180x31 cursor=110,16 -|16: /tmp/pardes-snap/fsearch/cwd Term+bash Save Mode Filter Collapse Del ^ ‹@p1 › ␣ l /MARK/ 1/3 +|16: /tmp/pardes-snap/fsearch/cwd Term+bash Save Mode Filter Collapse Del ^ ‹@p1 › ␣ l /MARK/ 1/3 |17: ls │ │ Walk Look Split Newcol Grep Edit Copy Keep Drop | Find Grep Recent Panes Symb |18: g.txt ols All Jumplist |19: ▶ /tmp/pardes-snap/fsearch/cwd/g.txt:2:1: MARK a @@ -95,7 +85,7 @@ |28: 7 l7 |29: 8 l8 == snap ctrln grid=180x31 cursor=110,16 -|16: /tmp/pardes-snap/fsearch/cwd Term+bash Save Mode Filter Collapse Del ^ ‹@p1 › ␣ l /MARK/ 2/3 +|16: /tmp/pardes-snap/fsearch/cwd Term+bash Save Mode Filter Collapse Del ^ ‹@p1 › ␣ l /MARK/ 2/3 |19: /tmp/pardes-snap/fsearch/cwd/g.txt:2:1: MARK a |20: ▶ /tmp/pardes-snap/fsearch/cwd/g.txt:6:1: MARK b |22: 2 MARK a @@ -139,5 +129,5 @@ |16: /tmp/pardes-snap/fsearch/cwd Term+bash Save Mode Filter Collapse Del ‹@p1 › g.txt:1 › /MARK/ 2/3 › /tmp/pardes-snap/fsearch/cwd/g.txt Keep Save Term Collapse == snap cancel grid=180x31 cursor=97,23 == snap nomatch grid=180x31 cursor=118,16 -|16: /tmp/pardes-snap/fsearch/cwd Term+bash Save Mode Filter Collapse Del ^ ‹@p1 › /MARK/ 2/3 › / zzqq = Look /zzqq/ 0 ⏎ land · M-⏎ as a list · C-r history · e -|17: ls sc +|16: /tmp/pardes-snap/fsearch/cwd Term+bash Save Mode Filter Collapse Del ^ ‹@p1 › /MARK/ 2/3 › / zzqq = Look /zzqq/ 0 ⏎ land · M-⏎ as a list · C-r history · esc +|17: ls diff --git a/test/snapshots/lsp.golden b/test/snapshots/lsp.golden index 445c5d4b..94958ba4 100644 --- a/test/snapshots/lsp.golden +++ b/test/snapshots/lsp.golden @@ -57,7 +57,7 @@ |14: ~ |40: ✓ /tmp/pardes-snap/lsp/cwd/a.zig Hover 1 message · SPC h m == snap symbols grid=120x41 cursor=24,2 -|2: ^ a.zig:8 › ␣ l Symbols 1/3 +|2: ^ a.zig:8 › ␣ l Symbols 1/3 |3: │ │ Walk Look Split Newcol Grep Edit Copy Keep Drop | Find Grep Recent Panes Symbols All Jumplist |4: │ │ ▶ a.zig:1:7-9 std |5: │ │ a.zig:3:4-9 helper @@ -76,9 +76,9 @@ |18: ~ |40: ✓ /tmp/pardes-snap/lsp/cwd/a.zig Symbols 2 messages · SPC h m == snap step grid=120x41 cursor=27,2 -|2: ^ a.zig:8 › ␣ l Symbols jn 0/0 +|2: ^ a.zig:8 › ␣ l Symbols jn 0 |4: │ │ nothing matches |5: │ │ |6: │ │ == snap nothing grid=120x41 cursor=29,2 -|2: ^ a.zig:8 › ␣ l Symbols jngd 0/0 +|2: ^ a.zig:8 › ␣ l Symbols jngd 0 diff --git a/test/snapshots/msg.golden b/test/snapshots/msg.golden index 7e622261..4c6f2308 100644 --- a/test/snapshots/msg.golden +++ b/test/snapshots/msg.golden @@ -48,18 +48,12 @@ |9: |16: · reloaded /tmp/pardes-snap/msg/cwd/a.txt 5 messages · SPC h m == snap prompt grid=70x17 cursor=7,2 -|2: ^ s EXT = Exec Edit x/EXT/ 0 ⏎ select · M-⏎ as a list · C-r histo -|3: ry · esc -|4: 1 EXTERNAL -|5: ~ +|2: ^ s EXT = Exec Edit x/EXT/ 0 == snap prompt-wins grid=70x17 cursor=7,2 -|4: 1 AGAIN +|3: 1 AGAIN |16: · reloaded /tmp/pardes-snap/msg/cwd/a.txt ×2 5 messages · SPC h m == snap esc grid=70x17 cursor=7,4 |2: /tmp/pardes-snap/msg/cwd/a.txt Keep Save Term Collapse Follow Del -|3: 1 AGAIN -|4: ~ -|5: == snap msgbuiltin grid=70x17 cursor=29,5 |2: */tmp/pardes-snap/msg/cwd/a.txt Save Term Collapse Follow Del |4: 2 diff --git a/test/snapshots/pipe.golden b/test/snapshots/pipe.golden index a8d2aa31..9ac8ced4 100644 --- a/test/snapshots/pipe.golden +++ b/test/snapshots/pipe.golden @@ -1,7 +1,7 @@ == snap prompt grid=180x13 cursor=14,2 | Newcol Joincol Find Grep Help Changelog Tutor Dump Themes Config History Debug Exit | New Term Find Grep Joincol Delcol -|^ | tr a-z A-Z = Exec Edit |tr a-z A-Z 1 line → 1 · exit 0 ⏎ replace · C-r history · esc +|^ | tr a-z A-Z = Exec Edit |tr a-z A-Z 1 line → 1 · exit 0 ⏎ replace · C-r history · esc | 1 alpha beta | ALPHA BETA | 2 gamma delta diff --git a/test/snapshots/selregex.golden b/test/snapshots/selregex.golden index df68f85a..b6e45518 100644 --- a/test/snapshots/selregex.golden +++ b/test/snapshots/selregex.golden @@ -1,7 +1,7 @@ == snap prompt-armed grid=160x25 cursor=4,2 | Newcol Joincol Find Grep Help Changelog Tutor Dump Themes Config History Debug Exit | New Term Find Grep Joincol Delcol -|^ s ⏎ select · M-⏎ as a list · C-r history · esc +|^ s ⏎ select · M-⏎ as a list · C-r history · esc | 1┃const one = 1; | 2┃const two = 2; | 3┃const three = 3; @@ -25,12 +25,12 @@ | | /tmp/pardes-snap/selregex/cwd/m.zig:3 == snap preview grid=160x25 cursor=9,2 -|2: ^ s const = Exec Edit x/const/ 3 selections in 3 lines ⏎ select · M-⏎ as a list · C-r history · esc +|2: ^ s const = Exec Edit x/const/ 3 selections in 3 lines ⏎ select · M-⏎ as a list · C-r history · esc |24: /tmp/pardes-snap/selregex/cwd/m.zig:1 == style preview grid=160x25 |0: 0-1 d,#1d2824, 2-159 #b2c3b8,#1d2824, |1: 0-1 d,#887455, 2-159 #becfc4,#314738, -|2: 0-1 #000000,#add38a, 2-2 #add38a,#2c2819,b 3-3 #add38a,#2c2819, 4-8 #becfc4,#2c2819, 9-16 #becfc4,#2c2819,f 17-59 #becfc4,#2c2819, 60-103 #becfc4,#2c2819,f 104-159 #becfc4,#2c2819, +|2: 0-1 #000000,#add38a, 2-2 #add38a,#2c2819,b 3-3 #add38a,#2c2819, 4-8 #becfc4,#2c2819, 9-16 #becfc4,#2c2819,f 17-115 #becfc4,#2c2819, 116-159 #becfc4,#2c2819,f |3: 0-0 d,#608269, 1-1 d,#0d1410, 2-4 d,#0d1410,b 5-5 #616f64,#0d1410,b 6-6 #add38a,#0d1410,b 7-10 #f5f7ee,#3c614a, 11-11 #3c614a,#f5f7ee, 12-12 #3c614a,#0d1410, 13-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-159 #e5eee5,#0d1410, |4: 0-0 d,#608269, 1-4 d,#0d1410, 5-5 #59675c,#0d1410, 6-6 #add38a,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-12 #3c614a,#0d1410, 13-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-159 #e5eee5,#0d1410, |5: 0-0 d,#608269, 1-4 d,#0d1410, 5-5 #59675c,#0d1410, 6-6 #add38a,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-12 #3c614a,#0d1410, 13-20 #e5eee5,#0d1410, 21-21 #f8c082,#0d1410, 22-159 #e5eee5,#0d1410, @@ -64,12 +64,12 @@ |4: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-12 #3c614a,#0d1410, 13-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-159 #e5eee5,#0d1410, |5: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-12 #3c614a,#0d1410, 13-20 #e5eee5,#0d1410, 21-21 #f8c082,#0d1410, 22-159 #e5eee5,#0d1410, == snap narrowed grid=160x25 cursor=21,2 -|2: ^ Edit x/const/ › s t = Exec Edit x/t/ 3 selections in 3 lines ⏎ select · M-⏎ as a list · C-r history · esc +|2: ^ Edit x/const/ › s t = Exec Edit x/t/ 3 selections in 3 lines ⏎ select · M-⏎ as a list · C-r history · esc |3: 1┃const one = 1; |4: 2┃const two = 2; |5: 3┃const three = 3; == style narrowed grid=160x25 -|2: 0-1 #000000,#add38a, 2-17 #becfc4,#2c2819, 18-18 #add38a,#2c2819,b 19-19 #add38a,#2c2819, 20-20 #becfc4,#2c2819, 21-28 #becfc4,#2c2819,f 29-67 #becfc4,#2c2819, 68-111 #becfc4,#2c2819,f 112-159 #becfc4,#2c2819, +|2: 0-1 #000000,#add38a, 2-17 #becfc4,#2c2819, 18-18 #add38a,#2c2819,b 19-19 #add38a,#2c2819, 20-20 #becfc4,#2c2819, 21-28 #becfc4,#2c2819,f 29-115 #becfc4,#2c2819, 116-159 #becfc4,#2c2819,f |3: 0-0 d,#608269, 1-1 d,#0d1410, 2-4 d,#0d1410,b 5-5 #616f64,#0d1410,b 6-6 #add38a,#0d1410,b 7-10 #e5eee5,#0d1410, 11-11 #3c614a,#f5f7ee, 12-12 #3c614a,#0d1410, 13-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-159 #e5eee5,#0d1410, |4: 0-0 d,#608269, 1-4 d,#0d1410, 5-5 #59675c,#0d1410, 6-6 #add38a,#0d1410, 7-10 #e5eee5,#0d1410, 11-11 #3c614a,#f5f7ee, 12-12 #3c614a,#0d1410, 13-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-159 #e5eee5,#0d1410, |5: 0-0 d,#608269, 1-4 d,#0d1410, 5-5 #59675c,#0d1410, 6-6 #add38a,#0d1410, 7-10 #e5eee5,#0d1410, 11-11 #3c614a,#f5f7ee, 12-12 #3c614a,#0d1410, 13-20 #e5eee5,#0d1410, 21-21 #f8c082,#0d1410, 22-159 #e5eee5,#0d1410, diff --git a/test/snapshots/ttyhelp.golden b/test/snapshots/ttyhelp.golden index 3eb84714..93442263 100644 --- a/test/snapshots/ttyhelp.golden +++ b/test/snapshots/ttyhelp.golden @@ -49,7 +49,7 @@ |20: r SPC and those keys (`Help l`, as `SPC l ?` shows them). Each fills the one +Help: a second |30: ✓ @p1 Help 1 message · SPC h m == snap leaderworks grid=100x31 cursor=12,5 -|5: ^ Help tutor 1/136 +|5: ^ Help tutor 1/1 |6: ▶ SPC h t · Tutor · help│ t Tutor |7: │ Open the tutor, a document to work through. |8: │ keys SPC h t |
