From 65b838b9b441a7ce1810f979216ff9246d63df72 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 5 Nov 2026 11:17:05 -0300 Subject: effects out, the terminal's own: JumpTrail, ChipShadow and ThumbFlash go with their passes in src/tui/panel_compositor.zig, their three tests, their words and settings, and the tty's COLORTERM check, which only they read Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- docs/typ/builtins-gui.json | 3 - docs/typ/builtins-tui.json | 3 - docs/typ/reference.typ | 6 +- src/config.zig | 19 +-- src/tui/panel_compositor.zig | 315 ------------------------------------------- src/tui/tui.zig | 15 --- test/record_casts.py | 2 +- 7 files changed, 4 insertions(+), 359 deletions(-) diff --git a/docs/typ/builtins-gui.json b/docs/typ/builtins-gui.json index de898384..006b6c12 100644 --- a/docs/typ/builtins-gui.json +++ b/docs/typ/builtins-gui.json @@ -7,7 +7,6 @@ {"name": "Callstack", "leader": "SPC l b", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Show outermost callers first, with signatures and call sites (gc)."}, {"name": "CallstackDepth", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "Caller levels collected by Callstack, 1 through 64; default 8. Bare, it says the current limit."}, {"name": "Changelog", "leader": "SPC h c", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "This build's version and what changed to reach it, printed into an output buffer the same way Config prints the live settings."}, - {"name": "ChipShadow", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "In a terminal, a notice chip casts a cell's shadow right and down, on or off."}, {"name": "ClipPaste", "leader": "SPC p", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Paste the system clipboard after the selection."}, {"name": "ClipPasteBefore", "leader": "SPC P", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Paste the system clipboard before the selection."}, {"name": "ClipReplace", "leader": "SPC R", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Replace the selection with the system clipboard."}, @@ -52,7 +51,6 @@ {"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."}, {"name": "JumpScope", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "file, all", "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."}, - {"name": "JumpTrail", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "In a terminal, a jump of the cursor leaves a short trail that fades, on or off."}, {"name": "Jumplist", "leader": "SPC j l", "also": [], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "List the places jumped from, each a place to go."}, {"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."}, @@ -129,7 +127,6 @@ {"name": "Theme", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "Switch to the named theme."}, {"name": "ThemeFile", "leader": null, "also": [], "arg": true, "scope": "root", "setting": false, "choices": null, "doc": "Load a theme from a file."}, {"name": "Themes", "leader": "SPC t t", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "List the themes in a pane, each a word to click."}, - {"name": "ThumbFlash", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "In a terminal, a pane's scroll thumb brightens as it scrolls and fades back, on or off."}, {"name": "Togglettymode", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Switch this terminal between raw program input and normal editor mode."}, {"name": "TreeContext", "leader": null, "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Show the declarations enclosing the top row at the pane's head, on or off."}, {"name": "TreeContextTagStyle", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "A pane's TreeContext rows draw in the tag's style, on or off."}, diff --git a/docs/typ/builtins-tui.json b/docs/typ/builtins-tui.json index 8fdbec16..3de0e0cc 100644 --- a/docs/typ/builtins-tui.json +++ b/docs/typ/builtins-tui.json @@ -7,7 +7,6 @@ {"name": "Callstack", "leader": "SPC l b", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Show outermost callers first, with signatures and call sites (gc)."}, {"name": "CallstackDepth", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "Caller levels collected by Callstack, 1 through 64; default 8. Bare, it says the current limit."}, {"name": "Changelog", "leader": "SPC h c", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "This build's version and what changed to reach it, printed into an output buffer the same way Config prints the live settings."}, - {"name": "ChipShadow", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "In a terminal, a notice chip casts a cell's shadow right and down, on or off."}, {"name": "ClipPaste", "leader": "SPC p", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Paste the system clipboard after the selection."}, {"name": "ClipPasteBefore", "leader": "SPC P", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Paste the system clipboard before the selection."}, {"name": "ClipReplace", "leader": "SPC R", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Replace the selection with the system clipboard."}, @@ -47,7 +46,6 @@ {"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."}, {"name": "JumpScope", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "file, all", "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."}, - {"name": "JumpTrail", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "In a terminal, a jump of the cursor leaves a short trail that fades, on or off."}, {"name": "Jumplist", "leader": "SPC j l", "also": [], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "List the places jumped from, each a place to go."}, {"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."}, @@ -118,7 +116,6 @@ {"name": "Theme", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "Switch to the named theme."}, {"name": "ThemeFile", "leader": null, "also": [], "arg": true, "scope": "root", "setting": false, "choices": null, "doc": "Load a theme from a file."}, {"name": "Themes", "leader": "SPC t t", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "List the themes in a pane, each a word to click."}, - {"name": "ThumbFlash", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "In a terminal, a pane's scroll thumb brightens as it scrolls and fades back, on or off."}, {"name": "Togglettymode", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Switch this terminal between raw program input and normal editor mode."}, {"name": "TreeContext", "leader": null, "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Show the declarations enclosing the top row at the pane's head, on or off."}, {"name": "TreeContextTagStyle", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "A pane's TreeContext rows draw in the tag's style, on or off."}, diff --git a/docs/typ/reference.typ b/docs/typ/reference.typ index f0e7295e..00d71e9c 100644 --- a/docs/typ/reference.typ +++ b/docs/typ/reference.typ @@ -469,10 +469,8 @@ start off, and the web shell has none. The focused pane can stand off the page: #word("Lift") `shadow|rim|auto|off`, #word("InactiveDim") ``, #word("Motion") `off|crisp|smooth|bouncy|playful` (default `smooth`), #word("SelectionGlow"), #word("HoverGlow"), #word("Occlusion"), -#word("Parallax"), #word("JumpTrail"), #word("ChipShadow"), -#word("ThumbFlash"), #word("CursorBlink"), #word("GripWidth") `<50-300>`. Most are -the GUI's; #word("InactiveDim") works everywhere, and #word("JumpTrail"), -#word("ChipShadow") and #word("ThumbFlash") are the terminal's. No effect +#word("Parallax"), #word("CursorBlink"), #word("GripWidth") `<50-300>`. Most are +the GUI's; #word("InactiveDim") works everywhere. 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/src/config.zig b/src/config.zig index c8ba76bd..3c8e25de 100644 --- a/src/config.zig +++ b/src/config.zig @@ -171,9 +171,6 @@ pub const leader_path = paths: { if (builtins.capabilities.lift) table.set(.HoverGlow, null); if (builtins.capabilities.lift) table.set(.Occlusion, null); if (builtins.capabilities.lift) table.set(.Parallax, null); - table.set(.JumpTrail, null); - table.set(.ChipShadow, null); - table.set(.ThumbFlash, null); table.set(.ProgramEsc, null); if (builtins.capabilities.lift) table.set(.Lift, null); table.set(.Motion, null); @@ -765,17 +762,6 @@ pub const Runtime = struct { /// G13: a theme's page pattern under the bodies (lapis's dots) moves /// with the text at a quarter of its speed, a pixel shell's. parallax: bool = false, - /// G14: text that changes glows for a moment in the theme's accent and - /// fades, a pixel shell's. - /// T2: in a terminal, a jump of the cursor leaves a short trail that - /// fades in 120 ms (a truecolor terminal's; a pixel shell glides). - jump_trail: bool = false, - /// T1: in a terminal, a notice chip casts a cell's shadow right and - /// down (truecolor terminals). - chip_shadow: bool = false, - /// T7: in a terminal, a pane's scroll thumb brightens as it scrolls and - /// fades back (truecolor terminals). - thumb_flash: 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, @@ -932,7 +918,7 @@ pub const Runtime = struct { /// The message timings a setting word sets, each in milliseconds. pub const MessageTime = enum { linger, fall, dissolve }; - pub const Toggle = enum { colors, wrap, tree_context_tag_style, tag_bottom, debug, focus_tint, syntax_bold, pager_color, verbose, message_animation, ligatures, cursor_blink, selection_glow, hover_glow, occlusion, parallax, jump_trail, chip_shadow, thumb_flash, program_esc }; + pub const Toggle = enum { colors, wrap, tree_context_tag_style, tag_bottom, debug, focus_tint, syntax_bold, pager_color, verbose, message_animation, ligatures, cursor_blink, selection_glow, hover_glow, occlusion, parallax, program_esc }; pub const Action = union(enum) { toggle: Toggle, @@ -1008,9 +994,6 @@ pub const Runtime = struct { .{ .word = "HoverGlow", .action = .{ .toggle = .hover_glow }, .doc = "A soft underline of light under the word a look-hover would open, on or off." }, .{ .word = "Occlusion", .action = .{ .toggle = .occlusion }, .doc = "Pane bodies darken faintly toward their edges, 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 = "JumpTrail", .action = .{ .toggle = .jump_trail }, .doc = "In a terminal, a jump of the cursor leaves a short trail that fades, on or off." }, - .{ .word = "ChipShadow", .action = .{ .toggle = .chip_shadow }, .doc = "In a terminal, a notice chip casts a cell's shadow right and down, on or off." }, - .{ .word = "ThumbFlash", .action = .{ .toggle = .thumb_flash }, .doc = "In a terminal, a pane's scroll thumb brightens as it scrolls and fades back, 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." }, diff --git a/src/tui/panel_compositor.zig b/src/tui/panel_compositor.zig index 0375ffef..142a6fae 100644 --- a/src/tui/panel_compositor.zig +++ b/src/tui/panel_compositor.zig @@ -153,193 +153,6 @@ pub fn glideRows(frame: *Frame, glide: *const Glide) !void { }; } -/// T1 (§9.2): each notice chip casts a shadow one cell right and one down, -/// inside its own pane's body: its ground 35% toward black in OKLab on a -/// cell with text; on a blank one a half block (▌ on the right, ▀ below, -/// ▘ at the corner) in the darker colour, so the shadow is half a cell -/// thick and reads as one. Never the cursor's cell, a selection, a tag or -/// another chip. Truecolor terminals only. -pub fn chipShadows(frame: *Frame, core: *pardes.Pardes, truecolor: bool) !void { - if (!core.settings.chip_shadow or !truecolor) return; - const regions = frame.shown().regionList(); - const any = for (regions) |region| { - if (region.kind == .notice) break true; - } else false; - if (!any) return; - const out = try frame.own(); - const theme = core.theme(); - const page = theme.bg orelse pardes.colors.null_page; - for (regions) |chip| { - if (chip.kind != .notice or chip.rect.w == 0) continue; - const body = for (regions) |region| { - if (region.kind == .body and region.owner == chip.owner) break region.rect; - } else continue; - const right = chip.rect.x + chip.rect.w; - const below = chip.rect.y + chip.rect.h; - // The column right of it (from its second row), the row below (from - // its second column), and the corner. - var y = chip.rect.y; - while (y <= below) : (y += 1) { - var x = chip.rect.x; - while (x <= right) : (x += 1) { - const side = x == right and y > chip.rect.y and y < below; - const foot = y == below and x > chip.rect.x and x < right; - const corner = x == right and y == below; - if (!side and !foot and !corner) continue; - if (x < body.x or y < body.y or x >= body.x + body.w or y >= body.y + body.h or x >= out.cols or y >= out.rows) continue; - if (out.cursor) |cu| if (cu.x == x and cu.y == y) continue; - const covered = for (regions) |region| { - if ((region.kind == .notice or region.kind == .tag or region.kind == .grip) and x >= region.rect.x and x < region.rect.x + region.rect.w and y >= region.rect.y and y < region.rect.y + region.rect.h) break true; - } else false; - if (covered) continue; - const cell = &out.cells[@as(usize, y) * out.cols + x]; - const ground: [3]u8 = if (cell.default) page else switch (cell.style.bg) { - .rgb => |rgb| rgb, - else => page, - }; - if (std.mem.eql(u8, &ground, &theme.sel_bg)) continue; - const dark = pardes.colors.mixOklab(ground, .{ 0, 0, 0 }, 0.35); - const blank = cell.default or cell.len == 0 or (cell.len == 1 and cell.text[0] == ' '); - if (blank) { - const glyph: []const u8 = if (corner) "▘" else if (side) "▌" else "▀"; - cell.* = .{ .default = false, .style = .{ .fg = .{ .rgb = dark }, .bg = .{ .rgb = ground } } }; - @memcpy(cell.text[0..glyph.len], glyph); - cell.len = @intCast(glyph.len); - } else { - cell.default = false; - cell.style.bg = .{ .rgb = dark }; - } - } - } - } -} - -/// T7 (§9.2): a pane whose view moved (Region.line) has its scroll thumb -/// brighten, drawn most of the way to the text's colour, and fade back -/// over 250 ms with an ease-out: where you are in the file, as you move. -/// The rail is chrome, not a focus indicator. Truecolor terminals only. -pub const ThumbFlash = struct { - lines: [pardes.MAX_PANES]i32 = @splat(std.math.minInt(i32)), - since: [pardes.MAX_PANES]u64 = @splat(0), - - const life_ns: u64 = 250 * std.time.ns_per_ms; - - pub fn apply(flash: *ThumbFlash, frame: *Frame, core: *pardes.Pardes, truecolor: bool) !void { - const on = core.settings.thumb_flash and truecolor and core.settings.motion != .off; - const theme = core.theme(); - const ink = theme.fg orelse .{ 0xcc, 0xcc, 0xcc }; - const regions = frame.shown().regionList(); - for (regions) |body| { - if (body.kind != .body or body.owner >= flash.lines.len) continue; - const id = body.owner; - if (flash.lines[id] != std.math.minInt(i32) and flash.lines[id] != body.line) flash.since[id] = core.now_ns; - flash.lines[id] = body.line; - const age = core.now_ns -| flash.since[id]; - if (!on or flash.since[id] == 0 or age >= life_ns) continue; - const rail = for (regions) |region| { - if (region.kind == .rail and region.owner == id) break region; - } else continue; - if (rail.thumb_h == 0) continue; - const t = @as(f32, @floatFromInt(age)) / @as(f32, @floatFromInt(life_ns)); - const strength = 0.6 * (1 - t) * (1 - t); - const o = try frame.own(); - var y = rail.rect.y + rail.thumb_y; - while (y < rail.rect.y + rail.thumb_y + rail.thumb_h and y < o.rows) : (y += 1) { - var x = rail.rect.x; - while (x < rail.rect.x + rail.rect.w and x < o.cols) : (x += 1) { - const cell = &o.cells[@as(usize, y) * o.cols + x]; - const ground: [3]u8 = switch (cell.style.bg) { - .rgb => |rgb| rgb, - else => continue, - }; - if (!std.mem.eql(u8, &ground, &core.chromeTheme().scroll_thumb)) continue; - cell.style.bg = .{ .rgb = pardes.colors.mixOklab(ground, ink, strength) }; - } - } - core.shell_continuous = true; - } - } -}; - -/// T2 (docs/render-pipeline.md §9.2): the cursor jumping three cells or -/// more leaves a trail of three to five cells along its path, just behind -/// it, their ground drawn toward the text's colour, most beside the -/// cursor, all fading out over 120 ms. Truecolor terminals only; a cell a -/// frame changes, a few bytes. Never the cursor's own cell, a selection or -/// anything outside the focused pane's body; off with Motion off. -pub const JumpTrail = struct { - last: ?[2]u16 = null, - from: [2]u16 = .{ 0, 0 }, - to: [2]u16 = .{ 0, 0 }, - start_ns: u64 = 0, - active: bool = false, - - const life_ns: u64 = 120 * std.time.ns_per_ms; - - pub fn apply(trail: *JumpTrail, frame: *Frame, core: *pardes.Pardes, truecolor: bool) !void { - defer core.shell_continuous = trail.active or core.shell_continuous; - const on = core.settings.jump_trail and truecolor and core.settings.motion != .off; - const cursor = frame.shown().cursor orelse { - trail.active = false; - return; - }; - const here: [2]u16 = .{ cursor.x, cursor.y }; - if (trail.last) |was| { - const dx = @as(i32, here[0]) - was[0]; - const dy = @as(i32, here[1]) - was[1]; - if (on and @max(@abs(dx), @abs(dy)) >= 3) { - trail.* = .{ .last = here, .from = was, .to = here, .start_ns = core.now_ns, .active = true }; - } - } - trail.last = here; - if (!on or !trail.active) { - trail.active = false; - return; - } - const age = core.now_ns -| trail.start_ns; - if (age >= life_ns or !std.meta.eql(trail.to, here)) { - trail.active = false; - return; - } - const out = try frame.own(); - const theme = core.theme(); - const ink = theme.fg orelse .{ 0xcc, 0xcc, 0xcc }; - const page = theme.bg orelse pardes.colors.null_page; - const body = for (out.regionList()) |region| { - if (region.kind == .body and region.owner == core.active) break region.rect; - } else return; - const t = @as(f32, @floatFromInt(age)) / @as(f32, @floatFromInt(life_ns)); - const fade = (1 - t) * (1 - t); - const dx = @as(f32, @floatFromInt(@as(i32, trail.from[0]) - trail.to[0])); - const dy = @as(f32, @floatFromInt(@as(i32, trail.from[1]) - trail.to[1])); - const span = @max(@abs(dx), @abs(dy)); - const n: usize = @intFromFloat(std.math.clamp(@round(span / 4), 3, 5)); - var k: usize = 1; - var last_cell: ?[2]i32 = null; - var step: f32 = 1; - while (k <= n and step <= span) : (step += 1) { - const x: i32 = @intFromFloat(@round(@as(f32, @floatFromInt(trail.to[0])) + dx * step / span)); - const y: i32 = @intFromFloat(@round(@as(f32, @floatFromInt(trail.to[1])) + dy * step / span)); - if (last_cell) |seen| if (seen[0] == x and seen[1] == y) continue; - last_cell = .{ x, y }; - defer k += 1; - if (x < body.x or y < body.y or x >= @as(i32, body.x) + body.w or y >= @as(i32, body.y) + body.h) continue; - const cell = &out.cells[@as(usize, @intCast(y)) * out.cols + @as(usize, @intCast(x))]; - const ground: [3]u8 = if (cell.default) page else switch (cell.style.bg) { - .rgb => |rgb| rgb, - else => page, - }; - if (std.mem.eql(u8, &ground, &theme.sel_bg)) continue; - const strength = 0.55 * fade * (1 - @as(f32, @floatFromInt(k - 1)) / @as(f32, @floatFromInt(n))); - if (strength < 0.02) continue; - const was_default = cell.default; - cell.default = false; - if (was_default) cell.style = .{}; - cell.style.bg = .{ .rgb = pardes.colors.mixOklab(ground, ink, strength) }; - } - } -}; - /// Content effects have no honest frame without the frozen old grid. In /// production the core drops such tracks before publishing Surface; retain /// this guard at the backend boundary so a partial/custom caller also snaps @@ -970,131 +783,3 @@ test "the tty draws a glide at whole rows: once a flick or a spin slows, its ste try std.testing.expectEqual(row, (frame.shown().cursor orelse return error.NoCursor).y); } } - -test "a jump leaves a trail of a few cells behind the cursor that fades in 120 ms" { - const gpa = std.testing.allocator; - const core = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); - defer core.deinit(); - _ = try core.setTestFile(std.mem.asBytes(&@as([20][20]u8, @splat("some text on a line\n".*)))); - try std.testing.expect(core.executeBuiltinLine(0, "Theme forge")); - core.settings.jump_trail = true; - for (0..40) |_| core.update(.tick); - core.sync(); - var arena: std.heap.ArenaAllocator = .init(gpa); - defer arena.deinit(); - const s = try core.render(arena.allocator()); - const body = for (s.regionList()) |region| { - if (region.kind == .body) break region.rect; - } else return error.NoBody; - var trail: JumpTrail = .{}; - core.now_ns = std.time.ns_per_s; - s.cursor = .{ .x = body.x + 2, .y = body.y + 1 }; - var frame: Frame = .{ .arena = arena.allocator(), .canonical = s }; - try trail.apply(&frame, core, true); - // Ten cells right: a trail back toward where it was. - s.cursor = .{ .x = body.x + 12, .y = body.y + 1 }; - core.now_ns += 16 * std.time.ns_per_ms; - frame = .{ .arena = arena.allocator(), .canonical = s }; - try trail.apply(&frame, core, true); - const lit = frame.shown(); - try std.testing.expect(trail.active and core.shell_continuous); - var changed: usize = 0; - for (lit.cells, s.cells, 0..) |a, b, i| { - if (std.meta.eql(a.style.bg, b.style.bg)) continue; - changed += 1; - // On the cursor's row, behind it, never its own cell. - try std.testing.expectEqual(@as(usize, body.y + 1), i / s.cols); - try std.testing.expect(i % s.cols < body.x + 12 and i % s.cols > body.x + 2); - } - try std.testing.expect(changed >= 3 and changed <= 5); - // Gone by 120 ms; a step of a cell leaves none; nor a terminal without - // truecolor. - core.now_ns += 130 * std.time.ns_per_ms; - core.shell_continuous = false; - frame = .{ .arena = arena.allocator(), .canonical = s }; - try trail.apply(&frame, core, true); - try std.testing.expect(frame.copy == null and !trail.active and !core.shell_continuous); - s.cursor = .{ .x = body.x + 13, .y = body.y + 1 }; - frame = .{ .arena = arena.allocator(), .canonical = s }; - try trail.apply(&frame, core, true); - try std.testing.expect(frame.copy == null); - s.cursor = .{ .x = body.x + 2, .y = body.y + 1 }; - frame = .{ .arena = arena.allocator(), .canonical = s }; - try trail.apply(&frame, core, false); - try std.testing.expect(frame.copy == null); -} - -test "a notice chip casts a cell's shadow right and down, inside its body, off the cursor" { - const gpa = std.testing.allocator; - const core = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); - defer core.deinit(); - _ = try core.setTestFile(std.mem.asBytes(&@as([20][20]u8, @splat("some text on a line\n".*)))); - try std.testing.expect(core.executeBuiltinLine(0, "Theme forge")); - core.settings.chip_shadow = true; - try std.testing.expect(core.executeBuiltinLine(0, "Msg a notice")); - for (0..60) |_| core.update(.tick); - core.sync(); - var arena: std.heap.ArenaAllocator = .init(gpa); - defer arena.deinit(); - const s = try core.render(arena.allocator()); - const chip = for (s.regionList()) |region| { - if (region.kind == .notice) break region.rect; - } else return error.NoNotice; - s.cursor = null; - var frame: Frame = .{ .arena = arena.allocator(), .canonical = s }; - try chipShadows(&frame, core, true); - const out = frame.copy orelse return error.NoShadow; - var changed: usize = 0; - for (out.cells, s.cells, 0..) |a, b, i| { - if (std.meta.eql(a, b)) continue; - changed += 1; - const x = i % s.cols; - const y = i / s.cols; - // Right of the chip or below it, never inside it. - try std.testing.expect(x == chip.x + chip.w or y == chip.y + chip.h); - try std.testing.expect(!(x >= chip.x and x < chip.x + chip.w and y >= chip.y and y < chip.y + chip.h)); - } - try std.testing.expect(changed >= chip.w - 1); - // Off, or without truecolor: the frame as it was. - frame = .{ .arena = arena.allocator(), .canonical = s }; - try chipShadows(&frame, core, false); - try std.testing.expect(frame.copy == null); - core.settings.chip_shadow = false; - try chipShadows(&frame, core, true); - try std.testing.expect(frame.copy == null); -} - -test "a scrolled pane's thumb brightens and fades back in 250 ms" { - const gpa = std.testing.allocator; - const core = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); - defer core.deinit(); - const pane = try core.setTestFile(std.mem.asBytes(&@as([200][20]u8, @splat("some text on a line\n".*)))); - try std.testing.expect(core.executeBuiltinLine(0, "Theme forge")); - core.settings.thumb_flash = true; - for (0..40) |_| core.update(.tick); - core.sync(); - var arena: std.heap.ArenaAllocator = .init(gpa); - defer arena.deinit(); - var flash: ThumbFlash = .{}; - core.now_ns = std.time.ns_per_s; - var frame: Frame = .{ .arena = arena.allocator(), .canonical = try core.render(arena.allocator()) }; - try flash.apply(&frame, core, true); - try std.testing.expect(frame.copy == null); - pane.scrollBy(20); - core.now_ns += 16 * std.time.ns_per_ms; - const moved = try core.render(arena.allocator()); - frame = .{ .arena = arena.allocator(), .canonical = moved }; - try flash.apply(&frame, core, true); - const lit = frame.copy orelse return error.NoFlash; - try std.testing.expect(core.shell_continuous); - var brighter: usize = 0; - for (lit.cells, moved.cells) |a, b| { - if (!std.meta.eql(a.style.bg, b.style.bg)) brighter += 1; - } - try std.testing.expect(brighter >= 1); - core.now_ns += 300 * std.time.ns_per_ms; - core.shell_continuous = false; - frame = .{ .arena = arena.allocator(), .canonical = try core.render(arena.allocator()) }; - try flash.apply(&frame, core, true); - try std.testing.expect(frame.copy == null and !core.shell_continuous); -} diff --git a/src/tui/tui.zig b/src/tui/tui.zig index 674a7812..fae55141 100644 --- a/src/tui/tui.zig +++ b/src/tui/tui.zig @@ -1409,12 +1409,8 @@ const Screen = struct { /// Its size as last taken (`Shell.resized`). size: ?vaxis.Winsize = null, tracks: []const pardes.animation.Track = &.{}, - /// T2: the cursor's jump trail (JumpTrail). - trail: panel_compositor.JumpTrail = .{}, /// The view's glide, the GUI's motion drawn at whole rows (anim 12). glide: pardes.glide.Glide = .{}, - /// T7: when each pane's view last moved (ThumbFlash). - flash: panel_compositor.ThumbFlash = .{}, /// `fd` made raw, as vaxis.Tty.init makes /dev/tty: the terminal of a /// forked session is no controlling terminal of its, which /dev/tty is. @@ -2619,16 +2615,12 @@ const Shell = struct { panel_compositor.compose(&frame, sc.tracks, s.core.theme().bg) catch return; const tz_cells = tracy.zone(@src(), "surface->vaxis"); const win = vx.window(); - const truecolor = vx.caps.rgb or colortermTruecolor(); // Each of the shell's own motions below asks for frames while it runs. if (sc.glide.pending) sc.glide.measure(s.gpa, canonical); if (sc.glide.moving()) sc.glide.advance(s.core.now_ns, sc.glide.motion); s.core.shell_continuous = sc.glide.moving(); s.core.frames.scroll = @round(sc.glide.follow.offset); panel_compositor.glideRows(&frame, &sc.glide) catch {}; - panel_compositor.chipShadows(&frame, s.core, truecolor) catch {}; - sc.flash.apply(&frame, s.core, truecolor) catch {}; - sc.trail.apply(&frame, s.core, truecolor) catch {}; const shown = frame.shown(); paintCells(win, shown.cells, shown.cols, shown.rows); if (s.remote) |c| if (c.link.notice_len > 0) noticeLine(win, c.link.notice(), shown.cols, shown.rows); @@ -3407,10 +3399,3 @@ test "a fade sends the text it dims, not the blanks beside it" { try std.testing.expect(std.mem.indexOf(u8, sent[1], "90:90:90") != null); try std.testing.expect(std.mem.indexOfScalar(u8, sent[1], 'a') != null); } - -/// Truecolor by COLORTERM (truecolor or 24bit), for a terminal that does -/// not answer vaxis's query (§9.2: vaxis caps or COLORTERM). -fn colortermTruecolor() bool { - const value = std.mem.span(std.c.getenv("COLORTERM") orelse return false); - return std.mem.eql(u8, value, "truecolor") or std.mem.eql(u8, value, "24bit"); -} diff --git a/test/record_casts.py b/test/record_casts.py index 15f46ced..703f1459 100644 --- a/test/record_casts.py +++ b/test/record_casts.py @@ -859,7 +859,7 @@ def make_home(work): # wherever the wall clock put it. (home / 'config/pardes/init').write_text( 'Theme orchard\nShell /bin/sh\nMessageLinger 0\nMessageAnimation off\nCursorBlink off\n' - 'SelectionGlow off\nHoverGlow off\nJumpTrail off\nThumbFlash off\n') + 'SelectionGlow off\nHoverGlow off\n') (home / '.gitconfig').write_text('[log]\n\tabbrevCommit = true\n[color]\n\tui = always\n') return home -- cgit v1.3