terminal2: adjust down edges

This commit is contained in:
Mitchell Hashimoto
2024-03-05 22:32:13 -08:00
parent a303b7628e
commit 5c04ebe3bd
2 changed files with 31 additions and 0 deletions

View File

@ -485,6 +485,7 @@ test "Selection: adjust up" {
} }
} }
// X
test "Selection: adjust down" { test "Selection: adjust down" {
const testing = std.testing; const testing = std.testing;
var screen = try Screen.init(testing.allocator, 5, 10, 0); var screen = try Screen.init(testing.allocator, 5, 10, 0);
@ -520,6 +521,7 @@ test "Selection: adjust down" {
} }
} }
// X
test "Selection: adjust down with not full screen" { test "Selection: adjust down with not full screen" {
const testing = std.testing; const testing = std.testing;
var screen = try Screen.init(testing.allocator, 5, 10, 0); var screen = try Screen.init(testing.allocator, 5, 10, 0);

View File

@ -482,6 +482,35 @@ test "Selection: adjust down" {
} }
} }
test "Selection: adjust down with not full screen" {
const testing = std.testing;
var s = try Screen.init(testing.allocator, 5, 10, 0);
defer s.deinit();
try s.testWriteString("A\nB\nC");
// On the last line
{
var sel = try Selection.init(
&s,
s.pages.pin(.{ .screen = .{ .x = 4, .y = 1 } }).?,
s.pages.pin(.{ .screen = .{ .x = 3, .y = 2 } }).?,
false,
);
defer sel.deinit(&s);
sel.adjust(&s, .down);
// Start line
try testing.expectEqual(point.Point{ .screen = .{
.x = 4,
.y = 1,
} }, s.pages.pointFromPin(.screen, sel.start.*).?);
try testing.expectEqual(point.Point{ .screen = .{
.x = 4,
.y = 2,
} }, s.pages.pointFromPin(.screen, sel.end.*).?);
}
}
test "Selection: order, standard" { test "Selection: order, standard" {
const testing = std.testing; const testing = std.testing;
const alloc = testing.allocator; const alloc = testing.allocator;