summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-04 23:55:03 -0300
committerGabriel Schneider <[email protected]>2026-11-05 01:02:08 -0300
commitfc2bc8b80cf524c4a4800b8492b1ddcd6e693ab9 (patch)
treec513336568a71910710e99cf3cc18b7a1d67d431
parentc7bab5ec27f8dc1058e282fbbfc8fe9f01cd78bf (diff)
downloadpardes-fc2bc8b80cf524c4a4800b8492b1ddcd6e693ab9.tar.gz
pardes-fc2bc8b80cf524c4a4800b8492b1ddcd6e693ab9.zip
image: the three renderer toggles (toggleGlyphArt, togglePalette, toggleAscii, a line each) are the field flips at their one caller each, the Petscii, Palette and Ascii builtins, and the image tag test sets the fields it wants
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
-rw-r--r--src/builtins.zig6
-rw-r--r--src/image.zig12
-rw-r--r--test/panes.zig8
3 files changed, 4 insertions, 22 deletions
diff --git a/src/builtins.zig b/src/builtins.zig
index 3686eb88..95a6c692 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -1031,7 +1031,7 @@ pub const Petscii = struct {
const want = stateArg(c, OnOff, "Petscii", "on or off") orelse return;
if ((want == .on) == now) return;
}
- if (c.pane.image) |*state| panes.Image.toggleGlyphArt(state);
+ if (c.pane.image) |*state| state.glyph_art = !state.glyph_art;
panes.terminal.togglePetscii(c.pane);
}
};
@@ -1046,7 +1046,7 @@ pub const Palette = struct {
const want = stateArg(c, panes.Image.PaletteMode, "Palette", "commodore or terminal") orelse return;
if (want == state.pmode) return;
}
- panes.Image.togglePalette(state);
+ state.pmode = if (state.pmode == .commodore) .terminal else .commodore;
}
};
@@ -1060,7 +1060,7 @@ pub const Ascii = struct {
const want = stateArg(c, OnOff, "Ascii", "on or off") orelse return;
if ((want == .on) == state.ascii) return;
}
- panes.Image.toggleAscii(state);
+ state.ascii = !state.ascii;
}
};
diff --git a/src/image.zig b/src/image.zig
index fe515073..357d9e94 100644
--- a/src/image.zig
+++ b/src/image.zig
@@ -981,18 +981,6 @@ pub fn create(p: *pardes.Pardes, id: usize, path: []const u8, raw: []u8) !*parde
return pane;
}
-pub fn toggleGlyphArt(state: *State) void {
- state.glyph_art = !state.glyph_art;
-}
-
-pub fn togglePalette(state: *State) void {
- state.pmode = if (state.pmode == .commodore) .terminal else .commodore;
-}
-
-pub fn toggleAscii(state: *State) void {
- state.ascii = !state.ascii;
-}
-
/// Image renderer choices are pane-local, not global Config values. Keep them
/// queryable where they apply: the live tag beside the image's path.
/// `glyphs`: whether the picture is drawn as glyph art, which a terminal
diff --git a/test/panes.zig b/test/panes.zig
index 1e00fa94..22fdd225 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -2321,16 +2321,10 @@ const OutputTests = struct {
const ImageTests = struct {
const State = panes.Image.State;
- const toggleGlyphArt = panes.Image.toggleGlyphArt;
- const togglePalette = panes.Image.togglePalette;
- const toggleAscii = panes.Image.toggleAscii;
const tagPrefix = panes.Image.tagPrefix;
test "pane-local renderer choices are visible in the image tag" {
- var state: State = .{ .path = @constCast("/tmp/picture.ppm") };
- toggleGlyphArt(&state);
- togglePalette(&state);
- toggleAscii(&state);
+ const state: State = .{ .path = @constCast("/tmp/picture.ppm"), .glyph_art = true, .pmode = .terminal, .ascii = false };
const tag = try tagPrefix(std.testing.allocator, &state, state.glyph_art);
defer std.testing.allocator.free(tag);
try std.testing.expectEqualStrings(