Encoding fixes on windows [release]

This commit is contained in:
crschnick 2023-03-25 10:51:08 +00:00
parent 890d110b45
commit 1d2b1539a8
4 changed files with 29 additions and 19 deletions

View file

@ -5,6 +5,7 @@ import io.xpipe.app.comp.storage.store.StoreEntryFlatMiniSection;
import io.xpipe.app.comp.storage.store.StoreEntryWrapper; import io.xpipe.app.comp.storage.store.StoreEntryWrapper;
import io.xpipe.app.fxcomps.SimpleComp; import io.xpipe.app.fxcomps.SimpleComp;
import io.xpipe.core.store.ShellStore; import io.xpipe.core.store.ShellStore;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.Region; import javafx.scene.layout.Region;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
@ -37,6 +38,11 @@ final class BookmarkList extends SimpleComp {
list.getChildren().add(button); list.getChildren().add(button);
} }
list.setFillWidth(true); list.setFillWidth(true);
return list;
var sp = new ScrollPane(list);
sp.setFitToWidth(true);
sp.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
return sp;
} }
} }

View file

@ -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 VSCODE_LINUX = new LinuxPathType("app.vscode", "code");
public static final LinuxPathType KATE = new LinuxPathType("app.kate", "kate"); public static final LinuxPathType KATE = new LinuxPathType("app.kate", "kate");
@ -66,7 +64,11 @@ public interface ExternalEditorType extends PrefsChoiceValue {
@Override @Override
public void launch(Path file) throws Exception { public void launch(Path file) throws Exception {
ApplicationHelper.executeLocalApplication( 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 format = customCommand.contains("$file") ? customCommand : customCommand + " $file";
var fileString = file.toString().contains(" ") ? "\"" + file + "\"" : file.toString(); var fileString = file.toString().contains(" ") ? "\"" + file + "\"" : file.toString();
ApplicationHelper.executeLocalApplication(format.replace("$file", fileString)); ApplicationHelper.executeLocalApplication(sc -> format.replace("$file", fileString), true);
} }
@Override @Override
@ -134,13 +136,16 @@ public interface ExternalEditorType extends PrefsChoiceValue {
throw new IOException("Unable to find installation of " + getId()); 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<ExternalEditorType> WINDOWS_EDITORS = List.of(VSCODE, NOTEPADPLUSPLUS_WINDOWS, NOTEPAD); public static final List<ExternalEditorType> WINDOWS_EDITORS = List.of(VSCODE, NOTEPADPLUSPLUS_WINDOWS, NOTEPAD);
public static final List<LinuxPathType> LINUX_EDITORS = public static final List<LinuxPathType> 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<ExternalEditorType> MACOS_EDITORS = List.of(VSCODE_MACOS, SUBLIME_MACOS, TEXT_EDIT); public static final List<ExternalEditorType> MACOS_EDITORS = List.of(VSCODE_MACOS, SUBLIME_MACOS, TEXT_EDIT);
public static final List<ExternalEditorType> ALL = ((Supplier<List<ExternalEditorType>>) () -> { public static final List<ExternalEditorType> ALL = ((Supplier<List<ExternalEditorType>>) () -> {

View file

@ -5,25 +5,20 @@ import io.xpipe.core.impl.LocalStore;
import io.xpipe.core.process.ShellControl; import io.xpipe.core.process.ShellControl;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.function.Function;
public class ApplicationHelper { public class ApplicationHelper {
public static void executeLocalApplication(String s) throws Exception { public static void executeLocalApplication(Function<ShellControl, String> s, boolean detach) throws Exception {
TrackEvent.withDebug("proc", "Executing local application") TrackEvent.withDebug("proc", "Executing local application")
.tag("command", s) .tag("command", s)
.handle(); .handle();
try (var c = LocalStore.getShell().command(s).start()) {
c.discardOrThrow();
}
}
public static void executeLocalApplication(List<String> s) throws Exception { try (var sc = LocalStore.getShell().start()) {
TrackEvent.withDebug("proc", "Executing local application") var cmd = detach ? ScriptHelper.createDetachCommand(sc, s.apply(sc)) : s.apply(sc);
.elements(s) try (var c = sc.command(cmd).start()) {
.handle(); c.discardOrThrow();
try (var c = LocalStore.getShell().command(s).start()) { }
c.discardOrThrow();
} }
} }

View file

@ -111,6 +111,10 @@ public interface ShellDialect {
String getFileMoveCommand(String oldFile, String newFile); String getFileMoveCommand(String oldFile, String newFile);
default boolean requiresScript(String content) {
return content.contains("\n");
}
CommandControl createTextFileWriteCommand(ShellControl parent, String content, String file); CommandControl createTextFileWriteCommand(ShellControl parent, String content, String file);
String getFileDeleteCommand(String file); String getFileDeleteCommand(String file);