module ConsoleGlitter::Cursor

Public Instance Methods

back(distance = 1) click to toggle source

Public: Move the cursor back for a given distance.

distance - Distance to move the cursor.

Returns a String containing the VT control code.

# File lib/console-glitter/cursor.rb, line 38
def back(distance = 1)
  ConsoleGlitter.escape("#{distance}D")
end
Also aliased as: left
column(position) click to toggle source

Public: Move the absolute horizontal position specified.

position - Number of the column to which the cursor should be moved.

Returns a String containing the VT control code.

# File lib/console-glitter/cursor.rb, line 65
def column(position)
  ConsoleGlitter.escape("#{position}G")
end
down(distance = 1) click to toggle source

Public: Move the cursor down for a given distance.

distance - Distance to move the cursor.

Returns a String containing the VT control code.

# File lib/console-glitter/cursor.rb, line 19
def down(distance = 1)
  ConsoleGlitter.escape("#{distance}B")
end
forward(distance = 1) click to toggle source

Public: Move the cursor forward for a given distance.

distance - Distance to move the cursor.

Returns a String containing the VT control code.

# File lib/console-glitter/cursor.rb, line 28
def forward(distance = 1)
  ConsoleGlitter.escape("#{distance}C")
end
Also aliased as: right
hide() click to toggle source

Public: Hide the cursor.

Returns a String containing the VT control code.

# File lib/console-glitter/cursor.rb, line 101
def hide
  ConsoleGlitter.escape("?25l")
end
left(distance = 1)
Alias for: back
move(x, y) click to toggle source

Public: Move the cursor to the position specified. The top left position is 1,1.

x - Column (x-position) to which the cursor should be moved. x - Row (y-position) to which the cursor should be moved.

Returns a String containing the VT control code.

# File lib/console-glitter/cursor.rb, line 76
def move(x, y)
  ConsoleGlitter.escape("#{y};#{x}H")
end
nextline(distance = 1) click to toggle source

Public: Move the cursor to the next line, returning the cursor to the beginning of the line.

Returns a String containing the VT control code.

# File lib/console-glitter/cursor.rb, line 47
def nextline(distance = 1)
  ConsoleGlitter.escape("#{distance}E")
end
previousline(distance = 1)
Alias for: prevline
prevline(distance = 1) click to toggle source

Public: Move the cursor to the previous line, returning the cursor to the beginning of the line.

Returns a String containing the VT control code.

# File lib/console-glitter/cursor.rb, line 55
def prevline(distance = 1)
  ConsoleGlitter.escape("#{distance}F")
end
Also aliased as: previousline
restore() click to toggle source

Public: Move the cursor to a previously saved position.

Note: If the cursor’s position was never previously saved, it will default to 1,1.

Returns a String containing the VT control code.

# File lib/console-glitter/cursor.rb, line 94
def restore
  ConsoleGlitter.escape("u")
end
right(distance = 1)
Alias for: forward
save() click to toggle source

Public: Save the cursor’s current position, replacing any previously saved position.

Returns a String containing the VT control code.

# File lib/console-glitter/cursor.rb, line 84
def save
  ConsoleGlitter.escape("s")
end
show() click to toggle source

Public: Show the cursor.

Returns a String containing the VT control code.

# File lib/console-glitter/cursor.rb, line 108
def show
  ConsoleGlitter.escape("?25h")
end
up(distance = 1) click to toggle source

Public: Move the cursor up for a given distance.

distance - Distance to move the cursor.

Returns a String containing the VT control code.

# File lib/console-glitter/cursor.rb, line 10
def up(distance = 1)
  ConsoleGlitter.escape("#{distance}A")
end