Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Jansi to 2.4.1 #106

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ lazy val jni = project
shared,
name := "windows-ansi",
libraryDependencies ++= Seq(
"org.fusesource.jansi" % "jansi" % "1.18"
"org.fusesource.jansi" % "jansi" % "2.4.1",
)
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
package io.github.alexarchambault.windowsansi;

import org.fusesource.jansi.internal.Kernel32;
import org.fusesource.jansi.internal.WindowsSupport;

import java.io.IOException;
import java.net.URL;
import java.util.Locale;
import java.util.Objects;

public final class WindowsAnsi {

static {
// Workaround while we can't benefit from https://github.com/fusesource/jansi/pull/292
String arch = System.getProperty("os.arch", "").toLowerCase(Locale.ROOT);
if (arch.equals("arm64") || arch.equals("aarch64")) {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
URL dllUrl = cl.getResource("org/fusesource/jansi/internal/native/Windows/arm64/jansi.dll");
URL soUrl = cl.getResource("org/fusesource/jansi/internal/native/Windows/arm64/libjansi.so");
if (dllUrl == null && soUrl != null) {
System.setProperty("library.jansi.name", "libjansi.so");
}
}

// Make https://github.com/fusesource/hawtjni/blob/c14fec00b9976ff6b84e62e483d678594a7d3832/hawtjni-runtime/src/main/java/org/fusesource/hawtjni/runtime/Library.java#L167 happy
if (System.getProperty("com.ibm.vm.bitmode") == null)
System.setProperty("com.ibm.vm.bitmode", "64");
Expand All @@ -31,7 +43,7 @@ public static boolean setup() throws IOException {
long console = Kernel32.GetStdHandle(Kernel32.STD_OUTPUT_HANDLE);
int[] mode = new int[1];
if (Kernel32.GetConsoleMode(console, mode) == 0)
throw new IOException("Failed to get console mode: " + WindowsSupport.getLastErrorMessage());
throw new IOException("Failed to get console mode: " + Kernel32.getLastErrorMessage());
return Kernel32.SetConsoleMode(console, mode[0] | ENABLE_VIRTUAL_TERMINAL_PROCESSING) != 0;
}

Expand Down
Loading