nxt::ansi namespace

Classes

struct SynchronizedUpdate
RAII wrapper for terminal synchronized update mode.
struct TerminalGuard
class Writer
ANSI escape sequence builder that writes to a string buffer.

Enums

enum class Mode { disabled, debug, enabled }
ANSI output modes.
enum class TerminalColor: int { black = 30, red = 31, green = 32, yellow = 33, blue = 34, magenta = 35, cyan = 36, white = 37, bright_black = 90, bright_red = 91, bright_green = 92, bright_yellow = 93, bright_blue = 94, bright_magenta = 95, bright_cyan = 96, bright_white = 97 }
ANSI 16-color SGR foreground codes.

Functions

void begin_synchronized_update()
void clear_line()
void clear_screen()
void end_synchronized_update()
void hide_cursor()
void init()
auto is_tty() →  bool
Check if stdout is connected to a real TTY.
void move_to(ansi_row_t row, ansi_col_t col)
void move_to(Pos pos)
auto query_cursor_position() →  std::optional<Pos>
auto render_raster(const Raster& raster) →  std::string
void reset_scroll_region()
void scroll_down(height_t n = 1*ln)
void scroll_up(height_t n = 1*ln)
void set_scroll_region(row_t top, row_t bottom)
void show_cursor()

Variables

Mode mode
Current ANSI output mode.

Enum documentation

enum class nxt::ansi::Mode

ANSI output modes.

enum class nxt::ansi::TerminalColor: int

ANSI 16-color SGR foreground codes.

Function documentation

void nxt::ansi::begin_synchronized_update()

void nxt::ansi::clear_line()

void nxt::ansi::clear_screen()

void nxt::ansi::end_synchronized_update()

void nxt::ansi::hide_cursor()

void nxt::ansi::init()

Initialize the ANSI module. Sets mode based on TTY detection. Call this early in main().

bool nxt::ansi::is_tty()

Check if stdout is connected to a real TTY.

void nxt::ansi::move_to(ansi_row_t row, ansi_col_t col)

void nxt::ansi::move_to(Pos pos)

std::optional<Pos> nxt::ansi::query_cursor_position()

Query current cursor position (blocking). Sends DSR 6 and reads CPR response from stdin. Returns nullopt if query fails (not a TTY, timeout, parse error). Requires terminal to be in raw mode for reliable response reading.

std::string nxt::ansi::render_raster(const Raster& raster)

Standalone functions for immediate output (writes directly to stdout) Render a raster as inline SGR-styled text suitable for scrollback output.

void nxt::ansi::reset_scroll_region()

void nxt::ansi::scroll_down(height_t n = 1*ln)

void nxt::ansi::scroll_up(height_t n = 1*ln)

void nxt::ansi::set_scroll_region(row_t top, row_t bottom)

void nxt::ansi::show_cursor()

Variable documentation

Mode nxt::ansi::mode

Current ANSI output mode.