module TTY::Cursor

def backward(count = nil)

Other tags:
    Api: - public

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

def clear_line

Other tags:
    Api: - public
def clear_line
  move_start + ECMA_CSI + ECMA_CLR
end

def clear_lines(count, direction = :up)

Other tags:
    Api: - public

Parameters:
  • :direction (Symbol) --
  • count (Integer) --
def clear_lines(count, direction = :up)
  count.times.reduce('') do |acc, i|
    dir = direction == :up ? up : down
    acc << clear_line + ((i == count - 1) ? '' : dir)
  end
end

def clear_screen

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

def clear_screen_down

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

def clear_screen_up

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

def current

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

def down(count = nil)

Other tags:
    Api: - public

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

def forward(count = nil)

Other tags:
    Api: - public
def forward(count = nil)
  ECMA_CSI + "#{count || 1}C"
end

def hide

Other tags:
    Api: - public
def hide
  ECMA_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_start

Other tags:
    Api: - public
def move_start
  backward(1000)
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 ECMA_CSI + 'H' if row.nil? && column.nil?
  ECMA_CSI + "#{column + 1};#{row + 1}H"
end

def next_line

Other tags:
    Api: - public
def next_line
  ECMA_CSI + 'E'
end

def prev_line

Other tags:
    Api: - public
def prev_line
  ECMA_CSI + 'A' + ECMA_CSI + '1G'
end

def restore

Other tags:
    Api: - public
def restore
  ECMA_CSI + 'u'
end

def save

Other tags:
    Api: - public
def save
  ECMA_CSI + 's'
end

def show

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

def up(count = nil)

Other tags:
    Api: - public

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