Skip to content

struct Athena::Console::Cursor
inherits Struct #

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)#

Methods#

#clear_line : self#

Clears the current line.

#clear_line_after : self#

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

#clear_output : self#

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

#clear_screen : self#

Clears the entire screen.

#current_position : ::Tuple(Int32, Int32)#

Returns the current column, row position of the cursor.

#hide : self#

Hides the cursor.

#move_down(lines : Int32 = 1) : self#

Moves the cursor down lines lines.

#move_left(lines : Int32 = 1) : self#

Moves the cursor left lines lines.

#move_right(lines : Int32 = 1) : self#

Moves the cursor right lines lines.

#move_to_column(column : Int32) : self#

Moves the cursor to the provided column.

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

Moves the cursor to the provided column, row position.

#move_up(lines : Int32 = 1) : self#

Moves the cursor up lines lines.

#restore_position : self#

Restores the position set via #save_position.

#save_position : self#

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

#show : self#

Shows the cursor.