Raxol.Terminal.Buffer.CharEditor (Raxol v2.0.1)

View Source

Manages 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

char_width(char)

Gets the width of a character.

content_length(line)

Determines the content length of a line (number of non-blank characters).

control_char?(char)

Checks if a character is a control character.

delete_char(cell)

Deletes a character at the current position.

delete_characters(buffer, row, col, count, default_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 with the specified style.

Parameters

  • buffer - The screen buffer to modify
  • row - The row to delete characters from
  • col - The column to start deleting from
  • count - The number of characters to delete
  • default_style - The style to apply to new blank characters

Returns

The updated screen buffer.

delete_chars(buffer, row, col, count)

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 modify
  • row - The row to delete characters from
  • col - The column to start deleting from
  • count - The number of characters to delete

Returns

The updated screen buffer.

delete_from_line(line, col, count, default_style)

Deletes characters from a line at the specified position.

Parameters

  • line - The line to modify
  • col - The column to start deleting from
  • count - The number of characters to delete
  • default_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

delete_string(cell, length)

Deletes a string of characters.

erase_chars(buffer, row, col, count)

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 modify
  • row - The row to erase characters from
  • col - The column to start erasing from
  • count - The number of characters to erase

Returns

The updated screen buffer.

erase_chars(buffer, row, col, count, style)

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 modify
  • row - The row to erase characters from
  • col - The column to start erasing from
  • count - The number of characters to erase
  • style - The style to apply to new blank characters

Returns

The updated screen buffer.

insert_char(cell, char)

Inserts a character at the current position.

insert_characters(buffer, row, col, count, default_style)

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 modify
  • row - The row to insert characters in
  • col - The column to start inserting at
  • count - The number of characters to insert
  • default_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)
" "

insert_chars(buffer, row, col, count)

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 modify
  • row - The row to insert characters in
  • col - The column to start inserting at
  • count - The number of characters to insert

Returns

The updated screen buffer.

insert_into_line(line, col, count, default_style)

Inserts characters into a line at the specified position.

Parameters

  • line - The line to modify
  • col - The column to start inserting at
  • count - The number of characters to insert
  • default_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

insert_string(cell, string)

Inserts a string of characters.

printable_char?(char)

Checks if a character is a printable character.

replace_char(cell, char)

Replaces a character at the current position.

replace_chars(buffer, row, col, string, style \\ nil)

replace_string(cell, string)

Replaces a string of characters.

string_width(string)

Gets the width of a string.

truncate_to_content_length(line, content_length)

Truncates a line to the specified content length, padding with blank cells if needed.

update_line_with_string(line, col, string, width)

whitespace_char?(char)

Checks if a character is a whitespace character.

write_char(buffer, row, col, char)

Writes a character at the specified position in the buffer.

write_string(buffer, row, col, string)

Writes a string at the specified position in the buffer.