diff --git a/src/Surface.zig b/src/Surface.zig index fe7fd2157..f5c5b65da 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -3471,6 +3471,8 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool .page_down => .page_down, .home => .home, .end => .end, + .beginning_of_line => .beginning_of_line, + .end_of_line => .end_of_line, }); // If the selection endpoint is outside of the current viewpoint, diff --git a/src/input/Binding.zig b/src/input/Binding.zig index 213e711c9..a2eb360c4 100644 --- a/src/input/Binding.zig +++ b/src/input/Binding.zig @@ -304,6 +304,8 @@ pub const Action = union(enum) { page_down, home, end, + beginning_of_line, + end_of_line, }; pub const SplitDirection = enum { diff --git a/src/terminal/Selection.zig b/src/terminal/Selection.zig index e4edca0f6..365947bf9 100644 --- a/src/terminal/Selection.zig +++ b/src/terminal/Selection.zig @@ -344,6 +344,8 @@ pub const Adjustment = enum { end, page_up, page_down, + beginning_of_line, + end_of_line, }; /// Adjust the selection by some given adjustment. An adjustment allows @@ -362,7 +364,7 @@ pub fn adjust( .up => if (end_pin.up(1)) |new_end| { end_pin.* = new_end; } else { - end_pin.x = 0; + self.adjust(s, .beginning_of_line); }, .down => { @@ -377,7 +379,7 @@ pub fn adjust( } } else { // If we're at the bottom, just go to the end of the line - end_pin.x = end_pin.page.data.size.cols - 1; + self.adjust(s, .end_of_line); } }, @@ -440,6 +442,10 @@ pub fn adjust( } } }, + + .beginning_of_line => end_pin.x = 0, + + .end_of_line => end_pin.x = end_pin.page.data.size.cols - 1, } }