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

Fix support for the jansi.graceful property #272

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
java: [ '11', '17' ]
java: [ '21' ]
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -46,4 +46,4 @@ jobs:
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: mvn verify
run: mvn test
run: mvn verify -Dnosign
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ include Makefile.common

linux-armv6-digest:=@sha256:7bad6ab302af34bdf6634c8c2b02c8dc6ac932c67da9ecc199c549ab405e971e
linux-x86-digest:=@sha256:7a8fda5ff1bb436ac1f2e7d40043deb630800fce33d123d04779d48f85702dcd
linux-riscv64-digest:=@sha256:e10e1d3588cffffaf4d0721825e4f952710ad29d4b6630ea76d353914ffdc415
windows-static-x86-digest:=@sha256:896bd4a43bbc89502904afdc8d00e6f2422f8f35852cc59777d6426bfc8491e8
windows-static-x64-digest:=@sha256:f159861bc80b29e5dafb223477167bec53ecec6cdacb051d31e90c5823542100
windows-arm64-digest:=@sha256:f4b3c1a49ec8b53418cef1499dc3f9a54a5570b7a3ecdf42fc8c83eb94b01b7d
Expand Down Expand Up @@ -121,6 +122,12 @@ linux-ppc64: download-includes
docker run -it --rm -v $$PWD:/workdir --user $$(id -u):$$(id -g) \
-e CROSS_TRIPLE=powerpc64le-linux-gnu multiarch/crossbuild$(cross-build-digest) make clean-native native OS_NAME=Linux OS_ARCH=ppc64

target/dockcross/dockcross-linux-riscv64: dockcross
docker run --rm dockcross/linux-riscv64$(linux-riscv64-digest) > target/dockcross/dockcross-linux-riscv64
chmod +x target/dockcross/dockcross-linux-riscv64
linux-riscv64: download-includes target/dockcross/dockcross-linux-riscv64
target/dockcross/dockcross-linux-riscv64 bash -c 'make clean-native native CROSS_PREFIX=riscv64-unknown-linux-gnu- OS_NAME=Linux OS_ARCH=riscv64'

target/dockcross/dockcross-windows-static-x86: dockcross
docker run --rm dockcross/windows-static-x86$(windows-static-x86-digest) > target/dockcross/dockcross-windows-static-x86
chmod +x target/dockcross/dockcross-windows-static-x86
Expand Down
7 changes: 7 additions & 0 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ Linux-ppc64_LINKFLAGS := -shared -static-libgcc
Linux-ppc64_LIBNAME := libjansi.so
Linux-ppc64_JANSI_FLAGS :=

Linux-riscv64_CC := $(CROSS_PREFIX)gcc
Linux-riscv64_STRIP := $(CROSS_PREFIX)strip
Linux-riscv64_CCFLAGS := -I$(JAVA_HOME)/include -Itarget/inc -Itarget/inc/unix -Os -fPIC -fvisibility=hidden
Linux-riscv64_LINKFLAGS := -shared -static-libgcc
Linux-riscv64_LIBNAME := libjansi.so
Linux-riscv64_JANSI_FLAGS :=

DragonFly-x86_64_CC := $(CROSS_PREFIX)cc
DragonFly-x86_64_STRIP := $(CROSS_PREFIX)strip
DragonFly-x86_64_CCFLAGS := -I$(JAVA_HOME)/include -Itarget/inc -Itarget/inc/unix -O2 -fPIC -fvisibility=hidden
Expand Down
112 changes: 95 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@
</properties>

<dependencies>
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>nativeimage</artifactId>
<version>23.1.0</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
Expand Down Expand Up @@ -160,13 +167,67 @@
</resources>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<id>enforce-java</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>21</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.11.0</version>
<configuration>
<fork>true</fork>
<source>${jdkTarget}</source>
<target>${jdkTarget}</target>
<release>${jdkTarget}</release>
<compilerArgs>
<arg>-Xlint:-options</arg>
</compilerArgs>
</configuration>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<excludes>
<exclude>**/ffm/*.java</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>jdk-21</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>21</release>
<includes>
<include>**/ffm/*.java</include>
</includes>
<compilerArgs>
<arg>--enable-preview</arg>
</compilerArgs>
</configuration>
</execution>
<execution>
<id>default-testCompile</id>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
Expand Down Expand Up @@ -206,12 +267,14 @@
<configuration>
<jvmVersion>9</jvmVersion>
<module>
<mainClass>org.fusesource.jansi.AnsiMain</mainClass>
<moduleInfo>
<name>org.fusesource.jansi</name>
<exports>org.fusesource.jansi;
org.fusesource.jansi.io;</exports>
</moduleInfo>
</module>
<overwriteExistingFiles>true</overwriteExistingFiles>
</configuration>
</execution>
</executions>
Expand Down Expand Up @@ -324,20 +387,6 @@
<artifactId>maven-release-plugin</artifactId>
<version>3.0.0-M1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<goals>
<goal>sign</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
Expand All @@ -351,12 +400,12 @@
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.38.0</version>
<version>2.39.0</version>
<configuration>
<java>
<toggleOffOn />
<palantirJavaFormat>
<version>2.35.0</version>
<version>2.38.0</version>
</palantirJavaFormat>
<importOrder>
<order>java|javax,org,,\#</order>
Expand Down Expand Up @@ -410,4 +459,33 @@
</extensions>
</build>

<profiles>
<profile>
<id>sign</id>
<activation>
<property>
<name>!nosign</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<goals>
<goal>sign</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
41 changes: 32 additions & 9 deletions src/main/java/org/fusesource/jansi/Ansi.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,14 @@ public int value() {
}
}

@FunctionalInterface
public interface Consumer {
void apply(Ansi ansi);
}

public static final String DISABLE = Ansi.class.getName() + ".disable";

private static Callable<Boolean> detector = new Callable<Boolean>() {
public Boolean call() throws Exception {
return !Boolean.getBoolean(DISABLE);
}
};
private static Callable<Boolean> detector = () -> !Boolean.getBoolean(DISABLE);

public static void setDetector(final Callable<Boolean> detector) {
if (detector == null) throw new IllegalArgumentException();
Expand Down Expand Up @@ -374,7 +371,7 @@ public Ansi reset() {
}

private final StringBuilder builder;
private final ArrayList<Integer> attributeOptions = new ArrayList<Integer>(5);
private final ArrayList<Integer> attributeOptions = new ArrayList<>(5);

public Ansi() {
this(new StringBuilder(80));
Expand Down Expand Up @@ -716,19 +713,45 @@ public Ansi scrollDown(final int rows) {
return rows > 0 ? appendEscapeSequence('T', rows) : rows < 0 ? scrollUp(-rows) : this;
}

@Deprecated
public Ansi restorCursorPosition() {
return restoreCursorPosition();
}

public Ansi saveCursorPosition() {
saveCursorPositionSCO();
return saveCursorPositionDEC();
}

// SCO command
public Ansi saveCursorPositionSCO() {
return appendEscapeSequence('s');
}

@Deprecated
public Ansi restorCursorPosition() {
return appendEscapeSequence('u');
// DEC command
public Ansi saveCursorPositionDEC() {
builder.append(FIRST_ESC_CHAR);
builder.append('7');
return this;
}

public Ansi restoreCursorPosition() {
restoreCursorPositionSCO();
return restoreCursorPositionDEC();
}

// SCO command
public Ansi restoreCursorPositionSCO() {
return appendEscapeSequence('u');
}

// DEC command
public Ansi restoreCursorPositionDEC() {
builder.append(FIRST_ESC_CHAR);
builder.append('8');
return this;
}

public Ansi reset() {
return a(Attribute.RESET);
}
Expand Down
Loading
Loading