From 7574ff8666a93e0c2049aaa055cea12ce96da4e4 Mon Sep 17 00:00:00 2001 From: crschnick Date: Fri, 8 Dec 2023 09:10:56 +0000 Subject: [PATCH] Add support for JetBrains editors --- .../xpipe/app/prefs/ExternalEditorType.java | 30 ++++++++++++++++--- .../resources/lang/preferences_en.properties | 5 ++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/prefs/ExternalEditorType.java b/app/src/main/java/io/xpipe/app/prefs/ExternalEditorType.java index 8be194f1d..24586f74a 100644 --- a/app/src/main/java/io/xpipe/app/prefs/ExternalEditorType.java +++ b/app/src/main/java/io/xpipe/app/prefs/ExternalEditorType.java @@ -4,7 +4,9 @@ import io.xpipe.app.ext.PrefsChoiceValue; import io.xpipe.app.issue.ErrorEvent; import io.xpipe.app.util.ApplicationHelper; import io.xpipe.app.util.WindowsRegistry; +import io.xpipe.core.process.CommandBuilder; import io.xpipe.core.process.OsType; +import io.xpipe.core.store.LocalStore; import java.io.IOException; import java.nio.file.Path; @@ -142,15 +144,27 @@ public interface ExternalEditorType extends PrefsChoiceValue { void launch(Path file) throws Exception; - class LinuxPathType extends ExternalApplicationType.PathApplication implements ExternalEditorType { + class GenericPathType extends ExternalApplicationType.PathApplication implements ExternalEditorType { - public LinuxPathType(String id, String command) { + public GenericPathType(String id, String command) { super(id, command); } @Override - public void launch(Path file) throws IOException { - new ProcessBuilder(List.of(executable, file.toString())).start(); + public void launch(Path file) throws Exception { + LocalStore.getShell().executeSimpleCommand(CommandBuilder.of().add(executable).addFile(file.toString())); + } + + @Override + public boolean isSelectable() { + return true; + } + } + + class LinuxPathType extends GenericPathType { + + public LinuxPathType(String id, String command) { + super(id, command); } @Override @@ -193,9 +207,16 @@ public interface ExternalEditorType extends PrefsChoiceValue { } } + ExternalEditorType FLEET = new GenericPathType("app.fleet", "fleet"); + ExternalEditorType INTELLIJ = new GenericPathType("app.intellij", "idea"); + ExternalEditorType PYCHARM = new GenericPathType("app.pycharm", "pycharm"); + ExternalEditorType WEBSTORM = new GenericPathType("app.webstorm", "webstorm"); + ExternalEditorType CLION = new GenericPathType("app.clion", "clion"); + List WINDOWS_EDITORS = List.of(VSCODE_INSIDERS_WINDOWS, VSCODE_WINDOWS, NOTEPADPLUSPLUS_WINDOWS, NOTEPAD); List LINUX_EDITORS = List.of(VSCODE_LINUX, KATE, GEDIT, PLUMA, LEAFPAD, MOUSEPAD, GNOME); List MACOS_EDITORS = List.of(BBEDIT, VSCODE_MACOS, SUBLIME_MACOS, TEXT_EDIT); + List CROSS_PLATFORM_EDITORS = List.of(FLEET, INTELLIJ, PYCHARM, WEBSTORM, CLION); @SuppressWarnings("TrivialFunctionalExpressionUsage") List ALL = ((Supplier>) () -> { @@ -209,6 +230,7 @@ public interface ExternalEditorType extends PrefsChoiceValue { if (OsType.getLocal().equals(OsType.MACOS)) { all.addAll(MACOS_EDITORS); } + all.addAll(CROSS_PLATFORM_EDITORS); all.add(CUSTOM); return all; }) diff --git a/app/src/main/resources/io/xpipe/app/resources/lang/preferences_en.properties b/app/src/main/resources/io/xpipe/app/resources/lang/preferences_en.properties index b64d7fe1b..699758ebc 100644 --- a/app/src/main/resources/io/xpipe/app/resources/lang/preferences_en.properties +++ b/app/src/main/resources/io/xpipe/app/resources/lang/preferences_en.properties @@ -119,6 +119,11 @@ alacrittyWindows=Alacritty alacrittyMacOs=Alacritty kittyMacOs=Kitty bbedit=BBEdit +fleet=Fleet +intellij=IntelliJ +pycharm=PyCharm +webstorm=WebStorm +clion=CLion tabbyMacOs=Tabby terminal=Terminal terminalProgram=Default program