diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 14:52:20 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 14:56:07 -0300 |
| commit | c6dc2a6148855e0f02e86103dd80f47525a985e4 (patch) | |
| tree | b8f5b4fc9da0aac4786fe3e7c04f3b979b304911 /dev/gui/gui.zig | |
| parent | f7f6b564c0f43aaa31233dcdf1ae7daf24799fe1 (diff) | |
| parent | 70fcd1b561f6f18e95101633a0f1bcd3f30a0247 (diff) | |
| download | pardes-c6dc2a6148855e0f02e86103dd80f47525a985e4.tar.gz pardes-c6dc2a6148855e0f02e86103dd80f47525a985e4.zip | |
walk UI M10: F1's three fixes (pmqrrmvm a picker previews its first row from the frame its rows come; zzxpztus C-r's history has the band's cursor; qxkzuoyq f7f6b564c0f4 a rolled level that wraps keeps its hints on its last row) and F2's four (nxorurnk a cause longer than its word keeps the path's end; qkynmxtw a message too wide for the notice row gives way by its items, ten goldens; qypmxlxx no `exit N` in a failed run's detail; mkwywzon 70fcd1b561f6 a pane's mark is its window button's glyph) merged onto M9 (svssokqn), resolved by meaning: no text conflict and no file in common (F1: core/Pick.zig, Prompt.zig, TagState.zig; F2: core/Messages.zig, colors.zig, panes.zig, dev/gui/gui.zig and the ten process-test goldens), and none reads what the other changed: F1's head hints and history rows are the tag's and the band's, F2's cuts the notice row's and the window's button, so the two stacks' tests hold each other's trees as they were written; core-test 1102/1273 (171 skipped: M9's 1097 + F1's three tests + F2's two), load 3.4 to 7
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'dev/gui/gui.zig')
| -rw-r--r-- | dev/gui/gui.zig | 79 |
1 files changed, 73 insertions, 6 deletions
diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig index 7d8259e0..66074f42 100644 --- a/dev/gui/gui.zig +++ b/dev/gui/gui.zig @@ -4319,6 +4319,18 @@ fn scrollColumn(g: *const Gui, chrome: *const pardes.Chrome, col: u16, layout: C return .{ x0, x0 + w }; } +/// Whether a pane's box, at `edge` of its row, shows a mark and no mode: +/// draw.zig renderPane writes the mode in the box's first cell (blank in +/// normal mode) and a live message's mark (Messages.markOf: `✗ ! ? ⋯`) in +/// its second, which the cell shells show beside it; a button holds one +/// glyph, the mode's bars are decor, so the mark takes their place. +fn boxMark(line: []const pardes.Cell, edge: usize) bool { + if (edge + 1 >= line.len or line[edge].printableAscii() != ' ') return false; + const second = &line[edge + 1]; + // A dirty box's `*` is the cell shells' form of the button's fill. + return !second.default and second.printableAscii() != ' ' and second.printableAscii() != '*'; +} + /// acme's button for the grip whose first cell is (col, row), in window /// pixels: the scroll column wide, its tag row tall, from the rule above to /// the rule below, so button and scrollbar read as one strip. @@ -4420,8 +4432,11 @@ fn emitSurfaceCell( else emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, .tagline, line, at, cursor, is_cursor, page); // A grip's glyph is the cell at its left edge, and a blank one is - // no glyph: its marks are decor. - const glyph = &line[at - @min(here.grip_offset, at)]; + // no glyph: its marks are decor. A pane's button holds one glyph: + // its mode's, else its mark (boxMark). + const edge = at - @min(here.grip_offset, at); + const mark = here.pane_grip and here.grip_top and boxMark(line, edge); + const glyph = &line[if (mark) edge + 1 else edge]; const grip = here.grip and here.grip_top and !glyph.default and glyph.printableAscii() != ' ' and !glyph.style.invisible; const offset: u16 = if (grip) @min(here.grip_offset, at) else 0; // An anchor starts at its column's rule: its left edge is inset by @@ -4442,7 +4457,14 @@ fn emitSurfaceCell( const center = (b[0] + b[2]) / 2 - @as(f32, @floatFromInt(col - offset)) * body_layout.w; const shift: f32 = if (cached != null) @as(f32, @floatFromInt(@as(u32, offset) * g.cell_w)) + @as(f32, @floatFromInt(config.GUTTER * g.cell_w)) / 2 - center else 0; const resolved = resolveCell(g, glyph[0..1], 0, null, .tagline, false, page); - const ink = if (here.pane_grip) inkOn(gripFill(chrome, here.focus, here.dirty, here.reading)) else resolved.fg; + const fill = gripFill(chrome, here.focus, here.dirty, here.reading); + // A mark in its kind's ink (Messages.ink), held to its floor on + // the button's fill, which is not a tag's ground when focused + // or dirty (UX D4). + const ink = if (mark) switch (glyph.style.fg) { + .rgb => |rgb| pardes.colors.pushAway(rgb, &.{fill}, pardes.colors.Roles.ink_floor), + else => inkOn(fill), + } else if (here.pane_grip) inkOn(fill) else resolved.fg; instances[next.*].fr = @as(f32, @floatFromInt(ink[0])) / 255; instances[next.*].fg = @as(f32, @floatFromInt(ink[1])) / 255; instances[next.*].fb = @as(f32, @floatFromInt(ink[2])) / 255; @@ -5392,13 +5414,13 @@ fn gripDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ce } } // The marks are the first row's alone, where its cell is blank (no - // mode glyph), centered in the button, in its ink from the region's - // state. + // mode glyph) and no message's mark takes the button (boxMark), + // centered in the button, in its ink from the region's state. const x = grip.rect.x; const y = grip.rect.y; if (x >= cols) continue; const cell = &cells[@as(usize, y) * cols + x]; - if (cell.default or cell.printableAscii() != ' ') continue; + if (cell.default or cell.printableAscii() != ' ' or boxMark(cells[@as(usize, y) * cols ..][0..cols], x)) continue; const rgb = inkOn(gripFill(chrome, grip.active, grip.dirty, grip.reading)); const center_x = @floor((button[0] + button[2]) / 2); const center_y = @as(f32, @floatFromInt(y)) * layout.h + @as(f32, @floatFromInt(taglineBandOffset(y, win_h, g.cell_h, g.tagline_height))) + @as(f32, @floatFromInt(g.tagline_height)) / 2; @@ -8355,3 +8377,48 @@ test "a band over a terminal's body has the tag rule under its last row, as a ba } try std.testing.expect(found); } + +test "a pane's mark is its button's glyph where the mode draws none, in its kind's ink held to 4.5:1 on the button's fill, and the mode's bars give way to it (S2 09a: the window drew the box, then the path)" { + const gpa = std.testing.allocator; + var cells: [12]pardes.Cell = @splat(.{ .default = false, .style = .{ .font_role = .tagline } }); + // draw.zig renderPane's box: the mode blank (normal), the mark beside it. + const err: [3]u8 = .{ 0xff, 0x7e, 0xa2 }; + cells[1] = .{ .default = false, .style = .{ .fg = .{ .rgb = err }, .bold = true, .font_role = .tagline } }; + @memcpy(cells[1].text[0..3], "\u{2717}"); + cells[1].len = 3; + const grip = [_]pardes.Region{.{ .kind = .grip, .serial = 1, .active = true, .rect = .{ .x = 0, .y = 0, .w = 2, .h = 1 } }}; + var cover: [12]Cover = undefined; + coverFrame(&cover, 6, 2, &.{}, &.{}, &grip); + const chrome: pardes.Chrome = .{}; + var g = testGui(10, 20, 8, 16); + g.atlas = try Atlas.init(gpa, font_ttf); + defer g.atlas.deinit(gpa); + g.px = 20; + g.tagline_px = 16; + defer g.words.deinit(gpa); + defer g.decor.deinit(gpa); + var instances: [4]CellInstance = undefined; + var next: u32 = 0; + for (0..2) |col| emitSurfaceCell(&g, &chrome, &instances, &next, @intCast(col), 0, fixedCellLayout(&g), 100, 100, cells[0..6], cover[0..6], col, null, false, bg_default); + try std.testing.expectEqual(@as(u32, 4), next); + // Each of the box's two cells draws its slice of the mark's glyph, in + // the err ink pushed off the focused button's fill. + const fill = gripFill(&chrome, true, false, false); + const want = pardes.colors.pushAway(err, &.{fill}, pardes.colors.Roles.ink_floor); + try std.testing.expect(pardes.colors.contrast(want, fill) >= pardes.colors.Roles.ink_floor); + const drawn = g.atlas.glyphForCodepoint(0x2717); + try std.testing.expect(g.atlas.glyphs.get(.{ .face = drawn.face, .glyph = drawn.glyph, .role = .tagline, .decoration = .{ .bold = true }, .centered = true }) != null); + for ([_]usize{ 1, 3 }) |i| { + try std.testing.expectEqual(@as(f32, @floatFromInt(want[0])) / 255, instances[i].fr); + try std.testing.expectEqual(@as(f32, @floatFromInt(want[1])) / 255, instances[i].fg); + try std.testing.expectEqual(@as(f32, @floatFromInt(want[2])) / 255, instances[i].fb); + } + // The mode's two bars are not drawn under it; without a mark they are. + const layout = fixedCellLayout(&g); + try gripDecor(&g, gpa, &grip, &cells, &chrome, layout, 6, 2, 100, 100); + const marked = g.decor.items.len; + g.decor.clearRetainingCapacity(); + cells[1] = cells[2]; + try gripDecor(&g, gpa, &grip, &cells, &chrome, layout, 6, 2, 100, 100); + try std.testing.expectEqual(marked + 2, g.decor.items.len); +} |
