Raxol.Terminal.Buffer.CharEditor (Raxol v0.5.0)

View Source

Manages 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

char_width(char)

Gets the width of a character.

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 using the provided default 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 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)
" "

delete_string(cell, length)

Deletes a string of characters.

insert_char(cell, char)

Inserts a character at the current position.

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

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 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_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_string(cell, string)

Replaces a string of characters.

string_width(string)

Gets the width of a string.

whitespace_char?(char)

Checks if a character is a whitespace character.