summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-07-09 09:47:04 -0300
committerGabriel Schneider <[email protected]>2026-08-01 15:02:07 -0300
commita99f039bc2ce01302d6f6c5fe42e260950870008 (patch)
tree91a24c5b66c983619141fcce23393a73cabf833b /src/pardes.zig
parent172eb56fee0b6bde698e72be2bca55a90fe81ce9 (diff)
downloadpardes-a99f039bc2ce01302d6f6c5fe42e260950870008.tar.gz
pardes-a99f039bc2ce01302d6f6c5fe42e260950870008.zip
right click search
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index f6c0a09c..cae3a0ab 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -2073,14 +2073,19 @@ pub const Pardes = struct {
pane.tag_col = @intCast(pane.tag_tail.items.len);
}
- /// Enter on a `/` input: run `grep -nH '<pat>' <path>` in a shell in the
- /// file's directory (the same path middle-click send takes), so the
- /// results are ordinary persistent terminal text. Remember the results
- /// pane and start n/N below its current prompt row.
+ /// Enter on a `/` input: peel the typed pattern off the tag tail (past the
+ /// " /" marker) and run it through the shared search.
fn submitSearch(p: *Pardes, pane: *Pane) void {
- const f = pane.file orelse return;
const tail = pane.tag_tail.items;
- const pat = std.mem.trim(u8, tail[@min(@as(usize, pane.search_at) + 2, tail.len)..], " \t\r\n");
+ p.runSearch(pane, tail[@min(@as(usize, pane.search_at) + 2, tail.len)..]);
+ }
+
+ /// grep `pat_raw` (the `/` input, or a right-click word/selection) into a
+ /// shell in the file's directory and arm n/N to walk the results below the
+ /// prompt row — the shared body of `/`-submit and file-pane right-click.
+ fn runSearch(p: *Pardes, pane: *Pane, pat_raw: []const u8) void {
+ const f = pane.file orelse return;
+ const pat = std.mem.trim(u8, pat_raw, " \t\r\n");
if (pat.len == 0) return;
const arena = p.scratch.allocator();
var cmd: std.ArrayList(u8) = .empty;
@@ -4300,7 +4305,12 @@ pub const Pardes = struct {
}
}
switch (look.resolve(txt, cwd, &realbuf)) {
- .none => {},
+ // acme button-3: a word that names no file/dir, in a text file,
+ // is a search — grep it into a shell exactly like `/` (n/N then
+ // walk the results). Paths (src/a/b.rs:100) still resolve above
+ // and open; only the non-file case falls through here. On a
+ // terminal a dead look stays inert.
+ .none => if (pane.file != null) p.runSearch(pane, txt),
.url => |u| if (u.len <= 256) p.emit(.{ .open_link = .from(u) }),
.dir => |dir| {
// focus an existing terminal on this dir, else fork one below