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

View source

Methods#

#clear_line : self#

Clears the current line.

View source

#clear_line_after : self#

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

View source

#clear_output : self#

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

View source

#clear_screen : self#

Clears the entire screen.

View source

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

Returns the current column, row position of the cursor.

View source

#hide : self#

Hides the cursor.

View source

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

Moves the cursor down lines lines.

View source

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

Moves the cursor left lines lines.

View source

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

Moves the cursor right lines lines.

View source

#move_to_column(column : Int32) : self#

Moves the cursor to the provided column.

View source

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

Moves the cursor to the provided column, row position.

View source

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

Moves the cursor up lines lines.

View source

#restore_position : self#

Restores the position set via #save_position.

View source

#save_position : self#

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

View source

#show : self#

Shows the cursor.

View source