summaryrefslogtreecommitdiff
path: root/src/config.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 10:46:03 -0300
committerGabriel Schneider <[email protected]>2026-11-05 15:12:36 -0300
commit11204e1206f7f7ffeaa861c1a442a312e563d3ed (patch)
treef788736bf5b6a56694563b664b5db73bc54bff72 /src/config.zig
parentc9b9dad8469f5d654c31d688d7e2d93da8325f39 (diff)
downloadpardes-11204e1206f7f7ffeaa861c1a442a312e563d3ed.tar.gz
pardes-11204e1206f7f7ffeaa861c1a442a312e563d3ed.zip
effects out, the post chain: Crt, Bloom, Vignette, Grain, Shader and ShaderAnimation go with src/gui/Post.zig, src/ShaderBuild.zig (the run-time glslc spawn and its watched files), shaders/post/, post.vert, bloom-down and bloom-up and their prebuilt .spv, the window's scene texture and its post-chain-only redraw (level A), the disable_scene_effects tape site and Pardes.disableSceneEffects; EffectCode goes with src/effect_sources.zig, which only embedded the effects' sources (/virtual keeps src/); the corner-click test keeps its point without a chain, the window monkey loses its Bloom axis; macOS's post-processor (ScenePostprocessor.swift, crt.ci.metal, pardes_scene) is a change of its own
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/config.zig')
-rw-r--r--src/config.zig229
1 files changed, 8 insertions, 221 deletions
diff --git a/src/config.zig b/src/config.zig
index b12630e9..9394f912 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -193,15 +193,6 @@ pub const leader_path = paths: {
table.set(.PanelScramble, "ar");
table.set(.PanelType, "at");
}
- if (builtins.capabilities.scene_shaders) {
- table.set(.Crt, "tr");
- table.set(.Bloom, null);
- table.set(.Vignette, null);
- table.set(.Grain, null);
- table.set(.Shader, null);
- table.set(.ShaderAnimation, null);
- }
- if (builtins.EffectCode.enabled) table.set(.EffectCode, null);
if (builtins.TreeContext.enabled) table.set(.TreeContext, null);
table.set(.ThemeFile, null);
table.set(.DumpThemes, null);
@@ -544,7 +535,6 @@ pub const pipe_marker = " |";
pub const search_buffer = "+Search";
pub const help_buffer = "+Help";
pub const dump_config_buffer = "+DumpConfig";
-pub const effect_code_buffer = "+EffectCode";
pub const jumps_buffer = "+Jumps";
pub const preview_buffer = "+Preview";
pub const unsaved_buffer = "+Unsaved";
@@ -825,12 +815,6 @@ pub const Runtime = struct {
} = .{},
panel_transition: animation.Transition = .off,
- /// The post chain (docs/render-pipeline.md ยง6), in the order it runs.
- post: Post = .{},
- /// When the chain redraws on its own, past the frames it post-processes:
- /// never, while the window has the focus, or always (ghostty's
- /// custom-shader-animation).
- shader_animation: ShaderAnimation = .on,
/// What a terminal's shell pages through (host_io.ChildEnv): `pardes`,
/// PAGER and GIT_PAGER set to `pardes -`, a +Pager pane, where the
/// user's environment set neither; `off`, the environment as it is.
@@ -860,7 +844,6 @@ pub const Runtime = struct {
/// +Preview with): it never resizes itself after.
search_rows: u16 = 8,
- pub const ShaderAnimation = enum { off, on, always };
pub const Pager = enum { pardes, off };
pub const TermImages = enum { real, petscii };
pub const JumpScope = enum { file, all };
@@ -879,81 +862,6 @@ pub const Runtime = struct {
/// sets 35), not so much that they stop being worth reading.
pub const auto_dim: u8 = 30;
- /// Each pass the bundled Crt or a Shadertoy file.
- pub const Post = struct {
- pub const max = 8;
- pub const Entry = struct {
- scene: ?Scene = null,
- path: Text(limits.host_path_cap) = .{},
- /// A bundled pass's strength, 1 to `max_level`; 0 for a file.
- level: u8 = 0,
- };
- pub const max_level = 3;
- /// What `on` and a bare word turn a bundled pass on at.
- pub const default_level = 2;
- entries: [max]Entry = @splat(.{}),
- len: u8 = 0,
- /// Bumped on every change: a shell compiles the chain again when it
- /// moves.
- generation: u32 = 0,
-
- pub fn list(post: *const Post) []const Entry {
- return post.entries[0..post.len];
- }
-
- pub fn has(post: *const Post, scene: Scene) bool {
- return post.level(scene) != 0;
- }
-
- /// A bundled pass's level; 0 when it is not in the chain.
- pub fn level(post: *const Post, scene: Scene) u8 {
- for (post.list()) |entry| if (entry.scene == scene) return entry.level;
- return 0;
- }
-
- /// Sets a bundled pass's level: 0 takes it out, anything else puts it
- /// in at the end or changes it where it is.
- pub fn setLevel(post: *Post, scene: Scene, to: u8) bool {
- std.debug.assert(to <= max_level);
- if (to == 0) return post.set(scene, "", false);
- for (post.entries[0..post.len]) |*entry| if (entry.scene == scene) {
- if (entry.level != to) post.generation +%= 1;
- entry.level = to;
- return true;
- };
- if (!post.set(scene, "", true)) return false;
- post.entries[post.len - 1].level = to;
- return true;
- }
-
- /// Puts the pass in the chain, at its end, or takes it out; `want`
- /// null flips it. False when the chain is full or the path too long.
- pub fn set(post: *Post, scene: ?Scene, path: []const u8, want: ?bool) bool {
- const at: ?usize = for (post.list(), 0..) |entry, i| {
- if (entry.scene == scene and std.mem.eql(u8, entry.path.get(), path)) break i;
- } else null;
- const on = want orelse (at == null);
- if (on == (at != null)) return true;
- post.generation +%= 1;
- if (at) |i| {
- std.mem.copyForwards(Entry, post.entries[i .. post.len - 1], post.entries[i + 1 .. post.len]);
- post.len -= 1;
- return true;
- }
- if (post.len == max) return false;
- post.entries[post.len] = .{ .scene = scene };
- if (!post.entries[post.len].path.set(path)) return false;
- post.len += 1;
- return true;
- }
-
- pub fn clear(post: *Post) void {
- if (post.len == 0) return;
- post.len = 0;
- post.generation +%= 1;
- }
- };
-
pub const tagline_percent_min: u8 = 1;
pub const tagline_percent_max: u8 = 100;
@@ -1012,7 +920,6 @@ pub const Runtime = struct {
pub const Capabilities = struct {
font_picker: bool,
panel_transitions: bool,
- scene_shaders: bool,
tagline_font_size: bool,
window_opacity: bool = false,
window_blur: bool = false,
@@ -1028,9 +935,6 @@ pub const Runtime = struct {
pub const MessageTime = enum { linger, fall, dissolve };
pub const Toggle = enum { colors, wrap, tree_context_tag_style, tag_bottom, debug, focus_tint, syntax_bold, pager_color, verbose, message_animation, ligatures, cursor_blink, selection_glow, hover_glow, occlusion, parallax, jump_trail, chip_shadow, thumb_flash, program_esc };
- /// A bundled post pass, a Shadertoy file in shaders/post/: the CRT, and
- /// G4's bloom, vignette and grain (docs/effects.md).
- pub const Scene = enum { crt, bloom, vignette, grain };
pub const Action = union(enum) {
toggle: Toggle,
@@ -1053,11 +957,6 @@ pub const Runtime = struct {
callstack_depth,
search_rows,
transition: animation.Transition,
- scene: Scene,
- /// A Shadertoy file into the post chain or out of it; `off` empties
- /// it of files.
- shader,
- shader_animation,
choice: Choice,
};
@@ -1084,7 +983,6 @@ pub const Runtime = struct {
.window_opacity => .window_opacity,
.window_blur => .window_blur,
.transition => .panel_transitions,
- .scene, .shader, .shader_animation => .scene_shaders,
.lift, .grip_width => .lift,
.toggle => |field| switch (field) {
.ligatures => .ligatures,
@@ -1141,12 +1039,6 @@ pub const Runtime = struct {
.{ .word = "PanelCurtain", .action = .{ .transition = .curtain }, .doc = "Panes open and close like a curtain, on or off." },
.{ .word = "PanelScramble", .action = .{ .transition = .scramble }, .doc = "Panes open and close through scrambled text, on or off." },
.{ .word = "PanelType", .action = .{ .transition = .typewriter }, .doc = "Panes type themselves in as they open, on or off." },
- .{ .word = "Crt", .action = .{ .scene = .crt }, .doc = "The bundled CRT post pass over the window, on or off." },
- .{ .word = "Bloom", .action = .{ .scene = .bloom }, .doc = "The brightest ink glows a little: a level, 0 (off) through 3." },
- .{ .word = "Vignette", .action = .{ .scene = .vignette }, .doc = "The window's corners fall into shade: a level, 0 (off) through 3." },
- .{ .word = "Grain", .action = .{ .scene = .grain }, .doc = "The page takes a fine, still grain, like paper: a level, 0 (off) through 3." },
- .{ .word = "Shader", .action = .shader, .doc = "A Shadertoy file into the post chain, or out of it, compiled again when saved; off empties the chain." },
- .{ .word = "ShaderAnimation", .action = .shader_animation, .doc = "When the post chain animates on its own: off, on (while focused) or always." },
.{ .word = "Pager", .action = .{ .choice = .pager }, .doc = "What a terminal's commands page through: pardes, a +Pager pane (pardes -), or off, the environment's own; for terminals started after it." },
.{ .word = "PagerColor", .action = .{ .toggle = .pager_color }, .doc = "A +Pager keeps its program's colours, on or off; for the next text paged." },
.{ .word = "TermImages", .action = .{ .choice = .term_images }, .doc = "How a new terminal draws its program's kitty graphics: real, as pixels where it can, or petscii, as glyph art." },
@@ -1191,12 +1083,6 @@ pub const Runtime = struct {
if (actionCount(.{ .transition = effect }) != expected)
@compileError("non-off panel transition must occur exactly once: " ++ @tagName(effect));
}
- for (std.enums.values(Scene)) |effect| {
- if (actionCount(.{ .scene = effect }) != 1)
- @compileError("scene effect must occur exactly once: " ++ @tagName(effect));
- }
- if (actionCount(.shader) != 1 or actionCount(.shader_animation) != 1)
- @compileError("Shader and ShaderAnimation must each occur exactly once");
}
pub fn apply(state: *Runtime, setting: Setting, argument: ?[]const u8) bool {
@@ -1254,35 +1140,6 @@ pub const Runtime = struct {
state.panel_transition = .off;
}
},
- .scene => |effect| {
- // A level, 0 (off) to 3; `on` is the default level, `off` 0,
- // and bare flips between the two.
- const text = std.mem.trim(u8, argument orelse "", " \t\r\n");
- const to: u8 = if (text.len == 0)
- (if (state.post.has(effect)) 0 else Post.default_level)
- else if (std.mem.eql(u8, text, "on"))
- Post.default_level
- else if (std.mem.eql(u8, text, "off"))
- 0
- else
- std.fmt.parseInt(u8, text, 10) catch return false;
- if (to > Post.max_level) return false;
- return state.post.setLevel(effect, to);
- },
- .shader => {
- const path = std.mem.trim(u8, argument orelse return false, " \t\r\n");
- if (path.len == 0) return false;
- if (std.mem.eql(u8, path, "off")) {
- var i: usize = 0;
- while (i < state.post.len) {
- const entry = state.post.entries[i];
- if (entry.scene == null) _ = state.post.set(null, entry.path.get(), false) else i += 1;
- }
- return true;
- }
- return state.post.set(null, path, null);
- },
- .shader_animation => state.shader_animation = stepped(ShaderAnimation, state.shader_animation, argument) orelse return false,
// Bare, it steps to the next word, as a tag word should.
.choice => |which| switch (which) {
inline else => |field| {
@@ -1328,8 +1185,6 @@ pub const Runtime = struct {
},
.lift => "on, " ++ comptime words.of(LiftStyle),
.motion => comptime words.of(animation.Motion.Flavour),
- .scene => std.fmt.comptimePrint("on, off, 0-{d}", .{Post.max_level}),
- .shader_animation => comptime words.of(ShaderAnimation),
else => null,
};
}
@@ -1347,7 +1202,6 @@ pub const Runtime = struct {
.message_ms => std.fmt.comptimePrint("0-{d} (milliseconds)", .{message_ms_max}),
.shell => "a path of at most 255 bytes; bare, $SHELL, else /bin/sh",
.dump_dir => std.fmt.comptimePrint("an absolute or ~ path of at most {d} bytes, to a directory that may be written; bare, the default", .{limits.host_path_cap}),
- .shader => "a Shadertoy file's path, or off",
.font => "a name or path, :8 to :72 after it (Mono:14)",
else => null,
};
@@ -1463,19 +1317,6 @@ pub const Runtime = struct {
.tagline_size => try out.print("{s} {d}\n", .{ setting.word, state.font.tagline_percent }),
// Each a switch of its own, the one in use on.
.transition => |transition| try out.print("{s} {s}\n", .{ setting.word, onOff(state.panel_transition == transition) }),
- .scene => |effect| {
- const level = state.post.level(effect);
- if (level == 0) try out.print("{s} off\n", .{setting.word}) else try out.print("{s} {d}\n", .{ setting.word, level });
- },
- .shader => {
- var files: usize = 0;
- for (state.post.list()) |entry| if (entry.scene == null) {
- try out.print("{s} {s}\n", .{ setting.word, entry.path.get() });
- files += 1;
- };
- if (files == 0) try out.print("{s} off\n", .{setting.word});
- },
- .shader_animation => try out.print("{s} {s}\n", .{ setting.word, @tagName(state.shader_animation) }),
.choice => |which| switch (which) {
inline else => |field| try out.print("{s} {s}\n", .{ setting.word, @tagName(@field(state, @tagName(field))) }),
},
@@ -1517,7 +1358,7 @@ pub const Runtime = struct {
try out.print("# Pet: {s}\n", .{@tagName(state.pet)});
}
- test "panel and scene effects flip bare and are set by on and off" {
+ test "panel effects flip bare and are set by on and off" {
var state: Runtime = .{};
const slide = findAction(.{ .transition = .slide }).?;
const zoom = findAction(.{ .transition = .zoom }).?;
@@ -1530,10 +1371,6 @@ pub const Runtime = struct {
try std.testing.expect(apply(&state, slide, null));
try std.testing.expectEqual(animation.Transition.off, state.panel_transition);
try std.testing.expect(!apply(&state, slide, "yes"));
- const scene = findAction(.{ .scene = std.enums.values(Scene)[0] }).?;
- try std.testing.expect(apply(&state, scene, "on"));
- try std.testing.expect(apply(&state, scene, "on"));
- try std.testing.expect(state.post.has(std.enums.values(Scene)[0]));
}
test "a toggle flips when bare and sets when told on or off" {
@@ -1569,53 +1406,6 @@ pub const Runtime = struct {
try std.testing.expectEqual(animation.Transition.ascii, state.panel_transition);
try std.testing.expect(apply(&state, find("PanelAscii").?, null));
try std.testing.expectEqual(animation.Transition.off, state.panel_transition);
- try std.testing.expect(apply(&state, find("Crt").?, null));
- try std.testing.expect(state.post.has(.crt));
- }
-
- test "the post chain runs in the order its passes were put in, and Shader off empties it of files" {
- var state: Runtime = .{};
- try std.testing.expect(apply(&state, find("Shader").?, " ~/a.glsl\n"));
- try std.testing.expect(apply(&state, find("Crt").?, "on"));
- try std.testing.expect(apply(&state, find("Shader").?, "/b.glsl"));
- const chain = state.post.list();
- try std.testing.expectEqual(@as(usize, 3), chain.len);
- try std.testing.expectEqualStrings("~/a.glsl", chain[0].path.get());
- try std.testing.expectEqual(Scene.crt, chain[1].scene.?);
- try std.testing.expectEqualStrings("/b.glsl", chain[2].path.get());
- const moved = state.post.generation;
- // A file named again leaves; the others keep their order.
- try std.testing.expect(apply(&state, find("Shader").?, "~/a.glsl"));
- try std.testing.expect(state.post.generation != moved);
- try std.testing.expectEqual(Scene.crt, state.post.list()[0].scene.?);
- try std.testing.expect(apply(&state, find("Shader").?, "off"));
- try std.testing.expectEqual(@as(usize, 1), state.post.len);
- try std.testing.expect(!apply(&state, find("Shader").?, null));
- try std.testing.expect(apply(&state, find("ShaderAnimation").?, "always"));
- try std.testing.expectEqual(ShaderAnimation.always, state.shader_animation);
- try std.testing.expect(!apply(&state, find("ShaderAnimation").?, "sometimes"));
- }
-
- test "a bundled pass takes a level: on is the default, 0 and off take it out, and the old words still flip" {
- var state: Runtime = .{};
- const crt = find("Crt").?;
- try std.testing.expect(apply(&state, crt, "on"));
- try std.testing.expectEqual(@as(u8, Post.default_level), state.post.level(.crt));
- try std.testing.expect(apply(&state, find("Shader").?, "/after.glsl"));
- const moved = state.post.generation;
- try std.testing.expect(apply(&state, crt, "3"));
- try std.testing.expectEqual(@as(u8, 3), state.post.level(.crt));
- // A new level keeps its place in the chain.
- try std.testing.expectEqual(Scene.crt, state.post.list()[0].scene.?);
- try std.testing.expect(state.post.generation != moved);
- try std.testing.expect(!apply(&state, crt, "4"));
- try std.testing.expect(!apply(&state, crt, "loud"));
- try std.testing.expect(apply(&state, crt, "0"));
- try std.testing.expect(!state.post.has(.crt));
- try std.testing.expect(apply(&state, crt, null));
- try std.testing.expectEqual(@as(u8, Post.default_level), state.post.level(.crt));
- try std.testing.expect(apply(&state, crt, "off"));
- try std.testing.expectEqual(@as(u8, 0), state.post.level(.crt));
}
test "Lift takes a style, on is auto, and bare flips it off and back to auto" {
@@ -1732,7 +1522,6 @@ pub const Runtime = struct {
.capabilities = .{
.font_picker = true,
.panel_transitions = true,
- .scene_shaders = true,
.tagline_font_size = true,
.window_opacity = true,
.window_blur = true,
@@ -1742,13 +1531,12 @@ pub const Runtime = struct {
.state = &state,
};
const values = [_][2][]const u8{
- .{ "TaglineSize", "73" }, .{ "WindowOpacity", "85" }, .{ "WindowBlur", "40" },
- .{ "MessageLinger", "1500" }, .{ "MessageFall", "1500" }, .{ "MessageDissolve", "1500" },
- .{ "DumpDir", "~/dumps" }, .{ "Crt", "3" }, .{ "Shader", "~/crt.glsl" },
- .{ "ShaderAnimation", "always" }, .{ "TermImages", "petscii" }, .{ "JumpScope", "all" },
- .{ "SearchPlace", "column" }, .{ "SearchPane", "new" }, .{ "Lift", "rim" },
- .{ "Motion", "playful" }, .{ "InactiveDim", "35" }, .{ "GripWidth", "200" },
- .{ "CallstackDepth", "16" }, .{ "Tab", "8" }, .{ "SearchRows", "12" },
+ .{ "TaglineSize", "73" }, .{ "WindowOpacity", "85" }, .{ "WindowBlur", "40" },
+ .{ "MessageLinger", "1500" }, .{ "MessageFall", "1500" }, .{ "MessageDissolve", "1500" },
+ .{ "DumpDir", "~/dumps" }, .{ "TermImages", "petscii" }, .{ "JumpScope", "all" },
+ .{ "SearchPlace", "column" }, .{ "SearchPane", "new" }, .{ "Lift", "rim" },
+ .{ "Motion", "playful" }, .{ "InactiveDim", "35" }, .{ "GripWidth", "200" },
+ .{ "CallstackDepth", "16" }, .{ "Tab", "8" }, .{ "SearchRows", "12" },
};
for (values) |v| try std.testing.expect(apply(&state, find(v[0]).?, v[1]));
try std.testing.expect(state.font.requested_name.set("Wanted Mono"));
@@ -1785,7 +1573,6 @@ pub const Runtime = struct {
defaults_context.capabilities = .{
.font_picker = false,
.panel_transitions = true,
- .scene_shaders = false,
.tagline_font_size = false,
};
defaults_context.state = &defaults;
@@ -1793,7 +1580,7 @@ pub const Runtime = struct {
try writeReport(&out, defaults_context);
const defaults_report = storage[0..out.end];
// A setting this shell does not have reads so, as a comment.
- for ([_][]const u8{ "# WindowOpacity unsupported\n", "# WindowBlur unsupported\n", "# Font unsupported\n", "# Crt unsupported\n", "# TaglineSize unsupported\n", "# Ligatures unsupported\n" }) |expected|
+ for ([_][]const u8{ "# WindowOpacity unsupported\n", "# WindowBlur unsupported\n", "# Font unsupported\n", "# TaglineSize unsupported\n", "# Ligatures unsupported\n" }) |expected|
try std.testing.expect(std.mem.indexOf(u8, defaults_report, expected) != null);
try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Font in use") == null);
// Every line before the blank one is a ctl word and its value, or a