Basics
Guides
API Reference
Basics
Guides
API Reference
[17:14] static extends: object
Jansi is a small ASL 2.0 licensed Java library that allows you to use ANSI escape sequences to format your console output. The static jansi class is used to install or uninstall the Jansi system, control whether codes are emitted, and to print Ansi objects to the wrapped console streams. The companion ansi class provides a fluent builder API for assembling the formatted output.
systemInstall ()
Installs the Jansi system. On Windows this enables ANSI escape support; on other platforms this swaps the system streams for ones that strip codes when output is redirected away from a terminal.
this objectsystemUninstall ()
Uninstalls the Jansi system, restoring the original System.out and System.err streams.
this objectprintln (Val)
Prints a line with the provided value to the wrapped AnsiConsole output stream.
Val is the value to print. Accepts an ansi builder or any other value.this objectprint (Val)
Prints the provided value to the wrapped AnsiConsole output stream without a trailing newline.
Val is the value to print. Accepts an ansi builder or any other value.this objectgetTermWidth ()
Gets the terminal width.
An int with the width.out ()
Gets the wrapped AnsiConsole standard output stream.
A AussomJavaObject wrapping the PrintStream.err ()
Gets the wrapped AnsiConsole standard error stream.
A AussomJavaObject wrapping the PrintStream.setEnabled (bool On)
Globally enables or disables emission of ANSI escape sequences from new ansi builders. This is a thread local switch on the JAnsi side.
On is a bool. True turns emission on, false turns it off.this objectisEnabled ()
Returns whether ANSI escape sequence emission is currently enabled.
A bool, true if emission is on.[130:7] extends: object
The ansi class provides a fluent API for generating ANSI escape sequences. Each formatting call returns the same builder so calls can be chained and ended with a call to jansi.print or jansi.println.
ansi ()
Constructor creates a new ansi builder and stores the underlying Java Ansi object as this.obj.
a (Val)
Appends the provided value to the builder.
Val is the value to append. Strings, numbers, and Attribute enum values are all accepted.this objectnewline ()
Appends a newline to the builder.
this objectformat (string Pattern, list Args)
Formats the provided pattern with the supplied arguments and appends the result to the builder.
Pattern is a Java printf style format string.Args is an optional list of values to format. Defaults to an empty list.this objectrender (string Text)
Renders the provided JAnsi markup string and appends the result. JAnsi markup uses the form "@|red,bold text|@" to apply named colors and attributes to a span of text.
Text is the markup string to render.this objectreset ()
Resets all current colors and attributes to terminal defaults.
this objectbold ()
Turns on bold (increased intensity).
this objectboldOff ()
Turns off bold.
this objectfaint ()
Turns on faint (decreased intensity).
this objectitalic ()
Turns on italic.
this objectitalicOff ()
Turns off italic.
this objectunderline ()
Turns on single underline.
this objectunderlineDouble ()
Turns on double underline.
this objectunderlineOff ()
Turns off underline.
this objectstrikethrough ()
Turns on strikethrough.
this objectstrikethroughOff ()
Turns off strikethrough.
this objectblink ()
Turns on slow blink.
this objectblinkFast ()
Turns on fast blink. Many terminals render this the same as slow blink.
this objectblinkOff ()
Turns off blink.
this objectnegative ()
Turns on negative (reverse video).
this objectnegativeOff ()
Turns off negative (reverse video).
this objectconceal ()
Turns on conceal (hidden text).
this objectconcealOff ()
Turns off conceal.
this objecteraseScreen (string Kind = "forward")
Erases the screen. The optional Kind selects the region: "forward" (default) clears from the cursor to the end, "backward" clears from the start to the cursor, "all" clears the whole screen.
Kind is one of "forward", "backward", or "all".this objecteraseLine (string Kind = "forward")
Erases the current line. The optional Kind selects the region: "forward" (default) clears from the cursor to the end of the line, "backward" clears from the start of the line to the cursor, "all" clears the whole line.
Kind is one of "forward", "backward", or "all".this objectcursor (int row, int col)
Moves the cursor to the provided absolute location.
row is an int with the row number from the top of the screen.col is an int with the column number from the left side of the screen.this objectcursorToColumn (int X)
Moves the cursor to the provided absolute column on the current row.
X is an int with the target column number.this objectcursorUp (int N)
Moves the cursor up by the provided number of rows.
N is an int with the number of rows to move.this objectcursorDown (int N)
Moves the cursor down by the provided number of rows.
N is an int with the number of rows to move.this objectcursorLeft (int N)
Moves the cursor left by the provided number of columns.
N is an int with the number of columns to move.this objectcursorRight (int N)
Moves the cursor right by the provided number of columns.
N is an int with the number of columns to move.this objectcursorMove (int X, int Y)
Moves the cursor by the provided column and row deltas.
X is an int with the column delta.Y is an int with the row delta.this objectcursorDownLine (int N = 1)
Moves the cursor down N lines and to the start of each line.
N is an int with the number of lines to move. Default is 1.this objectcursorUpLine (int N = 1)
Moves the cursor up N lines and to the start of each line.
N is an int with the number of lines to move. Default is 1.this objectsaveCursorPosition ()
Saves the current cursor position. Pair with restoreCursorPosition to return to it later.
this objectrestoreCursorPosition ()
Restores the cursor to the position saved by the previous saveCursorPosition call.
this objectscrollUp (int Rows)
Scrolls the screen up by the provided number of rows.
Rows is an int with the number of rows to scroll.this objectscrollDown (int Rows)
Scrolls the screen down by the provided number of rows.
Rows is an int with the number of rows to scroll.this objectfg (int Red, int Green, int Blue)
Sets the foreground color from the provided 24 bit RGB value.
Red is an int with the red component (0-255).Green is an int with the green component (0-255).Blue is an int with the blue component (0-255).this objectbg (int Red, int Green, int Blue)
Sets the background color from the provided 24 bit RGB value.
Red is an int with the red component (0-255).Green is an int with the green component (0-255).Blue is an int with the blue component (0-255).this objectfg256 (int Idx)
Sets the foreground color from the 256 color palette.
Idx is an int with the palette index (0-255).this objectbg256 (int Idx)
Sets the background color from the 256 color palette.
Idx is an int with the palette index (0-255).this objectfgBlack ()
Sets the foreground color to black.
this objectfgRed ()
Sets the foreground color to red.
this objectfgGreen ()
Sets the foreground color to green.
this objectfgYellow ()
Sets the foreground color to yellow.
this objectfgBlue ()
Sets the foreground color to blue.
this objectfgMagenta ()
Sets the foreground color to magenta.
this objectfgCyan ()
Sets the foreground color to cyan.
this objectfgWhite ()
Sets the foreground color to white.
this objectfgDefault ()
Resets the foreground color to the terminal default.
this objectbgBlack ()
Sets the background color to black.
this objectbgRed ()
Sets the background color to red.
this objectbgGreen ()
Sets the background color to green.
this objectbgYellow ()
Sets the background color to yellow.
this objectbgBlue ()
Sets the background color to blue.
this objectbgMagenta ()
Sets the background color to magenta.
this objectbgCyan ()
Sets the background color to cyan.
this objectbgWhite ()
Sets the background color to white.
this objectbgDefault ()
Resets the background color to the terminal default.
this objectfgBrightBlack ()
Sets the foreground color to bright black.
this objectfgBrightRed ()
Sets the foreground color to bright red.
this objectfgBrightGreen ()
Sets the foreground color to bright green.
this objectfgBrightYellow ()
Sets the foreground color to bright yellow.
this objectfgBrightBlue ()
Sets the foreground color to bright blue.
this objectfgBrightMagenta ()
Sets the foreground color to bright magenta.
this objectfgBrightCyan ()
Sets the foreground color to bright cyan.
this objectfgBrightWhite ()
Sets the foreground color to bright white.
this objectfgBrightDefault ()
Resets the bright foreground color to the terminal default.
this objectbgBrightBlack ()
Sets the background color to bright black.
this objectbgBrightRed ()
Sets the background color to bright red.
this objectbgBrightGreen ()
Sets the background color to bright green.
this objectbgBrightYellow ()
Sets the background color to bright yellow.
this objectbgBrightBlue ()
Sets the background color to bright blue.
this objectbgBrightMagenta ()
Sets the background color to bright magenta.
this objectbgBrightCyan ()
Sets the background color to bright cyan.
this objectbgBrightWhite ()
Sets the background color to bright white.
this objectbgBrightDefault ()
Resets the bright background color to the terminal default.
this object
Aussom
Write once. Embed everywhere.
Copyright 2026 Austin Lehman. All rights reserved.