Skip to content

Commit

Permalink
Force creation of a dumb terminal if TERM starts with dumb
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Oct 23, 2023
1 parent 91e29d0 commit 84bd81f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import org.jline.terminal.impl.AbstractPosixTerminal;
import org.jline.terminal.impl.AbstractTerminal;
import org.jline.terminal.impl.DumbTerminal;
import org.jline.terminal.impl.DumbTerminalProvider;
import org.jline.terminal.spi.SystemStream;
import org.jline.terminal.spi.TerminalProvider;
Expand Down Expand Up @@ -367,6 +368,8 @@ private Terminal doBuild() throws IOException {
Charset encoding = computeEncoding();
String type = computeType();

boolean forceDumb =
(DumbTerminal.TYPE_DUMB.equals(type) || type != null && type.startsWith(DumbTerminal.TYPE_DUMB_COLOR));
Boolean dumb = this.dumb;
if (dumb == null) {
dumb = getBoolean(PROP_DUMB, null);
Expand All @@ -389,7 +392,7 @@ private Terminal doBuild() throws IOException {
stream -> stream, stream -> providers.stream().anyMatch(p -> p.isSystemStream(stream))));
SystemStream systemStream = select(system, systemOutput);

if (system.get(SystemStream.Input) && systemStream != null) {
if (!forceDumb && system.get(SystemStream.Input) && systemStream != null) {
if (attributes != null || size != null) {
Log.warn("Attributes and size fields are ignored when creating a system terminal");
}
Expand Down Expand Up @@ -437,8 +440,8 @@ private Terminal doBuild() throws IOException {
terminal = null;
}
}
if (terminal == null && (dumb == null || dumb)) {
if (dumb == null) {
if (terminal == null && (forceDumb || dumb == null || dumb)) {
if (!forceDumb && dumb == null) {
if (Log.isDebugEnabled()) {
Log.warn("input is tty: {}", system.get(SystemStream.Input));
Log.warn("output is tty: {}", system.get(SystemStream.Output));
Expand Down
3 changes: 1 addition & 2 deletions terminal/src/main/java/org/jline/utils/Status.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ public int size() {

@Override
public String toString() {
return "Status[" + "supported="
+ supported + ']';
return "Status[" + "supported=" + supported + ']';
}
}

0 comments on commit 84bd81f

Please sign in to comment.