feat: add more vim keybinds

This is a combination of 6 commits.

- added a new command
- change dd to use cut
- add prototypes for A I o O commands
- fixed keybind test compilation bug
- add keybinds for the new enter_mode commands
- added prototype for copy line
This commit is contained in:
Robert Burnett 2024-11-21 17:57:17 -06:00 committed by CJ van den Berg
parent 0a75e04c3a
commit c909a2a50a
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
4 changed files with 87 additions and 3 deletions

View file

@ -18,8 +18,16 @@
["l", "move_right_vim"],
["h", "move_left"],
["<Space>", "move_right_vim"],
["i", "enter_mode", "insert"],
["a", "enter_mode_at_next_char", "insert"],
["I", "enter_mode_at_line_begin", "insert"],
["A", "enter_mode_at_line_end", "insert"],
["o", "enter_mode_on_newline_down", "insert"],
["O", "enter_mode_on_newline_up", "insert"],
["v", "enter_mode", "visual"],
["/", "find"],
["n", "goto_next_match"],
["0", "move_begin"],
@ -36,7 +44,10 @@
["<S-g>", "move_buffer_end"],
["d<S-4>", "delete_to_end"],
["d4", "delete_to_end"],
["dd", "cut"],
["<S-'><S-->dd", "delete_line"],
["yy", "copy_line"],
["<C-u>", "move_scroll_page_up"],
["<C-d>", "move_scroll_page_down"],
@ -58,7 +69,8 @@
["jk", "enter_mode", "normal"],
["<Esc>", "enter_mode", "normal"],
["<Del>", "delete_forward"],
["<BS>", "delete_backward"]
["<BS>", "delete_backward"],
["<CR>", "insert_line_after"]
]
}
}

View file

@ -325,7 +325,7 @@ const Binding = struct {
pub const KeybindHints = std.StringHashMapUnmanaged([]u8);
const max_key_sequence_time_interval = 750;
const max_key_sequence_time_interval = 1500;
const max_input_buffer_size = 4096;
var globals: struct {
@ -678,6 +678,8 @@ const match_test_cases = .{
.{ "<C-x><C-c>", "<C-x><C-c>", .matched },
.{ "<C-x><A-a>", "<C-x><A-a><Tab>", .match_possible },
.{ "<C-o>", "<C-o>", .matched },
.{ "<S-'><S-->dd", "<S-'><S-->dd", .matched },
.{ "<S-'><S-->dd", "<S-'><S-->da", .match_impossible },
};
test "match" {