Module: ConsoleGlitter::Cursor

Extended by:
Cursor
Included in:
Cursor
Defined in:
lib/console-glitter/cursor.rb

Instance Method Summary collapse

Instance Method Details

#back(distance = 1) ⇒ Object Also known as: left

Public: Move the cursor back for a given distance.

distance - Distance to move the cursor.

Returns a String containing the VT control code.



38
39
40
# File 'lib/console-glitter/cursor.rb', line 38

def back(distance = 1)
  ConsoleGlitter.escape("#{distance}D")
end

#column(position) ⇒ Object

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.



65
66
67
# File 'lib/console-glitter/cursor.rb', line 65

def column(position)
  ConsoleGlitter.escape("#{position}G")
end

#down(distance = 1) ⇒ Object

Public: Move the cursor down for a given distance.

distance - Distance to move the cursor.

Returns a String containing the VT control code.



19
20
21
# File 'lib/console-glitter/cursor.rb', line 19

def down(distance = 1)
  ConsoleGlitter.escape("#{distance}B")
end

#forward(distance = 1) ⇒ Object Also known as: right

Public: Move the cursor forward for a given distance.

distance - Distance to move the cursor.

Returns a String containing the VT control code.



28
29
30
# File 'lib/console-glitter/cursor.rb', line 28

def forward(distance = 1)
  ConsoleGlitter.escape("#{distance}C")
end

#hideObject

Public: Hide the cursor.

Returns a String containing the VT control code.



101
102
103
# File 'lib/console-glitter/cursor.rb', line 101

def hide
  ConsoleGlitter.escape("?25l")
end

#move(x, y) ⇒ Object

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.



76
77
78
# File 'lib/console-glitter/cursor.rb', line 76

def move(x, y)
  ConsoleGlitter.escape("#{y};#{x}H")
end

#nextline(distance = 1) ⇒ Object

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.



47
48
49
# File 'lib/console-glitter/cursor.rb', line 47

def nextline(distance = 1)
  ConsoleGlitter.escape("#{distance}E")
end

#prevline(distance = 1) ⇒ Object Also known as: previousline

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.



55
56
57
# File 'lib/console-glitter/cursor.rb', line 55

def prevline(distance = 1)
  ConsoleGlitter.escape("#{distance}F")
end

#restoreObject

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.



94
95
96
# File 'lib/console-glitter/cursor.rb', line 94

def restore
  ConsoleGlitter.escape("u")
end

#saveObject

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

Returns a String containing the VT control code.



84
85
86
# File 'lib/console-glitter/cursor.rb', line 84

def save
  ConsoleGlitter.escape("s")
end

#showObject

Public: Show the cursor.

Returns a String containing the VT control code.



108
109
110
# File 'lib/console-glitter/cursor.rb', line 108

def show
  ConsoleGlitter.escape("?25h")
end

#up(distance = 1) ⇒ Object

Public: Move the cursor up for a given distance.

distance - Distance to move the cursor.

Returns a String containing the VT control code.



10
11
12
# File 'lib/console-glitter/cursor.rb', line 10

def up(distance = 1)
  ConsoleGlitter.escape("#{distance}A")
end