diff options
Diffstat (limited to 'core/Core.zig')
| -rw-r--r-- | core/Core.zig | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/core/Core.zig b/core/Core.zig index f47cc5d8..a22822c2 100644 --- a/core/Core.zig +++ b/core/Core.zig @@ -1167,14 +1167,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 |_| {} } @@ -2018,7 +2017,7 @@ pub fn sync(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; @@ -2579,9 +2578,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; @@ -2608,10 +2608,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, @@ -2627,9 +2628,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) { @@ -2701,12 +2703,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); @@ -2767,7 +2771,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); @@ -2797,7 +2801,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); @@ -2809,7 +2815,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); @@ -3081,7 +3087,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. @@ -3284,7 +3290,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" { @@ -3310,7 +3316,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. @@ -3350,7 +3356,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); @@ -3368,7 +3374,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; @@ -3390,7 +3396,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; |
