diff options
Diffstat (limited to 'src/draw.zig')
| -rw-r--r-- | src/draw.zig | 50 |
1 files changed, 0 insertions, 50 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 }); |
