summaryrefslogtreecommitdiff
path: root/test/session.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-04 10:45:36 -0300
committerGabriel Schneider <[email protected]>2026-11-04 10:48:22 -0300
commitff0b8a382de7a1994a6912dc71ba28a8ecdaf474 (patch)
treefd93e430e7e95a0e91e587290fd076cbce1fcdb3 /test/session.zig
parentfb9b3a3304e0bdbeffc68e56dfe2ad6511a6a64e (diff)
downloadpardes-ff0b8a382de7a1994a6912dc71ba28a8ecdaf474.tar.gz
pardes-ff0b8a382de7a1994a6912dc71ba28a8ecdaf474.zip
test: syntax colours and Save's prompt through the 9P tree alone, Session.styles added (each cell's style as /screen draws it, as JSON text): in test/behaviour/settings.zig Colors off drawing a source plain and on again colouring its fn and if, the layout as it was, an edit made while off included, and SyntaxBold keywords coloured and bold in every row a detached session's size grows a pane into; in panes.zig a rename colouring a source in its new name's language, its text unchanged; in keys.zig Save's prompt on a scratch made by New from a file's pane starting from its directory, one slash after it (/dír space/, and / alone); each checked to fail against a break (the Colors toggle not marking syntax dirty, the painted stretch four rows from the scroll, a rename not marking syntax dirty, the prompt's slash always added, the prompt from the session's directory); test/panes.zig's Colors and growing tests and pane.zig's cached-syntax rename test deleted, and the Save prompt test trimmed to an owned directory ending in a slash or empty (a shell's, T2)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/session.zig')
-rw-r--r--test/session.zig17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/session.zig b/test/session.zig
index 16a131fd..6f36785c 100644
--- a/test/session.zig
+++ b/test/session.zig
@@ -314,6 +314,23 @@ pub const Session = struct {
var it = std.mem.splitScalar(u8, tag[lo + 2 .. close], '/');
return .{ try std.fmt.parseInt(u32, it.next().?, 10), try std.fmt.parseInt(u32, it.next() orelse return error.NoPage, 10) };
}
+
+ // pane2:
+
+ /// Each cell's style as /screen draws it, as JSON text (compare two
+ /// cells by it), row-major as `screen` draws the cells: row `y`'s cell
+ /// `x` is `[y * cols + x]`.
+ pub fn styles(s: *Session) ![]const []const u8 {
+ const a = s.arena.allocator();
+ const json = try std.json.parseFromSliceLeaky(std.json.Value, a, try s.read("/screen"), .{});
+ const kinds = json.object.get("styles").?.array.items;
+ const named = try a.alloc([]const u8, kinds.len);
+ for (kinds, named) |style, *text| text.* = try std.json.Stringify.valueAlloc(a, style, .{});
+ const cells = json.object.get("cells").?.array.items;
+ const out = try a.alloc([]const u8, cells.len);
+ for (cells, out) |cell, *style| style.* = named[@intCast(cell.array.items[1].integer)];
+ return out;
+ }
};
fn refusal(path: []const u8, r: Reply) error{Refused} {