package core:terminal/ansi

⌘K
Ctrl+K
or
/

    Overview

    Constant references to many widely-supported ANSI escape codes. Primarily used in terminal emulators for enhanced graphics, such as colors, text styling, and animated displays.

    For example, you can print out a line of cyan text like this:

    fmt.println(ansi.CSI + ansi.FG_CYAN + ansi.SGR + "Hellope!" + ansi.CSI + ansi.RESET + ansi.SGR)
    
    

    The helper procedures can also be used to color text and control the terminal:

    fmt.println(ansi.color("Hellope!", ansi.FG_CYAN))
    fmt.print(ansi.clear_screen() + ansi.hide_cursor() + ansi.enter_alt_screen())
    fmt.print(ansi.move_cursor(2, 4) + "Hellope!")
    fmt.print(ansi.exit_alt_screen() + ansi.show_cursor())
    
    

    Formatting helpers also accept a caller-provided buffer to avoid allocating:

    sgr_buf: [len(ansi.FG_CYAN) + 3]byte
    fmt.print(ansi.sgr(sgr_buf[:], ansi.FG_CYAN))
    cursor_buf: [ansi.CURSOR_SEQUENCE_BUF_MAX]byte
    fmt.print(ansi.move_cursor(cursor_buf[:], 2, 4))
    
    

    Multiple SGR (Select Graphic Rendition) codes can be joined by semicolons:

    fmt.println(ansi.CSI + ansi.BOLD + ";" + ansi.FG_BLUE + ansi.SGR + "Hellope!" + ansi.CSI + ansi.RESET + ansi.SGR)
    
    

    If your terminal supports 24-bit true color mode, you can also do this:

    fmt.println(ansi.CSI + ansi.FG_COLOR_24_BIT + ";0;255;255" + ansi.SGR + "Hellope!" + ansi.CSI + ansi.RESET + ansi.SGR)
    
    

    For more information, see:

    Index

    Types (0)

    This section is empty.

    Constants (113)
    Variables (0)

    This section is empty.

    Types

    This section is empty.

    Constants

    AUX_OFF ¶

    AUX_OFF :: "4i"
     

    AUX Port Off

    AUX_ON ¶

    AUX_ON :: "5i"
     

    AUX Port On

    BEL ¶

    BEL :: "\a"
     

    Bell

    BG_BRIGHT_BLACK ¶

    BG_BRIGHT_BLACK :: "100"
     

    Also known as grey.

    BG_COLOR_24_BIT ¶

    BG_COLOR_24_BIT :: "48;2"
     

    Followed by ";r;g;b" where r,g,b are in 0..=255

    BG_COLOR_8_BIT ¶

    BG_COLOR_8_BIT :: "48;5"
     

    Followed by ";n" where n is in 0..=255

    BLINK_RAPID :: "6"
     

    Not widely supported.

    BS ¶

    BS :: "\b"
     

    Backspace

    CHA ¶

    CHA :: "G"
     

    Cursor Horizontal Absolute

    CLIPBOARD ¶

    CLIPBOARD :: "52"
     

    Followed by ";c;<Base64-encoded string>" ST.

    CNL ¶

    CNL :: "E"
     

    Cursor Next Line

    CPL ¶

    CPL :: "F"
     

    Cursor Previous Line

    CSI ¶

    CSI :: ESC + "["
     

    Control Sequence Introducer

    CUB ¶

    CUB :: "D"
     

    Cursor Back

    CUD ¶

    CUD :: "B"
     

    Cursor Down

    CUF ¶

    CUF :: "C"
     

    Cursor Forward

    CUP ¶

    CUP :: "H"
     

    Cursor Position

    CURSOR_SEQUENCE_BUF_MAX ¶

    CURSOR_SEQUENCE_BUF_MAX :: 4 + 6 * size_of(int)
     

    Buffer size sufficient for any cursor movement helper, including move_cursor, for all values representable by int. SGR and color helpers depend on the lengths of their string arguments and have no fixed maximum buffer size.

    CUU ¶

    CUU :: "A"
     

    Cursor Up

    DECASB_ENTER ¶

    DECASB_ENTER :: "?1049h"
     

    Alternate Screen Buffer (Enter)

    DECASB_EXIT ¶

    DECASB_EXIT :: "?1049l"
     

    Alternate Screen Buffer (Exit)

    DECAWM_OFF ¶

    DECAWM_OFF :: "?7l"
     

    Auto Wrap Mode (Disabled)

    DECAWM_ON ¶

    DECAWM_ON :: "?7h"
     

    Auto Wrap Mode (Enabled)

    DECRC ¶

    DECRC :: ESC + "8"
     

    DEC Restore Cursor

    DECSC ¶

    DECSC :: ESC + "7"
     

    DEC Save Cursor

    DECTCEM_HIDE ¶

    DECTCEM_HIDE :: "?25l"
     

    Text Cursor Enable Mode (Invisible)

    DECTCEM_SHOW ¶

    DECTCEM_SHOW :: "?25h"
     

    Text Cursor Enable Mode (Visible)

    DSR ¶

    DSR :: "6n"
     

    Device Status Report

    ED ¶

    ED :: "J"
     

    Erase in Display

    EL ¶

    EL :: "K"
     

    Erase in Line

    ESC ¶

    ESC :: "\e"
     

    Escape

    FG_BRIGHT_BLACK ¶

    FG_BRIGHT_BLACK :: "90"
     

    Also known as grey.

    FG_COLOR_24_BIT ¶

    FG_COLOR_24_BIT :: "38;2"
     

    Followed by ";r;g;b" where r,g,b are in 0..=255

    FG_COLOR_8_BIT ¶

    FG_COLOR_8_BIT :: "38;5"
     

    Followed by ";n" where n is in 0..=255

    FONT_FRAKTUR ¶

    FONT_FRAKTUR :: "20"
     

    Rarely supported.

    HIDE ¶

    HIDE :: "8"
     

    Not widely supported.

    HVP ¶

    HVP :: "f"
     

    Horizontal Vertical Position

    HYPERLINK :: "8"
     

    Followed by ";[params];<URI>" ST. Closed by OSC HYPERLINK ";;" ST.

    INVERT ¶

    INVERT :: "7"
     

    Also known as reverse video.

    ITALIC ¶

    ITALIC :: "3"
     

    Not widely supported.

    NO_ITALIC_BLACKLETTER ¶

    NO_ITALIC_BLACKLETTER :: "23"

    NO_PROPORTIONAL_SPACING ¶

    NO_PROPORTIONAL_SPACING :: "50"

    OSC ¶

    OSC :: ESC + "]"
     

    Operating System Command

    PROPORTIONAL_SPACING ¶

    PROPORTIONAL_SPACING :: "26"

    RCP ¶

    RCP :: "u"
     

    Restore Saved Cursor Position

    SCP ¶

    SCP :: "s"
     

    Save Current Cursor Position

    SD ¶

    SD :: "T"
     

    Scroll Down

    SGR ¶

    SGR :: "m"
     

    Select Graphic Rendition

    ST ¶

    ST :: ESC + "\\"
     

    String Terminator

    SU ¶

    SU :: "S"
     

    Scroll Up

    UNDERLINE_DOUBLE ¶

    UNDERLINE_DOUBLE :: "21"
     

    May be interpreted as "disable bold."

    WINDOW_TITLE ¶

    WINDOW_TITLE :: "2"
     

    Followed by ";<text>" ST.

    Variables

    This section is empty.

    Procedures

    clear_display_to_end ¶

    clear_display_to_end :: proc() -> string {…}

    clear_line ¶

    clear_line :: proc() -> string {…}

    clear_screen ¶

    clear_screen :: proc() -> string {…}
     

    Returns a sequence that clears the screen and moves the cursor to the home position.

    clear_to_end_of_line ¶

    clear_to_end_of_line :: proc() -> string {…}

    clear_to_start_of_line ¶

    clear_to_start_of_line :: proc() -> string {…}

    color_alloc ¶

    color_alloc :: proc(text: any, codes: string, allocator := context.temp_allocator) -> string {…}

    color_buf ¶

    color_buf :: proc(buf: []u8, text: any, codes: string) -> string {…}

    disable_auto_wrap ¶

    disable_auto_wrap :: proc() -> string {…}

    enable_auto_wrap ¶

    enable_auto_wrap :: proc() -> string {…}

    enter_alt_screen ¶

    enter_alt_screen :: proc() -> string {…}

    exit_alt_screen ¶

    exit_alt_screen :: proc() -> string {…}

    hide_cursor ¶

    hide_cursor :: proc "contextless" () -> string {…}

    move_cursor_alloc ¶

    move_cursor_alloc :: proc(row, column: int, allocator := context.temp_allocator) -> string {…}

    move_cursor_backward_alloc ¶

    move_cursor_backward_alloc :: proc(
    	count:     int = 1, 
    	allocator := context.temp_allocator, 
    ) -> string {…}

    move_cursor_backward_buf ¶

    move_cursor_backward_buf :: proc(buf: []u8, count: int = 1) -> string {…}

    move_cursor_buf ¶

    move_cursor_buf :: proc(buf: []u8, row, column: int) -> string {…}

    move_cursor_down_alloc ¶

    move_cursor_down_alloc :: proc(count: int = 1, allocator := context.temp_allocator) -> string {…}

    move_cursor_down_buf ¶

    move_cursor_down_buf :: proc(buf: []u8, count: int = 1) -> string {…}

    move_cursor_forward_alloc ¶

    move_cursor_forward_alloc :: proc(
    	count:     int = 1, 
    	allocator := context.temp_allocator, 
    ) -> string {…}

    move_cursor_forward_buf ¶

    move_cursor_forward_buf :: proc(buf: []u8, count: int = 1) -> string {…}

    move_cursor_previous_line_alloc ¶

    move_cursor_previous_line_alloc :: proc(
    	count:     int = 1, 
    	allocator := context.temp_allocator, 
    ) -> string {…}

    move_cursor_previous_line_buf ¶

    move_cursor_previous_line_buf :: proc(buf: []u8, count: int = 1) -> string {…}

    move_cursor_up_alloc ¶

    move_cursor_up_alloc :: proc(count: int = 1, allocator := context.temp_allocator) -> string {…}

    move_cursor_up_buf ¶

    move_cursor_up_buf :: proc(buf: []u8, count: int = 1) -> string {…}

    restore_cursor ¶

    restore_cursor :: proc() -> string {…}

    save_cursor ¶

    save_cursor :: proc() -> string {…}

    sgr_alloc ¶

    sgr_alloc :: proc(code: string, allocator := context.temp_allocator) -> string {…}

    sgr_buf ¶

    sgr_buf :: proc(buf: []u8, code: string) -> string {…}

    show_cursor ¶

    show_cursor :: proc "contextless" () -> string {…}

    Procedure Groups

    color ¶

    color :: proc{
    	color_alloc,
    	color_buf,
    }
    
     

    Wraps text in an SGR style and resets the style afterward.

    codes may contain multiple semicolon-separated SGR parameters, such as BOLD + ";" + FG_RED or FG_COLOR_24_BIT + ";255;0;0". The buffer form requires enough space for the %v representation of text, codes, and the surrounding escape sequences.

    sgr ¶

    sgr :: proc{
    	sgr_alloc,
    	sgr_buf,
    }
    
     

    Returns an SGR sequence for the given code, such as FG_RED or BOLD. The buffer form requires enough space for the code and sequence (len(code) + 3 bytes).

    Source Files

    Generation Information

    Generated with odin version dev-2026-11 (vendor "odin") Windows_amd64 @ 2026-11-18 21:05:19.828955300 +0000 UTC