Raxol.Terminal.Buffer.Manager (Raxol v0.4.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 in the buffer manager state struct (PID version).
Returns the default tab stop positions for a given width.
Gets the active buffer based on the active_buffer_type.
Gets a cell from the active buffer.
Gets the current cursor position.
Gets the cursor position from the manager state.
Gets the damaged regions in the buffer.
Returns all damaged regions in the buffer manager state.
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).
Checks if the buffer needs to scroll (stub implementation). Returns the state unchanged for now.
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 active buffer based on the active_buffer_type.
Updates the memory usage for the buffer manager.
Returns true if the buffer manager's memory usage is within limits.
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 in the buffer manager state struct (PID version).
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 the active buffer based on the active_buffer_type.
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 cursor position from the manager state.
Gets the damaged regions in the buffer.
Examples
iex> {:ok, pid} = Buffer.Manager.start_link()
iex> Buffer.Manager.get_damage(pid)
[]
Returns all damaged regions in the buffer manager state.
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).
Checks if the buffer needs to scroll (stub implementation). Returns the state unchanged for now.
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 active buffer based on the active_buffer_type.
Updates the memory usage for the buffer manager.
Returns true if the buffer manager's memory usage is within limits.