Raxol.Terminal.Integration.Renderer (Raxol v0.5.0)

View Source

Handles terminal output rendering and display management using Termbox2.

Summary

Functions

Clears the terminal screen (specifically, the back buffer). Call present/0 afterwards to make it visible. Returns :ok or {:error, reason}.

Gets the current terminal dimensions. Returns {:ok, {width, height}} or {:error, :dimensions_unavailable}. Note: termbox2 width/height C functions return int, not status codes. A negative value might indicate an error (e.g., not initialized).

Gets the terminal title.

Initializes the underlying terminal system. Must be called before other rendering functions. Returns :ok or {:error, reason}.

Moves the hardware cursor to a specific position on the screen. Call present/0 afterwards if you want to ensure it's shown with other changes. The cursor position is typically updated with present/0. Returns :ok or {:error, reason}.

Creates a new renderer with the given options.

Renders the current terminal state to the screen. Returns :ok or {:error, reason}.

Resets the renderer configuration to defaults.

Resizes the renderer to the given dimensions.

Sets a specific configuration value.

Sets the cursor visibility.

Sets the terminal title.

Shuts down the underlying terminal system. Must be called to restore terminal state. Returns :ok or {:error, reason}.

Updates the renderer configuration.

Functions

clear_screen(state)

Clears the terminal screen (specifically, the back buffer). Call present/0 afterwards to make it visible. Returns :ok or {:error, reason}.

get_dimensions()

Gets the current terminal dimensions. Returns {:ok, {width, height}} or {:error, :dimensions_unavailable}. Note: termbox2 width/height C functions return int, not status codes. A negative value might indicate an error (e.g., not initialized).

get_title(state)

Gets the terminal title.

init_terminal()

Initializes the underlying terminal system. Must be called before other rendering functions. Returns :ok or {:error, reason}.

move_cursor(state, x, y)

Moves the hardware cursor to a specific position on the screen. Call present/0 afterwards if you want to ensure it's shown with other changes. The cursor position is typically updated with present/0. Returns :ok or {:error, reason}.

new(opts \\ [])

Creates a new renderer with the given options.

render(state)

Renders the current terminal state to the screen. Returns :ok or {:error, reason}.

reset_config(state)

Resets the renderer configuration to defaults.

resize(state, width, height)

Resizes the renderer to the given dimensions.

set_config_value(state, key, value)

Sets a specific configuration value.

set_cursor_visibility(state, visible)

Sets the cursor visibility.

set_title(state, title)

Sets the terminal title.

shutdown_terminal()

Shuts down the underlying terminal system. Must be called to restore terminal state. Returns :ok or {:error, reason}.

update_config(state, config)

Updates the renderer configuration.