module ConsoleGlitter::Cursor
Public Instance Methods
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
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
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
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
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
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
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
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
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
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
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
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