feat: add argument metadata to (most) commands that take parameters
This commit is contained in:
		
							parent
							
								
									ae91afe255
								
							
						
					
					
						commit
						150374afae
					
				
					 14 changed files with 85 additions and 78 deletions
				
			
		| 
						 | 
				
			
			@ -27,7 +27,14 @@ const Vtable = struct {
 | 
			
		|||
 | 
			
		||||
const Metadata = struct {
 | 
			
		||||
    description: []const u8 = &[_]u8{},
 | 
			
		||||
    interactive: bool = true,
 | 
			
		||||
    arguments: []const ArgumentType = &[_]ArgumentType{},
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
pub const ArgumentType = enum {
 | 
			
		||||
    string,
 | 
			
		||||
    integer,
 | 
			
		||||
    float,
 | 
			
		||||
    object,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
pub fn Closure(comptime T: type) type {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1826,7 +1826,7 @@ pub const Editor = struct {
 | 
			
		|||
            return error.InvalidArgument;
 | 
			
		||||
        return self.primary_drag(y, x);
 | 
			
		||||
    }
 | 
			
		||||
    pub const drag_to_meta = .{ .interactive = false };
 | 
			
		||||
    pub const drag_to_meta = .{ .arguments = &.{ .integer, .integer } };
 | 
			
		||||
 | 
			
		||||
    pub fn secondary_click(self: *Self, y: c_int, x: c_int) !void {
 | 
			
		||||
        return self.primary_drag(y, x);
 | 
			
		||||
| 
						 | 
				
			
			@ -1920,7 +1920,7 @@ pub const Editor = struct {
 | 
			
		|||
        else
 | 
			
		||||
            self.scroll_up();
 | 
			
		||||
    }
 | 
			
		||||
    pub const scroll_up_pageup_meta = .{ .interactive = false };
 | 
			
		||||
    pub const scroll_up_pageup_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn scroll_down_pagedown(self: *Self, _: Context) Result {
 | 
			
		||||
        if (self.fast_scroll)
 | 
			
		||||
| 
						 | 
				
			
			@ -1928,7 +1928,7 @@ pub const Editor = struct {
 | 
			
		|||
        else
 | 
			
		||||
            self.scroll_down();
 | 
			
		||||
    }
 | 
			
		||||
    pub const scroll_down_pagedown_meta = .{ .interactive = false };
 | 
			
		||||
    pub const scroll_down_pagedown_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn scroll_to(self: *Self, row: usize) void {
 | 
			
		||||
        self.update_scroll_dest_abs(row);
 | 
			
		||||
| 
						 | 
				
			
			@ -1959,12 +1959,12 @@ pub const Editor = struct {
 | 
			
		|||
    pub fn scroll_view_top(self: *Self, _: Context) Result {
 | 
			
		||||
        return self.scroll_view_offset(scroll_cursor_min_border_distance);
 | 
			
		||||
    }
 | 
			
		||||
    pub const scroll_view_top_meta = .{ .interactive = false };
 | 
			
		||||
    pub const scroll_view_top_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn scroll_view_bottom(self: *Self, _: Context) Result {
 | 
			
		||||
        return self.scroll_view_offset(if (self.view.rows > scroll_cursor_min_border_distance) self.view.rows - scroll_cursor_min_border_distance else 0);
 | 
			
		||||
    }
 | 
			
		||||
    pub const scroll_view_bottom_meta = .{ .interactive = false };
 | 
			
		||||
    pub const scroll_view_bottom_meta = .{};
 | 
			
		||||
 | 
			
		||||
    fn set_clipboard(self: *Self, text: []const u8) void {
 | 
			
		||||
        if (self.clipboard) |old|
 | 
			
		||||
| 
						 | 
				
			
			@ -2317,14 +2317,14 @@ pub const Editor = struct {
 | 
			
		|||
        self.with_cursors_const_arg(root, move_cursor_to_char_left, ctx) catch {};
 | 
			
		||||
        self.clamp();
 | 
			
		||||
    }
 | 
			
		||||
    pub const move_to_char_left_meta = .{ .interactive = false };
 | 
			
		||||
    pub const move_to_char_left_meta = .{ .arguments = &.{.integer} };
 | 
			
		||||
 | 
			
		||||
    pub fn move_to_char_right(self: *Self, ctx: Context) Result {
 | 
			
		||||
        const root = try self.buf_root();
 | 
			
		||||
        self.with_cursors_const_arg(root, move_cursor_to_char_right, ctx) catch {};
 | 
			
		||||
        self.clamp();
 | 
			
		||||
    }
 | 
			
		||||
    pub const move_to_char_right_meta = .{ .interactive = false };
 | 
			
		||||
    pub const move_to_char_right_meta = .{ .arguments = &.{.integer} };
 | 
			
		||||
 | 
			
		||||
    pub fn move_up(self: *Self, _: Context) Result {
 | 
			
		||||
        const root = try self.buf_root();
 | 
			
		||||
| 
						 | 
				
			
			@ -2543,7 +2543,7 @@ pub const Editor = struct {
 | 
			
		|||
        const root = try self.with_cursels_mut(b.root, toggle_cursel_prefix, b.allocator);
 | 
			
		||||
        try self.update_buf(root);
 | 
			
		||||
    }
 | 
			
		||||
    pub const toggle_prefix_meta = .{ .interactive = false };
 | 
			
		||||
    pub const toggle_prefix_meta = .{ .arguments = &.{.string} };
 | 
			
		||||
 | 
			
		||||
    pub fn toggle_comment(self: *Self, _: Context) Result {
 | 
			
		||||
        const comment = if (self.syntax) |syn| syn.file_type.comment else "//";
 | 
			
		||||
| 
						 | 
				
			
			@ -2811,14 +2811,14 @@ pub const Editor = struct {
 | 
			
		|||
        self.with_selections_const_arg(root, move_cursor_to_char_left, ctx) catch {};
 | 
			
		||||
        self.clamp();
 | 
			
		||||
    }
 | 
			
		||||
    pub const select_to_char_left_meta = .{ .interactive = false };
 | 
			
		||||
    pub const select_to_char_left_meta = .{ .arguments = &.{.integer} };
 | 
			
		||||
 | 
			
		||||
    pub fn select_to_char_right(self: *Self, ctx: Context) Result {
 | 
			
		||||
        const root = try self.buf_root();
 | 
			
		||||
        self.with_selections_const_arg(root, move_cursor_to_char_right, ctx) catch {};
 | 
			
		||||
        self.clamp();
 | 
			
		||||
    }
 | 
			
		||||
    pub const select_to_char_right_meta = .{ .interactive = false };
 | 
			
		||||
    pub const select_to_char_right_meta = .{ .arguments = &.{.integer} };
 | 
			
		||||
 | 
			
		||||
    pub fn select_begin(self: *Self, _: Context) Result {
 | 
			
		||||
        const root = try self.buf_root();
 | 
			
		||||
| 
						 | 
				
			
			@ -2936,7 +2936,7 @@ pub const Editor = struct {
 | 
			
		|||
        try self.update_buf(root);
 | 
			
		||||
        self.clamp();
 | 
			
		||||
    }
 | 
			
		||||
    pub const insert_chars_meta = .{ .interactive = false };
 | 
			
		||||
    pub const insert_chars_meta = .{ .arguments = &.{.string} };
 | 
			
		||||
 | 
			
		||||
    pub fn insert_line(self: *Self, _: Context) Result {
 | 
			
		||||
        const b = try self.buf_for_update();
 | 
			
		||||
| 
						 | 
				
			
			@ -3047,7 +3047,7 @@ pub const Editor = struct {
 | 
			
		|||
    pub fn disable_fast_scroll(self: *Self, _: Context) Result {
 | 
			
		||||
        self.fast_scroll = false;
 | 
			
		||||
    }
 | 
			
		||||
    pub const disable_fast_scroll_meta = .{ .interactive = false };
 | 
			
		||||
    pub const disable_fast_scroll_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn enable_jump_mode(self: *Self, _: Context) Result {
 | 
			
		||||
        self.jump_mode = true;
 | 
			
		||||
| 
						 | 
				
			
			@ -3059,7 +3059,7 @@ pub const Editor = struct {
 | 
			
		|||
        self.jump_mode = false;
 | 
			
		||||
        tui.current().rdr.request_mouse_cursor_text(true);
 | 
			
		||||
    }
 | 
			
		||||
    pub const disable_jump_mode_meta = .{ .interactive = false };
 | 
			
		||||
    pub const disable_jump_mode_meta = .{};
 | 
			
		||||
 | 
			
		||||
    fn update_syntax(self: *Self) !void {
 | 
			
		||||
        const root = try self.buf_root();
 | 
			
		||||
| 
						 | 
				
			
			@ -3225,7 +3225,7 @@ pub const Editor = struct {
 | 
			
		|||
            self.clamp();
 | 
			
		||||
        } else return error.InvalidArgument;
 | 
			
		||||
    }
 | 
			
		||||
    pub const open_buffer_from_file_meta = .{ .interactive = false };
 | 
			
		||||
    pub const open_buffer_from_file_meta = .{ .arguments = &.{.string} };
 | 
			
		||||
 | 
			
		||||
    pub fn open_scratch_buffer(self: *Self, ctx: Context) Result {
 | 
			
		||||
        var file_path: []const u8 = undefined;
 | 
			
		||||
| 
						 | 
				
			
			@ -3235,7 +3235,7 @@ pub const Editor = struct {
 | 
			
		|||
            self.clamp();
 | 
			
		||||
        } else return error.InvalidArgument;
 | 
			
		||||
    }
 | 
			
		||||
    pub const open_scratch_buffer_meta = .{ .interactive = false };
 | 
			
		||||
    pub const open_scratch_buffer_meta = .{ .arguments = &.{ .string, .string } };
 | 
			
		||||
 | 
			
		||||
    pub fn save_file(self: *Self, ctx: Context) Result {
 | 
			
		||||
        var then = false;
 | 
			
		||||
| 
						 | 
				
			
			@ -3265,7 +3265,7 @@ pub const Editor = struct {
 | 
			
		|||
            try self.save_as(file_path);
 | 
			
		||||
        } else return error.InvalidArgument;
 | 
			
		||||
    }
 | 
			
		||||
    pub const save_file_as_meta = .{ .interactive = false };
 | 
			
		||||
    pub const save_file_as_meta = .{ .arguments = &.{.string} };
 | 
			
		||||
 | 
			
		||||
    pub fn close_file(self: *Self, _: Context) Result {
 | 
			
		||||
        self.cancel_all_selections();
 | 
			
		||||
| 
						 | 
				
			
			@ -3286,7 +3286,7 @@ pub const Editor = struct {
 | 
			
		|||
            self.clamp();
 | 
			
		||||
        } else return error.InvalidArgument;
 | 
			
		||||
    }
 | 
			
		||||
    pub const find_query_meta = .{ .interactive = false };
 | 
			
		||||
    pub const find_query_meta = .{ .arguments = &.{.string} };
 | 
			
		||||
 | 
			
		||||
    fn find_in(self: *Self, query: []const u8, comptime find_f: ripgrep.FindF, write_buffer: bool) !void {
 | 
			
		||||
        const root = try self.buf_root();
 | 
			
		||||
| 
						 | 
				
			
			@ -3658,7 +3658,7 @@ pub const Editor = struct {
 | 
			
		|||
        self.clamp();
 | 
			
		||||
        try self.send_editor_jump_destination();
 | 
			
		||||
    }
 | 
			
		||||
    pub const goto_line_meta = .{ .interactive = false };
 | 
			
		||||
    pub const goto_line_meta = .{ .arguments = &.{.integer} };
 | 
			
		||||
 | 
			
		||||
    pub fn goto_column(self: *Self, ctx: Context) Result {
 | 
			
		||||
        var column: usize = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -3669,7 +3669,7 @@ pub const Editor = struct {
 | 
			
		|||
        try primary.cursor.move_to(root, primary.cursor.row, @intCast(if (column < 1) 0 else column - 1), self.metrics);
 | 
			
		||||
        self.clamp();
 | 
			
		||||
    }
 | 
			
		||||
    pub const goto_column_meta = .{ .interactive = false };
 | 
			
		||||
    pub const goto_column_meta = .{ .arguments = &.{.integer} };
 | 
			
		||||
 | 
			
		||||
    pub fn goto_line_and_column(self: *Self, ctx: Context) Result {
 | 
			
		||||
        try self.send_editor_jump_source();
 | 
			
		||||
| 
						 | 
				
			
			@ -3710,7 +3710,7 @@ pub const Editor = struct {
 | 
			
		|||
        try self.send_editor_jump_destination();
 | 
			
		||||
        self.need_render();
 | 
			
		||||
    }
 | 
			
		||||
    pub const goto_line_and_column_meta = .{ .interactive = false };
 | 
			
		||||
    pub const goto_line_and_column_meta = .{ .arguments = &.{ .integer, .integer } };
 | 
			
		||||
 | 
			
		||||
    pub fn goto_definition(self: *Self, _: Context) Result {
 | 
			
		||||
        const file_path = self.file_path orelse return;
 | 
			
		||||
| 
						 | 
				
			
			@ -3828,7 +3828,7 @@ pub const Editor = struct {
 | 
			
		|||
            return error.InvalidArgument;
 | 
			
		||||
        self.get_primary().selection = sel;
 | 
			
		||||
    }
 | 
			
		||||
    pub const select_meta = .{ .interactive = false };
 | 
			
		||||
    pub const select_meta = .{ .arguments = &.{ .integer, .integer, .integer, .integer } };
 | 
			
		||||
 | 
			
		||||
    fn get_formatter(self: *Self) ?[]const []const u8 {
 | 
			
		||||
        if (self.syntax) |syn| if (syn.file_type.formatter) |fmtr| if (fmtr.len > 0) return fmtr;
 | 
			
		||||
| 
						 | 
				
			
			@ -3857,7 +3857,7 @@ pub const Editor = struct {
 | 
			
		|||
            return error.InvalidArgument;
 | 
			
		||||
        try self.filter_cmd(ctx.args);
 | 
			
		||||
    }
 | 
			
		||||
    pub const filter_meta = .{ .interactive = false };
 | 
			
		||||
    pub const filter_meta = .{ .arguments = &.{.string} };
 | 
			
		||||
 | 
			
		||||
    fn filter_cmd(self: *Self, cmd: tp.message) !void {
 | 
			
		||||
        if (self.filter) |_| return error.Stop;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -298,5 +298,5 @@ const cmds = struct {
 | 
			
		|||
        if (self.menu.selected == null) return tp.exit_error(error.NoSelectedFile, @errorReturnTrace());
 | 
			
		||||
        self.menu.activate_selected();
 | 
			
		||||
    }
 | 
			
		||||
    pub const goto_selected_file_meta = .{ .interactive = false };
 | 
			
		||||
    pub const goto_selected_file_meta = .{};
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -202,17 +202,17 @@ const cmds = struct {
 | 
			
		|||
    pub fn home_menu_down(self: *Self, _: Ctx) Result {
 | 
			
		||||
        self.menu.select_down();
 | 
			
		||||
    }
 | 
			
		||||
    pub const home_menu_down_meta = .{ .interactive = false };
 | 
			
		||||
    pub const home_menu_down_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn home_menu_up(self: *Self, _: Ctx) Result {
 | 
			
		||||
        self.menu.select_up();
 | 
			
		||||
    }
 | 
			
		||||
    pub const home_menu_up_meta = .{ .interactive = false };
 | 
			
		||||
    pub const home_menu_up_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn home_menu_activate(self: *Self, _: Ctx) Result {
 | 
			
		||||
        self.menu.activate_selected();
 | 
			
		||||
    }
 | 
			
		||||
    pub const home_menu_activate_meta = .{ .interactive = false };
 | 
			
		||||
    pub const home_menu_activate_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn home_sheeran(self: *Self, _: Ctx) Result {
 | 
			
		||||
        self.fire = if (self.fire) |*fire| ret: {
 | 
			
		||||
| 
						 | 
				
			
			@ -220,7 +220,7 @@ const cmds = struct {
 | 
			
		|||
            break :ret null;
 | 
			
		||||
        } else try Fire.init(self.allocator, self.plane);
 | 
			
		||||
    }
 | 
			
		||||
    pub const home_sheeran_meta = .{ .interactive = false };
 | 
			
		||||
    pub const home_sheeran_meta = .{};
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const Fire = struct {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -237,7 +237,7 @@ const cmds = struct {
 | 
			
		|||
        if (self.top_bar) |bar| _ = try bar.msg(.{ "PRJ", "open" });
 | 
			
		||||
        if (self.bottom_bar) |bar| _ = try bar.msg(.{ "PRJ", "open" });
 | 
			
		||||
    }
 | 
			
		||||
    pub const open_project_cwd_meta = .{ .interactive = false };
 | 
			
		||||
    pub const open_project_cwd_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn open_project_dir(self: *Self, ctx: Ctx) Result {
 | 
			
		||||
        var project_dir: []const u8 = undefined;
 | 
			
		||||
| 
						 | 
				
			
			@ -249,7 +249,7 @@ const cmds = struct {
 | 
			
		|||
        if (self.top_bar) |bar| _ = try bar.msg(.{ "PRJ", "open" });
 | 
			
		||||
        if (self.bottom_bar) |bar| _ = try bar.msg(.{ "PRJ", "open" });
 | 
			
		||||
    }
 | 
			
		||||
    pub const open_project_dir_meta = .{ .interactive = false };
 | 
			
		||||
    pub const open_project_dir_meta = .{ .arguments = &.{.string} };
 | 
			
		||||
 | 
			
		||||
    pub fn change_project(self: *Self, ctx: Ctx) Result {
 | 
			
		||||
        var project_dir: []const u8 = undefined;
 | 
			
		||||
| 
						 | 
				
			
			@ -275,7 +275,7 @@ const cmds = struct {
 | 
			
		|||
        if (try project_manager.request_most_recent_file(self.allocator)) |file_path|
 | 
			
		||||
            self.show_file_async_and_free(file_path);
 | 
			
		||||
    }
 | 
			
		||||
    pub const change_project_meta = .{ .interactive = false };
 | 
			
		||||
    pub const change_project_meta = .{ .arguments = &.{.string} };
 | 
			
		||||
 | 
			
		||||
    pub fn navigate(self: *Self, ctx: Ctx) Result {
 | 
			
		||||
        tui.reset_drag_context();
 | 
			
		||||
| 
						 | 
				
			
			@ -346,7 +346,7 @@ const cmds = struct {
 | 
			
		|||
        }
 | 
			
		||||
        tui.need_render();
 | 
			
		||||
    }
 | 
			
		||||
    pub const navigate_meta = .{ .interactive = false };
 | 
			
		||||
    pub const navigate_meta = .{ .arguments = &.{.object} };
 | 
			
		||||
 | 
			
		||||
    pub fn open_help(self: *Self, _: Ctx) Result {
 | 
			
		||||
        tui.reset_drag_context();
 | 
			
		||||
| 
						 | 
				
			
			@ -370,7 +370,7 @@ const cmds = struct {
 | 
			
		|||
        try self.read_restore_info();
 | 
			
		||||
        tui.need_render();
 | 
			
		||||
    }
 | 
			
		||||
    pub const restore_session_meta = .{ .interactive = false };
 | 
			
		||||
    pub const restore_session_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn toggle_panel(self: *Self, _: Ctx) Result {
 | 
			
		||||
        if (self.is_panel_view_showing(logview))
 | 
			
		||||
| 
						 | 
				
			
			@ -387,7 +387,7 @@ const cmds = struct {
 | 
			
		|||
    pub fn toggle_logview(self: *Self, _: Ctx) Result {
 | 
			
		||||
        try self.toggle_panel_view(logview, false);
 | 
			
		||||
    }
 | 
			
		||||
    pub const toggle_logview_meta = .{ .interactive = false };
 | 
			
		||||
    pub const toggle_logview_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn show_logview(self: *Self, _: Ctx) Result {
 | 
			
		||||
        try self.toggle_panel_view(logview, true);
 | 
			
		||||
| 
						 | 
				
			
			@ -407,7 +407,7 @@ const cmds = struct {
 | 
			
		|||
    pub fn show_inspector_view(self: *Self, _: Ctx) Result {
 | 
			
		||||
        try self.toggle_panel_view(@import("inspector_view.zig"), true);
 | 
			
		||||
    }
 | 
			
		||||
    pub const show_inspector_view_meta = .{ .interactive = false };
 | 
			
		||||
    pub const show_inspector_view_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn jump_back(self: *Self, _: Ctx) Result {
 | 
			
		||||
        try self.location_history.back(location_jump);
 | 
			
		||||
| 
						 | 
				
			
			@ -422,7 +422,7 @@ const cmds = struct {
 | 
			
		|||
    pub fn show_home(self: *Self, _: Ctx) Result {
 | 
			
		||||
        return self.create_home();
 | 
			
		||||
    }
 | 
			
		||||
    pub const show_home_meta = .{ .interactive = false };
 | 
			
		||||
    pub const show_home_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn gutter_mode_next(self: *Self, _: Ctx) Result {
 | 
			
		||||
        const tui_ = tui.current();
 | 
			
		||||
| 
						 | 
				
			
			@ -506,7 +506,7 @@ const cmds = struct {
 | 
			
		|||
                ed.Diagnostic.to_severity(severity),
 | 
			
		||||
            );
 | 
			
		||||
    }
 | 
			
		||||
    pub const add_diagnostic_meta = .{ .interactive = false };
 | 
			
		||||
    pub const add_diagnostic_meta = .{ .arguments = &.{ .string, .string, .string, .string, .integer, .integer, .integer, .integer, .integer } };
 | 
			
		||||
 | 
			
		||||
    pub fn clear_diagnostics(self: *Self, ctx: Ctx) Result {
 | 
			
		||||
        var file_path: []const u8 = undefined;
 | 
			
		||||
| 
						 | 
				
			
			@ -519,7 +519,7 @@ const cmds = struct {
 | 
			
		|||
        if (self.file_list_type == .diagnostics and self.is_panel_view_showing(filelist_view))
 | 
			
		||||
            try self.toggle_panel_view(filelist_view, false);
 | 
			
		||||
    }
 | 
			
		||||
    pub const clear_diagnostics_meta = .{ .interactive = false };
 | 
			
		||||
    pub const clear_diagnostics_meta = .{ .arguments = &.{.string} };
 | 
			
		||||
 | 
			
		||||
    pub fn show_diagnostics(self: *Self, _: Ctx) Result {
 | 
			
		||||
        const editor = self.editor orelse return;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -315,7 +315,7 @@ pub fn Create(options: type) type {
 | 
			
		|||
                try self.file_path.appendSlice(buf[0..bytes]);
 | 
			
		||||
                self.update_mini_mode_text();
 | 
			
		||||
            }
 | 
			
		||||
            pub const mini_mode_insert_code_point_meta = .{ .interactive = false };
 | 
			
		||||
            pub const mini_mode_insert_code_point_meta = .{ .arguments = &.{.integer} };
 | 
			
		||||
 | 
			
		||||
            pub fn mini_mode_insert_bytes(self: *Self, ctx: Ctx) Result {
 | 
			
		||||
                var bytes: []const u8 = undefined;
 | 
			
		||||
| 
						 | 
				
			
			@ -325,7 +325,7 @@ pub fn Create(options: type) type {
 | 
			
		|||
                try self.file_path.appendSlice(bytes);
 | 
			
		||||
                self.update_mini_mode_text();
 | 
			
		||||
            }
 | 
			
		||||
            pub const mini_mode_insert_bytes_meta = .{ .interactive = false };
 | 
			
		||||
            pub const mini_mode_insert_bytes_meta = .{ .arguments = &.{.string} };
 | 
			
		||||
 | 
			
		||||
            pub fn mini_mode_select(self: *Self, _: Ctx) Result {
 | 
			
		||||
                options.select(self);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -186,7 +186,7 @@ const cmds = struct {
 | 
			
		|||
        self.insert_code_point(egc) catch |e| return tp.exit_error(e, @errorReturnTrace());
 | 
			
		||||
        self.update_mini_mode_text();
 | 
			
		||||
    }
 | 
			
		||||
    pub const mini_mode_insert_code_point_meta = .{ .interactive = false };
 | 
			
		||||
    pub const mini_mode_insert_code_point_meta = .{ .arguments = &.{.integer} };
 | 
			
		||||
 | 
			
		||||
    pub fn mini_mode_insert_bytes(self: *Self, ctx: Ctx) Result {
 | 
			
		||||
        var bytes: []const u8 = undefined;
 | 
			
		||||
| 
						 | 
				
			
			@ -195,7 +195,7 @@ const cmds = struct {
 | 
			
		|||
        self.insert_bytes(bytes) catch |e| return tp.exit_error(e, @errorReturnTrace());
 | 
			
		||||
        self.update_mini_mode_text();
 | 
			
		||||
    }
 | 
			
		||||
    pub const mini_mode_insert_bytes_meta = .{ .interactive = false };
 | 
			
		||||
    pub const mini_mode_insert_bytes_meta = .{ .arguments = &.{.string} };
 | 
			
		||||
 | 
			
		||||
    pub fn mini_mode_delete_backwards(self: *Self, _: Ctx) Result {
 | 
			
		||||
        _ = self.input.popOrNull();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -135,7 +135,7 @@ const cmds = struct {
 | 
			
		|||
        self.insert_code_point(egc) catch |e| return tp.exit_error(e, @errorReturnTrace());
 | 
			
		||||
        self.update_mini_mode_text();
 | 
			
		||||
    }
 | 
			
		||||
    pub const mini_mode_insert_code_point_meta = .{ .interactive = false };
 | 
			
		||||
    pub const mini_mode_insert_code_point_meta = .{ .arguments = &.{.integer} };
 | 
			
		||||
 | 
			
		||||
    pub fn mini_mode_insert_bytes(self: *Self, ctx: Ctx) Result {
 | 
			
		||||
        var bytes: []const u8 = undefined;
 | 
			
		||||
| 
						 | 
				
			
			@ -144,7 +144,7 @@ const cmds = struct {
 | 
			
		|||
        self.insert_bytes(bytes) catch |e| return tp.exit_error(e, @errorReturnTrace());
 | 
			
		||||
        self.update_mini_mode_text();
 | 
			
		||||
    }
 | 
			
		||||
    pub const mini_mode_insert_bytes_meta = .{ .interactive = false };
 | 
			
		||||
    pub const mini_mode_insert_bytes_meta = .{ .arguments = &.{.string} };
 | 
			
		||||
 | 
			
		||||
    pub fn mini_mode_delete_backwards(self: *Self, _: Ctx) Result {
 | 
			
		||||
        if (self.input.len > 0) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -130,7 +130,7 @@ const cmds = struct {
 | 
			
		|||
        self.update_mini_mode_text();
 | 
			
		||||
        self.goto();
 | 
			
		||||
    }
 | 
			
		||||
    pub const mini_mode_insert_code_point_meta = .{ .interactive = false };
 | 
			
		||||
    pub const mini_mode_insert_code_point_meta = .{ .arguments = &.{.integer} };
 | 
			
		||||
 | 
			
		||||
    pub fn mini_mode_insert_bytes(self: *Self, ctx: Ctx) Result {
 | 
			
		||||
        var bytes: []const u8 = undefined;
 | 
			
		||||
| 
						 | 
				
			
			@ -140,5 +140,5 @@ const cmds = struct {
 | 
			
		|||
        self.update_mini_mode_text();
 | 
			
		||||
        self.goto();
 | 
			
		||||
    }
 | 
			
		||||
    pub const mini_mode_insert_bytes_meta = .{ .interactive = false };
 | 
			
		||||
    pub const mini_mode_insert_bytes_meta = .{ .arguments = &.{.string} };
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -106,7 +106,7 @@ const cmds = struct {
 | 
			
		|||
        const bytes = input.ucs32_to_utf8(&[_]u32{code_point}, &buf) catch return error.InvalidArgument;
 | 
			
		||||
        return self.execute_operation(command.fmt(.{buf[0..bytes]}));
 | 
			
		||||
    }
 | 
			
		||||
    pub const mini_mode_insert_code_point_meta = .{ .interactive = false };
 | 
			
		||||
    pub const mini_mode_insert_code_point_meta = .{ .arguments = &.{.integer} };
 | 
			
		||||
 | 
			
		||||
    pub fn mini_mode_insert_bytes(self: *Self, ctx: Ctx) Result {
 | 
			
		||||
        var bytes: []const u8 = undefined;
 | 
			
		||||
| 
						 | 
				
			
			@ -114,7 +114,7 @@ const cmds = struct {
 | 
			
		|||
            return error.InvalidArgument;
 | 
			
		||||
        return self.execute_operation(ctx);
 | 
			
		||||
    }
 | 
			
		||||
    pub const mini_mode_insert_bytes_meta = .{ .interactive = false };
 | 
			
		||||
    pub const mini_mode_insert_bytes_meta = .{ .arguments = &.{.string} };
 | 
			
		||||
 | 
			
		||||
    pub fn mini_mode_cancel(_: *Self, _: Ctx) Result {
 | 
			
		||||
        command.executeName("exit_mini_mode", .{}) catch {};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,7 @@ pub const Entry = struct {
 | 
			
		|||
 | 
			
		||||
pub fn load_entries(palette: *Type) !void {
 | 
			
		||||
    for (command.commands.items) |cmd_| if (cmd_) |p| {
 | 
			
		||||
        if (p.meta.interactive)
 | 
			
		||||
        if (p.meta.description.len > 0)
 | 
			
		||||
            (try palette.entries.addOne()).* = .{
 | 
			
		||||
                .label = if (p.meta.description.len > 0) p.meta.description else p.name,
 | 
			
		||||
                .name = p.name,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -277,27 +277,27 @@ const cmds = struct {
 | 
			
		|||
    pub fn palette_menu_down(self: *Self, _: Ctx) Result {
 | 
			
		||||
        self.menu.select_down();
 | 
			
		||||
    }
 | 
			
		||||
    pub const palette_menu_down_meta = .{ .interactive = false };
 | 
			
		||||
    pub const palette_menu_down_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn palette_menu_up(self: *Self, _: Ctx) Result {
 | 
			
		||||
        self.menu.select_up();
 | 
			
		||||
    }
 | 
			
		||||
    pub const palette_menu_up_meta = .{ .interactive = false };
 | 
			
		||||
    pub const palette_menu_up_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn palette_menu_activate(self: *Self, _: Ctx) Result {
 | 
			
		||||
        self.menu.activate_selected();
 | 
			
		||||
    }
 | 
			
		||||
    pub const palette_menu_activate_meta = .{ .interactive = false };
 | 
			
		||||
    pub const palette_menu_activate_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn palette_menu_activate_quick(self: *Self, _: Ctx) Result {
 | 
			
		||||
        if (self.menu.selected orelse 0 > 0) self.menu.activate_selected();
 | 
			
		||||
    }
 | 
			
		||||
    pub const palette_menu_activate_quick_meta = .{ .interactive = false };
 | 
			
		||||
    pub const palette_menu_activate_quick_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn palette_menu_cancel(self: *Self, _: Ctx) Result {
 | 
			
		||||
        try self.cmd("exit_overlay_mode", .{});
 | 
			
		||||
    }
 | 
			
		||||
    pub const palette_menu_cancel_meta = .{ .interactive = false };
 | 
			
		||||
    pub const palette_menu_cancel_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn overlay_delete_word_left(self: *Self, _: Ctx) Result {
 | 
			
		||||
        self.delete_word() catch |e| return tp.exit_error(e, @errorReturnTrace());
 | 
			
		||||
| 
						 | 
				
			
			@ -315,7 +315,7 @@ const cmds = struct {
 | 
			
		|||
            return error.InvalidArgument;
 | 
			
		||||
        self.insert_code_point(egc) catch |e| return tp.exit_error(e, @errorReturnTrace());
 | 
			
		||||
    }
 | 
			
		||||
    pub const overlay_insert_code_point_meta = .{ .interactive = false };
 | 
			
		||||
    pub const overlay_insert_code_point_meta = .{ .arguments = &.{.integer} };
 | 
			
		||||
 | 
			
		||||
    pub fn overlay_insert_bytes(self: *Self, ctx: Ctx) Result {
 | 
			
		||||
        var bytes: []const u8 = undefined;
 | 
			
		||||
| 
						 | 
				
			
			@ -323,20 +323,20 @@ const cmds = struct {
 | 
			
		|||
            return error.InvalidArgument;
 | 
			
		||||
        self.insert_bytes(bytes) catch |e| return tp.exit_error(e, @errorReturnTrace());
 | 
			
		||||
    }
 | 
			
		||||
    pub const overlay_insert_bytes_meta = .{ .interactive = false };
 | 
			
		||||
    pub const overlay_insert_bytes_meta = .{ .arguments = &.{.string} };
 | 
			
		||||
 | 
			
		||||
    pub fn overlay_release_control(self: *Self, _: Ctx) Result {
 | 
			
		||||
        if (self.menu.selected orelse 0 > 0) return self.cmd("palette_menu_activate", .{});
 | 
			
		||||
    }
 | 
			
		||||
    pub const overlay_release_control_meta = .{ .interactive = false };
 | 
			
		||||
    pub const overlay_release_control_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn overlay_toggle_panel(self: *Self, _: Ctx) Result {
 | 
			
		||||
        return self.cmd_async("toggle_panel");
 | 
			
		||||
    }
 | 
			
		||||
    pub const overlay_toggle_panel_meta = .{ .interactive = false };
 | 
			
		||||
    pub const overlay_toggle_panel_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn overlay_toggle_inputview(self: *Self, _: Ctx) Result {
 | 
			
		||||
        return self.cmd_async("toggle_inputview");
 | 
			
		||||
    }
 | 
			
		||||
    pub const overlay_toggle_inputview_meta = .{ .interactive = false };
 | 
			
		||||
    pub const overlay_toggle_inputview_meta = .{};
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -368,7 +368,7 @@ pub fn Create(options: type) type {
 | 
			
		|||
                self.menu.select_down();
 | 
			
		||||
                self.selection_updated();
 | 
			
		||||
            }
 | 
			
		||||
            pub const palette_menu_down_meta = .{ .interactive = false };
 | 
			
		||||
            pub const palette_menu_down_meta = .{};
 | 
			
		||||
 | 
			
		||||
            pub fn palette_menu_up(self: *Self, _: Ctx) Result {
 | 
			
		||||
                if (self.menu.selected) |selected| {
 | 
			
		||||
| 
						 | 
				
			
			@ -383,7 +383,7 @@ pub fn Create(options: type) type {
 | 
			
		|||
                self.menu.select_up();
 | 
			
		||||
                self.selection_updated();
 | 
			
		||||
            }
 | 
			
		||||
            pub const palette_menu_up_meta = .{ .interactive = false };
 | 
			
		||||
            pub const palette_menu_up_meta = .{};
 | 
			
		||||
 | 
			
		||||
            pub fn palette_menu_pagedown(self: *Self, _: Ctx) Result {
 | 
			
		||||
                if (self.total_items > self.view_rows) {
 | 
			
		||||
| 
						 | 
				
			
			@ -395,7 +395,7 @@ pub fn Create(options: type) type {
 | 
			
		|||
                self.menu.select_last();
 | 
			
		||||
                self.selection_updated();
 | 
			
		||||
            }
 | 
			
		||||
            pub const palette_menu_pagedown_meta = .{ .interactive = false };
 | 
			
		||||
            pub const palette_menu_pagedown_meta = .{};
 | 
			
		||||
 | 
			
		||||
            pub fn palette_menu_pageup(self: *Self, _: Ctx) Result {
 | 
			
		||||
                if (self.view_pos > self.view_rows)
 | 
			
		||||
| 
						 | 
				
			
			@ -406,23 +406,23 @@ pub fn Create(options: type) type {
 | 
			
		|||
                self.menu.select_first();
 | 
			
		||||
                self.selection_updated();
 | 
			
		||||
            }
 | 
			
		||||
            pub const palette_menu_pageup_meta = .{ .interactive = false };
 | 
			
		||||
            pub const palette_menu_pageup_meta = .{};
 | 
			
		||||
 | 
			
		||||
            pub fn palette_menu_activate(self: *Self, _: Ctx) Result {
 | 
			
		||||
                self.menu.activate_selected();
 | 
			
		||||
            }
 | 
			
		||||
            pub const palette_menu_activate_meta = .{ .interactive = false };
 | 
			
		||||
            pub const palette_menu_activate_meta = .{};
 | 
			
		||||
 | 
			
		||||
            pub fn palette_menu_activate_quick(self: *Self, _: Ctx) Result {
 | 
			
		||||
                if (self.menu.selected orelse 0 > 0) self.menu.activate_selected();
 | 
			
		||||
            }
 | 
			
		||||
            pub const palette_menu_activate_quick_meta = .{ .interactive = false };
 | 
			
		||||
            pub const palette_menu_activate_quick_meta = .{};
 | 
			
		||||
 | 
			
		||||
            pub fn palette_menu_cancel(self: *Self, _: Ctx) Result {
 | 
			
		||||
                if (@hasDecl(options, "cancel")) try options.cancel(self);
 | 
			
		||||
                try self.cmd("exit_overlay_mode", .{});
 | 
			
		||||
            }
 | 
			
		||||
            pub const palette_menu_cancel_meta = .{ .interactive = false };
 | 
			
		||||
            pub const palette_menu_cancel_meta = .{};
 | 
			
		||||
 | 
			
		||||
            pub fn overlay_delete_word_left(self: *Self, _: Ctx) Result {
 | 
			
		||||
                self.delete_word() catch |e| return tp.exit_error(e, @errorReturnTrace());
 | 
			
		||||
| 
						 | 
				
			
			@ -440,7 +440,7 @@ pub fn Create(options: type) type {
 | 
			
		|||
                    return error.InvalidArgument;
 | 
			
		||||
                self.insert_code_point(egc) catch |e| return tp.exit_error(e, @errorReturnTrace());
 | 
			
		||||
            }
 | 
			
		||||
            pub const overlay_insert_code_point_meta = .{ .interactive = false };
 | 
			
		||||
            pub const overlay_insert_code_point_meta = .{ .arguments = &.{.integer} };
 | 
			
		||||
 | 
			
		||||
            pub fn overlay_insert_bytes(self: *Self, ctx: Ctx) Result {
 | 
			
		||||
                var bytes: []const u8 = undefined;
 | 
			
		||||
| 
						 | 
				
			
			@ -448,22 +448,22 @@ pub fn Create(options: type) type {
 | 
			
		|||
                    return error.InvalidArgument;
 | 
			
		||||
                self.insert_bytes(bytes) catch |e| return tp.exit_error(e, @errorReturnTrace());
 | 
			
		||||
            }
 | 
			
		||||
            pub const overlay_insert_bytes_meta = .{ .interactive = false };
 | 
			
		||||
            pub const overlay_insert_bytes_meta = .{ .arguments = &.{.string} };
 | 
			
		||||
 | 
			
		||||
            pub fn overlay_release_control(self: *Self, _: Ctx) Result {
 | 
			
		||||
                if (self.menu.selected orelse 0 > 0) return self.cmd("palette_menu_activate", .{});
 | 
			
		||||
            }
 | 
			
		||||
            pub const overlay_release_control_meta = .{ .interactive = false };
 | 
			
		||||
            pub const overlay_release_control_meta = .{};
 | 
			
		||||
 | 
			
		||||
            pub fn overlay_toggle_panel(self: *Self, _: Ctx) Result {
 | 
			
		||||
                return self.cmd_async("toggle_panel");
 | 
			
		||||
            }
 | 
			
		||||
            pub const overlay_toggle_panel_meta = .{ .interactive = false };
 | 
			
		||||
            pub const overlay_toggle_panel_meta = .{};
 | 
			
		||||
 | 
			
		||||
            pub fn overlay_toggle_inputview(self: *Self, _: Ctx) Result {
 | 
			
		||||
                return self.cmd_async("toggle_inputview");
 | 
			
		||||
            }
 | 
			
		||||
            pub const overlay_toggle_inputview_meta = .{ .interactive = false };
 | 
			
		||||
            pub const overlay_toggle_inputview_meta = .{};
 | 
			
		||||
        };
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -620,7 +620,7 @@ const cmds = struct {
 | 
			
		|||
        self.logger.print("theme: {s}", .{self.theme.description});
 | 
			
		||||
        try self.save_config();
 | 
			
		||||
    }
 | 
			
		||||
    pub const set_theme_meta = .{ .interactive = false };
 | 
			
		||||
    pub const set_theme_meta = .{ .arguments = &.{.string} };
 | 
			
		||||
 | 
			
		||||
    pub fn theme_next(self: *Self, _: Ctx) Result {
 | 
			
		||||
        self.theme = get_next_theme_by_name(self.theme.name);
 | 
			
		||||
| 
						 | 
				
			
			@ -724,17 +724,17 @@ const cmds = struct {
 | 
			
		|||
        };
 | 
			
		||||
        // self.logger.print("input mode: {s}", .{(self.input_mode orelse return).description});
 | 
			
		||||
    }
 | 
			
		||||
    pub const enter_mode_meta = .{ .interactive = false };
 | 
			
		||||
    pub const enter_mode_meta = .{ .arguments = &.{.string} };
 | 
			
		||||
 | 
			
		||||
    pub fn enter_mode_default(self: *Self, _: Ctx) Result {
 | 
			
		||||
        return enter_mode(self, Ctx.fmt(.{self.config.input_mode}));
 | 
			
		||||
    }
 | 
			
		||||
    pub const enter_mode_default_meta = .{ .interactive = false };
 | 
			
		||||
    pub const enter_mode_default_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn open_command_palette(self: *Self, _: Ctx) Result {
 | 
			
		||||
        return self.enter_overlay_mode(@import("mode/overlay/command_palette.zig").Type);
 | 
			
		||||
    }
 | 
			
		||||
    pub const open_command_palette_meta = .{ .interactive = false };
 | 
			
		||||
    pub const open_command_palette_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn open_recent(self: *Self, _: Ctx) Result {
 | 
			
		||||
        return self.enter_overlay_mode(@import("mode/overlay/open_recent.zig"));
 | 
			
		||||
| 
						 | 
				
			
			@ -758,7 +758,7 @@ const cmds = struct {
 | 
			
		|||
        self.input_mode_outer = null;
 | 
			
		||||
        self.refresh_hover();
 | 
			
		||||
    }
 | 
			
		||||
    pub const exit_overlay_mode_meta = .{ .interactive = false };
 | 
			
		||||
    pub const exit_overlay_mode_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn find(self: *Self, ctx: Ctx) Result {
 | 
			
		||||
        return enter_mini_mode(self, @import("mode/mini/find.zig"), ctx);
 | 
			
		||||
| 
						 | 
				
			
			@ -807,7 +807,7 @@ const cmds = struct {
 | 
			
		|||
        self.input_mode_outer = null;
 | 
			
		||||
        self.mini_mode = null;
 | 
			
		||||
    }
 | 
			
		||||
    pub const exit_mini_mode_meta = .{ .interactive = false };
 | 
			
		||||
    pub const exit_mini_mode_meta = .{};
 | 
			
		||||
 | 
			
		||||
    pub fn open_keybind_config(self: *Self, _: Ctx) Result {
 | 
			
		||||
        var mode_parts = std.mem.splitScalar(u8, self.config.input_mode, '/');
 | 
			
		||||
| 
						 | 
				
			
			@ -857,7 +857,7 @@ const cmds = struct {
 | 
			
		|||
        }
 | 
			
		||||
        try tp.self_pid().send_raw(.{ .buf = msg_cb.items });
 | 
			
		||||
    }
 | 
			
		||||
    pub const run_async_meta = .{ .interactive = false };
 | 
			
		||||
    pub const run_async_meta = .{};
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
pub const MiniMode = struct {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue