Skip to content

AnsiEncoder

[Source]

Stateless ANSI escape sequence encoder.

primitive val AnsiEncoder

Constructors

create

[Source]

new val create()
: AnsiEncoder val^

Returns


Public Functions

move_to

[Source]

Emit ESC[(row+1);(col+1)H — terminal coordinates are 1-indexed.

fun box move_to(
  col: USize val,
  row: USize val)
: Array[U8 val] val

Parameters

Returns


set_fg

[Source]

Emit ESC[{fg_code}m for the given color.

fun box set_fg(
  color: (Default val | Black val | Red val | 
    Green val | Yellow val | Blue val | 
    Magenta val | Cyan val | White val | 
    BrightBlack val | BrightRed val | BrightGreen val | 
    BrightYellow val | BrightBlue val | BrightMagenta val | 
    BrightCyan val | BrightWhite val | Rainbow val))
: Array[U8 val] val

Parameters

Returns


set_bg

[Source]

Emit ESC[{bg_code}m for the given color.

fun box set_bg(
  color: (Default val | Black val | Red val | 
    Green val | Yellow val | Blue val | 
    Magenta val | Cyan val | White val | 
    BrightBlack val | BrightRed val | BrightGreen val | 
    BrightYellow val | BrightBlue val | BrightMagenta val | 
    BrightCyan val | BrightWhite val | Rainbow val))
: Array[U8 val] val

Parameters

Returns


set_attrs

[Source]

Emit an SGR sequence for each set attribute bit. Bold=1, dim=2, underline=4, blink=5, reverse=7.

fun box set_attrs(
  attrs: U8 val)
: Array[U8 val] val

Parameters

  • attrs: U8 val

Returns


reset

[Source]

Emit ESC[0m to reset all attributes and colors.

fun box reset()
: Array[U8 val] val

Returns


write_char

[Source]

Encode a Unicode codepoint as UTF-8 bytes.

fun box write_char(
  codepoint: U32 val)
: Array[U8 val] val

Parameters

  • codepoint: U32 val

Returns


hide_cursor

[Source]

Emit ESC[?25l to hide the cursor.

fun box hide_cursor()
: Array[U8 val] val

Returns


show_cursor

[Source]

Emit ESC[?25h to show the cursor.

fun box show_cursor()
: Array[U8 val] val

Returns


clear_screen

[Source]

Emit ESC[2J to clear the entire screen.

fun box clear_screen()
: Array[U8 val] val

Returns


eq

[Source]

fun box eq(
  that: AnsiEncoder val)
: Bool val

Parameters

Returns


ne

[Source]

fun box ne(
  that: AnsiEncoder val)
: Bool val

Parameters

Returns