Merge branch 'zig-0.13'
This commit is contained in:
		
						commit
						a1d6c1b2e8
					
				
					 7 changed files with 93 additions and 88 deletions
				
			
		| 
						 | 
				
			
			@ -27,29 +27,37 @@ input_namespace: []const u8,
 | 
			
		|||
const Self = @This();
 | 
			
		||||
 | 
			
		||||
const menu_commands = if (build_options.gui) &[_][]const u8{
 | 
			
		||||
    "open_help",
 | 
			
		||||
    "find_file",
 | 
			
		||||
    "create_new_file",
 | 
			
		||||
    "open_file",
 | 
			
		||||
    "open_recent",
 | 
			
		||||
    "open_recent_project",
 | 
			
		||||
    "find_in_files",
 | 
			
		||||
    "open_command_palette",
 | 
			
		||||
    "select_task",
 | 
			
		||||
    "add_task",
 | 
			
		||||
    "open_config",
 | 
			
		||||
    "open_gui_config",
 | 
			
		||||
    "change_fontface",
 | 
			
		||||
    "open_keybind_config",
 | 
			
		||||
    "toggle_input_mode",
 | 
			
		||||
    "change_theme",
 | 
			
		||||
    "change_fontface",
 | 
			
		||||
    "open_help",
 | 
			
		||||
    "open_version_info",
 | 
			
		||||
    "quit",
 | 
			
		||||
} else &[_][]const u8{
 | 
			
		||||
    "open_help",
 | 
			
		||||
    "find_file",
 | 
			
		||||
    "create_new_file",
 | 
			
		||||
    "open_file",
 | 
			
		||||
    "open_recent",
 | 
			
		||||
    "open_recent_project",
 | 
			
		||||
    "find_in_files",
 | 
			
		||||
    "open_command_palette",
 | 
			
		||||
    "select_task",
 | 
			
		||||
    "add_task",
 | 
			
		||||
    "open_config",
 | 
			
		||||
    "open_keybind_config",
 | 
			
		||||
    "toggle_input_mode",
 | 
			
		||||
    "change_theme",
 | 
			
		||||
    "open_help",
 | 
			
		||||
    "open_version_info",
 | 
			
		||||
    "quit",
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -240,7 +240,7 @@ const cmds = struct {
 | 
			
		|||
        try self.check_all_not_dirty();
 | 
			
		||||
        try tp.self_pid().send("quit");
 | 
			
		||||
    }
 | 
			
		||||
    pub const quit_meta: Meta = .{ .description = "Quit (exit) Flow Control" };
 | 
			
		||||
    pub const quit_meta: Meta = .{ .description = "Quit" };
 | 
			
		||||
 | 
			
		||||
    pub fn quit_without_saving(_: *Self, _: Ctx) Result {
 | 
			
		||||
        try tp.self_pid().send("quit");
 | 
			
		||||
| 
						 | 
				
			
			@ -399,19 +399,19 @@ const cmds = struct {
 | 
			
		|||
        try command.executeName("open_scratch_buffer", command.fmt(.{ "version", root.version_info, "diff" }));
 | 
			
		||||
        tui.need_render();
 | 
			
		||||
    }
 | 
			
		||||
    pub const open_version_info_meta: Meta = .{ .description = "Show build version information" };
 | 
			
		||||
    pub const open_version_info_meta: Meta = .{ .description = "Version" };
 | 
			
		||||
 | 
			
		||||
    pub fn open_config(_: *Self, _: Ctx) Result {
 | 
			
		||||
        const file_name = try root.get_config_file_name(@import("config"));
 | 
			
		||||
        try tp.self_pid().send(.{ "cmd", "navigate", .{ .file = file_name[0 .. file_name.len - 5] } });
 | 
			
		||||
    }
 | 
			
		||||
    pub const open_config_meta: Meta = .{ .description = "Edit configuration file" };
 | 
			
		||||
    pub const open_config_meta: Meta = .{ .description = "Edit configuration" };
 | 
			
		||||
 | 
			
		||||
    pub fn open_gui_config(_: *Self, _: Ctx) Result {
 | 
			
		||||
        const file_name = try root.get_config_file_name(@import("gui_config"));
 | 
			
		||||
        try tp.self_pid().send(.{ "cmd", "navigate", .{ .file = file_name[0 .. file_name.len - ".json".len] } });
 | 
			
		||||
    }
 | 
			
		||||
    pub const open_gui_config_meta: Meta = .{ .description = "Edit gui configuration file" };
 | 
			
		||||
    pub const open_gui_config_meta: Meta = .{ .description = "Edit gui configuration" };
 | 
			
		||||
 | 
			
		||||
    pub fn open_tabs_style_config(self: *Self, _: Ctx) Result {
 | 
			
		||||
        const Style = @import("status/tabs.zig").Style;
 | 
			
		||||
| 
						 | 
				
			
			@ -433,7 +433,7 @@ const cmds = struct {
 | 
			
		|||
        }));
 | 
			
		||||
        if (self.get_active_buffer()) |buffer| buffer.mark_not_ephemeral();
 | 
			
		||||
    }
 | 
			
		||||
    pub const open_tabs_style_config_meta: Meta = .{ .description = "Edit tab styles configuration file" };
 | 
			
		||||
    pub const open_tabs_style_config_meta: Meta = .{ .description = "Edit tab style" };
 | 
			
		||||
 | 
			
		||||
    pub fn create_scratch_buffer(self: *Self, ctx: Ctx) Result {
 | 
			
		||||
        const args = try ctx.args.clone(self.allocator);
 | 
			
		||||
| 
						 | 
				
			
			@ -463,7 +463,7 @@ const cmds = struct {
 | 
			
		|||
        if (tp.env.get().str("language").len == 0)
 | 
			
		||||
            try command.executeName("change_file_type", .{});
 | 
			
		||||
    }
 | 
			
		||||
    pub const create_new_file_meta: Meta = .{ .description = "Create: New File…" };
 | 
			
		||||
    pub const create_new_file_meta: Meta = .{ .description = "New file" };
 | 
			
		||||
 | 
			
		||||
    pub fn delete_buffer(self: *Self, ctx: Ctx) Result {
 | 
			
		||||
        var file_path: []const u8 = undefined;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -676,11 +676,12 @@ const cmds = struct {
 | 
			
		|||
    const Ctx = command.Context;
 | 
			
		||||
    const Meta = command.Metadata;
 | 
			
		||||
    const Result = command.Result;
 | 
			
		||||
    const Meta = command.Metadata;
 | 
			
		||||
 | 
			
		||||
    pub fn restart(_: *Self, _: Ctx) Result {
 | 
			
		||||
        try tp.self_pid().send("restart");
 | 
			
		||||
    }
 | 
			
		||||
    pub const restart_meta: Meta = .{ .description = "Restart flow (without saving)" };
 | 
			
		||||
    pub const restart_meta: Meta = .{ .description = "Restart (without saving)" };
 | 
			
		||||
 | 
			
		||||
    pub fn force_terminate(self: *Self, _: Ctx) Result {
 | 
			
		||||
        self.deinit();
 | 
			
		||||
| 
						 | 
				
			
			@ -711,7 +712,7 @@ const cmds = struct {
 | 
			
		|||
        self.logger.print("theme: {s}", .{self.theme_.description});
 | 
			
		||||
        try save_config();
 | 
			
		||||
    }
 | 
			
		||||
    pub const theme_next_meta: Meta = .{ .description = "Switch to next color theme" };
 | 
			
		||||
    pub const theme_next_meta: Meta = .{ .description = "Next color theme" };
 | 
			
		||||
 | 
			
		||||
    pub fn theme_prev(self: *Self, _: Ctx) Result {
 | 
			
		||||
        self.theme_ = get_prev_theme_by_name(self.theme_.name);
 | 
			
		||||
| 
						 | 
				
			
			@ -720,7 +721,7 @@ const cmds = struct {
 | 
			
		|||
        self.logger.print("theme: {s}", .{self.theme_.description});
 | 
			
		||||
        try save_config();
 | 
			
		||||
    }
 | 
			
		||||
    pub const theme_prev_meta: Meta = .{ .description = "Switch to previous color theme" };
 | 
			
		||||
    pub const theme_prev_meta: Meta = .{ .description = "Previous color theme" };
 | 
			
		||||
 | 
			
		||||
    pub fn toggle_whitespace_mode(self: *Self, _: Ctx) Result {
 | 
			
		||||
        self.config_.whitespace_mode = if (std.mem.eql(u8, self.config_.whitespace_mode, "none"))
 | 
			
		||||
| 
						 | 
				
			
			@ -743,7 +744,7 @@ const cmds = struct {
 | 
			
		|||
        _ = try self.send_widgets(tp.self_pid(), m);
 | 
			
		||||
        self.logger.print("whitespace rendering {s}", .{self.config_.whitespace_mode});
 | 
			
		||||
    }
 | 
			
		||||
    pub const toggle_whitespace_mode_meta: Meta = .{ .description = "Switch to next whitespace rendering mode" };
 | 
			
		||||
    pub const toggle_whitespace_mode_meta: Meta = .{ .description = "Next whitespace mode" };
 | 
			
		||||
 | 
			
		||||
    pub fn toggle_input_mode(self: *Self, _: Ctx) Result {
 | 
			
		||||
        var it = std.mem.splitScalar(u8, self.config_.input_mode, '/');
 | 
			
		||||
| 
						 | 
				
			
			@ -766,7 +767,7 @@ const cmds = struct {
 | 
			
		|||
        try keybind.set_namespace(self.config_.input_mode);
 | 
			
		||||
        return self.refresh_input_mode();
 | 
			
		||||
    }
 | 
			
		||||
    pub const toggle_input_mode_meta: Meta = .{ .description = "Switch to next input mode" };
 | 
			
		||||
    pub const toggle_input_mode_meta: Meta = .{ .description = "Switch input mode" };
 | 
			
		||||
 | 
			
		||||
    pub fn enter_mode(self: *Self, ctx: Ctx) Result {
 | 
			
		||||
        var mode: []const u8 = undefined;
 | 
			
		||||
| 
						 | 
				
			
			@ -795,22 +796,27 @@ const cmds = struct {
 | 
			
		|||
    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: Meta = .{ .description = "Show/Run commands" };
 | 
			
		||||
    pub const open_command_palette_meta: Meta = .{ .description = "Command palette" };
 | 
			
		||||
 | 
			
		||||
    pub fn insert_command_name(self: *Self, _: Ctx) Result {
 | 
			
		||||
        return self.enter_overlay_mode(@import("mode/overlay/list_all_commands_palette.zig").Type);
 | 
			
		||||
    }
 | 
			
		||||
    pub const insert_command_name_meta: Meta = .{ .description = "Insert command name" };
 | 
			
		||||
    pub const insert_command_name_meta: Meta = .{ .description = "Show active keybindings" };
 | 
			
		||||
 | 
			
		||||
    pub fn find_file(self: *Self, _: Ctx) Result {
 | 
			
		||||
        return self.enter_overlay_mode(@import("mode/overlay/open_recent.zig"));
 | 
			
		||||
    }
 | 
			
		||||
    pub const find_file_meta: Meta = .{ .description = "Find file" };
 | 
			
		||||
 | 
			
		||||
    pub fn open_recent(self: *Self, _: Ctx) Result {
 | 
			
		||||
        return self.enter_overlay_mode(@import("mode/overlay/open_recent.zig"));
 | 
			
		||||
    }
 | 
			
		||||
    pub const open_recent_meta: Meta = .{ .description = "Open recent file" };
 | 
			
		||||
    pub const open_recent_meta: Meta = .{ .description = "Open recent" };
 | 
			
		||||
 | 
			
		||||
    pub fn open_recent_project(self: *Self, _: Ctx) Result {
 | 
			
		||||
        return self.enter_overlay_mode(@import("mode/overlay/open_recent_project.zig").Type);
 | 
			
		||||
    }
 | 
			
		||||
    pub const open_recent_project_meta: Meta = .{ .description = "Open recent project" };
 | 
			
		||||
    pub const open_recent_project_meta: Meta = .{ .description = "Open project" };
 | 
			
		||||
 | 
			
		||||
    pub fn switch_buffers(self: *Self, _: Ctx) Result {
 | 
			
		||||
        return self.enter_overlay_mode(@import("mode/overlay/buffer_palette.zig").Type);
 | 
			
		||||
| 
						 | 
				
			
			@ -820,7 +826,7 @@ const cmds = struct {
 | 
			
		|||
    pub fn select_task(self: *Self, _: Ctx) Result {
 | 
			
		||||
        return self.enter_overlay_mode(@import("mode/overlay/task_palette.zig").Type);
 | 
			
		||||
    }
 | 
			
		||||
    pub const select_task_meta: Meta = .{ .description = "Select a task to run" };
 | 
			
		||||
    pub const select_task_meta: Meta = .{ .description = "Run task" };
 | 
			
		||||
 | 
			
		||||
    pub fn add_task(self: *Self, ctx: Ctx) Result {
 | 
			
		||||
        return enter_mini_mode(self, struct {
 | 
			
		||||
| 
						 | 
				
			
			@ -840,7 +846,7 @@ const cmds = struct {
 | 
			
		|||
            }
 | 
			
		||||
        }, ctx);
 | 
			
		||||
    }
 | 
			
		||||
    pub const add_task_meta: Meta = .{ .description = "Add a task to run" };
 | 
			
		||||
    pub const add_task_meta: Meta = .{ .description = "Add task" };
 | 
			
		||||
 | 
			
		||||
    pub fn delete_task(_: *Self, ctx: Ctx) Result {
 | 
			
		||||
        var task: []const u8 = undefined;
 | 
			
		||||
| 
						 | 
				
			
			@ -853,7 +859,7 @@ const cmds = struct {
 | 
			
		|||
    pub fn change_theme(self: *Self, _: Ctx) Result {
 | 
			
		||||
        return self.enter_overlay_mode(@import("mode/overlay/theme_palette.zig").Type);
 | 
			
		||||
    }
 | 
			
		||||
    pub const change_theme_meta: Meta = .{ .description = "Select color theme" };
 | 
			
		||||
    pub const change_theme_meta: Meta = .{ .description = "Change color theme" };
 | 
			
		||||
 | 
			
		||||
    pub fn change_file_type(self: *Self, _: Ctx) Result {
 | 
			
		||||
        return self.enter_overlay_mode(@import("mode/overlay/file_type_palette.zig").Type);
 | 
			
		||||
| 
						 | 
				
			
			@ -864,7 +870,7 @@ const cmds = struct {
 | 
			
		|||
        if (build_options.gui)
 | 
			
		||||
            self.rdr_.get_fontfaces();
 | 
			
		||||
    }
 | 
			
		||||
    pub const change_fontface_meta: Meta = .{ .description = "Select font face" };
 | 
			
		||||
    pub const change_fontface_meta: Meta = .{ .description = "Change font" };
 | 
			
		||||
 | 
			
		||||
    pub fn exit_overlay_mode(self: *Self, _: Ctx) Result {
 | 
			
		||||
        self.rdr_.cursor_disable();
 | 
			
		||||
| 
						 | 
				
			
			@ -879,12 +885,12 @@ const cmds = struct {
 | 
			
		|||
    pub fn find(self: *Self, ctx: Ctx) Result {
 | 
			
		||||
        return enter_mini_mode(self, @import("mode/mini/find.zig"), ctx);
 | 
			
		||||
    }
 | 
			
		||||
    pub const find_meta: Meta = .{ .description = "Find in current file" };
 | 
			
		||||
    pub const find_meta: Meta = .{ .description = "Find" };
 | 
			
		||||
 | 
			
		||||
    pub fn find_in_files(self: *Self, ctx: Ctx) Result {
 | 
			
		||||
        return enter_mini_mode(self, @import("mode/mini/find_in_files.zig"), ctx);
 | 
			
		||||
    }
 | 
			
		||||
    pub const find_in_files_meta: Meta = .{ .description = "Find in all project files" };
 | 
			
		||||
    pub const find_in_files_meta: Meta = .{ .description = "Find in files" };
 | 
			
		||||
 | 
			
		||||
    pub fn goto(self: *Self, ctx: Ctx) Result {
 | 
			
		||||
        return enter_mini_mode(self, @import("mode/mini/goto.zig"), ctx);
 | 
			
		||||
| 
						 | 
				
			
			@ -894,7 +900,7 @@ const cmds = struct {
 | 
			
		|||
    pub fn move_to_char(self: *Self, ctx: Ctx) Result {
 | 
			
		||||
        return enter_mini_mode(self, @import("mode/mini/move_to_char.zig"), ctx);
 | 
			
		||||
    }
 | 
			
		||||
    pub const move_to_char_meta: Meta = .{ .description = "Move cursor to matching character" };
 | 
			
		||||
    pub const move_to_char_meta: Meta = .{ .description = "Move to character" };
 | 
			
		||||
 | 
			
		||||
    pub fn open_file(self: *Self, ctx: Ctx) Result {
 | 
			
		||||
        if (get_active_selection(self.allocator)) |text| {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue