Skip to content

Commit

Permalink
Restore compatibility with jansi 1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Apr 27, 2017
1 parent 5ed8881 commit 16055f7
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
16 changes: 16 additions & 0 deletions jline/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,22 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Export-Package>*;-noimport:=true</Export-Package>
<Import-Package>
com.sun.jna*,
org.apache.sshd*,
org.fusesource.jansi;version="[1.12,2)",
org.fusesource.jansi.internal;version="[1.6,2)",
*
</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
4 changes: 4 additions & 0 deletions terminal-jansi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
<configuration>
<instructions>
<Export-Package>*;-noimport:=true</Export-Package>
<Import-Package>
org.fusesource.jansi;version="[1.12,2)",
org.fusesource.jansi.internal;version="[1.6,2)"
</Import-Package>
<Fragment-Host>org.jline.terminal</Fragment-Host>
</instructions>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,16 @@ public JansiNativePty(int master, FileDescriptor masterFD, int slave, FileDescri
}

protected static String ttyname() throws IOException {
String name = CLibrary.ttyname(0);
String name;
if (JANSI_MAJOR_VERSION > 1 || JANSI_MAJOR_VERSION == 1 && JANSI_MINOR_VERSION >= 16) {
name = CLibrary.ttyname(0);
} else {
try {
name = exec(true, OSUtils.TTY_COMMAND);
} catch (IOException e) {
throw new IOException("Not a tty", e);
}
}
if (name != null) {
name = name.trim();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public Pty current() throws IOException {
}
}
else if (osName.startsWith("Mac") || osName.startsWith("Darwin")) {
if (JANSI_MAJOR_VERSION > 0) {
if (JANSI_MAJOR_VERSION > 1 || JANSI_MAJOR_VERSION == 1 && JANSI_MINOR_VERSION >= 12) {
return OsXNativePty.current();
}
}
Expand All @@ -70,7 +70,10 @@ else if (osName.startsWith("FreeBSD")) {

@Override
public Terminal winSysTerminal(String name, boolean nativeSignals, Terminal.SignalHandler signalHandler) throws IOException {
return new JansiWinSysTerminal(name, nativeSignals, signalHandler);
if (JANSI_MAJOR_VERSION > 1 || JANSI_MAJOR_VERSION == 1 && JANSI_MINOR_VERSION >= 12) {
return new JansiWinSysTerminal(name, nativeSignals, signalHandler);
}
throw new UnsupportedOperationException();
}

}

0 comments on commit 16055f7

Please sign in to comment.