Package org.fusesource.jansi
Class Ansi
java.lang.Object
org.fusesource.jansi.Ansi
- All Implemented Interfaces:
Appendable
Provides a fluent API for generating
ANSI escape sequences.
This class comes from Jansi and is provided for backward compatibility
with maven-shared-utils, while Maven has migrated to JLine (into which Jansi has been merged
since JLine 3.25.0).
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Display attributes, also know as SGR (Select Graphic Rendition) parameters.static enum
ANSI 8 colors for fluent APIstatic interface
static enum
ED (Erase in Display) / EL (Erase in Line) parameter (see CSI sequence J and K) -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiona
(boolean value) a
(char value) a
(char[] value) a
(char[] value, int offset, int len) a
(double value) a
(float value) a
(int value) a
(long value) a
(CharSequence value) a
(CharSequence value, int start, int end) a
(StringBuffer value) a
(Ansi.Attribute attribute) static Ansi
ansi()
static Ansi
ansi
(int size) static Ansi
ansi
(StringBuilder builder) append
(char c) append
(CharSequence csq) append
(CharSequence csq, int start, int end) apply
(Ansi.Consumer fun) Applies another function to this Ansi instance.bg
(int color) bg
(Ansi.Color color) bgBright
(Ansi.Color color) bgCyan()
bgGreen()
bgRed()
bgRgb
(int color) bgRgb
(int r, int g, int b) bgYellow()
bold()
boldOff()
cursor
(int row, int column) Moves the cursor to row n, column m.cursorDown
(int y) Moves the cursor down.Moves the cursor to the beginning of the line below.cursorDownLine
(int n) Moves the cursor to the beginning of the n-th line below.cursorLeft
(int x) Moves the cursor left.cursorMove
(int x, int y) Moves the cursor relative to the current position.cursorRight
(int x) Moves the cursor right.cursorToColumn
(int x) Moves the cursor to column n.cursorUp
(int y) Moves the cursor up.Moves the cursor to the beginning of the line above.cursorUpLine
(int n) Moves the cursor to the beginning of the n-th line above.eraseLine
(Ansi.Erase kind) eraseScreen
(Ansi.Erase kind) fg
(int color) fg
(Ansi.Color color) fgBlack()
fgBlue()
fgBright
(Ansi.Color color) fgCyan()
fgGreen()
fgRed()
fgRgb
(int color) fgRgb
(int r, int g, int b) fgYellow()
static boolean
newline()
Uses theAnsiRenderer
to generate the ANSI escape sequences for the supplied text.String formats and renders the supplied arguments.reset()
Deprecated.scrollDown
(int rows) scrollUp
(int rows) toString()
-
Constructor Details
-
Ansi
public Ansi() -
Ansi
-
Ansi
public Ansi(int size) -
Ansi
-
-
Method Details
-
isEnabled
public static boolean isEnabled() -
ansi
-
ansi
-
ansi
-
fg
-
fg
-
fgRgb
-
fgRgb
-
fgBlack
-
fgBlue
-
fgCyan
-
fgDefault
-
fgGreen
-
fgMagenta
-
fgRed
-
fgYellow
-
bg
-
bg
-
bgRgb
-
bgRgb
-
bgCyan
-
bgDefault
-
bgGreen
-
bgMagenta
-
bgRed
-
bgYellow
-
fgBright
-
fgBrightBlack
-
fgBrightBlue
-
fgBrightCyan
-
fgBrightDefault
-
fgBrightGreen
-
fgBrightMagenta
-
fgBrightRed
-
fgBrightYellow
-
bgBright
-
bgBrightCyan
-
bgBrightDefault
-
bgBrightGreen
-
bgBrightMagenta
-
bgBrightRed
-
bgBrightYellow
-
a
-
cursor
Moves the cursor to row n, column m. The values are 1-based. Any values less than 1 are mapped to 1.- Parameters:
row
- row (1-based) from topcolumn
- column (1 based) from left- Returns:
- this Ansi instance
-
cursorToColumn
Moves the cursor to column n. The parameter n is 1-based. If n is less than 1 it is moved to the first column.- Parameters:
x
- the index (1-based) of the column to move to- Returns:
- this Ansi instance
-
cursorUp
Moves the cursor up. If the parameter y is negative it moves the cursor down.- Parameters:
y
- the number of lines to move up- Returns:
- this Ansi instance
-
cursorDown
Moves the cursor down. If the parameter y is negative it moves the cursor up.- Parameters:
y
- the number of lines to move down- Returns:
- this Ansi instance
-
cursorRight
Moves the cursor right. If the parameter x is negative it moves the cursor left.- Parameters:
x
- the number of characters to move right- Returns:
- this Ansi instance
-
cursorLeft
Moves the cursor left. If the parameter x is negative it moves the cursor right.- Parameters:
x
- the number of characters to move left- Returns:
- this Ansi instance
-
cursorMove
Moves the cursor relative to the current position. The cursor is moved right if x is positive, left if negative and down if y is positive and up if negative.- Parameters:
x
- the number of characters to move horizontallyy
- the number of lines to move vertically- Returns:
- this Ansi instance
- Since:
- 2.2
-
cursorDownLine
Moves the cursor to the beginning of the line below.- Returns:
- this Ansi instance
-
cursorDownLine
Moves the cursor to the beginning of the n-th line below. If the parameter n is negative it moves the cursor to the beginning of the n-th line above.- Parameters:
n
- the number of lines to move the cursor- Returns:
- this Ansi instance
-
cursorUpLine
Moves the cursor to the beginning of the line above.- Returns:
- this Ansi instance
-
cursorUpLine
Moves the cursor to the beginning of the n-th line above. If the parameter n is negative it moves the cursor to the beginning of the n-th line below.- Parameters:
n
- the number of lines to move the cursor- Returns:
- this Ansi instance
-
eraseScreen
-
eraseScreen
-
eraseLine
-
eraseLine
-
scrollUp
-
scrollDown
-
restorCursorPosition
Deprecated. -
saveCursorPosition
-
saveCursorPositionSCO
-
saveCursorPositionDEC
-
restoreCursorPosition
-
restoreCursorPositionSCO
-
restoreCursorPositionDEC
-
reset
-
bold
-
boldOff
-
a
-
a
-
a
-
a
-
a
-
a
-
a
-
a
-
a
-
a
-
a
-
a
-
a
-
newline
-
format
-
apply
Applies another function to this Ansi instance.- Parameters:
fun
- the function to apply- Returns:
- this Ansi instance
- Since:
- 2.2
-
render
Uses theAnsiRenderer
to generate the ANSI escape sequences for the supplied text.- Parameters:
text
- text- Returns:
- this
- Since:
- 2.2
-
render
String formats and renders the supplied arguments. Uses theAnsiRenderer
to generate the ANSI escape sequences.- Parameters:
text
- formatargs
- arguments- Returns:
- this
- Since:
- 2.2
-
toString
-
append
- Specified by:
append
in interfaceAppendable
-
append
- Specified by:
append
in interfaceAppendable
-
append
- Specified by:
append
in interfaceAppendable
-