mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +00:00
Encoding fixes on windows [release]
This commit is contained in:
parent
890d110b45
commit
1d2b1539a8
4 changed files with 29 additions and 19 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ExternalEditorType> WINDOWS_EDITORS = List.of(VSCODE, NOTEPADPLUSPLUS_WINDOWS, NOTEPAD);
|
||||
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> ALL = ((Supplier<List<ExternalEditorType>>) () -> {
|
||||
|
|
|
@ -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<ShellControl, String> 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<String> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue