feat: implement scroll_view_center_cycle to replace cmd_cycle3

This commit is contained in:
CJ van den Berg 2024-11-17 22:43:14 +01:00
parent 43c49125f8
commit e172590ba8
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
13 changed files with 33 additions and 95 deletions

View file

@ -1943,7 +1943,18 @@ pub const Editor = struct {
pub fn scroll_view_center(self: *Self, _: Context) Result {
return self.scroll_view_offset(self.view.rows / 2);
}
pub const scroll_view_center_meta = .{ .description = "Scroll cursor to center/top/bottom of view" };
pub const scroll_view_center_meta = .{ .description = "Scroll cursor to center of view" };
pub fn scroll_view_center_cycle(self: *Self, _: Context) Result {
const cursor_row = self.get_primary().cursor.row;
return if (cursor_row == self.view.row + scroll_cursor_min_border_distance)
self.scroll_view_bottom(.{})
else if (cursor_row == self.view.row + self.view.rows / 2)
self.scroll_view_top(.{})
else
self.scroll_view_offset(self.view.rows / 2);
}
pub const scroll_view_center_cycle_meta = .{ .description = "Scroll cursor to center/top/bottom of view" };
pub fn scroll_view_top(self: *Self, _: Context) Result {
return self.scroll_view_offset(scroll_cursor_min_border_distance);