diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 2df0f2b2..169a1924 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -30,7 +30,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
- java: [ '1.8', '11', '17' ]
+ java: [ '11', '17' ]
steps:
- uses: actions/checkout@v2
with:
diff --git a/pom.xml b/pom.xml
index 40bbb48d..9cf9578f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -31,53 +31,61 @@
JansiJansi is a java library for generating and interpreting ANSI escape sequences.
-
- 7
- 1.7
- UTF-8
- 1.6.1
- 2021-10-14T05:42:06Z
-
-
http://fusesource.github.io/jansi2009
-
- jira
- https://github.com/fusesource/jansi/issues
-
+
+
+ Apache License, Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+ repo
+
+
+
+
+
+ chirino
+ Hiram Chirino
+ hiram@hiramchirino.com
+ http://hiramchirino.com
+ GMT-5
+
+
+ gnodet
+ Guillaume Nodet
+ gnodet@gmail.com
+ GMT+1
+
+ Discussion List
- http://groups.google.com/group/jansi
- jansi-dev@googlegroups.comjansi-dev+subscribe@googlegroups.comjansi-dev+unsubscribe@googlegroups.com
+ jansi-dev@googlegroups.com
+ http://groups.google.com/group/jansiCommits and Issue Tracker List
- http://groups.google.com/group/jansi-commits
- jansi-commits@googlegroups.comjansi-commits+subscribe@googlegroups.comjansi-commisots+unsubscribe@googlegroups.com
+ jansi-commits@googlegroups.com
+ http://groups.google.com/group/jansi-commits
-
-
- Apache License, Version 2.0
- http://www.apache.org/licenses/LICENSE-2.0.txt
- repo
-
-
-
- https://github.com/fusesource/jansiscm:git:git://github.com/fusesource/jansi.gitscm:git:ssh://git@github.com/fusesource/jansi.git
- HEAD
-
+ HEAD
+ https://github.com/fusesource/jansi
+
+
+
+ jira
+ https://github.com/fusesource/jansi/issues
+
@@ -92,53 +100,59 @@
+
+ 8
+ 8
+ UTF-8
+ 1.6.1
+ 2021-10-14T05:42:06Z
+
+
+
+
+ org.junit.jupiter
+ junit-jupiter
+ 5.7.0
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-params
+ 5.7.0
+ test
+
+
+ info.picocli
+ picocli-codegen
+ 4.5.2
+ test
+
+
+
- sonatype-nexus-snapshots
- Sonatype Snapshot Repository
- https://oss.sonatype.org/content/repositories/snapshotstrue
+ sonatype-nexus-snapshots
+ Sonatype Snapshot Repository
+ https://oss.sonatype.org/content/repositories/snapshots
-
-
- chirino
- Hiram Chirino
- hiram@hiramchirino.com
- http://hiramchirino.com
- GMT-5
-
-
- gnodet
- Guillaume Nodet
- gnodet@gmail.com
- GMT+1
-
-
-
-
-
- org.fusesource.mvnplugins
- fuse-jxr-skin
- 1.9
-
-
- src/main/resourcestrue
+ src/main/resources**/*.properties
- src/main/resourcesfalse
+ src/main/resources**/*.properties
@@ -151,25 +165,8 @@
maven-compiler-plugin3.8.1
- 8
- 8
+ ${jdkTarget}
-
-
- default-compile
-
- ${jdkTarget}
- ${jdkTarget}
-
-
-
- default-testCompile
-
- 1.8
- 1.8
-
-
- org.apache.felix
@@ -178,18 +175,16 @@
bundle-manifest
- process-classesmanifest
+ process-classesorg.fusesource.jansi.AnsiMain
-
- !org.fusesource.jansi.internal.native.*;
+ !org.fusesource.jansi.internal.native.*;
org.fusesource.jansi.*;
- -noimport:=true
-
+ -noimport:=true
<_removeheaders>Bnd-LastModified,Include-Resource,Private-Package,Originally-Created-By
<_reproducible>true
@@ -204,19 +199,17 @@
add-module-infos
- packageadd-module-info
+ package9org.fusesource.jansi
-
- org.fusesource.jansi;
- org.fusesource.jansi.io;
-
+ org.fusesource.jansi;
+ org.fusesource.jansi.io;
@@ -228,13 +221,20 @@
org.codehaus.mojoexec-maven-plugin3.0.0
+
+
+ info.picocli
+ picocli-codegen
+ 4.5.2
+
+ generate-graalvm-info
- process-classesjava
+ process-classestruetest
@@ -251,13 +251,6 @@
-
-
- info.picocli
- picocli-codegen
- 4.5.2
-
- org.apache.maven.plugins
@@ -338,10 +331,10 @@
sign-artifacts
- verifysign
+ verify
@@ -355,28 +348,66 @@
https://oss.sonatype.org/
+
+ com.diffplug.spotless
+ spotless-maven-plugin
+ 2.38.0
+
+
+
+
+ 2.35.0
+
+
+ java|javax,org,,\#
+
+
+
+ /*
+ * Copyright (C) 2009-2023 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.
+ */
+
+
+
+
+ false
+ 4
+ true
+
+
+
+ true
+
+
+
+
+
+ apply
+
+ process-sources
+
+
+
+
+
+ org.fusesource.mvnplugins
+ fuse-jxr-skin
+ 1.9
+
+
-
-
- org.junit.jupiter
- junit-jupiter
- 5.7.0
- test
-
-
- org.junit.jupiter
- junit-jupiter-params
- 5.7.0
- test
-
-
- info.picocli
- picocli-codegen
- 4.5.2
- test
-
-
-
diff --git a/src/main/java/org/fusesource/jansi/Ansi.java b/src/main/java/org/fusesource/jansi/Ansi.java
index 8c04569a..befe4b48 100644
--- a/src/main/java/org/fusesource/jansi/Ansi.java
+++ b/src/main/java/org/fusesource/jansi/Ansi.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2017 the original author(s).
+ * Copyright (C) 2009-2023 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.
@@ -22,7 +22,6 @@
* Provides a fluent API for generating
* ANSI escape sequences.
*
- * @author Hiram Chirino
* @since 1.0
*/
public class Ansi implements Appendable {
@@ -119,7 +118,6 @@ public String toString() {
public int value() {
return value;
}
-
}
/**
@@ -215,8 +213,7 @@ public static Ansi ansi(int size) {
}
}
- private static class NoAnsi
- extends Ansi {
+ private static class NoAnsi extends Ansi {
public NoAnsi() {
super();
}
@@ -900,8 +897,7 @@ private Ansi appendEscapeSequence(char command, Object... options) {
}
private void flushAttributes() {
- if (attributeOptions.isEmpty())
- return;
+ if (attributeOptions.isEmpty()) return;
if (attributeOptions.size() == 1 && attributeOptions.get(0) == 0) {
builder.append(FIRST_ESC_CHAR);
builder.append(SECOND_ESC_CHAR);
diff --git a/src/main/java/org/fusesource/jansi/AnsiColors.java b/src/main/java/org/fusesource/jansi/AnsiColors.java
index 7cc90961..aa677c1a 100644
--- a/src/main/java/org/fusesource/jansi/AnsiColors.java
+++ b/src/main/java/org/fusesource/jansi/AnsiColors.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2017 the original author(s).
+ * Copyright (C) 2009-2023 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.
@@ -21,7 +21,6 @@
* @since 2.1
*/
public enum AnsiColors {
-
Colors16("16 colors"),
Colors256("256 colors"),
TrueColor("24-bit colors");
diff --git a/src/main/java/org/fusesource/jansi/AnsiConsole.java b/src/main/java/org/fusesource/jansi/AnsiConsole.java
index ad648f8a..3b7b0032 100644
--- a/src/main/java/org/fusesource/jansi/AnsiConsole.java
+++ b/src/main/java/org/fusesource/jansi/AnsiConsole.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2017 the original author(s).
+ * Copyright (C) 2009-2023 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.
@@ -28,30 +28,29 @@
import org.fusesource.jansi.internal.CLibrary;
import org.fusesource.jansi.internal.CLibrary.WinSize;
+import org.fusesource.jansi.internal.Kernel32.CONSOLE_SCREEN_BUFFER_INFO;
import org.fusesource.jansi.io.AnsiOutputStream;
import org.fusesource.jansi.io.AnsiProcessor;
import org.fusesource.jansi.io.FastBufferedOutputStream;
import org.fusesource.jansi.io.WindowsAnsiProcessor;
-import org.fusesource.jansi.internal.Kernel32.CONSOLE_SCREEN_BUFFER_INFO;
import static org.fusesource.jansi.internal.CLibrary.ioctl;
import static org.fusesource.jansi.internal.CLibrary.isatty;
import static org.fusesource.jansi.internal.Kernel32.GetConsoleMode;
+import static org.fusesource.jansi.internal.Kernel32.GetConsoleScreenBufferInfo;
import static org.fusesource.jansi.internal.Kernel32.GetStdHandle;
import static org.fusesource.jansi.internal.Kernel32.STD_ERROR_HANDLE;
import static org.fusesource.jansi.internal.Kernel32.STD_OUTPUT_HANDLE;
import static org.fusesource.jansi.internal.Kernel32.SetConsoleMode;
-import static org.fusesource.jansi.internal.Kernel32.GetConsoleScreenBufferInfo;
/**
* Provides consistent access to an ANSI aware console PrintStream or an ANSI codes stripping PrintStream
- * if not on a terminal (see
+ * if not on a terminal (see
* Jansi native
* CLibrary isatty(int)).
*
The native library used is named jansi and is loaded using HawtJNI Runtime
* Library
*
- * @author Hiram Chirino
* @since 1.0
* @see #systemInstall()
* @see #out()
@@ -203,19 +202,18 @@ public static int getTerminalWidth() {
return w;
}
- static final boolean IS_WINDOWS = System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("win");
+ static final boolean IS_WINDOWS =
+ System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("win");
- static final boolean IS_CYGWIN = IS_WINDOWS
- && System.getenv("PWD") != null
- && System.getenv("PWD").startsWith("/");
+ static final boolean IS_CYGWIN =
+ IS_WINDOWS && System.getenv("PWD") != null && System.getenv("PWD").startsWith("/");
static final boolean IS_MSYSTEM = IS_WINDOWS
&& System.getenv("MSYSTEM") != null
&& (System.getenv("MSYSTEM").startsWith("MINGW")
- || System.getenv("MSYSTEM").equals("MSYS"));
+ || System.getenv("MSYSTEM").equals("MSYS"));
- static final boolean IS_CONEMU = IS_WINDOWS
- && System.getenv("ConEmuPID") != null;
+ static final boolean IS_CONEMU = IS_WINDOWS && System.getenv("ConEmuPID") != null;
static final int ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004;
@@ -223,7 +221,6 @@ public static int getTerminalWidth() {
static int STDERR_FILENO = 2;
-
static {
if (getBoolean(JANSI_EAGER)) {
initStreams();
@@ -234,8 +231,7 @@ public static int getTerminalWidth() {
private static int installed;
private static int virtualProcessing;
- private AnsiConsole() {
- }
+ private AnsiConsole() {}
private static AnsiPrintStream ansiStream(boolean stdout) {
FileDescriptor descriptor = stdout ? FileDescriptor.out : FileDescriptor.err;
@@ -277,13 +273,11 @@ private static AnsiPrintStream ansiStream(boolean stdout) {
type = withException ? AnsiType.Unsupported : AnsiType.Redirected;
installer = uninstaller = null;
width = new AnsiOutputStream.ZeroWidthSupplier();
- }
- else if (IS_WINDOWS) {
+ } else if (IS_WINDOWS) {
final long console = GetStdHandle(stdout ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE);
final int[] mode = new int[1];
final boolean isConsole = GetConsoleMode(console, mode) != 0;
- if (isConsole
- && SetConsoleMode(console, mode[0] | ENABLE_VIRTUAL_TERMINAL_PROCESSING) != 0) {
+ if (isConsole && SetConsoleMode(console, mode[0] | ENABLE_VIRTUAL_TERMINAL_PROCESSING) != 0) {
SetConsoleMode(console, mode[0]); // set it back for now, but we know it works
processor = null;
type = AnsiType.VirtualTerminal;
@@ -302,15 +296,14 @@ public void run() throws IOException {
}
}
};
- }
- else if ((IS_CONEMU || IS_CYGWIN || IS_MSYSTEM) && !isConsole) {
+ } else if ((IS_CONEMU || IS_CYGWIN || IS_MSYSTEM) && !isConsole) {
// ANSI-enabled ConEmu, Cygwin or MSYS(2) on Windows...
processor = null;
type = AnsiType.Native;
installer = uninstaller = null;
- }
- else {
- // On Windows, when no ANSI-capable terminal is used, we know the console does not natively interpret ANSI
+ } else {
+ // On Windows, when no ANSI-capable terminal is used, we know the console does not natively interpret
+ // ANSI
// codes but we can use jansi Kernel32 API for console
AnsiProcessor proc;
AnsiType ttype;
@@ -381,9 +374,7 @@ else if (getBoolean(JANSI_STRIP)) {
// the ansi escapes for piping it into ansi color aware commands (e.g. less -r)
else if (getBoolean(JANSI_FORCE)) {
mode = AnsiMode.Force;
- }
-
- else {
+ } else {
mode = isatty ? AnsiMode.Default : AnsiMode.Strip;
}
@@ -391,7 +382,8 @@ else if (getBoolean(JANSI_FORCE)) {
String colorterm, term;
// If the jansi.colors property is set, use it
- String jansiColors = System.getProperty(stdout ? JANSI_OUT_COLORS : JANSI_ERR_COLORS, System.getProperty(JANSI_COLORS));
+ String jansiColors =
+ System.getProperty(stdout ? JANSI_OUT_COLORS : JANSI_ERR_COLORS, System.getProperty(JANSI_COLORS));
if (JANSI_COLORS_TRUECOLOR.equals(jansiColors)) {
colors = AnsiColors.TrueColor;
} else if (JANSI_COLORS_256.equals(jansiColors)) {
@@ -433,8 +425,10 @@ else if (term != null && term.contains("-256color")) {
} catch (UnsupportedCharsetException e) {
}
}
- return newPrintStream(new AnsiOutputStream(out, width, mode, processor, type, colors, cs,
- installer, uninstaller, resetAtUninstall), cs.name());
+ return newPrintStream(
+ new AnsiOutputStream(
+ out, width, mode, processor, type, colors, cs, installer, uninstaller, resetAtUninstall),
+ cs.name());
}
private static AnsiPrintStream newPrintStream(AnsiOutputStream out, String enc) {
@@ -507,7 +501,7 @@ public static PrintStream sysErr() {
* AnsiConsole.err() to System.err.
* @see #systemUninstall()
*/
- synchronized static public void systemInstall() {
+ public static synchronized void systemInstall() {
if (installed == 0) {
initStreams();
try {
@@ -525,7 +519,7 @@ synchronized static public void systemInstall() {
/**
* check if the streams have been installed or not
*/
- synchronized public static boolean isInstalled() {
+ public static synchronized boolean isInstalled() {
return installed > 0;
}
@@ -534,7 +528,7 @@ synchronized public static boolean isInstalled() {
* multiple times, {@link #systemUninstall()} must be called the same number of times before
* it is actually uninstalled.
*/
- synchronized public static void systemUninstall() {
+ public static synchronized void systemUninstall() {
installed--;
if (installed == 0) {
try {
@@ -552,14 +546,11 @@ synchronized public static void systemUninstall() {
/**
* Initialize the out/err ansi-enabled streams
*/
- synchronized static void initStreams()
- {
- if ( !initialized )
- {
+ static synchronized void initStreams() {
+ if (!initialized) {
out = ansiStream(true);
err = ansiStream(false);
initialized = true;
}
}
-
}
diff --git a/src/main/java/org/fusesource/jansi/AnsiMain.java b/src/main/java/org/fusesource/jansi/AnsiMain.java
index 0de2e6fb..c2a845d6 100644
--- a/src/main/java/org/fusesource/jansi/AnsiMain.java
+++ b/src/main/java/org/fusesource/jansi/AnsiMain.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2017 the original author(s).
+ * Copyright (C) 2009-2023 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.
@@ -15,8 +15,6 @@
*/
package org.fusesource.jansi;
-import static org.fusesource.jansi.Ansi.ansi;
-
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.File;
@@ -31,6 +29,8 @@
import org.fusesource.jansi.internal.CLibrary;
import org.fusesource.jansi.internal.JansiLoader;
+import static org.fusesource.jansi.Ansi.ansi;
+
/**
* Main class for the library, providing executable jar to diagnose Jansi setup.
*
If no system property is set and output is sent to a terminal (no redirect to a file):
@@ -82,12 +82,12 @@ public static void main(String... args) throws IOException {
System.out.println();
System.out.println("os.name= " + System.getProperty("os.name") + ", "
- + "os.version= " + System.getProperty("os.version") + ", "
- + "os.arch= " + System.getProperty("os.arch"));
+ + "os.version= " + System.getProperty("os.version") + ", "
+ + "os.arch= " + System.getProperty("os.arch"));
System.out.println("file.encoding= " + System.getProperty("file.encoding"));
System.out.println("java.version= " + System.getProperty("java.version") + ", "
- + "java.vendor= " + System.getProperty("java.vendor") + ","
- + " java.home= " + System.getProperty("java.home"));
+ + "java.vendor= " + System.getProperty("java.vendor") + ","
+ + " java.home= " + System.getProperty("java.home"));
System.out.println();
@@ -98,7 +98,8 @@ public static void main(String... args) throws IOException {
System.out.println(AnsiConsole.JANSI_COLORS + "= " + System.getProperty(AnsiConsole.JANSI_COLORS, ""));
System.out.println(AnsiConsole.JANSI_OUT_COLORS + "= " + System.getProperty(AnsiConsole.JANSI_OUT_COLORS, ""));
System.out.println(AnsiConsole.JANSI_ERR_COLORS + "= " + System.getProperty(AnsiConsole.JANSI_ERR_COLORS, ""));
- System.out.println(AnsiConsole.JANSI_PASSTHROUGH + "= " + AnsiConsole.getBoolean(AnsiConsole.JANSI_PASSTHROUGH));
+ System.out.println(
+ AnsiConsole.JANSI_PASSTHROUGH + "= " + AnsiConsole.getBoolean(AnsiConsole.JANSI_PASSTHROUGH));
System.out.println(AnsiConsole.JANSI_STRIP + "= " + AnsiConsole.getBoolean(AnsiConsole.JANSI_STRIP));
System.out.println(AnsiConsole.JANSI_FORCE + "= " + AnsiConsole.getBoolean(AnsiConsole.JANSI_FORCE));
System.out.println(AnsiConsole.JANSI_NORESET + "= " + AnsiConsole.getBoolean(AnsiConsole.JANSI_NORESET));
@@ -116,7 +117,7 @@ public static void main(String... args) throws IOException {
System.out.println();
diagnoseTty(false); // System.out
- diagnoseTty(true); // System.err
+ diagnoseTty(true); // System.err
AnsiConsole.systemInstall();
@@ -153,10 +154,10 @@ public static void main(String... args) throws IOException {
if (args.length == 1) {
File f = new File(args[0]);
- if (f.exists())
- {
+ if (f.exists()) {
// write file content
- System.out.println(ansi().bold().a("\"" + args[0] + "\" content:").reset());
+ System.out.println(
+ ansi().bold().a("\"" + args[0] + "\" content:").reset());
writeFileContent(f);
return;
}
@@ -165,14 +166,14 @@ public static void main(String... args) throws IOException {
// write args without Jansi then with Jansi AnsiConsole
System.out.println(ansi().bold().a("original args:").reset());
int i = 1;
- for (String arg: args) {
+ for (String arg : args) {
AnsiConsole.system_out.print(i++ + ": ");
AnsiConsole.system_out.println(arg);
}
System.out.println(ansi().bold().a("Jansi filtered args:").reset());
i = 1;
- for (String arg: args) {
+ for (String arg : args) {
System.out.print(i++ + ": ");
System.out.println(arg);
}
@@ -183,7 +184,7 @@ public static void main(String... args) throws IOException {
private static String getJansiVersion() {
Package p = AnsiMain.class.getPackage();
- return ( p == null ) ? null : p.getImplementationVersion();
+ return (p == null) ? null : p.getImplementationVersion();
}
private static void diagnoseTty(boolean stderr) {
@@ -191,40 +192,40 @@ private static void diagnoseTty(boolean stderr) {
int isatty = CLibrary.LOADED ? CLibrary.isatty(fd) : 0;
System.out.println("isatty(STD" + (stderr ? "ERR" : "OUT") + "_FILENO): " + isatty + ", System."
- + (stderr ? "err" : "out") + " " + ((isatty == 0) ? "is *NOT*" : "is") + " a terminal");
+ + (stderr ? "err" : "out") + " " + ((isatty == 0) ? "is *NOT*" : "is") + " a terminal");
}
private static void testAnsi(boolean stderr) {
- @SuppressWarnings( "resource" )
+ @SuppressWarnings("resource")
PrintStream s = stderr ? System.err : System.out;
s.print("test on System." + (stderr ? "err" : "out") + ":");
- for(Ansi.Color c: Ansi.Color.values()) {
+ for (Ansi.Color c : Ansi.Color.values()) {
s.print(" " + ansi().fg(c) + c + ansi().reset());
}
s.println();
s.print(" bright:");
- for(Ansi.Color c: Ansi.Color.values()) {
+ for (Ansi.Color c : Ansi.Color.values()) {
s.print(" " + ansi().fgBright(c) + c + ansi().reset());
}
s.println();
s.print(" bold:");
- for(Ansi.Color c: Ansi.Color.values()) {
+ for (Ansi.Color c : Ansi.Color.values()) {
s.print(" " + ansi().bold().fg(c) + c + ansi().reset());
}
s.println();
s.print(" faint:");
- for(Ansi.Color c: Ansi.Color.values()) {
+ for (Ansi.Color c : Ansi.Color.values()) {
s.print(" " + ansi().a(Attribute.INTENSITY_FAINT).fg(c) + c + ansi().reset());
}
s.println();
s.print(" bold+faint:");
- for(Ansi.Color c: Ansi.Color.values()) {
+ for (Ansi.Color c : Ansi.Color.values()) {
s.print(" " + ansi().bold().a(Attribute.INTENSITY_FAINT).fg(c) + c + ansi().reset());
}
s.println();
Ansi ansi = ansi();
ansi.a(" 256 colors: ");
- for (int i = 0; i < 6*6*6; i++) {
+ for (int i = 0; i < 6 * 6 * 6; i++) {
if (i > 0 && i % 36 == 0) {
ansi.reset();
ansi.newline();
@@ -234,7 +235,7 @@ private static void testAnsi(boolean stderr) {
ansi.a(" ");
}
int a0 = i % 6;
- int a1 = (i / 6) % 6;
+ int a1 = (i / 6) % 6;
int a2 = i / 36;
ansi.bg(16 + a0 + a2 * 6 + a1 * 36).a(' ');
}
@@ -272,7 +273,8 @@ private static String getPomPropertiesVersion(String path) throws IOException {
}
private static void printJansiLogoDemo() throws IOException {
- BufferedReader in = new BufferedReader(new InputStreamReader(AnsiMain.class.getResourceAsStream("jansi.txt"), "UTF-8"));
+ BufferedReader in =
+ new BufferedReader(new InputStreamReader(AnsiMain.class.getResourceAsStream("jansi.txt"), "UTF-8"));
try {
String l;
while ((l = in.readLine()) != null) {
diff --git a/src/main/java/org/fusesource/jansi/AnsiMode.java b/src/main/java/org/fusesource/jansi/AnsiMode.java
index 5897197d..a0675760 100644
--- a/src/main/java/org/fusesource/jansi/AnsiMode.java
+++ b/src/main/java/org/fusesource/jansi/AnsiMode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2017 the original author(s).
+ * Copyright (C) 2009-2023 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.
@@ -21,7 +21,6 @@
* @since 2.1
*/
public enum AnsiMode {
-
Strip("Strip all ansi sequences"),
Default("Print ansi sequences if the stream is a terminal"),
Force("Always print ansi sequences, even if the stream is redirected");
diff --git a/src/main/java/org/fusesource/jansi/AnsiPrintStream.java b/src/main/java/org/fusesource/jansi/AnsiPrintStream.java
index df6e5a65..ddaff741 100644
--- a/src/main/java/org/fusesource/jansi/AnsiPrintStream.java
+++ b/src/main/java/org/fusesource/jansi/AnsiPrintStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2020 the original author(s).
+ * Copyright (C) 2009-2023 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.
@@ -31,7 +31,8 @@ public AnsiPrintStream(AnsiOutputStream out, boolean autoFlush) {
super(out, autoFlush);
}
- public AnsiPrintStream(AnsiOutputStream out, boolean autoFlush, String encoding) throws UnsupportedEncodingException {
+ public AnsiPrintStream(AnsiOutputStream out, boolean autoFlush, String encoding)
+ throws UnsupportedEncodingException {
super(out, autoFlush, encoding);
}
diff --git a/src/main/java/org/fusesource/jansi/AnsiRenderer.java b/src/main/java/org/fusesource/jansi/AnsiRenderer.java
index 09f4e422..20b1c179 100644
--- a/src/main/java/org/fusesource/jansi/AnsiRenderer.java
+++ b/src/main/java/org/fusesource/jansi/AnsiRenderer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2021 the original author(s).
+ * Copyright (C) 2009-2023 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.
@@ -115,8 +115,7 @@ public static Appendable render(final String input, Appendable target) throws IO
}
public static String render(final String text, final String... codes) {
- return render(Ansi.ansi(), codes)
- .a(text).reset().toString();
+ return render(Ansi.ansi(), codes).a(text).reset().toString();
}
/**
@@ -214,7 +213,7 @@ public enum Code {
// Aliases
BOLD(Attribute.INTENSITY_BOLD),
- FAINT(Attribute.INTENSITY_FAINT),;
+ FAINT(Attribute.INTENSITY_FAINT);
private final Enum> n;
@@ -250,7 +249,5 @@ public boolean isBackground() {
}
}
- private AnsiRenderer() {
- }
-
-}
\ No newline at end of file
+ private AnsiRenderer() {}
+}
diff --git a/src/main/java/org/fusesource/jansi/AnsiType.java b/src/main/java/org/fusesource/jansi/AnsiType.java
index 9e7f9a4f..90ddee75 100644
--- a/src/main/java/org/fusesource/jansi/AnsiType.java
+++ b/src/main/java/org/fusesource/jansi/AnsiType.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2017 the original author(s).
+ * Copyright (C) 2009-2023 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.
@@ -21,7 +21,6 @@
* @since 2.1
*/
public enum AnsiType {
-
Native("Supports ansi sequences natively"),
Unsupported("Ansi sequences are stripped out"),
VirtualTerminal("Supported through windows virtual terminal"),
diff --git a/src/main/java/org/fusesource/jansi/WindowsSupport.java b/src/main/java/org/fusesource/jansi/WindowsSupport.java
index 989fa3f4..010f527e 100644
--- a/src/main/java/org/fusesource/jansi/WindowsSupport.java
+++ b/src/main/java/org/fusesource/jansi/WindowsSupport.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2019 the original author(s).
+ * Copyright (C) 2009-2023 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.
@@ -38,5 +38,4 @@ public static String getErrorMessage(int errorCode) {
throw new IllegalStateException(e);
}
}
-
}
diff --git a/src/main/java/org/fusesource/jansi/internal/CLibrary.java b/src/main/java/org/fusesource/jansi/internal/CLibrary.java
index ec7e8ad8..2e2285c3 100644
--- a/src/main/java/org/fusesource/jansi/internal/CLibrary.java
+++ b/src/main/java/org/fusesource/jansi/internal/CLibrary.java
@@ -1,11 +1,11 @@
/*
- * Copyright (C) 2009-2017 the original author(s).
+ * Copyright (C) 2009-2023 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
+ * 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,
@@ -20,7 +20,6 @@
* HawtJNI Runtime
* as jansi library.
*
- * @author Hiram Chirino
* @see JansiLoader
*/
@SuppressWarnings("unused")
@@ -89,36 +88,20 @@ public class CLibrary {
* @return 0 on success
* @see OPENPTY(3) man-page
*/
- public static native int openpty(
- int[] amaster,
- int[] aslave,
- byte[] name,
- Termios termios,
- WinSize winsize);
-
- public static native int tcgetattr(
- int filedes,
- Termios termios);
-
- public static native int tcsetattr(
- int filedes,
- int optional_actions,
- Termios termios);
+ public static native int openpty(int[] amaster, int[] aslave, byte[] name, Termios termios, WinSize winsize);
+
+ public static native int tcgetattr(int filedes, Termios termios);
+
+ public static native int tcsetattr(int filedes, int optional_actions, Termios termios);
/**
* Control a STREAMS device.
*
* @see IOCTL(3P) man-page
*/
- public static native int ioctl(
- int filedes,
- long request,
- int[] params);
+ public static native int ioctl(int filedes, long request, int[] params);
- public static native int ioctl(
- int filedes,
- long request,
- WinSize params);
+ public static native int ioctl(int filedes, long request, WinSize params);
/**
* Window sizes.
@@ -141,8 +124,7 @@ public static class WinSize {
public short ws_xpixel;
public short ws_ypixel;
- public WinSize() {
- }
+ public WinSize() {}
public WinSize(short ws_row, short ws_col) {
this.ws_row = ws_row;
@@ -175,5 +157,4 @@ public static class Termios {
public long c_ispeed;
public long c_ospeed;
}
-
}
diff --git a/src/main/java/org/fusesource/jansi/internal/JansiLoader.java b/src/main/java/org/fusesource/jansi/internal/JansiLoader.java
index 8a08e5e2..b9c307cf 100644
--- a/src/main/java/org/fusesource/jansi/internal/JansiLoader.java
+++ b/src/main/java/org/fusesource/jansi/internal/JansiLoader.java
@@ -1,3 +1,20 @@
+/*
+ * Copyright (C) 2009-2023 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.internal;
+
/*--------------------------------------------------------------------------
* Copyright 2007 Taro L. Saito
*
@@ -13,7 +30,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
-package org.fusesource.jansi.internal;
import java.io.File;
import java.io.FileInputStream;
@@ -62,7 +78,9 @@ public static synchronized boolean initialize() {
loadJansiNativeLibrary();
} catch (Exception e) {
if (!Boolean.parseBoolean(System.getProperty(AnsiConsole.JANSI_GRACEFUL, "true"))) {
- throw new RuntimeException("Unable to load jansi native library. You may want set the `jansi.graceful` system property to true to be able to use Jansi on your platform", e);
+ throw new RuntimeException(
+ "Unable to load jansi native library. You may want set the `jansi.graceful` system property to true to be able to use Jansi on your platform",
+ e);
}
}
return loaded;
@@ -114,8 +132,7 @@ private static int readNBytes(InputStream in, byte[] b) throws IOException {
int len = b.length;
while (n < len) {
int count = in.read(b, n, len - n);
- if (count <= 0)
- break;
+ if (count <= 0) break;
n += count;
}
return n;
@@ -160,8 +177,8 @@ private static String contentsEquals(InputStream in1, InputStream in2) throws IO
* @param targetFolder Target folder.
* @return
*/
- private static boolean extractAndLoadLibraryFile(String libFolderForCurrentOS, String libraryFileName,
- String targetFolder) {
+ private static boolean extractAndLoadLibraryFile(
+ String libFolderForCurrentOS, String libraryFileName, String targetFolder) {
String nativeLibraryFilePath = libFolderForCurrentOS + "/" + libraryFileName;
// Include architecture name in temporary filename in order to avoid conflicts
// when multiple JVMs with different architectures running at the same time
@@ -197,14 +214,16 @@ private static boolean extractAndLoadLibraryFile(String libFolderForCurrentOS, S
try (InputStream extractedLibIn = new FileInputStream(extractedLibFile)) {
String eq = contentsEquals(nativeIn, extractedLibIn);
if (eq != null) {
- throw new RuntimeException(String.format("Failed to write a native library file at %s because %s", extractedLibFile, eq));
+ throw new RuntimeException(String.format(
+ "Failed to write a native library file at %s because %s", extractedLibFile, eq));
}
}
}
// Load library
if (loadNativeLibrary(extractedLibFile)) {
- nativeLibrarySourceUrl = JansiLoader.class.getResource(nativeLibraryFilePath).toExternalForm();
+ nativeLibrarySourceUrl =
+ JansiLoader.class.getResource(nativeLibraryFilePath).toExternalForm();
return true;
}
} catch (IOException e) {
@@ -241,13 +260,16 @@ private static boolean loadNativeLibrary(File libPath) {
} catch (UnsatisfiedLinkError e) {
if (!libPath.canExecute()) {
// NOTE: this can be tested using something like:
- // docker run --rm --tmpfs /tmp -v $PWD:/jansi openjdk:11 java -jar /jansi/target/jansi-xxx-SNAPSHOT.jar
- System.err.printf("Failed to load native library:%s. The native library file at %s is not executable, "
- + "make sure that the directory is mounted on a partition without the noexec flag, or set the "
- + "jansi.tmpdir system property to point to a proper location. osinfo: %s%n",
+ // docker run --rm --tmpfs /tmp -v $PWD:/jansi openjdk:11 java -jar
+ // /jansi/target/jansi-xxx-SNAPSHOT.jar
+ System.err.printf(
+ "Failed to load native library:%s. The native library file at %s is not executable, "
+ + "make sure that the directory is mounted on a partition without the noexec flag, or set the "
+ + "jansi.tmpdir system property to point to a proper location. osinfo: %s%n",
libPath.getName(), libPath, OSInfo.getNativeLibFolderPathForCurrentOS());
} else {
- System.err.printf("Failed to load native library:%s. osinfo: %s%n",
+ System.err.printf(
+ "Failed to load native library:%s. osinfo: %s%n",
libPath.getName(), OSInfo.getNativeLibFolderPathForCurrentOS());
}
System.err.println(e);
@@ -301,10 +323,10 @@ private static void loadJansiNativeLibrary() throws Exception {
// Load the os-dependent library from the jar file
String packagePath = JansiLoader.class.getPackage().getName().replace('.', '/');
- jansiNativeLibraryPath = String.format("/%s/native/%s", packagePath, OSInfo.getNativeLibFolderPathForCurrentOS());
+ jansiNativeLibraryPath =
+ String.format("/%s/native/%s", packagePath, OSInfo.getNativeLibFolderPathForCurrentOS());
boolean hasNativeLib = hasResource(jansiNativeLibraryPath + "/" + jansiNativeLibraryName);
-
if (hasNativeLib) {
// temporary library folder
String tempFolder = getTempDir().getAbsolutePath();
@@ -331,7 +353,8 @@ private static void loadJansiNativeLibrary() throws Exception {
}
}
- throw new Exception(String.format("No native library found for os.name=%s, os.arch=%s, paths=[%s]",
+ throw new Exception(String.format(
+ "No native library found for os.name=%s, os.arch=%s, paths=[%s]",
OSInfo.getOSName(), OSInfo.getArchName(), join(triedPaths, File.pathSeparator)));
}
@@ -339,7 +362,6 @@ private static boolean hasResource(String path) {
return JansiLoader.class.getResource(path) != null;
}
-
/**
* @return The major version of the jansi library.
*/
@@ -381,14 +403,11 @@ private static String join(List list, String separator) {
StringBuilder sb = new StringBuilder();
boolean first = true;
for (String item : list) {
- if (first)
- first = false;
- else
- sb.append(separator);
+ if (first) first = false;
+ else sb.append(separator);
sb.append(item);
}
return sb.toString();
}
-
}
diff --git a/src/main/java/org/fusesource/jansi/internal/Kernel32.java b/src/main/java/org/fusesource/jansi/internal/Kernel32.java
index 1a779458..1d45de1f 100644
--- a/src/main/java/org/fusesource/jansi/internal/Kernel32.java
+++ b/src/main/java/org/fusesource/jansi/internal/Kernel32.java
@@ -1,11 +1,11 @@
/*
- * Copyright (C) 2009-2017 the original author(s).
+ * Copyright (C) 2009-2023 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
+ * 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,
@@ -22,8 +22,6 @@
/**
* Interface to access Win32 base APIs.
*
- * @author Hiram Chirino
- * @author Guillaume Nodet
* @see JansiLoader
*/
@SuppressWarnings("unused")
@@ -58,7 +56,6 @@ public class Kernel32 {
public static int STD_ERROR_HANDLE;
public static int INVALID_HANDLE_VALUE;
-
public static native long malloc(long size);
public static native void free(long ptr);
@@ -66,7 +63,7 @@ public class Kernel32 {
/**
* http://msdn.microsoft.com/en-us/library/ms686311%28VS.85%29.aspx
*/
- static public class SMALL_RECT {
+ public static class SMALL_RECT {
static {
JansiLoader.initialize();
init();
@@ -102,9 +99,7 @@ public SMALL_RECT copy() {
/**
* see http://msdn.microsoft.com/en-us/library/ms686047%28VS.85%29.aspx
*/
- public static native int SetConsoleTextAttribute(
- long consoleOutput,
- short attributes);
+ public static native int SetConsoleTextAttribute(long consoleOutput, short attributes);
public static class COORD {
@@ -157,7 +152,6 @@ public int windowHeight() {
}
}
-
// DWORD WINAPI WaitForSingleObject(
// _In_ HANDLE hHandle,
// _In_ DWORD dwMilliseconds
@@ -169,29 +163,19 @@ public int windowHeight() {
*/
public static native int CloseHandle(long handle);
-
/**
* see: http://msdn.microsoft.com/en-us/library/ms679360(VS.85).aspx
*/
public static native int GetLastError();
public static native int FormatMessageW(
- int flags,
- long source,
- int messageId,
- int languageId,
- byte[] buffer,
- int size,
- long[] args
- );
-
+ int flags, long source, int messageId, int languageId, byte[] buffer, int size, long[] args);
/**
* See: http://msdn.microsoft.com/en-us/library/ms683171%28VS.85%29.aspx
*/
public static native int GetConsoleScreenBufferInfo(
- long consoleOutput,
- CONSOLE_SCREEN_BUFFER_INFO consoleScreenBufferInfo);
+ long consoleOutput, CONSOLE_SCREEN_BUFFER_INFO consoleScreenBufferInfo);
/**
* see: http://msdn.microsoft.com/en-us/library/ms683231%28VS.85%29.aspx
@@ -201,68 +185,47 @@ public static native int GetConsoleScreenBufferInfo(
/**
* http://msdn.microsoft.com/en-us/library/ms686025%28VS.85%29.aspx
*/
- public static native int SetConsoleCursorPosition(
- long consoleOutput,
- COORD cursorPosition);
+ public static native int SetConsoleCursorPosition(long consoleOutput, COORD cursorPosition);
/**
* see: http://msdn.microsoft.com/en-us/library/ms682663%28VS.85%29.aspx
*/
public static native int FillConsoleOutputCharacterW(
- long consoleOutput,
- char character,
- int length,
- COORD writeCoord,
- int[] numberOfCharsWritten);
+ long consoleOutput, char character, int length, COORD writeCoord, int[] numberOfCharsWritten);
/**
* see: https://msdn.microsoft.com/en-us/library/ms682662%28VS.85%29.aspx
*/
public static native int FillConsoleOutputAttribute(
- long consoleOutput,
- short attribute,
- int length,
- COORD writeCoord,
- int[] numberOfAttrsWritten);
+ long consoleOutput, short attribute, int length, COORD writeCoord, int[] numberOfAttrsWritten);
/**
* see: http://msdn.microsoft.com/en-us/library/ms687401(v=VS.85).aspx
*/
public static native int WriteConsoleW(
- long consoleOutput,
- char[] buffer,
- int numberOfCharsToWrite,
- int[] numberOfCharsWritten,
- long reserved);
+ long consoleOutput, char[] buffer, int numberOfCharsToWrite, int[] numberOfCharsWritten, long reserved);
/**
* see: http://msdn.microsoft.com/en-us/library/ms683167%28VS.85%29.aspx
*/
- public static native int GetConsoleMode(
- long handle,
- int[] mode);
+ public static native int GetConsoleMode(long handle, int[] mode);
/**
* see: http://msdn.microsoft.com/en-us/library/ms686033%28VS.85%29.aspx
*/
- public static native int SetConsoleMode(
- long handle,
- int mode);
+ public static native int SetConsoleMode(long handle, int mode);
/**
* see: http://msdn.microsoft.com/en-us/library/078sfkak(VS.80).aspx
*/
public static native int _getch();
-
/**
* see: http://msdn.microsoft.com/en-us/library/ms686050%28VS.85%29.aspx
*
* @return 0 if title was set successfully
*/
- public static native int SetConsoleTitle(
- String title);
-
+ public static native int SetConsoleTitle(String title);
/**
* see: http://msdn.microsoft.com/en-us/library/ms683169(v=VS.85).aspx
@@ -337,14 +300,13 @@ public static class KEY_EVENT_RECORD {
public int controlKeyState;
public String toString() {
- return "KEY_EVENT_RECORD{" +
- "keyDown=" + keyDown +
- ", repeatCount=" + repeatCount +
- ", keyCode=" + keyCode +
- ", scanCode=" + scanCode +
- ", uchar=" + uchar +
- ", controlKeyState=" + controlKeyState +
- '}';
+ return "KEY_EVENT_RECORD{" + "keyDown="
+ + keyDown + ", repeatCount="
+ + repeatCount + ", keyCode="
+ + keyCode + ", scanCode="
+ + scanCode + ", uchar="
+ + uchar + ", controlKeyState="
+ + controlKeyState + '}';
}
}
@@ -388,12 +350,11 @@ public static class MOUSE_EVENT_RECORD {
public int eventFlags;
public String toString() {
- return "MOUSE_EVENT_RECORD{" +
- "mousePosition=" + mousePosition +
- ", buttonState=" + buttonState +
- ", controlKeyState=" + controlKeyState +
- ", eventFlags=" + eventFlags +
- '}';
+ return "MOUSE_EVENT_RECORD{" + "mousePosition="
+ + mousePosition + ", buttonState="
+ + buttonState + ", controlKeyState="
+ + controlKeyState + ", eventFlags="
+ + eventFlags + '}';
}
}
@@ -473,49 +434,33 @@ public static class INPUT_RECORD {
public MENU_EVENT_RECORD menuEvent = new MENU_EVENT_RECORD();
public FOCUS_EVENT_RECORD focusEvent = new FOCUS_EVENT_RECORD();
- public static native void memmove(
- INPUT_RECORD dest,
- long src,
- long size);
-
+ public static native void memmove(INPUT_RECORD dest, long src, long size);
}
/**
* see: http://msdn.microsoft.com/en-us/library/ms684961(v=VS.85).aspx
*/
- private static native int ReadConsoleInputW(
- long handle,
- long inputRecord,
- int length,
- int[] eventsCount);
+ private static native int ReadConsoleInputW(long handle, long inputRecord, int length, int[] eventsCount);
/**
* see: http://msdn.microsoft.com/en-us/library/ms684344(v=VS.85).aspx
*/
- private static native int PeekConsoleInputW(
- long handle,
- long inputRecord,
- int length,
- int[] eventsCount);
+ private static native int PeekConsoleInputW(long handle, long inputRecord, int length, int[] eventsCount);
/**
* see: http://msdn.microsoft.com/en-us/library/ms683207(v=VS.85).aspx
*/
- public static native int GetNumberOfConsoleInputEvents(
- long handle,
- int[] numberOfEvents);
+ public static native int GetNumberOfConsoleInputEvents(long handle, int[] numberOfEvents);
/**
* see: http://msdn.microsoft.com/en-us/library/ms683147(v=VS.85).aspx
*/
- public static native int FlushConsoleInputBuffer(
- long handle);
+ public static native int FlushConsoleInputBuffer(long handle);
/**
* Return console input events.
*/
- public static INPUT_RECORD[] readConsoleInputHelper(
- long handle, int count, boolean peek) throws IOException {
+ public static INPUT_RECORD[] readConsoleInputHelper(long handle, int count, boolean peek) throws IOException {
int[] length = new int[1];
int res;
long inputRecordPtr = 0;
@@ -524,8 +469,8 @@ public static INPUT_RECORD[] readConsoleInputHelper(
if (inputRecordPtr == 0) {
throw new IOException("cannot allocate memory with JNI");
}
- res = peek ?
- PeekConsoleInputW(handle, inputRecordPtr, count, length)
+ res = peek
+ ? PeekConsoleInputW(handle, inputRecordPtr, count, length)
: ReadConsoleInputW(handle, inputRecordPtr, count, length);
if (res == 0) {
throw new IOException("ReadConsoleInputW failed: " + WindowsSupport.getLastErrorMessage());
@@ -552,8 +497,7 @@ public static INPUT_RECORD[] readConsoleInputHelper(
* @param count requested number of events
* @return array possibly of size smaller then count
*/
- public static INPUT_RECORD[] readConsoleKeyInput(long handle, int count, boolean peek)
- throws IOException {
+ public static INPUT_RECORD[] readConsoleKeyInput(long handle, int count, boolean peek) throws IOException {
while (true) {
// read events until we have keyboard events, the queue could be full
// of mouse events.
@@ -574,6 +518,4 @@ public static INPUT_RECORD[] readConsoleKeyInput(long handle, int count, boolean
}
}
}
-
-
}
diff --git a/src/main/java/org/fusesource/jansi/internal/OSInfo.java b/src/main/java/org/fusesource/jansi/internal/OSInfo.java
index f96e5e26..8c9999ca 100644
--- a/src/main/java/org/fusesource/jansi/internal/OSInfo.java
+++ b/src/main/java/org/fusesource/jansi/internal/OSInfo.java
@@ -1,3 +1,20 @@
+/*
+ * Copyright (C) 2009-2023 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.internal;
+
/*--------------------------------------------------------------------------
* Copyright 2008 Taro L. Saito
*
@@ -13,7 +30,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
-package org.fusesource.jansi.internal;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -24,7 +40,6 @@
/**
* Provides OS name and architecture name.
*
- * @author leo
*/
public class OSInfo {
@@ -37,6 +52,7 @@ public class OSInfo {
public static final String ARM64 = "arm64";
private static final HashMap archMapping = new HashMap();
+
static {
// x86 mappings
archMapping.put(X86, X86);
@@ -78,7 +94,6 @@ public class OSInfo {
archMapping.put("aarch64", ARM64);
}
-
public static void main(String[] args) {
if (args.length >= 1) {
if ("--os".equals(args[0])) {
@@ -120,7 +135,6 @@ public static boolean isAlpine() {
} catch (Throwable e) {
return false;
}
-
}
static String getHardwareName() {
@@ -190,8 +204,7 @@ public static String getArchName() {
osArch = resolveArmArchType();
} else {
String lc = osArch.toLowerCase(Locale.US);
- if (archMapping.containsKey(lc))
- return archMapping.get(lc);
+ if (archMapping.containsKey(lc)) return archMapping.get(lc);
}
return translateArchNameToFolderName(osArch);
}
@@ -201,8 +214,8 @@ static String translateOSNameToFolderName(String osName) {
return "Windows";
} else if (osName.contains("Mac") || osName.contains("Darwin")) {
return "Mac";
-// } else if (isAlpine()) {
-// return "Linux-Alpine";
+ // } else if (isAlpine()) {
+ // return "Linux-Alpine";
} else if (osName.contains("Linux")) {
return "Linux";
} else if (osName.contains("AIX")) {
diff --git a/src/main/java/org/fusesource/jansi/io/AnsiOutputStream.java b/src/main/java/org/fusesource/jansi/io/AnsiOutputStream.java
index 35f41ec0..d925d728 100644
--- a/src/main/java/org/fusesource/jansi/io/AnsiOutputStream.java
+++ b/src/main/java/org/fusesource/jansi/io/AnsiOutputStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2020 the original author(s).
+ * Copyright (C) 2009-2023 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.
@@ -26,14 +26,13 @@
import org.fusesource.jansi.AnsiType;
/**
- * A ANSI print stream extracts ANSI escape codes written to
+ * A ANSI print stream extracts ANSI escape codes written to
* an output stream and calls corresponding AnsiProcessor.process* methods.
* This particular class is not synchronized for improved performances.
*
*
For more information about ANSI escape codes, see
* Wikipedia article
*
- * @author Guillaume Nodet
* @since 1.0
* @see AnsiProcessor
*/
@@ -76,7 +75,7 @@ public int getTerminalWidth() {
private static final int SECOND_CHARSET1_CHAR = ')';
private AnsiProcessor ap;
- private final static int MAX_ESCAPE_SEQUENCE_LENGTH = 100;
+ private static final int MAX_ESCAPE_SEQUENCE_LENGTH = 100;
private final byte[] buffer = new byte[MAX_ESCAPE_SEQUENCE_LENGTH];
private int pos = 0;
private int startOfValue;
@@ -93,9 +92,17 @@ public int getTerminalWidth() {
private AnsiMode mode;
private boolean resetAtUninstall;
- public AnsiOutputStream(OutputStream os, WidthSupplier width, AnsiMode mode,
- AnsiProcessor processor, AnsiType type, AnsiColors colors,
- Charset cs, IoRunnable installer, IoRunnable uninstaller, boolean resetAtUninstall) {
+ public AnsiOutputStream(
+ OutputStream os,
+ WidthSupplier width,
+ AnsiMode mode,
+ AnsiProcessor processor,
+ AnsiType type,
+ AnsiColors colors,
+ Charset cs,
+ IoRunnable installer,
+ IoRunnable uninstaller,
+ boolean resetAtUninstall) {
super(os);
this.width = width;
this.processor = processor;
@@ -330,9 +337,7 @@ public void install() throws IOException {
}
public void uninstall() throws IOException {
- if (resetAtUninstall
- && type != AnsiType.Redirected
- && type != AnsiType.Unsupported) {
+ if (resetAtUninstall && type != AnsiType.Redirected && type != AnsiType.Unsupported) {
setMode(AnsiMode.Default);
write(RESET_CODE);
flush();
diff --git a/src/main/java/org/fusesource/jansi/io/AnsiProcessor.java b/src/main/java/org/fusesource/jansi/io/AnsiProcessor.java
index 02b4838e..d4b825cf 100644
--- a/src/main/java/org/fusesource/jansi/io/AnsiProcessor.java
+++ b/src/main/java/org/fusesource/jansi/io/AnsiProcessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2017 the original author(s).
+ * Copyright (C) 2009-2023 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.
@@ -21,10 +21,10 @@
import java.util.Iterator;
/**
- * ANSI processor providing process* corresponding to ANSI escape codes.
+ * ANSI processor providing process* corresponding to ANSI escape codes.
* This class methods implementations are empty: subclasses should actually perform the
* ANSI escape behaviors by implementing active code in process* methods.
- *
+ *
*
For more information about ANSI escape codes, see
* Wikipedia article
*
@@ -44,12 +44,10 @@ public AnsiProcessor(OutputStream os) {
* @throws IOException if no more non-null values left
*/
protected int getNextOptionInt(Iterator