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