mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +00:00
Terminal fixes
This commit is contained in:
parent
da4174e0f5
commit
eb2f0d0730
14 changed files with 54 additions and 12 deletions
|
@ -129,13 +129,21 @@ public class AppTheme {
|
|||
TrackEvent.debug("Set theme " + t.getId() + " for scene");
|
||||
|
||||
AppPrefs.get().theme.addListener((c, o, n) -> {
|
||||
AppCache.update("lastDarkTheme", n != null && n.isDark());
|
||||
changeTheme(n);
|
||||
});
|
||||
|
||||
init = true;
|
||||
}
|
||||
|
||||
public static void reset() {
|
||||
if (!init) {
|
||||
return;
|
||||
}
|
||||
|
||||
var nowDark = Platform.getPreferences().getColorScheme() == ColorScheme.DARK;
|
||||
AppCache.update("lastDarkTheme", nowDark);
|
||||
}
|
||||
|
||||
private static void setDefault() {
|
||||
try {
|
||||
var colorScheme = Platform.getPreferences().getColorScheme();
|
||||
|
|
|
@ -71,6 +71,7 @@ public abstract class PlatformMode extends OperationMode {
|
|||
onSwitchFrom();
|
||||
StoreViewState.reset();
|
||||
AppLayoutModel.reset();
|
||||
AppTheme.reset();
|
||||
PlatformState.teardown();
|
||||
TrackEvent.info("Platform shutdown finished");
|
||||
BACKGROUND.finalTeardown();
|
||||
|
|
|
@ -18,10 +18,6 @@ public class LocalStore extends JacksonizedValue
|
|||
return ShellStoreState.class;
|
||||
}
|
||||
|
||||
public ShellControl control(ShellControl parent) {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShellControlFunction shellFunction() {
|
||||
return new ShellControlFunction() {
|
||||
|
|
|
@ -69,6 +69,8 @@ public interface ShellStore extends DataStore, FileSystemStore, ValidatableStore
|
|||
return func.control();
|
||||
}
|
||||
|
||||
return p.control(p.getParentStore().getOrStartSession());
|
||||
// Don't reuse local shell
|
||||
var parentSc = p.getParentStore() instanceof LocalStore l ? l.standaloneControl() : p.getParentStore().getOrStartSession();
|
||||
return p.control(parentSc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package io.xpipe.app.terminal;
|
||||
|
||||
import io.xpipe.app.ext.ProcessControlProvider;
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.core.process.CommandBuilder;
|
||||
import io.xpipe.core.process.ShellDialects;
|
||||
|
||||
|
@ -11,7 +13,8 @@ public class CmdTerminalType extends ExternalTerminalType.SimplePathType impleme
|
|||
|
||||
@Override
|
||||
public int getProcessHierarchyOffset() {
|
||||
return -1;
|
||||
var powershell = ShellDialects.isPowershell(ProcessControlProvider.get().getEffectiveLocalDialect()) || AppPrefs.get().enableTerminalLogging().get();
|
||||
return powershell ? 0 : -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -943,7 +943,6 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
|||
WindowsTerminalType.WINDOWS_TERMINAL_CANARY,
|
||||
WindowsTerminalType.WINDOWS_TERMINAL_PREVIEW,
|
||||
WindowsTerminalType.WINDOWS_TERMINAL,
|
||||
TabbyTerminalType.TABBY_WINDOWS,
|
||||
AlacrittyTerminalType.ALACRITTY_WINDOWS,
|
||||
WezTerminalType.WEZTERM_WINDOWS,
|
||||
CMD,
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package io.xpipe.app.terminal;
|
||||
|
||||
import io.xpipe.app.ext.ProcessControlProvider;
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.core.process.CommandBuilder;
|
||||
import io.xpipe.core.process.ShellDialects;
|
||||
|
||||
|
@ -12,6 +14,12 @@ public class PowerShellTerminalType extends ExternalTerminalType.SimplePathType
|
|||
super("app.powershell", "powershell", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessHierarchyOffset() {
|
||||
var powershell = ProcessControlProvider.get().getEffectiveLocalDialect() == POWERSHELL || AppPrefs.get().enableTerminalLogging().get();
|
||||
return powershell ? -1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsTabs() {
|
||||
return false;
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package io.xpipe.app.terminal;
|
||||
|
||||
import io.xpipe.app.ext.ProcessControlProvider;
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.core.process.CommandBuilder;
|
||||
import io.xpipe.core.process.ShellDialects;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
|
|
|
@ -30,7 +30,8 @@ public class TerminalLaunchRequest {
|
|||
@NonFinal
|
||||
boolean setupCompleted;
|
||||
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
@NonFinal
|
||||
CountDownLatch latch;
|
||||
|
||||
public Path waitForCompletion() throws BeaconServerException {
|
||||
while (true) {
|
||||
|
@ -54,6 +55,7 @@ public class TerminalLaunchRequest {
|
|||
}
|
||||
|
||||
public void setupRequestAsync() {
|
||||
latch = new CountDownLatch(1);
|
||||
ThreadHelper.runAsync(() -> {
|
||||
setupRequest();
|
||||
latch.countDown();
|
||||
|
|
|
@ -117,7 +117,8 @@ public class TerminalLauncher {
|
|||
var logFile = logDir.resolve(new FilePath(DataStorage.get().getStoreEntryDisplayName(entry) + " ("
|
||||
+ DATE_FORMATTER.format(Instant.now()) + ").log")
|
||||
.fileSystemCompatible(OsType.getLocal())
|
||||
.toString());
|
||||
.toString()
|
||||
.replaceAll(" ", "_"));
|
||||
try (var sc = LocalShell.getShell().start()) {
|
||||
if (OsType.getLocal() == OsType.WINDOWS) {
|
||||
var content =
|
||||
|
|
|
@ -51,7 +51,7 @@ public class TerminalLauncherManager {
|
|||
synchronized (entries) {
|
||||
var req = entries.get(request);
|
||||
if (req == null) {
|
||||
req = new TerminalLaunchRequest(request, processControl, config, directory, null, false);
|
||||
req = new TerminalLaunchRequest(request, processControl, config, directory, null, false, null);
|
||||
entries.put(request, req);
|
||||
} else {
|
||||
req.setResult(null);
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package io.xpipe.app.terminal;
|
||||
|
||||
import io.xpipe.app.core.window.NativeWinWindowControl;
|
||||
import io.xpipe.app.ext.ProcessControlProvider;
|
||||
import io.xpipe.app.issue.TrackEvent;
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.app.util.ThreadHelper;
|
||||
import io.xpipe.core.process.OsType;
|
||||
|
||||
import io.xpipe.core.process.ShellDialects;
|
||||
import lombok.Getter;
|
||||
import lombok.Value;
|
||||
|
||||
|
@ -79,11 +81,18 @@ public class TerminalView {
|
|||
}
|
||||
|
||||
var shell = processHandle.get().parent();
|
||||
TrackEvent.withTrace("Shell session opened")
|
||||
.tag("pid", shell.map(p -> p.pid()).orElse(-1L))
|
||||
.handle();
|
||||
if (shell.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var terminal = getTerminalProcess(shell.get());
|
||||
TrackEvent.withTrace("Terminal session opened")
|
||||
.tag("pid", terminal.map(p -> p.pid()).orElse(-1L))
|
||||
.tag("exec", terminal.flatMap(p -> p.info().command()).orElse("?"))
|
||||
.handle();
|
||||
if (terminal.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -131,9 +140,12 @@ public class TerminalView {
|
|||
return Optional.empty();
|
||||
}
|
||||
|
||||
// Adjust for terminal logging script setup
|
||||
var off = trackableTerminalType.getProcessHierarchyOffset();
|
||||
if (AppPrefs.get().enableTerminalLogging().get() && OsType.getLocal() != OsType.WINDOWS) {
|
||||
off += 2;
|
||||
} else if (AppPrefs.get().enableTerminalLogging().get() && OsType.getLocal() == OsType.WINDOWS) {
|
||||
off += ShellDialects.isPowershell(ProcessControlProvider.get().getEffectiveLocalDialect()) ? 0 : 1;
|
||||
}
|
||||
|
||||
var current = Optional.of(shell);
|
||||
|
|
|
@ -12,7 +12,7 @@ import io.xpipe.core.process.ShellControl;
|
|||
import java.nio.file.Path;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface WezTerminalType extends ExternalTerminalType {
|
||||
public interface WezTerminalType extends ExternalTerminalType, TrackableTerminalType {
|
||||
|
||||
ExternalTerminalType WEZTERM_WINDOWS = new Windows();
|
||||
ExternalTerminalType WEZTERM_LINUX = new Linux();
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.xpipe.app.terminal;
|
|||
|
||||
import io.xpipe.app.ext.ProcessControlProvider;
|
||||
import io.xpipe.app.issue.ErrorEvent;
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.app.util.LocalShell;
|
||||
import io.xpipe.app.util.ScriptHelper;
|
||||
import io.xpipe.core.process.CommandBuilder;
|
||||
|
@ -55,6 +56,12 @@ public interface WindowsTerminalType extends ExternalTerminalType, TrackableTerm
|
|||
return cmd;
|
||||
}
|
||||
|
||||
@Override
|
||||
default int getProcessHierarchyOffset() {
|
||||
var powershell = AppPrefs.get().enableTerminalLogging().get() && !ShellDialects.isPowershell(ProcessControlProvider.get().getEffectiveLocalDialect());
|
||||
return powershell ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
default boolean supportsTabs() {
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue