diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 23:27:29 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 23:58:31 -0300 |
| commit | cd3627307740896426830423598d2e1a8e27b024 (patch) | |
| tree | 8cb845c8da5d07c15d9d234f285bff9cffb83449 /src | |
| parent | 342650183a54dcfcdce6ca4d45d6fdf48b2d1c1c (diff) | |
| download | pardes-cd3627307740896426830423598d2e1a8e27b024.tar.gz pardes-cd3627307740896426830423598d2e1a8e27b024.zip | |
settings #5, three behaviour knobs go, each the value it had by default: ProgramEsc (in a raw terminal Esc goes back a pane and Shift-Esc is the program's Esc; keys.zig's at-the-prompt Esc, which only ProgramEsc reached, goes), JumpScope (Back and Forward keep to the focused pane's file first; Jump.jumpBy's scope test goes) and WindowBlur (the macOS window draws no blur: macos.zig's pardes_window_blur, its header line, and AppDelegate.swift's NSVisualEffectView backdrop go, built nowhere here; Capabilities.window_blur with them); deleted tests: "with ProgramEsc raw tty Escape only leaves at a shell prompt", "modes: with JumpScope all, Ctrl-o and Ctrl-i take every place in the order it was jumped to, and bare JumpScope is file again", "window blur defaults off and validates without changing opacity", macos.zig's "mac window blur builtin reaches the ABI without changing opacity", and the JumpScope all half of "settings: Back and Forward written to exec keep to the focused file"; rewritten: dump's settings test on Wrap, the PDF jump test without its scope check, other-files' jump to a closed file from the +Jumps listing (no file to keep to); the reference, guide, helix-keys and macos docs lose the three; no golden changes; gates on tui: core-test 961/961, behaviour-test 240/240, unit-test 1476/1477, pane-test 171/172, snap all 105 scripts ok, process-test 0 of 37 failed; gui unit-test 1520/1521
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src')
| -rw-r--r-- | src/CHANGELOG.md | 4 | ||||
| -rw-r--r-- | src/Jump.zig | 10 | ||||
| -rw-r--r-- | src/builtins.zig | 7 | ||||
| -rw-r--r-- | src/config.zig | 57 | ||||
| -rw-r--r-- | src/dump.zig | 4 | ||||
| -rw-r--r-- | src/keys.zig | 41 | ||||
| -rw-r--r-- | src/macos.zig | 25 | ||||
| -rw-r--r-- | src/macos/Sources/AppDelegate.swift | 46 | ||||
| -rw-r--r-- | src/macos/pardes.h | 2 |
9 files changed, 33 insertions, 163 deletions
diff --git a/src/CHANGELOG.md b/src/CHANGELOG.md index ba9bc911..69d9d649 100644 --- a/src/CHANGELOG.md +++ b/src/CHANGELOG.md @@ -19,6 +19,10 @@ - SearchPlace, SearchPane and SearchRows: a query pane is attached under the pane that asked, eight rows under its line 1, and the next search from that pane reuses it; the finder column is gone with them. + - ProgramEsc: in a raw terminal Esc goes back a pane and Shift-Esc is + the program's Esc. + - JumpScope: Back and Forward keep to the focused pane's file first. + - WindowBlur: the macOS window draws no blur behind a translucent ground. - What pardes keeps on disk is in xitdb databases now (a pinned commit of github.com/xit-vcs/xitdb, pure Zig). The state file, `pardes.xitdb` in diff --git a/src/Jump.zig b/src/Jump.zig index 131d7e9d..2220f3c8 100644 --- a/src/Jump.zig +++ b/src/Jump.zig @@ -226,10 +226,10 @@ pub fn trackJump(p: *Pardes) void { /// 9P exec. `jcur` is the entry where you are; the step moves it to the /// entry it lands on, and the entries it passed over stay where they are. /// -/// JumpScope file, from a pane with a file: the nearest entry that way in -/// this pane, else in this file in any pane (a closed one's too), else, -/// with none of this file left that way, the nearest of any file, as -/// JumpScope all always takes. Forward mirrors Back, so it retraces a run +/// From a pane with a file: the nearest entry that way in this pane, else +/// in this file in any pane (a closed one's too), else, with none of this +/// file left that way, the nearest of any file; from a terminal or a +/// scratch, the nearest of any. Forward mirrors Back, so it retraces a run /// of Backs inside one file step for step, and Forwards end, as they /// always have, at the newest entry. pub fn jumpBy(p: *Pardes, delta: i32) void { @@ -239,7 +239,7 @@ pub fn jumpBy(p: *Pardes, delta: i32) void { return p.setMessage(p.active, if (older) "Back: nothing further back" else "Forward: nothing further on"); var next = if (older) p.jumps.cur - 1 else p.jumps.cur + 1; // A terminal or a scratch has no file to keep to: the step is global. - if (p.settings.jump_scope == .file) if (p.panes[p.active]) |here| if (Pardes.recentPlace(here)) |place| if (place.path.len > 0) { + if (p.panes[p.active]) |here| if (Pardes.recentPlace(here)) |place| if (place.path.len > 0) { const hash = if (jumpPath(here)) |path| std.hash.Wyhash.hash(0, path) else 0; // The nearest of this pane's own wins over a nearer one of this // file in another pane: the step does not move the keyboard. diff --git a/src/builtins.zig b/src/builtins.zig index 5b15a968..4c6fc367 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -22,7 +22,6 @@ pub const frontend: config.Runtime.Capabilities = .{ // The tty's font belongs to its emulator. .tagline_font_size = pardes.platform != .tui, .window_opacity = pardes.platform == .gui or pardes.platform == .macos, - .window_blur = pardes.platform == .macos, // The grip's width, the cursor's blink and the Pet are the SDL window's. .pixels = pardes.platform == .gui, }; @@ -32,8 +31,8 @@ pub const frontend: config.Runtime.Capabilities = .{ /// its own frontend does (`viewCapabilities`), so a terminal's replica of a /// window's session steps as the window's own does, and back. pub const desktop = pardes.platform == .tui or pardes.platform == .gui; -const window_capabilities: config.Runtime.Capabilities = .{ .font_picker = true, .tagline_font_size = true, .window_opacity = true, .window_blur = false, .pixels = true }; -const terminal_capabilities: config.Runtime.Capabilities = .{ .font_picker = false, .tagline_font_size = false, .window_opacity = false, .window_blur = false, .pixels = false }; +const window_capabilities: config.Runtime.Capabilities = .{ .font_picker = true, .tagline_font_size = true, .window_opacity = true, .pixels = true }; +const terminal_capabilities: config.Runtime.Capabilities = .{ .font_picker = false, .tagline_font_size = false, .window_opacity = false, .pixels = false }; /// The words this build has: a desktop build's are the window's. pub const capabilities: config.Runtime.Capabilities = if (desktop) window_capabilities else frontend; @@ -243,7 +242,7 @@ pub const registry = struct { // a switch flips bare, a choice steps, and DumpDir and Shell bare // are the default .toggle, .dump_dir, .choice, .shell => false, - .theme, .font, .tagline_size, .window_opacity, .window_blur, .message_linger, .inactive_dim, .grip_width => true, + .theme, .font, .tagline_size, .window_opacity, .message_linger, .inactive_dim, .grip_width => true, // bare, it says the current value (exec.applySettingBuiltin) .tab, .callstack_depth => false, }; diff --git a/src/config.zig b/src/config.zig index 6f45adba..3e05d7e1 100644 --- a/src/config.zig +++ b/src/config.zig @@ -114,7 +114,6 @@ pub const leader_path = paths: { .Search = null, .Panes = null, .More = null, - .JumpScope = null, .Debug = "td", .Msg = null, .Verbose = null, @@ -149,10 +148,8 @@ pub const leader_path = paths: { table.set(.MessageLinger, null); table.set(.DumpDir, null); if (builtins.capabilities.window_opacity) table.set(.WindowOpacity, null); - if (builtins.capabilities.window_blur) table.set(.WindowBlur, null); if (builtins.capabilities.pixels) table.set(.CursorBlink, null); table.set(.JumpTrail, null); - table.set(.ProgramEsc, null); if (builtins.capabilities.pixels) table.set(.GripWidth, null); table.set(.InactiveDim, null); if (builtins.capabilities.pixels) table.set(.Pet, null); @@ -259,8 +256,8 @@ pub const jump_keys = [_]struct { chord: Chord, cmd: Builtin }{ /// Shift-Esc: the Esc nothing swallows. In every mode and pane it does what /// Esc does from normal mode, back to the previous pane (Last); in a raw -/// terminal plain Esc does it and Shift-Esc is the program's Esc, unless -/// ProgramEsc is on. Ctrl-b alone toggles raw. +/// terminal plain Esc does it and Shift-Esc is the program's Esc. Ctrl-b +/// alone toggles raw. pub const back_out: []const Chord = &.{.{ .cp = Key.escape, .shift = true }}; pub const tty_toggle_default: u21 = 'b'; @@ -701,16 +698,12 @@ pub const Runtime = struct { /// A jump of the cursor leaves a short trail that fades: a setting /// alone, each frontend draws it (jump_trail.zig). jump_trail: bool = false, - /// In a raw terminal, Esc goes to the program and Shift-Esc backs out - /// (off, the default: Esc backs out and Shift-Esc is the program's). - program_esc: bool = false, /// How long a message stays after the key or click that dismisses it. message_linger_ms: u16 = 800, /// Where Dump writes and a relative Restore looks; empty is the default /// ($XDG_DATA_HOME/pardes, else ~/.local/share/pardes). dump_dir: Text(limits.host_path_cap) = .{}, window_opacity: u8 = 100, - window_blur: u8 = 0, window_opacity_pending: bool = true, /// The window's companion in the workspace tag's blank space /// (gui/pet.zig), or none: a setting alone, the window moves it. @@ -734,18 +727,13 @@ pub const Runtime = struct { tagline_percent: u8 = 100, } = .{}, - /// What Back and Forward keep to (Jump.jumpBy): `file`, the places in - /// the focused pane's file first, other files only once those run out - /// that way; `all`, every place in the order it was jumped to. - jump_scope: JumpScope = .file, /// acme's Tab: a tab's width in cells, in every pane (config.tab_now /// is what the drawing and the column arithmetic read). tab: u16 = tab_width, callstack_depth: u8 = @import("lsp/lsp.zig").callstack_default_depth, - pub const JumpScope = enum { file, all }; /// A setting that is one of a few words, each an enum field of Runtime. - pub const Choice = enum { jump_scope, pet }; + pub const Choice = enum { pet }; pub const Pet = enum { off, cat, frog }; pub const tagline_percent_min: u8 = 1; @@ -807,7 +795,6 @@ pub const Runtime = struct { font_picker: bool, tagline_font_size: bool, window_opacity: bool = false, - window_blur: bool = false, /// The shell draws its own pixels (the SDL window): the grip at /// GripWidth, its own cursor blink, the Pet. pixels: bool = false, @@ -815,7 +802,7 @@ pub const Runtime = struct { pub const Capability = std.meta.FieldEnum(Capabilities); - pub const Toggle = enum { wrap, debug, verbose, cursor_blink, jump_trail, program_esc }; + pub const Toggle = enum { wrap, debug, verbose, cursor_blink, jump_trail }; pub const Action = union(enum) { toggle: Toggle, @@ -824,7 +811,6 @@ pub const Runtime = struct { font, tagline_size, window_opacity, - window_blur, message_linger, dump_dir, /// A percentage, 0 through 100. @@ -856,7 +842,6 @@ pub const Runtime = struct { return switch (action) { .font, .tagline_size => .font_picker, .window_opacity => .window_opacity, - .window_blur => .window_blur, .grip_width => .pixels, .toggle => |field| switch (field) { .cursor_blink => .pixels, @@ -874,7 +859,6 @@ pub const Runtime = struct { .{ .word = "Verbose", .action = .{ .toggle = .verbose }, .doc = "A builtin says its own name on the message row as it runs, on or off." }, .{ .word = "CursorBlink", .action = .{ .toggle = .cursor_blink }, .doc = "The cursor blinks, solid while typing, on or off." }, .{ .word = "JumpTrail", .action = .{ .toggle = .jump_trail }, .doc = "A jump of the cursor leaves a short trail that fades, on or off." }, - .{ .word = "ProgramEsc", .action = .{ .toggle = .program_esc }, .doc = "In a raw terminal, Esc goes to the program and Shift-Esc backs out, on; off (the default) swaps them." }, .{ .word = "GripWidth", .action = .grip_width, .doc = "The grip and scrollbar width, as a percent of the theme's rail." }, .{ .word = "InactiveDim", .action = .inactive_dim, .doc = "Fade the unfocused panes' text by a percentage, 0 through 100, 0 off." }, .{ .word = "Pet", .action = .{ .choice = .pet }, .doc = "The window's companion in the workspace tag's blank space: off, cat or frog." }, @@ -885,8 +869,6 @@ pub const Runtime = struct { .{ .word = "Font", .action = .font, .doc = "The body font, by name or path, and its size." }, .{ .word = "TaglineSize", .action = .tagline_size, .doc = "Scale the tag font, a percentage." }, .{ .word = "WindowOpacity", .action = .window_opacity, .doc = "The window's opacity, a percentage." }, - .{ .word = "WindowBlur", .action = .window_blur, .doc = "The blur behind a translucent window, a radius." }, - .{ .word = "JumpScope", .action = .{ .choice = .jump_scope }, .doc = "What Back and Forward keep to: file, the focused pane's file until it runs out that way, or all, every place in order." }, .{ .word = "CallstackDepth", .action = .callstack_depth, .doc = "Caller levels collected by Callstack, 1 through 64; default 8. Bare, it says the current limit." }, .{ .word = "Tab", .action = .tab, .doc = "A tab's width in cells, 1 through 16, in every pane; bare, it says the width." }, }; @@ -917,8 +899,8 @@ pub const Runtime = struct { for (std.enums.values(Toggle)) |field| if (actionCount(.{ .toggle = field }) != 1) @compileError("runtime toggle must occur exactly once: " ++ @tagName(field)); if (actionCount(.shell) != 1 or actionCount(.theme) != 1 or actionCount(.font) != 1 or - actionCount(.tagline_size) != 1 or actionCount(.window_opacity) != 1 or actionCount(.window_blur) != 1) - @compileError("Shell, Theme, Font, TaglineSize, WindowOpacity, and WindowBlur actions must each occur exactly once"); + actionCount(.tagline_size) != 1 or actionCount(.window_opacity) != 1) + @compileError("Shell, Theme, Font, TaglineSize and WindowOpacity actions must each occur exactly once"); } pub fn apply(state: *Runtime, setting: Setting, argument: ?[]const u8) bool { @@ -945,7 +927,6 @@ pub const Runtime = struct { state.window_opacity = number(u8, argument, " \t\r\n", 0, 100) orelse return false; state.window_opacity_pending = true; }, - .window_blur => state.window_blur = number(u8, argument, " \t\r\n", 0, 100) orelse return false, // Bare, it returns to the default directory. Else an absolute or // `~` path, to a directory there or to be made, that may be // written: a Dump there could never be, refused now. @@ -999,7 +980,7 @@ pub const Runtime = struct { /// words (`choices`), else its range or the kind of thing it takes. pub fn takes(action: Action) ?[]const u8 { return choices(action) orelse switch (action) { - .inactive_dim, .window_opacity, .window_blur => "0-100 (a percentage)", + .inactive_dim, .window_opacity => "0-100 (a percentage)", .grip_width => "50-300 (a percentage)", .tab => "1-16 (cells)", .callstack_depth => "1-64 (levels)", @@ -1092,7 +1073,7 @@ pub const Runtime = struct { else try out.print("{s} {s}\n", .{ setting.word, context.theme_name }), // A number in a field named as its action. - inline .window_opacity, .window_blur, .inactive_dim, .callstack_depth, .tab, .grip_width => |_, tag| try out.print("{s} {d}\n", .{ setting.word, @field(state, @tagName(tag)) }), + inline .window_opacity, .inactive_dim, .callstack_depth, .tab, .grip_width => |_, tag| try out.print("{s} {d}\n", .{ setting.word, @field(state, @tagName(tag)) }), .dump_dir => { const dir = if (state.dump_dir.len > 0) state.dump_dir.get() else context.default_dump_dir; if (dir.len > 0) try out.print("{s} {s}\n", .{ setting.word, dir }) else try out.print("# {s} (none)\n", .{setting.word}); @@ -1228,22 +1209,6 @@ pub const Runtime = struct { try std.testing.expect(state.window_opacity_pending); } - test "window blur defaults off and validates without changing opacity" { - const setting = find("WindowBlur").?; - var state: Runtime = .{}; - try std.testing.expectEqual(@as(u8, 0), state.window_blur); - try std.testing.expectEqual(Capability.window_blur, availability(setting.action).?); - for ([_][]const u8{ "0", " 40\n", "100" }, [_]u8{ 0, 40, 100 }) |argument, expected| { - try std.testing.expect(apply(&state, setting, argument)); - try std.testing.expectEqual(expected, state.window_blur); - try std.testing.expectEqual(@as(u8, 100), state.window_opacity); - } - for ([_]?[]const u8{ null, "", " \t\n", "101", "-1", "+40", "40%", "0.5", "40 20", "4_0", "0x28", "999999999999999" }) |argument| { - try std.testing.expect(!apply(&state, setting, argument)); - try std.testing.expectEqual(@as(u8, 100), state.window_blur); - } - } - test "font request tuple rejects atomically" { var state: Runtime = .{}; try std.testing.expect(requestFont(&state, "/fonts/old.ttf", "Old", 1200)); @@ -1286,15 +1251,13 @@ pub const Runtime = struct { .font_picker = true, .tagline_font_size = true, .window_opacity = true, - .window_blur = true, .pixels = true, }, .state = &state, }; const values = [_][2][]const u8{ - .{ "TaglineSize", "73" }, .{ "WindowOpacity", "85" }, .{ "WindowBlur", "40" }, + .{ "TaglineSize", "73" }, .{ "WindowOpacity", "85" }, .{ "MessageLinger", "1500" }, .{ "DumpDir", "~/dumps" }, - .{ "JumpScope", "all" }, .{ "GripWidth", "200" }, .{ "InactiveDim", "35" }, .{ "CallstackDepth", "16" }, .{ "Tab", "8" }, }; @@ -1339,7 +1302,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", "# TaglineSize unsupported\n" }) |expected| + for ([_][]const u8{ "# WindowOpacity unsupported\n", "# Font unsupported\n", "# TaglineSize 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 diff --git a/src/dump.zig b/src/dump.zig index 455f172d..976344b6 100644 --- a/src/dump.zig +++ b/src/dump.zig @@ -672,12 +672,12 @@ test "a dump keeps the session's settings, and a restore applies them" { const p = try Pardes.init(gpa, .{ .tty_only = true }); defer p.deinit(); try std.testing.expect(p.executeBuiltinLine(p.active, "Verbose off")); - try std.testing.expect(p.executeBuiltinLine(p.active, "JumpScope all")); + try std.testing.expect(p.executeBuiltinLine(p.active, "Wrap off")); try dumpState(p); const restored = try initFromDump(gpa, .{ .tty_only = true }, p.dump_out.?); defer restored.deinit(); try std.testing.expect(!restored.settings.verbose); - try std.testing.expectEqual(config.Runtime.JumpScope.all, restored.settings.jump_scope); + try std.testing.expect(!restored.settings.wrap); } test "a session with every column it may hold dumps and restores them all" { diff --git a/src/keys.zig b/src/keys.zig index 9f16b42a..9496d37a 100644 --- a/src/keys.zig +++ b/src/keys.zig @@ -169,9 +169,9 @@ pub fn handleKey(p: *Pardes, key: Key) void { if (p.window_pick != null) return layout.windowKey(p, key); const pane = p.panes[p.active] orelse return; layout.noteTyped(p); - // In a raw terminal the two Escs swap unless ProgramEsc is on: Esc - // backs out, and Shift-Esc is the program's, sent as a plain Esc. - const raw_esc = key.cp == Key.escape and !key.ctrl and !key.alt and !p.settings.program_esc and + // In a raw terminal the two Escs swap: Esc backs out, and Shift-Esc is + // the program's, sent as a plain Esc. + const raw_esc = key.cp == Key.escape and !key.ctrl and !key.alt and pane.isTerminal() and pane.body.mode == .tty and pane.focus == .body and pane.prompt == .none and tagline.focusedHeader(p) == null; if (raw_esc and key.shift) { @@ -210,10 +210,6 @@ pub fn handleKey(p: *Pardes, key: Key) void { p.prefix = .none; if (key.ctrl and !key.alt and key.cp == p.tty_toggle) return toggleTty(p, p.active); - // With ProgramEsc on, bare Escape leaves only at a shell prompt - // (Shift-Esc, above, always). - if (key.cp == Key.escape and !key.ctrl and !key.alt and !key.shift and exec.takesCommandLine(p, p.active)) - return exec.runBuiltin(p, .Last, p.active, "", null); panes.terminal.followOutput(pane); // typing snaps back to live output // Paste stays the window's, the one exception to forwarding a raw // tty's keys: Ctrl-V types the register at the program and @@ -642,37 +638,6 @@ test "raw tty Esc backs out and Shift-Esc is the program's Esc" { try std.testing.expectEqualStrings("\x1b", test_api.ptyBytes(p, null, &buf)); } -test "with ProgramEsc raw tty Escape only leaves at a shell prompt" { - const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24, .file = "mise.toml" }); - defer p.deinit(); - p.settings.program_esc = true; - _ = exec.spawnTty(p, 0); - const shell = p.active; - const pane = p.panes[shell].?; - var buf: [256]u8 = undefined; - _ = test_api.ptyBytes(p, null, &buf); - - // Ordinary keys reach the child; Shift-Escape is the one unconditional way - // out and sends it nothing. - p.update(.{ .key = .{ .cp = 'x', .text = "x" } }); - try std.testing.expectEqual(shell, p.active); - try std.testing.expect(test_api.ptyBytes(p, null, &buf).len > 0); - - p.update(.{ .key = .{ .cp = Key.escape, .shift = true } }); - try std.testing.expectEqual(@as(usize, 0), p.active); - try std.testing.expectEqualStrings("", test_api.ptyBytes(p, null, &buf)); - try std.testing.expectEqual(Text.Mode.tty, pane.body.mode); - - p.update(.{ .key = .{ .cp = Key.escape } }); // back into the shell - try std.testing.expectEqual(shell, p.active); - _ = test_api.ptyBytes(p, null, &buf); - - p.update(.{ .key = .{ .cp = Key.escape } }); // bare Escape leaves at a prompt - try std.testing.expectEqual(@as(usize, 0), p.active); - try std.testing.expectEqualStrings("", test_api.ptyBytes(p, null, &buf)); - try std.testing.expectEqual(Text.Mode.tty, pane.body.mode); -} - test "the Del question shows only once its delay is up: a quick SPC d j never sees it" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 40 }); defer p.deinit(); diff --git a/src/macos.zig b/src/macos.zig index 13b8b332..17b1bf35 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -724,13 +724,6 @@ export fn pardes_window_opacity() u8 { return st.core.settings.window_opacity; } -/// Public AppKit backdrop strength, independent of background paint opacity. -export fn pardes_window_blur() u8 { - pardes.turn.wake(); - defer pardes.turn.rest(); - return if (state) |st| st.core.settings.window_blur else 0; -} - fn taglineFontPercent(core: ?*const pardes.Pardes) u8 { return if (core) |p| p.settings.font.tagline_percent else pardes.config.gui_tagline_font_percent; } @@ -2549,7 +2542,6 @@ test "pardes.h declares every export the way it is defined" { try expectSameAbi(@TypeOf(c.pardes_active_dirty), @TypeOf(pardes_active_dirty)); try expectSameAbi(@TypeOf(c.pardes_theme_bg), @TypeOf(pardes_theme_bg)); try expectSameAbi(@TypeOf(c.pardes_window_opacity), @TypeOf(pardes_window_opacity)); - try expectSameAbi(@TypeOf(c.pardes_window_blur), @TypeOf(pardes_window_blur)); } test "pardes.h matches the Zig boundary" { @@ -2868,20 +2860,3 @@ test "mac tag layer ABI preserves logical capacity and physical grip" { try std.testing.expectEqual(encodeCell(.{}).len, canonical[10].len); } -test "mac window blur builtin reaches the ABI without changing opacity" { - try std.testing.expectEqual(@as(u8, 0), pardes_window_blur()); - const gpa = std.testing.allocator; - const core = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 8, .rows = 3 }); - defer core.deinit(); - state = .{ .gpa = gpa, .threaded = undefined, .io = std.testing.io, .core = core, .runtime = .{}, .config_arena = .init(gpa), .prompt_rcs = .{} }; - defer { - state.?.config_arena.deinit(); - state = null; - } - try std.testing.expect(core.executeBuiltinLine(0, "WindowOpacity 71")); - for ([_][]const u8{ "WindowBlur 0", "WindowBlur 40", "WindowBlur 100", "WindowBlur 101", "WindowBlur 0" }, [_]u8{ 0, 40, 100, 100, 0 }) |command, expected| { - try std.testing.expect(core.executeBuiltinLine(0, command)); - try std.testing.expectEqual(expected, pardes_window_blur()); - try std.testing.expectEqual(@as(u8, 71), pardes_window_opacity()); - } -} diff --git a/src/macos/Sources/AppDelegate.swift b/src/macos/Sources/AppDelegate.swift index 3cce7592..dbc0fbc9 100644 --- a/src/macos/Sources/AppDelegate.swift +++ b/src/macos/Sources/AppDelegate.swift @@ -15,9 +15,6 @@ import AppKit final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate { private var window: NSWindow! private var view: PardesView! - /// The blur behind the grid, shown only while the theme declares no - /// background of its own. See applyTheme. - private var backdrop: NSVisualEffectView! // One display-clock chain at a time. Input and pty notifications may all // call pump(), but none advances animation; they only observe this flag and // leave the already-scheduled frame alone. @@ -78,31 +75,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate { // isReleasedWhenClosed on would have AppKit release it out from under // that reference the moment the close button is pressed. window.isReleasedWhenClosed = false - // The grid and the blur are SIBLINGS in a plain container, not parent - // and child. A transparent theme has to show something through the - // grid, and AppKit will not blur what is behind a window unless an - // NSVisualEffectView asks it to. The backdrop can be hidden independently - // when blur is disabled or the ground is opaque; hiding a superview hides - // its subviews with it. Nested, an opaque theme drew a blank window. let container = NSView(frame: NSRect(origin: .zero, size: want)) container.autoresizesSubviews = true - backdrop = NSVisualEffectView(frame: container.bounds) - // .underWindowBackground is the material meant for exactly this — the - // full-window wash behind content, rather than the sidebar/HUD - // materials that carry their own tint. .behindWindow is what samples - // the desktop instead of the window's own layers. - backdrop.material = .underWindowBackground - backdrop.blendingMode = .behindWindow - // .active, not .followsWindowActiveState: the grid stays readable when - // the window is not key, and a backdrop that flattens to grey on focus - // loss makes an unfocused pardes look switched off. - backdrop.state = .active - backdrop.autoresizingMask = [.width, .height] view.frame = container.bounds view.autoresizingMask = [.width, .height] - // Order matters: the blur is BEHIND the grid. - container.addSubview(backdrop) - container.addSubview(view, positioned: .above, relativeTo: backdrop) + container.addSubview(view) window.contentView = container // Trim the content box down to whole cells: a partial column or row is @@ -465,8 +442,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate { /// Dress the WINDOW in what the core is wearing: the background AppKit /// paints where the view does not (the titlebar, and the strip a live - /// resize outruns), and the blur behind a theme that brings no background - /// of its own. + /// resize outruns). /// /// Cheap enough to call every pump: the view compares before it dirties /// itself, and the window properties are written only when the answer @@ -474,7 +450,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate { /// theme whose background happened to equal the view's starting guess /// would otherwise leave the window in AppKit's default clothes forever. private var dressed = false - private var appliedBlur: UInt8 = 0 private func applyTheme() { // Both reads happen every pump, and neither may be short-circuited by @@ -483,16 +458,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate { // tick would leave one of them unworn. let themeChanged = view.adoptThemeBG(pardes_theme_bg()) let opacityChanged = view.adoptWindowOpacity(pardes_window_opacity()) - let blur = pardes_window_blur() - let blurChanged = blur != appliedBlur - guard themeChanged || opacityChanged || blurChanged || !dressed else { return } - appliedBlur = blur - backdrop.alphaValue = CGFloat(blur) / 100 - backdrop.isHidden = blur == 0 || (view.themeBG != nil && view.backgroundAlpha >= 1) + guard themeChanged || opacityChanged || !dressed else { return } dressed = true - // Opacity paints the theme ground; blur controls the native material - // behind it. An opaque ground hides the backdrop without losing the - // requested strength, so lowering opacity restores the effect. if let rgb = view.themeBG { window.isOpaque = view.backgroundAlpha >= 1 window.backgroundColor = view.backgroundAlpha < 1 ? .clear : NSColor( @@ -509,10 +476,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate { + 0.0722 * CGFloat(rgb & 0xFF)) / 255 window.appearance = NSAppearance(named: luma > 0.5 ? .aqua : .darkAqua) } else { - // Transparent: the window stops painting anything of its own and - // the optional blur sits behind it. isOpaque false lets the desktop - // reach the backdrop at all — a titled window is opaque by default - // and would composite over it. + // Transparent: the window stops painting anything of its own. + // isOpaque false lets the desktop show through at all — a titled + // window is opaque by default and would composite over it. window.isOpaque = false window.backgroundColor = .clear window.appearance = NSAppearance(named: .darkAqua) diff --git a/src/macos/pardes.h b/src/macos/pardes.h index 62ae5218..c4470569 100644 --- a/src/macos/pardes.h +++ b/src/macos/pardes.h @@ -266,8 +266,6 @@ uint32_t pardes_theme_bg(void); // Read it once per pump beside pardes_theme_bg(): reading also acknowledges // whatever `WindowOpacity` asked for. 100 is opaque and is the default. uint8_t pardes_window_opacity(void); -// Backdrop material strength, 0..100; zero disables blur. Not a pixel radius. -uint8_t pardes_window_blur(void); // Pane taglines use this percentage of the current body font size. It is the // embedded default before init and the live core setting afterwards; the host |
