Package org.fusesource.jansi
Class AnsiRenderer
- java.lang.Object
-
- org.fusesource.jansi.AnsiRenderer
-
public class AnsiRenderer extends Object
Renders ANSI color escape-codes in strings by parsing out some special syntax to pick up the correct fluff to use. The syntax for embedded ANSI codes is:@|code(,code)* text|@
Examples:@|bold Hello|@
@|bold,red Warning!|@
- Since:
- 2.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AnsiRenderer.Code
-
Field Summary
Fields Modifier and Type Field Description static String
BEGIN_TOKEN
static String
CODE_LIST_SEPARATOR
static String
CODE_TEXT_SEPARATOR
static String
END_TOKEN
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
render(String input)
static Appendable
render(String input, Appendable target)
Renders the given input to the target Appendable.static String
render(String text, String... codes)
static String
renderCodes(String codes)
RendersAnsiRenderer.Code
names as an ANSI escape string.static String
renderCodes(String... codes)
RendersAnsiRenderer.Code
names as an ANSI escape string.static boolean
test(String text)
-
-
-
Field Detail
-
BEGIN_TOKEN
public static final String BEGIN_TOKEN
- See Also:
- Constant Field Values
-
END_TOKEN
public static final String END_TOKEN
- See Also:
- Constant Field Values
-
CODE_TEXT_SEPARATOR
public static final String CODE_TEXT_SEPARATOR
- See Also:
- Constant Field Values
-
CODE_LIST_SEPARATOR
public static final String CODE_LIST_SEPARATOR
- See Also:
- Constant Field Values
-
-
Method Detail
-
render
public static String render(String input) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
render
public static Appendable render(String input, Appendable target) throws IOException
Renders the given input to the target Appendable.- Parameters:
input
- source to rendertarget
- render onto this target Appendable.- Returns:
- the given Appendable
- Throws:
IOException
- If an I/O error occurs
-
renderCodes
public static String renderCodes(String... codes)
RendersAnsiRenderer.Code
names as an ANSI escape string.- Parameters:
codes
- The code names to render- Returns:
- an ANSI escape string.
-
renderCodes
public static String renderCodes(String codes)
RendersAnsiRenderer.Code
names as an ANSI escape string.- Parameters:
codes
- A space separated list of code names to render- Returns:
- an ANSI escape string.
-
-