refactor: clean-up command naming
This commit is contained in:
parent
f9c029f617
commit
ea31e414ee
11 changed files with 55 additions and 55 deletions
|
@ -257,7 +257,7 @@ pub fn get_mru_position(self: *Self, from: tp.pid_ref, file_path: []const u8) !v
|
|||
for (self.files.items) |*file| {
|
||||
if (!std.mem.eql(u8, file.path, file_path)) continue;
|
||||
if (file.row != 0)
|
||||
try from.send(.{ "cmd", "goto", .{ file.row + 1, file.col + 1 } });
|
||||
try from.send(.{ "cmd", "goto_line_and_column", .{ file.row + 1, file.col + 1 } });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2976,7 +2976,7 @@ pub const Editor = struct {
|
|||
self.clamp();
|
||||
}
|
||||
|
||||
pub fn open_file(self: *Self, ctx: Context) Result {
|
||||
pub fn open_buffer_from_file(self: *Self, ctx: Context) Result {
|
||||
var file_path: []const u8 = undefined;
|
||||
if (ctx.args.match(.{tp.extract(&file_path)}) catch false) {
|
||||
try self.open(file_path);
|
||||
|
@ -3382,7 +3382,7 @@ pub const Editor = struct {
|
|||
self.clamp();
|
||||
}
|
||||
|
||||
pub fn goto(self: *Self, ctx: Context) Result {
|
||||
pub fn goto_line_and_column(self: *Self, ctx: Context) Result {
|
||||
try self.send_editor_jump_source();
|
||||
var line: usize = 0;
|
||||
var column: usize = 0;
|
||||
|
|
|
@ -108,7 +108,7 @@ fn menu_action_help(_: **Menu.State(*Self), _: *Button.State(*Menu.State(*Self))
|
|||
}
|
||||
|
||||
fn menu_action_open_file(_: **Menu.State(*Self), _: *Button.State(*Menu.State(*Self))) void {
|
||||
command.executeName("enter_open_file_mode", .{}) catch {};
|
||||
command.executeName("open_file", .{}) catch {};
|
||||
}
|
||||
|
||||
fn menu_action_open_recent_file(_: **Menu.State(*Self), _: *Button.State(*Menu.State(*Self))) void {
|
||||
|
|
|
@ -289,10 +289,10 @@ const cmds = struct {
|
|||
editor.send_editor_jump_source() catch {};
|
||||
}
|
||||
try self.create_editor();
|
||||
try command.executeName("open_file", command.fmt(.{f}));
|
||||
try command.executeName("open_buffer_from_file", command.fmt(.{f}));
|
||||
}
|
||||
if (goto_args.len != 0) {
|
||||
try command.executeName("goto", .{ .args = .{ .buf = goto_args } });
|
||||
try command.executeName("goto_line_and_column", .{ .args = .{ .buf = goto_args } });
|
||||
} else if (line) |l| {
|
||||
try command.executeName("goto_line", command.fmt(.{l}));
|
||||
if (!same_file)
|
||||
|
|
|
@ -85,21 +85,21 @@ fn mapPress(self: *Self, keypress: u32, egc: u32, modifiers: u32) !void {
|
|||
'Z' => self.cmd("undo", .{}),
|
||||
'Y' => self.cmd("redo", .{}),
|
||||
'Q' => self.cmd("quit", .{}),
|
||||
'O' => self.cmd("enter_open_file_mode", .{}),
|
||||
'O' => self.cmd("open_file", .{}),
|
||||
'W' => self.cmd("close_file", .{}),
|
||||
'S' => self.cmd("save_file", .{}),
|
||||
'L' => self.cmd_cycle3("scroll_view_center", "scroll_view_top", "scroll_view_bottom", .{}),
|
||||
'N' => self.cmd("goto_next_match", .{}),
|
||||
'P' => self.cmd("goto_prev_match", .{}),
|
||||
'B' => self.cmd("enter_move_to_char_mode", command.fmt(.{false})),
|
||||
'T' => self.cmd("enter_move_to_char_mode", command.fmt(.{true})),
|
||||
'B' => self.cmd("move_to_char", command.fmt(.{false})),
|
||||
'T' => self.cmd("move_to_char", command.fmt(.{true})),
|
||||
'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", .{}),
|
||||
'F' => self.cmd("find", .{}),
|
||||
'G' => self.cmd("goto", .{}),
|
||||
'D' => self.cmd("add_cursor_next_match", .{}),
|
||||
'A' => self.cmd("select_all", .{}),
|
||||
'I' => self.insert_bytes("\t"),
|
||||
|
@ -126,7 +126,7 @@ fn mapPress(self: *Self, keypress: u32, egc: u32, modifiers: u32) !void {
|
|||
'Z' => self.cmd("redo", .{}),
|
||||
'Q' => self.cmd("quit_without_saving", .{}),
|
||||
'W' => self.cmd("close_file_without_saving", .{}),
|
||||
'F' => self.cmd("enter_find_in_files_mode", .{}),
|
||||
'F' => self.cmd("find_in_files", .{}),
|
||||
'L' => self.cmd_async("add_cursor_all_matches"),
|
||||
'I' => self.cmd_async("toggle_inspector_view"),
|
||||
'M' => self.cmd("show_diagnostics", .{}),
|
||||
|
@ -330,11 +330,11 @@ const hints = tui.KeybindHints.initComptime(.{
|
|||
.{ "dupe_up", "S-A-d" },
|
||||
.{ "enable_fast_scroll", "hold Ctrl" },
|
||||
.{ "enable_jump_mode", "hold Alt" },
|
||||
.{ "enter_find_in_files_mode", "C-S-f" },
|
||||
.{ "enter_find_mode", "C-f" },
|
||||
.{ "enter_goto_mode", "C-g" },
|
||||
.{ "enter_move_to_char_mode", "C-b, C-t" }, // true/false
|
||||
.{ "enter_open_file_mode", "C-o" },
|
||||
.{ "find_in_files", "C-S-f" },
|
||||
.{ "find", "C-f" },
|
||||
.{ "goto", "C-g" },
|
||||
.{ "move_to_char", "C-b, C-t" }, // true/false
|
||||
.{ "open_file", "C-o" },
|
||||
.{ "filter", "A-s" }, // self.cmd("filter", command.fmt(.{"sort"})),
|
||||
// .{ "filter", "S-A-s" }, // self.cmd("filter", command.fmt(.{ "sort", "-u" })),
|
||||
.{ "format", "S-A-f" },
|
||||
|
|
|
@ -61,7 +61,7 @@ fn mapPress(self: *Self, keypress: u32, modifiers: u32) tp.result {
|
|||
'J' => self.cmd("toggle_panel", .{}),
|
||||
'Q' => self.cmd("quit", .{}),
|
||||
'W' => self.cmd("quit", .{}),
|
||||
'O' => self.cmd("enter_open_file_mode", .{}),
|
||||
'O' => self.cmd("open_file", .{}),
|
||||
'E' => self.cmd("open_recent", .{}),
|
||||
'P' => self.cmd("open_command_palette", .{}),
|
||||
'/' => self.cmd("open_help", .{}),
|
||||
|
@ -72,7 +72,7 @@ fn mapPress(self: *Self, keypress: u32, modifiers: u32) tp.result {
|
|||
'P' => self.cmd("open_command_palette", .{}),
|
||||
'Q' => self.cmd("quit_without_saving", .{}),
|
||||
'R' => self.cmd("restart", .{}),
|
||||
'F' => self.cmd("enter_find_in_files_mode", .{}),
|
||||
'F' => self.cmd("find_in_files", .{}),
|
||||
'L' => self.cmd_async("toggle_panel"),
|
||||
'/' => self.cmd("open_help", .{}),
|
||||
else => {},
|
||||
|
@ -92,7 +92,7 @@ fn mapPress(self: *Self, keypress: u32, modifiers: u32) tp.result {
|
|||
},
|
||||
0 => switch (keypress) {
|
||||
'h' => self.cmd("open_help", .{}),
|
||||
'o' => self.cmd("enter_open_file_mode", .{}),
|
||||
'o' => self.cmd("open_file", .{}),
|
||||
'e' => self.cmd("open_recent", .{}),
|
||||
'r' => self.msg("open recent project not implemented"),
|
||||
'p' => self.cmd("open_command_palette", .{}),
|
||||
|
@ -154,8 +154,8 @@ fn sheeran(self: *Self) void {
|
|||
}
|
||||
|
||||
const hints = tui.KeybindHints.initComptime(.{
|
||||
.{ "enter_find_in_files_mode", "C-S-f" },
|
||||
.{ "enter_open_file_mode", "o, C-o" },
|
||||
.{ "find_in_files", "C-S-f" },
|
||||
.{ "open_file", "o, C-o" },
|
||||
.{ "open_recent", "e, C-e" },
|
||||
.{ "open_command_palette", "p, C-S-p, S-A-p" },
|
||||
.{ "home_menu_activate", "enter" },
|
||||
|
|
|
@ -97,14 +97,14 @@ fn mapPress(self: *Self, keypress: u32, egc: u32, modifiers: u32) !void {
|
|||
'L' => self.cmd_cycle3("scroll_view_center", "scroll_view_top", "scroll_view_bottom", .{}),
|
||||
'N' => self.cmd("goto_next_match", .{}),
|
||||
'P' => self.cmd("goto_prev_match", .{}),
|
||||
'B' => self.cmd("enter_move_to_char_mode", command.fmt(.{false})),
|
||||
'T' => self.cmd("enter_move_to_char_mode", command.fmt(.{true})),
|
||||
'B' => self.cmd("move_to_char", command.fmt(.{false})),
|
||||
'T' => self.cmd("move_to_char", command.fmt(.{true})),
|
||||
'X' => self.cmd("cut", .{}),
|
||||
'C' => self.cmd("enter_mode", command.fmt(.{"vim/normal"})),
|
||||
'V' => self.cmd("system_paste", .{}),
|
||||
'K' => self.leader = .{ .keypress = keynormal, .modifiers = modifiers },
|
||||
'F' => self.cmd("enter_find_mode", .{}),
|
||||
'G' => self.cmd("enter_goto_mode", .{}),
|
||||
'F' => self.cmd("find", .{}),
|
||||
'G' => self.cmd("goto", .{}),
|
||||
'O' => self.cmd("run_ls", .{}),
|
||||
'A' => self.cmd("select_all", .{}),
|
||||
'I' => self.insert_bytes("\t"),
|
||||
|
@ -131,7 +131,7 @@ fn mapPress(self: *Self, keypress: u32, egc: u32, modifiers: u32) !void {
|
|||
'Z' => self.cmd("redo", .{}),
|
||||
'Q' => self.cmd("quit_without_saving", .{}),
|
||||
'W' => self.cmd("close_file_without_saving", .{}),
|
||||
'F' => self.cmd("enter_find_in_files_mode", .{}),
|
||||
'F' => self.cmd("find_in_files", .{}),
|
||||
'L' => self.cmd_async("add_cursor_all_matches"),
|
||||
'I' => self.cmd_async("toggle_inspector_view"),
|
||||
key.ENTER => self.cmd("smart_insert_line_before", .{}),
|
||||
|
|
|
@ -104,14 +104,14 @@ fn mapPress(self: *Self, keypress: u32, egc: u32, modifiers: u32) !void {
|
|||
'L' => self.cmd_cycle3("scroll_view_center", "scroll_view_top", "scroll_view_bottom", .{}),
|
||||
'N' => self.cmd("goto_next_match", .{}),
|
||||
'P' => self.cmd("goto_prev_match", .{}),
|
||||
'B' => self.cmd("enter_move_to_char_mode", command.fmt(.{false})),
|
||||
'T' => self.cmd("enter_move_to_char_mode", command.fmt(.{true})),
|
||||
'B' => self.cmd("move_to_char", command.fmt(.{false})),
|
||||
'T' => self.cmd("move_to_char", command.fmt(.{true})),
|
||||
'X' => self.cmd("cut", .{}),
|
||||
'C' => self.cmd("copy", .{}),
|
||||
'V' => self.cmd("system_paste", .{}),
|
||||
'K' => self.leader = .{ .keypress = keynormal, .modifiers = modifiers },
|
||||
'F' => self.cmd("enter_find_mode", .{}),
|
||||
'G' => self.cmd("enter_goto_mode", .{}),
|
||||
'F' => self.cmd("find", .{}),
|
||||
'G' => self.cmd("goto", .{}),
|
||||
'A' => self.cmd("select_all", .{}),
|
||||
'/' => self.cmd("toggle_comment", .{}),
|
||||
key.ENTER => self.cmd("smart_insert_line_after", .{}),
|
||||
|
@ -136,7 +136,7 @@ fn mapPress(self: *Self, keypress: u32, egc: u32, modifiers: u32) !void {
|
|||
'Z' => self.cmd("redo", .{}),
|
||||
'Q' => self.cmd("quit_without_saving", .{}),
|
||||
'W' => self.cmd("close_file_without_saving", .{}),
|
||||
'F' => self.cmd("enter_find_in_files_mode", .{}),
|
||||
'F' => self.cmd("find_in_files", .{}),
|
||||
'L' => self.cmd_async("add_cursor_all_matches"),
|
||||
'I' => self.cmd_async("toggle_inspector_view"),
|
||||
key.ENTER => self.cmd("smart_insert_line_before", .{}),
|
||||
|
@ -235,7 +235,7 @@ fn mapPress(self: *Self, keypress: u32, egc: u32, modifiers: u32) !void {
|
|||
'a' => self.seq(.{ "move_right", "enter_mode" }, command.fmt(.{"vim/insert"})),
|
||||
'v' => self.cmd("enter_mode", command.fmt(.{"vim/visual"})),
|
||||
|
||||
'/' => self.cmd("enter_find_mode", .{}),
|
||||
'/' => self.cmd("find", .{}),
|
||||
'n' => self.cmd("goto_next_match", .{}),
|
||||
|
||||
'h' => self.cmd_count("move_left_vim", .{}),
|
||||
|
@ -515,11 +515,11 @@ const hints = tui.KeybindHints.initComptime(.{
|
|||
.{ "dupe_up", "S-A-d" },
|
||||
.{ "enable_fast_scroll", "hold Ctrl" },
|
||||
.{ "enable_jump_mode", "hold Alt" },
|
||||
.{ "enter_find_in_files_mode", "C-S-f" },
|
||||
.{ "enter_find_mode", "C-f, /" },
|
||||
.{ "enter_goto_mode", "C-g" },
|
||||
.{ "enter_move_to_char_mode", "C-b, C-t" }, // true/false
|
||||
.{ "enter_open_file_mode", "C-o" },
|
||||
.{ "find_in_files", "C-S-f" },
|
||||
.{ "find", "C-f, /" },
|
||||
.{ "goto", "C-g" },
|
||||
.{ "move_to_char", "C-b, C-t" }, // true/false
|
||||
.{ "open_file", "C-o" },
|
||||
.{ "filter", "A-s" }, // self.cmd("filter", command.fmt(.{"sort"})),
|
||||
// .{ "filter", "S-A-s" }, // self.cmd("filter", command.fmt(.{ "sort", "-u" })),
|
||||
.{ "format", "S-A-f" },
|
||||
|
|
|
@ -104,14 +104,14 @@ fn mapPress(self: *Self, keypress: u32, egc: u32, modifiers: u32) !void {
|
|||
'L' => self.cmd_cycle3("scroll_view_center", "scroll_view_top", "scroll_view_bottom", .{}),
|
||||
'N' => self.cmd("goto_next_match", .{}),
|
||||
'P' => self.cmd("goto_prev_match", .{}),
|
||||
'B' => self.cmd("enter_move_to_char_mode", command.fmt(.{false})),
|
||||
'T' => self.cmd("enter_move_to_char_mode", command.fmt(.{true})),
|
||||
'B' => self.cmd("move_to_char", command.fmt(.{false})),
|
||||
'T' => self.cmd("move_to_char", command.fmt(.{true})),
|
||||
'X' => self.cmd("cut", .{}),
|
||||
'C' => self.cmd("copy", .{}),
|
||||
'V' => self.cmd("system_paste", .{}),
|
||||
'K' => self.leader = .{ .keypress = keynormal, .modifiers = modifiers },
|
||||
'F' => self.cmd("enter_find_mode", .{}),
|
||||
'G' => self.cmd("enter_goto_mode", .{}),
|
||||
'F' => self.cmd("find", .{}),
|
||||
'G' => self.cmd("goto", .{}),
|
||||
'A' => self.cmd("select_all", .{}),
|
||||
'/' => self.cmd("toggle_comment", .{}),
|
||||
key.ENTER => self.cmd("smart_insert_line_after", .{}),
|
||||
|
@ -136,7 +136,7 @@ fn mapPress(self: *Self, keypress: u32, egc: u32, modifiers: u32) !void {
|
|||
'Z' => self.cmd("redo", .{}),
|
||||
'Q' => self.cmd("quit_without_saving", .{}),
|
||||
'W' => self.cmd("close_file_without_saving", .{}),
|
||||
'F' => self.cmd("enter_find_in_files_mode", .{}),
|
||||
'F' => self.cmd("find_in_files", .{}),
|
||||
'L' => self.cmd_async("add_cursor_all_matches"),
|
||||
'I' => self.cmd_async("toggle_inspector_view"),
|
||||
key.ENTER => self.cmd("smart_insert_line_before", .{}),
|
||||
|
@ -233,7 +233,7 @@ fn mapPress(self: *Self, keypress: u32, egc: u32, modifiers: u32) !void {
|
|||
'a' => self.seq(.{ "move_right", "enter_mode" }, command.fmt(.{"vim/insert"})),
|
||||
'v' => self.cmd("enter_mode", command.fmt(.{"vim/visual"})),
|
||||
|
||||
'/' => self.cmd("enter_find_mode", .{}),
|
||||
'/' => self.cmd("find", .{}),
|
||||
'n' => self.cmd("goto_next_match", .{}),
|
||||
|
||||
'h' => self.cmd_count("select_left", .{}),
|
||||
|
@ -475,11 +475,11 @@ const hints = tui.KeybindHints.initComptime(.{
|
|||
.{ "dupe_up", "S-A-d" },
|
||||
.{ "enable_fast_scroll", "hold Ctrl" },
|
||||
.{ "enable_jump_mode", "hold Alt" },
|
||||
.{ "enter_find_in_files_mode", "C-S-f" },
|
||||
.{ "enter_find_mode", "C-f, /" },
|
||||
.{ "enter_goto_mode", "C-g" },
|
||||
.{ "enter_move_to_char_mode", "C-b, C-t" }, // true/false
|
||||
.{ "enter_open_file_mode", "C-o" },
|
||||
.{ "find_in_files", "C-S-f" },
|
||||
.{ "find", "C-f, /" },
|
||||
.{ "goto", "C-g" },
|
||||
.{ "move_to_char", "C-b, C-t" }, // true/false
|
||||
.{ "open_file", "C-o" },
|
||||
.{ "filter", "A-s" }, // self.cmd("filter", command.fmt(.{"sort"})),
|
||||
// .{ "filter", "S-A-s" }, // self.cmd("filter", command.fmt(.{ "sort", "-u" })),
|
||||
.{ "format", "S-A-f" },
|
||||
|
|
|
@ -31,7 +31,7 @@ pub fn create(a: Allocator, parent: Plane, event_handler: ?Widget.EventHandler)
|
|||
}
|
||||
|
||||
fn on_click(_: *Self, _: *Button.State(Self)) void {
|
||||
command.executeName("enter_goto_mode", .{}) catch {};
|
||||
command.executeName("goto", .{}) catch {};
|
||||
}
|
||||
|
||||
pub fn layout(self: *Self, _: *Button.State(Self)) Widget.Layout {
|
||||
|
|
|
@ -654,23 +654,23 @@ const cmds = struct {
|
|||
if (self.input_mode) |*mode| mode.deinit();
|
||||
}
|
||||
|
||||
pub fn enter_find_mode(self: *Self, ctx: Ctx) Result {
|
||||
pub fn find(self: *Self, ctx: Ctx) Result {
|
||||
return enter_mini_mode(self, @import("mode/mini/find.zig"), ctx);
|
||||
}
|
||||
|
||||
pub fn enter_find_in_files_mode(self: *Self, ctx: Ctx) Result {
|
||||
pub fn find_in_files(self: *Self, ctx: Ctx) Result {
|
||||
return enter_mini_mode(self, @import("mode/mini/find_in_files.zig"), ctx);
|
||||
}
|
||||
|
||||
pub fn enter_goto_mode(self: *Self, ctx: Ctx) Result {
|
||||
pub fn goto(self: *Self, ctx: Ctx) Result {
|
||||
return enter_mini_mode(self, @import("mode/mini/goto.zig"), ctx);
|
||||
}
|
||||
|
||||
pub fn enter_move_to_char_mode(self: *Self, ctx: Ctx) Result {
|
||||
pub fn move_to_char(self: *Self, ctx: Ctx) Result {
|
||||
return enter_mini_mode(self, @import("mode/mini/move_to_char.zig"), ctx);
|
||||
}
|
||||
|
||||
pub fn enter_open_file_mode(self: *Self, ctx: Ctx) Result {
|
||||
pub fn open_file(self: *Self, ctx: Ctx) Result {
|
||||
return enter_mini_mode(self, @import("mode/mini/open_file.zig"), ctx);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue