summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 18:57:42 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:15 -0300
commit8f0ac9d1f4aaffa7e264cab80b949040a88f0f08 (patch)
tree4700a193277637de92c2842dd16dd51434e8656e /src
parent5dbd21795f6c68bd3c10d409135970e3033364f3 (diff)
downloadpardes-8f0ac9d1f4aaffa7e264cab80b949040a88f0f08.tar.gz
pardes-8f0ac9d1f4aaffa7e264cab80b949040a88f0f08.zip
A multi-row tag shows its grip on the first row only, as acme's button
Rows under the first are the tag band's fill (the focused tint when the pane is focused), for pane tags and column tags alike, on every shell, since each draws the grid's cells. The grip region still spans every tag row, so a press there grabs the pane, as a press anywhere in acme's button column does (acme.c: t->scrollr is the tag's full height). GUI goldens 12-18 change only in the grip rows under the first.
Diffstat (limited to 'src')
-rw-r--r--src/draw.zig42
1 files changed, 40 insertions, 2 deletions
diff --git a/src/draw.zig b/src/draw.zig
index d1d4c11b..2e608132 100644
--- a/src/draw.zig
+++ b/src/draw.zig
@@ -675,7 +675,14 @@ fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r:
// Grips keep physical grid dimensions, independently of tag text.
.font_role = .tagline,
};
- s.fill(r.x, tag_y, config.GUTTER, pane.tag_rows, box_style);
+ // The grip is the first row's alone, as acme's button is; the rows
+ // under it are the tag band's, and still grab the pane (the region
+ // spans them all, as acme's button column does).
+ s.fill(r.x, tag_y, config.GUTTER, @min(1, pane.tag_rows), box_style);
+ s.fill(r.x, tag_y + 1, config.GUTTER, pane.tag_rows -| 1, .{
+ .bg = .{ .rgb = if (active and p.settings.focus_tint) chrome.tag_active_bg else chrome.tag_bg },
+ .font_role = .tagline,
+ });
s.set(r.x, tag_y, switch (pane.body.mode) {
.normal => config.tag_normal,
.insert => config.tag_insert,
@@ -739,7 +746,8 @@ pub fn paintHeaders(p: *Pardes, s: *Surface, arena: std.mem.Allocator) !void {
const grip_bg = if (grabbed) chrome.column_box else chrome.column_box_dim;
const lum = (@as(u16, grip_bg[0]) * 3 + @as(u16, grip_bg[1]) * 6 + @as(u16, grip_bg[2])) / 10;
const ink: [3]u8 = if (lum > 140) .{ 0, 0, 0 } else .{ 255, 255, 255 };
- s.fill(p.col_x[c], region.rect.y, grip, column_rows, .{ .bg = .{ .rgb = grip_bg }, .fg = .{ .rgb = ink }, .font_role = .tagline });
+ s.fill(p.col_x[c], region.rect.y, grip, @min(1, column_rows), .{ .bg = .{ .rgb = grip_bg }, .fg = .{ .rgb = ink }, .font_role = .tagline });
+ s.fill(p.col_x[c], region.rect.y + 1, grip, column_rows -| 1, .{ .bg = .{ .rgb = bg }, .font_role = .tagline });
s.fill(p.col_x[c] + grip, region.rect.y, inset - grip, column_rows, .{ .bg = .{ .rgb = bg }, .font_role = .tagline });
}
const top = if (p.header_focus and p.header_column == c) p.header_top else 0;
@@ -1159,6 +1167,36 @@ pub fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pa
}
}
+test "a tag of three rows has its grip on the first, and band under it that still grabs the pane" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 });
+ defer p.deinit();
+ const pane = try p.setTestFile("text\n");
+ pane.tag.own = try std.testing.allocator.dupe(u8, "Second\nthird\nfourth");
+ var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
+ defer arena.deinit();
+ for ([_]bool{ false, true }) |bottom| {
+ p.settings.tag_bottom = bottom;
+ p.sync();
+ _ = arena.reset(.retain_capacity);
+ const s = try p.render(arena.allocator());
+ const r = p.rects[0];
+ const top = p.tagTop(pane, r);
+ try std.testing.expect(pane.tag_rows >= 3);
+ const chrome = p.chromeTheme();
+ const band = if (p.settings.focus_tint) chrome.tag_active_bg else chrome.tag_bg;
+ for (0..config.GUTTER) |dx| {
+ const x = r.x + @as(u16, @intCast(dx));
+ try std.testing.expectEqual(Color{ .rgb = chrome.box }, s.at(x, top).style.bg);
+ for (1..pane.tag_rows) |line| {
+ const cell = s.at(x, top + @as(u16, @intCast(line)));
+ try std.testing.expectEqual(Color{ .rgb = band }, cell.style.bg);
+ try std.testing.expectEqualStrings(" ", cell.grapheme());
+ }
+ }
+ try std.testing.expectEqual(pane.tag_rows, s.region(.grip, 0).?.rect.h);
+ }
+}
+
test "place puts every part where the painters and layers put it, in every layout" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 });
defer p.deinit();