diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 11:09:06 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 15:12:36 -0300 |
| commit | a28b37fb04566c36759edab0da7b1f98dffa6808 (patch) | |
| tree | 440e9b4a32321c4c79874132de743e2ac31d9606 | |
| parent | 11204e1206f7f7ffeaa861c1a442a312e563d3ed (diff) | |
| download | pardes-a28b37fb04566c36759edab0da7b1f98dffa6808.tar.gz pardes-a28b37fb04566c36759edab0da7b1f98dffa6808.zip | |
effects out, Pet: src/gui/pet.zig, the Pet word and setting, the window's pet overlay (the triangle overlay holds the cursor's quad alone) and the DumpConfig `# Pet` line go; the root ctl reads LocationsConfig through DumpConfig's writer, so ctl.zig writes no settings line of its own; the Pet behaviour test goes, what it pinned besides the pet (a GUI-only builtin refused at a pane's exec in a terminal's view) now in the GUI-only settings test, with Fonts; the appearance gallery loses its pets
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
| -rw-r--r-- | docs/typ/builtins-gui.json | 1 | ||||
| -rw-r--r-- | docs/typ/reference.typ | 1 | ||||
| -rw-r--r-- | src/builtins.zig | 14 | ||||
| -rw-r--r-- | src/config.zig | 4 | ||||
| -rw-r--r-- | src/gui/gui.zig | 112 | ||||
| -rw-r--r-- | src/gui/pet.zig | 215 | ||||
| -rw-r--r-- | src/ninep/ctl.zig | 10 | ||||
| -rw-r--r-- | test/appearance_gallery.py | 31 | ||||
| -rw-r--r-- | test/behaviour/settings.zig | 28 |
9 files changed, 15 insertions, 401 deletions
diff --git a/docs/typ/builtins-gui.json b/docs/typ/builtins-gui.json index e2e118c7..de898384 100644 --- a/docs/typ/builtins-gui.json +++ b/docs/typ/builtins-gui.json @@ -99,7 +99,6 @@ {"name": "PdfFit", "leader": "SPC t z", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Fit the PDF page to the pane by width or by height, flipping between them (or to the one named, `width|height`)."}, {"name": "PdfSections", "leader": "SPC t s", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "List the PDF's sections in a pane, each a place to go."}, {"name": "PdfTint", "leader": "SPC t i", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Tint the PDF page to the theme, or show it as printed, stepping through them (or to the one named, `disabled|filtered|full`)."}, - {"name": "Pet", "leader": null, "also": [], "arg": true, "scope": "root", "setting": false, "choices": null, "doc": "An optional SDL workspace-tag companion; never consumes input or text cells."}, {"name": "Petscii", "leader": "SPC t p", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "glyph art over the host's pixels: an image pane's picture, or the kitty graphics a terminal's program placed (yazi's previews)"}, {"name": "ProgramEsc", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "In a raw terminal, Esc goes to the program and Shift-Esc backs out, on; off (the default) swaps them."}, {"name": "Putall", "leader": null, "also": [], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "acme's Putall: every pane holding unsaved edits to a file is saved, each as its own Save; one that is refused (changed on disk since, a write that fails) says so and the rest are saved all the same."}, diff --git a/docs/typ/reference.typ b/docs/typ/reference.typ index 84eeff47..f0e7295e 100644 --- a/docs/typ/reference.typ +++ b/docs/typ/reference.typ @@ -447,7 +447,6 @@ word clicked in a tag does. The same lines go in the startup file [#word("TaglineSize") `<1-100>`], [82: tagline face, percent; SDL and macOS], [#word("WindowOpacity") `<0-100>`], [100; SDL only: everything but text and the cursor], [#word("Ligatures")], [on; SDL only, macOS draws CoreText's own], - [#word("Pet") `cat|frog|off`], [off; SDL only: a sprite in the workspace tag's blank space], ) #word("LocationsConfig") with no argument prints the current settings as a line diff --git a/src/builtins.zig b/src/builtins.zig index c7b427f5..39ad9d7b 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -1632,20 +1632,6 @@ pub const Changelog = struct { } }; -/// An optional SDL workspace-tag companion; never consumes input or text cells. -pub const Pet = struct { - pub const scope: Scope = .session; - pub const takes_arg = true; - pub const requires_arg = true; - pub const enabled = desktop; - pub const gui_only = true; - pub const in_window = true; - pub fn run(c: Ctx) void { - const name = std.mem.trim(u8, c.arg orelse return, " \t\r\n"); - c.p.settings.pet = std.meta.stringToEnum(@TypeOf(c.p.settings.pet), name) orelse return; - } -}; - /// Open a minimap of the file in braille dots. pub const Mini = struct { pub const takes_arg = true; diff --git a/src/config.zig b/src/config.zig index 9394f912..c8ba76bd 100644 --- a/src/config.zig +++ b/src/config.zig @@ -158,7 +158,6 @@ pub const leader_path = paths: { table.set(.Font, null); table.set(.TaglineSize, null); } - if (builtins.Pet.enabled) table.set(.Pet, null); table.set(.MessageAnimation, null); table.set(.MessageLinger, null); table.set(.MessageFall, null); @@ -794,7 +793,6 @@ pub const Runtime = struct { window_opacity: u8 = 100, window_blur: u8 = 0, window_opacity_pending: bool = true, - pet: enum { off, cat, frog } = .off, // Effective values change only after a host acknowledges the request. shell: struct { @@ -1354,8 +1352,6 @@ pub const Runtime = struct { ); try out.print("# Look hover delay: {d} frames\n", .{context.hover_delay_frames}); try out.print("# Native images: {s}\n", .{onOff(context.native_images)}); - if (std.mem.eql(u8, context.platform, "gui")) - try out.print("# Pet: {s}\n", .{@tagName(state.pet)}); } test "panel effects flip bare and are set by on and off" { diff --git a/src/gui/gui.zig b/src/gui/gui.zig index 2c2f53c4..ee565aeb 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -13,7 +13,6 @@ const look = @import("../look.zig"); const message = pardes.Messages.Message; const file_watch = @import("../file_watch.zig"); const deck = @import("deck.zig"); -const pet = @import("pet.zig"); const fonts = @import("../fonts.zig"); // the fallback faces const selection_pipe = @import("../selection_pipe.zig"); const c_heap = @import("c_heap"); @@ -240,9 +239,9 @@ const LoadedFallback = struct { const max_touch_points: usize = 16; const touch_scroll_tick: f32 = 0.02; -// The triangle overlay holds only the pet and the cursor's glide quad: the -// chrome is decor. -const max_overlay_vertices: usize = pet.max_vertices + 6; +// The triangle overlay holds only the cursor's glide quad: the chrome is +// decor. +const max_overlay_vertices: usize = 6; const font_px_step: f32 = 2.0; const font_px_min: f32 = 8.0; @@ -1137,7 +1136,6 @@ const Gui = struct { words: Words = .{}, touch: Touch = .{}, - pet_state: pet.State = .{}, live_ctrl: bool = false, live_alt: bool = false, @@ -1434,7 +1432,7 @@ const Group = struct { /// standing still), a group for each track in paint order (tier 2 moving and /// opening, tier 3 closing), tier 4 (floating: the notices, then the guides /// and the debug box, which the core paints over them) and tier 5 (ink: the -/// bar cursors; the pet and the cursor's glide draw after it). Tier 1 is the +/// bar cursors; the cursor's glide draws after it). Tier 1 is the /// focus lift, which does not exist yet. const Groups = struct { items: [pardes.MAX_PANES * 2 + 4]Group = @splat(.{}), @@ -5862,7 +5860,7 @@ fn renderFrame( if (!pdf_focus) core.frames.scroll = g.glide.follow.offset; core.frames.caret = caretRow(g, surface) orelse 0; const cursors_shown = groups.tracks == 0 and !quad_mode; - var overlay_count = buildOverlay(g, core, surface, sw, sh); + var overlay_count = buildOverlay(g, surface, sw, sh); if (overlay_count != 0 and !uploadOverlayGpu(g, cmd, overlay_count)) overlay_count = 0; if (!prepareNativeImages(g, gpa, cmd, surface, &groups, sw, sh)) { @@ -9882,18 +9880,15 @@ fn cursorDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, if (box.bar) try addDecor(g, gpa, box.x0, box.y0, box.x1, box.y1, box.rgb, 1, null, win_w, win_h); } -/// The triangle overlay: the workspace pet and the cursor's glide, over -/// everything. +/// The triangle overlay: the cursor's glide, over everything. fn buildOverlay( g: *Gui, - core: *const pardes.Pardes, surface: *const pardes.Surface, sw: u32, sh: u32, ) u32 { if (g.overlay_vertices.len == 0 or sw == 0 or sh == 0) return 0; var builder = OverlayBuilder{ .vertices = g.overlay_vertices, .win_w = @floatFromInt(sw), .win_h = @floatFromInt(sh) }; - appendWorkspacePet(g, core, surface, &builder); appendCursorGlide(g, surface, &builder); return @intCast(builder.len); } @@ -9936,81 +9931,6 @@ fn appendCursorGlide(g: *Gui, surface: *const pardes.Surface, builder: *OverlayB builder.addTri(px[0][0], px[0][1], px[2][0], px[2][1], px[3][0], px[3][1], color); } -fn appendWorkspacePet(g: *Gui, core: *const pardes.Pardes, surface: *const pardes.Surface, builder: *OverlayBuilder) void { - const kind: pet.Kind = @fromBackingInt(@intCast(@backingInt(core.settings.pet))); - if (kind == .off or surface.rows == 0 or surface.cols == 0) { - g.pet_state = .{}; - return; - } - // Read only the rendered global row. No pane/column tags, status text or - // mouse targets are changed; editing the workspace tag leaves it be. - var occupied: usize = 0; - for (surface.cells[0..surface.cols], 0..) |*cell, i| { - if (cellCodepoint(cell) != ' ') occupied = i + 1; - } - const band_top: f32 = @floatFromInt(taglineBandOffset(0, builder.win_h, g.cell_h, g.tagline_height)); - const region = if (occupied >= surface.cols) null else pet.lane( - occupied, - @floatFromInt(g.tagline_width), - builder.win_w, - band_top, - @floatFromInt(g.tagline_height), - ); - // SDL's regular pump already wakes at least every 16 ms. Quantization in - // sample keeps this independent of input, render rate and scene effects, - // without creating another timer or forcing core animation ticks. - const pose = g.pet_state.sample(kind, c.SDL_GetTicks(), region) orelse return; - const ink = overlayRgb(core.chromeTheme().tag_fg); - const eye = overlayRgb(core.chromeTheme().tag_bg); - // Behind the cursor: the overlay is over the cells, so the pixels a - // cursor covers are left out. - var boxes: [max_cursors]CursorBox = undefined; - const cursors = boxes[0..cursorBoxes(g, surface, fixedCellLayout(g), builder.win_h, &boxes)]; - for (0..pet.height) |y| for (0..pet.width) |x| { - const color = pet.pixel(kind, pose, x, y); - if (color == 0) continue; - const x0 = pose.x + @as(f32, @floatFromInt(x)) * pose.scale; - const y0 = pose.y + @as(f32, @floatFromInt(y)) * pose.scale; - const covered = for (cursors) |box| { - if (x0 < box.x1 and x0 + pose.scale > box.x0 and y0 < box.y1 and y0 + pose.scale > box.y0) break true; - } else false; - if (covered) continue; - builder.addRect(x0, y0, x0 + pose.scale, y0 + pose.scale, if (color == 2) eye else ink); - }; -} - -test "pet overlay stays beyond workspace text and keeps going while its tag is edited" { - std.testing.refAllDecls(pet); - const core = try pardes.Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24 }); - defer core.deinit(); - core.settings.pet = .cat; - var cells: [80]pardes.Cell = @splat(.{}); - const surface: pardes.Surface = .{ .cols = 80, .rows = 1, .cells = &cells }; - for ("Workspace Commands", 0..) |ch, i| { - cells[i].text[0] = ch; - cells[i].len = 1; - cells[i].default = false; - } - var g = testGui(10, 20, 8, 16); - var vertices: [pet.max_vertices]OverlayVertex = undefined; - var builder: OverlayBuilder = .{ .vertices = &vertices, .win_w = 800, .win_h = 480 }; - appendWorkspacePet(&g, core, &surface, &builder); - try std.testing.expect(builder.len > 0); - for (vertices[0..builder.len]) |v| { - const x = (v.x + 1) * 400; - const y = (1 - v.y) * 240; - try std.testing.expect(x >= 20 * 8 - 0.01); - try std.testing.expect(y >= 0 and y < 20); - } - const before = g.pet_state; - pardes.tagline.enterHeader(core, null); - builder.len = 0; - appendWorkspacePet(&g, core, &surface, &builder); - try std.testing.expect(builder.len > 0); - try std.testing.expectEqual(before.tick, g.pet_state.tick); - try std.testing.expectEqual(before.x, g.pet_state.x); -} - fn cursorColor(chrome: *const pardes.Chrome, cell: *const pardes.Cell, role: pardes.FontRole) [3]u8 { return if (role == .tagline) switch (cell.style.fg) { .rgb => |rgb| rgb, @@ -10018,15 +9938,6 @@ fn cursorColor(chrome: *const pardes.Chrome, cell: *const pardes.Cell, role: par } else chrome.fg orelse fg_default; } -fn overlayRgb(rgb: [3]u8) OverlayColor { - return .{ - .r = @as(f32, @floatFromInt(rgb[0])) / 255.0, - .g = @as(f32, @floatFromInt(rgb[1])) / 255.0, - .b = @as(f32, @floatFromInt(rgb[2])) / 255.0, - .a = 1, - }; -} - fn uploadOverlayGpu(g: *Gui, cmd: *c.SDL_GPUCommandBuffer, vertex_count: u32) bool { const byte_len: u32 = vertex_count * @sizeOf(OverlayVertex); const ptr = c.SDL_MapGPUTransferBuffer(g.device, g.overlay_vxfer, false) orelse return false; @@ -10088,17 +9999,6 @@ const OverlayBuilder = struct { b.addVertex(x2, y2, color); } - fn addRect(b: *OverlayBuilder, x0_in: f32, y0_in: f32, x1_in: f32, y1_in: f32, color: OverlayColor) void { - if (b.len + 6 > b.vertices.len) return; - const x0 = std.math.clamp(@min(x0_in, x1_in), 0.0, b.win_w); - const x1 = std.math.clamp(@max(x0_in, x1_in), 0.0, b.win_w); - const y0 = std.math.clamp(@min(y0_in, y1_in), 0.0, b.win_h); - const y1 = std.math.clamp(@max(y0_in, y1_in), 0.0, b.win_h); - if (x1 <= x0 or y1 <= y0) return; - b.addTri(x0, y0, x1, y0, x1, y1, color); - b.addTri(x0, y0, x1, y1, x0, y1, color); - } - }; fn envU16(env: *std.process.Environ.Map, name: []const u8) ?u16 { diff --git a/src/gui/pet.zig b/src/gui/pet.zig deleted file mode 100644 index 7a13ca91..00000000 --- a/src/gui/pet.zig +++ /dev/null @@ -1,215 +0,0 @@ -//! Original code-native pixel companions. Pure, bounded geometry and a 10 Hz -//! animation clock: no textures, allocation, input handling or editor state. -const std = @import("std"); - -pub const Kind = enum { off, cat, frog }; -pub const width = 12; -pub const height = 9; -pub const max_vertices = width * height * 6; -pub const Lane = struct { left: f32, right: f32, top: f32, scale: f32 }; -pub const Pose = struct { x: f32, y: f32, scale: f32, left: bool, walking: bool, frame: u8 }; -/// The frog's hop: sits two ticks, takes off, peaks for two, comes down, lands. -const hop_ticks = 8; - -/// Only the trailing blank part of the global tag is eligible. The caller -/// supplies its last occupied cell, including any wide-grapheme continuation. -pub fn lane(occupied: usize, cell_w: f32, screen_w: f32, top: f32, band_h: f32) ?Lane { - if (cell_w <= 0 or band_h < height + 2) return null; - const scale = @min(3, @floor((band_h - 2) / height)); - const left = @as(f32, @floatFromInt(occupied + 2)) * cell_w; - const right = screen_w - 2 * cell_w - width * scale; - if (right - left < 4 * scale) return null; - return .{ .left = left, .right = right, .top = top + band_h - height * scale - 1, .scale = scale }; -} - -pub const State = struct { - kind: Kind = .off, - tick: ?u64 = null, - x: f32 = 0, - target: f32 = 0, - left: bool = false, - idle: u8 = 12, - frame: u8 = 0, - rng: std.Random.DefaultPrng = undefined, - - /// No lane (the tag's text has filled it) hides the pet but keeps - /// where it was and what it was doing. - pub fn sample(s: *State, kind: Kind, now_ms: u64, area: ?Lane) ?Pose { - const region = area orelse return null; - if (kind == .off) { - s.* = .{}; - return null; - } - const tick = now_ms / 100; - if (s.kind != kind or s.tick == null) { - s.* = .{ .kind = kind, .tick = tick, .x = region.left, .target = region.left, .rng = .init(now_ms) }; - } - s.x = std.math.clamp(s.x, region.left, region.right); - s.target = std.math.clamp(s.target, region.left, region.right); - // Coming back from suspension never launches the pet across the tag. - const steps = @min(tick -| s.tick.?, 2); - s.tick = tick; - for (0..steps) |_| { - s.frame +%= 1; - if (s.idle > 0) { - s.idle -= 1; - if (s.idle == 0) { - // Wander to a random spot of the lane; one too close - // would be a shuffle in place, so take the far end. - s.target = region.left + s.rng.random().float(f32) * (region.right - region.left); - if (@abs(s.target - s.x) < 8 * region.scale) - s.target = if (s.x - region.left > region.right - s.x) region.left else region.right; - s.left = s.target < s.x; - s.frame = 255; // the walk starts at frame 0 - } - continue; - } - // The cat walks steadily; the frog travels only while airborne. - const phase = s.frame % hop_ticks; - if (kind == .cat or (phase >= 2 and phase < 6)) { - const step = (if (kind == .cat) @as(f32, 1.8) else 2.6) * region.scale; - s.x = if (s.left) @max(s.target, s.x - step) else @min(s.target, s.x + step); - } - if (s.x == s.target and (kind == .cat or phase == hop_ticks - 1)) - s.idle = s.rng.random().intRangeAtMost(u8, 20, 60); - } - return .{ .x = @floor(s.x), .y = region.top, .scale = region.scale, .left = s.left, .walking = s.idle == 0, .frame = s.frame }; - } -}; - -const cat = [_][]const u8{ - " # # ", - " #####", - " ##o##", - " # ######", - " # ######## ", - " ######### ", - " ######## ", - " ## ## ", - " # # ", -}; -const frog = [_][]const u8{ - " ", - " ", - " ", - " ## ", - " #o## ", - " #########", - " ######### ", - " ##### ## ", - "###### ### ", -}; -const frog_leap = [_][]const u8{ - " ## ", - " #o## ", - " #######", - " ######## ", - " ####### ", - " ### ## ", - "## # ", - "# ", - " ", -}; - -/// 0 transparent, 1 theme ink, 2 eye cutout. Walk legs and idle blinks are -/// generated in this fixed 12x9 tile; neither can spill into an adjacent row. -pub fn pixel(kind: Kind, pose: Pose, x_in: usize, y: usize) u2 { - if (x_in >= width or y >= height or kind == .off) return 0; - const x = if (pose.left) width - 1 - x_in else x_in; - const alternate = (pose.frame / 2) % 2 == 1; - // An idle companion still looks alive during its first pause: a slow - // two-pixel tail-tip flick, or the frog's throat gently inflating. These - // remain inside the tile and mirror with the rest of the animal. - const breathing = (pose.frame / 4) % 2 == 1; - if (!pose.walking and breathing) { - if (kind == .cat and y == 3 and x <= 1) - return @intFromBool(x == 0); - if (kind == .frog and ((y == 6 and x == 11) or (y == 7 and x == 10))) return 1; - } - if (kind == .cat and pose.walking and alternate and y >= 7) - return @intFromBool((y == 7 and (x == 3 or x == 7)) or (y == 8 and (x == 2 or x == 8))); - // A hopping frog leaps two rows low at take-off and one on the way down. - const phase = pose.frame % hop_ticks; - const leaping = kind == .frog and pose.walking and phase >= 2 and phase < 6; - const sink: usize = if (!leaping) 0 else if (phase == 2) 2 else if (phase == 5) 1 else 0; - if (y < sink) return 0; - const ch = (if (kind == .cat) cat else if (leaping) frog_leap else frog)[y - sink][x]; - return switch (ch) { - '#' => 1, - 'o' => if (!pose.walking and pose.frame % 30 >= 27) 1 else 2, - else => 0, - }; -} - -test "pet stays in trailing workspace blanks, and a lost lane hides it without a reset" { - try std.testing.expect(lane(20, 8, 200, 0, 16) == null); - try std.testing.expect(lane(3, 8, 200, 0, 10) == null); - const region = lane(3, 8, 200, 2, 20).?; - try std.testing.expect(region.left >= 5 * 8); - var state: State = .{}; - var moved = false; - var reversed = false; - for (0..2000) |i| { - const pose = state.sample(.cat, i * 100, region).?; - try std.testing.expect(pose.x >= region.left and pose.x + width * pose.scale <= 200 - 16); - try std.testing.expect(pose.y >= 2 and pose.y + height * pose.scale < 22); - moved = moved or pose.walking; - reversed = reversed or pose.left; - } - try std.testing.expect(moved and reversed); - const kept = state; - try std.testing.expect(state.sample(.cat, 300000, null) == null); - try std.testing.expectEqual(kept.x, state.x); - try std.testing.expectEqual(kept.tick, state.tick); - try std.testing.expect(state.sample(.off, 300100, region) == null); -} - -test "pet clock is fixed rate and sprites bounded in both directions" { - const region = lane(1, 8, 400, 0, 16).?; - var state: State = .{}; - const start = state.sample(.frog, 1000, region).?; - try std.testing.expectEqualDeep(start, state.sample(.frog, 1099, region).?); - for ([_]Kind{ .cat, .frog }) |kind| for ([_]bool{ false, true }) |left| { - const pose: Pose = .{ .x = 0, .y = 0, .scale = 1, .left = left, .walking = true, .frame = 3 }; - var count: usize = 0; - for (0..height) |y| for (0..width) |x| { - count += @intFromBool(pixel(kind, pose, x, y) != 0); - }; - try std.testing.expect(count > 20 and count <= width * height); - try std.testing.expectEqual(@as(u2, 0), pixel(kind, pose, width, height)); - }; -} - -test "pet rests at random spots and the frog travels only in the air" { - const region = lane(1, 8, 800, 0, 16).?; - var state: State = .{}; - var last = state.sample(.frog, 0, region).?; - var rested_midway = false; - for (1..3000) |i| { - const pose = state.sample(.frog, i * 100, region).?; - const phase = pose.frame % hop_ticks; - if (pose.x != last.x) try std.testing.expect(pose.walking and phase >= 2 and phase < 6); - rested_midway = rested_midway or (last.walking and !pose.walking and pose.x > region.left and pose.x < @floor(region.right)); - last = pose; - } - try std.testing.expect(rested_midway); -} - -test "pet initial idle visibly animates without walking or leaving its tile" { - const region = lane(1, 8, 400, 0, 16).?; - for ([_]Kind{ .cat, .frog }) |kind| { - var state: State = .{}; - const initial = state.sample(kind, 0, region).?; - var later = initial; - for (1..5) |tick| later = state.sample(kind, tick * 100, region).?; - try std.testing.expect(!initial.walking and !later.walking); - try std.testing.expectEqual(initial.x, later.x); - try std.testing.expectEqual(initial.y, later.y); - var changes: usize = 0; - for (0..height) |y| for (0..width) |x| { - changes += @intFromBool(pixel(kind, initial, x, y) != pixel(kind, later, x, y)); - }; - try std.testing.expectEqual(@as(usize, 2), changes); - try std.testing.expectEqual(@as(u2, 0), pixel(kind, later, width, height)); - } -} diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 8a84e37f..2cfee904 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -612,18 +612,18 @@ const e_prompt = "control message needs its argument"; /// is /status's or the DumpConfig window's. fn writeSettings(p: *Pardes, w: *std.Io.Writer) !void { try writeSettingsFor(p, &p.settings, w, builtins.viewCapabilities(p)); - try w.writeAll("LocationsConfig "); - try p.locations_config.write(w); - try w.writeByte('\n'); - if (comptime builtins.Pet.enabled) if (builtins.registry.here(p, .Pet)) try w.print("Pet {s}\n", .{@tagName(p.settings.pet)}); } /// The setting words of `s`, one a line, those a frontend of `caps` takes -/// (the root ctl's: the live view's). +/// (the root ctl's: the live view's), and the session's LocationsConfig. fn writeSettingsFor(p: *Pardes, s: *const config.Runtime, w: *std.Io.Writer, caps: config.Runtime.Capabilities) !void { // DumpConfig's words: a `# Word unsupported` comment for what `caps` lacks. var dump_dir: [1024]u8 = undefined; + var located_buf: [256]u8 = undefined; + var located: std.Io.Writer = .fixed(&located_buf); + try p.locations_config.write(&located); try config.Runtime.writeSettings(w, .{ + .locations = located.buffered(), .theme_name = p.theme().name, .theme_file = pardes.colors.loadedThemeFile(p), .compiled_default_shell = config.defaultShell(), diff --git a/test/appearance_gallery.py b/test/appearance_gallery.py index 8672de71..0d3ab1fa 100644 --- a/test/appearance_gallery.py +++ b/test/appearance_gallery.py @@ -1,12 +1,10 @@ #!/usr/bin/env python3 -"""Review native palettes, compact tags, sized fonts and pets in an owned SDL session.""" +"""Review native palettes, compact tags and sized fonts in an owned SDL session.""" import argparse -import hashlib import json import os from pathlib import Path import subprocess -import time from fs import session from ui_review import capture, command, panes, require, wait_for @@ -29,9 +27,6 @@ Native palettes spectrum vivid syntax harvest warm earth clay soft rose and pine - -Pet cat / Pet frog / Pet off -Companions stay in unused workspace-tag space. ''' PREFERENCE_NOTES = b'''Pardes / contrast studies @@ -73,7 +68,7 @@ def run(args): if args.live_window: inherited = {'SDL_VIDEODRIVER': 'x11'} handles = {} - report = {'themes': [], 'pets': [], 'os_windows': []} + report = {'themes': [], 'os_windows': []} with session('/bin/sh', root, name, socket_name=name, tty=True, launch=launch, inherited=inherited, terminal=handles) as (client, _): source = next(serial for serial, tag in panes(client).items() if str(source_path) in tag) @@ -173,27 +168,6 @@ def run(args): report['native_themes_first'] = True client.write(f'/pane/{selector}/exec', b'Del\n') command(client, terminal, 'Collapse') - for pet in (() if args.skip_pets else ('cat', 'frog', 'off')): - command(client, right, 'Pet ' + pet) - settings = config_report() - require('Pet: ' + pet + '\n' in settings, 'pet setting not applied') - # Returning focus to the source closes all transient report state. - client.write(f'/pane/{source}/look', f'{source_path}:1\n'.encode()) - take_frame('pet-' + pet) - if pet != 'off': - frame = client.screen() - original_tag = frame['cells'][:frame['cols']] - time.sleep(1) - take_frame('pet-' + pet + '-later') - frame = client.screen() - require(original_tag == frame['cells'][:frame['cols']], 'pet animation changed tag text or styles') - def band_digest(label): - pixels = subprocess.check_output(['magick', str(root / (label + '.png')), - '-crop', '1500x20+0+0', '-depth', '8', 'RGB:-']) - return hashlib.sha256(pixels).hexdigest() - require(band_digest('pet-' + pet) != band_digest('pet-' + pet + '-later'), - 'pet did not animate in workspace tag') - report['pets'].append(pet) require(client.read(f'/pane/{source}/body') == original == source_path.read_bytes(), 'Agave source changed') report['source_unchanged'] = True client.write(f'/pane/{terminal}/pty/data', b'exit\r') @@ -208,6 +182,5 @@ if __name__ == '__main__': parser.add_argument('--project', required=True, type=Path) parser.add_argument('--live-window', action='store_true', help='capture the owned OS window without offscreen test mode') parser.add_argument('--themes', nargs='+', default=THEMES, help='themes to compare in order') - parser.add_argument('--skip-pets', action='store_true', help='review palettes without repeating pet animation tests') parser.add_argument('--theme-selector', action='store_true', help='capture native-first picker and focused source gutter') run(parser.parse_args()) diff --git a/test/behaviour/settings.zig b/test/behaviour/settings.zig index 4b0245d2..76b60da4 100644 --- a/test/behaviour/settings.zig +++ b/test/behaviour/settings.zig @@ -43,30 +43,6 @@ test "settings: Shell refuses a path that is no executable, and bare it goes bac try std.testing.expectEqualStrings(default, try setting(&s, "Shell")); } -test "settings: Pet is the window's: a terminal's view refuses it, from a pane and the root; a window takes only its pets" { - var s = try Session.initFile(std.testing.allocator, "x\n"); - defer s.deinit(); - // Which build, from its options, not from the answer: a terminal's view - // taking Pet must fail here, not pass as a window. - if (comptime @import("pardes_config").platform == .gui) { - try s.write("/ctl", "Pet cat\n"); - // A window's: dog is no pet of its, and off is. - try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "\nPet cat\n") != null); - _ = try s.refused("/ctl", "Pet dog\n"); - try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "\nPet cat\n") != null); - try s.write("/ctl", "Pet frog\n"); - try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "\nPet frog\n") != null); - try s.write("/ctl", "Pet off\n"); - try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "\nPet off\n") != null); - return; - } - try std.testing.expectEqual(@as(u16, 22), try s.refused("/ctl", "Pet cat\n")); - try std.testing.expect(std.mem.startsWith(u8, s.said, "Pet is GUI-only, invalid here")); - try std.testing.expectEqual(@as(u16, 22), try s.refused(s.at("/pane/{d}/exec", .{try s.focused()}), "Pet cat\n")); - try std.testing.expectEqualStrings("Pet is GUI-only, invalid here", s.said); - try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "Pet ") == null); -} - fn expectHas(text: []const u8, part: []const u8) !void { if (std.mem.indexOf(u8, text, part) == null) { std.debug.print("not in it: {s}\n", .{part}); @@ -127,6 +103,8 @@ test "settings: a setting this frontend cannot show says GUI-only, never run as try std.testing.expectEqualStrings("Fonts is GUI-only, invalid here \"Fonts\"", s.said); try std.testing.expectEqual(@as(u16, 22), try s.refused("/exec", "Fonts\n")); try std.testing.expectEqualStrings("Fonts is GUI-only, invalid here", s.said); + try std.testing.expectEqual(@as(u16, 22), try s.refused(s.at("/pane/{d}/exec", .{try s.focused()}), "Fonts\n")); + try std.testing.expectEqualStrings("Fonts is GUI-only, invalid here", s.said); } _ = try s.refused("/ctl", "Liftt on\n"); try std.testing.expectEqualStrings("unknown control message \"Liftt\"", s.said); @@ -257,8 +235,6 @@ test "settings: every on/off setting the root ctl reads flips when its word is w const word, const was = .{ line[0..space], line[space + 1 ..] }; const on = std.mem.eql(u8, was, "on"); if (!on and !std.mem.eql(u8, was, "off")) continue; - // Pet's `off` says it has no pet; it takes a name, not a flip. - if (std.mem.eql(u8, word, "Pet")) continue; s.write("/ctl", s.at("{s}\n", .{word})) catch |err| { std.debug.print("a bare {s} (was {s}) was refused\n", .{ word, was }); return err; |
