groovy: Fix libjansi issue
This commit is contained in:
parent
c064f5bc00
commit
68a9bd25d5
|
@ -0,0 +1,78 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2009 the original author(s).
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.fusesource.jansi;
|
||||||
|
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import static org.fusesource.jansi.AnsiRenderer.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print writer which supports automatic ANSI color rendering via {@link AnsiRenderer}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
|
||||||
|
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
|
||||||
|
* @since 1.1
|
||||||
|
*/
|
||||||
|
public class AnsiRenderWriter
|
||||||
|
extends PrintWriter
|
||||||
|
{
|
||||||
|
|
||||||
|
public AnsiRenderWriter(final OutputStream out) {
|
||||||
|
super(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnsiRenderWriter(final OutputStream out, final boolean autoFlush) {
|
||||||
|
super(out, autoFlush);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnsiRenderWriter(final Writer out) {
|
||||||
|
super(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnsiRenderWriter(final Writer out, final boolean autoFlush) {
|
||||||
|
super(out, autoFlush);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(final String s) {
|
||||||
|
if (test(s)) {
|
||||||
|
super.write(render(s));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
super.write(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Need to prevent partial output from being written while formatting or we will get rendering exceptions
|
||||||
|
//
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PrintWriter format(final String format, final Object... args) {
|
||||||
|
print(String.format(format, args));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PrintWriter format(final Locale l, final String format, final Object... args) {
|
||||||
|
print(String.format(l, format, args));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
--- a/bin/startGroovy
|
||||||
|
+++ b/bin/startGroovy
|
||||||
|
@@ -295,6 +295,7 @@
|
||||||
|
-Dgroovy.starter.conf="$GROOVY_CONF" \
|
||||||
|
-Dgroovy.home="$GROOVY_HOME" \
|
||||||
|
-Dtools.jar="$TOOLS_JAR" \
|
||||||
|
+ -Dlibrary.jansi.path="$GROOVY_HOME/lib/jansi-native" \
|
||||||
|
"$STARTER_MAIN_CLASS" \
|
||||||
|
--main "$CLASS" \
|
||||||
|
--conf "$GROOVY_CONF" \
|
|
@ -3,17 +3,57 @@ TERMUX_PKG_DESCRIPTION="A powerful multi-faceted programming language for the JV
|
||||||
TERMUX_PKG_LICENSE="Apache-2.0"
|
TERMUX_PKG_LICENSE="Apache-2.0"
|
||||||
TERMUX_PKG_MAINTAINER="@termux"
|
TERMUX_PKG_MAINTAINER="@termux"
|
||||||
TERMUX_PKG_VERSION=4.0.0
|
TERMUX_PKG_VERSION=4.0.0
|
||||||
TERMUX_PKG_SRCURL=https://groovy.jfrog.io/artifactory/dist-release-local/groovy-zips/apache-groovy-binary-$TERMUX_PKG_VERSION.zip
|
TERMUX_PKG_REVISION=1
|
||||||
TERMUX_PKG_SHA256=bd5b8af69c169f41c5c7aea00cb8832a6e232ee697f626e29d8f92adebe30df9
|
_JANSI_VERSION=2.4.0
|
||||||
TERMUX_PKG_DEPENDS="openjdk-17"
|
_JLINE_VERSION=2.14.6
|
||||||
|
_JANSI_TAGNAME="jansi-${_JANSI_VERSION}"
|
||||||
|
_JLINE2_TAGNAME="jline-${_JLINE_VERSION}"
|
||||||
|
TERMUX_PKG_SRCURL=(https://groovy.jfrog.io/artifactory/dist-release-local/groovy-zips/apache-groovy-binary-$TERMUX_PKG_VERSION.zip
|
||||||
|
https://github.com/fusesource/jansi/archive/refs/tags/${_JANSI_TAGNAME}.tar.gz
|
||||||
|
https://github.com/jline/jline2/archive/refs/tags/${_JLINE2_TAGNAME}.tar.gz)
|
||||||
|
TERMUX_PKG_SHA256=(bd5b8af69c169f41c5c7aea00cb8832a6e232ee697f626e29d8f92adebe30df9
|
||||||
|
ba18c50770eebb0b6f472254ada8608138e70045a564efa43626a09691dcf553
|
||||||
|
c6205afb214288cd8ef53f1ea1243ba9388c84b55c929f0b9e6cee7757c6efac)
|
||||||
|
TERMUX_PKG_DEPENDS="libjansi, openjdk-17"
|
||||||
TERMUX_PKG_BUILD_IN_SRC=true
|
TERMUX_PKG_BUILD_IN_SRC=true
|
||||||
TERMUX_PKG_PLATFORM_INDEPENDENT=true
|
TERMUX_PKG_PLATFORM_INDEPENDENT=true
|
||||||
|
|
||||||
termux_step_make_install() {
|
termux_step_post_get_source() {
|
||||||
|
mv jansi-${_JANSI_TAGNAME} jansi
|
||||||
|
cp "$TERMUX_PKG_BUILDER_DIR"/AnsiRenderWriter.java \
|
||||||
|
jansi/src/main/java/org/fusesource/jansi/
|
||||||
|
|
||||||
|
mv jline2-${_JLINE2_TAGNAME} jline2
|
||||||
|
rm -f jline2/src/main/java/jline/{Ansi,}WindowsTerminal.java
|
||||||
|
}
|
||||||
|
|
||||||
|
termux_step_make() {
|
||||||
rm -f ./bin/*.bat
|
rm -f ./bin/*.bat
|
||||||
|
|
||||||
|
mkdir -p lib/jansi-native
|
||||||
|
ln -sf $TERMUX_PREFIX/lib/libjansi.so lib/jansi-native/
|
||||||
|
|
||||||
|
local _JANSI_JARFILE="$TERMUX_PKG_BUILDDIR"/lib/${_JANSI_TAGNAME}.jar
|
||||||
|
rm "${_JANSI_JARFILE}"
|
||||||
|
cd "$TERMUX_PKG_BUILDDIR"/jansi/src/main/java
|
||||||
|
javac -encoding UTF-8 -source 1.8 -target 1.8 $(find . -name '*.java')
|
||||||
|
jar cf "${_JANSI_JARFILE}" $(find . -name '*.class')
|
||||||
|
|
||||||
|
local _JLINE_JARFILE="$TERMUX_PKG_BUILDDIR"/lib/${_JLINE2_TAGNAME}.jar
|
||||||
|
rm "${_JLINE_JARFILE}"
|
||||||
|
cd "$TERMUX_PKG_BUILDDIR"/jline2/src/main/java
|
||||||
|
javac -cp "${_JANSI_JARFILE}" -encoding UTF-8 -source 1.8 -target 1.8 \
|
||||||
|
$(find . -name '*.java')
|
||||||
|
jar cf "${_JLINE_JARFILE}" $(find . -name '*.class')
|
||||||
|
cd "$TERMUX_PKG_BUILDDIR"/jline2/src/main/resources
|
||||||
|
jar uf "${_JLINE_JARFILE}" $(find . -name '*.properties')
|
||||||
|
}
|
||||||
|
|
||||||
|
termux_step_make_install() {
|
||||||
rm -rf $TERMUX_PREFIX/opt/groovy
|
rm -rf $TERMUX_PREFIX/opt/groovy
|
||||||
mkdir -p $TERMUX_PREFIX/opt/groovy
|
mkdir -p $TERMUX_PREFIX/opt/groovy
|
||||||
cp -r ./* $TERMUX_PREFIX/opt/groovy/
|
find . -mindepth 1 -maxdepth 1 ! -name jansi ! -name jline2 \
|
||||||
|
-exec cp -r \{\} $TERMUX_PREFIX/opt/groovy/ \;
|
||||||
for i in $TERMUX_PREFIX/opt/groovy/bin/*; do
|
for i in $TERMUX_PREFIX/opt/groovy/bin/*; do
|
||||||
if [ ! -f "$i" ]; then
|
if [ ! -f "$i" ]; then
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
--- a/jline2/src/main/java/jline/TerminalFactory.java
|
||||||
|
+++ b/jline2/src/main/java/jline/TerminalFactory.java
|
||||||
|
@@ -166,7 +166,6 @@
|
||||||
|
private static final Map<Flavor, Class<? extends Terminal>> FLAVORS = new HashMap<Flavor, Class<? extends Terminal>>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
- registerFlavor(Flavor.WINDOWS, AnsiWindowsTerminal.class);
|
||||||
|
registerFlavor(Flavor.UNIX, UnixTerminal.class);
|
||||||
|
registerFlavor(Flavor.OSV, OSvTerminal.class);
|
||||||
|
}
|
||||||
|
--- a/jline2/src/main/java/jline/internal/Ansi.java
|
||||||
|
+++ b/jline2/src/main/java/jline/internal/Ansi.java
|
||||||
|
@@ -11,7 +11,12 @@
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
-import org.fusesource.jansi.AnsiOutputStream;
|
||||||
|
+import java.nio.charset.Charset;
|
||||||
|
+import org.fusesource.jansi.AnsiColors;
|
||||||
|
+import org.fusesource.jansi.AnsiMode;
|
||||||
|
+import org.fusesource.jansi.AnsiType;
|
||||||
|
+import org.fusesource.jansi.io.AnsiOutputStream;
|
||||||
|
+import org.fusesource.jansi.io.AnsiProcessor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ansi support.
|
||||||
|
@@ -25,7 +30,18 @@
|
||||||
|
if (str == null) return "";
|
||||||
|
try {
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
- AnsiOutputStream aos = new AnsiOutputStream(baos);
|
||||||
|
+
|
||||||
|
+ AnsiOutputStream.WidthSupplier width = new AnsiOutputStream.ZeroWidthSupplier();
|
||||||
|
+ AnsiMode mode = AnsiMode.Strip;
|
||||||
|
+ AnsiProcessor processor = null;
|
||||||
|
+ AnsiType type = AnsiType.Unsupported;
|
||||||
|
+ AnsiColors colors = AnsiColors.Colors16;
|
||||||
|
+ Charset cs = Charset.defaultCharset();
|
||||||
|
+ AnsiOutputStream.IoRunnable installer = null;
|
||||||
|
+ AnsiOutputStream.IoRunnable uninstaller = null;
|
||||||
|
+ boolean resetAtUninstall = false;
|
||||||
|
+
|
||||||
|
+ AnsiOutputStream aos = new AnsiOutputStream(baos, width, mode, processor, type, colors, cs, installer, uninstaller, resetAtUninstall);
|
||||||
|
aos.write(str.getBytes());
|
||||||
|
aos.close();
|
||||||
|
return baos.toString();
|
Loading…
Reference in New Issue