Raxol.Terminal.Commands.Editor (Raxol v0.3.0)
View SourceHandles editor operations for the terminal buffer.
This module provides functions for inserting and deleting lines and characters, as well as erasing characters in the terminal buffer. It also handles screen and line operations like clearing the screen or parts of it.
Summary
Functions
Clears a line or a part of it based on the mode parameter.
Clears a rectangular region of the screen.
Clears the screen or a part of it based on the mode parameter.
Deletes a specified number of characters starting from the current cursor position. Characters to the right of the deleted characters are shifted left, and blank characters are added at the end.
Deletes a specified number of lines starting from the current cursor position. Lines below the deleted lines are shifted up, and blank lines are added at the bottom.
Erases a specified number of characters starting from the current cursor position. Characters are replaced with blank spaces using the default style.
Inserts a specified number of blank characters at the current cursor position. Characters to the right of the cursor are shifted right, and characters shifted off the end are discarded.
Inserts a specified number of blank lines at the current cursor position. Lines below the cursor are shifted down, and lines shifted off the bottom are discarded.
Functions
@spec clear_line( Raxol.Terminal.ScreenBuffer.t(), {non_neg_integer(), non_neg_integer()}, integer(), Raxol.Terminal.ANSI.TextFormatting.text_style() ) :: Raxol.Terminal.ScreenBuffer.t()
Clears a line or a part of it based on the mode parameter.
Parameters
buffer
- The current screen buffercursor_pos
- The current cursor position {x, y}mode
- The clear mode:- 0 - Clear from cursor to end of line
- 1 - Clear from beginning of line to cursor
- 2 - Clear entire line
default_style
- The style to use for cleared areas
Returns
- Updated screen buffer
@spec clear_region( Raxol.Terminal.ScreenBuffer.t(), non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer(), Raxol.Terminal.ANSI.TextFormatting.text_style() ) :: Raxol.Terminal.ScreenBuffer.t()
Clears a rectangular region of the screen.
Parameters
buffer
- The current screen bufferstart_x
- Starting x coordinatestart_y
- Starting y coordinateend_x
- Ending x coordinateend_y
- Ending y coordinatedefault_style
- The style to use for cleared areas
Returns
- Updated screen buffer
@spec clear_screen( Raxol.Terminal.ScreenBuffer.t(), {non_neg_integer(), non_neg_integer()}, integer(), Raxol.Terminal.ANSI.TextFormatting.text_style() ) :: Raxol.Terminal.ScreenBuffer.t()
Clears the screen or a part of it based on the mode parameter.
Parameters
buffer
- The current screen buffercursor_pos
- The current cursor position {x, y}mode
- The clear mode:- 0 - Clear from cursor to end of screen
- 1 - Clear from beginning of screen to cursor
- 2 - Clear entire screen but don't move cursor
- 3 - Clear entire screen including scrollback
default_style
- The style to use for cleared areas
Returns
- Updated screen buffer
@spec delete_chars( 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 current cursor position. Characters to the right of the deleted characters are shifted left, and blank characters are added at the end.
@spec delete_lines( Raxol.Terminal.ScreenBuffer.t(), non_neg_integer(), non_neg_integer(), Raxol.Terminal.ANSI.TextFormatting.text_style() ) :: Raxol.Terminal.ScreenBuffer.t()
Deletes a specified number of lines starting from the current cursor position. Lines below the deleted lines are shifted up, and blank lines are added at the bottom.
@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 current cursor position. Characters are replaced with blank spaces using the default style.
@spec insert_chars( 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 current cursor position. Characters to the right of the cursor are shifted right, and characters shifted off the end are discarded.
@spec insert_lines( Raxol.Terminal.ScreenBuffer.t(), non_neg_integer(), non_neg_integer(), Raxol.Terminal.ANSI.TextFormatting.text_style() ) :: Raxol.Terminal.ScreenBuffer.t()
Inserts a specified number of blank lines at the current cursor position. Lines below the cursor are shifted down, and lines shifted off the bottom are discarded.