diff --git a/app/src/main/java/io/xpipe/app/browser/BookmarkList.java b/app/src/main/java/io/xpipe/app/browser/BookmarkList.java index f77d814a7..4a767c193 100644 --- a/app/src/main/java/io/xpipe/app/browser/BookmarkList.java +++ b/app/src/main/java/io/xpipe/app/browser/BookmarkList.java @@ -5,6 +5,7 @@ import io.xpipe.app.comp.storage.store.StoreEntryFlatMiniSection; import io.xpipe.app.comp.storage.store.StoreEntryWrapper; import io.xpipe.app.fxcomps.SimpleComp; import io.xpipe.core.store.ShellStore; +import javafx.scene.control.ScrollPane; import javafx.scene.layout.Region; import javafx.scene.layout.VBox; @@ -37,6 +38,11 @@ final class BookmarkList extends SimpleComp { list.getChildren().add(button); } list.setFillWidth(true); - return list; + + var sp = new ScrollPane(list); + sp.setFitToWidth(true); + sp.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); + + return sp; } } 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 9876321b3..b49107339 100644 --- a/app/src/main/java/io/xpipe/app/prefs/ExternalEditorType.java +++ b/app/src/main/java/io/xpipe/app/prefs/ExternalEditorType.java @@ -43,8 +43,6 @@ public interface ExternalEditorType extends PrefsChoiceValue { } }; - public static final LinuxPathType NOTEPADPLUSPLUS_LINUX = new LinuxPathType("app.notepad++", "notepad++"); - public static final LinuxPathType VSCODE_LINUX = new LinuxPathType("app.vscode", "code"); public static final LinuxPathType KATE = new LinuxPathType("app.kate", "kate"); @@ -66,7 +64,11 @@ public interface ExternalEditorType extends PrefsChoiceValue { @Override public void launch(Path file) throws Exception { ApplicationHelper.executeLocalApplication( - List.of("open", "-a", getApplicationPath().orElseThrow().toString(), file.toString())); + shellControl -> String.format( + "open -a %s %s", + shellControl.getShellDialect().fileArgument(getApplicationPath().orElseThrow().toString()), + shellControl.getShellDialect().fileArgument(file.toString())), + false); } } @@ -87,7 +89,7 @@ public interface ExternalEditorType extends PrefsChoiceValue { var format = customCommand.contains("$file") ? customCommand : customCommand + " $file"; var fileString = file.toString().contains(" ") ? "\"" + file + "\"" : file.toString(); - ApplicationHelper.executeLocalApplication(format.replace("$file", fileString)); + ApplicationHelper.executeLocalApplication(sc -> format.replace("$file", fileString), true); } @Override @@ -134,13 +136,16 @@ public interface ExternalEditorType extends PrefsChoiceValue { throw new IOException("Unable to find installation of " + getId()); } - ApplicationHelper.executeLocalApplication(List.of(path.get().toString(), file.toString())); + ApplicationHelper.executeLocalApplication( + sc -> String.format( + "%s %s", sc.getShellDialect().fileArgument(path.get().toString()), sc.getShellDialect().fileArgument(file.toString())), + true); } } public static final List WINDOWS_EDITORS = List.of(VSCODE, NOTEPADPLUSPLUS_WINDOWS, NOTEPAD); public static final List LINUX_EDITORS = - List.of(VSCODE_LINUX, NOTEPADPLUSPLUS_LINUX, KATE, GEDIT, PLUMA, LEAFPAD, MOUSEPAD); + List.of(VSCODE_LINUX, KATE, GEDIT, PLUMA, LEAFPAD, MOUSEPAD); public static final List MACOS_EDITORS = List.of(VSCODE_MACOS, SUBLIME_MACOS, TEXT_EDIT); public static final List ALL = ((Supplier>) () -> { diff --git a/app/src/main/java/io/xpipe/app/util/ApplicationHelper.java b/app/src/main/java/io/xpipe/app/util/ApplicationHelper.java index 89f205aa9..c5e7817c5 100644 --- a/app/src/main/java/io/xpipe/app/util/ApplicationHelper.java +++ b/app/src/main/java/io/xpipe/app/util/ApplicationHelper.java @@ -5,25 +5,20 @@ import io.xpipe.core.impl.LocalStore; import io.xpipe.core.process.ShellControl; import java.io.IOException; -import java.util.List; +import java.util.function.Function; public class ApplicationHelper { - public static void executeLocalApplication(String s) throws Exception { + public static void executeLocalApplication(Function s, boolean detach) throws Exception { TrackEvent.withDebug("proc", "Executing local application") .tag("command", s) .handle(); - try (var c = LocalStore.getShell().command(s).start()) { - c.discardOrThrow(); - } - } - public static void executeLocalApplication(List s) throws Exception { - TrackEvent.withDebug("proc", "Executing local application") - .elements(s) - .handle(); - try (var c = LocalStore.getShell().command(s).start()) { - c.discardOrThrow(); + try (var sc = LocalStore.getShell().start()) { + var cmd = detach ? ScriptHelper.createDetachCommand(sc, s.apply(sc)) : s.apply(sc); + try (var c = sc.command(cmd).start()) { + c.discardOrThrow(); + } } } diff --git a/core/src/main/java/io/xpipe/core/process/ShellDialect.java b/core/src/main/java/io/xpipe/core/process/ShellDialect.java index 1bab1db3a..e3107723c 100644 --- a/core/src/main/java/io/xpipe/core/process/ShellDialect.java +++ b/core/src/main/java/io/xpipe/core/process/ShellDialect.java @@ -111,6 +111,10 @@ public interface ShellDialect { String getFileMoveCommand(String oldFile, String newFile); + default boolean requiresScript(String content) { + return content.contains("\n"); + } + CommandControl createTextFileWriteCommand(ShellControl parent, String content, String file); String getFileDeleteCommand(String file);