summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-15 17:30:38 -0300
committerGabriel Schneider <[email protected]>2026-09-15 17:34:36 -0300
commite462d566f710e714e3b7176672e98fc82a6dea62 (patch)
tree64b3e9dc1ef36aeedbaae7f7e3a77b556676b952 /test
parentebe561b8083782a105a2ee29fb0a031d1c2427d3 (diff)
downloadpardes-e462d566f710e714e3b7176672e98fc82a6dea62.tar.gz
pardes-e462d566f710e714e3b7176672e98fc82a6dea62.zip
Separate pane and column grip hit areas from tagline text with a small gap
Diffstat (limited to 'test')
-rw-r--r--test/column_drag.zig20
-rw-r--r--test/mode.zig2
-rw-r--r--test/panes.zig22
-rw-r--r--test/web-snapshots/touch.mjs5
4 files changed, 31 insertions, 18 deletions
diff --git a/test/column_drag.zig b/test/column_drag.zig
index 1c9a344e..be4e33a3 100644
--- a/test/column_drag.zig
+++ b/test/column_drag.zig
@@ -85,7 +85,7 @@ test "column grip drag moves only its interval and keeps tag caret with the colu
try std.testing.expect(p.drag == .column_move);
mouse(p, .drag, target);
_ = try p.render(frame.allocator());
- try std.testing.expectEqual(p.col_w[3] - config.GUTTER - 1, (try tagLayer(p, 3)).viewport.w);
+ try std.testing.expectEqual(p.col_w[3] - pardes.TAG_TEXT_INSET - 1, (try tagLayer(p, 3)).viewport.w);
try std.testing.expectEqual(last_rect, p.rects[p.col_panes[3][0]]);
try std.testing.expectEqual(last_columns, (try tagLayer(p, 3)).cols);
try expectOrder(p, &before, &.{ 0, 1, 2, 3 });
@@ -103,7 +103,7 @@ test "column grip drag moves only its interval and keeps tag caret with the colu
try std.testing.expectEqual(caret, p.topbar_col);
_ = try p.render(frame.allocator());
try std.testing.expectEqual(before[1].serial, (try tagLayer(p, 3)).serial);
- try std.testing.expectEqual(p.col_w[3] - config.GUTTER, (try tagLayer(p, 3)).viewport.w);
+ try std.testing.expectEqual(p.col_w[3] - pardes.TAG_TEXT_INSET, (try tagLayer(p, 3)).viewport.w);
mouse(p, .press, p.col_x[3]);
const back = p.col_x[1] + config.GUTTER;
mouse(p, .drag, back);
@@ -136,13 +136,13 @@ test "column grip is separate from compact text and the resize seam" {
defer frame.deinit();
_ = try p.render(frame.allocator());
const layer = try tagLayer(p, 1);
- try std.testing.expectEqual(p.col_x[1] + config.GUTTER, layer.viewport.x);
+ try std.testing.expectEqual(p.col_x[1] + pardes.TAG_TEXT_INSET, layer.viewport.x);
const surface = &p.surface;
for (0..p.ncol) |column| {
const pane_id = p.col_panes[column][0];
const rect = p.rects[pane_id];
try std.testing.expectEqual(p.col_x[column], rect.x);
- try std.testing.expectEqual(rect.x + config.GUTTER, (try tagLayer(p, column)).viewport.x);
+ try std.testing.expectEqual(rect.x + pardes.TAG_TEXT_INSET, (try tagLayer(p, column)).viewport.x);
for (p.surface.tagLayers()) |pane_layer| {
if (pane_layer.cols > 0 and pane_layer.kind == .pane and pane_layer.id == pane_id)
try std.testing.expectEqual((try tagLayer(p, column)).viewport.x, pane_layer.viewport.x);
@@ -152,9 +152,15 @@ test "column grip is separate from compact text and the resize seam" {
const x = rect.x + @as(u16, @intCast(offset));
try std.testing.expectEqual(surface.at(x, pane_tag_y).style.font_role, surface.at(x, pardes.TOPBAR_H).style.font_role);
}
- try std.testing.expectEqual(pardes.FontRole.tagline, surface.at(rect.x + config.GUTTER, pardes.TOPBAR_H).style.font_role);
- try std.testing.expectEqual(pardes.FontRole.tagline, surface.at(rect.x + config.GUTTER, pane_tag_y).style.font_role);
+ try std.testing.expectEqual(pardes.FontRole.tagline, surface.at(rect.x + pardes.TAG_TEXT_INSET, pardes.TOPBAR_H).style.font_role);
+ try std.testing.expectEqual(pardes.FontRole.tagline, surface.at(rect.x + pardes.TAG_TEXT_INSET, pane_tag_y).style.font_role);
}
+ const gap_x = p.col_x[1] + config.GUTTER;
+ try std.testing.expectEqualStrings(" ", p.surface.at(gap_x, pardes.TOPBAR_H).grapheme());
+ mouse(p, .press, gap_x);
+ try std.testing.expect(p.drag != .column_move);
+ try std.testing.expect(!p.header_drag);
+ mouse(p, .release, gap_x);
p.update(.{ .mouse = headerMouse(layer, 0, .press) });
try std.testing.expect(p.drag != .column_move);
try std.testing.expect(p.header_drag);
@@ -199,7 +205,7 @@ test "column grips stay blank and muted across focus hover and drag" {
try std.testing.expectEqual(muted, cell.style.bg);
try std.testing.expectEqual(pardes.FontRole.tagline, cell.style.font_role);
}
- try std.testing.expectEqual(p.col_x[column] + config.GUTTER, (try tagLayer(p, column)).viewport.x);
+ try std.testing.expectEqual(p.col_x[column] + pardes.TAG_TEXT_INSET, (try tagLayer(p, column)).viewport.x);
}
if (dragging) mouse(p, .release, x);
}
diff --git a/test/mode.zig b/test/mode.zig
index 6d694b42..cc36ac04 100644
--- a/test/mode.zig
+++ b/test/mode.zig
@@ -16,7 +16,7 @@ fn clickModeTag(p: *Pardes) !void {
const rect = p.rects[0];
const row = if (p.settings.tag_bottom) rect.y + rect.h - pardes.BOX_H else rect.y;
for ([_]pardes.Mouse.Kind{ .press, .release }) |kind|
- p.update(.{ .mouse = .{ .button = .left, .kind = kind, .col = rect.x + pardes.config.GUTTER + @as(u16, @intCast(col)), .row = row } });
+ p.update(.{ .mouse = .{ .button = .left, .kind = kind, .col = rect.x + pardes.TAG_TEXT_INSET + @as(u16, @intCast(col)), .row = row } });
try std.testing.expect(pane.tag_edit);
}
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 } });
diff --git a/test/web-snapshots/touch.mjs b/test/web-snapshots/touch.mjs
index b78cbdc0..1351712e 100644
--- a/test/web-snapshots/touch.mjs
+++ b/test/web-snapshots/touch.mjs
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
function tags(frame) {
// This fixture has workspace and column bars in its first two rows.
- return frame.styleRows.flatMap((cells, y) => y > 1 && /^\s{2}\S/.test(frame.lines[y]) && cells.some((cell) => cell[2] & 128) ? [y] : []);
+ return frame.styleRows.flatMap((cells, y) => y > 1 && /^\s{3}\S/.test(frame.lines[y]) && cells.some((cell) => cell[2] & 128) ? [y] : []);
}
function pane(frame, name) {
@@ -95,7 +95,8 @@ export default async function ({ grid, touch, wait, stable, delay, evaluate, mou
tagValues[10]=0x556677;
renderer.render();
result.tag.bgInvalidates=renderer.tagRoot.firstChild!==tag;
- tagValues[1]=1;tagValues[4]=2;tagValues[5]=0;
+ wasm.pardes_tag_text_inset=()=>3;
+ tagValues[1]=1;tagValues[4]=3;tagValues[5]=0;
bytes[0]=32;data.setUint32(8,0x778899,true);
renderer.render();
const columnGrip=renderer.tagRoot.querySelector('[data-tag-grip]');