diff options
author | jgmdev <jgmdev@gmail.com> | 2022-10-05 12:28:09 -0400 |
---|---|---|
committer | jgmdev <jgmdev@gmail.com> | 2022-10-05 12:28:09 -0400 |
commit | b1bc52ffc0ac7b288297ca48e7f4232399f53e43 (patch) | |
tree | c42999d8b6da07f077d43e6d81ded6b2c5b8ee38 /plugins/ipc.lua | |
parent | 2eb56c58dadea86d2dffb569cb68b7e2c1d171a4 (diff) | |
download | lite-xl-plugins-b1bc52ffc0ac7b288297ca48e7f4232399f53e43.tar.gz lite-xl-plugins-b1bc52ffc0ac7b288297ca48e7f4232399f53e43.zip |
ipc: add different methods of opening directories
Diffstat (limited to 'plugins/ipc.lua')
-rw-r--r-- | plugins/ipc.lua | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/plugins/ipc.lua b/plugins/ipc.lua index 128e39c..8a68fc2 100644 --- a/plugins/ipc.lua +++ b/plugins/ipc.lua @@ -18,10 +18,10 @@ local MESSAGE_EXPIRATION=3 ---@class config.plugins.ipc ---@field single_instance boolean ----@field dirs_instance boolean +---@field dirs_instance string config.plugins.ipc = common.merge({ single_instance = true, - dirs_instance = true, + dirs_instance = "new", -- The config specification used by the settings gui config_spec = { name = "Inter-process communication", @@ -34,10 +34,15 @@ config.plugins.ipc = common.merge({ }, { label = "Directories Instance", - description = "Open a new instance for directories.", + description = "Control how to open directories in single instance mode.", path = "dirs_instance", - type = "toggle", - default = true + type = "selection", + default = "new", + values = { + {"Create a New Instance", "new"}, + {"Add to Current Instance", "add"}, + {"Change Current Instance Project Directory", "change"} + } } } }, config.plugins.ipc) @@ -908,8 +913,10 @@ system.get_time = function() if path_info.type == "file" then ipc:call_async(primary_instance, "core.open_file", nil, path) else - if not config.plugins.ipc.dirs_instance then + if config.plugins.ipc.dirs_instance == "add" then ipc:call_async(primary_instance, "core.open_directory", nil, path) + elseif config.plugins.ipc.dirs_instance == "change" then + ipc:call_async(primary_instance, "core.change_directory", nil, path) else if #ARGS > 2 then system.exec(string.format("%q %q", EXEFILE, path)) @@ -950,6 +957,16 @@ ipc:register_method("core.open_directory", function(directory) end end, {{name = "directory", type = "string"}}) +ipc:register_method("core.change_directory", function(directory) + if system.get_file_info(directory) then + if system.raise_window then system.raise_window() end + if directory == core.project_dir then return end + core.confirm_close_docs(core.docs, function(dirpath) + core.open_folder_project(dirpath) + end, directory) + end +end, {{name = "directory", type = "string"}}) + -------------------------------------------------------------------------------- -- Register file dragging signals from instance to instance -------------------------------------------------------------------------------- |