summaryrefslogtreecommitdiff
path: root/src/config.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-11 12:38:56 -0300
committerGabriel Schneider <[email protected]>2026-09-15 17:24:42 -0300
commit682e237df7e8b22f820d14a4adee58e6e2f84268 (patch)
tree5d888cb46f1a49e89fc55e2a4c232d3af0265b1d /src/config.zig
parent6878e1c309172d624c0d7a3555f6f0217ae6770e (diff)
downloadpardes-682e237df7e8b22f820d14a4adee58e6e2f84268.tar.gz
pardes-682e237df7e8b22f820d14a4adee58e6e2f84268.zip
trunk: resume before the Reload experiment
Empty marker on the last pre-Reload change. Keep the Reload experiment on reload (3801914), its first change on reload-start (200a1fc), and the unfinished performance investigation on reload-perf-wip.
Diffstat (limited to 'src/config.zig')
-rw-r--r--src/config.zig92
1 files changed, 78 insertions, 14 deletions
diff --git a/src/config.zig b/src/config.zig
index 5dcfef01..282e63da 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -43,6 +43,8 @@ pub const leader_path = paths: {
.Subtypes = "lT",
.Del = "d",
.Filter = null,
+ .Togglettymode = null,
+ .Collapse = null,
.Kill = null,
.ClipYank = "y",
.ClipYankMain = "Y",
@@ -51,7 +53,7 @@ pub const leader_path = paths: {
.ClipReplace = "R",
.Save = "fs",
.New = "fn",
- .Newtty = "nt",
+ .Tty = "nt",
.Find = "ff",
.Grep = "fg",
.Config = "fc",
@@ -64,6 +66,9 @@ pub const leader_path = paths: {
.Debug = "td",
.Msg = null,
.Colors = "tc",
+ .FocusTint = null,
+ .ColumnTags = null,
+ .SyntaxBold = null,
.Wrap = "tw",
.Tagbottom = "tb",
.NextColor = "tn",
@@ -92,6 +97,7 @@ pub const leader_path = paths: {
table.set(.Font, null);
table.set(.TaglineSize, null);
}
+ if (pardes.platform == .gui) table.set(.Pet, null);
if (builtins.capabilities.panel_transitions) {
table.set(.PanelSlide, "as");
table.set(.PanelZoom, "az");
@@ -215,13 +221,12 @@ pub const tty_blank: enum { prompt, prompt_and_input } = .prompt;
// Projected colors below this contrast use the theme's more legible anchor.
pub const tty_filter_min_contrast: f64 = 1.5;
-pub const topbar_str = "New Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill";
+pub const topbar_str = "Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill";
-pub const pane_builtins_str = "New Newtty Del";
-pub const file_pane_builtins_str = "Save New Newtty Del";
-pub const terminal_pane_builtins_str = "Save New Newtty Del Filter";
-
-pub const tag_right_pad: u16 = 20;
+pub const pane_builtins_str = "Tty Del Collapse";
+pub const pdf_pane_builtins_str = "Tty Del PdfSections PdfTint Collapse";
+pub const file_pane_builtins_str = "Save Tty Del Collapse";
+pub const terminal_pane_builtins_str = "Save Tty Del Togglettymode Filter Collapse";
// Each mode badge is one codepoint.
pub const tag_normal = " ";
@@ -529,6 +534,10 @@ pub const Runtime = struct {
wrap: bool = true,
tag_bottom: bool = false,
debug: bool = false,
+ focus_tint: bool = true,
+ column_tags: bool = true,
+ syntax_bold: bool = false,
+ pet: enum { off, cat, frog } = .off,
// Effective values change only after a host acknowledges the request.
shell: struct {
@@ -540,6 +549,7 @@ pub const Runtime = struct {
font: struct {
requested_path: Text(limits.host_path_cap) = .{},
requested_name: Text(255) = .{},
+ requested_size_hundredths: u16 = 0, // zero preserves the renderer's current size
effective_name: Text(255) = .{},
pending: bool = false,
effective_size_hundredths: u16 = 0,
@@ -582,12 +592,30 @@ pub const Runtime = struct {
pub const FontSizeUnit = enum { unknown, pixels, points };
- // Validate both strings before changing either member of the request.
- pub fn requestFont(state: *Runtime, path: []const u8, name: []const u8) bool {
+ pub const FontSpec = struct {
+ name: []const u8,
+ size_hundredths: u16 = 0,
+
+ pub fn parse(argument: []const u8) ?FontSpec {
+ const text = std.mem.trim(u8, argument, " \t\r\n");
+ if (text.len == 0) return null;
+ const colon = std.mem.indexOfScalar(u8, text, ':') orelse return .{ .name = text };
+ const name = std.mem.trim(u8, text[0..colon], " \t");
+ if (name.len == 0) return null;
+ const size = std.fmt.parseFloat(f32, text[colon + 1 ..]) catch return null;
+ if (!std.math.isFinite(size) or size < 8 or size > 72) return null;
+ return .{ .name = name, .size_hundredths = @intFromFloat(@round(size * 100)) };
+ }
+ };
+
+ // Validate the complete request before changing any member.
+ pub fn requestFont(state: *Runtime, path: []const u8, name: []const u8, size_hundredths: u16) bool {
if (path.len > state.font.requested_path.bytes.len or
name.len > state.font.requested_name.bytes.len) return false;
+ if (size_hundredths != 0 and (size_hundredths < 800 or size_hundredths > 7200)) return false;
std.debug.assert(state.font.requested_path.set(path));
std.debug.assert(state.font.requested_name.set(name));
+ state.font.requested_size_hundredths = size_hundredths;
state.font.pending = true;
return true;
}
@@ -601,7 +629,7 @@ pub const Runtime = struct {
pub const Capability = std.meta.FieldEnum(Capabilities);
- pub const Toggle = enum { colors, wrap, tag_bottom, debug };
+ pub const Toggle = enum { colors, wrap, tag_bottom, debug, focus_tint, column_tags, syntax_bold };
pub const Scene = std.meta.FieldEnum(layout.SceneEffect);
pub const Action = union(enum) {
@@ -640,6 +668,9 @@ pub const Runtime = struct {
.{ .word = "Wrap", .action = .{ .toggle = .wrap } },
.{ .word = "Tagbottom", .action = .{ .toggle = .tag_bottom } },
.{ .word = "Debug", .action = .{ .toggle = .debug } },
+ .{ .word = "FocusTint", .action = .{ .toggle = .focus_tint } },
+ .{ .word = "ColumnTags", .action = .{ .toggle = .column_tags } },
+ .{ .word = "SyntaxBold", .action = .{ .toggle = .syntax_bold } },
.{ .word = "Theme", .action = .theme },
.{ .word = "Shell", .action = .shell },
.{ .word = "Font", .action = .font, .availability = .font_picker },
@@ -718,6 +749,9 @@ pub const Runtime = struct {
.wrap => state.wrap = !state.wrap,
.tag_bottom => state.tag_bottom = !state.tag_bottom,
.debug => state.debug = !state.debug,
+ .focus_tint => state.focus_tint = !state.focus_tint,
+ .column_tags => state.column_tags = !state.column_tags,
+ .syntax_bold => state.syntax_bold = !state.syntax_bold,
},
.shell => {
const value = std.mem.trim(u8, argument orelse return false, " \t\r\n");
@@ -778,6 +812,9 @@ pub const Runtime = struct {
.wrap => state.wrap,
.tag_bottom => state.tag_bottom,
.debug => state.debug,
+ .focus_tint => state.focus_tint,
+ .column_tags => state.column_tags,
+ .syntax_bold => state.syntax_bold,
};
try out.print("{s}: {s}\n", .{ setting.word, onOff(value) });
},
@@ -801,7 +838,11 @@ pub const Runtime = struct {
},
.font => if (!setting.enabled(context.capabilities))
try out.print("{s}: unsupported\n", .{setting.word})
- else
+ else {
+ if (state.font.requested_size_hundredths == 0)
+ try out.print("{s} requested size: unchanged\n", .{setting.word})
+ else
+ try out.print("{s} requested size: {d}.{d:0>2}\n", .{ setting.word, state.font.requested_size_hundredths / 100, state.font.requested_size_hundredths % 100 });
try out.print(
"{s} requested: {s}\n" ++
"{s} requested path: {s}\n" ++
@@ -822,7 +863,8 @@ pub const Runtime = struct {
state.font.effective_size_hundredths % 100,
@tagName(state.font.effective_size_unit),
},
- ),
+ );
+ },
.tagline_size => if (!context.capabilities.tagline_font_size)
try out.print("{s}: unsupported\n", .{setting.word})
else if (!setting.enabled(context.capabilities))
@@ -865,6 +907,8 @@ pub const Runtime = struct {
else
try out.writeAll("Look hover delay: off\n");
try out.print("Native images: {s}\n", .{onOff(context.native_images)});
+ if (std.mem.eql(u8, context.platform, "gui"))
+ try out.print("Pet: {s}\n", .{@tagName(state.pet)});
}
test "setting names are unique and argument metadata follows actions" {
@@ -912,11 +956,26 @@ pub const Runtime = struct {
test "font request tuple rejects atomically" {
var state: Runtime = .{};
- try std.testing.expect(requestFont(&state, "/fonts/old.ttf", "Old"));
+ try std.testing.expect(requestFont(&state, "/fonts/old.ttf", "Old", 1200));
var too_long: [256]u8 = @splat('x');
- try std.testing.expect(!requestFont(&state, "/fonts/new.ttf", &too_long));
+ try std.testing.expect(!requestFont(&state, "/fonts/new.ttf", &too_long, 1800));
+ try std.testing.expect(!requestFont(&state, "/fonts/new.ttf", "New", 799));
try std.testing.expectEqualStrings("/fonts/old.ttf", state.font.requested_path.get());
try std.testing.expectEqualStrings("Old", state.font.requested_name.get());
+ try std.testing.expectEqual(@as(u16, 1200), state.font.requested_size_hundredths);
+ }
+
+ test "font specification accepts optional size and rejects invalid suffixes" {
+ const plain = FontSpec.parse(" Example Mono ").?;
+ try std.testing.expectEqualStrings("Example Mono", plain.name);
+ try std.testing.expectEqual(@as(u16, 0), plain.size_hundredths);
+ const sized = FontSpec.parse("Example Mono:12.5").?;
+ try std.testing.expectEqualStrings("Example Mono", sized.name);
+ try std.testing.expectEqual(@as(u16, 1250), sized.size_hundredths);
+ try std.testing.expectEqual(@as(u16, 800), FontSpec.parse("Mono:8").?.size_hundredths);
+ try std.testing.expectEqual(@as(u16, 7200), FontSpec.parse("Mono:72").?.size_hundredths);
+ for ([_][]const u8{ "", ":12", "Mono:", "Mono:abc", "Mono:0", "Mono:-12", "Mono:7.99", "Mono:72.01", "Mono:nan", "Mono:inf", "Mono:12:13" }) |bad|
+ try std.testing.expect(FontSpec.parse(bad) == null);
}
test "Config report observes every simple setting and all live context" {
@@ -960,6 +1019,9 @@ pub const Runtime = struct {
.wrap => "Wrap: off\n",
.tag_bottom => "Tagbottom: on\n",
.debug => "Debug: on\n",
+ .focus_tint => "FocusTint: off\n",
+ .column_tags => "ColumnTags: off\n",
+ .syntax_bold => "SyntaxBold: on\n",
},
.shell => "Shell requested (new panes): fish\n",
.tagline_size => "TaglineSize: 73%\n",
@@ -989,6 +1051,7 @@ pub const Runtime = struct {
try std.testing.expect(state.font.requested_name.set("Wanted Mono"));
try std.testing.expect(state.font.requested_path.set("/fonts/wanted.ttf"));
+ state.font.requested_size_hundredths = 1850;
try std.testing.expect(state.font.effective_name.set("Effective Mono"));
state.font.pending = true;
state.font.effective_size_hundredths = 1375;
@@ -1000,6 +1063,7 @@ pub const Runtime = struct {
const report = storage[0..out.end];
for ([_][]const u8{
"Theme: acme\n",
+ "Font requested size: 18.50\n",
"Font requested: Wanted Mono\n",
"Font requested path: /fonts/wanted.ttf\n",
"Font effective: Effective Mono\n",