mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +00:00
Fixes
This commit is contained in:
parent
bae68e7ea8
commit
e5c1ebed1d
7 changed files with 38 additions and 24 deletions
|
@ -155,7 +155,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FailableFunction<LaunchConfiguration, String, Exception> remoteLaunchCommand() {
|
||||
public FailableFunction<LaunchConfiguration, String, Exception> remoteLaunchCommand(ShellDialect systemDialect) {
|
||||
return launchConfiguration -> {
|
||||
var toExecute = CommandBuilder.of()
|
||||
.add(executable, "-v", "--title")
|
||||
|
@ -566,7 +566,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FailableFunction<LaunchConfiguration, String, Exception> remoteLaunchCommand() {
|
||||
public FailableFunction<LaunchConfiguration, String, Exception> remoteLaunchCommand(ShellDialect systemDialect) {
|
||||
return launchConfiguration -> {
|
||||
var toExecute = CommandBuilder.of()
|
||||
.add("open", "-a")
|
||||
|
@ -628,7 +628,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
|||
all.addAll(MACOS_TERMINALS);
|
||||
}
|
||||
if (remote) {
|
||||
all.removeIf(externalTerminalType -> externalTerminalType.remoteLaunchCommand() == null);
|
||||
all.removeIf(externalTerminalType -> externalTerminalType.remoteLaunchCommand(null) == null);
|
||||
}
|
||||
// Prefer recommended
|
||||
all.sort(Comparator.comparingInt(o -> (o.isRecommended() ? -1 : 0)));
|
||||
|
@ -672,7 +672,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
|||
|
||||
default void launch(LaunchConfiguration configuration) throws Exception {}
|
||||
|
||||
default FailableFunction<LaunchConfiguration, String, Exception> remoteLaunchCommand() {
|
||||
default FailableFunction<LaunchConfiguration, String, Exception> remoteLaunchCommand(ShellDialect systemDialect) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -714,12 +714,6 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
|||
var open = scriptDialect.getOpenScriptCommand(scriptFile.toString());
|
||||
return open;
|
||||
}
|
||||
|
||||
public CommandBuilder appendDialectLaunchCommand(CommandBuilder b) {
|
||||
var open = getDialectLaunchCommand();
|
||||
b.add(open);
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
abstract class MacOsType extends ExternalApplicationType.MacApplication implements ExternalTerminalType {
|
||||
|
@ -751,12 +745,12 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FailableFunction<LaunchConfiguration, String, Exception> remoteLaunchCommand() {
|
||||
public FailableFunction<LaunchConfiguration, String, Exception> remoteLaunchCommand(ShellDialect systemDialect) {
|
||||
return launchConfiguration -> {
|
||||
var args = toCommand(launchConfiguration);
|
||||
args.add(0, executable);
|
||||
if (explicityAsync) {
|
||||
args = launchConfiguration.getScriptDialect().launchAsnyc(args);
|
||||
args = systemDialect.launchAsnyc(args);
|
||||
}
|
||||
return args.buildSimple();
|
||||
};
|
||||
|
|
|
@ -37,7 +37,7 @@ public class DataStoreFormatter {
|
|||
return formattedOsName(s.getOsName());
|
||||
}
|
||||
|
||||
if (s.getShellDialect().equals(ShellDialects.UNSUPPORTED)) {
|
||||
if (s.getShellDialect().equals(ShellDialects.NO_INTERACTION)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ public class ShellDialects {
|
|||
public static ShellDialect CSH;
|
||||
public static ShellDialect FISH;
|
||||
|
||||
public static ShellDialect UNSUPPORTED;
|
||||
public static ShellDialect NO_INTERACTION;
|
||||
public static ShellDialect CISCO;
|
||||
public static ShellDialect MIKROTIK;
|
||||
public static ShellDialect RBASH;
|
||||
|
@ -74,7 +74,7 @@ public class ShellDialects {
|
|||
CSH = byId("csh");
|
||||
ASH = byId("ash");
|
||||
SH = byId("sh");
|
||||
UNSUPPORTED = byId("unsupported");
|
||||
NO_INTERACTION = byId("unsupported");
|
||||
CISCO = byId("cisco");
|
||||
MIKROTIK = byId("mikrotik");
|
||||
RBASH = byId("rbash");
|
||||
|
|
|
@ -96,7 +96,7 @@ public class CoreJacksonModule extends SimpleModule {
|
|||
|
||||
@Override
|
||||
public ShellDialect deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
|
||||
var tree = JacksonMapper.getDefault().readTree(p);
|
||||
JsonNode tree = JacksonMapper.getDefault().readTree(p);
|
||||
if (tree.isObject()) {
|
||||
var t = (JsonNode) tree.get("type");
|
||||
if (t == null) {
|
||||
|
@ -105,7 +105,7 @@ public class CoreJacksonModule extends SimpleModule {
|
|||
return ShellDialects.byNameIfPresent(t.asText()).orElse(null);
|
||||
}
|
||||
|
||||
return ShellDialects.byNameIfPresent(p.getValueAsString()).orElse(null);
|
||||
return ShellDialects.byNameIfPresent(tree.asText()).orElse(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@ import io.xpipe.app.core.AppLayoutModel;
|
|||
import io.xpipe.app.ext.ActionProvider;
|
||||
import io.xpipe.app.storage.DataStoreEntry;
|
||||
import io.xpipe.app.storage.DataStoreEntryRef;
|
||||
import io.xpipe.core.process.ShellDialects;
|
||||
import io.xpipe.core.process.ShellStoreState;
|
||||
import io.xpipe.core.store.ShellStore;
|
||||
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
public class BrowseStoreAction implements ActionProvider {
|
||||
|
@ -19,6 +19,16 @@ public class BrowseStoreAction implements ActionProvider {
|
|||
public DataStoreCallSite<?> getDataStoreCallSite() {
|
||||
return new DataStoreCallSite<ShellStore>() {
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(DataStoreEntryRef<ShellStore> o) {
|
||||
var state = o.get().getStorePersistentState();
|
||||
if (state instanceof ShellStoreState shellStoreState) {
|
||||
return shellStoreState.getShellDialect() != ShellDialects.NO_INTERACTION;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionProvider.Action createAction(DataStoreEntryRef<ShellStore> store) {
|
||||
return new Action(store.get());
|
||||
|
|
|
@ -5,6 +5,8 @@ import io.xpipe.app.ext.ActionProvider;
|
|||
import io.xpipe.app.storage.DataStoreEntry;
|
||||
import io.xpipe.app.storage.DataStoreEntryRef;
|
||||
import io.xpipe.app.util.ScanAlert;
|
||||
import io.xpipe.core.process.ShellDialects;
|
||||
import io.xpipe.core.process.ShellStoreState;
|
||||
import io.xpipe.core.store.ShellStore;
|
||||
|
||||
import javafx.beans.value.ObservableValue;
|
||||
|
@ -34,7 +36,16 @@ public class ScanAction implements ActionProvider {
|
|||
|
||||
@Override
|
||||
public boolean isApplicable(DataStoreEntryRef<ShellStore> o) {
|
||||
return o.get().getProvider().canHaveSubShells();
|
||||
if (!o.get().getProvider().canHaveSubShells()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var state = o.get().getStorePersistentState();
|
||||
if (state instanceof ShellStoreState shellStoreState) {
|
||||
return shellStoreState.getShellDialect() != ShellDialects.NO_INTERACTION;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -89,17 +89,16 @@ public class DesktopEnvironmentStore extends JacksonizedValue
|
|||
}
|
||||
|
||||
public void runDesktopTerminal(String name, String script) throws Exception {
|
||||
var launchCommand = terminal.remoteLaunchCommand();
|
||||
var launchCommand = terminal.remoteLaunchCommand(base.getStore().getUsedDialect());
|
||||
var toExecute = (script != null
|
||||
? getMergedInitCommands(
|
||||
script + "\n" + dialect.getPauseCommand() + "\n" + dialect.getNormalExitCommand())
|
||||
: getMergedInitCommands(null));
|
||||
var scriptFile = base.getStore().createScript(dialect, toExecute);
|
||||
var launchScriptFile = base.getStore()
|
||||
.createScript(
|
||||
dialect, dialect.prepareTerminalInitFileOpenCommand(dialect, null, scriptFile.toString()));
|
||||
.createScript(dialect, dialect.prepareTerminalInitFileOpenCommand(dialect, null, scriptFile.toString()));
|
||||
var launchConfig =
|
||||
new ExternalTerminalType.LaunchConfiguration(null, name, name, launchScriptFile, getUsedDialect());
|
||||
new ExternalTerminalType.LaunchConfiguration(null, name, name, launchScriptFile, dialect);
|
||||
base.getStore().runDesktopScript(name, launchCommand.apply(launchConfig));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue