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:
parent
0a75e04c3a
commit
c909a2a50a
4 changed files with 87 additions and 3 deletions
|
@ -43,7 +43,9 @@ pub fn Closure(comptime T: type) type {
|
|||
f: FunT,
|
||||
data: T,
|
||||
|
||||
///The type signature of commands
|
||||
const FunT: type = *const fn (T, ctx: Context) Result;
|
||||
|
||||
const Self = @This();
|
||||
|
||||
pub fn init(f: FunT, data: T, name: []const u8, meta: Metadata) Self {
|
||||
|
|
|
@ -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"]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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" {
|
||||
|
|
|
@ -44,4 +44,72 @@ const cmds_ = struct {
|
|||
try cmd("quit_without_saving", .{});
|
||||
}
|
||||
pub const @"wq!_meta" = .{ .description = "wq! (write file and quit without saving)" };
|
||||
|
||||
pub fn enter_mode_at_next_char(self: *void, ctx: Ctx) Result {
|
||||
_ = self; // autofix
|
||||
_ = ctx; // autofix
|
||||
//TODO
|
||||
return undefined;
|
||||
}
|
||||
|
||||
pub const enter_mode_at_next_char_meta = .{ .description = "Move forward one char and change mode" };
|
||||
|
||||
pub fn enter_mode_on_newline_down(self: *void, ctx: Ctx) Result {
|
||||
_ = self; // autofix
|
||||
_ = ctx; // autofix
|
||||
//TODO
|
||||
return undefined;
|
||||
}
|
||||
|
||||
pub const enter_mode_on_newline_down_meta = .{ .description = "Insert a newline and change mode" };
|
||||
|
||||
pub fn enter_mode_on_newline_up(self: *void, ctx: Ctx) Result {
|
||||
_ = self; // autofix
|
||||
_ = ctx; // autofix
|
||||
//TODO
|
||||
return undefined;
|
||||
}
|
||||
pub const enter_mode_on_newline_up_meta = .{ .description = "Insert a newline above the current line and change mode" };
|
||||
|
||||
pub fn enter_mode_at_line_begin(self: *void, ctx: Ctx) Result {
|
||||
_ = self; // autofix
|
||||
_ = ctx; // autofix
|
||||
//TODO
|
||||
return undefined;
|
||||
}
|
||||
|
||||
pub const enter_mode_at_line_begin_meta = .{ .description = "Goto line begin and change mode" };
|
||||
|
||||
pub fn enter_mode_at_line_end(self: *void, ctx: Ctx) Result {
|
||||
_ = self; // autofix
|
||||
_ = ctx; // autofix
|
||||
//TODO
|
||||
return undefined;
|
||||
}
|
||||
pub const enter_mode_at_line_end_meta = .{ .description = "Goto line end and change mode" };
|
||||
|
||||
pub fn copy_line(self: *void, ctx: Ctx) Result {
|
||||
_ = self; // autofix
|
||||
_ = ctx; // autofix
|
||||
//TODO
|
||||
return undefined;
|
||||
}
|
||||
|
||||
pub const copy_line_meta = .{ .description = "Copies the current line" };
|
||||
|
||||
pub fn delete_line(self: *void, ctx: Ctx) Result {
|
||||
_ = self; // autofix
|
||||
_ = ctx; // autofix
|
||||
//TODO
|
||||
return undefined;
|
||||
//try self.move_begin(ctx);
|
||||
//const b = try self.buf_for_update();
|
||||
//var root = try self.delete_to(move_cursor_end, b.root, b.allocator);
|
||||
//root = try self.delete_to(move_cursor_right, b.root, b.allocator);
|
||||
//try self.delete_forward(ctx);
|
||||
//try self.update_buf(root);
|
||||
//self.clamp();
|
||||
}
|
||||
pub const delete_line_meta = .{ .description = "Delete the current line without copying" };
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue