Add warning when no known terminal is recognized [release]

This commit is contained in:
crschnick 2023-03-29 18:14:04 +00:00
parent 90e18d0627
commit 56234f2abf
4 changed files with 8 additions and 5 deletions

View file

@ -11,6 +11,7 @@ import io.xpipe.core.process.ShellControl;
import lombok.Getter; import lombok.Getter;
import java.util.List; import java.util.List;
import java.util.stream.Stream;
public interface ExternalTerminalType extends PrefsChoiceValue { public interface ExternalTerminalType extends PrefsChoiceValue {
@ -119,7 +120,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
public static final ExternalTerminalType CUSTOM = new CustomType(); public static final ExternalTerminalType CUSTOM = new CustomType();
public static final List<ExternalTerminalType> ALL = List.of( public static final List<ExternalTerminalType> ALL = Stream.of(
WINDOWS_TERMINAL, WINDOWS_TERMINAL,
POWERSHELL, POWERSHELL,
CMD, CMD,
@ -130,15 +131,15 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
ITERM2, ITERM2,
MACOS_TERMINAL, MACOS_TERMINAL,
CUSTOM) CUSTOM)
.stream()
.filter(terminalType -> terminalType.isSelectable()) .filter(terminalType -> terminalType.isSelectable())
.toList(); .toList();
public static ExternalTerminalType getDefault() { public static ExternalTerminalType getDefault() {
return ALL.stream() return ALL.stream()
.filter(externalTerminalType -> !externalTerminalType.equals(CUSTOM))
.filter(terminalType -> terminalType.isAvailable()) .filter(terminalType -> terminalType.isAvailable())
.findFirst() .findFirst()
.orElse(CUSTOM); .orElse(null);
} }
public abstract void launch(String name, String command) throws Exception; public abstract void launch(String name, String command) throws Exception;

View file

@ -1,5 +1,6 @@
package io.xpipe.app.util; package io.xpipe.app.util;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.prefs.AppPrefs; import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.core.process.CommandControl; import io.xpipe.core.process.CommandControl;
@ -17,7 +18,7 @@ public class TerminalHelper {
var type = AppPrefs.get().terminalType().getValue(); var type = AppPrefs.get().terminalType().getValue();
if (type == null) { if (type == null) {
throw new IllegalStateException("No terminal has been configured to be used"); throw new IllegalStateException(AppI18n.get("noTerminalSet"));
} }
type.launch(title, command); type.launch(title, command);

View file

@ -120,6 +120,7 @@ gedit=GEdit
leafpad=Leafpad leafpad=Leafpad
mousepad=Mousepad mousepad=Mousepad
pluma=Pluma pluma=Pluma
noTerminalSet=No terminal application has been set. Please do so in the settings menu.
textEdit=Text Edit textEdit=Text Edit
sublime=Sublime Text sublime=Sublime Text
newTable=new_table newTable=new_table

View file

@ -1 +1 @@
0.5.24 0.5.25