Add adjust_selection actions for beginning_of_line and end_of_line

This commit is contained in:
Justin Su
2024-07-20 23:06:06 -04:00
parent 3ad478044b
commit 97bd46de7f
3 changed files with 12 additions and 2 deletions

View File

@ -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,

View File

@ -304,6 +304,8 @@ pub const Action = union(enum) {
page_down,
home,
end,
beginning_of_line,
end_of_line,
};
pub const SplitDirection = enum {

View File

@ -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,
}
}