diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-29 03:13:10 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:15 -0300 |
| commit | 6dfc6838c1c02978c026b650d69f87f23e3ff81c (patch) | |
| tree | a488db19607f2a1a7759f2e66a4688182e371124 /src/pardes.zig | |
| parent | 073695995ecf4a269da8d338b23bfab1d3369c05 (diff) | |
| download | pardes-6dfc6838c1c02978c026b650d69f87f23e3ff81c.tar.gz pardes-6dfc6838c1c02978c026b650d69f87f23e3ff81c.zip | |
Words from the workspace and column tags run in the session's directory
A command or Tty run from the workspace tag or a column tag started in
the focused pane's directory, though those tags have none of their own.
As acme's row and column tags do, they now run in the session's
directory, where pardes started (Pardes.sessionDir); a pane's tag and
text keep the pane's. The same for /tagexec, a column's exec and ctl.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/pardes.zig')
| -rw-r--r-- | src/pardes.zig | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index ac6d52cd..42f1b6e4 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -4275,6 +4275,12 @@ pub const Pardes = struct { /// (exec.placeNew): closed at the step's end, once whatever made them /// is done with them. unplaced: std.StaticBitSet(MAX_PANES) = .initEmpty(), + /// The running word came from the workspace's or a column's tag, which + /// have no directory of their own: it runs in the session's + /// (`sessionDir`), as acme's row and column tags do. + exec_header: bool = false, + session_dir: [limits.host_path_cap]u8 = undefined, + session_dir_len: ?u16 = null, /// acme's activecol (dat.c:37), by column serial, 0 for none: the /// column last typed in (acme.c:487), clicked in with the select button /// (acme.c:659), dropped into by a grip (acme.c:640), or given a new @@ -5776,6 +5782,8 @@ pub const Pardes = struct { // A column tag's command acts on that column, empty or not. p.exec_column = if (header != null) p.header_column else null; defer p.exec_column = null; + p.exec_header = header != null; + defer p.exec_header = false; // Out of the tag or header FIRST: Del frees the pane, Kill // and Restore the whole session. if (header != null) tagline.exitHeader(p) else pane.focus = .body; @@ -5878,6 +5886,23 @@ pub const Pardes = struct { // ---- search (`/`, Find, n/N): results into an output buffer, look the rows ---- + /// Where pardes started: the directory of what runs from a header. + pub fn sessionDir(p: *Pardes) []const u8 { + if (p.session_dir_len) |n| return p.session_dir[0..n]; + if (comptime !hosted) return "/"; + if (std.c.getcwd(&p.session_dir, p.session_dir.len) == null) return "/"; + const n: u16 = @intCast(std.mem.indexOfScalar(u8, &p.session_dir, 0) orelse return "/"); + p.session_dir_len = n; + return p.session_dir[0..n]; + } + + /// The directory a word run from pane `id`'s text or tag runs in, or, + /// from a header, the session's. + pub fn execDir(p: *Pardes, id: usize) []const u8 { + if (p.exec_header) return p.sessionDir(); + return paneDir(p.panes[id] orelse return p.sessionDir()); + } + pub fn paneDir(pane: *const Pane) []const u8 { switch (pane.cwd) { .inherited => |src| return paneDir(src), |
