summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/Band.zig2
-rw-r--r--core/Command.zig2
-rw-r--r--core/Pick.zig138
-rw-r--r--core/Prompt.zig58
-rw-r--r--core/TagState.zig26
-rw-r--r--core/draw.zig4
-rw-r--r--core/views.zig10
7 files changed, 118 insertions, 122 deletions
diff --git a/core/Band.zig b/core/Band.zig
index 5efe1a36..1a1a9b48 100644
--- a/core/Band.zig
+++ b/core/Band.zig
@@ -894,7 +894,7 @@ test "SPC Down unrolls the level into a band under the tag's text, drawn over th
// The head, the layer's first row, names the level and says how to roll
// it up.
const head = (try TagState.head(p, frame.allocator(), pane)).?.text;
- try std.testing.expect(std.mem.startsWith(u8, head, "␣ SPC ") and std.mem.endsWith(u8, head, " ↑ roll up · ? field · esc"));
+ try std.testing.expect(std.mem.startsWith(u8, head, "␣ SPC ") and std.mem.endsWith(u8, head, " ? help"));
try std.testing.expect(std.mem.startsWith(u8, try layerRow(frame.allocator(), layer, 0), "␣ SPC "));
// Down moves the cursor; Up back to the first row, then rolls up.
p.update(.{ .key = .{ .cp = Key.down } });
diff --git a/core/Command.zig b/core/Command.zig
index 691f7dfa..afc3790d 100644
--- a/core/Command.zig
+++ b/core/Command.zig
@@ -759,7 +759,7 @@ test ": opens a field in the tag after its key cell: the tag's own words first,
try std.testing.expectEqual(Prompt.Op.command, s.prompt.op);
try std.testing.expectEqual(panes.Pane.Focus.body, pane.focus);
// The head: its key cell, the field, the count, the hints.
- try std.testing.expect(has(try headOf(p), ": 18 commands Tab complete · ⏎ run · C-r history · esc"));
+ try std.testing.expect(has(try headOf(p), "18 commands C-r history"));
// The rows: the tag's words in its order, `in the tag`, the last ruled
// off; then the commands, each what it takes.
try std.testing.expect(has(try bandRow(p, a, 0), "▶ Save "));
diff --git a/core/Pick.zig b/core/Pick.zig
index 7bceab39..2637bb1d 100644
--- a/core/Pick.zig
+++ b/core/Pick.zig
@@ -106,6 +106,10 @@ made: bool = false,
cap: u16 = 0,
/// Unrolled in a view's tag now.
unrolled: bool = false,
+/// The most rows its list has had since it unrolled, eleven at most: its
+/// band grows with a list whose rows come later and never shrinks while it
+/// is up (bandRows, UX D6).
+tall: u8 = 0,
names: Names = .{},
/// A Grep's lines, as the disk engine sends them (Query.take).
found: std.ArrayList(Query.Found) = .empty,
@@ -414,6 +418,7 @@ fn unroll(p: *Pardes, pk: *Pick, query: []const u8) void {
s.field.set(query);
s.rows = .{ .at = @intCast(@min(pk.at, std.math.maxInt(u16))) };
pk.unrolled = true;
+ pk.tall = 0;
pk.shown = no_row;
pk.previewed = false;
// The whole window previews a theme.
@@ -595,6 +600,7 @@ fn toBest(p: *Pardes, pk: *Pick) void {
/// current row.
pub fn produceAll(p: *Pardes, tick: bool) void {
for (p.picks) |slot| if (slot) |pk| if (pk.unrolled) {
+ pk.tall = @intCast(@max(pk.tall, @min(have(p, pk), Band.Cursor.shown)));
if (pk.names.busy()) {
// A cursor on the best match follows it while the rest are
// scored.
@@ -608,6 +614,12 @@ pub fn produceAll(p: *Pardes, tick: bool) void {
};
}
+/// The rows a picker's source has: every name it scores (not what the
+/// query keeps), a Grep's lines and All's places for this query.
+fn have(p: *const Pardes, pk: *const Pick) usize {
+ return if (fuzzy(pk)) pk.names.cands.items.len else count(p, pk);
+}
+
/// The frames a live picker still owes: scoring, a preview (nextWake's).
pub fn busy(p: *const Pardes) bool {
for (p.picks) |slot| if (slot) |pk| if (pk.unrolled) {
@@ -813,10 +825,11 @@ fn rowAt(p: *Pardes, pk: *const Pick, arena: std.mem.Allocator, i: usize) std.me
// ---- the tag ----
-/// The head under the landing pane's tag (SPEC §5.3, UX DESIGN M2): the
+/// The head under the asking pane's tag (SPEC §5.3, UX DESIGN M2, O1): the
/// key cells, the source's word, the query, the count `cursor/total` and
-/// `•marked`; on a second row the acts and the other sources' words, under
-/// spines from the key cells.
+/// `•marked`, and one hint, `M-l acts`, the key to the acts (UX DESIGN O4:
+/// no row of acts and sources; each source has its own key, M-h switches
+/// keeping the query).
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;
@@ -839,65 +852,29 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?TagState.Head {
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, actions and Lists have no acts and no other sources: no
- // second row.
- if (pk.source == .themes or pk.source == .actions or pk.source == .lists) {
- const hints = text.items.len;
- try b.styled(switch (pk.source) {
- .themes => "⏎ wear it · esc",
- .lists => "⏎ reopen it · esc",
- else => "⏎ or 1-9 apply it · esc",
- }, .dim);
- try b.right(counted, hints);
- var h = b.done();
- h.caret = caret;
- return h;
- }
- try b.right(counted, text.items.len);
- // The second row, one row (UX D2): under the spines from the key
- // cells, from two cells right of the last, the acts, `|`, the other
- // sources' words, each switching to it, the `|` and the sources dim
- // (UX D4); what does not fit is dropped from the right (the sources
- // first) and the row ends in a dim `…` (M-l and M-h reach them all).
- try b.row(if (b.ncols > 0) b.cols[b.ncols - 1] + 2 else 0);
- var offer: [acts.len + 1 + std.enums.values(Source).len][]const u8 = undefined;
- var nw: usize = 0;
- for (acts) |act| if (offered(pk, act)) {
- offer[nw] = act.word;
- nw += 1;
- };
- const nacts = nw;
- offer[nw] = "|";
- nw += 1;
- inline for (comptime std.enums.values(Source)) |src| if (src != .list and src != .messages and src != .themes and src != .actions and src != .lists and src != pk.source) {
- offer[nw] = words.get(src).word;
- nw += 1;
- };
- for (offer[0..nw], 0..) |word, i| {
- const gap: usize = @intFromBool(i > 0);
- const rest: usize = if (i + 1 < nw) 2 else 0;
- if (b.col() + gap + File.displayWidth(p.settings.tab, word) + rest > b.width) {
- try b.put(if (gap > 0) " " else "");
- try b.styled("…", .dim);
- break;
- }
- try b.put(if (gap > 0) " " else "");
- if (i >= nacts) try b.styled(word, .dim) else try b.put(word);
- }
+ // Themes, code actions and Lists have no acts: no hint.
+ const hints = text.items.len;
+ if (pk.source != .themes and pk.source != .actions and pk.source != .lists) try b.styled("M-l acts", .dim);
+ try b.right(counted, hints);
var h = b.done();
h.caret = caret;
return h;
}
-/// The band's rows (UX D6): as many as the list will show, from what the
-/// source has (not what the query keeps: typing never moves the body),
-/// four at least, eleven at most, and its `cap` at most (the host pane's
-/// 40 % at open: the layout asks this while it lays the column out, when
-/// no pane has its rows yet).
+/// The band's rows (UX D6, DESIGN O4): as many as the list will show, from
+/// what the source has (not what the query keeps: typing never moves the
+/// body) and the most it has had (`tall`): a list known at open exactly its
+/// rows, one whose rows come later (Find, Grep, All, Symbols) three at
+/// least, growing as they come; eleven at most, and its `cap` at most (the
+/// asking pane's 40 % at open: the layout asks this while it lays the
+/// column out, when no pane has its rows yet).
pub fn bandRows(p: *const Pardes) u16 {
const pk = live(p) orelse return 0;
- const have = if (!fuzzy(pk)) Band.Cursor.shown else pk.names.cands.items.len;
- const rows: usize = @max(1, @min(Band.Cursor.shown, @max(4, have), pk.cap));
+ const later: usize = switch (pk.source) {
+ .find, .grep, .all, .symbols => 3,
+ else => 1,
+ };
+ const rows: usize = @max(1, @min(Band.Cursor.shown, @max(later, pk.tall, have(p, pk)), pk.cap));
// Its second step's rows too: the sources, the acts and what they act on.
return @intCast(switch (pk.spine) {
.sources => @max(rows, spine_rows.len),
@@ -2326,7 +2303,7 @@ test "a picker from a held pane hangs under that pane's tag, which keeps the key
try std.testing.expectEqualStrings("pick", pk.query.slice());
}
-test "a picker's act row is one row under the spines, two cells right of the last: what does not fit dropped from the right, the sources first, a dim `…` ending it" {
+test "a picker's head is one row: the count and one dim hint at its right end, `M-l acts`; no row of acts and sources, the list's rows right under it; Themes hints nothing (UX DESIGN O4)" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 60, .rows = 40 });
defer p.deinit();
p.settings.jumps = .walk;
@@ -2337,25 +2314,31 @@ test "a picker's act row is one row under the spines, two cells right of the las
_ = try p.setTestFile("held\n");
const asker = p.view().active;
Trail.keep(p.panes[asker].?);
+ p.gpa.free(p.panes[asker].?.file.?.path);
+ p.panes[asker].?.file.?.path = try std.Io.Dir.path.join(p.gpa, &.{ std.Io.Dir.path.dirname(a_path).?, "held.txt" });
p.stream.engine = .walk;
open(p, asker, .find, "", "", "");
- const reader = asker;
+ settle(p);
var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
defer frame.deinit();
const a = frame.allocator();
- const tag = try headOf(p, a, reader);
- var rows = std.mem.splitScalar(u8, tag, '\n');
- try std.testing.expect(std.mem.startsWith(u8, rows.next().?, "␣ f Find "));
- const acts_row = rows.next().?;
- try std.testing.expect(rows.next() == null);
- try std.testing.expect(std.mem.startsWith(u8, acts_row, "│ │ Walk Look "));
- try std.testing.expect(std.mem.endsWith(u8, acts_row, " …"));
- try std.testing.expect(File.displayWidth(p.settings.tab, acts_row) <= pardes.tagline.tagWidth(p, reader));
- const h = (try head(p, a, p.panes[reader].?)).?;
+ const tag = try headOf(p, a, asker);
+ try std.testing.expect(std.mem.indexOfScalar(u8, tag, '\n') == null);
+ try std.testing.expect(std.mem.startsWith(u8, tag, "␣ f Find ") and std.mem.endsWith(u8, tag, "1/1 M-l acts"));
+ try std.testing.expectEqual(@as(usize, pardes.tagline.tagWidth(p, asker)), File.displayWidth(p.settings.tab, tag));
+ const h = (try head(p, a, p.panes[asker].?)).?;
try std.testing.expect(h.spans[h.spans.len - 1].style == .dim);
+ // The band's first row the list's first.
+ const band = (try Band.of(p, a, p.panes[asker].?, asker)).?;
+ try std.testing.expect(std.mem.indexOf(u8, (try band.line(a, p.settings.tab, 0)).text, "▶ alpha.zig") != null);
+ p.update(.{ .key = .{ .cp = Key.escape } });
+ open(p, asker, .themes, "", "", "");
+ const themes = try headOf(p, a, asker);
+ try std.testing.expect(std.mem.indexOf(u8, themes, "esc") == null and std.mem.indexOf(u8, themes, "M-l") == null and std.mem.indexOf(u8, themes, "⏎") == null);
+ p.update(.{ .key = .{ .cp = Key.escape } });
}
-test "a picker's band is sized from its list at open, 4 rows at least, and typing never moves it" {
+test "a picker's band is its list's rows (UX DESIGN O4, D6): a list whose rows come later (Find) holds 3 at open, never moved by typing; a list known at open exactly its rows: SPC b b with two panes covers its head and 2 rows" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 40 });
defer p.deinit();
p.settings.jumps = .walk;
@@ -2375,13 +2358,23 @@ test "a picker's band is sized from its list at open, 4 rows at least, and typin
const reader = asker;
p.sync();
const rows = Band.covered(p, p.panes[reader].?, reader).band;
- // One or two files listed: four rows, ground under them.
- try std.testing.expectEqual(@as(u16, 4), rows);
+ // One file listed: three rows, ground under it.
+ try std.testing.expectEqual(@as(u16, 3), rows);
for ("zzq") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } });
settle(p);
p.sync();
try std.testing.expectEqual(@as(usize, 0), count(p, live(p).?));
try std.testing.expectEqual(rows, Band.covered(p, p.panes[reader].?, reader).band);
+ p.update(.{ .key = .{ .cp = Key.escape } });
+ // Two panes: SPC b b's band two rows.
+ p.newScratchBelow(asker);
+ p.view().active = asker;
+ p.sync();
+ for (" bb") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } });
+ p.sync();
+ try std.testing.expectEqual(Source.panes, live(p).?.source);
+ const at = Band.covered(p, p.panes[asker].?, asker);
+ try std.testing.expect(at.head == 1 and at.band == 2);
}
test "a picker's band is capped once at open at 40 % of its asking pane's rows; the pane it previews in borrows from its column for a body of 60 %: a Grep from a held pane at 100x30 previews 8 rows at least, in a reader made under it (UX D6, DESIGN O1)" {
@@ -2407,7 +2400,10 @@ test "a picker's band is capped once at open at 40 % of its asking pane's rows;
const reader = p.paneBySerial(live(p).?.landing).?;
try std.testing.expect(reader != asker);
for ("pub fn") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } });
+ // Its lines after the typing's pause: the band from 3 rows to its cap.
+ if (p.stream.due_ns) |due| p.clock.now_ns = due;
settle(p);
+ try std.testing.expectEqual(@as(usize, 40), count(p, live(p).?));
p.update(.{ .key = .{ .cp = Key.down } });
p.update(.tick);
p.sync();
@@ -2447,7 +2443,7 @@ test "a picker's keys: Tab marks and moves, M-a all and none, C-SPC refines and
var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
defer frame.deinit();
const refs = try headOf(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);
+ try std.testing.expect(std.mem.indexOf(u8, refs, " Refs ") != null and std.mem.endsWith(u8, refs, " 3/4 •1 M-l acts"));
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 } });
@@ -2466,7 +2462,7 @@ test "a picker's keys: Tab marks and moves, M-a all and none, C-SPC refines and
try std.testing.expectEqual(@as(usize, 1), count(p, pk));
_ = frame.reset(.retain_capacity);
const refined = try headOf(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);
+ try std.testing.expect(std.mem.indexOf(u8, refined, " Refs alpha | w ") != null and std.mem.endsWith(u8, refined, " 1/1 M-l acts"));
// 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 e9c231da..d5f9a374 100644
--- a/core/Prompt.zig
+++ b/core/Prompt.zig
@@ -124,24 +124,28 @@ pub const Ring = struct {
const Info = struct {
/// Its key cell.
cell: []const u8,
- hint: []const u8,
};
const info = std.EnumArray(Op, Info).init(.{
- .search = .{ .cell = "/", .hint = "⏎ land · M-⏎ as a list · C-r history · esc" },
- .search_back = .{ .cell = "?", .hint = "⏎ land · M-⏎ as a list · C-r history · esc" },
- .select = .{ .cell = "s", .hint = "⏎ select · M-⏎ as a list · C-r history · esc" },
- .split = .{ .cell = "S", .hint = "⏎ select · M-⏎ as a list · C-r history · esc" },
- .keep = .{ .cell = "K", .hint = "⏎ keep · M-⏎ as a list · C-r history · esc" },
- .remove = .{ .cell = "A-K", .hint = "⏎ keep · M-⏎ as a list · C-r history · esc" },
- .pipe = .{ .cell = "|", .hint = "⏎ replace · C-r history · esc" },
- .pipe_to = .{ .cell = "A-|", .hint = "⏎ run · C-r history · esc" },
- .insert = .{ .cell = "!", .hint = "⏎ insert · C-r history · esc" },
- .append = .{ .cell = "A-!", .hint = "⏎ append · C-r history · esc" },
- .keep_pipe = .{ .cell = "$", .hint = "⏎ keep · C-r history · esc" },
- .command = .{ .cell = ":", .hint = "Tab complete · ⏎ run · C-r history · esc" },
+ .search = .{ .cell = "/" },
+ .search_back = .{ .cell = "?" },
+ .select = .{ .cell = "s" },
+ .split = .{ .cell = "S" },
+ .keep = .{ .cell = "K" },
+ .remove = .{ .cell = "A-K" },
+ .pipe = .{ .cell = "|" },
+ .pipe_to = .{ .cell = "A-|" },
+ .insert = .{ .cell = "!" },
+ .append = .{ .cell = "A-!" },
+ .keep_pipe = .{ .cell = "$" },
+ .command = .{ .cell = ":" },
});
+/// Every prompt's one hint (UX DESIGN O4): the key to what its head and
+/// band do not show. Enter's verb is the head's own `= Look /dirty/`;
+/// M-Enter and Tab are in Help; Esc is never hinted.
+const hint = "C-r history";
+
/// The history `op` reads and Enter adds to.
fn ring(p: *Pardes, op: Op) *Ring {
return switch (op) {
@@ -1097,7 +1101,7 @@ fn strike(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, line: i32, lo_:
}
/// The head of the prompt's tag: `s self▌ = Exec Edit x/self/ 4
-/// selections in 6 lines ⏎ select · M-⏎ as a list · C-r history · esc`.
+/// selections in 6 lines C-r history`.
pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !TagState.Head {
const s = &p.view().tag_state;
const pr = &s.prompt;
@@ -1139,7 +1143,6 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !TagState.Head {
}
if (pr.op == .command) try Command.count(p, arena, text);
const hints = text.items.len;
- const hint = info.get(pr.op).hint;
if (tail) |t| {
// Both beside the count, or neither: as much room as the right
// block asks for its two gaps (Builder.right drops the hints alone).
@@ -1402,9 +1405,10 @@ 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(has(try headOf(p), "s ⏎ select · M-⏎ as a list · C-r history · esc"));
+ // Its one hint at the row's end (UX DESIGN O4).
+ try std.testing.expect(std.mem.startsWith(u8, try headOf(p), "s ") and std.mem.endsWith(u8, try headOf(p), " C-r history"));
typeKeys(p, "self");
- try std.testing.expect(has(try headOf(p), "s self = Exec Edit x/self/ 2 selections in 3 lines ⏎ select"));
+ try std.testing.expect(has(try headOf(p), "s self = Exec Edit x/self/ ") and has(try headOf(p), "2 selections in 3 lines C-r history"));
try std.testing.expectEqual(@as(u16, 1), pane.body.nsel);
try std.testing.expect(selecting(p, pane).?.dim == false);
// No match: 0, and the selection it began with.
@@ -1447,7 +1451,7 @@ test "Enter keeps what s found, the pattern in / and in the history Up brings ba
try std.testing.expect(has(try headOf(p), "K self.. = Exec Edit g/self../ keeps 2 of 2"));
p.update(.{ .key = .{ .cp = Key.down } });
typeKeys(p, "b");
- try std.testing.expect(has(try headOf(p), "K b = Exec Edit g/b/ keeps 1 of 2 ⏎ keep"));
+ try std.testing.expect(has(try headOf(p), "K b = Exec Edit g/b/ ") and has(try headOf(p), "keeps 1 of 2 C-r history"));
// Ctrl-r: the history under the tag, a row a line.
p.update(.{ .key = .{ .cp = 'r', .ctrl = true } });
try std.testing.expectEqual(@as(u16, 1), Band.takes(p, p.view().active));
@@ -1459,7 +1463,7 @@ test "Enter keeps what s found, the pattern in / and in the history Up brings ba
typeKeys(p, "|");
try std.testing.expectEqual(Pane.Prompt.none, pane.prompt);
p.update(.{ .key = .{ .cp = 't', .text = "tr a-z A-Z" } });
- try std.testing.expect(has(try headOf(p), "| tr a-z A-Z = Exec Edit |tr a-z A-Z ⋯ ⏎ replace"));
+ try std.testing.expect(has(try headOf(p), "| tr a-z A-Z = Exec Edit |tr a-z A-Z ") and has(try headOf(p), "⋯ C-r history"));
p.update(.{ .key = .{ .cp = Key.enter } });
try std.testing.expectEqualStrings("tr a-z A-Z", p.registers.value('|', 0).?);
var asked: ?u32 = null;
@@ -1496,7 +1500,7 @@ test "/ searches the body as it is typed: the current place selected, `▸` in t
pane.body.cur_row = 2;
pane.body.cur_col = 6;
typeKeys(p, "/dirty");
- try std.testing.expect(has(try headOf(p), "/ dirty = Look /dirty/ 3/7 · 5 lines ⏎ land · M-⏎ as a list"));
+ try std.testing.expect(has(try headOf(p), "/ dirty = Look /dirty/ ") and has(try headOf(p), "3/7 · 5 lines C-r history"));
try std.testing.expectEqual(@as(?usize, 2), pane.places.current);
// (Its first row under the head's, UX DESIGN M2.)
try std.testing.expectEqualStrings(" ", try gutterAt(p, frame.allocator(), 1));
@@ -1554,9 +1558,9 @@ test "? searches back from the caret; no match is 0; a pattern that is no regex
pane.body.cur_col = 6;
const was = pane.body.primaryRange(pane.file.?.content, 0);
typeKeys(p, "?dirty");
- try std.testing.expect(has(try headOf(p), "? dirty = Look ?dirty? 2/7 · 5 lines ⏎ land"));
+ try std.testing.expect(has(try headOf(p), "? dirty = Look ?dirty? ") and has(try headOf(p), "2/7 · 5 lines C-r history"));
typeKeys(p, "x");
- try std.testing.expect(has(try headOf(p), "= Look ?dirtyx? 0 ⏎ land"));
+ try std.testing.expect(has(try headOf(p), "= Look ?dirtyx? ") and has(try headOf(p), "0 C-r history"));
try std.testing.expectEqualDeep(was, pane.body.primaryRange(pane.file.?.content, 0));
p.update(.{ .key = .{ .cp = Key.backspace } });
typeKeys(p, "(");
@@ -1643,13 +1647,13 @@ test "a pipe prompt runs a known filter live, a run a selection: the outputs gho
p.update(.{ .key = .{ .cp = Key.enter } });
typeKeys(p, "|");
p.update(.{ .key = .{ .cp = 't', .text = "tr a-z A-Z" } });
- try std.testing.expect(has(try headOf(p), "| tr a-z A-Z = Exec Edit |tr a-z A-Z ⋯ ⏎ replace"));
+ try std.testing.expect(has(try headOf(p), "| tr a-z A-Z = Exec Edit |tr a-z A-Z ") and has(try headOf(p), "⋯ C-r history"));
const first = lastPipe(p) orelse return error.MissingLiveRun;
const asked = p.pipe.pipeRequest(first).?;
try std.testing.expectEqual(@as(usize, 2), asked.inputs.len);
try std.testing.expect(has(asked.command, "tr a-z A-Z") and has(asked.command, "\\036"));
p.update(.{ .pipe_resp = .{ .id = first, .success = true, .outputs = &.{ "B\x1e\x1e0", "A\x1e\x1e0" } } });
- try std.testing.expect(has(try headOf(p), " 2 lines → 2 · exit 0 ⏎ replace"));
+ try std.testing.expect(has(try headOf(p), "2 lines → 2 · exit 0 C-r history"));
// The body: each output a ghost line under the line it replaces, the
// rows below pushed down; the text as it was; its first row under the
// head's (UX DESIGN M2).
@@ -1791,7 +1795,7 @@ test "a search's count keeps ` · N lines` after it in the dim ink, and drops it
const h = try head(p, p.scratch.allocator(), pane);
const lines = std.mem.indexOf(u8, h.text, " \u{b7} 5 lines");
if (cols == 200) {
- try std.testing.expect(has(h.text, "3/7 \u{b7} 5 lines \u{23ce} land"));
+ try std.testing.expect(has(h.text, "3/7 \u{b7} 5 lines C-r history"));
const dim = for (h.spans) |span| {
if (span.lo == lines.? and span.style == .dim) break span;
} else return error.TestUnexpectedResult;
@@ -1799,7 +1803,7 @@ test "a search's count keeps ` · N lines` after it in the dim ink, and drops it
} else {
// No room for the hints: the count alone, at the row's end.
try std.testing.expect(lines == null);
- try std.testing.expect(std.mem.indexOf(u8, h.text, "\u{23ce} land") == null);
+ try std.testing.expect(std.mem.indexOf(u8, h.text, "C-r history") == null);
try std.testing.expect(std.mem.endsWith(u8, h.text, "3/7"));
}
}
@@ -1810,7 +1814,7 @@ test "a search's count keeps ` · N lines` after it in the dim ink, and drops it
pane.body.cur_row = 7;
pane.body.cur_col = 6;
typeKeys(p, "/dirty");
- try std.testing.expect(has(try headOf(p), "1/7 \u{21bb} \u{b7} 5 lines \u{23ce} land"));
+ try std.testing.expect(has(try headOf(p), "1/7 \u{21bb} \u{b7} 5 lines C-r history"));
}
test "C-r's history has the band's cursor like any list (UX D5): `▶` on its newest line, Down and C-n, Up and C-p move it, Enter takes the line under it" {
diff --git a/core/TagState.zig b/core/TagState.zig
index 622cb949..9be689c0 100644
--- a/core/TagState.zig
+++ b/core/TagState.zig
@@ -730,14 +730,12 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?Head {
try b.put(" ");
try b.put(c.label);
};
- const hints = b.text.items.len;
- try b.styled("⏎ run · esc", .dim);
- try b.right(hints, hints);
} else try b.put("…");
} else {
+ // The state's question, not a hint (UX DESIGN O4).
try b.put("…");
const hints = b.text.items.len;
- try b.styled("press a key or a sequence · esc", .dim);
+ try b.styled("press a key or a sequence", .dim);
try b.right(hints, hints);
}
return b.done();
@@ -745,7 +743,7 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?Head {
.pick => return @import("Pick.zig").head(p, arena, pane),
.prompt => return try Prompt.head(p, arena, pane),
// `Rename`, the name under the caret struck, the new one typed:
- // `Rename best → top▌ ⏎ rename · esc` (SPEC §3.5).
+ // `Rename best → top▌` (SPEC §3.5), no hint (UX DESIGN O4).
.rename => {
try b.put("Rename ");
try b.styled(Ask.renamedWord(pane) orelse "", .strike);
@@ -753,9 +751,6 @@ 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());
- 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;
@@ -764,10 +759,12 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?Head {
const cur = current(p, v) orelse return null;
try b.keyCells(cur.root, cur.path);
const node = bindings.nodeAt(cur.root, cur.path) orelse return b.done();
+ // One hint, a level's and the registers' (UX DESIGN O4): `? help`.
+ const hint = "? help";
if (s.unrolled) {
try b.put(if (cur.path.len == 0) bindings.info.get(cur.root).label else node.label);
const hints = b.text.items.len;
- try b.styled("↑ roll up · ? field · esc", .dim);
+ try b.styled(hint, .dim);
try b.right(hints, hints);
return b.done();
}
@@ -801,7 +798,6 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?Head {
// level that wraps gives them its spare row, its last child going to
// it to leave them room; a level of one row or of all its rows keeps
// its rows, and they drop where they do not fit.
- const hint = "↓ unroll · ? help";
const hinted = 2 + panes.File.displayWidth(tab, hint);
var rows: usize = 1;
for (level, 0..) |c, i| {
@@ -966,14 +962,14 @@ test "the right block: the count `cursor/matches` at the row's right end, fixed
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.expect(std.mem.endsWith(u8, row, " ? help"));
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 });
+ const narrow = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 14, .rows = 30 });
defer narrow.deinit();
_ = try narrow.setTestFile("one\n");
narrow.update(.{ .key = .{ .cp = ' ' } });
@@ -1024,7 +1020,7 @@ test "a rolled level breaks between its children only: the rows after the first
whole += 1;
}
try std.testing.expect(whole > 0 and whole < level.len);
- try std.testing.expect(std.mem.endsWith(u8, rows[n - 1], try std.fmt.allocPrint(a, "+{d} ↓", .{level.len - whole})));
+ try std.testing.expect(std.mem.indexOf(u8, rows[n - 1], try std.fmt.allocPrint(a, "+{d} ↓", .{level.len - whole})) != null);
// A level that fits takes one row; its hints at its end where the row
// has room for them, else none.
p.update(.{ .key = .{ .cp = 'h' } });
@@ -1494,7 +1490,7 @@ test "a rolled level that wraps has its hints on its last row at every width tha
p.clock.now_ns = p.view().tag_state.due_ns;
try std.testing.expect(hostOf(p) != null);
const tag = try testTag(p, a);
- if (std.mem.count(u8, tag, "\n") == 1) try std.testing.expect(std.mem.endsWith(u8, tag, " ↓ unroll · ? help"));
+ if (std.mem.count(u8, tag, "\n") == 1) try std.testing.expect(std.mem.endsWith(u8, tag, " ? help"));
p.update(.{ .key = .{ .cp = pardes.Key.escape } });
try std.testing.expect(hostOf(p) == null);
};
@@ -1748,7 +1744,7 @@ test "out of rest a tag is drawn as at rest, the head hanging under it (UX DESIG
const head_y: u16 = @intCast(now_y + tag_rows);
const row = try gridRow(a, s, r.x + pardes.TAG_TEXT_INSET, head_y, r.w - pardes.TAG_TEXT_INSET);
try std.testing.expect(std.mem.startsWith(u8, row, "␣ l Refs "));
- try std.testing.expect(std.mem.endsWith(u8, row, " 1/1"));
+ try std.testing.expect(std.mem.endsWith(u8, row, " 1/1 M-l acts"));
// The band's first row under the head's: the list's row, its cursor's.
const band_y: u16 = head_y + Band.covered(p, pane, id).head;
try std.testing.expect(std.mem.indexOf(u8, try gridRow(a, s, r.x + pardes.TAG_TEXT_INSET, band_y, r.w - pardes.TAG_TEXT_INSET), "▶ near.txt:3") != null);
diff --git a/core/draw.zig b/core/draw.zig
index a94c8e60..de47f469 100644
--- a/core/draw.zig
+++ b/core/draw.zig
@@ -1908,7 +1908,7 @@ test "a tag out of rest draws its keys bold in the key ink and its hint in the d
const a = frame.allocator();
const roles = &p.chromeTheme().roles;
const inks = roles.on(if (pardes.Trail.reading(p, pane)) .reading_focused else .focused);
- // SPC's level rolled, after its delay: `␣ ▸ … l lsp… … ↓ unroll · ? help`.
+ // SPC's level rolled, after its delay: `␣ ▸ … l lsp… … ? help`.
p.clock.now_ns = 5 * std.time.ns_per_s;
p.clock.stepped_ns = p.clock.now_ns;
p.update(.{ .key = .{ .cp = ' ' } });
@@ -1930,7 +1930,7 @@ test "a tag out of rest draws its keys bold in the key ink and its hint in the d
return null;
}
};
- const hint = Row.find(row, "unroll").?;
+ const hint = Row.find(row, "? help").?;
try std.testing.expectEqual(Color{ .rgb = inks.dim }, row[hint].style.fg);
for (row) |cell| try std.testing.expect(!cell.style.dim);
var keys: usize = 0;
diff --git a/core/views.zig b/core/views.zig
index 79fff084..75e2e5d9 100644
--- a/core/views.zig
+++ b/core/views.zig
@@ -615,7 +615,7 @@ test "a view not live with its band open, dumped and loaded, draws before its ne
test "a picker's band in a short column, dumped and loaded: its rows are the never-loaded session's, and so is the next layout" {
const gpa = std.testing.allocator;
const dump = @import("dump.zig");
- const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 15 });
+ const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 14 });
defer p.deinit();
p.settings.jumps = .walk;
var tmp = std.testing.tmpDir(.{});
@@ -631,17 +631,17 @@ test "a picker's band in a short column, dumped and loaded: its rows are the nev
const low = p.view().active;
p.view().active = host;
p.sync();
- // Find in the pane itself (it reads): its head and its act row over
- // the band, which the short column holds under what it wants.
+ // Find in the pane itself (it reads): its head over the band, which
+ // the short column holds under what it wants.
p.stream.engine = .walk;
pardes.Pick.open(p, host, .find, "", "", "");
p.sync();
const at = pardes.Band.covered(p, pane, host);
try testing.expect(at.band > 0 and at.band < pardes.Band.takes(p, host));
- try testing.expect(at.head >= 2);
+ try testing.expect(at.head == 1);
const bytes = try dump.byteDump(p);
defer gpa.free(bytes);
- const q = try dump.load(gpa, .{ .tty_only = true, .cols = 40, .rows = 15 }, bytes, null);
+ const q = try dump.load(gpa, .{ .tty_only = true, .cols = 40, .rows = 14 }, bytes, null);
defer q.deinit();
try testing.expectEqual(pane.view.covered, q.panes[host].?.view.covered);
try testing.expectEqual(pane.tag_rows, q.panes[host].?.tag_rows);