mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
terminal2: more selectLine tests
This commit is contained in:
@ -4606,6 +4606,7 @@ test "Screen: selectLine semantic prompt boundary" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// X
|
||||||
test "Screen: selectLine across soft-wrap ignores blank lines" {
|
test "Screen: selectLine across soft-wrap ignores blank lines" {
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
const alloc = testing.allocator;
|
const alloc = testing.allocator;
|
||||||
@ -4642,6 +4643,7 @@ test "Screen: selectLine across soft-wrap ignores blank lines" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// X
|
||||||
test "Screen: selectLine with scrollback" {
|
test "Screen: selectLine with scrollback" {
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
const alloc = testing.allocator;
|
const alloc = testing.allocator;
|
||||||
|
@ -3729,6 +3729,66 @@ test "Screen: selectLine across soft-wrap" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "Screen: selectLine across soft-wrap ignores blank lines" {
|
||||||
|
const testing = std.testing;
|
||||||
|
const alloc = testing.allocator;
|
||||||
|
|
||||||
|
var s = try init(alloc, 5, 10, 0);
|
||||||
|
defer s.deinit();
|
||||||
|
try s.testWriteString(" 12 34012 \n 123");
|
||||||
|
|
||||||
|
// Going forward
|
||||||
|
{
|
||||||
|
var sel = s.selectLine(s.pages.pin(.{ .active = .{
|
||||||
|
.x = 1,
|
||||||
|
.y = 0,
|
||||||
|
} }).?).?;
|
||||||
|
defer sel.deinit(&s);
|
||||||
|
try testing.expectEqual(point.Point{ .screen = .{
|
||||||
|
.x = 1,
|
||||||
|
.y = 0,
|
||||||
|
} }, s.pages.pointFromPin(.screen, sel.start().*).?);
|
||||||
|
try testing.expectEqual(point.Point{ .screen = .{
|
||||||
|
.x = 3,
|
||||||
|
.y = 1,
|
||||||
|
} }, s.pages.pointFromPin(.screen, sel.end().*).?);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Going backward
|
||||||
|
{
|
||||||
|
var sel = s.selectLine(s.pages.pin(.{ .active = .{
|
||||||
|
.x = 1,
|
||||||
|
.y = 1,
|
||||||
|
} }).?).?;
|
||||||
|
defer sel.deinit(&s);
|
||||||
|
try testing.expectEqual(point.Point{ .screen = .{
|
||||||
|
.x = 1,
|
||||||
|
.y = 0,
|
||||||
|
} }, s.pages.pointFromPin(.screen, sel.start().*).?);
|
||||||
|
try testing.expectEqual(point.Point{ .screen = .{
|
||||||
|
.x = 3,
|
||||||
|
.y = 1,
|
||||||
|
} }, s.pages.pointFromPin(.screen, sel.end().*).?);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Going forward and backward
|
||||||
|
{
|
||||||
|
var sel = s.selectLine(s.pages.pin(.{ .active = .{
|
||||||
|
.x = 3,
|
||||||
|
.y = 0,
|
||||||
|
} }).?).?;
|
||||||
|
defer sel.deinit(&s);
|
||||||
|
try testing.expectEqual(point.Point{ .screen = .{
|
||||||
|
.x = 1,
|
||||||
|
.y = 0,
|
||||||
|
} }, s.pages.pointFromPin(.screen, sel.start().*).?);
|
||||||
|
try testing.expectEqual(point.Point{ .screen = .{
|
||||||
|
.x = 3,
|
||||||
|
.y = 1,
|
||||||
|
} }, s.pages.pointFromPin(.screen, sel.end().*).?);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
test "Screen: selectAll" {
|
test "Screen: selectAll" {
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
const alloc = testing.allocator;
|
const alloc = testing.allocator;
|
||||||
@ -3764,3 +3824,46 @@ test "Screen: selectAll" {
|
|||||||
} }, s.pages.pointFromPin(.screen, sel.end().*).?);
|
} }, s.pages.pointFromPin(.screen, sel.end().*).?);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "Screen: selectLine with scrollback" {
|
||||||
|
const testing = std.testing;
|
||||||
|
const alloc = testing.allocator;
|
||||||
|
|
||||||
|
var s = try init(alloc, 2, 3, 5);
|
||||||
|
defer s.deinit();
|
||||||
|
try s.testWriteString("1A\n2B\n3C\n4D\n5E");
|
||||||
|
|
||||||
|
// Selecting first line
|
||||||
|
{
|
||||||
|
var sel = s.selectLine(s.pages.pin(.{ .active = .{
|
||||||
|
.x = 0,
|
||||||
|
.y = 0,
|
||||||
|
} }).?).?;
|
||||||
|
defer sel.deinit(&s);
|
||||||
|
try testing.expectEqual(point.Point{ .active = .{
|
||||||
|
.x = 0,
|
||||||
|
.y = 0,
|
||||||
|
} }, s.pages.pointFromPin(.active, sel.start().*).?);
|
||||||
|
try testing.expectEqual(point.Point{ .active = .{
|
||||||
|
.x = 1,
|
||||||
|
.y = 0,
|
||||||
|
} }, s.pages.pointFromPin(.active, sel.end().*).?);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Selecting last line
|
||||||
|
{
|
||||||
|
var sel = s.selectLine(s.pages.pin(.{ .active = .{
|
||||||
|
.x = 0,
|
||||||
|
.y = 2,
|
||||||
|
} }).?).?;
|
||||||
|
defer sel.deinit(&s);
|
||||||
|
try testing.expectEqual(point.Point{ .active = .{
|
||||||
|
.x = 0,
|
||||||
|
.y = 2,
|
||||||
|
} }, s.pages.pointFromPin(.active, sel.start().*).?);
|
||||||
|
try testing.expectEqual(point.Point{ .active = .{
|
||||||
|
.x = 1,
|
||||||
|
.y = 2,
|
||||||
|
} }, s.pages.pointFromPin(.active, sel.end().*).?);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user