From 61610f579a520660f53fd9fa962ca094fba34965 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Thu, 29 Feb 2024 01:09:46 +0100 Subject: [PATCH] feat: add vim ctrl-u and ctrl-d pageup/down bindings --- src/tui/mode/input/vim/insert.zig | 4 ++-- src/tui/mode/input/vim/normal.zig | 4 ++-- src/tui/mode/input/vim/visual.zig | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/tui/mode/input/vim/insert.zig b/src/tui/mode/input/vim/insert.zig index 941d6a5..6235aaa 100644 --- a/src/tui/mode/input/vim/insert.zig +++ b/src/tui/mode/input/vim/insert.zig @@ -73,6 +73,8 @@ fn mapPress(self: *Self, keypress: u32, egc: u32, modifiers: u32) tp.result { if (self.leader) |_| return self.mapFollower(keynormal, egc, modifiers); return switch (modifiers) { mod.CTRL => switch (keynormal) { + 'U' => self.cmd("move_scroll_page_up", .{}), + 'D' => self.cmd("move_scroll_page_down", .{}), 'J' => self.cmd("toggle_logview", .{}), 'Z' => self.cmd("undo", .{}), 'Y' => self.cmd("redo", .{}), @@ -87,12 +89,10 @@ fn mapPress(self: *Self, keypress: u32, egc: u32, modifiers: u32) tp.result { 'X' => self.cmd("cut", .{}), 'C' => self.cmd("enter_mode", command.fmt(.{"vim/normal"})), 'V' => self.cmd("system_paste", .{}), - 'U' => self.cmd("pop_cursor", .{}), 'K' => self.leader = .{ .keypress = keynormal, .modifiers = modifiers }, 'F' => self.cmd("enter_find_mode", .{}), 'G' => self.cmd("enter_goto_mode", .{}), 'O' => self.cmd("run_ls", .{}), - 'D' => self.cmd("add_cursor_next_match", .{}), 'A' => self.cmd("select_all", .{}), 'I' => self.insert_bytes("\t"), '/' => self.cmd("toggle_comment", .{}), diff --git a/src/tui/mode/input/vim/normal.zig b/src/tui/mode/input/vim/normal.zig index 3d52c4a..2032cc7 100644 --- a/src/tui/mode/input/vim/normal.zig +++ b/src/tui/mode/input/vim/normal.zig @@ -74,6 +74,8 @@ fn mapPress(self: *Self, keypress: u32, egc: u32, modifiers: u32) tp.result { if (self.leader) |_| return self.mapFollower(keynormal, egc, modifiers); return switch (modifiers) { mod.CTRL => switch (keynormal) { + 'U' => self.cmd("move_scroll_page_up", .{}), + 'D' => self.cmd("move_scroll_page_down", .{}), 'R' => self.cmd("redo", .{}), 'O' => self.cmd("jump_back", .{}), 'I' => self.cmd("jump_forward", .{}), @@ -92,11 +94,9 @@ fn mapPress(self: *Self, keypress: u32, egc: u32, modifiers: u32) tp.result { 'X' => self.cmd("cut", .{}), 'C' => self.cmd("copy", .{}), 'V' => self.cmd("system_paste", .{}), - 'U' => self.cmd("pop_cursor", .{}), 'K' => self.leader = .{ .keypress = keynormal, .modifiers = modifiers }, 'F' => self.cmd("enter_find_mode", .{}), 'G' => self.cmd("enter_goto_mode", .{}), - 'D' => self.cmd("add_cursor_next_match", .{}), 'A' => self.cmd("select_all", .{}), '/' => self.cmd("toggle_comment", .{}), key.ENTER => self.cmd("insert_line_after", .{}), diff --git a/src/tui/mode/input/vim/visual.zig b/src/tui/mode/input/vim/visual.zig index ec36c12..30d4ad1 100644 --- a/src/tui/mode/input/vim/visual.zig +++ b/src/tui/mode/input/vim/visual.zig @@ -74,6 +74,8 @@ fn mapPress(self: *Self, keypress: u32, egc: u32, modifiers: u32) tp.result { if (self.leader) |_| return self.mapFollower(keynormal, egc, modifiers); return switch (modifiers) { mod.CTRL => switch (keynormal) { + 'U' => self.cmd("move_scroll_page_up", .{}), + 'D' => self.cmd("move_scroll_page_down", .{}), 'R' => self.cmd("redo", .{}), 'O' => self.cmd("jump_back", .{}), 'I' => self.cmd("jump_forward", .{}), @@ -92,7 +94,6 @@ fn mapPress(self: *Self, keypress: u32, egc: u32, modifiers: u32) tp.result { 'X' => self.cmd("cut", .{}), 'C' => self.cmd("copy", .{}), 'V' => self.cmd("system_paste", .{}), - 'U' => self.cmd("pop_cursor", .{}), 'K' => self.leader = .{ .keypress = keynormal, .modifiers = modifiers }, 'F' => self.cmd("enter_find_mode", .{}), 'G' => self.cmd("enter_goto_mode", .{}),