summaryrefslogtreecommitdiff
path: root/src/dump.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/dump.zig')
-rw-r--r--src/dump.zig19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/dump.zig b/src/dump.zig
index 89abd995..ff5d2166 100644
--- a/src/dump.zig
+++ b/src/dump.zig
@@ -11,11 +11,11 @@ const log = std.log.scoped(.dump);
/// pins it for deterministic goldens); else $XDG_DATA_HOME|~/.local/share
/// /pardes/pardes-<utc>.zon — timestamped so dumps never overwrite each other.
/// Creates the pardes dir (parents assumed; a failure surfaces at open).
-pub fn outPath(buf: *[1024:0]u8) ?[:0]const u8 {
+pub fn outPath(buf: *[1024:0]u8, dir_setting: []const u8) ?[:0]const u8 {
if (std.c.getenv("PARDES_DUMP")) |p|
return std.fmt.bufPrintSentinel(buf, "{s}", .{std.mem.span(p)}, 0) catch null;
var dir_buf: [900]u8 = undefined;
- const dir = defaultDirectory(&dir_buf) orelse return null;
+ const dir = directory(&dir_buf, dir_setting) orelse return null;
var dz: [901:0]u8 = undefined;
@memcpy(dz[0..dir.len], dir);
dz[dir.len] = 0;
@@ -32,6 +32,15 @@ pub fn outPath(buf: *[1024:0]u8) ?[:0]const u8 {
ds.getSecondsIntoMinute(),
}, 0) catch null;
}
+/// Where dumps go and relative Restore names are looked up: the `DumpDir`
+/// setting when set (a leading `~/` is the home directory), else the default.
+pub fn directory(buf: []u8, dir_setting: []const u8) ?[]const u8 {
+ if (dir_setting.len == 0) return defaultDirectory(buf);
+ if (std.mem.startsWith(u8, dir_setting, "~/")) if (std.c.getenv("HOME")) |h|
+ return std.fmt.bufPrint(buf, "{s}/{s}", .{ std.mem.span(h), dir_setting[2..] }) catch null;
+ return std.fmt.bufPrint(buf, "{s}", .{dir_setting}) catch null;
+}
+
/// The standard dump directory, without creating it or generating a filename.
pub fn defaultDirectory(buf: []u8) ?[]const u8 {
if (std.c.getenv("XDG_DATA_HOME")) |x|
@@ -69,8 +78,14 @@ pub const PaneKind = enum {
pub const Terminal = struct {
cwd: []const u8 = "",
+ /// The rendered scrollback and screen as plain text, one row per line.
stream: []const u8 = "",
stream_b64: []const u8 = "",
+ /// `stream_b64` is the emulator's primary screen and scrollback as clean
+ /// VT (ghostty's formatter), which replays to what the screen showed.
+ /// Absent (older dumps), it is the raw tail of the pty's output, which
+ /// replays faithfully only if it holds the whole session at one size.
+ stream_is_screen: bool = false,
cursor: Cursor = .{},
};