struct Athena::Console::Cursor

Overview

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

Defined in:

cursor.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(output : ACON::Output::Interface, input : IO = STDIN) #

[View source]

Instance Method Detail

def clear_line : self #

Clears the current line.


[View source]
def clear_line_after : self #

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


[View source]
def clear_output : self #

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


[View source]
def clear_screen : self #

Clears the entire screen.


[View source]
def current_position : Tuple(Int32, Int32) #

Returns the current column, row position of the cursor.


[View source]
def hide : self #

Hides the cursor.


[View source]
def move_down(lines : Int32 = 1) : self #

Moves the cursor down lines lines.


[View source]
def move_left(lines : Int32 = 1) : self #

Moves the cursor left lines lines.


[View source]
def move_right(lines : Int32 = 1) : self #

Moves the cursor right lines lines.


[View source]
def move_to_column(column : Int32) : self #

Moves the cursor to the provided column.


[View source]
def move_to_position(column : Int32, row : Int32) : self #

Moves the cursor to the provided column, row position.


[View source]
def move_up(lines : Int32 = 1) : self #

Moves the cursor up lines lines.


[View source]
def restore_position : self #

Restores the position set via #save_position.


[View source]
def save_position : self #

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


[View source]
def show : self #

Shows the cursor.


[View source]