Raxol.Terminal.Commands.Editor (Raxol v0.3.0)

View Source

Handles 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

clear_line(buffer, cursor_pos, mode, default_style)

Clears a line or a part of it based on the mode parameter.

Parameters

  • buffer - The current screen buffer
  • cursor_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

clear_region(buffer, start_x, start_y, end_x, end_y, default_style)

Clears a rectangular region of the screen.

Parameters

  • buffer - The current screen buffer
  • start_x - Starting x coordinate
  • start_y - Starting y coordinate
  • end_x - Ending x coordinate
  • end_y - Ending y coordinate
  • default_style - The style to use for cleared areas

Returns

  • Updated screen buffer

clear_screen(buffer, cursor_pos, mode, default_style)

Clears the screen or a part of it based on the mode parameter.

Parameters

  • buffer - The current screen buffer
  • cursor_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

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

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.

delete_lines(buffer, row, count, default_style)

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.

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

Erases a specified number of characters starting from the current cursor position. Characters are replaced with blank spaces using the default style.

insert_chars(buffer, row, col, count, 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.

insert_lines(buffer, row, count, default_style)

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.