From dfcc040ac979b695dc2e68b9d866c2769ba6d928 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 5 Nov 2026 22:40:49 -0300 Subject: settings #2, five presentation variants go, each now the style it had by default: Colors (text panes and terminals coloured, with SPC t c), TreeContextTagStyle (TreeContext rows in the tag's style), FocusTint (the focused tags tinted), SyntaxBold (keywords not bold) and Ligatures (the window shapes them; gui.zig's syncLigatures and the words' ligatures flag go, and Capabilities.ligatures); the reads deleted are in File.zig, body_layer.zig, Tables.zig, exec.zig's applySettingBuiltin, Core.zig (SessionView.layered left at its default), draw.zig, surface.zig's comment and gui.zig; deleted tests: "settings: Colors off draws a source plain, and on again colours its keywords", "Ligatures is a setting only in the shell that shapes text" and "Ligatures off draws a ligature as its cells' own glyphs, and on shapes it again", and the toggled half of TreeContext's Core test; rewritten through what stays: SyntaxBold's every-row test as keywords coloured in every row, the tag-click tests on JumpTrail, the tag-name tint tests with the focused tag's ink plain, Core's tab test by the keyword's ink; golden changes, each the cut's: syntax, theme, mini and ninep lose their Colors toggles and frames (the message row after them names the builtin before, Mini), and leader, ttyhelp and builtins' Help listing is four columns narrower, TreeContextTagStyle having been its longest word; perf.zig's harness id moves again; the window scenes from 09 on take new gui-goldens lines, the scene no longer writing FocusTint on and its word gone from the message row (the base window build running the same scenes gives the same frames); gates on tui: core-test 965/965, behaviour-test 242/242, unit-test 1482/1483, pane-test 171/172, snap all 105 scripts ok, process-test 0 of 37 failed; gui unit-test 1526/1527, gui-golden 0 of 1 failed Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/behaviour/settings.zig | 38 ++++++-------------------------------- test/behaviour/tags.zig | 27 +++++++++++++-------------- 2 files changed, 19 insertions(+), 46 deletions(-) (limited to 'test/behaviour') diff --git a/test/behaviour/settings.zig b/test/behaviour/settings.zig index 80573e2f..fdb37fa3 100644 --- a/test/behaviour/settings.zig +++ b/test/behaviour/settings.zig @@ -207,41 +207,15 @@ fn keywordsIn(s: *Session, want: []const u8) !usize { return seen; } -test "settings: Colors off draws a source plain, and on again colours its keywords, the layout as it was, an edit made while off included" { - if (!syntax) return error.SkipZigTest; - for ([_]bool{ false, true }) |edit_while_off| { - var s = try Session.initFile(std.testing.allocator, "pub fn first() void { if (true) {} }\n"); - defer s.deinit(); - const n = try s.focused(); - try s.write(s.at("/pane/{d}/name", .{n}), "/colors.zig\n"); - var ident: []const u8 = "first"; - if (edit_while_off) { - try std.testing.expect(!std.mem.eql(u8, try styleOf(&s, " fn ", 1), try styleOf(&s, "first", 0))); - try s.write("/ctl", "Colors off\n"); - try s.replace(s.at("/pane/{d}/body", .{n}), "pub fn edited() void { if (false) {} }\n"); - ident = "edited"; - } else try s.write("/ctl", "Colors off\n"); - try std.testing.expectEqual(@as(usize, 2), try keywordsIn(&s, try styleOf(&s, ident, 0))); - const layout = try s.read("/layout"); - try s.write("/ctl", "Colors on\n"); - try s.expect("/layout", layout); - const kw = try styleOf(&s, " fn ", 1); - try std.testing.expect(!std.mem.eql(u8, kw, try styleOf(&s, ident, 0))); - try std.testing.expect(!has(kw, "\"bold\":true")); - try std.testing.expectEqual(@as(usize, 2), try keywordsIn(&s, kw)); - } -} - -test "settings: SyntaxBold keywords stay coloured and bold in every row a pane grows into" { +test "settings: keywords stay coloured in every row a pane grows into" { if (!syntax) return error.SkipZigTest; var s = try Session.initFile(std.testing.allocator, std.mem.asBytes(&@as([100][33]u8, @splat("pub fn f() void { if (true) {} }\n".*)))); defer s.deinit(); try s.write(s.at("/pane/{d}/name", .{try s.focused()}), "/resize.zig\n"); - try s.write("/ctl", "SyntaxBold on\n"); s.detach(); try s.write("/ctl", "size 80 8\n"); const kw = try styleOf(&s, " fn ", 1); - try std.testing.expect(has(kw, "\"bold\":true")); + try std.testing.expect(!std.mem.eql(u8, kw, try styleOf(&s, "f()", 0))); for ([_]usize{ 50, 12, 70 }) |rows| { try s.write("/ctl", s.at("size 80 {d}\n", .{rows})); try std.testing.expect(try keywordsIn(&s, kw) >= 2 * (rows - 4)); @@ -272,9 +246,9 @@ test "settings: every on/off setting the root ctl reads flips when its word is w flipped += 1; } // A floor, so a ctl that lists none fails: a bare session's on/off - // words, Colors to PagerColor, are ten. - try std.testing.expect(flipped >= 10); - for ([_][]const u8{ "Colors off", "Wrap off", "Debug on" }) |want| + // words, Wrap, Debug, Verbose and JumpTrail at least, are four. + try std.testing.expect(flipped >= 4); + for ([_][]const u8{ "Wrap off", "Debug on" }) |want| try std.testing.expectEqualStrings(want, try setting(&s, want[0..std.mem.indexOfScalar(u8, want, ' ').?])); try s.write("/ctl", "Theme acme\n"); try s.write("/ctl", "Shell /bin/sh\n"); @@ -289,7 +263,7 @@ fn look(s: *Session, style: []const u8) !struct { bool, []const u8 } { return .{ json.object.get("bold").?.bool, try std.json.Stringify.valueAlloc(a, json.object.get("fg").?, .{}) }; } -test "settings: a keyword is coloured apart from the text beside it, and not bold (SyntaxBold is off by default), at a long file's end" { +test "settings: a keyword is coloured apart from the text beside it, and not bold, at a long file's end" { var s = try Session.initFile(std.testing.allocator, "initial\n"); defer s.deinit(); const n = try s.focused(); diff --git a/test/behaviour/tags.zig b/test/behaviour/tags.zig index 4477e73e..8d04f8ad 100644 --- a/test/behaviour/tags.zig +++ b/test/behaviour/tags.zig @@ -250,15 +250,15 @@ test "tags: a long pane tag wraps onto rows, and a click on a wrapped row maps t try s.write("/ctl", "size 50 12\n"); const n = try s.focused(); try s.write(s.at("/pane/{d}/name", .{n}), "/an/especially/deep/project/path/with/a/long/component/filename.zig"); - try s.write(s.at("/pane/{d}/tag", .{n}), " SyntaxBold"); + try s.write(s.at("/pane/{d}/tag", .{n}), " JumpTrail"); const before = try tag(&s, n); try s.keys(":A"); try std.testing.expect((try s.cursor()).?[0] < 50); - // SyntaxBold is on a row of its own, below the path's. - try std.testing.expect((try s.where("SyntaxBold"))[1] > (try s.where("/an/"))[1]); + // JumpTrail is on a row of its own, below the path's. + try std.testing.expect((try s.where("JumpTrail"))[1] > (try s.where("/an/"))[1]); // Its last character, which a wrapped row's offset not mapped back misses. - try s.click("SyntaxBold", "SyntaxBol".len, 2); - try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "SyntaxBold on\n") != null); + try s.click("JumpTrail", "JumpTrai".len, 2); + try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "JumpTrail on\n") != null); try std.testing.expectEqualStrings(before, try tag(&s, n)); } @@ -268,20 +268,20 @@ test "tags: a word the tag's wrapping breaks across rows is still one word to a s.detach(); try s.write("/ctl", "size 50 12\n"); const n = try s.focused(); - // Lengthen the path until the wrap splits the word after "Synt" (a + // Lengthen the path until the wrap splits the word after "Jump" (a // rename resets the tag's text, so it is written again each time). var pad: usize = 1; while (pad < 80) : (pad += 1) { try s.write(s.at("/pane/{d}/name", .{n}), s.at("/{s}/f.zig", .{(&@as([80]u8, @splat('a')))[0..pad]})); - try s.write(s.at("/pane/{d}/tag", .{n}), " SyntaxBold"); + try s.write(s.at("/pane/{d}/tag", .{n}), " JumpTrail"); var rows = std.mem.splitScalar(u8, try s.screen(), '\n'); const split = while (rows.next()) |row| { - if (std.mem.endsWith(u8, std.mem.trimEnd(u8, row, " "), "Synt")) break true; + if (std.mem.endsWith(u8, std.mem.trimEnd(u8, row, " "), "Jump")) break true; } else false; if (split) break; } else return error.NoSplit; - try s.click("Synt", 1, 2); - try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "SyntaxBold on\n") != null); + try s.click("Jump", 1, 2); + try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "JumpTrail on\n") != null); } /// A click on the tag's path, at its last character: a name drafted @@ -296,18 +296,18 @@ test "tags: a name drafted in the tag commits with Enter, cancels with two Escs, defer s.deinit(); const n = try s.focused(); const name = s.at("/pane/{d}/name", .{n}); - try s.write(s.at("/pane/{d}/tag", .{n}), " SyntaxBold"); + try s.write(s.at("/pane/{d}/tag", .{n}), " JumpTrail"); for ([_]bool{ false, true }) |commit| { const path = std.mem.trimEnd(u8, try s.read(name), "\n"); try clickPathEnd(&s, path); try s.keys("\x15/new name.zig"); try s.expect(name, s.at("{s}\n", .{path})); - _ = try s.where("/new name.zig Save Term Collapse Del SyntaxBold"); + _ = try s.where("/new name.zig Save Term Collapse Del JumpTrail"); try s.expect(s.at("/pane/{d}/body", .{n}), "original body\n"); // Esc keeps the draft pending; a second drops it. try s.keys(if (commit) "\n" else "\x1b\x1b"); try s.expect(name, if (commit) "/new name.zig\n" else "/test.txt\n"); - try std.testing.expectEqualStrings(s.at("{s} Save Term Collapse Del SyntaxBold", .{if (commit) "/new name.zig" else "/test.txt"}), try tag(&s, n)); + try std.testing.expectEqualStrings(s.at("{s} Save Term Collapse Del JumpTrail", .{if (commit) "/new name.zig" else "/test.txt"}), try tag(&s, n)); // The keyboard is the body's again. try std.testing.expect((try s.cursor()).?[1] != (try s.where("Save Term"))[1]); } @@ -464,7 +464,6 @@ test "tags: a pane tag's file name is tinted, its directory, dirty marker and wo var s = try Session.initFile(std.testing.allocator, "body\n"); defer s.deinit(); const n = try s.focused(); - try s.write("/ctl", "FocusTint off\n"); try s.write(s.at("/pane/{d}/name", .{n}), "/project/界file.zig\n"); try s.write(s.at("/pane/{d}/dirty", .{n}), "1"); const x0, const y = try s.where("/project/"); -- cgit v1.3