Package org.fusesource.jansi
Class Ansi
- java.lang.Object
-
- org.fusesource.jansi.Ansi
-
- All Implemented Interfaces:
Appendable
public class Ansi extends Object implements Appendable
Provides a fluent API for generating ANSI escape sequences.- Since:
- 1.0
- Author:
- Hiram Chirino
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAnsi.AttributeDisplay attributes, also know as SGR (Select Graphic Rendition) parameters.static classAnsi.ColorANSI 8 colors for fluent APIstatic interfaceAnsi.Consumerstatic classAnsi.EraseED (Erase in Display) / EL (Erase in Line) parameter (see CSI sequence J and K)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Ansia(boolean value)Ansia(char value)Ansia(char[] value)Ansia(char[] value, int offset, int len)Ansia(double value)Ansia(float value)Ansia(int value)Ansia(long value)Ansia(CharSequence value)Ansia(CharSequence value, int start, int end)Ansia(Object value)Ansia(String value)Ansia(StringBuffer value)Ansia(Ansi.Attribute attribute)static Ansiansi()static Ansiansi(int size)static Ansiansi(StringBuilder builder)Ansiappend(char c)Ansiappend(CharSequence csq)Ansiappend(CharSequence csq, int start, int end)Ansiapply(Ansi.Consumer fun)Applies another function to this Ansi instance.Ansibg(int color)Ansibg(Ansi.Color color)AnsibgBright(Ansi.Color color)AnsibgBrightCyan()AnsibgBrightDefault()AnsibgBrightGreen()AnsibgBrightMagenta()AnsibgBrightRed()AnsibgBrightYellow()AnsibgCyan()AnsibgDefault()AnsibgGreen()AnsibgMagenta()AnsibgRed()AnsibgRgb(int color)AnsibgRgb(int r, int g, int b)AnsibgYellow()Ansibold()AnsiboldOff()Ansicursor(int row, int column)Moves the cursor to row n, column m.AnsicursorDown(int y)Moves the cursor down.AnsicursorDownLine()Moves the cursor to the beginning of the line below.AnsicursorDownLine(int n)Moves the cursor to the beginning of the n-th line below.AnsicursorLeft(int x)Moves the cursor left.AnsicursorMove(int x, int y)Moves the cursor relative to the current position.AnsicursorRight(int x)Moves the cursor right.AnsicursorToColumn(int x)Moves the cursor to column n.AnsicursorUp(int y)Moves the cursor up.AnsicursorUpLine()Moves the cursor to the beginning of the line above.AnsicursorUpLine(int n)Moves the cursor to the beginning of the n-th line above.AnsieraseLine()AnsieraseLine(Ansi.Erase kind)AnsieraseScreen()AnsieraseScreen(Ansi.Erase kind)Ansifg(int color)Ansifg(Ansi.Color color)AnsifgBlack()AnsifgBlue()AnsifgBright(Ansi.Color color)AnsifgBrightBlack()AnsifgBrightBlue()AnsifgBrightCyan()AnsifgBrightDefault()AnsifgBrightGreen()AnsifgBrightMagenta()AnsifgBrightRed()AnsifgBrightYellow()AnsifgCyan()AnsifgDefault()AnsifgGreen()AnsifgMagenta()AnsifgRed()AnsifgRgb(int color)AnsifgRgb(int r, int g, int b)AnsifgYellow()Ansiformat(String pattern, Object... args)static booleanisDetected()static booleanisEnabled()Ansinewline()Ansirender(String text)Uses theAnsiRendererto generate the ANSI escape sequences for the supplied text.Ansirender(String text, Object... args)String formats and renders the supplied arguments.Ansireset()AnsirestorCursorPosition()Deprecated.AnsirestoreCursorPosition()AnsisaveCursorPosition()AnsiscrollDown(int rows)AnsiscrollUp(int rows)static voidsetDetector(Callable<Boolean> detector)static voidsetEnabled(boolean flag)StringtoString()
-
-
-
Method Detail
-
setDetector
public static void setDetector(Callable<Boolean> detector)
-
isDetected
public static boolean isDetected()
-
setEnabled
public static void setEnabled(boolean flag)
-
isEnabled
public static boolean isEnabled()
-
ansi
public static Ansi ansi(StringBuilder builder)
-
fg
public Ansi fg(Ansi.Color color)
-
bg
public Ansi bg(Ansi.Color color)
-
fgBright
public Ansi fgBright(Ansi.Color color)
-
fgBrightBlack
public Ansi fgBrightBlack()
-
fgBrightBlue
public Ansi fgBrightBlue()
-
fgBrightCyan
public Ansi fgBrightCyan()
-
fgBrightDefault
public Ansi fgBrightDefault()
-
fgBrightGreen
public Ansi fgBrightGreen()
-
fgBrightMagenta
public Ansi fgBrightMagenta()
-
fgBrightRed
public Ansi fgBrightRed()
-
fgBrightYellow
public Ansi fgBrightYellow()
-
bgBright
public Ansi bgBright(Ansi.Color color)
-
bgBrightCyan
public Ansi bgBrightCyan()
-
bgBrightDefault
public Ansi bgBrightDefault()
-
bgBrightGreen
public Ansi bgBrightGreen()
-
bgBrightMagenta
public Ansi bgBrightMagenta()
-
bgBrightRed
public Ansi bgBrightRed()
-
bgBrightYellow
public Ansi bgBrightYellow()
-
a
public Ansi a(Ansi.Attribute attribute)
-
cursor
public Ansi cursor(int row, int column)
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
public Ansi cursorToColumn(int x)
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
public Ansi cursorUp(int y)
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
public Ansi cursorDown(int y)
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
public Ansi cursorRight(int x)
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
public Ansi cursorLeft(int x)
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
public Ansi cursorMove(int x, int y)
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
public Ansi cursorDownLine()
Moves the cursor to the beginning of the line below.- Returns:
- this Ansi instance
-
cursorDownLine
public Ansi cursorDownLine(int n)
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
public Ansi cursorUpLine()
Moves the cursor to the beginning of the line above.- Returns:
- this Ansi instance
-
cursorUpLine
public Ansi cursorUpLine(int n)
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
public Ansi eraseScreen()
-
eraseScreen
public Ansi eraseScreen(Ansi.Erase kind)
-
eraseLine
public Ansi eraseLine(Ansi.Erase kind)
-
scrollDown
public Ansi scrollDown(int rows)
-
saveCursorPosition
public Ansi saveCursorPosition()
-
restorCursorPosition
@Deprecated public Ansi restorCursorPosition()
Deprecated.
-
restoreCursorPosition
public Ansi restoreCursorPosition()
-
a
public Ansi a(CharSequence value, int start, int end)
-
a
public Ansi a(CharSequence value)
-
a
public Ansi a(StringBuffer value)
-
apply
public Ansi apply(Ansi.Consumer fun)
Applies another function to this Ansi instance.- Parameters:
fun- the function to apply- Returns:
- this Ansi instance
- Since:
- 2.2
-
render
public Ansi render(String text)
Uses theAnsiRendererto generate the ANSI escape sequences for the supplied text.- Parameters:
text- text- Returns:
- this
- Since:
- 2.2
-
render
public Ansi render(String text, Object... args)
String formats and renders the supplied arguments. Uses theAnsiRendererto generate the ANSI escape sequences.- Parameters:
text- formatargs- arguments- Returns:
- this
- Since:
- 2.2
-
append
public Ansi append(CharSequence csq)
- Specified by:
appendin interfaceAppendable
-
append
public Ansi append(CharSequence csq, int start, int end)
- Specified by:
appendin interfaceAppendable
-
append
public Ansi append(char c)
- Specified by:
appendin interfaceAppendable
-
-