summaryrefslogtreecommitdiff
path: root/core/Core.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/Core.zig')
-rw-r--r--core/Core.zig189
1 files changed, 98 insertions, 91 deletions
diff --git a/core/Core.zig b/core/Core.zig
index 4c98977a..3a2e1f51 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -351,8 +351,6 @@ custom_theme: ?LegacyTheme = null,
/// session's own theme untouched under it.
theme_preview: ?u16 = null,
preview_chrome: ChromeTheme = undefined,
-/// bodyChrome's: the theme it was worked out for, and it.
-body_chrome: ?struct { theme: LegacyTheme, chrome: ChromeTheme } = null,
theme_file_path: config.Settings.Text(limits.host_path_cap) = .{},
/// The ThemeFile last loaded whole: what /ctl and DumpConfig name, and
/// what a failed ThemeFile goes back to (colors.revertThemeFile).
@@ -547,7 +545,7 @@ pub const replica = .{
"opts", "dump_out", "dump_export",
"tape",
},
- .derived = .{ "shell_rows", "diff_output", "locations_cache", "retired_panes", "tty_filter_palette", "body_chrome", "theme_preview", "preview_chrome" },
+ .derived = .{ "shell_rows", "diff_output", "locations_cache", "retired_panes", "tty_filter_palette", "theme_preview", "preview_chrome" },
// The host's handles, the state file every session of the user
// shares (and Recent read from it), this session's closed panes, and
// the files of a host with no file system of its own. (The 9P
@@ -1006,24 +1004,11 @@ fn setLastDumpInner(p: *Pardes, path: []const u8) void {
ctlfs.events.notePath(p, "dump", path);
}
-/// The workspace tag's `Restore <path>` names `path` from now on: the
-/// default's does by itself, and one the tag was edited around (its own
-/// text) has the old path swapped, never left pointing at a dump that is
-/// not the last.
+/// The window row's `Restore <path>` names `path` from now on: a computed
+/// word (UX K'2, tagline.headerWords), never the user's text.
pub fn pointRestoreAt(p: *Pardes, path: []const u8) void {
const copy = p.gpa.dupe(u8, path) catch |err| return p.reportError(.at(p.view().active), "Restore", err);
- if (p.last_dump) |old| {
- if (p.global_tag.own) |own| swap: {
- const a = p.scratch.allocator();
- const was = std.fmt.allocPrint(a, "Restore {s}", .{old}) catch break :swap;
- if (std.mem.indexOf(u8, own, was) == null) break :swap;
- const now = std.fmt.allocPrint(a, "Restore {s}", .{path}) catch break :swap;
- const swapped = std.mem.replaceOwned(u8, p.gpa, own, was, now) catch break :swap;
- p.gpa.free(own);
- p.global_tag.own = swapped;
- }
- p.gpa.free(old);
- }
+ if (p.last_dump) |old| p.gpa.free(old);
p.last_dump = copy;
}
@@ -1172,14 +1157,13 @@ fn acknowledgeShellInner(p: *Pardes, id: Pane.Id, executable: []const u8, prompt
pane.greeted = false;
pane.had_shell = true;
pane.fs.unmarked = !prompt_marks;
- // The tag's Term word names the shell the host ran, and a click
- // on it (`Term+fish`) opens another of the same.
+ // The tag's text names the shell the host ran (tagline.defaultTail),
+ // and a click on it (`Term+fish`) opens another of the same.
if (pane.command == null) {
// A shell given as a path keeps it: its bare name would find
// nothing, or another program, on the usual paths.
const base = if (pane.shell) |given| (if (std.mem.indexOfScalar(u8, given, '/') != null) given else std.Io.Dir.path.basename(executable)) else std.Io.Dir.path.basename(executable);
- const rest = tagline.terminal_pane_tail[" Term".len..];
- if (std.fmt.bufPrint(&pane.shell_tail, " Term+{s}{s}", .{ base, rest })) |tail| {
+ if (std.fmt.bufPrint(&pane.shell_tail, "Term+{s}", .{base})) |tail| {
pane.shell_tail_len = @intCast(tail.len);
} else |_| {}
}
@@ -2021,7 +2005,9 @@ pub fn layOut(p: *Pardes) void {
// A file opened or closed this step: the kept list follows.
p.saveRecent();
tagline.flattenHeaders(p);
- if (p.headerColumn() != null and layout.columnBarHeight(p) == 0) {
+ // A column's tag with no row to be in lets the keyboard go; a lone
+ // column's keeps it in the window row (UX K'2).
+ if (p.headerColumn() != null and layout.columnBarHeight(p) == 0 and !layout.columnInWindowRow(p)) {
tagline.exitHeader(p);
}
pardes.panes.reapPanes(p);
@@ -2061,7 +2047,7 @@ pub fn layOut(p: *Pardes) void {
const prefix: ?[]const u8 = tagline.prefixIn(p, wa, pane) catch null;
// The tag's cursor and selections are offsets in its text at rest:
// a head shown over its own text moves none of them (UX D1).
- const at_rest = if (pardes.Trail.outOfRest(p, pane)) tagline.restPrefix(p, wa, pane) catch null else prefix;
+ const at_rest = if (pardes.Trail.outOfRest(p, pane) or pardes.TagState.asks(p, pane)) tagline.restPrefix(p, wa, pane) catch null else prefix;
const lead = if (at_rest) |made| made.len else pane.tag_lead;
if (lead != pane.tag_lead) {
const t = &pane.tag;
@@ -2187,10 +2173,11 @@ fn sizes(p: *const Pardes, pane: *const Pane) bool {
return pane.sized_by == p.live;
}
+/// The theme in the old names, for what still reads a theme's own
+/// fields (colors.ChromeTheme.view).
pub fn theme(p: *const Pardes) *const LegacyTheme {
- if (p.theme_preview) |i| return &colors.legacy_themes[i];
- if (p.custom_theme) |*custom| return custom;
- return &colors.legacy_themes[p.settings.theme];
+ if (p.theme_preview == null) if (p.custom_theme) |*custom| return custom;
+ return &p.chromeTheme().view;
}
/// The colours of the chrome: the theme's, set as it changes.
@@ -2205,16 +2192,6 @@ pub fn chrome(p: *const Pardes) *const colors.Chrome {
return &p.chromeTheme().resolved;
}
-/// The theme's own chrome, not a fade's (`theme()`'s, worked out once
-/// per theme: its contrast searches take pow calls, too many for a
-/// grapheme or a row).
-pub fn bodyChrome(p: *Pardes) *const ChromeTheme {
- const th = p.theme();
- if (p.body_chrome) |*cached| if (std.meta.eql(cached.theme, th.*)) return &cached.chrome;
- p.body_chrome = .{ .theme = th.*, .chrome = ChromeTheme.fromTheme(th) };
- return &p.body_chrome.?.chrome;
-}
-
/// When the core next needs a frame, on the `stepped_ns` timeline: a
/// frame from now while work goes on (places to find, a picture
/// decoding, a PDF page on a lane), the end of the wait while something
@@ -2585,25 +2562,30 @@ test "topbar hover highlights exactly the executable word" {
defer frame.deinit();
_ = try p.render(frame.allocator());
- p.update(.{ .mouse = .{ .button = .none, .kind = .motion, .col = TAG_TEXT_INSET + 1, .row = 0 } });
- _ = frame.reset(.retain_capacity);
- const hovered = try p.render(frame.allocator());
- for (0.."Newcol".len) |col| {
- const cell = hovered.at(TAG_TEXT_INSET + @as(u16, @intCast(col)), 0);
- try std.testing.expectEqual(Color{ .rgb = p.theme().sel_bg }, cell.style.bg);
- try std.testing.expectEqual(Color{ .rgb = p.theme().sel_fg }, cell.style.fg);
- }
- try std.testing.expectEqual(Color{ .rgb = p.chromeTheme().tag_bg }, hovered.at(TAG_TEXT_INSET + 6, 0).style.bg);
+ // Each side of the window row (UX K'2): the lone column's `New`, then
+ // the window's `Find`.
+ const words = tagline.windowRow(p).words;
+ for ([_]struct { at: u16, len: u16 }{ .{ .at = TAG_TEXT_INSET, .len = "New".len }, .{ .at = words, .len = "Find".len } }) |word| {
+ p.update(.{ .mouse = .{ .button = .none, .kind = .motion, .col = word.at + 1, .row = 0 } });
+ _ = frame.reset(.retain_capacity);
+ const hovered = try p.render(frame.allocator());
+ for (0..word.len) |col| {
+ const cell = hovered.at(word.at + @as(u16, @intCast(col)), 0);
+ try std.testing.expectEqual(Color{ .rgb = p.theme().sel_bg }, cell.style.bg);
+ try std.testing.expectEqual(Color{ .rgb = p.theme().sel_fg }, cell.style.fg);
+ }
+ try std.testing.expectEqual(Color{ .rgb = p.chromeTheme().tag_bg }, hovered.at(word.at + word.len, 0).style.bg);
- p.update(.{ .mouse = .{ .button = .none, .kind = .motion, .col = TAG_TEXT_INSET + 6, .row = 0 } });
- _ = frame.reset(.retain_capacity);
- const whitespace = try p.render(frame.allocator());
- try std.testing.expectEqual(Color{ .rgb = p.chromeTheme().tag_bg }, whitespace.at(TAG_TEXT_INSET + 1, 0).style.bg);
+ p.update(.{ .mouse = .{ .button = .none, .kind = .motion, .col = word.at + word.len, .row = 0 } });
+ _ = frame.reset(.retain_capacity);
+ const whitespace = try p.render(frame.allocator());
+ try std.testing.expectEqual(Color{ .rgb = p.chromeTheme().tag_bg }, whitespace.at(word.at + 1, 0).style.bg);
+ }
p.update(.pointer_leave);
_ = frame.reset(.retain_capacity);
const left = try p.render(frame.allocator());
- try std.testing.expectEqual(Color{ .rgb = p.chromeTheme().tag_bg }, left.at(TAG_TEXT_INSET + 1, 0).style.bg);
+ try std.testing.expectEqual(Color{ .rgb = p.chromeTheme().tag_bg }, left.at(words + 1, 0).style.bg);
}
test "pane-tag Exec prefers Term and argument builtins before shell fallback" {
@@ -2614,9 +2596,10 @@ test "pane-tag Exec prefers Term and argument builtins before shell fallback" {
while (p.nextEffect()) |_| {} // initial shell spawn/geometry
p.acknowledgeShell(.at(0), "/bin/sh", false);
- // The Term word names the shell the host ran, and opens another of it.
+ // The Term word names the shell the host ran, and opens another of it:
+ // the tag's text after its computed Del (UX K'3).
const pane = p.panes[0].?;
- try std.testing.expectEqualStrings(" Term+sh" ++ tagline.terminal_pane_tail[" Term".len..], tagline.curTail(pane));
+ try std.testing.expectEqualStrings("Term+sh", tagline.curTail(pane));
const tag_x = p.view().rects[0].x + TAG_TEXT_INSET;
const tag_y = p.view().rects[0].y;
@@ -2643,10 +2626,11 @@ test "pane-tag Exec prefers Term and argument builtins before shell fallback" {
// Argument-taking builtins use the same gesture path: a tag sweep is the
// complete command line, and Theme consumes its tail without a PTY write.
if (pane.tag.own) |own| p.gpa.free(own);
- pane.tag.own = try p.gpa.dupe(u8, " Theme dark");
- p.update(.{ .mouse = .{ .button = config.exec_button, .kind = .press, .col = tag_x + 1, .row = tag_y } });
- p.update(.{ .mouse = .{ .button = config.exec_button, .kind = .drag, .col = tag_x + 10, .row = tag_y } });
- p.update(.{ .mouse = .{ .button = config.exec_button, .kind = .release, .col = tag_x + 10, .row = tag_y } });
+ pane.tag.own = try p.gpa.dupe(u8, "Theme dark");
+ const theme_x = tag_x + @as(u16, @intCast(std.mem.indexOf(u8, try tagline.tagText(p, p.scratch.allocator(), pane), "Theme dark").?));
+ p.update(.{ .mouse = .{ .button = config.exec_button, .kind = .press, .col = theme_x, .row = tag_y } });
+ p.update(.{ .mouse = .{ .button = config.exec_button, .kind = .drag, .col = theme_x + 9, .row = tag_y } });
+ p.update(.{ .mouse = .{ .button = config.exec_button, .kind = .release, .col = theme_x + 9, .row = tag_y } });
try std.testing.expectEqualStrings("dark", p.theme().name);
while (p.nextEffect()) |effect| switch (effect) {
.write => return error.ArgumentBuiltinFellThroughToPty,
@@ -2662,9 +2646,10 @@ test "pane-tag Exec prefers Term and argument builtins before shell fallback" {
// A word absent from the builtin vocabulary takes the fallback, including
// the terminating carriage return expected by the shell prompt.
if (pane.tag.own) |own| p.gpa.free(own);
- pane.tag.own = try p.gpa.dupe(u8, " DefinitelyNotABuiltin");
- p.update(.{ .mouse = .{ .button = config.exec_button, .kind = .press, .col = tag_x + 1, .row = tag_y } });
- p.update(.{ .mouse = .{ .button = config.exec_button, .kind = .release, .col = tag_x + 1, .row = tag_y } });
+ pane.tag.own = try p.gpa.dupe(u8, "DefinitelyNotABuiltin");
+ const word_x = tag_x + @as(u16, @intCast(std.mem.indexOf(u8, try tagline.tagText(p, p.scratch.allocator(), pane), "Definitely").?)) + 1;
+ p.update(.{ .mouse = .{ .button = config.exec_button, .kind = .press, .col = word_x, .row = tag_y } });
+ p.update(.{ .mouse = .{ .button = config.exec_button, .kind = .release, .col = word_x, .row = tag_y } });
var sent: [256]u8 = undefined;
var sent_len: usize = 0;
while (p.nextEffect()) |effect| switch (effect) {
@@ -2736,12 +2721,14 @@ test "TreeContext command and custom tag survive a workspace round trip" {
defer p.deinit();
const pane = try p.setTestFile("pub fn main() void {}\n");
try std.testing.expect(!pardes.panes.File.supportsContext(pane));
- try std.testing.expectEqualStrings(tagline.file_pane_tail, tagline.curTail(pane));
+ try std.testing.expectEqualStrings(tagline.file_pane_tail, tagline.kindTail(pane));
const path = try p.gpa.dupe(u8, "/test.zig");
p.gpa.free(pane.file.?.path);
pane.file.?.path = path;
if (!pardes.panes.File.supportsContext(pane)) return error.SkipZigTest;
- try std.testing.expectEqualStrings(if (lsp.speaks("/test.zig")) tagline.lsp_context_pane_tail else tagline.context_pane_tail, tagline.curTail(pane));
+ // TreeContext is a word of its kind's (`:`'s, UX K'4), not its tag's.
+ try std.testing.expectEqualStrings(if (lsp.speaks("/test.zig")) tagline.lsp_context_pane_tail else tagline.context_pane_tail, tagline.kindTail(pane));
+ try std.testing.expect(std.mem.indexOf(u8, try tagline.tagText(p, p.scratch.allocator(), pane), "TreeContext") == null);
try std.testing.expect(!pane.file.?.tree_context);
try std.testing.expect(p.executeBuiltinLine(0, "TreeContext on"));
try std.testing.expect(pane.file.?.tree_context);
@@ -2802,7 +2789,7 @@ test "Filter is ordered after Del and toggles only its terminal or +Pager pane"
const pager_id = try pardes.panes.Output.openPager(p, 0, "/tmp");
const pager_pane = p.panes[pager_id].?;
try testing.expect(pager_pane.tty_filter);
- try testing.expectEqualStrings(tagline.pager_pane_tail, tagline.curTail(pager_pane));
+ try testing.expectEqualStrings(" Filter Del", tagline.computedWords(pager_pane));
try testing.expectEqual(@as(u16, 0), pardes.panes.File.gutterWidth(pager_pane));
try testing.expect(p.executeBuiltinLine(pager_id, "Filter"));
try testing.expect(!pager_pane.tty_filter);
@@ -2832,7 +2819,9 @@ test "compact tag commands stay beside their own prefix across layout changes" {
defer gpa.free(above_tag);
const below_tag = try tagline.tagText(p, p.scratch.allocator(), below);
try std.testing.expect(below_tag.len > above_tag.len);
- const tail = tagline.terminal_pane_tail;
+ // Its computed Del, the blank before its own text (UX K'1), and that
+ // text: Term, its shell not yet named.
+ const tail = " Del Term";
try std.testing.expectEqualStrings(tail, above_tag[above_tag.len - tail.len ..]);
try std.testing.expectEqual(above.cwdSlice().len + tail.len, above_tag.len);
@@ -2844,7 +2833,7 @@ test "compact tag commands stay beside their own prefix across layout changes" {
try std.testing.expectEqualStrings(above_tag, try tagline.tagText(p, p.scratch.allocator(), above));
p.update(.{ .resize = .{ .cols = 100, .rows = 30 } });
while (p.nextEffect()) |_| {}
- try std.testing.expectEqualStrings(tail, tagline.curTail(below));
+ try std.testing.expectEqualStrings("Term", tagline.curTail(below));
try below.appendTag(" lots and lots of typing out here");
try std.testing.expectEqual(above_tag.len, (try tagline.tagText(p, p.scratch.allocator(), above)).len);
@@ -3116,7 +3105,7 @@ test "a REPL bound for a language takes the exec made on a body in it; tags, Exe
try std.testing.expect(p.executeBuiltinLine(1, "Repl PY"));
var idbuf: [48]u8 = undefined;
try std.testing.expectEqualStrings("python-a", exec.replId(&idbuf, p.panes[1].?));
- try std.testing.expect(std.mem.endsWith(u8, try tagline.tagPrefix(p, p.panes[1].?), " python-a"));
+ try std.testing.expect(std.mem.endsWith(u8, try tagline.pathPrefix(p, p.scratch.allocator(), p.panes[1].?), " python-a"));
Sent.drain(p);
// A click on the file's body, a single word: typed into the REPL.
@@ -3319,7 +3308,7 @@ test "a Term started by a shell's path keeps the path in its Term+ word" {
try std.testing.expect(p.executeBuiltinLine(0, "Term /bin/sh"));
try std.testing.expect(p.view().active != 0);
p.acknowledgeShell(.at(p.view().active), "/bin/sh", false);
- try std.testing.expect(std.mem.startsWith(u8, tagline.curTail(p.panes[p.view().active].?), " Term+/bin/sh "));
+ try std.testing.expectEqualStrings("Term+/bin/sh", tagline.curTail(p.panes[p.view().active].?));
}
test "Tty, Term's old name in saved tags, runs as Term, bare and with its +shell" {
@@ -3345,7 +3334,7 @@ test "Term+fish, one word a tag can hold, opens a terminal on that shell" {
try std.testing.expect(p.view().active != 0);
try std.testing.expectEqualStrings("sh", p.panes[p.view().active].?.shell.?);
p.acknowledgeShell(.at(p.view().active), "/bin/sh", false);
- try std.testing.expect(std.mem.startsWith(u8, tagline.curTail(p.panes[p.view().active].?), " Term+sh "));
+ try std.testing.expectEqualStrings("Term+sh", tagline.curTail(p.panes[p.view().active].?));
p.view().active = 0;
// A shell that is not there is said, not quietly replaced, and the
// pane that asked gets no shell of its own.
@@ -3385,7 +3374,7 @@ test "a command pane shows how its command ended, and the next command there run
}
var frame = std.heap.ArenaAllocator.init(gpa);
defer frame.deinit();
- try std.testing.expect(std.mem.endsWith(u8, try tagline.tagPrefix(p, pane), "(make -j8) running"));
+ try std.testing.expect(std.mem.endsWith(u8, try tagline.pathPrefix(p, p.scratch.allocator(), pane), "(make -j8) running"));
// Running, a second command goes to a pane of its own.
const other = exec.execute(p, 1, "ls") orelse return error.NoCommandPane;
try std.testing.expect(other != dst);
@@ -3403,7 +3392,7 @@ test "a command pane shows how its command ended, and the next command there run
try std.testing.expect(p.panes[dst] == pane and !pane.command_pty);
try std.testing.expect(p.panes[dst] == pane);
try std.testing.expect(pane.command_done);
- try std.testing.expect(std.mem.endsWith(u8, try tagline.tagPrefix(p, pane), "(make -j8) exit 2"));
+ try std.testing.expect(std.mem.endsWith(u8, try tagline.pathPrefix(p, p.scratch.allocator(), pane), "(make -j8) exit 2"));
// Kill leaves a finished one be.
try std.testing.expect(p.executeBuiltinLine(0, "Kill make"));
while (p.nextEffect()) |effect| if (effect == .signal_pty and effect.signal_pty.pane.index() == dst) return error.SignalledAFinishedCommand;
@@ -3425,7 +3414,7 @@ test "a command pane shows how its command ended, and the next command there run
const ended = std.mem.indexOf(u8, body, "exit 2") orelse return error.ExitLost;
const next = std.mem.indexOf(u8, body, "% make test") orelse return error.NoSeparator;
try std.testing.expect(said < ended and ended < next);
- try std.testing.expect(std.mem.endsWith(u8, try tagline.tagPrefix(p, pane), "(make test) running"));
+ try std.testing.expect(std.mem.endsWith(u8, try tagline.pathPrefix(p, p.scratch.allocator(), pane), "(make test) running"));
// Kill stops a running one: its whole process group, SIGTERM.
try std.testing.expect(p.executeBuiltinLine(0, "Kill make"));
var signalled = false;
@@ -3786,18 +3775,17 @@ test "tabbed file aligns syntax cursor and mouse at the nearest insertion gap" {
try std.testing.expect(look.expandedSel(p, pane, .{ .state = .dragging, .c0 = separator, .c1 = separator, .r0 = BOX_H, .r1 = BOX_H }) == null);
}
-test "the workspace tag's Restore word names the last dump, the tag edited around it or not, across a Restore too" {
+test "the window row's Restore word names the last dump, the user's text after it, across a Restore too (UX K'2)" {
const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 20, .tty_only = true });
defer p.deinit();
p.setLastDump("/tmp/a.zon");
- // The tag edited: its own text holds the Restore word as it was then.
- p.global_tag.own = try p.gpa.dupe(u8, try std.fmt.allocPrint(p.scratch.allocator(), "{s} Mine", .{tagline.headerDefault(p, .workspace)}));
+ p.global_tag.own = try p.gpa.dupe(u8, "Mine");
p.setLastDump("/tmp/b.zon");
- try std.testing.expect(std.mem.indexOf(u8, p.global_tag.own.?, "Restore /tmp/b.zon Mine") != null);
+ try std.testing.expectEqualStrings("Find Grep Newcol Help Exit Restore /tmp/b.zon Mine", tagline.topbar(p));
try dump.dumpState(p);
const restored = try dump.restore(p, p.dump_out.?, "/tmp/c.zon");
defer restored.deinit();
- try std.testing.expect(std.mem.indexOf(u8, restored.global_tag.own.?, "Restore /tmp/c.zon Mine") != null);
+ try std.testing.expectEqualStrings("Find Grep Newcol Help Exit Restore /tmp/c.zon Mine", tagline.topbar(restored));
try std.testing.expectEqualStrings("/tmp/c.zon", restored.last_dump.?);
}
@@ -3806,27 +3794,45 @@ test "editable workspace and column tags are typed into and persist" {
defer p.deinit();
_ = try p.setTestFile("untouched\n");
p.presented();
- try std.testing.expectEqual(TOPBAR_H + COLBAR_H, p.view().rects[0].y);
+ // One column: its tag in the window row, no column row (UX K'2).
+ try std.testing.expectEqual(TOPBAR_H, p.view().rects[0].y);
+ const words = tagline.windowRow(p).words;
// a sweep over a header is its selection, the caret where it ended
- p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = TAG_TEXT_INSET, .row = 0 } });
- p.update(.{ .mouse = .{ .button = .left, .kind = .drag, .col = TAG_TEXT_INSET + 6, .row = 0 } });
- p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = TAG_TEXT_INSET + 6, .row = 0 } });
+ p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = words, .row = 0 } });
+ p.update(.{ .mouse = .{ .button = .left, .kind = .drag, .col = words + 6, .row = 0 } });
+ p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = words + 6, .row = 0 } });
try std.testing.expect(p.global_tag.vsel.active and p.global_tag.vsel.col == 0 and p.global_tag.cur_col == 6);
- // A clicked header is in normal mode: `a` types after the sweep's
- // last character, the blank it ended on.
+ // A clicked header is in normal mode: `a` types after the sweep's last
+ // character, in the computed words: refused, they are no one's.
p.update(.{ .key = .{ .cp = 'a', .text = "a" } });
p.update(.{ .key = .{ .cp = 'H', .text = "Help " } });
- try std.testing.expect(std.mem.startsWith(u8, p.global_tag.own.?, "Newcol Help Joincol"));
+ try std.testing.expect(p.global_tag.own == null);
p.update(.{ .key = .{ .cp = Key.escape } });
- p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = TAG_TEXT_INSET, .row = TOPBAR_H } });
- p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = TAG_TEXT_INSET, .row = TOPBAR_H } });
+ // After them, the user's text.
+ const end: u16 = @intCast(words + "Find Grep Newcol Help Exit ".len);
+ p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = end, .row = 0 } });
+ p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = end, .row = 0 } });
+ p.update(.{ .key = .{ .cp = 'i', .text = "i" } });
+ p.update(.{ .key = .{ .cp = 'H', .text = "Help " } });
+ try std.testing.expectEqualStrings("Help ", p.global_tag.own.?);
+ try std.testing.expectEqualStrings("Find Grep Newcol Help Exit Help ", tagline.topbar(p));
+ p.update(.{ .key = .{ .cp = Key.escape } });
+ // The column's tag, at the window row's left: typed into, it has the
+ // user's text and the column row comes for it; emptied, it goes.
+ const own: u16 = TAG_TEXT_INSET + "New Term ".len;
+ p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = own, .row = 0 } });
+ p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = own, .row = 0 } });
+ try std.testing.expectEqual(@as(?usize, 0), p.headerColumn());
p.update(.{ .key = .{ .cp = 'i', .text = "i" } });
p.update(.{ .key = .{ .cp = 'é', .text = "é" } });
- try std.testing.expect(std.mem.startsWith(u8, tagline.columnTag(p, 0), "éNew"));
+ try std.testing.expectEqualStrings("New Term é", tagline.columnTag(p, 0));
+ try std.testing.expectEqual(TOPBAR_H + COLBAR_H, p.view().rects[0].y);
p.update(.{ .key = .{ .cp = Key.backspace } });
- try std.testing.expect(std.mem.startsWith(u8, tagline.columnTag(p, 0), "New"));
+ try std.testing.expectEqualStrings("New Term ", tagline.columnTag(p, 0));
+ try std.testing.expectEqual(TOPBAR_H, p.view().rects[0].y);
+ try std.testing.expectEqual(@as(?usize, 0), p.headerColumn());
p.update(.{ .paste = "Grep " });
- try std.testing.expect(std.mem.startsWith(u8, tagline.columnTag(p, 0), "Grep New"));
+ try std.testing.expectEqualStrings("New Term Grep ", tagline.columnTag(p, 0));
try std.testing.expectEqualStrings("untouched\n", p.panes[0].?.file.?.content);
try dump.dumpState(p);
const restored = try dump.restore(p, p.dump_out.?, "test");
@@ -3838,7 +3844,7 @@ test "editable workspace and column tags are typed into and persist" {
try dump.dumpState(p);
const empty = try dump.restore(p, p.dump_out.?, "test");
defer empty.deinit();
- try std.testing.expectEqualStrings("", tagline.columnTag(empty, 0));
+ try std.testing.expectEqualStrings("New Term ", tagline.columnTag(empty, 0));
}
test "column tag first-cell execution keeps New local to the clicked column" {
@@ -3866,6 +3872,7 @@ test "a screen too short for the column row releases a column tag's focus withou
defer p.deinit();
const pane = try p.setTestFile("unchanged body\n");
p.view().col_tags[0].own = try p.gpa.dupe(u8, "New Help");
+ p.sync();
p.presented();
const shown = p.view().rects[0];
try std.testing.expectEqual(TOPBAR_H + COLBAR_H, shown.y);
@@ -3879,7 +3886,7 @@ test "a screen too short for the column row releases a column tag's focus withou
try std.testing.expect(p.view().header == null and p.headerColumn() == null);
p.update(.{ .resize = .{ .cols = 60, .rows = 12 } });
try std.testing.expectEqual(shown, p.view().rects[0]);
- try std.testing.expectEqualStrings("New Help", tagline.columnTag(p, 0));
+ try std.testing.expectEqualStrings("New Term New Help", tagline.columnTag(p, 0));
try std.testing.expectEqualStrings("unchanged body\n", pane.file.?.content);
}