Raxol.Terminal.Renderer (Raxol v0.2.0)
View SourceTerminal renderer module.
This module handles rendering of terminal output, including:
- Character cell rendering
- Text styling
- Cursor rendering
- Performance optimizations
Summary
Functions
Clears the cursor position.
Creates a new renderer with the given screen buffer.
Renders the screen buffer to a string.
Sets the cursor position.
Sets the font settings.
Sets the theme.
Types
@type t() :: %Raxol.Terminal.Renderer{ cursor: {non_neg_integer(), non_neg_integer()} | nil, font_settings: map(), screen_buffer: Raxol.Terminal.ScreenBuffer.t(), theme: map() }
Functions
Clears the cursor position.
Examples
iex> screen_buffer = ScreenBuffer.new(80, 24)
iex> renderer = Renderer.new(screen_buffer)
iex> renderer = Renderer.set_cursor(renderer, {10, 5})
iex> renderer = Renderer.clear_cursor(renderer)
iex> renderer.cursor
nil
Creates a new renderer with the given screen buffer.
Examples
iex> screen_buffer = ScreenBuffer.new(80, 24)
iex> renderer = Renderer.new(screen_buffer)
iex> renderer.screen_buffer
%ScreenBuffer{}
Renders the screen buffer to a string.
Examples
iex> screen_buffer = ScreenBuffer.new(80, 24)
iex> renderer = Renderer.new(screen_buffer)
iex> output = Renderer.render(renderer)
iex> is_binary(output)
true
Sets the cursor position.
Examples
iex> screen_buffer = ScreenBuffer.new(80, 24)
iex> renderer = Renderer.new(screen_buffer)
iex> renderer = Renderer.set_cursor(renderer, {10, 5})
iex> renderer.cursor
{10, 5}
Sets the font settings.
Examples
iex> screen_buffer = ScreenBuffer.new(80, 24)
iex> renderer = Renderer.new(screen_buffer)
iex> font_settings = %{family: "monospace", size: 14}
iex> renderer = Renderer.set_font_settings(renderer, font_settings)
iex> renderer.font_settings
%{family: "monospace", size: 14}
Sets the theme.
Examples
iex> screen_buffer = ScreenBuffer.new(80, 24)
iex> renderer = Renderer.new(screen_buffer)
iex> theme = %{foreground: %{default: "#FFFFFF"}}
iex> renderer = Renderer.set_theme(renderer, theme)
iex> renderer.theme
%{foreground: %{default: "#FFFFFF"}}