diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-15 17:30:38 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-09-15 17:34:36 -0300 |
| commit | e462d566f710e714e3b7176672e98fc82a6dea62 (patch) | |
| tree | 64b3e9dc1ef36aeedbaae7f7e3a77b556676b952 /test/panes.zig | |
| parent | ebe561b8083782a105a2ee29fb0a031d1c2427d3 (diff) | |
| download | pardes-e462d566f710e714e3b7176672e98fc82a6dea62.tar.gz pardes-e462d566f710e714e3b7176672e98fc82a6dea62.zip | |
Separate pane and column grip hit areas from tagline text with a small gap
Diffstat (limited to 'test/panes.zig')
| -rw-r--r-- | test/panes.zig | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/test/panes.zig b/test/panes.zig index f3e7034f..da06f692 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -111,9 +111,15 @@ const TagLayerTests = struct { _ = try p.render(frame.allocator()); const layer = try findLayer(p, .pane, second); const edge = @as(f32, @floatFromInt(layer.viewport.x)) * 10; - p.update(.{ .mouse = mouse(layer, edge - 0.1, .press) }); + const grip_edge = edge - @as(f32, @floatFromInt(pardes.TAG_GAP)) * 10; + p.update(.{ .mouse = mouse(layer, grip_edge - 0.1, .press) }); try std.testing.expect(p.drag == .move); try std.testing.expectEqual(second, p.drag.move.id); + p.update(.{ .mouse = mouse(layer, grip_edge - 0.1, .release) }); + try std.testing.expectEqualStrings(" ", p.surface.at(layer.viewport.x - 1, layer.viewport.y).grapheme()); + p.update(.{ .mouse = mouse(layer, edge - 0.1, .press) }); + try std.testing.expect(p.drag != .move); + try std.testing.expect(!p.panes[second].?.tag_edit); p.update(.{ .mouse = mouse(layer, edge - 0.1, .release) }); p.update(.{ .mouse = mouse(layer, edge + 0.1, .press) }); p.update(.{ .mouse = mouse(layer, edge + 0.1, .release) }); @@ -201,7 +207,7 @@ const TagNavigationTests = struct { _ = try p.render(frame.allocator()); const rect = p.rects[0]; const y = if (p.settings.tag_bottom) rect.y + rect.h - pardes.BOX_H else rect.y; - ClickCursorTests.click(p, .left, rect.x + config.GUTTER + 6, y); + ClickCursorTests.click(p, .left, rect.x + pardes.TAG_TEXT_INSET + 6, y); try std.testing.expectEqual(@as(usize, 0), p.active); try std.testing.expectEqual(@as(u16, 6), first.tag_col); key(p, Key.escape); @@ -948,14 +954,14 @@ const TagNameTintTests = struct { const base = std.mem.lastIndexOfScalar(u8, name, '/') orelse return error.MissingDirectory; const rect = p.rects[id]; const y = if (p.settings.tag_bottom) rect.y + rect.h - pardes.BOX_H else rect.y; - const left = rect.x + config.GUTTER; + const left = rect.x + pardes.TAG_TEXT_INSET; var visible_name: usize = 0; var at: usize = 0; while (at < text.len) : (at = modal.nextGrapheme(text, at)) { const start: i32 = @as(i32, @intCast(panes.File.rawDisplayCol(text, at))) - pane.tag_scroll; const end = start + @as(i32, @intCast(panes.File.displayWidth(text[at..modal.nextGrapheme(text, at)]))); var col = @max(0, start); - while (col < end and col < rect.w - config.GUTTER) : (col += 1) { + while (col < end and col < rect.w - pardes.TAG_TEXT_INSET) : (col += 1) { const in_name = at > base and at < name.len; const fg = if (in_name) name_fg else tag_fg; try std.testing.expectEqual(pardes.Color{ .rgb = fg }, surface.at(left + @as(u16, @intCast(col)), y).style.fg); @@ -1009,7 +1015,7 @@ const TagNameTintTests = struct { var arena = std.heap.ArenaAllocator.init(p.gpa); defer arena.deinit(); const surface = try p.render(arena.allocator()); - const x = p.rects[0].x + config.GUTTER + @as(u16, @intCast(panes.File.rawDisplayCol(name, pane.tag_col) - pane.tag_scroll)); + const x = p.rects[0].x + pardes.TAG_TEXT_INSET + @as(u16, @intCast(panes.File.rawDisplayCol(name, pane.tag_col) - pane.tag_scroll)); const y = if (p.settings.tag_bottom) p.rects[0].y + p.rects[0].h - pardes.BOX_H else p.rects[0].y; try std.testing.expectEqual(pardes.Color{ .rgb = p.theme().sel_fg }, surface.at(x, y).style.fg); try std.testing.expectEqual(pardes.Color{ .rgb = p.theme().sel_fg }, surface.at(x + 1, y).style.fg); @@ -1032,7 +1038,7 @@ const TagNameTintTests = struct { for ([_]bool{ false, true }) |active| { p.settings.focus_tint = active; const surface = try p.render(arena.allocator()); - const x = p.rects[0].x + config.GUTTER; + const x = p.rects[0].x + pardes.TAG_TEXT_INSET; const y = if (p.settings.tag_bottom) p.rects[0].y + p.rects[0].h - pardes.BOX_H else p.rects[0].y; const fg = if (active) active_fg else tag_fg; try std.testing.expectEqual(pardes.Color{ .rgb = fg }, surface.at(x + 1, y).style.fg); @@ -1139,7 +1145,7 @@ test "middle clicking Save commits the staged filename before issuing a save" { _ = try p.render(arena.allocator()); const text = try p.tagText(arena.allocator(), pane); const save_at = std.mem.indexOf(u8, text, "Save").?; - const x: u16 = @intCast(p.rects[0].x + config.GUTTER + save_at - pane.tag_scroll); + const x: u16 = @intCast(p.rects[0].x + pardes.TAG_TEXT_INSET + save_at - pane.tag_scroll); const y = p.rects[0].y; while (p.nextEffect()) |_| {} p.update(.{ .mouse = .{ .col = x, .row = y, .button = config.exec_button, .kind = .press } }); @@ -1211,7 +1217,7 @@ test "long pane tags reveal commands and map visible clicks to whole tag address const text = try p.tagText(p.gpa, pane); defer p.gpa.free(text); const offset = std.mem.indexOf(u8, text, "SyntaxBold").?; - const x: u16 = @intCast(p.rects[0].x + config.GUTTER + panes.File.rawDisplayCol(text, offset) - pane.tag_scroll); + const x: u16 = @intCast(p.rects[0].x + pardes.TAG_TEXT_INSET + panes.File.rawDisplayCol(text, offset) - pane.tag_scroll); const y = p.rects[0].y; const before = p.settings.syntax_bold; p.update(.{ .mouse = .{ .col = x, .row = y, .button = config.exec_button, .kind = .press } }); |
