module TTY::Cursor

def backward(n = nil)

Other tags:
    Api: - public

Parameters:
  • n (Integer) --
def backward(n = nil)
  CSI + "#{n || 1}D"
end

def clear_char(n = nil)

Other tags:
    Api: - public
def clear_char(n = nil)
  CSI + "#{n}X"
end

def clear_line

Other tags:
    Api: - public
def clear_line
  CSI + '2K' + column(1)
end

def clear_line_after

Other tags:
    Api: - public
def clear_line_after
  CSI + '0K'
end

def clear_line_before

Other tags:
    Api: - public
def clear_line_before
  CSI + '1K'
end

def clear_lines(n, direction = :up)

Other tags:
    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

Other tags:
    Api: - public
def clear_screen
  CSI + '2J'
end

def clear_screen_down

Other tags:
    Api: - public
def clear_screen_down
  CSI + 'J'
end

def clear_screen_up

Other tags:
    Api: - public
def clear_screen_up
  CSI + '1J'
end

def column(n = nil)

Other tags:
    Api: - public

Parameters:
  • n (Integer) --
def column(n = nil)
  CSI + "#{n || 1}G"
end

def current

Other tags:
    Api: - public
def current
  CSI + '6n'
end

def down(n = nil)

Other tags:
    Api: - public

Parameters:
  • n (Integer) --
def down(n = nil)
  CSI + "#{(n || 1)}B"
end

def forward(n = nil)

Other tags:
    Api: - public

Parameters:
  • n (Integer) --
def forward(n = nil)
  CSI + "#{n || 1}C"
end

def hide

Other tags:
    Api: - public
def hide
  CSI + DEC_TCEM + DEC_RST
end

def invisible(stream = $stdout)

Other tags:
    Api: - public
def invisible(stream = $stdout)
  stream.print(hide)
  yield
ensure
  stream.print(show)
end

def move(x, y)

Other tags:
    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)

Other tags:
    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

Other tags:
    Api: - public
def next_line
  CSI + 'E' + column(1)
end

def prev_line

Other tags:
    Api: - public
def prev_line
  CSI + 'A' + column(1)
end

def restore

Other tags:
    Api: - public
def restore
  Gem.win_platform? ? CSI + 'u' : ESC + '8'
end

def row(n = nil)

Other tags:
    Api: - public

Parameters:
  • n (Integer) --
def row(n = nil)
  CSI + "#{n || 1}d"
end

def save

Other tags:
    Api: - public
def save
  Gem.win_platform? ? CSI + 's' : ESC + '7'
end

def scroll_down

Other tags:
    Api: - public
def scroll_down
  ESC + 'D'
end

def scroll_up

Other tags:
    Api: - public
def scroll_up
  ESC + 'M'
end

def show

Other tags:
    Api: - public
def show
  CSI + DEC_TCEM + DEC_SET
end

def up(n = nil)

Other tags:
    Api: - public

Parameters:
  • n (Integer) --
def up(n = nil)
  CSI + "#{(n || 1)}A"
end