struct

Athena::Console::Cursor

Inherits Struct / Value / Object

Provides an OO way to interact with the console window, allows writing on any position of the output.

@[ACONA::AsCommand("cursor")]
class CursorCommand < ACON::Command
  protected def execute(input : ACON::Input::Interface, output : ACON::Output::Interface) : ACON::Command::Status
    cursor = ACON::Cursor.new output

    # Move the cursor to a specific column, row position.
    cursor.move_to_position 50, 3

    # Write text at that location.
    output.puts "Hello!"

    # Clear the current line.
    cursor.clear_line

    ACON::Command::Status::SUCCESS
  end
end

Constructors

new(output : ACON::Output::Interface, input : IO = STDIN)
Source

Instance methods

clear_line

Clears the current line.

Source
clear_line_after

Clears the current line after the cursor's current position.

Source
clear_output

Clears the output from the cursors' current position to the end of the screen.

Source
clear_screen

Clears the entire screen.

Source
current_position

Returns the current column, row position of the cursor.

Source
hide

Hides the cursor.

Source
move_down(lines : Int32 = 1) : self

Moves the cursor down lines lines.

Source
move_left(lines : Int32 = 1) : self

Moves the cursor left lines lines.

Source
move_right(lines : Int32 = 1) : self

Moves the cursor right lines lines.

Source
move_to_column(column : Int32) : self

Moves the cursor to the provided column.

Source
move_to_position(column : Int32, row : Int32) : self

Moves the cursor to the provided column, row position.

Source
move_up(lines : Int32 = 1) : self

Moves the cursor up lines lines.

Source
restore_position

Restores the position set via #save_position.

Source
save_position

Saves the current position such that it could be restored via #restore_position.

Source
show

Shows the cursor.

Source