Raxol.Terminal.Buffer.CharEditor (Raxol v0.5.0)
View SourceManages terminal character editing operations.
Summary
Functions
Gets the width of a character.
Checks if a character is a control character.
Deletes a character at the current position.
Deletes a specified number of characters starting from the given position. Characters to the right of the deleted characters are shifted left. Blank characters are added at the end of the line using the provided default style.
Deletes a string of characters.
Inserts a character at the current position.
Inserts a specified number of blank characters at the given position. Characters to the right of the insertion point are shifted right. Characters shifted off the end of the line are discarded. Uses the provided default style for new characters.
Inserts characters into a line at the specified position.
Inserts a string of characters.
Checks if a character is a printable character.
Replaces a character at the current position.
Replaces a string of characters.
Gets the width of a string.
Checks if a character is a whitespace character.
Functions
Gets the width of a character.
Checks if a character is a control character.
Deletes a character at the current position.
@spec delete_characters( Raxol.Terminal.ScreenBuffer.t(), non_neg_integer(), non_neg_integer(), non_neg_integer(), Raxol.Terminal.ANSI.TextFormatting.text_style() ) :: Raxol.Terminal.ScreenBuffer.t()
Deletes a specified number of characters starting from the given position. Characters to the right of the deleted characters are shifted left. Blank characters are added at the end of the line using the provided default style.
Parameters
buffer
- The screen buffer to modifyrow
- The row to delete characters fromcol
- The column to start deleting fromcount
- The number of characters to deletedefault_style
- The style to apply to new characters
Returns
The updated screen buffer.
Examples
iex> buffer = ScreenBuffer.new(80, 24)
iex> style = %{fg: :red, bg: :blue}
iex> buffer = CharEditor.delete_characters(buffer, 0, 0, 5, style)
iex> CharEditor.get_char(buffer, 0, 0)
" "
Deletes a string of characters.
Inserts a character at the current position.
@spec insert_characters( Raxol.Terminal.ScreenBuffer.t(), non_neg_integer(), non_neg_integer(), non_neg_integer(), Raxol.Terminal.ANSI.TextFormatting.text_style() ) :: Raxol.Terminal.ScreenBuffer.t()
Inserts a specified number of blank characters at the given position. Characters to the right of the insertion point are shifted right. Characters shifted off the end of the line are discarded. Uses the provided default style for new characters.
Parameters
buffer
- The screen buffer to modifyrow
- The row to insert characters incol
- The column to start inserting atcount
- The number of characters to insertdefault_style
- The style to apply to new characters
Returns
The updated screen buffer.
Examples
iex> buffer = ScreenBuffer.new(80, 24)
iex> style = %{fg: :red, bg: :blue}
iex> buffer = CharEditor.insert_characters(buffer, 0, 0, 5, style)
iex> CharEditor.get_char(buffer, 0, 0)
" "
@spec insert_into_line( [Raxol.Terminal.Buffer.Cell.t()], non_neg_integer(), non_neg_integer(), Raxol.Terminal.ANSI.TextFormatting.text_style() ) :: [Raxol.Terminal.Buffer.Cell.t()]
Inserts characters into a line at the specified position.
Parameters
line
- The line to modifycol
- The column to start inserting atcount
- The number of characters to insertdefault_style
- The style to apply to new characters
Returns
The updated line with inserted characters.
Examples
iex> line = List.duplicate(%Cell{}, 10)
iex> style = %{fg: :red, bg: :blue}
iex> new_line = CharEditor.insert_into_line(line, 5, 3, style)
iex> length(new_line)
10
Inserts a string of characters.
Checks if a character is a printable character.
Replaces a character at the current position.
Replaces a string of characters.
Gets the width of a string.
Checks if a character is a whitespace character.