Accepting request 977563 from Java:packages

maven 3.8.5 / jansi 2.4.0 and fixes for building with them

OBS-URL: https://build.opensuse.org/request/show/977563
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/jline?expand=0&rev=26
This commit is contained in:
Dominique Leuenberger 2022-05-17 15:24:13 +00:00 committed by Git OBS Bridge
commit 9b4e6eb25d
3 changed files with 173 additions and 3 deletions

162
jline-jansi2.patch Normal file
View File

@ -0,0 +1,162 @@
--- jline2-jline-2.14.6/src/main/java/jline/AnsiWindowsTerminal.java 2022-05-13 06:20:11.713726341 +0200
+++ jline2-jline-2.14.6/src/main/java/jline/AnsiWindowsTerminal.java 2022-05-13 07:21:11.191259791 +0200
@@ -9,12 +9,17 @@
package jline;
import jline.internal.Configuration;
+import org.fusesource.jansi.AnsiColors;
import org.fusesource.jansi.AnsiConsole;
-import org.fusesource.jansi.AnsiOutputStream;
-import org.fusesource.jansi.WindowsAnsiOutputStream;
+import org.fusesource.jansi.AnsiMode;
+import org.fusesource.jansi.AnsiType;
+
+import org.fusesource.jansi.io.AnsiOutputStream;
+import org.fusesource.jansi.io.WindowsAnsiProcessor;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
+import java.nio.charset.Charset;
/**
* ANSI-supported {@link WindowsTerminal}.
@@ -42,26 +47,26 @@
if (Configuration.isWindows()) {
// On windows we know the console does not interpret ANSI codes..
try {
- return new WindowsAnsiOutputStream(stream);
+ return new AnsiOutputStream(stream, null, AnsiMode.Default, new WindowsAnsiProcessor(stream), AnsiType.Emulation, AnsiColors.Colors16, Charset.defaultCharset(), null, null, false );
} catch (Throwable ignore) {
// this happens when JNA is not in the path.. or
// this happens when the stdout is being redirected to a file.
}
// Use the ANSIOutputStream to strip out the ANSI escape sequences.
- return new AnsiOutputStream(stream);
+ return new AnsiOutputStream(stream, null, AnsiMode.Strip, null, AnsiType.Unsupported, AnsiColors.TrueColor, Charset.defaultCharset(), null, null, false);
}
return stream;
}
private static boolean detectAnsiSupport() {
- OutputStream out = AnsiConsole.wrapOutputStream(new ByteArrayOutputStream());
try {
- out.close();
+ new WindowsAnsiProcessor(new ByteArrayOutputStream());
+ return true;
}
catch (Exception e) {
// ignore;
}
- return out instanceof WindowsAnsiOutputStream;
+ return false;
}
public AnsiWindowsTerminal() throws Exception {
--- jline2-jline-2.14.6/src/main/java/jline/internal/Ansi.java 2022-05-13 06:20:11.749726581 +0200
+++ jline2-jline-2.14.6/src/main/java/jline/internal/Ansi.java 2022-05-13 06:20:28.793840511 +0200
@@ -10,8 +10,12 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.nio.charset.Charset;
-import org.fusesource.jansi.AnsiOutputStream;
+import org.fusesource.jansi.io.AnsiOutputStream;
+import org.fusesource.jansi.AnsiColors;
+import org.fusesource.jansi.AnsiMode;
+import org.fusesource.jansi.AnsiType;
/**
* Ansi support.
@@ -25,7 +29,18 @@
if (str == null) return "";
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- AnsiOutputStream aos = new AnsiOutputStream(baos);
+ AnsiOutputStream aos = new AnsiOutputStream(
+ baos,
+ null,
+ AnsiMode.Strip,
+ null,
+ AnsiType.Emulation,
+ AnsiColors.TrueColor,
+ Charset.defaultCharset(),
+ null,
+ null,
+ false
+ );
aos.write(str.getBytes());
aos.close();
return baos.toString();
--- jline2-jline-2.14.6/src/main/java/jline/WindowsTerminal.java 2022-05-13 06:20:11.717726368 +0200
+++ jline2-jline-2.14.6/src/main/java/jline/WindowsTerminal.java 2022-05-13 06:34:46.083425194 +0200
@@ -15,9 +15,10 @@
import jline.internal.Configuration;
import jline.internal.Log;
-import org.fusesource.jansi.internal.WindowsSupport;
+
import org.fusesource.jansi.internal.Kernel32;
import static org.fusesource.jansi.internal.Kernel32.*;
+import org.fusesource.jansi.internal.Kernel32.CONSOLE_SCREEN_BUFFER_INFO;
import static jline.WindowsTerminal.ConsoleMode.ENABLE_ECHO_INPUT;
import static jline.WindowsTerminal.ConsoleMode.ENABLE_LINE_INPUT;
@@ -208,18 +209,34 @@
// Native Bits
//
private static int getConsoleMode() {
- return WindowsSupport.getConsoleMode();
+ long hConsole = GetStdHandle (STD_INPUT_HANDLE);
+ if (hConsole == INVALID_HANDLE_VALUE)
+ return -1;
+ int mode[] = new int[1];
+ if (GetConsoleMode (hConsole, mode)==0)
+ return -1;
+ return mode[0];
}
private static void setConsoleMode(int mode) {
- WindowsSupport.setConsoleMode(mode);
+ long hConsole = GetStdHandle (STD_INPUT_HANDLE);
+ if (hConsole == INVALID_HANDLE_VALUE)
+ return;
+ SetConsoleMode (hConsole, mode);
+ }
+
+ private static INPUT_RECORD[] readConsoleInput(int count) throws IOException {
+ long hConsole = GetStdHandle (STD_INPUT_HANDLE);
+ if (hConsole == INVALID_HANDLE_VALUE)
+ return null;
+ return readConsoleKeyInput(hConsole, count, false);
}
private byte[] readConsoleInput() {
// XXX does how many events to read in one call matter?
INPUT_RECORD[] events = null;
try {
- events = WindowsSupport.readConsoleInput(1);
+ events = readConsoleInput(1);
} catch (IOException e) {
Log.debug("read Windows console input error: ", e);
}
@@ -304,11 +321,17 @@
}
private static int getWindowsTerminalWidth() {
- return WindowsSupport.getWindowsTerminalWidth();
+ long outputHandle = GetStdHandle (STD_OUTPUT_HANDLE);
+ CONSOLE_SCREEN_BUFFER_INFO info = new CONSOLE_SCREEN_BUFFER_INFO();
+ GetConsoleScreenBufferInfo (outputHandle, info);
+ return info.windowWidth();
}
private static int getWindowsTerminalHeight() {
- return WindowsSupport.getWindowsTerminalHeight();
+ long outputHandle = GetStdHandle (STD_OUTPUT_HANDLE);
+ CONSOLE_SCREEN_BUFFER_INFO info = new CONSOLE_SCREEN_BUFFER_INFO();
+ GetConsoleScreenBufferInfo (outputHandle, info);
+ return info.windowHeight();
}
/**

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Mon May 16 11:09:38 UTC 2022 - Fridrich Strba <fstrba@suse.com>
- Added patch:
* jline-jansi2.patch
+ fix jline build against jansi 2.4.x
- Remove dependency on jansi-native and hawtjni-runtime
-------------------------------------------------------------------
Sun Mar 20 13:12:08 UTC 2022 - Fridrich Strba <fstrba@suse.com>

View File

@ -26,11 +26,10 @@ URL: https://github.com/jline/jline2
Source0: https://github.com/jline/jline2/archive/jline-%{version}.tar.gz
Source1: %{name}-build.xml
Patch0: jline-java8compat.patch
Patch1: jline-jansi2.patch
BuildRequires: ant
BuildRequires: fdupes
BuildRequires: hawtjni-runtime
BuildRequires: jansi
BuildRequires: jansi-native
BuildRequires: javapackages-local
#!BuildIgnore: ant-antlr
Requires: mvn(org.fusesource.jansi:jansi)
@ -52,6 +51,7 @@ This package contains the API documentation for %{name}.
%prep
%setup -q -n jline2-jline-%{version}
%patch0 -p1
%patch1 -p1
%pom_change_dep org.fusesource.jansi:jansi org.fusesource.jansi:jansi:1.12
cp %{SOURCE1} build.xml
mkdir -p lib
@ -70,7 +70,7 @@ mkdir -p lib
%pom_remove_parent
%build
build-jar-repository -s lib jansi jansi-native hawtjni/hawtjni-runtime
build-jar-repository -s lib jansi
%{ant} package javadoc
%install