Raxol.Terminal.Buffer.Operations (Raxol v0.5.0)
View SourceHandles buffer operations for the terminal, including resizing, scrolling, and cursor movement.
Summary
Functions
Clears the scrollback buffer.
Creates a new empty line with the specified number of columns.
Deletes the specified number of characters at the cursor position.
Deletes the specified number of lines at the cursor position.
Deletes the specified number of lines at the cursor position with scroll region.
Erases the entire line.
Erases characters from the cursor position to the end of the line.
Erases characters from the start of the line to the cursor position.
Erases characters in the display based on the mode.
Erases characters in the current line based on the mode.
Erases all lines after the specified row.
Erases all lines before the specified row.
Gets the content of the buffer.
Moves the cursor to the beginning of the next line.
Inserts the specified number of blank characters at the cursor position.
Inserts the specified number of blank lines at the cursor position.
Inserts the specified number of blank lines at the cursor position with scroll region.
Checks if scrolling is needed and performs it if necessary.
Checks if scrolling is needed based on buffer state.
Creates a new buffer with the specified dimensions.
Moves the cursor to the next line, scrolling if necessary.
Reads data from the buffer.
Resizes the buffer to the specified dimensions.
Moves the cursor to the previous line.
Scrolls the buffer by the specified number of lines.
Scrolls the buffer down by the specified number of lines.
Scrolls the buffer up by the specified number of lines.
Writes data to the buffer.
Writes a character to the buffer at the specified position.
Writes a string to the buffer.
Functions
@spec clear_scrollback(ScreenBuffer.t()) :: ScreenBuffer.t()
Clears the scrollback buffer.
Parameters
buffer
- The screen buffer to modify
Returns
The modified buffer with an empty scrollback.
Examples
iex> buffer = ScreenBuffer.new(80, 24)
iex> Operations.clear_scrollback(buffer)
%{buffer | scrollback: []}
@spec create_empty_line(non_neg_integer()) :: [Raxol.Terminal.Buffer.Cell.t()]
Creates a new empty line with the specified number of columns.
Parameters
cols
- The number of columns in the line
Returns
A list of empty cells representing a line.
Examples
iex> Operations.create_empty_line(80)
[%Cell{char: "", style: %{}}, ...]
Deletes the specified number of characters at the cursor position.
Deletes the specified number of lines at the cursor position.
Deletes the specified number of lines at the cursor position with scroll region.
@spec erase_entire_line(ScreenBuffer.t(), non_neg_integer()) :: ScreenBuffer.t()
Erases the entire line.
Parameters
buffer
- The screen buffer to modifyrow
- The row to erase
Returns
The modified buffer with the specified line erased.
Examples
iex> buffer = ScreenBuffer.new(80, 24)
iex> Operations.erase_entire_line(buffer, 0)
[%Cell{char: "", style: %{}}, ...]
@spec erase_from_cursor_to_line_end( ScreenBuffer.t(), non_neg_integer(), non_neg_integer() ) :: ScreenBuffer.t()
Erases characters from the cursor position to the end of the line.
Parameters
buffer
- The screen buffer to modifyrow
- The row to erase fromcol
- The column to start erasing from
Returns
The modified buffer with characters erased.
Examples
iex> buffer = ScreenBuffer.new(80, 24)
iex> Operations.erase_from_cursor_to_line_end(buffer, 0, 40)
[%Cell{char: "", style: %{}}, ...]
@spec erase_from_line_start_to_cursor( ScreenBuffer.t(), non_neg_integer(), non_neg_integer() ) :: ScreenBuffer.t()
Erases characters from the start of the line to the cursor position.
Parameters
buffer
- The screen buffer to modifyrow
- The row to erase fromcol
- The column to erase up to
Returns
The modified buffer with characters erased.
Examples
iex> buffer = ScreenBuffer.new(80, 24)
iex> Operations.erase_from_line_start_to_cursor(buffer, 0, 40)
[%Cell{char: "", style: %{}}, ...]
Erases characters in the display based on the mode.
Erases characters in the current line based on the mode.
@spec erase_lines_after(ScreenBuffer.t(), non_neg_integer()) :: ScreenBuffer.t()
Erases all lines after the specified row.
Parameters
buffer
- The screen buffer to modifystart_row
- The row to start erasing from
Returns
The modified buffer with all lines after start_row erased.
Examples
iex> buffer = ScreenBuffer.new(80, 24)
iex> Operations.erase_lines_after(buffer, 12)
[%Cell{char: "", style: %{}}, ...]
@spec erase_lines_before(ScreenBuffer.t(), non_neg_integer()) :: ScreenBuffer.t()
Erases all lines before the specified row.
Parameters
buffer
- The screen buffer to modifyend_row
- The row to erase up to
Returns
The modified buffer with all lines before end_row erased.
Examples
iex> buffer = ScreenBuffer.new(80, 24)
iex> Operations.erase_lines_before(buffer, 12)
[%Cell{char: "", style: %{}}, ...]
Gets the content of the buffer.
Moves the cursor to the beginning of the next line.
Inserts the specified number of blank characters at the cursor position.
Inserts the specified number of blank lines at the cursor position.
Inserts the specified number of blank lines at the cursor position with scroll region.
Checks if scrolling is needed and performs it if necessary.
@spec needs_scroll?(ScreenBuffer.t()) :: boolean()
Checks if scrolling is needed based on buffer state.
Parameters
buffer
- The screen buffer to check
Returns
A boolean indicating if scrolling is needed.
Examples
iex> buffer = ScreenBuffer.new(80, 24)
iex> Operations.needs_scroll?(buffer)
false
Creates a new buffer with the specified dimensions.
Moves the cursor to the next line, scrolling if necessary.
Reads data from the buffer.
Resizes the buffer to the specified dimensions.
Moves the cursor to the previous line.
Scrolls the buffer by the specified number of lines.
Scrolls the buffer down by the specified number of lines.
Scrolls the buffer up by the specified number of lines.
Writes data to the buffer.
Writes a character to the buffer at the specified position.
Writes a string to the buffer.