diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-16 23:46:16 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:01 -0300 |
| commit | 5dc2c61f1df30d2dd84fbba6d0e8895a62c3b2b5 (patch) | |
| tree | ca8907b582fb2c1fda197aa1011e5ea5f2725a46 /src/host/Console.zig | |
| parent | ca602943e3fc9faad24e51497eeafb0ae7856800 (diff) | |
| download | sketchbook-5dc2c61f1df30d2dd84fbba6d0e8895a62c3b2b5.tar.gz sketchbook-5dc2c61f1df30d2dd84fbba6d0e8895a62c3b2b5.zip | |
Export a session to a file of its own, and import one
export-session [S] FILE writes session S (this run's by default, committed
first), with the marks and clips that point into it, as session 0 of a new
database: written beside FILE, synced, renamed over it. import FILE appends
each session of such a file to this database, from "import <file name>",
its marks and clips renamed NAME@<file name> (cut to 32 bytes). The copy is
value by value, the same few lines for both, over whatever a session holds;
sessions lists where one came from.
test-import records test/past.script's session, exports it, imports it into
another database and replays it there: the mark it carries is the State
half a second in exactly, and two seconds in is frame 120's.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'src/host/Console.zig')
| -rw-r--r-- | src/host/Console.zig | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/host/Console.zig b/src/host/Console.zig index 9f14830..75da732 100644 --- a/src/host/Console.zig +++ b/src/host/Console.zig @@ -17,6 +17,7 @@ const host_commands = [_][]const u8{ "help", "overlay memory", "overlay sound", "get", "set", "reset", "save", "load", "snapshot", "recording", "marks", "clips", "play session", "record", "stop", "play", "pause", "step", "seek start", "seek end", "diff", "quit", "exit", "overlay timing", "sessions", "timing on", "timing off", "timing frame", "timing work", "timing reset", "timing stats", + "export-session", "import", }; visible: bool = false, @@ -158,7 +159,8 @@ pub fn execute(self: *Console, host: *Host, line: []const u8, now: u64) ![]const if (eq(command, "help")) { self.log("save|load|diff [MARK] snapshot MARK marks | record|play [CLIP] recording CLIP clips | stop | pause"); - self.log("step N (frames) | seek start|end|<ms> | sessions | reset | get|set <field> [<value>] | overlay memory|sound | quit"); + self.log("step N (frames) | seek start|end|<ms> | sessions | play session S [at SECS] | export-session [S] FILE | import FILE"); + self.log("reset | get|set <field> [<value>] | overlay memory|sound | quit"); self.log("timing [on|off|frame|work|reset|stats] | overlay timing"); if (host.forward(self, line, now) == .unknown) self.log("Backtick hides the console. Tab completes."); return &.{}; @@ -290,6 +292,20 @@ pub fn execute(self: *Console, host: *Host, line: []const u8, now: u64) ![]const } else if (eq(command, "sessions")) { if (arg != null) return error.UnexpectedArgument; try self.listSessions(host); + } else if (eq(command, "export-session")) { + const s = &host.sessions; + const first = arg orelse return error.ExpectedFile; + const index = if (rest.len == 0) s.session else std.fmt.parseInt(u64, first, 10) catch return error.InvalidSession; + const path = if (rest.len == 0) first else std.mem.trim(u8, rest, " \t"); + try s.exportSession(index, path); + self.print("Exported session {d} to {s}.", .{ index, path }); + } else if (eq(command, "import")) { + const path = arg orelse return error.ExpectedFile; + if (rest.len != 0) return error.UnexpectedArgument; + const s = &host.sessions; + const first = try s.import(path); + const n = try s.count(.sessions); + self.print("Imported {s} as session {d}..{d}; marks and clips are NAME@{s}.", .{ path, first, n - 1, std.fs.path.basename(path) }); } else if (eq(command, "marks") or eq(command, "clips")) { if (arg != null) return error.UnexpectedArgument; try self.listNamed(host, eq(command, "marks")); @@ -349,7 +365,7 @@ fn listSessions(self: *Console, host: *Host) !void { const d = (m.ended -| m.started) / std.time.ns_per_s; break :blk std.fmt.bufPrint(&end_buf, "{d}:{d:0>2}", .{ d / 60, d % 60 }) catch ""; }; - self.print("{d}: {d:0>4}-{d:0>2}-{d:0>2} {d:0>2}:{d:0>2} builds {d} frames {d} {s}", .{ i, day.year, md.month.numeric(), md.day_index + 1, ds.getHoursIntoDay(), ds.getMinutesIntoHour(), m.stretches, m.frames, end }); + self.print("{d}: {d:0>4}-{d:0>2}-{d:0>2} {d:0>2}:{d:0>2} builds {d} frames {d} {s} {s}", .{ i, day.year, md.month.numeric(), md.day_index + 1, ds.getHoursIntoDay(), ds.getMinutesIntoHour(), m.stretches, m.frames, end, m.from() }); } } |
