Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: jansi

[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.

Members

  • ansiCls
  • ansiConsoleCls

Methods

  • 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.

    • @r this object
  • systemUninstall ()

    Uninstalls the Jansi system, restoring the original System.out and System.err streams.

    • @r this object
  • println (Val)

    Prints a line with the provided value to the wrapped AnsiConsole output stream.

    • @p Val is the value to print. Accepts an ansi builder or any other value.
    • @r this object
  • print (Val)

    Prints the provided value to the wrapped AnsiConsole output stream without a trailing newline.

    • @p Val is the value to print. Accepts an ansi builder or any other value.
    • @r this object
  • getTermWidth ()

    Gets the terminal width.

    • @r An int with the width.
  • out ()

    Gets the wrapped AnsiConsole standard output stream.

    • @r A AussomJavaObject wrapping the PrintStream.
  • err ()

    Gets the wrapped AnsiConsole standard error stream.

    • @r 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.

    • @p On is a bool. True turns emission on, false turns it off.
    • @r this object
  • isEnabled ()

    Returns whether ANSI escape sequence emission is currently enabled.

    • @r A bool, true if emission is on.

class: ansi

[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.

Members

  • obj
  • ansiCls
  • colorCls
  • attrCls
  • eraseCls

Methods

  • 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.

    • @p Val is the value to append. Strings, numbers, and Attribute enum values are all accepted.
    • @r this object
  • newline ()

    Appends a newline to the builder.

    • @r this object
  • format (string Pattern, list Args)

    Formats the provided pattern with the supplied arguments and appends the result to the builder.

    • @p Pattern is a Java printf style format string.
    • @p Args is an optional list of values to format. Defaults to an empty list.
    • @r this object
  • render (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.

    • @p Text is the markup string to render.
    • @r this object
  • reset ()

    Resets all current colors and attributes to terminal defaults.

    • @r this object
  • bold ()

    Turns on bold (increased intensity).

    • @r this object
  • boldOff ()

    Turns off bold.

    • @r this object
  • faint ()

    Turns on faint (decreased intensity).

    • @r this object
  • italic ()

    Turns on italic.

    • @r this object
  • italicOff ()

    Turns off italic.

    • @r this object
  • underline ()

    Turns on single underline.

    • @r this object
  • underlineDouble ()

    Turns on double underline.

    • @r this object
  • underlineOff ()

    Turns off underline.

    • @r this object
  • strikethrough ()

    Turns on strikethrough.

    • @r this object
  • strikethroughOff ()

    Turns off strikethrough.

    • @r this object
  • blink ()

    Turns on slow blink.

    • @r this object
  • blinkFast ()

    Turns on fast blink. Many terminals render this the same as slow blink.

    • @r this object
  • blinkOff ()

    Turns off blink.

    • @r this object
  • negative ()

    Turns on negative (reverse video).

    • @r this object
  • negativeOff ()

    Turns off negative (reverse video).

    • @r this object
  • conceal ()

    Turns on conceal (hidden text).

    • @r this object
  • concealOff ()

    Turns off conceal.

    • @r this object
  • eraseScreen (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.

    • @p Kind is one of "forward", "backward", or "all".
    • @r this object
  • eraseLine (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.

    • @p Kind is one of "forward", "backward", or "all".
    • @r this object
  • cursor (int row, int col)

    Moves the cursor to the provided absolute location.

    • @p row is an int with the row number from the top of the screen.
    • @p col is an int with the column number from the left side of the screen.
    • @r this object
  • cursorToColumn (int X)

    Moves the cursor to the provided absolute column on the current row.

    • @p X is an int with the target column number.
    • @r this object
  • cursorUp (int N)

    Moves the cursor up by the provided number of rows.

    • @p N is an int with the number of rows to move.
    • @r this object
  • cursorDown (int N)

    Moves the cursor down by the provided number of rows.

    • @p N is an int with the number of rows to move.
    • @r this object
  • cursorLeft (int N)

    Moves the cursor left by the provided number of columns.

    • @p N is an int with the number of columns to move.
    • @r this object
  • cursorRight (int N)

    Moves the cursor right by the provided number of columns.

    • @p N is an int with the number of columns to move.
    • @r this object
  • cursorMove (int X, int Y)

    Moves the cursor by the provided column and row deltas.

    • @p X is an int with the column delta.
    • @p Y is an int with the row delta.
    • @r this object
  • cursorDownLine (int N = 1)

    Moves the cursor down N lines and to the start of each line.

    • @p N is an int with the number of lines to move. Default is 1.
    • @r this object
  • cursorUpLine (int N = 1)

    Moves the cursor up N lines and to the start of each line.

    • @p N is an int with the number of lines to move. Default is 1.
    • @r this object
  • saveCursorPosition ()

    Saves the current cursor position. Pair with restoreCursorPosition to return to it later.

    • @r this object
  • restoreCursorPosition ()

    Restores the cursor to the position saved by the previous saveCursorPosition call.

    • @r this object
  • scrollUp (int Rows)

    Scrolls the screen up by the provided number of rows.

    • @p Rows is an int with the number of rows to scroll.
    • @r this object
  • scrollDown (int Rows)

    Scrolls the screen down by the provided number of rows.

    • @p Rows is an int with the number of rows to scroll.
    • @r this object
  • fg (int Red, int Green, int Blue)

    Sets the foreground color from the provided 24 bit RGB value.

    • @p Red is an int with the red component (0-255).
    • @p Green is an int with the green component (0-255).
    • @p Blue is an int with the blue component (0-255).
    • @r this object
  • bg (int Red, int Green, int Blue)

    Sets the background color from the provided 24 bit RGB value.

    • @p Red is an int with the red component (0-255).
    • @p Green is an int with the green component (0-255).
    • @p Blue is an int with the blue component (0-255).
    • @r this object
  • fg256 (int Idx)

    Sets the foreground color from the 256 color palette.

    • @p Idx is an int with the palette index (0-255).
    • @r this object
  • bg256 (int Idx)

    Sets the background color from the 256 color palette.

    • @p Idx is an int with the palette index (0-255).
    • @r this object
  • fgBlack ()

    Sets the foreground color to black.

    • @r this object
  • fgRed ()

    Sets the foreground color to red.

    • @r this object
  • fgGreen ()

    Sets the foreground color to green.

    • @r this object
  • fgYellow ()

    Sets the foreground color to yellow.

    • @r this object
  • fgBlue ()

    Sets the foreground color to blue.

    • @r this object
  • fgMagenta ()

    Sets the foreground color to magenta.

    • @r this object
  • fgCyan ()

    Sets the foreground color to cyan.

    • @r this object
  • fgWhite ()

    Sets the foreground color to white.

    • @r this object
  • fgDefault ()

    Resets the foreground color to the terminal default.

    • @r this object
  • bgBlack ()

    Sets the background color to black.

    • @r this object
  • bgRed ()

    Sets the background color to red.

    • @r this object
  • bgGreen ()

    Sets the background color to green.

    • @r this object
  • bgYellow ()

    Sets the background color to yellow.

    • @r this object
  • bgBlue ()

    Sets the background color to blue.

    • @r this object
  • bgMagenta ()

    Sets the background color to magenta.

    • @r this object
  • bgCyan ()

    Sets the background color to cyan.

    • @r this object
  • bgWhite ()

    Sets the background color to white.

    • @r this object
  • bgDefault ()

    Resets the background color to the terminal default.

    • @r this object
  • fgBrightBlack ()

    Sets the foreground color to bright black.

    • @r this object
  • fgBrightRed ()

    Sets the foreground color to bright red.

    • @r this object
  • fgBrightGreen ()

    Sets the foreground color to bright green.

    • @r this object
  • fgBrightYellow ()

    Sets the foreground color to bright yellow.

    • @r this object
  • fgBrightBlue ()

    Sets the foreground color to bright blue.

    • @r this object
  • fgBrightMagenta ()

    Sets the foreground color to bright magenta.

    • @r this object
  • fgBrightCyan ()

    Sets the foreground color to bright cyan.

    • @r this object
  • fgBrightWhite ()

    Sets the foreground color to bright white.

    • @r this object
  • fgBrightDefault ()

    Resets the bright foreground color to the terminal default.

    • @r this object
  • bgBrightBlack ()

    Sets the background color to bright black.

    • @r this object
  • bgBrightRed ()

    Sets the background color to bright red.

    • @r this object
  • bgBrightGreen ()

    Sets the background color to bright green.

    • @r this object
  • bgBrightYellow ()

    Sets the background color to bright yellow.

    • @r this object
  • bgBrightBlue ()

    Sets the background color to bright blue.

    • @r this object
  • bgBrightMagenta ()

    Sets the background color to bright magenta.

    • @r this object
  • bgBrightCyan ()

    Sets the background color to bright cyan.

    • @r this object
  • bgBrightWhite ()

    Sets the background color to bright white.

    • @r this object
  • bgBrightDefault ()

    Resets the bright background color to the terminal default.

    • @r this object