From 2901c624f85775b23c42f393e68ef7c32c977d01 Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Wed, 26 Apr 2023 17:25:40 +1200 Subject: [PATCH] Open config files from commands --- LOG.md | 6 +++--- src/keymap.jai | 2 +- src/widgets/commands.jai | 14 +++++++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/LOG.md b/LOG.md index 2ebec0e68..4591158ee 100644 --- a/LOG.md +++ b/LOG.md @@ -15,9 +15,9 @@ =========================== - Project commands: - - Open projects folder - - Open global config - - Open project config + + Open projects folder + + Open global config + + Open project config - Switch project - Line wrap: diff --git a/src/keymap.jai b/src/keymap.jai index a5dd9a714..c7529600e 100644 --- a/src/keymap.jai +++ b/src/keymap.jai @@ -147,7 +147,7 @@ Key_Combo :: struct { ACTIONS_COMMON :: string.[ "do_nothing", // to disable key combinations - "switch_project", + "open_project", "open_projects_directory", "open_global_config", "open_project_config", diff --git a/src/widgets/commands.jai b/src/widgets/commands.jai index e03ae1413..c47f16ce6 100644 --- a/src/widgets/commands.jai +++ b/src/widgets/commands.jai @@ -61,11 +61,15 @@ commands_execute_selected :: () { if command.action == { case .do_nothing; return; - case .open_projects_directory; - platform_open_in_explorer(projects_dir); - case .open_global_config; + case .open_projects_directory; platform_open_in_explorer(projects_dir); + case .open_global_config; editors_open_file(global_config_path); case .open_project_config; - case .switch_project; + if project_config_path { + editors_open_file(project_config_path); + } else { + add_user_warning("No project is active. Please open a project first.", dismiss_in_seconds = 5); + } + case .open_project; case; dummy_event: Input.Event; // TODO: refactor so that this event is not needed // (need to put the search bar into its own widget for this) @@ -150,7 +154,7 @@ commands := #run Command.[ .{ .show_open_file_dialog_in_navigate_mode, "Navigate To File", 0, false }, .{ .show_open_file_dialog_in_navigate_mode_from_root, "Navigate To File From Root", 0, false }, - .{ .switch_project, "Switch Project", 0, false }, + .{ .open_project, "Open Project", 0, false }, .{ .open_projects_directory, "Open Projects Directory", 0, false }, .{ .open_global_config, "Open Global Config", 0, false }, .{ .open_project_config, "Open Project Config", 0, false },