diff options
Diffstat (limited to 'core/builtins.zig')
| -rw-r--r-- | core/builtins.zig | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/core/builtins.zig b/core/builtins.zig index 718a0f1f..c7e821dd 100644 --- a/core/builtins.zig +++ b/core/builtins.zig @@ -1814,6 +1814,7 @@ pub const Grep = struct { /// stays, its count 0; the write hears `not found`. fn search(c: Ctx, source: panes.Query.Source, miss: []const u8) void { const pat = std.mem.trim(u8, c.arg orelse "", " \t\r\n"); + if (pardes.Pick.asked(c.p)) return pardes.Pick.open(c.p, c.id, if (source == .find) .find else .grep, "", pat, ""); const reused = panes.Query.ofOwner(c.p, c.pane.serial) != null; panes.Query.open(c.p, c.id, source, pat, pat.len == 0); if (pat.len == 0 or !c.p.fs.serving) return; @@ -1836,6 +1837,11 @@ pub const Search = struct { pub fn run(c: Ctx) void { const line = std.mem.trim(u8, c.arg orelse "", " \t\r\n"); const asked = panes.Query.parse(line) orelse panes.Query.parse(std.mem.concat(c.p.scratch.allocator(), u8, &.{ "/", line }) catch return).?; + // `SPC b b`, `SPC s s`, `SPC /` and the like: a picker in the tag. + if (pardes.Pick.asked(c.p)) switch (asked.source) { + inline .find, .grep, .recent, .panes, .symbols, .all => |s| return pardes.Pick.open(c.p, c.id, @field(pardes.Pick.Source, @tagName(s)), "", asked.pat, ""), + else => {}, + }; panes.Query.open(c.p, c.id, asked.source, asked.pat, true); } }; @@ -1857,6 +1863,7 @@ pub const Panes = struct { pub const takes_arg = true; pub const quiet = true; pub fn run(c: Ctx) void { + if (pardes.Pick.asked(c.p)) return pardes.Pick.open(c.p, c.id, .panes, "", std.mem.trim(u8, c.arg orelse "", " \t\r\n"), ""); panes.Query.open(c.p, c.id, .panes, std.mem.trim(u8, c.arg orelse "", " \t\r\n"), true); } }; @@ -2011,6 +2018,27 @@ pub const Forward = struct { } }; +/// Reopen the last picker as it was: its rows, marks, cursor and query. +/// +/// In the tag of the pane its Enter lands in from this one: this pane if it +/// reads, else its reader. `SPC '`. +pub const Resume = struct { + pub fn run(c: Ctx) void { + pardes.Pick.resumeFrom(c.p, c.id); + } +}; + +/// Keep this pane: a reading pane, which a jump steps, is held from now on. +/// +/// Its walk leaves its tag (its places, its owner): the next jump from its +/// owner makes a new reader. Editing a reading pane keeps it too. +pub const Keep = struct { + pub fn run(c: Ctx) void { + if (!pardes.Trail.reading(c.p, c.pane)) return c.p.setMessage(.at(c.id), "Keep: this pane is held already"); + pardes.Trail.keep(c.pane); + } +}; + /// Select the next thing a Look would open: a place in a list, a word that /// names a file. /// @@ -2064,6 +2092,7 @@ pub const Recent = struct { // The query pane under the pane the keyboard is in, line 1 // `Recent `, typed into; what follows the word narrows the files. if (c.p.panes[c.id] == null) return c.p.reportFailure(c.id, "Recent: open a pane to search from"); + if (pardes.Pick.asked(c.p)) return pardes.Pick.open(c.p, c.id, .recent, "", std.mem.trim(u8, c.arg orelse "", " \t\r\n"), ""); panes.Query.open(c.p, c.id, .recent, std.mem.trim(u8, c.arg orelse "", " \t\r\n"), true); } }; @@ -2093,6 +2122,7 @@ pub const Jumplist = struct { pub const scope: Scope = .session; pub const output: OutputTraits = .{ .name = config.jumps_buffer, .steps = true, .locations = true }; pub fn run(c: Ctx) void { + if (pardes.Pick.asked(c.p)) return pardes.Pick.open(c.p, c.id, .jumplist, "", "", ""); panes.Output.openJumps(c.p, c.id) catch |err| c.p.reportError(.at(c.id), "jumplist", err); } }; |
