Compare commits
7 commits
91288fa6a1
...
1dc0fcf9b5
| Author | SHA1 | Date | |
|---|---|---|---|
| 1dc0fcf9b5 | |||
| 6828b24367 | |||
| 385478741f | |||
| a53ef127ec | |||
| 961b88ffd5 | |||
| 7c0d841bb6 | |||
| 15b582243c |
7 changed files with 55 additions and 17 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;
|
||||
}
|
||||
|
||||
pub fn move_left(self: *Self) !void {
|
||||
if (self.col > 0) {
|
||||
self.col -= 1;
|
||||
pub fn move_left(self: *Self, n: usize) error{Stop}!void {
|
||||
if (self.col > n) {
|
||||
self.col -= n;
|
||||
} else if (self.col > 0) {
|
||||
self.col = 0;
|
||||
} else return error.Stop;
|
||||
}
|
||||
|
||||
pub fn move_right(self: *Self) !void {
|
||||
self.col += 1;
|
||||
pub fn move_right(self: *Self, n: usize) error{Stop}!void {
|
||||
self.col += n;
|
||||
}
|
||||
|
||||
pub fn move_up(self: *Self) !void {
|
||||
|
|
|
|||
|
|
@ -207,6 +207,8 @@ pub fn get_icon(id: ID) ?[]const u8 {
|
|||
const suppressed_errors = std.StaticStringMap(void).initComptime(.{
|
||||
.{ "enable_fast_scroll", void },
|
||||
.{ "disable_fast_scroll", void },
|
||||
.{ "enable_alt_scroll", void },
|
||||
.{ "disable_alt_scroll", void },
|
||||
.{ "clear_diagnostics", void },
|
||||
.{ "palette_menu_cancel", void },
|
||||
});
|
||||
|
|
|
|||
|
|
@ -255,13 +255,17 @@
|
|||
["left_control", "enable_jump_mode"],
|
||||
["right_control", "enable_jump_mode"],
|
||||
["left_alt", "enable_fast_scroll"],
|
||||
["right_alt", "enable_fast_scroll"]
|
||||
["right_alt", "enable_fast_scroll"],
|
||||
["left_shift", "enable_alt_scroll"],
|
||||
["right_shift", "enable_alt_scroll"]
|
||||
],
|
||||
"release": [
|
||||
["left_control", "disable_jump_mode"],
|
||||
["right_control", "disable_jump_mode"],
|
||||
["left_alt", "disable_fast_scroll"],
|
||||
["right_alt", "disable_fast_scroll"]
|
||||
["right_alt", "disable_fast_scroll"],
|
||||
["left_shift", "disable_alt_scroll"],
|
||||
["right_shift", "disable_alt_scroll"]
|
||||
]
|
||||
},
|
||||
"select": {
|
||||
|
|
|
|||
|
|
@ -717,6 +717,9 @@ const BindingSet = struct {
|
|||
const mods = switch (key_event.key) {
|
||||
input.key.left_control, input.key.right_control => 0,
|
||||
input.key.left_alt, input.key.right_alt => 0,
|
||||
input.key.left_shift, input.key.right_shift => 0,
|
||||
input.key.left_super, input.key.right_super => 0,
|
||||
input.key.iso_level_3_shift, input.key.iso_level_5_shift => 0,
|
||||
else => switch (mode_flag) {
|
||||
.ignore_alt_text_modifiers => if (std.mem.eql(u8, text, codepoint)) key_event.modifiers else 0,
|
||||
.normal => key_event.modifiers,
|
||||
|
|
|
|||
|
|
@ -126,10 +126,11 @@ pub const KeyEvent = struct {
|
|||
modifiers: Mods,
|
||||
) @This() {
|
||||
const mods_ = switch (keypress_) {
|
||||
key.left_super, key.right_super => modifiers & ~mod.super,
|
||||
key.left_shift, key.right_shift => modifiers & ~mod.shift,
|
||||
key.left_control, key.right_control => modifiers & ~mod.ctrl,
|
||||
key.left_alt, key.right_alt => modifiers & ~mod.alt,
|
||||
key.left_control, key.right_control => 0,
|
||||
key.left_alt, key.right_alt => 0,
|
||||
key.left_shift, key.right_shift => 0,
|
||||
key.left_super, key.right_super => 0,
|
||||
key.iso_level_3_shift, key.iso_level_5_shift => 0,
|
||||
else => modifiers,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ const Allocator = std.mem.Allocator;
|
|||
const time = std.time;
|
||||
|
||||
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 double_click_time_ms = 350;
|
||||
|
|
@ -371,6 +373,7 @@ pub const Editor = struct {
|
|||
handlers: EventHandler.List,
|
||||
scroll_dest: usize = 0,
|
||||
fast_scroll: bool = false,
|
||||
alt_scroll: bool = false,
|
||||
jump_mode: bool = false,
|
||||
|
||||
animation_step: usize = 0,
|
||||
|
|
@ -2791,16 +2794,20 @@ pub const Editor = struct {
|
|||
self.update_scroll_dest_abs(dest.row);
|
||||
}
|
||||
|
||||
pub fn scroll_up_pageup(self: *Self, _: Context) Result {
|
||||
if (self.fast_scroll)
|
||||
pub fn scroll_up_pageup(self: *Self, ctx: Context) Result {
|
||||
if (self.alt_scroll)
|
||||
try self.move_scroll_left(ctx)
|
||||
else if (self.fast_scroll)
|
||||
self.scroll_pageup()
|
||||
else
|
||||
self.scroll_up();
|
||||
}
|
||||
pub const scroll_up_pageup_meta: Meta = .{};
|
||||
|
||||
pub fn scroll_down_pagedown(self: *Self, _: Context) Result {
|
||||
if (self.fast_scroll)
|
||||
pub fn scroll_down_pagedown(self: *Self, ctx: Context) Result {
|
||||
if (self.alt_scroll)
|
||||
try self.move_scroll_right(ctx)
|
||||
else if (self.fast_scroll)
|
||||
self.scroll_pagedown()
|
||||
else
|
||||
self.scroll_down();
|
||||
|
|
@ -4150,12 +4157,18 @@ pub const Editor = struct {
|
|||
pub const move_scroll_down_meta: Meta = .{ .description = "Move and scroll down", .arguments = &.{.integer} };
|
||||
|
||||
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 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" };
|
||||
|
||||
|
|
@ -5090,6 +5103,16 @@ pub const Editor = struct {
|
|||
}
|
||||
pub const disable_fast_scroll_meta: Meta = .{};
|
||||
|
||||
pub fn enable_alt_scroll(self: *Self, _: Context) Result {
|
||||
self.alt_scroll = true;
|
||||
}
|
||||
pub const enable_alt_scroll_meta: Meta = .{ .description = "Enable horizontal scroll mode" };
|
||||
|
||||
pub fn disable_alt_scroll(self: *Self, _: Context) Result {
|
||||
self.alt_scroll = false;
|
||||
}
|
||||
pub const disable_alt_scroll_meta: Meta = .{};
|
||||
|
||||
pub fn enable_jump_mode(self: *Self, _: Context) Result {
|
||||
self.jump_mode = true;
|
||||
tui.rdr().request_mouse_cursor_pointer(true);
|
||||
|
|
|
|||
|
|
@ -882,6 +882,7 @@ pub fn is_mainview_focused() bool {
|
|||
|
||||
fn enter_overlay_mode(self: *Self, mode: type) command.Result {
|
||||
command.executeName("disable_fast_scroll", .{}) catch {};
|
||||
command.executeName("disable_alt_scroll", .{}) catch {};
|
||||
command.executeName("disable_jump_mode", .{}) catch {};
|
||||
if (self.mini_mode_) |_| try cmds.exit_mini_mode(self, .{});
|
||||
if (self.input_mode_outer_) |_| try cmds.exit_overlay_mode(self, .{});
|
||||
|
|
@ -894,6 +895,7 @@ fn enter_overlay_mode(self: *Self, mode: type) command.Result {
|
|||
|
||||
fn enter_overlay_mode_with_args(self: *Self, mode: type, ctx: command.Context) command.Result {
|
||||
command.executeName("disable_fast_scroll", .{}) catch {};
|
||||
command.executeName("disable_alt_scroll", .{}) catch {};
|
||||
command.executeName("disable_jump_mode", .{}) catch {};
|
||||
if (self.mini_mode_) |_| try cmds.exit_mini_mode(self, .{});
|
||||
if (self.input_mode_outer_) |_| try cmds.exit_overlay_mode(self, .{});
|
||||
|
|
@ -1469,6 +1471,7 @@ const cmds = struct {
|
|||
|
||||
fn enter_mini_mode(self: *Self, comptime mode: anytype, ctx: Ctx) !void {
|
||||
command.executeName("disable_fast_scroll", .{}) catch {};
|
||||
command.executeName("disable_alt_scroll", .{}) catch {};
|
||||
command.executeName("disable_jump_mode", .{}) catch {};
|
||||
if (self.mini_mode_) |_| try exit_mini_mode(self, .{});
|
||||
if (self.input_mode_outer_) |_| try exit_overlay_mode(self, .{});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue