feat: add fast_scroll mode support to horizontal scrolling
Also, bump the basic scroll step to 5 columns like other editors.
This commit is contained in:
parent
961b88ffd5
commit
a53ef127ec
2 changed files with 17 additions and 7 deletions
|
|
@ -29,14 +29,16 @@ pub inline fn eql(self: Self, other: Self) bool {
|
||||||
return self.row == other.row and self.col == other.col and self.rows == other.rows and self.cols == other.cols;
|
return self.row == other.row and self.col == other.col and self.rows == other.rows and self.cols == other.cols;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn move_left(self: *Self) !void {
|
pub fn move_left(self: *Self, n: usize) error{Stop}!void {
|
||||||
if (self.col > 0) {
|
if (self.col > n) {
|
||||||
self.col -= 1;
|
self.col -= n;
|
||||||
|
} else if (self.col > 0) {
|
||||||
|
self.col = 0;
|
||||||
} else return error.Stop;
|
} else return error.Stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn move_right(self: *Self) !void {
|
pub fn move_right(self: *Self, n: usize) error{Stop}!void {
|
||||||
self.col += 1;
|
self.col += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn move_up(self: *Self) !void {
|
pub fn move_up(self: *Self) !void {
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@ const Allocator = std.mem.Allocator;
|
||||||
const time = std.time;
|
const time = std.time;
|
||||||
|
|
||||||
const scroll_step_small = 3;
|
const scroll_step_small = 3;
|
||||||
|
const scroll_step_horizontal = 5;
|
||||||
|
const scroll_step_horizontal_fast = scroll_step_horizontal * 5;
|
||||||
const scroll_cursor_min_border_distance = 5;
|
const scroll_cursor_min_border_distance = 5;
|
||||||
|
|
||||||
const double_click_time_ms = 350;
|
const double_click_time_ms = 350;
|
||||||
|
|
@ -4150,12 +4152,18 @@ pub const Editor = struct {
|
||||||
pub const move_scroll_down_meta: Meta = .{ .description = "Move and scroll down", .arguments = &.{.integer} };
|
pub const move_scroll_down_meta: Meta = .{ .description = "Move and scroll down", .arguments = &.{.integer} };
|
||||||
|
|
||||||
pub fn move_scroll_left(self: *Self, _: Context) Result {
|
pub fn move_scroll_left(self: *Self, _: Context) Result {
|
||||||
self.view.move_left() catch {};
|
if (self.fast_scroll)
|
||||||
|
self.view.move_left(scroll_step_horizontal_fast) catch {}
|
||||||
|
else
|
||||||
|
self.view.move_left(scroll_step_horizontal) catch {};
|
||||||
}
|
}
|
||||||
pub const move_scroll_left_meta: Meta = .{ .description = "Scroll left" };
|
pub const move_scroll_left_meta: Meta = .{ .description = "Scroll left" };
|
||||||
|
|
||||||
pub fn move_scroll_right(self: *Self, _: Context) Result {
|
pub fn move_scroll_right(self: *Self, _: Context) Result {
|
||||||
self.view.move_right() catch {};
|
if (self.fast_scroll)
|
||||||
|
self.view.move_right(scroll_step_horizontal_fast) catch {}
|
||||||
|
else
|
||||||
|
self.view.move_right(scroll_step_horizontal) catch {};
|
||||||
}
|
}
|
||||||
pub const move_scroll_right_meta: Meta = .{ .description = "Scroll right" };
|
pub const move_scroll_right_meta: Meta = .{ .description = "Scroll right" };
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue