Skip to content

Commit

Permalink
JEP442 support
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Aug 1, 2023
1 parent 981a1f9 commit 61c6f78
Show file tree
Hide file tree
Showing 28 changed files with 2,988 additions and 2 deletions.
20 changes: 20 additions & 0 deletions jline/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@
<include>**/TTop.java</include>
<include>**/ConsoleEngineImpl.java</include>
</includes>
<excludes>
<exclude>**/jep434/*.java</exclude>
</excludes>
<compilerArgs>
<arg>-Xlint:all,-options</arg>
<arg>-Werror</arg>
Expand All @@ -335,6 +338,7 @@
<excludes>
<exclude>**/TTop.java</exclude>
<exclude>**/ConsoleEngineImpl.java</exclude>
<exclude>**/jep434/*.java</exclude>
</excludes>
<compilerArgs>
<arg>-Xlint:all,-options</arg>
Expand All @@ -344,6 +348,22 @@
</compilerArgs>
</configuration>
</execution>
<execution>
<id>jdk20</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<includes>
<include>**/jep434/*.java</include>
</includes>
<release>21</release>
<compilerArgs>
<arg>-Xlint:all,-options</arg>
<arg>--enable-preview</arg>
</compilerArgs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
Expand Down
1 change: 1 addition & 0 deletions reader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

<properties>
<automatic.module.name>org.jline.reader</automatic.module.name>
<surefire.argLine>--add-opens java.base/java.io=ALL-UNNAMED --enable-preview</surefire.argLine>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ protected enum BellType {

protected KillRing killRing = new KillRing();

protected UndoTree<Buffer> undo = new UndoTree<>(this::setBuffer);
protected UndoTree<Buffer> undo;
protected boolean isUndo;

/**
Expand Down Expand Up @@ -291,6 +291,7 @@ public LineReaderImpl(Terminal terminal, String appName) throws IOException {
this(terminal, appName, null);
}

@SuppressWarnings("this-escape")
public LineReaderImpl(Terminal terminal, String appName, Map<String, Object> variables) {
Objects.requireNonNull(terminal, "terminal can not be null");
this.terminal = terminal;
Expand All @@ -309,6 +310,7 @@ public LineReaderImpl(Terminal terminal, String appName, Map<String, Object> var
this.alternateOut = Curses.tputs(terminal.getStringCapability(Capability.exit_alt_charset_mode));
}

undo = new UndoTree<>(this::setBuffer);
builtinWidgets = builtinWidgets();
widgets = new HashMap<>(builtinWidgets);
bindingReader = new BindingReader(terminal.reader());
Expand Down
1 change: 1 addition & 0 deletions reader/src/main/java/org/jline/reader/impl/UndoTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class UndoTree<T> {
private final Node parent;
private Node current;

@SuppressWarnings("this-escape")
public UndoTree(Consumer<T> s) {
state = s;
parent = new Node(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class DefaultHistory implements History {

public DefaultHistory() {}

@SuppressWarnings("this-escape")
public DefaultHistory(LineReader reader) {
attach(reader);
}
Expand Down
35 changes: 35 additions & 0 deletions terminal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,41 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<excludes>
<exclude>**/jep442/*.java</exclude>
</excludes>
<compilerArgs>
<arg>-Xlint:all,-options</arg>
<arg>-Werror</arg>
</compilerArgs>
</configuration>
</execution>
<execution>
<id>jdk21</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<includes>
<include>**/jep442/*.java</include>
</includes>
<release>21</release>
<compilerArgs>
<arg>-Xlint:all,-options</arg>
<arg>--enable-preview</arg>
</compilerArgs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
Expand Down
1 change: 1 addition & 0 deletions terminal/src/main/java/org/jline/terminal/Attributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public enum LocalFlag {

public Attributes() {}

@SuppressWarnings("this-escape")
public Attributes(Attributes attr) {
copy(attr);
}
Expand Down
1 change: 1 addition & 0 deletions terminal/src/main/java/org/jline/terminal/Size.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class Size {

public Size() {}

@SuppressWarnings("this-escape")
public Size(int columns, int rows) {
this();
setColumns(columns);
Expand Down
20 changes: 20 additions & 0 deletions terminal/src/main/java/org/jline/terminal/TerminalBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public final class TerminalBuilder {
public static final String PROP_JNA = "org.jline.terminal.jna";
public static final String PROP_JANSI = "org.jline.terminal.jansi";
public static final String PROP_EXEC = "org.jline.terminal.exec";
public static final String PROP_JEP434 = "org.jline.terminal.jep434";
public static final String PROP_DUMB = "org.jline.terminal.dumb";
public static final String PROP_DUMB_COLOR = "org.jline.terminal.dumb.color";
public static final String PROP_OUTPUT = "org.jline.terminal.output";
Expand Down Expand Up @@ -129,6 +130,7 @@ public static TerminalBuilder builder() {
private Boolean jna;
private Boolean jansi;
private Boolean exec;
private Boolean jep434;
private Boolean dumb;
private Boolean color;
private Attributes attributes;
Expand Down Expand Up @@ -184,6 +186,11 @@ public TerminalBuilder exec(boolean exec) {
return this;
}

public TerminalBuilder jep434(boolean jep434) {
this.jep434 = jep434;
return this;
}

public TerminalBuilder dumb(boolean dumb) {
this.dumb = dumb;
return this;
Expand Down Expand Up @@ -368,12 +375,25 @@ private Terminal doBuild() throws IOException {
if (exec == null) {
exec = getBoolean(PROP_EXEC, true);
}
Boolean jep434 = this.jep434;
if (jep434 == null) {
jep434 = getBoolean(PROP_JEP434, true);
}
Boolean dumb = this.dumb;
if (dumb == null) {
dumb = getBoolean(PROP_DUMB, null);
}
IllegalStateException exception = new IllegalStateException("Unable to create a terminal");
List<TerminalProvider> providers = new ArrayList<>();
if (jep434) {
try {
TerminalProvider provider = TerminalProvider.load("jep434");
providers.add(provider);
} catch (Throwable t) {
Log.debug("Unable to load JEP434 support: ", t);
exception.addSuppressed(t);
}
}
if (jna) {
try {
TerminalProvider provider = TerminalProvider.load("jna");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,21 @@ public abstract class AbstractTerminal implements Terminal {
protected final Set<Capability> bools = new HashSet<>();
protected final Map<Capability, Integer> ints = new HashMap<>();
protected final Map<Capability, String> strings = new HashMap<>();
protected final ColorPalette palette = new ColorPalette(this);
protected final ColorPalette palette;
protected Status status;
protected Runnable onClose;

public AbstractTerminal(String name, String type) throws IOException {
this(name, type, null, SignalHandler.SIG_DFL);
}

@SuppressWarnings("this-escape")
public AbstractTerminal(String name, String type, Charset encoding, SignalHandler signalHandler)
throws IOException {
this.name = name;
this.type = type != null ? type : "ansi";
this.encoding = encoding != null ? encoding : Charset.defaultCharset();
this.palette = new ColorPalette(this);
for (Signal signal : Signal.values()) {
handlers.put(signal, signalHandler);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public abstract class AbstractWindowsTerminal<Console> extends AbstractTerminal
protected boolean focusTracking = false;
private volatile boolean closing;

@SuppressWarnings("this-escape")
public AbstractWindowsTerminal(
Writer writer,
String name,
Expand Down
11 changes: 11 additions & 0 deletions terminal/src/main/java/org/jline/terminal/impl/Diag.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ static void diag(PrintStream out) {
out.println("IS_OSX = " + OSUtils.IS_OSX);
out.println();

// Jep434
out.println("Jep434 Support");
out.println("=================");
try {
TerminalProvider provider = TerminalProvider.load("jep434");
testProvider(out, provider);
} catch (Throwable t) {
out.println("Jep434 support not available: " + t);
}
out.println();

out.println("JnaSupport");
out.println("=================");
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public DumbTerminal(String name, String type, InputStream in, OutputStream out,
this(name, type, in, out, encoding, SignalHandler.SIG_DFL);
}

@SuppressWarnings("this-escape")
public DumbTerminal(
String name, String type, InputStream in, OutputStream out, Charset encoding, SignalHandler signalHandler)
throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public ExternalTerminal(
this(name, type, masterInput, masterOutput, encoding, signalHandler, paused, null, null);
}

@SuppressWarnings("this-escape")
public ExternalTerminal(
String name,
String type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public LineDisciplineTerminal(String name, String type, OutputStream masterOutpu
this(name, type, masterOutput, encoding, SignalHandler.SIG_DFL);
}

@SuppressWarnings("this-escape")
public LineDisciplineTerminal(
String name, String type, OutputStream masterOutput, Charset encoding, SignalHandler signalHandler)
throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public PosixPtyTerminal(
this(name, type, pty, in, out, encoding, signalHandler, false);
}

@SuppressWarnings("this-escape")
public PosixPtyTerminal(
String name,
String type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class PosixSysTerminal extends AbstractPosixTerminal {
protected final Map<Signal, Object> nativeHandlers = new HashMap<>();
protected final Task closer;

@SuppressWarnings("this-escape")
public PosixSysTerminal(
String name, String type, Pty pty, Charset encoding, boolean nativeSignals, SignalHandler signalHandler)
throws IOException {
Expand Down
Loading

0 comments on commit 61c6f78

Please sign in to comment.