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.

class CursorCommand < ACON::Command
  @@default_name = "cursor"

  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? = nil) #

View source

Methods#

#clear_line #

Clears the current line.

View source

#clear_line_after #

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

View source

#clear_output #

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

View source

#clear_screen #

Clears the entire screen.

View source

#current_position #

Returns the current column, row position of the cursor.

View source

#hide #

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 #

Restores the position set via #save_position.

View source

#save_position #

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

View source

#show #

Shows the cursor.

View source