Raxol.Terminal.Buffer.Common (Raxol v0.5.0)
View SourceCommon buffer operations shared between different buffer-related modules. This module provides utility functions for buffer manipulation that are used by multiple modules to avoid code duplication.
Summary
Functions
Appends new lines to existing lines.
Creates a single empty line with optional styling.
Creates empty lines with optional styling.
Gets the lines within a specific region of the buffer.
Gets the bottom boundary of the scroll region.
Gets the top boundary of the scroll region.
Replaces content in a specific region of the buffer.
Functions
@spec append_lines([[Raxol.Terminal.Cell.t()]], [[Raxol.Terminal.Cell.t()]]) :: {:ok, [[Raxol.Terminal.Cell.t()]]}
Appends new lines to existing lines.
Parameters
lines
- Current buffer linesnew_lines
- Lines to append
Returns
{:ok, combined_lines}
on success
@spec create_empty_line(Raxol.Terminal.ANSI.TextFormatting.text_style() | nil) :: [ Raxol.Terminal.Cell.t() ]
Creates a single empty line with optional styling.
Parameters
blank_style
- Optional style to apply to blank line
Returns
Empty line with optional styling
@spec create_empty_lines( non_neg_integer(), Raxol.Terminal.ANSI.TextFormatting.text_style() | nil ) :: {:ok, [[Raxol.Terminal.Cell.t()]]}
Creates empty lines with optional styling.
Parameters
count
- Number of lines to createblank_style
- Optional style to apply to blank lines
Returns
{:ok, new_lines}
on success
@spec get_region_lines( [[Raxol.Terminal.Cell.t()]], non_neg_integer(), non_neg_integer() ) :: {:ok, [[Raxol.Terminal.Cell.t()]]} | {:error, atom()}
Gets the lines within a specific region of the buffer.
Parameters
lines
- Current buffer linestop
- Top boundary of regionbottom
- Bottom boundary of region
Returns
{:ok, region_lines}
on success{:error, :invalid_region}
on failure
@spec get_scroll_bottom( Raxol.Terminal.ScreenBuffer.t(), {non_neg_integer(), non_neg_integer()} | nil ) :: {:ok, non_neg_integer()} | {:error, atom()}
Gets the bottom boundary of the scroll region.
Parameters
buffer
- The screen bufferscroll_region
- Optional scroll region override
Returns
{:ok, bottom}
on success{:error, reason}
on failure
@spec get_scroll_top( Raxol.Terminal.ScreenBuffer.t(), {non_neg_integer(), non_neg_integer()} | nil ) :: {:ok, non_neg_integer()} | {:error, atom()}
Gets the top boundary of the scroll region.
Parameters
buffer
- The screen bufferscroll_region
- Optional scroll region override
Returns
{:ok, top}
on success{:error, reason}
on failure
@spec replace_region( [[Raxol.Terminal.Cell.t()]], [[Raxol.Terminal.Cell.t()]], non_neg_integer(), non_neg_integer() ) :: [[Raxol.Terminal.Cell.t()]]
Replaces content in a specific region of the buffer.
Parameters
lines
- Current buffer linesnew_region
- New content for the regiontop
- Top boundary of regionbottom
- Bottom boundary of region
Returns
Updated buffer lines with the region replaced