module TTY::Cursor
def backward(n = nil)
- Api: - public
Parameters:
-
n
(Integer
) --
def backward(n = nil) CSI + "#{n || 1}D" end
def clear_char(n = nil)
- Api: - public
def clear_char(n = nil) CSI + "#{n}X" end
def clear_line
- Api: - public
def clear_line CSI + '2K' + column(1) end
def clear_line_after
- Api: - public
def clear_line_after CSI + '0K' end
def clear_line_before
- Api: - public
def clear_line_before CSI + '1K' end
def clear_lines(n, direction = :up)
- Api: - public
Parameters:
-
:direction
(Symbol
) -- -
n
(Integer
) --
def clear_lines(n, direction = :up) n.times.reduce([]) do |acc, i| dir = direction == :up ? up : down acc << clear_line + ((i == n - 1) ? '' : dir) end.join end
def clear_screen
- Api: - public
def clear_screen CSI + '2J' end
def clear_screen_down
- Api: - public
def clear_screen_down CSI + 'J' end
def clear_screen_up
- Api: - public
def clear_screen_up CSI + '1J' end
def column(n = nil)
- Api: - public
Parameters:
-
n
(Integer
) --
def column(n = nil) CSI + "#{n || 1}G" end
def current
- Api: - public
def current CSI + '6n' end
def down(n = nil)
- Api: - public
Parameters:
-
n
(Integer
) --
def down(n = nil) CSI + "#{(n || 1)}B" end
def forward(n = nil)
- Api: - public
Parameters:
-
n
(Integer
) --
def forward(n = nil) CSI + "#{n || 1}C" end
def hide
- Api: - public
def hide CSI + DEC_TCEM + DEC_RST end
def invisible(stream = $stdout)
- Api: - public
def invisible(stream = $stdout) stream.print(hide) yield ensure stream.print(show) end
def move(x, y)
- Api: - public
Parameters:
-
y
(Integer
) -- -
x
(Integer
) --
def move(x, y) (x < 0 ? backward(-x) : (x > 0 ? forward(x) : '')) + (y < 0 ? down(-y) : (y > 0 ? up(y) : '')) end
def move_to(row = nil, column = nil)
- Api: - public
Parameters:
-
column
(Integer
) -- -
row
(Integer
) --
def move_to(row = nil, column = nil) return CSI + 'H' if row.nil? && column.nil? CSI + "#{column + 1};#{row + 1}H" end
def next_line
- Api: - public
def next_line CSI + 'E' + column(1) end
def prev_line
- Api: - public
def prev_line CSI + 'A' + column(1) end
def restore
- Api: - public
def restore Gem.win_platform? ? CSI + 'u' : ESC + '8' end
def row(n = nil)
- Api: - public
Parameters:
-
n
(Integer
) --
def row(n = nil) CSI + "#{n || 1}d" end
def save
- Api: - public
def save Gem.win_platform? ? CSI + 's' : ESC + '7' end
def scroll_down
- Api: - public
def scroll_down ESC + 'D' end
def scroll_up
- Api: - public
def scroll_up ESC + 'M' end
def show
- Api: - public
def show CSI + DEC_TCEM + DEC_SET end
def up(n = nil)
- Api: - public
Parameters:
-
n
(Integer
) --
def up(n = nil) CSI + "#{(n || 1)}A" end