summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-25 14:26:37 -0300
committerGabriel Schneider <[email protected]>2026-11-25 14:44:17 -0300
commit70fcd1b561f6f18e95101633a0f1bcd3f30a0247 (patch)
tree75300629dd695ab3e117c9ae3282bfc5102f1268
parentda3bc8e006f86889f7abfd55168ce29f1a01e554 (diff)
downloadpardes-70fcd1b561f6f18e95101633a0f1bcd3f30a0247.tar.gz
pardes-70fcd1b561f6f18e95101633a0f1bcd3f30a0247.zip
gui: a pane's message mark (Messages.markOf: `✗ ! ? ⋯`) is drawn in the window: its button's glyph where the mode draws none, in its kind's ink pushed to 4.5:1 off the button's fill (UX D4; colors.pushAway made pub), the mode's two bars giving way to it: draw.zig renderPane writes the mark in the box's SECOND cell, which a cell shell shows beside the mode, but the window draws a pane's box as acme's button across both gutter cells (scrollColumn: 14 px of the 20 at 16 px, 27 of 32 at 26 px, the text 6 and 5 px past it) and blanks every grip cell but the first (emitSurfaceCell: `here.pane_grip` emits a blank, its glyph only the cell at the button's left edge, the cell shells' dirty `*` meant to go that way), so the mark was dropped: the window showed the box, then the path (S2 09a, 10a: `mark-16-zoom.png`, `mark-26-zoom.png`); there is no cell between the button and the text to put it on, so the button holds it (boxMark: the box's first cell blank, its second neither blank nor the dirty `*`); a mode glyph (`^` typing or insert, `$` tty, a window letter) keeps the button, the mark back at rest; the dirty fill and the focus ring stay as they are; TEST FIRST: gui.zig "a pane's mark is its button's glyph where the mode draws none, ..." (the box's two cells as renderPane writes them, an error mark on a focused button: on the base's emitSurfaceCell and gripDecor (`mark` false) fails at gui.zig:8410, no `✗` glyph rasterized, and the bars drawn; passes with them); a user saw no mark in any window since the messages line landed
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
-rw-r--r--core/colors.zig2
-rw-r--r--dev/gui/gui.zig79
2 files changed, 74 insertions, 7 deletions
diff --git a/core/colors.zig b/core/colors.zig
index 4f58aed5..61af2e4a 100644
--- a/core/colors.zig
+++ b/core/colors.zig
@@ -733,7 +733,7 @@ fn toward(ink: [3]u8, ground: [3]u8, floor: f32) [3]u8 {
/// `ink` pushed by fiftieths toward white or black, whichever reads better
/// on all its grounds, until it reads at `floor` on every one; where no ink
/// does (solarized's mid-grey tag), that end, the most any ink reaches.
-fn pushAway(ink: [3]u8, grounds: []const [3]u8, floor: f32) [3]u8 {
+pub fn pushAway(ink: [3]u8, grounds: []const [3]u8, floor: f32) [3]u8 {
const white: [3]u8 = @splat(255);
const black: [3]u8 = @splat(0);
if (leastContrast(ink, grounds) >= floor) return ink;
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);
+}