diff options
| -rw-r--r-- | build/snap.zig | 2 | ||||
| -rw-r--r-- | docs/typ/builtins-gui.json | 2 | ||||
| -rw-r--r-- | docs/typ/builtins-tui.json | 1 | ||||
| -rw-r--r-- | docs/typ/reference.typ | 16 | ||||
| -rw-r--r-- | shaders/decor.frag.glsl | 43 | ||||
| -rw-r--r-- | src/builtins.zig | 4 | ||||
| -rw-r--r-- | src/config.zig | 65 | ||||
| -rw-r--r-- | src/draw.zig | 443 | ||||
| -rw-r--r-- | src/gui/gui.zig | 381 | ||||
| -rw-r--r-- | src/pardes.zig | 7 | ||||
| -rw-r--r-- | src/surface.zig | 9 | ||||
| -rw-r--r-- | src/views.zig | 4 | ||||
| -rw-r--r-- | test/behaviour/root_ctl.zig | 2 | ||||
| -rw-r--r-- | test/behaviour/settings.zig | 2 | ||||
| -rw-r--r-- | test/gui-goldens.txt | 2 | ||||
| -rw-r--r-- | test/monkey9p.zig | 2 | ||||
| -rw-r--r-- | test/process/window.zig | 26 |
17 files changed, 36 insertions, 975 deletions
diff --git a/build/snap.zig b/build/snap.zig index ac4e55c5..ec705b5f 100644 --- a/build/snap.zig +++ b/build/snap.zig @@ -66,7 +66,7 @@ pub fn addTty(b: *std.Build, opts: struct { run_process_test.has_side_effects = true; b.step("process-test", "run the process tests: real sessions driven over their sockets (-- [filter])").dependOn(&run_process_test.step); // The window's own, run in full when asked (test/process/window.zig): - // the monkey over every Motion x Lift, and the frames against + // the monkey over every Motion, and the frames against // this machine's goldens (PARDES_GUI_GOLDEN=update rewrites them). const monkey_gui_step = b.step("monkey-gui", "random input to the hidden window across the effect settings (-Dplatform=gui; PARDES_GUI_MONKEY_SEED, _STEPS)"); const gui_golden_step = b.step("gui-golden", "the hidden window's scenes against test/gui-goldens.txt, this machine's (-Dplatform=gui; PARDES_GUI_GOLDEN=update rewrites)"); diff --git a/docs/typ/builtins-gui.json b/docs/typ/builtins-gui.json index 16fd9f2b..f2eb46d3 100644 --- a/docs/typ/builtins-gui.json +++ b/docs/typ/builtins-gui.json @@ -45,7 +45,6 @@ {"name": "GripWidth", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "The grip and scrollbar width, as a percent of the theme's rail."}, {"name": "Help", "leader": "SPC ?", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Open the help: every key and every builtin."}, {"name": "Hover", "leader": "SPC l k", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Ask the language server about the symbol under the cursor."}, - {"name": "InactiveDim", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "Fade the unfocused panes' text by a percentage, 0 through 100, 0 off."}, {"name": "Incl", "leader": null, "also": [], "arg": true, "scope": "root", "setting": false, "choices": null, "doc": "acme's Incl, for the session: `Incl dir ...` adds directories a look at a name found nowhere else is tried in (`stdio.h`, `<foo.h>`), bare lists them, `Incl -` empties the list."}, {"name": "Index", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Run the file's language indexer at its project root, writing the index.scip the language words ask first."}, {"name": "Joincol", "leader": "SPC c j", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Fold the active pane's column into the one on its right, keeping its panes."}, @@ -54,7 +53,6 @@ {"name": "Kill", "leader": null, "also": [], "arg": true, "scope": "root", "setting": false, "choices": null, "doc": "acme's Kill: stop the commands pardes started -- the lines it typed into a terminal, from an exec, a middle click or a pty/run, while their shell says they run (C mark to D)."}, {"name": "Last", "leader": "SPC j j", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Go back to the last place jumped from in another pane."}, {"name": "Left", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Move the keyboard to the pane, or column tag, to the left."}, - {"name": "Lift", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off, shadow, rim, auto", "doc": "How the focused pane stands off the page: off, shadow, rim or auto."}, {"name": "Ligatures", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "A font's programming ligatures draw across their cells, on or off."}, {"name": "LocationsConfig", "leader": null, "also": [], "arg": true, "scope": "root", "setting": false, "choices": null, "doc": "Set how location rows are drawn, or show how they are when bare."}, {"name": "Look", "leader": null, "also": ["enter", "right-click"], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Look at its argument: open the file or address it names, else find the word, as a right click does."}, diff --git a/docs/typ/builtins-tui.json b/docs/typ/builtins-tui.json index 3de0e0cc..2947aa98 100644 --- a/docs/typ/builtins-tui.json +++ b/docs/typ/builtins-tui.json @@ -41,7 +41,6 @@ {"name": "Grep", "leader": "SPC f g", "also": ["topbar"], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Find's sibling: Find matches file NAMES under this pane's directory, Grep matches the LINES of those files, on the disk engine's worker."}, {"name": "Help", "leader": "SPC ?", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Open the help: every key and every builtin."}, {"name": "Hover", "leader": "SPC l k", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Ask the language server about the symbol under the cursor."}, - {"name": "InactiveDim", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "Fade the unfocused panes' text by a percentage, 0 through 100, 0 off."}, {"name": "Incl", "leader": null, "also": [], "arg": true, "scope": "root", "setting": false, "choices": null, "doc": "acme's Incl, for the session: `Incl dir ...` adds directories a look at a name found nowhere else is tried in (`stdio.h`, `<foo.h>`), bare lists them, `Incl -` empties the list."}, {"name": "Index", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Run the file's language indexer at its project root, writing the index.scip the language words ask first."}, {"name": "Joincol", "leader": "SPC c j", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Fold the active pane's column into the one on its right, keeping its panes."}, diff --git a/docs/typ/reference.typ b/docs/typ/reference.typ index 22d68c99..1544ddb6 100644 --- a/docs/typ/reference.typ +++ b/docs/typ/reference.typ @@ -368,7 +368,7 @@ task while the editor waits in its syscall. Reading #file("/ctl") gives every setting, one a line, in the words a write takes (#word("Theme") `orchard`, #word("Verbose") `on`, #word("DumpDir") `<dir>`, #word("Shell") `/bin/bash`, ...), as #word("DumpConfig") does, and one the -frontend lacks as a comment (`# Lift unsupported`), so writing back what it +frontend lacks as a comment (`# GripWidth unsupported`), so writing back what it reads changes nothing. Writes take settings and session builtins (`scope = .session` in `src/builtins.zig`), acting at the pane with the keyboard: @@ -376,7 +376,7 @@ Writes take settings and session builtins (`scope = .session` in - A setting written bare steps to its next value (a switch flips). A value it does not take is `bad value in control message; ...` naming what it takes; #file("/commands") lists them. A setting the frontend cannot show is - refused (`Lift is GUI-only, invalid here`). + refused (`GripWidth is GUI-only, invalid here`). - #word("Newcol") makes an empty column right of the keyboard's, halving it. #word("Joincol") folds the keyboard's column into the one on its right (its panes go below that column's), `Joincol: no column to the right`. @@ -419,8 +419,8 @@ runs fails with the editor's words (`Mount: already mounted`, `Save /root/x: acc == Settings <settings> -A setting that chooses among words (`on`/`off` switches, #word("Lift"), -#word("Motion")) steps to its next value when given bare, as its +A setting that chooses among words (`on`/`off` switches, #word("Motion")) +steps to its next value when given bare, as its word clicked in a tag does. The same lines go in the startup file (#doc("config")). @@ -465,11 +465,9 @@ turning it off: #word("PanelSlide"), #word("PanelZoom"), #word("PanelDissolve"), #word("PanelAscii"), #word("PanelVertical"), #word("PanelEdges"), #word("PanelFall"), #word("PanelWave"), #word("PanelCurtain"), #word("PanelScramble"), #word("PanelType"); all -start off, and the web shell has none. The -focused pane can stand off the page: #word("Lift") `shadow|rim|auto|off`, -#word("InactiveDim") `<percent>`, #word("Motion") `off|crisp|smooth|bouncy|playful` (default -`smooth`), #word("Parallax"), #word("CursorBlink"), #word("GripWidth") `<50-300>`. Most are -the GUI's; #word("InactiveDim") works everywhere. No effect +start off, and the web shell has none. #word("Motion") +`off|crisp|smooth|bouncy|playful` (default `smooth`), #word("Parallax"), +#word("CursorBlink"), #word("GripWidth") `<50-300>`, the GUI's. No effect may lower the contrast of text, the selection or a focus indicator. Resting the pointer on text for about 32 ms (`look_preview_delay_frames`, diff --git a/shaders/decor.frag.glsl b/shaders/decor.frag.glsl index bb1ef0d6..72083ffe 100644 --- a/shaders/decor.frag.glsl +++ b/shaders/decor.frag.glsl @@ -9,14 +9,6 @@ // result is the overlay pipeline's exactly. // // Checker (flag 0x08000000): two colours in squares, or in stripes, see main. -// -// Soft (flag 0x10000000): a rectangle's shadow, rim or glow blurred by a Gaussian, -// in closed form (the product of two erf edges), on one quad grown by 3 -// sigma: no blur pass. Everything is in the quad's own 0..1 space, so a -// track's transform carries it: sigma per axis in the uv, the caster's -// offset from its shadow in fg.gb, the strength in fg.r. The caster's own -// rectangle is left alone (it is drawn already), and the alpha is pre-warped -// so black darkens in linear light, then dithered so it never bands. layout(std140, set = 3, binding = 0) uniform UiUniforms { float background_opacity; @@ -31,24 +23,6 @@ layout(location = 5) flat in vec4 v_clip; layout(location = 0) out vec4 o_col; -// erf to about 4e-4 (Winitzki's approximation): smooth, cheap, odd. -float erfApprox(float x) { - float x2 = x * x; - const float a = 0.147; - float e = sqrt(1.0 - exp(-x2 * (1.2732395 + a * x2) / (1.0 + a * x2))); - return x < 0.0 ? -e : e; -} - -// How much of [lo, hi] a Gaussian of sigma s centred at x covers. -float edge(float x, float lo, float hi, float s) { - float k = 0.70710678 / s; - return 0.5 * (erfApprox((x - lo) * k) - erfApprox((x - hi) * k)); -} - -float ign(vec2 p) { - return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715)))); -} - void main() { if (v_clip.z >= v_clip.x && (gl_FragCoord.x < v_clip.x || gl_FragCoord.x >= v_clip.z || gl_FragCoord.y < v_clip.y || gl_FragCoord.y >= v_clip.w)) discard; @@ -64,20 +38,5 @@ void main() { o_col = vec4(((k & 1) == 0 ? v_bg : v_fg) * opacity, 1.0); return; } - if ((v_effect.x & 0x10000000u) == 0u) { - o_col = vec4(v_bg * opacity, v_fg.r); - return; - } - vec2 s = v_uv; - vec2 m = 3.0 * s; - vec2 p = v_cell_uv; - vec2 caster0 = m - v_fg.gb; - vec2 caster1 = 1.0 - m - v_fg.gb; - if (all(greaterThanEqual(p, caster0)) && all(lessThan(p, caster1))) discard; - float a = v_fg.r * edge(p.x, m.x, 1.0 - m.x, s.x) * edge(p.y, m.y, 1.0 - m.y, s.y); - // Black darkens in linear light; a light colour (a rim, a glow) is laid - // on as it is, within §8.2's 25%. - if (all(equal(v_bg, vec3(0.0)))) a = 1.0 - pow(max(1.0 - a, 0.0), 1.0 / 2.2); - a = clamp(a + (ign(gl_FragCoord.xy) - 0.5) / 255.0, 0.0, 1.0); - o_col = vec4(v_bg * opacity, a); + o_col = vec4(v_bg * opacity, v_fg.r); } diff --git a/src/builtins.zig b/src/builtins.zig index 39ad9d7b..6b31aba7 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -244,8 +244,8 @@ pub const registry = struct { if (@backingInt(b) == i) return switch (setting.action) { // a switch flips bare, a choice steps, and DumpDir and Shell bare // are the default - .toggle, .transition, .dump_dir, .choice, .lift, .motion, .shell => false, - .theme, .font, .tagline_size, .window_opacity, .window_blur, .message_ms, .inactive_dim, .grip_width => true, + .toggle, .transition, .dump_dir, .choice, .motion, .shell => false, + .theme, .font, .tagline_size, .window_opacity, .window_blur, .message_ms, .grip_width => true, // bare, it says the current value (exec.applySettingBuiltin) .tab, .callstack_depth, .search_rows => false, }; diff --git a/src/config.zig b/src/config.zig index e2d81c6d..647f3112 100644 --- a/src/config.zig +++ b/src/config.zig @@ -169,9 +169,7 @@ pub const leader_path = paths: { if (builtins.capabilities.lift) table.set(.CursorBlink, null); if (builtins.capabilities.lift) table.set(.Parallax, null); table.set(.ProgramEsc, null); - if (builtins.capabilities.lift) table.set(.Lift, null); table.set(.Motion, null); - table.set(.InactiveDim, null); if (builtins.capabilities.lift) table.set(.GripWidth, null); if (builtins.capabilities.panel_transitions) { table.set(.PanelSlide, "as"); @@ -721,14 +719,6 @@ pub const Runtime = struct { /// A font's programming ligatures (`->`, `!=`) draw across their cells. /// Only a shell that shapes text has the setting (`Capabilities.ligatures`). ligatures: bool = true, - /// How the focused pane and the notices stand off the page (G1, - /// docs/render-pipeline.md §9.1), or off. Opt-in until the focus lift's - /// default is decided. Only a pixel shell draws it (`Capabilities.lift`). - lift: LiftStyle = .off, - /// Blends the unfocused panes' text toward each cell's own ground, - /// percent (0 off): the focused pane wins by comparison, its tag tint - /// untouched. Kept above min(each cell's contrast, 4.5). - inactive_dim: u8 = 0, /// The grip's button and the scrollbar under it, one width, as a percent /// of the theme's `rail_px` (acme's 12px Scrollwid at a 17px tagline): /// a pixel shell's (docs/typ/themes.typ). @@ -824,16 +814,6 @@ pub const Runtime = struct { /// A setting that is one of a few words, each an enum field of Runtime. pub const Choice = enum { pager, term_images, jump_scope, search_place, search_pane }; - /// shadow: a soft drop shadow. rim: a light hairline along the top of - /// the focused pane's tag rows. auto: a shadow on a light page; on a - /// dark one, where a shadow has nothing to darken, the other panes - /// recede instead (InactiveDim, at `auto_dim` unless it is set). - pub const LiftStyle = enum(u8) { off, shadow, rim, auto }; - /// What `Lift auto` dims the unfocused panes by on a dark page when - /// InactiveDim is 0: enough to read at a glance (the user's own init - /// sets 35), not so much that they stop being worth reading. - pub const auto_dim: u8 = 30; - pub const tagline_percent_min: u8 = 1; pub const tagline_percent_max: u8 = 100; @@ -918,12 +898,8 @@ pub const Runtime = struct { window_blur, message_ms: MessageTime, dump_dir, - /// A lift style, `on` (auto) or `off`; bare flips auto and off. - lift, /// A motion flavour. motion, - /// A percentage, 0 through 100. - inactive_dim, grip_width, tab, callstack_depth, @@ -955,7 +931,7 @@ pub const Runtime = struct { .window_opacity => .window_opacity, .window_blur => .window_blur, .transition => .panel_transitions, - .lift, .grip_width => .lift, + .grip_width => .lift, .toggle => |field| switch (field) { .ligatures => .ligatures, .cursor_blink, .parallax => .lift, @@ -980,9 +956,7 @@ pub const Runtime = struct { .{ .word = "CursorBlink", .action = .{ .toggle = .cursor_blink }, .doc = "The cursor blinks, solid while typing, on or off." }, .{ .word = "Parallax", .action = .{ .toggle = .parallax }, .doc = "A theme's page pattern moves with the text at a quarter of its speed, 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 = "Lift", .action = .lift, .doc = "How the focused pane stands off the page: off, shadow, rim or auto." }, .{ .word = "Motion", .action = .motion, .doc = "How animations move: off, crisp, smooth, bouncy or playful." }, - .{ .word = "InactiveDim", .action = .inactive_dim, .doc = "Fade the unfocused panes' text by a percentage, 0 through 100, 0 off." }, .{ .word = "GripWidth", .action = .grip_width, .doc = "The grip and scrollbar width, as a percent of the theme's rail." }, .{ .word = "MessageLinger", .action = .{ .message_ms = .linger }, .doc = "How long, in milliseconds, a message stays after what dismisses it." }, .{ .word = "MessageFall", .action = .{ .message_ms = .fall }, .doc = "How long, in milliseconds, a message takes to fall into its row." }, @@ -1113,17 +1087,7 @@ pub const Runtime = struct { now.* = stepped(@TypeOf(now.*), now.*, argument) orelse return false; }, }, - .lift => { - const text = std.mem.trim(u8, argument orelse "", " \t\r\n"); - state.lift = if (text.len == 0) - (if (state.lift == .off) .auto else .off) - else if (std.mem.eql(u8, text, "on")) - .auto - else - std.meta.stringToEnum(LiftStyle, text) orelse return false; - }, .motion => state.motion = stepped(animation.Motion.Flavour, state.motion, argument) orelse return false, - .inactive_dim => state.inactive_dim = number(u8, argument, " \t\r\n%", 0, 100) orelse return false, .grip_width => state.grip_width = number(u16, argument, " \t\r\n%", 50, 300) orelse return false, .callstack_depth => state.callstack_depth = number(u8, argument, " \t\r\n", 1, @import("lsp/lsp.zig").callstack_max_depth) orelse return false, .tab => state.tab = number(u16, argument, " \t\r\n", 1, 16) orelse return false, @@ -1149,7 +1113,6 @@ pub const Runtime = struct { .choice => |which| switch (which) { inline else => |field| comptime words.of(@FieldType(Runtime, @tagName(field))), }, - .lift => "on, " ++ comptime words.of(LiftStyle), .motion => comptime words.of(animation.Motion.Flavour), else => null, }; @@ -1159,7 +1122,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)", + .window_opacity, .window_blur => "0-100 (a percentage)", .grip_width => "50-300 (a percentage)", .tab => "1-16 (cells)", .callstack_depth => "1-64 (levels)", @@ -1253,7 +1216,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, .search_rows, .grip_width => |_, tag| try out.print("{s} {d}\n", .{ setting.word, @field(state, @tagName(tag)) }), + inline .window_opacity, .window_blur, .callstack_depth, .tab, .search_rows, .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}); @@ -1286,7 +1249,6 @@ pub const Runtime = struct { .choice => |which| switch (which) { inline else => |field| try out.print("{s} {s}\n", .{ setting.word, @tagName(@field(state, @tagName(field))) }), }, - .lift => try out.print("{s} {s}\n", .{ setting.word, @tagName(state.lift) }), .motion => try out.print("{s} {s}\n", .{ setting.word, @tagName(state.motion) }), }; if (context.locations.len > 0) try out.print("LocationsConfig {s}\n", .{context.locations}); @@ -1372,21 +1334,6 @@ pub const Runtime = struct { try std.testing.expectEqual(animation.Transition.off, state.panel_transition); } - test "Lift takes a style, on is auto, and bare flips it off and back to auto" { - var state: Runtime = .{}; - const lift = find("Lift").?; - try std.testing.expect(apply(&state, lift, null)); - try std.testing.expectEqual(LiftStyle.auto, state.lift); - try std.testing.expect(apply(&state, lift, "rim")); - try std.testing.expectEqual(LiftStyle.rim, state.lift); - try std.testing.expect(apply(&state, lift, null)); - try std.testing.expectEqual(LiftStyle.off, state.lift); - try std.testing.expect(apply(&state, lift, "on")); - try std.testing.expectEqual(LiftStyle.auto, state.lift); - try std.testing.expect(!apply(&state, lift, "sparkle")); - try std.testing.expectEqual(LiftStyle.auto, state.lift); - } - test "tagline size validates before mutating live state" { const setting = find("TaglineSize").?; var state: Runtime = .{}; @@ -1498,9 +1445,9 @@ pub const Runtime = struct { .{ "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" }, + .{ "SearchPlace", "column" }, .{ "SearchPane", "new" }, .{ "Motion", "playful" }, + .{ "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")); diff --git a/src/draw.zig b/src/draw.zig index 68e1fb41..2ddb8faf 100644 --- a/src/draw.zig +++ b/src/draw.zig @@ -119,29 +119,6 @@ pub fn place(p: *Pardes, s: *Surface) void { s.addRegion(.{ .kind = .workspace_tag, .rect = .{ .x = 0, .y = 0, .w = s.cols, .h = p.topBarHeight() } }); // A column carried to the window's right edge shows where it lands as a // rail in the last cell: the layers under it stop a cell short. - // Lift: the focused pane rises, the others settle back, each on its - // spring; a notice floats while Lift is on. - const lift = liftStyle(p); - for (&p.panes, &p.lifts, &p.lift_serials, 0..) |slot, *spring, *serial, id| { - const pane = slot orelse continue; - if (serial.* != pane.serial) { - serial.* = pane.serial; - spring.* = .{}; - } - // How focused it is, which both a lift and a dim follow: at this - // frame's own time, not the stepped animations' 16 ms grid. A grid - // snaps (it has no in-between), and so does nothing that shows it. - const shown = lift != .off or inactiveDim(p) != 0; - const motion = animation.Motion.of(if (shown and builtins.frontend.lift) p.settings.motion else .off); - // A flavour exaggerates what is only a few pixels (Motion.gain). - spring.retarget(if (id == p.active) animation.Motion.of(p.settings.motion).gain else 0, p.now_ns, motion); - _ = spring.step(p.now_ns); - } - for (s.regions[0..s.nregions]) |*region| switch (region.kind) { - .grip, .tag, .body, .rail => region.lift = if (lift != .off) std.math.clamp(p.lifts[region.owner].value(p.now_ns), -1, 2) else 0, - .notice => region.lift = if (lift != .off) 1 else 0, - else => {}, - }; if (p.drag == .column_move) rail: { const d = p.drag.column_move; const source = layout.columnBySerial(p, d.serial) orelse break :rail; @@ -345,154 +322,6 @@ fn paneFrame(s: *const Surface, serial: u32, rect: Rect) PaneFrame { return .{ .to = still, .at = still }; } -/// The Lift style as drawn: `auto` is a shadow on a light page, and on a -/// dark one, where a shadow has nothing to darken, no lift at all (the other -/// panes recede instead, `inactiveDim`). -pub fn liftStyle(p: *const Pardes) config.Runtime.LiftStyle { - return switch (p.settings.lift) { - .auto => if (darkPage(p)) .off else .shadow, - else => |style| style, - }; -} - -/// How far, in percent, the unfocused panes' text fades toward its ground: -/// InactiveDim, or under `Lift auto` on a dark page `auto_dim` while that -/// is unset. -fn inactiveDim(p: *const Pardes) u8 { - if (p.settings.inactive_dim != 0) return p.settings.inactive_dim; - return if (p.settings.lift == .auto and darkPage(p)) config.Runtime.auto_dim else 0; -} - -fn darkPage(p: *const Pardes) bool { - return if (p.theme().bg) |bg| colors.relativeLuminance(bg) < 0.18 else true; -} - -/// Pane `id`'s text, `amount` (0 to 1) of the way to its ground, on the grid -/// and on every layer of it: its tag, its body, its notices. Its grip keeps -/// its colour, which already says it is not the focused one. The focused -/// pane, still brightening, is faded in its body's text alone: its tag and -/// a selection are focus indicators, which no effect may alter. -fn recede(p: *Pardes, s: *Surface, id: usize, amount: f32, focused: bool) void { - const th = p.theme(); - const chrome = p.chromeTheme(); - const r = p.rects[id]; - const palette = th.palette; - var memo: Memo = .{}; - const text_x = r.x + @min(config.GUTTER, r.w); - var row = r.y; - while (row < @min(@as(u32, r.y) + r.h, s.rows)) : (row += 1) { - var col = text_x; - while (col < @min(@as(u32, r.x) + r.w, s.cols)) : (col += 1) { - const cell = s.at(col, row); - if (cell.default) continue; - const tagline_role = cell.style.font_role == .tagline; - if (focused and (tagline_role or selected(cell, th.sel_bg))) continue; - fadeStyle(&cell.style, if (tagline_role) chrome.tag_fg else th.fg, if (tagline_role) chrome.tag_bg else th.bg, palette, amount, &memo); - } - } - const body = &s.body_layers[id]; - if (body.rows != 0) for (body.cells[0 .. @as(usize, body.cols) * body.rows]) |*cell| { - if (!(focused and selected(cell, th.sel_bg))) fadeStyle(&cell.style, th.fg, th.bg, palette, amount, &memo); - }; - if (focused) return; - const tag = &s.tag_layers[id]; - if (tag.rows != 0) for (tag.cells[0 .. @as(usize, tag.cols) * tag.rows]) |*cell| fadeStyle(&cell.style, chrome.tag_fg, tag.bg, palette, amount, &memo); - for (0..Pane.Notices.max) |i| { - const notice = &s.tag_layers[NOTICE_LAYER_BASE + id * Pane.Notices.max + i]; - if (notice.rows != 0) for (notice.cells[0 .. @as(usize, notice.cols) * notice.rows]) |*cell| fadeStyle(&cell.style, chrome.tag_fg, notice.bg, palette, amount, &memo); - } -} - -fn selected(cell: *const Cell, sel_bg: [3]u8) bool { - return switch (cell.style.bg) { - .rgb => |rgb| std.mem.eql(u8, &rgb, &sel_bg), - else => false, - }; -} - -/// The few ink and paper pairs a pane has, each faded once a frame. -const Memo = struct { - keys: [32]?[6]u8 = @splat(null), - values: [32][3]u8 = undefined, - - fn faded(memo: *Memo, ink: [3]u8, paper: [3]u8, amount: f32) [3]u8 { - const key = ink ++ paper; - const slot = (@as(usize, ink[0]) *% 31 +% ink[1] *% 7 +% ink[2] +% @as(usize, paper[0]) *% 13 +% paper[1] *% 3 +% paper[2]) % memo.keys.len; - if (memo.keys[slot]) |held| if (std.mem.eql(u8, &held, &key)) return memo.values[slot]; - // Contrast falls as the ink nears its paper: the most of `amount` - // that keeps the pair at its own contrast or 4.5, whichever is lower. - const floor = @min(colors.contrast(ink, paper), 4.5); - var t = amount; - if (colors.contrast(blend(ink, paper, t), paper) < floor) { - var lo: f32 = 0; - var hi: f32 = t; - for (0..8) |_| { - const mid = (lo + hi) / 2; - if (colors.contrast(blend(ink, paper, mid), paper) >= floor) lo = mid else hi = mid; - } - t = lo; - } - memo.keys[slot] = key; - memo.values[slot] = blend(ink, paper, t); - return memo.values[slot]; - } -}; - -/// A cell's ink blended `amount` of the way toward its paper, never below -/// the pair's own contrast or 4.5, whichever is lower (docs/effects.md): -/// faint resolved first, reverse honoured, as InactiveDim always did. -fn fadeStyle(style: *CellStyle, default_fg: ?[3]u8, default_bg: ?[3]u8, palette: ?[16][3]u8, amount: f32, memo: *Memo) void { - if (style.invisible) return; - var fg = resolved(style.fg, default_fg, palette) orelse return; - const bg = resolved(style.bg, default_bg, palette) orelse return; - if (style.dim) for (&fg) |*channel| { - channel.* = @intCast(@as(u16, channel.*) * 6 / 10); - }; - const ink = if (style.reverse) bg else fg; - const paper = if (style.reverse) fg else bg; - const rgb = memo.faded(ink, paper, amount); - if (style.reverse) { - style.bg = .{ .rgb = rgb }; - if (style.dim) style.fg = .{ .rgb = fg }; - } else style.fg = .{ .rgb = rgb }; - style.dim = false; -} - -/// `t` of the way from one colour to the other in linear light (§8.2), so a -/// coloured ink does not muddy on its way to the paper. -fn blend(from: [3]u8, to: [3]u8, t: f32) [3]u8 { - var out: [3]u8 = undefined; - for (&out, from, to) |*o, a, b| { - const l = colors.to_linear[a] * (1 - t) + colors.to_linear[b] * t; - o.* = encoded[@intFromFloat(@round(std.math.clamp(l, 0, 1) * (encoded.len - 1)))]; - } - return out; -} - -/// Linear light back to an sRGB channel, in 4096 steps. -const encoded: [4096]u8 = blk: { - @setEvalBranchQuota(1_000_000); - var table: [4096]u8 = undefined; - for (&table, 0..) |*out, i| { - const l = @as(f64, @floatFromInt(i)) / 4095; - const c = if (l <= 0.0031308) l * 12.92 else 1.055 * std.math.pow(f64, l, 1.0 / 2.4) - 0.055; - out.* = @intFromFloat(@round(c * 255)); - } - break :blk table; -}; - -fn resolved(color: Color, default: ?[3]u8, palette: ?[16][3]u8) ?[3]u8 { - return switch (color) { - .rgb => |rgb| rgb, - .default => default, - // A theme's own sixteen, as the painters give them (Terminal.palColor). - .index => |index| if (palette != null and index < 16) palette.?[index] else blk: { - const rgb = @import("ghostty-vt").color.default[index]; - break :blk .{ rgb.r, rgb.g, rgb.b }; - }, - }; -} - pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface { const taped = pardes.tape.enter(p, .render); defer pardes.tape.leave(p, taped); @@ -546,9 +375,6 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface { .scroll_thumb = chrome.scroll_thumb, .match_tick = chrome.search_bg, .match_current = p.theme().fg orelse chrome.tag_fg, - .sel_fg = p.theme().sel_fg, - .sel_bg = p.theme().sel_bg, - .lift_style = @backingInt(liftStyle(p)), .rule_px = p.theme().rule_px orelse 2, .grip_border = boxBorder(p), .grip_focus_ring = chrome.box, @@ -590,16 +416,6 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface { if (region.kind == .notice) try joinNotice(p, s, arena, region); } - // Both ways on the same spring: the pane focus leaves dims as the one - // it reaches brightens, so a focus change never pops (Motion off snaps - // both). - for (p.panes, p.lifts, 0..) |slot, spring, id| { - if (slot == null) continue; - const focus = spring.value(p.now_ns) / animation.Motion.of(p.settings.motion).gain; - const amount = @as(f32, @floatFromInt(inactiveDim(p))) / 100 * std.math.clamp(1 - focus, 0, 1); - if (amount > 0.001) recede(p, s, id, amount, id == p.active); - } - try paintHeaders(p, s); switch (p.drag) { @@ -1696,167 +1512,7 @@ test "a notice wider than its band, as a shader's compile error is, draws its en } } -test "a lift is sampled at each frame's own time, and asks for frames only while it moves" { - const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24 }); - defer p.deinit(); - // A grid has no in-between: there a lift snaps. - if (!builtins.frontend.lift) return error.SkipZigTest; - _ = try p.setTestFile("text\n"); - p.newScratchBelow(0); - var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); - defer arena.deinit(); - const ms = std.time.ns_per_ms; - p.settings.lift = .shadow; - p.advance(1000 * ms); - _ = try p.render(arena.allocator()); - p.advance(3000 * ms); - _ = arena.reset(.retain_capacity); - _ = try p.render(arena.allocator()); - try std.testing.expect(!p.continuous()); - p.active = 0; - var lifts: [3]f32 = undefined; - // 144 Hz: 6.9 ms apart, none of them on a 16 ms step of its own. - for (&lifts, 0..) |*lift, i| { - p.advance(3000 * ms + @as(u64, @intCast(i)) * 6_944_444); - _ = arena.reset(.retain_capacity); - const s = try p.render(arena.allocator()); - lift.* = for (s.regionList()) |region| { - if (region.kind == .grip and region.owner == p.active) break region.lift; - } else return error.TestExpectedGrip; - try std.testing.expect(p.continuous()); - } - try std.testing.expect(lifts[0] < lifts[1] and lifts[1] < lifts[2]); - // Settled, it is exactly up, and the core is idle again. - p.advance(5000 * ms); - _ = arena.reset(.retain_capacity); - _ = try p.render(arena.allocator()); - try std.testing.expect(!p.continuous()); - try std.testing.expectEqual(@as(?u64, null), p.nextWake()); -} - -/// The contrast a pane's first body glyph `g` is drawn at, on the grid. -fn glyphContrast(p: *Pardes, s: *Surface, id: usize, g: u8) f32 { - const r = p.rects[id]; - const th = p.theme(); - var row = p.bodyTop(p.panes[id].?, r); - while (row < r.y + r.h) : (row += 1) { - var col = r.x + config.GUTTER; - while (col < r.x + r.w) : (col += 1) { - const cell = s.at(col, row); - if (cell.default or cell.len != 1 or cell.text[0] != g) continue; - var fg = resolved(cell.style.fg, th.fg orelse .{ 255, 255, 255 }, th.palette).?; - const bg = resolved(cell.style.bg, th.bg orelse .{ 0, 0, 0 }, th.palette).?; - if (cell.style.dim) for (&fg) |*channel| { - channel.* = @intCast(@as(u16, channel.*) * 6 / 10); - }; - return colors.contrast(fg, bg); - } - } - unreachable; -} - -test "a focused pane's text is never at less contrast than an unfocused one's, in any Lift, dim or theme" { - const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24 }); - defer p.deinit(); - _ = try p.setTestFile("text\n"); - p.newScratchBelow(0); - p.animate_theme_changes = false; - var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); - defer arena.deinit(); - const s_ns = std.time.ns_per_s; - var now: u64 = s_ns; - for (0..pardes.themes.len) |theme| { - colors.setThemeIndex(p, theme); - for (std.enums.values(config.Runtime.LiftStyle)) |style| for ([_]u8{ 0, 100 }) |dim| { - p.settings.lift = style; - p.settings.inactive_dim = dim; - var seen: [2]f32 = undefined; - for (&seen, [_]usize{ 0, 1 }) |*c, focus| { - p.active = focus; - _ = arena.reset(.retain_capacity); - _ = try p.render(arena.allocator()); - now += 2 * s_ns; - p.advance(now); - _ = arena.reset(.retain_capacity); - c.* = glyphContrast(p, try p.render(arena.allocator()), 0, 't'); - } - try std.testing.expect(seen[0] >= seen[1] - 1e-3); - // And the unfocused one is still legible. - try std.testing.expect(seen[1] >= @min(seen[0], 4.5) - 2e-2); - }; - } -} - -test "a dim leaves the focused pane's tag, grip and cells exactly as they were" { - const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24 }); - defer p.deinit(); - _ = try p.setTestFile("text\n"); - p.newScratchBelow(0); - var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); - defer arena.deinit(); - p.active = 0; - p.advance(std.time.ns_per_s); - const plain = try p.render(arena.allocator()); - const r = p.rects[0]; - var before: std.ArrayList(Cell) = .empty; - defer before.deinit(std.testing.allocator); - for (r.y..r.y + r.h) |row| try before.appendSlice(std.testing.allocator, plain.cells[row * plain.cols + r.x ..][0..r.w]); - const tag_bg = plain.tag_layers[0].bg; - const tag_cells = try std.testing.allocator.dupe(Cell, plain.tag_layers[0].cells[0 .. @as(usize, plain.tag_layers[0].cols) * plain.tag_layers[0].rows]); - defer std.testing.allocator.free(tag_cells); - p.settings.inactive_dim = 100; - p.advance(3 * std.time.ns_per_s); - const dimmed = try p.render(arena.allocator()); - var i: usize = 0; - for (r.y..r.y + r.h) |row| for (dimmed.cells[row * dimmed.cols + r.x ..][0..r.w]) |cell| { - try std.testing.expect(cell.visuallyEqual(&before.items[i])); - i += 1; - }; - try std.testing.expectEqual(tag_bg, dimmed.tag_layers[0].bg); - for (tag_cells, dimmed.tag_layers[0].cells[0..tag_cells.len]) |a, b| try std.testing.expect(a.visuallyEqual(&b)); -} - -test "a dim never takes a pair below its own contrast or 4.5" { - for (pardes.themes) |theme| { - const fg = theme.fg orelse continue; - const bg = theme.bg orelse continue; - for ([_]bool{ false, true }) |reverse| for ([_]bool{ false, true }) |faint| { - var style: CellStyle = .{ .fg = .{ .rgb = fg }, .bg = .{ .rgb = bg }, .reverse = reverse, .dim = faint }; - var ink = fg; - if (faint) for (&ink) |*channel| { - channel.* = @intCast(@as(u16, channel.*) * 6 / 10); - }; - var memo: Memo = .{}; - fadeStyle(&style, null, null, null, 1, &memo); - const after = colors.contrast(style.fg.rgb, style.bg.rgb); - try std.testing.expect(after >= @min(colors.contrast(ink, bg), 4.5) - 2e-2); - }; - } -} - -test "a dim leaves a pair already under 4.5 alone, and reads a theme's own sixteen" { - var memo: Memo = .{}; - var low: CellStyle = .{ .fg = .{ .rgb = .{ 0x80, 0x80, 0x80 } }, .bg = .{ .rgb = .{ 0x60, 0x60, 0x60 } } }; - fadeStyle(&low, null, null, null, 1, &memo); - try std.testing.expectEqual([3]u8{ 0x80, 0x80, 0x80 }, low.fg.rgb); - // acme's bright white is black: faded, it stays a grey, never a white. - const acme = for (pardes.themes) |theme| { - if (std.mem.eql(u8, theme.name, "acme")) break theme; - } else unreachable; - var bright: CellStyle = .{ .fg = .{ .index = 15 } }; - memo = .{}; - fadeStyle(&bright, acme.fg, acme.bg, acme.palette, 0.3, &memo); - const rgb = bright.fg.rgb; - try std.testing.expect(rgb[0] == rgb[1] and rgb[0] < 0xc0); - // Reverse: the paper moves, the ink stays. - var reverse: CellStyle = .{ .fg = .{ .rgb = .{ 0, 0, 0 } }, .bg = .{ .rgb = .{ 255, 255, 255 } }, .reverse = true }; - memo = .{}; - fadeStyle(&reverse, null, null, null, 0.3, &memo); - try std.testing.expectEqual([3]u8{ 0, 0, 0 }, reverse.fg.rgb); - try std.testing.expect(reverse.bg.rgb[0] < 255); -} - -test "with no lift, no dim and no motion a focus switch asks for no frames" { +test "with no motion a focus switch asks for no frames" { const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24 }); defer p.deinit(); _ = try p.setTestFile("text\n"); @@ -1873,46 +1529,6 @@ test "with no lift, no dim and no motion a focus switch asks for no frames" { try std.testing.expect(!p.continuous()); } -test "each Motion flavour reaches the lift as its own trajectory" { - // A grid snaps; the flavours are a pixel shell's. - if (!builtins.frontend.lift) return error.SkipZigTest; - const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24 }); - defer p.deinit(); - _ = try p.setTestFile("text\n"); - p.newScratchBelow(0); - var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); - defer arena.deinit(); - p.settings.lift = .shadow; - var peaks: [5]f32 = undefined; - const ms = std.time.ns_per_ms; - var start: u64 = std.time.ns_per_s; - for (std.enums.values(animation.Motion.Flavour), &peaks) |flavour, *peak| { - p.settings.motion = flavour; - p.active = 1; - p.advance(start); - _ = arena.reset(.retain_capacity); - _ = try p.render(arena.allocator()); - start += 3 * std.time.ns_per_s; - p.advance(start); - _ = try p.render(arena.allocator()); - p.active = 0; - peak.* = 0; - var t: u64 = 0; - while (t <= 1500 * ms) : (t += 4 * ms) { - p.advance(start + t); - _ = arena.reset(.retain_capacity); - const s = try p.render(arena.allocator()); - const lift = for (s.regionList()) |region| { - if (region.kind == .grip and region.owner == 0) break region.lift; - } else unreachable; - peak.* = @max(peak.*, lift); - } - start += 3 * std.time.ns_per_s; - } - // Bouncy and playful pass their (exaggerated) mark; smooth never does. - try std.testing.expect(peaks[2] <= 1.001 and peaks[3] > 1.25 and peaks[4] > peaks[3]); -} - test "the caret is its own body: a page leaves it still under the moving text, a wheel scroll lands its springs on its line's new row" { if (!builtins.frontend.lift) return error.SkipZigTest; const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 30 }); @@ -2386,60 +2002,3 @@ test "focus moving to a pane with no cursor while the cursor glides lets the ses _ = try p.render(arena.allocator()); try std.testing.expect(!p.cursor_glide.moving() and !p.continuous()); } - -test "a pane focus reaches brightens on the same spring the one it leaves dims on, and Motion off snaps" { - if (!builtins.frontend.lift) return error.SkipZigTest; - const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24 }); - defer p.deinit(); - _ = try p.setTestFile(std.mem.asBytes(&@as([4][20]u8, @splat("some text on a line\n".*)))); - p.newScratchBelow(0); - p.settings.inactive_dim = 40; - p.settings.motion = .smooth; - var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); - defer arena.deinit(); - const ink = struct { - // The file's first glyph's ink, in whichever form its body has. - fn of(s: *const Surface) [3]u8 { - const body = &s.body_layers[0]; - const cells = if (body.rows != 0) body.cells[0 .. @as(usize, body.cols) * body.rows] else s.cells; - for (cells) |cell| if (!cell.default and cell.len == 1 and cell.text[0] == 's' and cell.style.font_role == .body) return switch (cell.style.fg) { - .rgb => |rgb| rgb, - else => .{ 0, 0, 0 }, - }; - return .{ 0, 0, 0 }; - } - }.of; - p.active = 1; - p.advance(std.time.ns_per_s); - _ = try p.render(arena.allocator()); - p.advance(3 * std.time.ns_per_s); - _ = arena.reset(.retain_capacity); - const dimmed = ink(try p.render(arena.allocator())); - p.active = 0; - var now: u64 = 3 * std.time.ns_per_s; - var last = dimmed[0]; - var steps: usize = 0; - for (0..30) |_| { - now += 16 * std.time.ns_per_ms; - p.advance(now); - _ = arena.reset(.retain_capacity); - const at = ink(try p.render(arena.allocator()))[0]; - // Brighter frame by frame (a flavour may pass it a little), never - // the whole way (46 levels here) at once. - try std.testing.expect(@abs(@as(i32, at) - @as(i32, last)) <= 12); - if (at != last) steps += 1; - last = at; - } - try std.testing.expect(steps >= 4); - p.advance(now + 2 * std.time.ns_per_s); - _ = arena.reset(.retain_capacity); - const bright = ink(try p.render(arena.allocator())); - try std.testing.expect(bright[0] > dimmed[0]); - - // Motion off: both snap. - p.settings.motion = .off; - p.active = 1; - p.advance(now + 3 * std.time.ns_per_s); - _ = arena.reset(.retain_capacity); - try std.testing.expectEqualSlices(u8, &dimmed, &ink(try p.render(arena.allocator()))); -} diff --git a/src/gui/gui.zig b/src/gui/gui.zig index ca3c7724..e97e6e38 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -480,8 +480,6 @@ const ImageInstance = extern struct { const old_layer_bit: u32 = 0x8000_0000; const clear_bg_bit: u32 = 0x4000_0000; const opaque_bg_bit: u32 = 0x2000_0000; -/// Decor that is a soft shadow, not a flat fill (decor.frag.glsl). -const soft_shadow_bit: u32 = 0x1000_0000; /// Decor that is a checker (decor.frag.glsl). const checker_bit: u32 = 0x0800_0000; /// A cell on the page's ground under the theme's dots, and a file name's @@ -8280,111 +8278,6 @@ fn addPattern(g: *Gui, gpa: std.mem.Allocator, x0: f32, y0: f32, x1: f32, y1: f3 instance.effect |= checker_bit; } -/// How a lift of 0 to 1 stands off the page: the shadow's blur and offset -/// in cell heights, and its darkest, where it leaves the caster's edge. -/// Within §8.2's budget: sigma 0.4-0.8 cell, at most 30% darker at the edge. -const Shadow = struct { - // A key light above: the drop is most of the blur, so the shadow hangs - // below and to the right and barely reaches over the caster's top. - const sigma: f32 = 0.42; - const drop: f32 = 0.34; - const side: f32 = 0.1; - const strength: f32 = 0.42; -}; - -/// A soft rectangle around `caster` (window pixels), blurred by `sigma` -/// and moved by (dx, dy): black is a shadow, a light colour a rim or a -/// glow. The caster's own rectangle is left alone, and `track` moves it all -/// as its caster moves. -fn addSoft(g: *Gui, gpa: std.mem.Allocator, caster: [4]f32, sigma_in: f32, dx: f32, dy: f32, strength: f32, rgb: [3]u8, track: ?pardes.animation.Track, win_w: f32, win_h: f32) !void { - if (strength <= 0.002) return; - const sigma = @max(0.5, sigma_in); - const x0 = caster[0] + dx - 3 * sigma; - const y0 = caster[1] + dy - 3 * sigma; - const x1 = caster[2] + dx + 3 * sigma; - const y1 = caster[3] + dy + 3 * sigma; - const w = x1 - x0; - const ht = y1 - y0; - if (w <= 0 or ht <= 0) return; - // In the quad's own 0..1 space (decor.frag.glsl): sigma per axis, the - // caster's offset from its shadow, the strength. - var instance: CellInstance = .{ - .x0 = (x0 / win_w) * 2.0 - 1.0, - .y0 = 1.0 - (y0 / win_h) * 2.0, - .x1 = (x1 / win_w) * 2.0 - 1.0, - .y1 = 1.0 - (y1 / win_h) * 2.0, - .u0 = sigma / w, - .v0 = sigma / ht, - .u1 = sigma / w, - .v1 = sigma / ht, - .fr = strength, - .fg = dx / w, - .fb = dy / ht, - .br = @as(f32, @floatFromInt(rgb[0])) / 255, - .bg = @as(f32, @floatFromInt(rgb[1])) / 255, - .bb = @as(f32, @floatFromInt(rgb[2])) / 255, - }; - setTransitionFields(&instance, track, fixedCellLayout(g), win_w, win_h, 0); - instance.effect |= soft_shadow_bit; - try g.decor.append(gpa, instance); -} - -/// How far each lift style may go on this theme without its text falling -/// below min(its contrast, 4.5): a shadow darkens, the others lighten. -const LiftCeilings = struct { - shadow: f32, - white: f32, - /// A rim is light on a dark page and shade on a light one, where light - /// would not show. - rim: [3]u8, - - /// Over the text on the page, and over a selection's text on its own - /// ground: the lower of the two. - fn of(chrome: *const pardes.Chrome) LiftCeilings { - const fg = chrome.fg orelse fg_default; - const bg = chrome.page orelse bg_default; - return .{ - .shadow = @min(shadowCeiling(fg, bg), shadowCeiling(chrome.sel_fg, chrome.sel_bg)), - .white = @min(lightenCeiling(fg, bg, .{ 255, 255, 255 }), lightenCeiling(chrome.sel_fg, chrome.sel_bg, .{ 255, 255, 255 })), - .rim = if (luminance(bg) < 0.18) .{ 255, 255, 255 } else .{ 0, 0, 0 }, - }; - } -}; - -/// What stands a lifted part off the page, `lift` 0 to 1 (a pane's spring, -/// a notice's 1), in the style chosen: a soft shadow, or a rim along the -/// top of the focused pane's tag rows (`rim_edge`, a pane's only: -/// never a notice's). -fn addLift(g: *Gui, gpa: std.mem.Allocator, style: pardes.config.Runtime.LiftStyle, ceilings: LiftCeilings, caster: [4]f32, rim_edge: ?[3]f32, bodies: []const [4]f32, lift: f32, track: ?pardes.animation.Track, win_w: f32, win_h: f32) !void { - if (lift <= 0.001) return; - const h: f32 = @floatFromInt(g.cell_h); - // The core sends `auto` already resolved (draw.liftStyle). - const shadow = switch (style) { - .off => return, - .shadow, .auto => true, - .rim => false, - }; - if (shadow) { - // Nothing of a shadow may touch a focus indicator (docs/effects.md): - // it falls on pane bodies and rails, never a tag, a grip or a header. - const first = g.decor.items.len; - try addSoft(g, gpa, caster, Shadow.sigma * h * lift, Shadow.side * h * lift, Shadow.drop * h * lift, @min(Shadow.strength * lift, ceilings.shadow), .{ 0, 0, 0 }, track, win_w, win_h); - try clipToBodies(g, gpa, first, bodies); - } - // A hairline just above the focused tag rows, never on them: it adds to - // the indicator without changing its colour. - if (style == .rim) if (rim_edge) |edge| { - const light = ceilings.rim[0] == 255; - const alpha = @min(Lift.rim * lift, if (light) ceilings.white else ceilings.shadow); - try addDecor(g, gpa, edge[0], edge[2] - dp(1), edge[1], edge[2], ceilings.rim, alpha, track, win_w, win_h); - }; -} - -/// A rim's strength, in the §8.2 budget for coloured light. -const Lift = struct { - const rim: f32 = 0.35; -}; - /// A body region in window pixels. fn bodyPixels(region: pardes.Region, layout: CellLayout) [4]f32 { return .{ @@ -8395,166 +8288,6 @@ fn bodyPixels(region: pardes.Region, layout: CellLayout) [4]f32 { }; } -/// Replaces the decor from `first` on with a copy per pane body it reaches, -/// each clipped to that body (and to what a vertical transition already -/// clipped it to): the lift then never reaches a tag, a grip or a header. -fn clipToBodies(g: *Gui, gpa: std.mem.Allocator, first: usize, bodies: []const [4]f32) !void { - const added = g.decor.items.len - first; - if (added == 0) return; - var own: [8]CellInstance = undefined; - const n = @min(added, own.len); - @memcpy(own[0..n], g.decor.items[first..][0..n]); - g.decor.shrinkRetainingCapacity(first); - for (own[0..n]) |instance| for (bodies) |body| { - var copy = instance; - const vertical = copy.clip_x1 >= copy.clip_x0; - copy.clip_x0 = if (vertical) @max(copy.clip_x0, body[0]) else body[0]; - copy.clip_y0 = if (vertical) @max(copy.clip_y0, body[1]) else body[1]; - copy.clip_x1 = if (vertical) @min(copy.clip_x1, body[2]) else body[2]; - copy.clip_y1 = if (vertical) @min(copy.clip_y1, body[3]) else body[3]; - if (copy.clip_x1 <= copy.clip_x0 or copy.clip_y1 <= copy.clip_y0) continue; - try g.decor.append(gpa, copy); - }; -} - -/// Like shadowCeiling for a light colour laid over at `a` (sRGB blend, as -/// the decor pipeline blends a colour that is not black): the largest `a` -/// that keeps text and page apart by min(their contrast, 4.5). -fn lightenCeiling(fg: [3]u8, bg: [3]u8, rgb: [3]u8) f32 { - const contrast = pardes.colors.contrast; - const blend = struct { - fn of(under: [3]u8, over: [3]u8, a: f32) [3]u8 { - var out: [3]u8 = undefined; - for (&out, under, over) |*o, x, y| o.* = @intFromFloat(@round(@as(f32, @floatFromInt(x)) * (1 - a) + @as(f32, @floatFromInt(y)) * a)); - return out; - } - }.of; - const target = @min(contrast(fg, bg), 4.5); - var lo: f32 = 0; - var hi: f32 = 1; - for (0..24) |_| { - const mid = (lo + hi) / 2; - if (contrast(blend(fg, rgb, mid), blend(bg, rgb, mid)) >= target - 1e-3) lo = mid else hi = mid; - } - return lo; -} - -const luminance = pardes.colors.relativeLuminance; - -/// How dark a shadow may make the page and its text, both together, before -/// the pair drops below its own contrast or 4.5, whichever is lower (§8.2): -/// darkening in linear light by k leaves (k L1 + .05) / (k L2 + .05). -pub fn shadowCeiling(fg: [3]u8, bg: [3]u8) f32 { - const a = luminance(fg); - const b = luminance(bg); - const light = @max(a, b); - const dark = @min(a, b); - const target = @min((light + 0.05) / (dark + 0.05), 4.5); - const room = light - target * dark; - if (room <= 0) return 0; - return std.math.clamp(1 - 0.05 * (target - 1) / room, 0, 1); -} - -test "a rim never lightens a native theme's text below its contrast or 4.5" { - for (pardes.themes) |theme| { - const fg = theme.fg orelse fg_default; - const bg = theme.bg orelse bg_default; - for ([_][3]u8{.{ 255, 255, 255 }}) |light| { - const a = @min(Lift.rim, lightenCeiling(fg, bg, light)); - const blend = struct { - fn of(under: [3]u8, over: [3]u8, t: f32) [3]u8 { - var out: [3]u8 = undefined; - for (&out, under, over) |*o, x, y| o.* = @intFromFloat(@round(@as(f32, @floatFromInt(x)) * (1 - t) + @as(f32, @floatFromInt(y)) * t)); - return out; - } - }.of; - const ratio = pardes.colors.contrast; - try std.testing.expect(ratio(blend(fg, light, a), blend(bg, light, a)) >= @min(ratio(fg, bg), 4.5) - 2e-3); - } - } -} - -test "a lift never touches a tag, a grip or a header, on a light theme or a dark one" { - const gpa = std.testing.allocator; - for ([_][]const u8{ "forge", "daybreak" }) |name| { - const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 24 }); - defer core.deinit(); - core.update(.{ .resize = .{ .cols = 80, .rows = 24, .row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 6, .tagline_h = 12 } } }); - _ = try core.newShell(1, ""); - try std.testing.expect(pardes.layout.splitColumn(core, 0, 1, false)); - var line: [64]u8 = undefined; - try std.testing.expect(core.executeBuiltinLine(0, try std.fmt.bufPrint(&line, "Theme {s}", .{name}))); - for (0..40) |_| core.update(.tick); - for (std.enums.values(pardes.config.Runtime.LiftStyle)) |style| { - core.settings.lift = style; - try std.testing.expect(core.executeBuiltinLine(0, "Msg a floating notice")); - core.advance(core.now_ns + 2 * std.time.ns_per_s); - core.sync(); - const s = try core.render(core.scratch.allocator()); - core.advance(core.now_ns + 2 * std.time.ns_per_s); - const settled = try core.render(core.scratch.allocator()); - _ = s; - // The focus indicator itself: the focused pane's tag is not the - // others' colour, whatever the lift. - var active: ?[3]u8 = null; - var other: ?[3]u8 = null; - for (settled.tagLayers()) |layer| if (layer.rows != 0 and layer.kind == .pane) { - if (layer.id == core.active) active = layer.bg else other = layer.bg; - }; - try std.testing.expect(!std.mem.eql(u8, &active.?, &other.?)); - var g = testGui(10, 20, 6, 12); - defer g.decor.deinit(gpa); - var groups = makeGroups(&.{}, false); - try buildDecor(&g, gpa, settled, &groups, fixedCellLayout(&g), 800, 480, true); - var lifted: usize = 0; - for (g.decor.items) |item| { - if (item.clip_x1 < item.clip_x0) continue; - lifted += 1; - // Inside a body or a rail, all of it. - const inside = for (settled.regionList()) |region| { - if (region.kind != .body and region.kind != .rail) continue; - const r = bodyPixels(region, fixedCellLayout(&g)); - if (item.clip_x0 >= r[0] and item.clip_y0 >= r[1] and item.clip_x1 <= r[2] and item.clip_y1 <= r[3]) break true; - } else false; - try std.testing.expect(inside); - } - const light_page = std.mem.eql(u8, name, "daybreak"); - try std.testing.expectEqual(style == .shadow or (style == .auto and light_page), lifted != 0); - // A rim is one hairline, just above the focused pane's tag row. - var rims: usize = 0; - for (g.decor.items) |item| { - if (item.clip_x1 >= item.clip_x0) continue; - const top = (1 - item.y0) / 2 * 480; - const height = (item.y0 - item.y1) / 2 * 480; - const on_active_tag = for (settled.regionList()) |region| { - if (region.kind == .tag and region.owner == core.active and @abs(top + 1 - @as(f32, @floatFromInt(region.rect.y)) * 20) < 0.01 and @abs(height - 1) < 0.01) break true; - } else false; - // Not the rule under a column bar, which may run there too. - rims += @intFromBool(on_active_tag and item.fr < 1); - } - try std.testing.expectEqual(@as(usize, @intFromBool(style == .rim)), rims); - } - } -} - -test "a shadow never darkens a native theme's text below its contrast or 4.5" { - var shaded: usize = 0; - for (pardes.themes) |theme| { - const fg = theme.fg orelse fg_default; - const bg = theme.bg orelse bg_default; - const ceiling = shadowCeiling(fg, bg); - const k = 1 - @min(Shadow.strength, ceiling); - const light = @max(luminance(fg), luminance(bg)); - const dark = @min(luminance(fg), luminance(bg)); - const before = (light + 0.05) / (dark + 0.05); - const after = (k * light + 0.05) / (k * dark + 0.05); - try std.testing.expect(after >= @min(before, 4.5) - 1e-3); - shaded += @intFromBool(ceiling > 0.05); - } - // And most themes have room for one. - try std.testing.expect(shaded * 2 > pardes.themes.len); -} - /// The frame's decor, group by group (docs/render-pipeline.md §3.4), all of it /// read from the regions and the palette: the page's rules and the still /// panes' rails, rules and grip marks in tier 0, a moving or closing pane's @@ -8563,18 +8296,6 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g g.decor.clearRetainingCapacity(); const chrome = &surface.chrome; const regions = surface.regionList(); - const ceilings = LiftCeilings.of(chrome); - var current_buf: [pardes.MAX_PANES][4]f32 = undefined; - var ncurrent: usize = 0; - for (regions) |part| if ((part.kind == .body or part.kind == .rail) and ncurrent < current_buf.len) { - current_buf[ncurrent] = bodyPixels(part, layout); - ncurrent += 1; - }; - const current_bodies = current_buf[0..ncurrent]; - const lift_style = std.enums.fromInt(pardes.config.Runtime.LiftStyle, chrome.lift_style) orelse .off; - const notice_lift = for (regions) |region| { - if (region.kind == .notice) break region.lift; - } else 0; for (groups.items[0..groups.len], 0..) |*group, index| { group.decor_start = @intCast(g.decor.items.len); defer group.decor_count = @as(u32, @intCast(g.decor.items.len)) - group.decor_start; @@ -8626,14 +8347,6 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g // A closing pane is gone: its chrome is the last frame's. const closing = if (track) |active| active.phase == .closing else false; const placed = if (closing) surface.previous_regions else regions; - // Where a lift may fall: pane bodies, never tags (addLift). - var body_buf: [pardes.MAX_PANES][4]f32 = undefined; - var nbodies: usize = 0; - for (placed) |part| if ((part.kind == .body or part.kind == .rail) and nbodies < body_buf.len) { - body_buf[nbodies] = bodyPixels(part, layout); - nbodies += 1; - }; - const bodies = body_buf[0..nbodies]; const ticks: []const pardes.RailTick = if (closing) &.{} else surface.rail_ticks[0..surface.nrail_ticks]; try paneDecor(g, gpa, placed, ticks, groups, index, chrome, layout, surface.cols, surface.rows, win_w, win_h, track); // A single spine runs down each column, through every tag and body. @@ -8647,66 +8360,11 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g if (column.rect.x == 0) continue; if (y1 > y0) try addDecor(g, gpa, x, y0, x + rulePx(chrome), y1, chrome.border, 1, null, win_w, win_h); }; - // Cast last in the group, over its cells, images and chrome: a - // lifted pane's shadow darkens its neighbours' rails and rules - // as it darkens their text, and never the pane itself. - for (placed) |grip| { - if (grip.kind != .grip or grip.lift <= 0.001 or groupOf(groups, grip.serial) != index) continue; - var box: [4]f32 = .{ @as(f32, @floatFromInt(grip.rect.x)) * layout.w, @as(f32, @floatFromInt(grip.rect.y)) * layout.h, 0, @as(f32, @floatFromInt(grip.rect.y + grip.rect.h)) * layout.h }; - box[2] = box[0]; - for (placed) |part| { - if (part.owner != grip.owner or (part.kind != .tag and part.kind != .rail and part.kind != .body)) continue; - box[1] = @min(box[1], @as(f32, @floatFromInt(part.rect.y)) * layout.h); - box[2] = @max(box[2], @as(f32, @floatFromInt(part.rect.x + part.rect.w)) * layout.w); - box[3] = @max(box[3], @as(f32, @floatFromInt(part.rect.y + part.rect.h)) * layout.h); - } - // The top edge of its tag rows, for a rim: x0, x1, y. - const rim_edge: ?[3]f32 = for (placed) |part| { - if (part.owner == grip.owner and part.kind == .tag) break .{ @as(f32, @floatFromInt(grip.rect.x)) * layout.w, @as(f32, @floatFromInt(part.rect.x + part.rect.w)) * layout.w, @as(f32, @floatFromInt(part.rect.y)) * layout.h }; - } else null; - try addLift(g, gpa, lift_style, ceilings, box, rim_edge, bodies, grip.lift, track, win_w, win_h); - } - // G7: a pane on the move stands off the page, rising as it sets - // out and settling as it lands, its shadow on the other panes' - // bodies only (never a tag, a grip or its own text), moving - // with it. - if (track) |active| if (active.phase != .closing and (active.effect == .slide or active.effect == .zoom or active.effect == .vertical)) { - const steps: f32 = @floatFromInt(@max(1, active.frames() -| 1)); - const u = std.math.clamp(@as(f32, @floatFromInt(active.frame)) / steps, 0, 1); - const lift = @sin(std.math.pi * u); - var box: [4]f32 = .{ std.math.inf(f32), std.math.inf(f32), -std.math.inf(f32), -std.math.inf(f32) }; - var others: [pardes.MAX_PANES][4]f32 = undefined; - var nothers: usize = 0; - for (placed) |part| { - if (part.kind != .tag and part.kind != .rail and part.kind != .body and part.kind != .grip) continue; - const r = bodyPixels(part, layout); - if (part.owner == active.pane) { - box = .{ @min(box[0], r[0]), @min(box[1], r[1]), @max(box[2], r[2]), @max(box[3], r[3]) }; - } else if ((part.kind == .body or part.kind == .rail) and nothers < others.len) { - others[nothers] = r; - nothers += 1; - } - } - if (box[2] > box[0] and lift > 0.01) { - const h: f32 = @floatFromInt(g.cell_h); - const first = g.decor.items.len; - try addSoft(g, gpa, box, Shadow.sigma * h * lift, Shadow.side * h * lift, Shadow.drop * h * lift, @min(Shadow.strength * lift, ceilings.shadow), .{ 0, 0, 0 }, track, win_w, win_h); - try clipToBodies(g, gpa, first, others[0..nothers]); - } - }; } // A notice chip is tagline hung over the body's top rows, so it is // ruled off from the text beneath it the way a tag is: the same // colour and thickness along its bottom, running to the window's // edge when it does, fading up and dissolving with its band. - // A notice floats: its shadow first, then every rule. - for (surface.tagLayers()) |*layer| { - if (layer.rows == 0 or layer.kind != .notice or noticeGroup(groups, layer) != index) continue; - const x = @as(f32, @floatFromInt(layer.viewport.x)) * layout.w; - const top = (@as(f32, @floatFromInt(layer.viewport.y)) + layer.slide) * layout.h; - const track = groups.items[groupAt(groups, layer.viewport.x, layer.viewport.y)].track; - try addLift(g, gpa, lift_style, ceilings, .{ x, top, x + @as(f32, @floatFromInt(layer.viewport.w)) * layout.w, top + layout.h }, null, current_bodies, notice_lift * layer.fade, track, win_w, win_h); - } for (surface.tagLayers()) |*layer| { if (layer.rows == 0 or layer.kind != .notice or noticeGroup(groups, layer) != index) continue; const x0 = @as(f32, @floatFromInt(layer.viewport.x)) * layout.w; @@ -9415,45 +9073,6 @@ test "decor is read from the regions, each pane's in its own group" { try std.testing.expectEqual(@as(u32, 0), groups.items[groups.ink].decor_count); } -test "a pane on the move casts a shadow on the other panes' bodies alone, most at mid-way" { - const gpa = std.testing.allocator; - const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 24 }); - defer core.deinit(); - _ = try core.newShell(1, ""); - try std.testing.expect(pardes.layout.splitColumn(core, 0, 1, false)); - try std.testing.expect(core.executeBuiltinLine(0, "Theme acme")); - for (0..40) |_| core.update(.tick); - core.sync(); - const s = try core.render(core.scratch.allocator()); - var g = testGui(10, 20, 6, 12); - defer g.decor.deinit(gpa); - const layout = fixedCellLayout(&g); - const serial = core.panes[1].?.serial; - var strengths: [3]f32 = @splat(0); - for ([_]u16{ 0, 6, 12 }, 0..) |frame, i| { - g.decor.clearRetainingCapacity(); - const moving: pardes.animation.Track = .{ .pane = 1, .serial = serial, .phase = .moving, .effect = .slide, .frame = frame, .frame_count = 13, .from = .{ .x = 0, .y = 1, .w = 40, .h = 23 }, .to = .{ .x = 40, .y = 1, .w = 40, .h = 23 } }; - var groups = makeGroups(&.{moving}, true); - if (!moving.active()) groups = makeGroups(&.{}, true); - try buildDecor(&g, gpa, s, &groups, layout, 800, 480, false); - for (g.decor.items) |item| { - if (item.effect & soft_shadow_bit == 0) continue; - strengths[i] = @max(strengths[i], item.fr); - // Clipped to pane 0's body or rail, never pane 1's, never a tag. - try std.testing.expect(item.clip_x1 >= item.clip_x0); - for (s.regionList()) |region| { - if (region.kind != .tag and region.kind != .grip and !(region.owner == 1 and (region.kind == .body or region.kind == .rail))) continue; - const r = bodyPixels(region, layout); - try std.testing.expect(item.clip_x1 <= r[0] or item.clip_x0 >= r[2] or item.clip_y1 <= r[1] or item.clip_y0 >= r[3]); - } - } - } - // Rising as it sets out, gone as it lands. - try std.testing.expectEqual(@as(f32, 0), strengths[0]); - try std.testing.expect(strengths[1] > 0.05); - try std.testing.expectEqual(@as(f32, 0), strengths[2]); -} - test "a body tells its first line, and lapis's dots under it move a quarter as far" { const gpa = std.testing.allocator; const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 24 }); diff --git a/src/pardes.zig b/src/pardes.zig index 415424b3..79e288a3 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -3805,10 +3805,6 @@ pub const Pardes = struct { theme_file_generation: u32 = 0, theme_file_pane: u8 = 0, chrome_animation: colors.ChromeAnimation = colors.ChromeAnimation.init(colors.initial_chrome), - /// Each pane's lift off the page (Lift): 1 while it has the focus, on a - /// spring. `lift_serials` says whose it is, so a reused slot starts flat. - lifts: [MAX_PANES]animation.Spring = @splat(.{}), - lift_serials: [MAX_PANES]u32 = @splat(0), /// The focused cursor's quad on its springs (animation.CursorGlide), /// the pane and view origin it was last aimed in, and the last key or /// click, which a blink holds for. @@ -4043,7 +4039,7 @@ pub const Pardes = struct { pub const replica = .{ .local = .{ // A frame, and the animations and timings that make it. - "surface", "presentation", "frames", "chrome_animation", "lifts", "lift_serials", + "surface", "presentation", "frames", "chrome_animation", "cursor_glide", "cursor_view", "cursor_crossing", "cursor_held", "frame_arena", "scratch", "needs_frame", "present_skipped", "shell_continuous", "native_image_patches", "echo", @@ -7349,7 +7345,6 @@ pub const Pardes = struct { /// and its present (vsync) paces it, at the display's rate. `nextWake` /// is for the stepped animations, which count frames of `frame_ns`. pub fn continuous(p: *const Pardes) bool { - for (p.lifts) |spring| if (!spring.settled) return true; return p.cursor_glide.moving() or p.shell_continuous or panes.Pdf.moving(p); } diff --git a/src/surface.zig b/src/surface.zig index 3b05d5f9..367839d0 100644 --- a/src/surface.zig +++ b/src/surface.zig @@ -377,10 +377,6 @@ pub const Region = struct { thumb_span: f32 = 0, /// A notice's index in its pane's `notices`. notice: u8 = 0, - /// How far it stands off the page, 0 to 1: a pane's while it has the - /// focus (Lift, on a spring), a notice's while Lift is on. A pixel shell - /// casts a soft shadow from it; the tier it is drawn in never changes. - lift: f32 = 0, /// A body's view: the first line it shows (a file's scroll, a /// terminal's grid offset), for what a pixel shell moves with the text /// (G13's parallax). @@ -420,11 +416,6 @@ pub const Chrome = struct { /// A pane's places' ticks on its rail, and its current one's. match_tick: [3]u8 = .{ 0, 0, 0 }, match_current: [3]u8 = .{ 0, 0, 0 }, - /// A selection's text and ground: a lift keeps their contrast too. - sel_fg: [3]u8 = .{ 0, 0, 0 }, - sel_bg: [3]u8 = .{ 0, 0, 0 }, - /// How a lifted part stands off the page (config.Runtime.LiftStyle). - lift_style: u8 = 0, /// Rule width in pixels (colors.Theme.rule_px). rule_px: u8 = 2, /// The ring round a grip, acme's button: unfocused, and focused. diff --git a/src/views.zig b/src/views.zig index d7e6703b..05eaef89 100644 --- a/src/views.zig +++ b/src/views.zig @@ -37,7 +37,7 @@ pub const fields = [_][:0]const u8{ "col_tags", "col_serial", "finder", "rects", "col_x", "col_w", "presentation", "active", "jumps", "njumps", "jcur", "jump_force", - "active_column", "lifts", "lift_serials", "cursor_glide", + "active_column", "cursor_glide", "cursor_view", "cursor_crossing", "cursor_held", "shell_continuous", "input_ns", "native_images", "native_image_patches", "windowed", "drag", "mouse_grab", "window_focused", "focus_told", @@ -539,7 +539,7 @@ pub fn deinit(p: *Pardes) void { /// What drawing a view keeps of its own (its animations, its panels as /// presented), kept from a frame drawn while it was out. -const drawn_fields = [_][:0]const u8{ "presentation", "lifts", "lift_serials", "cursor_glide", "cursor_view", "cursor_crossing", "cursor_held", "shell_continuous" }; +const drawn_fields = [_][:0]const u8{ "presentation", "cursor_glide", "cursor_view", "cursor_crossing", "cursor_held", "shell_continuous" }; /// Each view but the live one drawn and presented, the live one put back /// after exactly as it was: no digested field moves, so a replica that diff --git a/test/behaviour/root_ctl.zig b/test/behaviour/root_ctl.zig index 7bf15ee2..b9909eef 100644 --- a/test/behaviour/root_ctl.zig +++ b/test/behaviour/root_ctl.zig @@ -63,7 +63,7 @@ test "root-ctl: the root ctl reads the settings as a write takes them, and takes .{ "Nonsense 1", "unknown control message \"Nonsense\"" }, .{ "Verbose maybe", "bad value in control message; takes on, off \"maybe\"" }, // A number's refusal names its range. - .{ "InactiveDim 200", "bad value in control message; takes 0-100 (a percentage) \"200\"" }, + .{ "SearchRows 200", "bad value in control message; takes 1-100 (rows) \"200\"" }, .{ "MessageLinger x", "bad value in control message; takes 0-60000 (milliseconds) \"x\"" }, .{ "Newcol 2", "wrong #args in control message \"Newcol\"" }, .{ "Theme", "wrong #args in control message \"Theme\"" }, diff --git a/test/behaviour/settings.zig b/test/behaviour/settings.zig index 76b60da4..5ad4b7eb 100644 --- a/test/behaviour/settings.zig +++ b/test/behaviour/settings.zig @@ -93,8 +93,6 @@ test "settings: a setting this frontend cannot show says GUI-only, never run as var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); if (comptime @import("pardes_config").platform != .gui) { - _ = try s.refused("/ctl", "Lift on\n"); - try std.testing.expectEqualStrings("Lift is GUI-only, invalid here \"Lift\"", s.said); _ = try s.refused("/ctl", "GripWidth 120\n"); try std.testing.expectEqualStrings("GripWidth is GUI-only, invalid here \"GripWidth\"", s.said); // A builtin the GUI alone has, written to a ctl or an exec, never diff --git a/test/gui-goldens.txt b/test/gui-goldens.txt index 271b2a0f..6b3960d8 100644 --- a/test/gui-goldens.txt +++ b/test/gui-goldens.txt @@ -14,4 +14,4 @@ 15-theme-acme-light 6e2ba713570d3d2baeaf927218d21f497a43b1d1fc59e7a3eff68f213e5cf7f7 16-debug 776b774f85219e9ced28168e0b90ef4473a8687d1cf14747d21b129dd5aaea98 17-terminal 5f192b2fff53c66d154f4ad310d07c168838172d85cc59ba0fd51720d6abba2e -18-mid-transition 9cfac7223c513df1e15177a69808a0a922e9e6b7fe29c9934754a7e561144d0c +18-mid-transition 14746e3f30abc862e3a25a5f6907d135898cb0f963436f4fe7cd6085eee9a874 diff --git a/test/monkey9p.zig b/test/monkey9p.zig index d87fed07..692550a5 100644 --- a/test/monkey9p.zig +++ b/test/monkey9p.zig @@ -74,7 +74,7 @@ const builtins = [_][]const u8{ "Palette", "Ascii", "Save", "New", "Newcol", "Del", "Filter", "Mode", "Togglettymode", "Edit", "Undo", "Redo", "Collapse", "Delcol", "DelAbove", "DelBelow", "Term", "Repl", "Joincol", "Config", "LocationsConfig", "Messages", "Mini", "Find", "Grep", "Left", "Down", "Up", "Right", "Back", "Forward", "Last", "Recent", "Jumplist", "Colors", "Wrap", "Tagbottom", "Debug", "FocusTint", - "Verbose", "Motion", "InactiveDim", "DumpDir", "Theme", "Get", "Put", "Undo", "Redo", "Zerox", "Snarf", "Paste", "Cut", + "Verbose", "Motion", "SyntaxBold", "DumpDir", "Theme", "Get", "Put", "Undo", "Redo", "Zerox", "Snarf", "Paste", "Cut", "Sort", "Font", "Local", }; const pane_files = [_][]const u8{ "name", "body", "tag", "ctl", "addr", "dot", "limit", "data", "xdata", "sel", "dirty", "mark", "scroll", "errors", "event", "look", "exec", "tagexec", "pty", "pty/run", "pty/data", "pty/ctl", "pty/status" }; diff --git a/test/process/window.zig b/test/process/window.zig index ca91d110..49c2d4f0 100644 --- a/test/process/window.zig +++ b/test/process/window.zig @@ -29,14 +29,12 @@ fn paneWith(f: *process.Files, word: []const u8) !u32 { } const motions = [_][]const u8{ "off", "crisp", "smooth", "bouncy", "playful" }; -const lifts = [_][]const u8{ "off", "shadow", "rim", "auto" }; const themes = [_][]const u8{ "lapis", "lapis_plain", "forge", "acme", "dusk", "daybreak" }; -/// test/gui_monkey.py's: each Motion x Lift gets a random burst, then -/// must settle with its process alive and no crash record. Two -/// combinations and 30 steps in process-test; PARDES_GUI_MONKEY=all runs -/// all 20 (`zig build monkey-gui`), PARDES_GUI_MONKEY_SEED and _STEPS -/// choose the rest. +/// test/gui_monkey.py's: each Motion gets a random burst, then must +/// settle with its process alive and no crash record. Two of them and 30 +/// steps in process-test; PARDES_GUI_MONKEY=all runs all 5 (`zig build +/// monkey-gui`), PARDES_GUI_MONKEY_SEED and _STEPS choose the rest. fn monkey(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try process.only(.gui); const all = std.mem.eql(u8, envOr("PARDES_GUI_MONKEY", ""), "all"); @@ -44,20 +42,20 @@ fn monkey(gpa: std.mem.Allocator, exe: [:0]const u8) !void { const steps = try std.fmt.parseInt(usize, envOr("PARDES_GUI_MONKEY_STEPS", if (all) "60" else "30"), 10); var failed: usize = 0; var n: usize = 0; - for (motions) |m| for (lifts) |l| { + for (motions) |m| { defer n += 1; - // The smoke run: the quietest combination and the busiest. - if (!all and n != 0 and n != motions.len * lifts.len - 1) continue; - if (!try monkeyOne(gpa, exe, m, l, seed * 1000 + n, steps)) failed += 1; - }; + // The smoke run: the quietest and the busiest. + if (!all and n != 0 and n != motions.len - 1) continue; + if (!try monkeyOne(gpa, exe, m, seed * 1000 + n, steps)) failed += 1; + } if (failed > 0) return error.MonkeyFailed; } -fn monkeyOne(gpa: std.mem.Allocator, exe: [:0]const u8, motion: []const u8, lift: []const u8, seed: u64, steps: usize) !bool { +fn monkeyOne(gpa: std.mem.Allocator, exe: [:0]const u8, motion: []const u8, seed: u64, steps: usize) !bool { var arena = std.heap.ArenaAllocator.init(gpa); defer arena.deinit(); const a = arena.allocator(); - const init = try std.fmt.allocPrint(a, "Shell /bin/sh\nMessageLinger 0\nMotion {s}\nLift {s}\nPanelSlide\n", .{ motion, lift }); + const init = try std.fmt.allocPrint(a, "Shell /bin/sh\nMessageLinger 0\nMotion {s}\nPanelSlide\n", .{motion}); var d = try process.Detached.start(gpa, exe, "monkey", .{ .init = init, .grid = .{ 80, 28 }, .env = &.{ .{ "PARDES_TEST_CLOCK", "1" }, .{ "PARDES_TEST_PAD", "0" }, } }); @@ -101,7 +99,7 @@ fn monkeyOne(gpa: std.mem.Allocator, exe: [:0]const u8, motion: []const u8, lift }; } else |_| {} const ok = std.mem.eql(u8, verdict, "ok"); - if (!ok) std.debug.print("monkey {s}-{s} (seed {d}): {s}\n{s}", .{ motion, lift, seed, verdict, log.items }); + if (!ok) std.debug.print("monkey {s} (seed {d}): {s}\n{s}", .{ motion, seed, verdict, log.items }); return ok; } |
