Raxol.Terminal.Buffer.Manager (Raxol v0.3.0)
View SourceManages terminal buffers and their operations. Coordinates between different buffer-related modules.
Summary
Functions
Returns a specification to start this module under a supervisor.
Clears all damage regions.
Returns the default tab stop positions for a given width.
Gets a cell from the active buffer.
Gets the current cursor position.
Gets the damaged regions in the buffer.
Gets the current memory usage.
Gets the number of lines in the scrollback buffer.
Gets the current state of the buffer manager.
Initializes main and alternate screen buffers with the specified dimensions.
Marks a region of the buffer as damaged (needs redraw).
Creates a new buffer manager with the specified dimensions.
Resizes the buffer.
Sets a cell in the active buffer.
Sets the cursor position.
Sets the cursor position in the buffer manager.
Starts a new buffer manager process.
Updates the memory usage for the buffer manager.
Types
@type t() :: Raxol.Terminal.Buffer.Manager.State.t()
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Clears all damage regions.
Examples
iex> {:ok, pid} = Buffer.Manager.start_link()
iex> :ok = Buffer.Manager.clear_damage(pid)
iex> Buffer.Manager.get_damage(pid)
[]
Returns the default tab stop positions for a given width.
Examples
iex> Manager.default_tab_stops(8)
[0, 8, 16, 24, 32, 40, 48, 56]
Gets a cell from the active buffer.
Examples
iex> {:ok, pid} = Buffer.Manager.start_link()
iex> Buffer.Manager.get_cell(pid, 0, 0)
%Cell{char: " ", fg: :default, bg: :default}
Gets the current cursor position.
Examples
iex> {:ok, pid} = Buffer.Manager.start_link()
iex> Buffer.Manager.get_cursor(pid)
{0, 0}
Gets the damaged regions in the buffer.
Examples
iex> {:ok, pid} = Buffer.Manager.start_link()
iex> Buffer.Manager.get_damage(pid)
[]
Gets the current memory usage.
Examples
iex> {:ok, pid} = Buffer.Manager.start_link()
iex> Buffer.Manager.get_memory_usage(pid)
0
Gets the number of lines in the scrollback buffer.
Examples
iex> {:ok, pid} = Buffer.Manager.start_link()
iex> Buffer.Manager.get_scrollback_count(pid)
0
Gets the current state of the buffer manager.
Examples
iex> {:ok, pid} = Buffer.Manager.start_link()
iex> state = Buffer.Manager.get_state(pid)
iex> state.active_buffer.width
80
Initializes main and alternate screen buffers with the specified dimensions.
Examples
iex> {main_buffer, alt_buffer} = Manager.initialize_buffers(80, 24, 1000)
iex> main_buffer.width
80
iex> alt_buffer.height
24
Marks a region of the buffer as damaged (needs redraw).
Creates a new buffer manager with the specified dimensions.
Examples
iex> {:ok, manager} = Manager.new(80, 24)
iex> manager.active_buffer.width
80
iex> manager.active_buffer.height
24
Resizes the buffer.
Examples
iex> {:ok, pid} = Buffer.Manager.start_link()
iex> :ok = Buffer.Manager.resize(pid, 100, 30)
iex> state = Buffer.Manager.get_state(pid)
iex> state.active_buffer.width
100
iex> state.active_buffer.height
30
Sets a cell in the active buffer.
Examples
iex> {:ok, pid} = Buffer.Manager.start_link()
iex> cell = %Cell{char: "A", fg: :red, bg: :blue}
iex> :ok = Buffer.Manager.set_cell(pid, 0, 0, cell)
iex> state = Buffer.Manager.get_state(pid)
iex> Buffer.get_cell(state, 0, 0)
%Cell{char: "A", fg: :red, bg: :blue}
Sets the cursor position.
Examples
iex> {:ok, pid} = Buffer.Manager.start_link()
iex> :ok = Buffer.Manager.set_cursor(pid, 10, 5)
iex> state = Buffer.Manager.get_state(pid)
iex> Cursor.get_position(state)
{10, 5}
Sets the cursor position in the buffer manager.
Starts a new buffer manager process.
Options
:width
- The width of the buffer (default: 80):height
- The height of the buffer (default: 24):scrollback_height
- The maximum number of scrollback lines (default: 1000):memory_limit
- The maximum memory usage in bytes (default: 10_000_000)
Examples
iex> {:ok, pid} = Buffer.Manager.start_link(width: 100, height: 30)
iex> Process.alive?(pid)
true
Updates the memory usage for the buffer manager.