diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-30 23:58:54 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:18 -0300 |
| commit | 3815a0bfad5818e2caf85a00c0c2d3aecc13bd1c (patch) | |
| tree | dfb1920c13ac0e113d9294c96f86d36ecf95bbc9 /src/pardes.zig | |
| parent | 03ace1893d1a4b509c209e4e8ca023f7261e5cb9 (diff) | |
| download | pardes-3815a0bfad5818e2caf85a00c0c2d3aecc13bd1c.tar.gz pardes-3815a0bfad5818e2caf85a00c0c2d3aecc13bd1c.zip | |
pardes - reads stdin into a +Pager pane, and is a terminal's PAGER and GIT_PAGER, Pager pardes|off to opt out; command panes page through cat
A paging command in a terminal, or run through its pty/run, sat in
less, and a pty/run never answered. `pardes -` now reads stdin to its
end, strips terminal escapes (colour, OSC, overstrike), and shows it:
inside a session as a clean <cwd>/+Pager pane made through pane/new and
back at once, outside one as a new editor whose first pane it is, as
`vim -` does. A terminal's shell gets PAGER and GIT_PAGER set to this
pardes's own path and `-` where the user's environment sets neither;
`Pager off`, a setting in /ctl, init and DumpConfig, leaves terminals
started after it to the environment. A command pane's one-shot shell
keeps cat, its output being a pane already.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/pardes.zig')
| -rw-r--r-- | src/pardes.zig | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index 47ebf8fa..aa2c252c 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -4180,6 +4180,8 @@ pub const Boot = enum { document, /// a Look that found nothing: reported, not opened missing, + /// `pardes -`: stdin's text in a +Pager pane, as `vim -` shows it + stdin, /// the firmware's boot buffer, the only pane a board has embedded, /// the bare tty startup: one shell in raw tty mode, with an empty text @@ -4196,6 +4198,7 @@ pub const Boot = enum { if (opts.boot) |named| return named; if (opts.file != null) return .document; if (opts.missing != null) return .missing; + if (opts.stdin_text != null) return .stdin; if (comptime platform == .esp32p4) return .embedded; if (opts.tty_only) return .tty_shell; // ponytail: 1 and 3 are the only shell counts anyone asked for @@ -4215,6 +4218,8 @@ pub const Options = struct { file: ?[]const u8 = null, file_line: usize = 0, missing: ?struct { word: []const u8, dir: []const u8 } = null, + /// `pardes -`: stdin, its escapes stripped, for a +Pager pane at boot. + stdin_text: ?[]const u8 = null, tty_toggle: u21 = config.tty_toggle_default, /// load a dump of another instance instead of spawning shells (acme -l) load_path: ?[]const u8 = null, @@ -4626,6 +4631,17 @@ pub const Pardes = struct { _ = try panes.Output.open(p, 0, missing.dir, .errors, "", content); p.oneColumn(); }, + .stdin => { + const content = try gpa.dupe(u8, opts.stdin_text.?); + errdefer gpa.free(content); + const dir = p.sessionDir(); + const shown = try panes.Output.open(p, 0, dir, .{ .cmd = .New }, "", content); + // Named +Pager, as `pardes -` inside a session names its pane. + const named = try std.fs.path.join(gpa, &.{ dir, "+Pager" }); + gpa.free(shown.file.?.path); + shown.file.?.path = named; + p.oneColumn(); + }, .embedded => { const content = try p.gpa.dupe(u8, boot_buffer); errdefer p.gpa.free(content); |
