get some basic vim navigation working
This commit is contained in:
parent
cf0cf7aaa6
commit
b957e53bad
2 changed files with 29 additions and 11 deletions
|
@ -134,7 +134,7 @@ pub fn parse_key_events(allocator: std.mem.Allocator, str: []const u8) ![]KeyEve
|
|||
state = .escape_sequence_start;
|
||||
i += 1;
|
||||
},
|
||||
'a'...'z', ';', '0'...'9' => {
|
||||
'a'...'z', '\\', '[', ']', '/', '`', '-', '=', ';', '0'...'9' => {
|
||||
try result.append(.{ .key = str[i] });
|
||||
i += 1;
|
||||
},
|
||||
|
@ -608,6 +608,12 @@ const BindingSet = struct {
|
|||
for (self.bindings.items) |binding| blk: {
|
||||
switch (binding.match(self.current_sequence.items)) {
|
||||
.matched => {
|
||||
errdefer {
|
||||
//clear current sequence if command execution fails
|
||||
self.current_sequence.clearRetainingCapacity();
|
||||
self.current_sequence_egc.clearRetainingCapacity();
|
||||
}
|
||||
|
||||
if (!builtin.is_test) {
|
||||
self.logger.print("matched binding -> {s}", .{binding.command});
|
||||
if (!builtin.is_test) self.logger.print("execute '{s}'", .{binding.command});
|
||||
|
|
|
@ -3,14 +3,26 @@
|
|||
"normal": {
|
||||
"on_match_failure": "ignore",
|
||||
"bindings": [
|
||||
["j", "cursor_down"],
|
||||
["k", "cursor_up"],
|
||||
["h", "cursor_right_vim"],
|
||||
["l", "cursor_left_vim"],
|
||||
["i", "change_mode", "insert"],
|
||||
["o", "change_mode", "insert"],
|
||||
["a", "change_mode", "insert"],
|
||||
["v", "change_mode", "visual"],
|
||||
["j", "move_down"],
|
||||
["k", "move_up"],
|
||||
["l", "move_right_vim"],
|
||||
["h", "move_left"],
|
||||
["<Space>", "move_right_vim"],
|
||||
|
||||
["i", "enter_mode", "insert"],
|
||||
["v", "enter_mode", "visual"],
|
||||
|
||||
["/", "find"],
|
||||
["n", "goto_next_match"],
|
||||
|
||||
["0", "move_begin"],
|
||||
["<S-4>", "move_end"],
|
||||
|
||||
[";", "open_command_palette"],
|
||||
["<S-;>", "open_command_palette"],
|
||||
|
||||
["p", "paste"],
|
||||
|
||||
["gg", "goto_page_begin"],
|
||||
["<S-g>", "goto_page_end"],
|
||||
["<C-u>", "cursor_half_page_up"],
|
||||
|
@ -20,8 +32,8 @@
|
|||
"insert": {
|
||||
"on_match_failure": "insert",
|
||||
"bindings": [
|
||||
["jk", "change_mode", "normal"],
|
||||
["<Esc>", "change_mode", "normal"]
|
||||
["jk", "enter_mode", "normal"],
|
||||
["<Esc>", "enter_mode", "normal"]
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue