Skip to content

Commit

Permalink
JEP434 support
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Mar 8, 2023
1 parent 22c0237 commit 24b67a6
Show file tree
Hide file tree
Showing 12 changed files with 2,972 additions and 0 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
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>**/jep434/*.java</exclude>
</excludes>
<compilerArgs>
<arg>-Xlint:all,-options</arg>
<arg>-Werror</arg>
</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>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
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
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
Loading

0 comments on commit 24b67a6

Please sign in to comment.