Raxol.Terminal.Buffer.CharEditor (Raxol v2.0.1)
View SourceManages terminal character editing operations.
Summary
Functions
Gets the width of a character.
Determines the content length of a line (number of non-blank characters).
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 with the specified style.
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.
Deletes characters from a line at the specified position.
Deletes a string of characters.
Erases a specified number of characters starting from the given position. Characters to the right of the erased characters are shifted left. Blank characters are added at the end of the line.
Erases a specified number of characters starting from the given position with a specific style. Characters to the right of the erased characters are shifted left. Blank characters are added at the end of the line with the specified style.
Inserts a character at the current position.
Inserts a specified number of 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 a specified number of 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.
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.
Truncates a line to the specified content length, padding with blank cells if needed.
Checks if a character is a whitespace character.
Writes a character at the specified position in the buffer.
Writes a string at the specified position in the buffer.
Functions
Gets the width of a character.
Determines the content length of a line (number of non-blank characters).
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 with the specified 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 blank characters
Returns
The updated screen buffer.
@spec delete_chars( Raxol.Terminal.ScreenBuffer.t(), non_neg_integer(), non_neg_integer(), non_neg_integer() ) :: 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.
Parameters
buffer- The screen buffer to modifyrow- The row to delete characters fromcol- The column to start deleting fromcount- The number of characters to delete
Returns
The updated screen buffer.
@spec delete_from_line( [Raxol.Terminal.Cell.t()], non_neg_integer(), non_neg_integer(), Raxol.Terminal.ANSI.TextFormatting.text_style() ) :: [Raxol.Terminal.Cell.t()]
Deletes characters from a line at the specified position.
Parameters
line- The line to modifycol- The column to start deleting fromcount- The number of characters to deletedefault_style- The style to apply to new blank characters
Returns
The updated line with deleted characters replaced by blanks.
Examples
iex> line = List.duplicate(%Cell{}, 10)
iex> style = %{fg: :red, bg: :blue}
iex> new_line = CharEditor.delete_from_line(line, 5, 3, style)
iex> length(new_line)
10
Deletes a string of characters.
@spec erase_chars( Raxol.Terminal.ScreenBuffer.t(), non_neg_integer(), non_neg_integer(), non_neg_integer() ) :: Raxol.Terminal.ScreenBuffer.t()
Erases a specified number of characters starting from the given position. Characters to the right of the erased characters are shifted left. Blank characters are added at the end of the line.
Parameters
buffer- The screen buffer to modifyrow- The row to erase characters fromcol- The column to start erasing fromcount- The number of characters to erase
Returns
The updated screen buffer.
@spec erase_chars( Raxol.Terminal.ScreenBuffer.t(), non_neg_integer(), non_neg_integer(), non_neg_integer(), Raxol.Terminal.ANSI.TextFormatting.text_style() ) :: Raxol.Terminal.ScreenBuffer.t()
Erases a specified number of characters starting from the given position with a specific style. Characters to the right of the erased characters are shifted left. Blank characters are added at the end of the line with the specified style.
Parameters
buffer- The screen buffer to modifyrow- The row to erase characters fromcol- The column to start erasing fromcount- The number of characters to erasestyle- The style to apply to new blank characters
Returns
The updated screen buffer.
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 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_chars( Raxol.Terminal.ScreenBuffer.t(), non_neg_integer(), non_neg_integer(), non_neg_integer() ) :: Raxol.Terminal.ScreenBuffer.t()
Inserts a specified number of 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.
Parameters
buffer- The screen buffer to modifyrow- The row to insert characters incol- The column to start inserting atcount- The number of characters to insert
Returns
The updated screen buffer.
@spec insert_into_line( [Raxol.Terminal.Cell.t()], non_neg_integer(), non_neg_integer(), Raxol.Terminal.ANSI.TextFormatting.text_style() ) :: [Raxol.Terminal.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.
Truncates a line to the specified content length, padding with blank cells if needed.
Checks if a character is a whitespace character.
Writes a character at the specified position in the buffer.
Writes a string at the specified position in the buffer.