diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-24 13:01:25 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:14 -0300 |
| commit | d395739c8051e28726a4111eec1111a9c70567ec (patch) | |
| tree | 1e2ecebb1fa5cfc45009b286d1480a1779fc3898 /src/builtins.zig | |
| parent | 19a93afb5958b6a6548e1112813d4aa687a8976f (diff) | |
| download | pardes-d395739c8051e28726a4111eec1111a9c70567ec.tar.gz pardes-d395739c8051e28726a4111eec1111a9c70567ec.zip | |
Turn ligatures off with a Ligatures setting, in the shell that shapes text
The SDL shell shapes words with HarfBuzz, so a font's `->` and `!=` draw as
ligatures, and there was no way to have the plain glyphs back short of
changing font. `Ligatures` is a toggle, on by default; off, no cell goes to
the shaper and every cell draws its own glyph, exactly as a font without
ligatures does.
It exists only where it means something. A new `ligatures` capability, true
for the gui shell alone, gates it like Font and WindowOpacity are gated: it is
not a builtin elsewhere, has no leader path, and Config does not list it,
rather than print a row the TTY could never change. macOS draws CoreText
ligatures of its own, but nothing there reads the setting, so it stays off
there. The table check that kept every toggle unconditional now lets the
ligatures toggle, and only it, carry a capability, and requires that it
carry `ligatures`; every other setting's rule is as it was.
The gui keeps the setting beside its text caches, which were resolved under
it: when the core's value changes, the per-codepoint cells (which record
whether a cell is shaped) and the shaped words are dropped, and the frame the
toggle asked for draws every cell again. The atlas keeps its glyphs: plain
ones draw either way, and a ligature's strip is reused when it comes back.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Diffstat (limited to 'src/builtins.zig')
| -rw-r--r-- | src/builtins.zig | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/builtins.zig b/src/builtins.zig index 146789b0..a5dbf6cd 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -19,6 +19,9 @@ pub const capabilities: config.Runtime.Capabilities = .{ .tagline_font_size = pardes.platform != .tty and pardes.platform != .esp32p4, .window_opacity = pardes.platform == .gui or pardes.platform == .macos, .window_blur = pardes.platform == .macos, + // Only the SDL shell shapes with HarfBuzz and honours the setting. macOS + // draws CoreText ligatures of its own, but nothing there reads it yet. + .ligatures = pardes.platform == .gui, }; pub const Ctx = struct { @@ -164,6 +167,29 @@ test "capabilities exactly gate setting and effect-source builtins" { try std.testing.expectEqual(EffectCode.enabled, effect_code_registered); } +test "Ligatures is a setting only in the shell that shapes text" { + const exists = @hasField(registry.Builtin(), "Ligatures"); + try std.testing.expectEqual(pardes.platform == .gui, exists); + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); + defer p.deinit(); + try std.testing.expectEqual(exists, p.executeBuiltinLine(p.active, "Ligatures off")); + try std.testing.expectEqual(!exists, p.settings.ligatures); + var storage: [8192]u8 = undefined; + var out: std.Io.Writer = .fixed(&storage); + try config.Runtime.writeReport(&out, .{ + .startup_config_path = null, + .platform = @tagName(pardes.platform), + .theme_name = p.theme().name, + .compiled_default_shell = config.default_shell, + .hover_delay_frames = null, + .native_images = false, + .capabilities = capabilities, + .state = &p.settings, + }); + try std.testing.expectEqual(exists, std.mem.indexOf(u8, storage[0..out.end], "Ligatures off\n") != null); + try std.testing.expectEqual(exists, std.mem.indexOf(u8, storage[0..out.end], "Ligatures") != null); +} + comptime { for ([_][]const u8{ "Peek", "Poke", "Hexdump" }) |name| if (@hasField(registry.Builtin(), name) != Board.enabled) @compileError( |
