summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/draw.zig50
-rw-r--r--src/gui/gui.zig6
2 files changed, 4 insertions, 52 deletions
diff --git a/src/draw.zig b/src/draw.zig
index 83f93be0..96a12145 100644
--- a/src/draw.zig
+++ b/src/draw.zig
@@ -2041,56 +2041,6 @@ test "the focused cursor glides a jump, eases a step, the thin caret too, and is
try std.testing.expectApproxEqAbs(@as(f32, 1.0 / 8.0), s.chrome.cursor_quad[2] - s.chrome.cursor_quad[0], 1e-4);
}
-test "a tag caret past its row's end glides to the tag's right edge, where the layer's is" {
- if (!builtins.frontend.lift) return error.SkipZigTest;
- const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 16 });
- defer p.deinit();
- p.update(.{ .resize = .{ .cols = 60, .rows = 16, .row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 6, .tagline_h = 12 } } });
- const pane = try p.setTestFile("text\n");
- var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
- defer arena.deinit();
- // The tag's text grown a letter at a time, the caret after its last one
- // in insert mode, until a row is full and the caret is past its end.
- var found = false;
- var n: usize = 1;
- while (n < 200 and !found) : (n += 1) {
- _ = arena.reset(.retain_capacity);
- if (pane.tag.own) |own| p.gpa.free(own);
- const own = try p.gpa.alloc(u8, n);
- @memset(own, 'x');
- own[0] = ' ';
- pane.tag.own = own;
- tagline.enterTag(p, pane);
- const whole = try tagline.tagText(p, arena.allocator(), pane);
- pane.tag.mode = .insert;
- pane.tag.cur_row = 0;
- pane.tag.cur_col = @intCast(modal.lineSlice(whole, 0).len);
- p.sync();
- const s = try p.render(arena.allocator());
- const layer = for (s.tagLayers()) |*layer| {
- if (layer.rows != 0 and layer.kind == .pane and layer.cursor != null) break layer;
- } else continue;
- const caret = layer.cursor.?;
- const right: f32 = @floatFromInt(layer.viewport.x + layer.viewport.w);
- const box = focusedCursorBox(p, s).?;
- // Never past the tag's right edge, and the pane's.
- try std.testing.expect(box.x + box.w <= right + 1e-4);
- try std.testing.expect(box.x + box.w <= @as(f32, @floatFromInt(p.rects[p.active].x + p.rects[p.active].w)));
- const at = @as(f32, @floatFromInt(layer.viewport.x)) + @as(f32, @floatFromInt(caret.x)) * 6 / 10;
- if (at + box.w <= right) {
- // Inside its row: exactly where the layer's caret is.
- try std.testing.expectApproxEqAbs(at, box.x, 1e-4);
- } else {
- // Past it: on the tag's right edge, as the pixel shell's caret
- // is (gui.zig cursorBoxes).
- try std.testing.expectApproxEqAbs(right, box.x + box.w, 1e-4);
- try std.testing.expectApproxEqAbs(@as(f32, 6.0 / 10.0 / 8.0), box.w, 1e-4);
- found = true;
- }
- }
- try std.testing.expect(found);
-}
-
test "a terminal's cursor lands with scrolling output, never gliding against it" {
if (!builtins.frontend.lift or !pardes.terminal_panes) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 12 });
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index a5b7f34a..a850cdca 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -3221,8 +3221,10 @@ test "tagline pointer mapping retains physical grips and carries logical text co
try std.testing.expectEqual(body_y, body.row);
try std.testing.expect(body.tag_hit == null);
- const topbar = gridCellAtDimensions(core, 3.5 * tag_w, 0.5 * body_h, body_w, body_h, tag_w);
- try std.testing.expectEqual(@as(u16, 2), topbar.col);
+ // The workspace tag's text starts TAG_TEXT_INSET cells in, as a pane's.
+ const x_top = @as(f32, @floatFromInt(pardes.TAG_TEXT_INSET)) * body_w + 3.5 * tag_w;
+ const topbar = gridCellAtDimensions(core, x_top, 0.5 * body_h, body_w, body_h, tag_w);
+ try std.testing.expectEqual(pixelCell(x_top, 10), topbar.col);
try std.testing.expectEqual(@as(u16, 3), topbar.tag_hit.?.col);
try std.testing.expectEqual(pardes.TagKind.workspace, topbar.tag_hit.?.kind);
}