summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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();