summaryrefslogtreecommitdiff
path: root/test/session.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/session.zig')
-rw-r--r--test/session.zig17
1 files changed, 14 insertions, 3 deletions
diff --git a/test/session.zig b/test/session.zig
index c28c2892..71d723a4 100644
--- a/test/session.zig
+++ b/test/session.zig
@@ -25,9 +25,10 @@ pub const Session = struct {
/// through (initLanguage); none, and they go unanswered.
languages: ?std.Io = null,
- /// A session showing one file pane holding `text`.
+ /// A session showing one file pane holding `text`, keeping what outlives
+ /// it in a database in memory (src/Db.zig).
pub fn initFile(gpa: std.mem.Allocator, text: []const u8) !Session {
- const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 });
+ const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24, .state = .memory });
errdefer p.deinit();
_ = try p.setTestFile(text);
var s: Session = .{ .core = p, .arena = .init(gpa) };
@@ -48,7 +49,17 @@ pub const Session = struct {
/// A session showing its terminal pane, as `pardes` starts.
pub fn initTerm(gpa: std.mem.Allocator) !Session {
- const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 });
+ const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24, .state = .memory });
+ var s: Session = .{ .core = p, .arena = .init(gpa) };
+ s.drain();
+ return s;
+ }
+
+ /// A session showing a scratch pane, keeping its state in the state
+ /// file in `dir` (its DumpDir), as every session of a user shares one.
+ pub fn initShared(gpa: std.mem.Allocator, dir: []const u8) !Session {
+ var config: [4200]u8 = undefined;
+ const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24, .state = .disk, .startup_config = try std.fmt.bufPrint(&config, "DumpDir {s}\n", .{dir}) });
var s: Session = .{ .core = p, .arena = .init(gpa) };
s.drain();
return s;