summaryrefslogtreecommitdiff
path: root/src/gui/gui.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 22:40:49 -0300
committerGabriel Schneider <[email protected]>2026-11-05 23:58:31 -0300
commitdfcc040ac979b695dc2e68b9d866c2769ba6d928 (patch)
treecd88c998b46f758a7c74e3d800312d968d6303ac /src/gui/gui.zig
parentf930d53c58187381b2f0df6892546ac1c217c9db (diff)
downloadpardes-dfcc040ac979b695dc2e68b9d866c2769ba6d928.tar.gz
pardes-dfcc040ac979b695dc2e68b9d866c2769ba6d928.zip
settings #2, five presentation variants go, each now the style it had by default: Colors (text panes and terminals coloured, with SPC t c), TreeContextTagStyle (TreeContext rows in the tag's style), FocusTint (the focused tags tinted), SyntaxBold (keywords not bold) and Ligatures (the window shapes them; gui.zig's syncLigatures and the words' ligatures flag go, and Capabilities.ligatures); the reads deleted are in File.zig, body_layer.zig, Tables.zig, exec.zig's applySettingBuiltin, Core.zig (SessionView.layered left at its default), draw.zig, surface.zig's comment and gui.zig; deleted tests: "settings: Colors off draws a source plain, and on again colours its keywords", "Ligatures is a setting only in the shell that shapes text" and "Ligatures off draws a ligature as its cells' own glyphs, and on shapes it again", and the toggled half of TreeContext's Core test; rewritten through what stays: SyntaxBold's every-row test as keywords coloured in every row, the tag-click tests on JumpTrail, the tag-name tint tests with the focused tag's ink plain, Core's tab test by the keyword's ink; golden changes, each the cut's: syntax, theme, mini and ninep lose their Colors toggles and frames (the message row after them names the builtin before, Mini), and leader, ttyhelp and builtins' Help listing is four columns narrower, TreeContextTagStyle having been its longest word; perf.zig's harness id moves again; the window scenes from 09 on take new gui-goldens lines, the scene no longer writing FocusTint on and its word gone from the message row (the base window build running the same scenes gives the same frames); gates on tui: core-test 965/965, behaviour-test 242/242, unit-test 1482/1483, pane-test 171/172, snap all 105 scripts ok, process-test 0 of 37 failed; gui unit-test 1526/1527, gui-golden 0 of 1 failed
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/gui/gui.zig')
-rw-r--r--src/gui/gui.zig59
1 files changed, 3 insertions, 56 deletions
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index 7c042703..07624c20 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -1770,7 +1770,6 @@ fn localSession(
core.frontend.native_image_patches = true;
observeGuiFont(g, core);
syncTaglineFont(g, core);
- syncLigatures(g, core);
var prompt_rcs = host_io.Shell.prepare();
defer prompt_rcs.deinit();
@@ -1916,7 +1915,6 @@ fn localSession(
shell.surface = null;
observeGuiFont(g, core);
syncTaglineFont(g, core);
- syncLigatures(g, core);
}
}
@@ -2164,7 +2162,6 @@ fn remoteSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_
var drew = false;
while (!link.quit) {
core.frames.period_ns = refreshNs(g);
- syncLigatures(g, core);
var own: OwnView = .{ .g = g, .in = &in, .s = &shell, .pointer = drew };
r.within(&own, OwnView.run);
client.feed();
@@ -3861,7 +3858,6 @@ fn pollFrame(ctx: ?*anyopaque) void {
syncWindowOpacity(g, core);
core.frames.period_ns = refreshNs(g);
syncTaglineFont(g, core);
- syncLigatures(g, core);
if (core.takeFontRequest()) |path| blk: {
const bytes = filesystem.readFile(s.gpa, path) catch {
core.rejectFont();
@@ -5117,7 +5113,7 @@ fn emitScrollRows(g: *Gui, instances: [*]CellInstance, base: u32, surface: *cons
/// A scrolling body's tree-sitter context rows hold still: the shifted
/// rows start under them and are clipped below their band, and where a
-/// body layer stacks them at the tagline's height (TreeContextTagStyle)
+/// body layer stacks them at the tagline's height
/// the rows under them are drawn up to meet them, where the layer has them.
fn holdContext(g: *Gui, surface: *const pardes.Surface, id: usize, held: u16, bh: u16, layout: CellLayout) struct { rows: u16, lift: f32 } {
const rows = @min(held, bh);
@@ -6393,17 +6389,6 @@ fn resetGlyphAtlas(g: *Gui) void {
g.atlas_dirty_bottom = atlas_h;
}
-/// A changed Ligatures setting drops what was resolved under the old one: the
-/// per-codepoint cells (which say whether a cell is shaped) and the shaped
-/// words. The atlas keeps its glyphs, plain and strip alike; the plain ones
-/// draw either way, and the strips come back into use when ligatures do.
-/// The frame this runs before redraws every cell with the new setting.
-fn syncLigatures(g: *Gui, core: *pardes.Pardes) void {
- if (core.settings.ligatures == g.words.ligatures) return;
- g.words.clear();
- g.words.ligatures = core.settings.ligatures;
-}
-
fn syncTaglineFont(g: *Gui, core: *pardes.Pardes) void {
if (!fitTaglineFont(g, core.settings.font.tagline_percent)) return;
const geom = windowCells(g);
@@ -6436,10 +6421,6 @@ const Words = struct {
text: std.ArrayListUnmanaged(u32) = .empty,
slots: std.ArrayListUnmanaged(Slot) = .empty,
shaped: std.ArrayListUnmanaged(c.UIShapedCell) = .empty,
- /// The Ligatures setting. Off, no cell is shaped, so each draws its own
- /// glyph, as in a font without ligatures. It lives here because every
- /// cell and word above was resolved under it (`syncLigatures`).
- ligatures: bool = true,
/// The word the last cell was in, so the rest of it costs a compare. It
/// is positional, so every frame forgets it: the cells change under it.
memo: Memo = .{},
@@ -6503,7 +6484,7 @@ fn wordBreak(a: WordCell, b: WordCell, i: usize, cursor: ?usize) bool {
/// The atlas slot `line[at]` draws: blank for a plain space (or concealed
/// text), its own glyph when no ligature could replace that glyph (every
-/// cell, in a font without ligatures or with Ligatures off), else its slice
+/// cell, in a font without ligatures), else its slice
/// of the word around it, shaped once and cached by the word's text. The
/// cells of a word being walked cost a compare. Taglines are not shaped: they are drawn at two pitches
/// (tagline_width in a tag layer, a whole cell in the grid), and a strip would
@@ -6524,7 +6505,7 @@ fn cellSlot(g: *Gui, line: []const pardes.Cell, at: usize, cursor: ?usize, role:
if (!known.found_existing) {
const drawn = glyphForCodepoint(g, here.cp);
const font = if (drawn.face == 0) g.font else g.fallbacks[drawn.face - 1].?.face;
- known.value_ptr.* = if (role == .body and words.ligatures and c.ui_font_substitutes(font, drawn.glyph) != 0)
+ known.value_ptr.* = if (role == .body and c.ui_font_substitutes(font, drawn.glyph) != 0)
Words.shape_slot
else
cachedGlyph(g, .{ .face = drawn.face, .glyph = drawn.glyph, .role = role, .decoration = here.decoration }) orelse g.space_slot;
@@ -6724,40 +6705,6 @@ test "a ligature draws across its cells, one slice each, and comes apart under t
try std.testing.expectEqual(c.ui_font_glyph(font, '-'), (try glyphKeyAt(&g, cellSlot(&g, &line, 1, null, .tagline))).glyph);
}
-test "Ligatures off draws a ligature as its cells' own glyphs, and on shapes it again" {
- const bytes = try filesystem.readFile(std.testing.allocator, "assets/MapleMono-NF-Regular.ttf");
- defer std.testing.allocator.free(bytes);
- const font = c.ui_font_new(bytes.ptr, @intCast(bytes.len)) orelse return error.FontInit;
- defer c.ui_font_free(font);
- var g = try textTestGui(font, 27);
- defer font_allocator = std.heap.smp_allocator;
- defer std.testing.allocator.free(g.atlas_stage);
- defer g.glyphs.deinit();
- defer g.words.deinit(std.testing.allocator);
- const core = try pardes.Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24 });
- defer core.deinit();
-
- const text = "a->b";
- const line = textTestLine(text);
- var shaped: [text.len]Slot = undefined;
- for (&shaped, 0..) |*slot, i| slot.* = cellSlot(&g, &line, i, null, .body);
- try std.testing.expectEqual(shaped[1].u + g.cell_w, shaped[2].u);
-
- // Off, every cell is the slot the per-glyph path gives its codepoint.
- try std.testing.expect(core.executeBuiltinLine(core.active, "Ligatures off"));
- syncLigatures(&g, core);
- for (text, 0..) |byte, i| {
- const plain = cachedGlyph(&g, .{ .face = 0, .glyph = c.ui_font_glyph(font, byte), .role = .body }).?;
- try std.testing.expectEqual(plain, cellSlot(&g, &line, i, null, .body));
- }
- try std.testing.expect(!std.meta.eql(shaped[1], cellSlot(&g, &line, 1, null, .body)));
-
- // On again, the arrow is its strip once more.
- try std.testing.expect(core.executeBuiltinLine(core.active, "Ligatures on"));
- syncLigatures(&g, core);
- for (shaped, 0..) |slot, i| try std.testing.expectEqual(slot, cellSlot(&g, &line, i, null, .body));
-}
-
fn glyphKeyAt(g: *Gui, slot: Slot) !GlyphKey {
var it = g.glyphs.iterator();
while (it.next()) |entry| if (std.meta.eql(entry.value_ptr.*, slot)) return entry.key_ptr.*;