mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
terminal2: sel adjust home/end
This commit is contained in:
@ -197,16 +197,28 @@ pub fn adjust(
|
|||||||
// } else {
|
// } else {
|
||||||
// result.end.y += screen.rows;
|
// result.end.y += screen.rows;
|
||||||
// },
|
// },
|
||||||
//
|
|
||||||
// .home => {
|
.home => self.end.* = s.pages.pin(.{ .screen = .{
|
||||||
// result.end.y = 0;
|
.x = 0,
|
||||||
// result.end.x = 0;
|
.y = 0,
|
||||||
// },
|
} }).?,
|
||||||
//
|
|
||||||
// .end => {
|
.end => {
|
||||||
// result.end.y = screen_end;
|
var it = s.pages.rowIterator(
|
||||||
// result.end.x = screen.cols - 1;
|
.left_up,
|
||||||
//},
|
.{ .screen = .{} },
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
while (it.next()) |next| {
|
||||||
|
const rac = next.rowAndCell();
|
||||||
|
const cells = next.page.data.getCells(rac.row);
|
||||||
|
if (page.Cell.hasTextAny(cells)) {
|
||||||
|
self.end.* = next;
|
||||||
|
self.end.x = cells.len - 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
else => @panic("TODO"),
|
else => @panic("TODO"),
|
||||||
}
|
}
|
||||||
@ -511,6 +523,64 @@ test "Selection: adjust down with not full screen" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "Selection: adjust home" {
|
||||||
|
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 = 1, .y = 2 } }).?,
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
defer sel.deinit(&s);
|
||||||
|
sel.adjust(&s, .home);
|
||||||
|
|
||||||
|
// 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 = 0,
|
||||||
|
.y = 0,
|
||||||
|
} }, s.pages.pointFromPin(.screen, sel.end.*).?);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test "Selection: adjust end 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 = 0 } }).?,
|
||||||
|
s.pages.pin(.{ .screen = .{ .x = 1, .y = 1 } }).?,
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
defer sel.deinit(&s);
|
||||||
|
sel.adjust(&s, .end);
|
||||||
|
|
||||||
|
// Start line
|
||||||
|
try testing.expectEqual(point.Point{ .screen = .{
|
||||||
|
.x = 4,
|
||||||
|
.y = 0,
|
||||||
|
} }, 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;
|
||||||
|
Reference in New Issue
Block a user