mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
terminal2: sel adjust left
This commit is contained in:
@ -330,6 +330,7 @@ pub fn adjust(self: Selection, screen: *Screen, adjustment: Adjustment) Selectio
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// X
|
||||||
test "Selection: adjust right" {
|
test "Selection: adjust right" {
|
||||||
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);
|
||||||
@ -376,6 +377,7 @@ test "Selection: adjust right" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// X
|
||||||
test "Selection: adjust left" {
|
test "Selection: adjust left" {
|
||||||
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);
|
||||||
|
@ -139,25 +139,22 @@ pub fn adjust(
|
|||||||
// } else {
|
// } else {
|
||||||
// result.end.y += 1;
|
// result.end.y += 1;
|
||||||
// },
|
// },
|
||||||
//
|
|
||||||
// .left => {
|
.left => {
|
||||||
// // Step left, wrapping to the next row up at the start of each new line,
|
var it = s.pages.cellIterator(
|
||||||
// // until we find a non-empty cell.
|
.left_up,
|
||||||
// //
|
.{ .screen = .{} },
|
||||||
// // This iterator emits the start point first, throw it out.
|
s.pages.pointFromPin(.screen, self.end.*).?,
|
||||||
// var iterator = result.end.iterator(screen, .left_up);
|
);
|
||||||
// _ = iterator.next();
|
_ = it.next();
|
||||||
// while (iterator.next()) |next| {
|
while (it.next()) |next| {
|
||||||
// if (screen.getCell(
|
const rac = next.rowAndCell();
|
||||||
// .screen,
|
if (rac.cell.hasText()) {
|
||||||
// next.y,
|
self.end.* = next;
|
||||||
// next.x,
|
break;
|
||||||
// ).char != 0) {
|
}
|
||||||
// result.end = next;
|
}
|
||||||
// break;
|
},
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
|
|
||||||
.right => {
|
.right => {
|
||||||
// Step right, wrapping to the next row down at the start of each new line,
|
// Step right, wrapping to the next row down at the start of each new line,
|
||||||
@ -275,6 +272,57 @@ test "Selection: adjust right" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "Selection: adjust left" {
|
||||||
|
const testing = std.testing;
|
||||||
|
var s = try Screen.init(testing.allocator, 5, 10, 0);
|
||||||
|
defer s.deinit();
|
||||||
|
try s.testWriteString("A1234\nB5678\nC1234\nD5678");
|
||||||
|
|
||||||
|
// Simple movement left
|
||||||
|
{
|
||||||
|
var sel = try Selection.init(
|
||||||
|
&s,
|
||||||
|
s.pages.pin(.{ .screen = .{ .x = 5, .y = 1 } }).?,
|
||||||
|
s.pages.pin(.{ .screen = .{ .x = 3, .y = 3 } }).?,
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
defer sel.deinit(&s);
|
||||||
|
sel.adjust(&s, .left);
|
||||||
|
|
||||||
|
// Start line
|
||||||
|
try testing.expectEqual(point.Point{ .screen = .{
|
||||||
|
.x = 5,
|
||||||
|
.y = 1,
|
||||||
|
} }, s.pages.pointFromPin(.screen, sel.start.*).?);
|
||||||
|
try testing.expectEqual(point.Point{ .screen = .{
|
||||||
|
.x = 2,
|
||||||
|
.y = 3,
|
||||||
|
} }, s.pages.pointFromPin(.screen, sel.end.*).?);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Already at beginning of the line.
|
||||||
|
{
|
||||||
|
var sel = try Selection.init(
|
||||||
|
&s,
|
||||||
|
s.pages.pin(.{ .screen = .{ .x = 5, .y = 1 } }).?,
|
||||||
|
s.pages.pin(.{ .screen = .{ .x = 0, .y = 3 } }).?,
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
defer sel.deinit(&s);
|
||||||
|
sel.adjust(&s, .left);
|
||||||
|
|
||||||
|
// Start line
|
||||||
|
try testing.expectEqual(point.Point{ .screen = .{
|
||||||
|
.x = 5,
|
||||||
|
.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;
|
||||||
|
Reference in New Issue
Block a user