class Omnibar::Renderer

Public Class Methods

new(state) click to toggle source
# File lib/omnibar/renderer.rb, line 3
def initialize(state)
  @state = state
end

Public Instance Methods

render(view) click to toggle source
# File lib/omnibar/renderer.rb, line 7
def render(view)
  ANSI.clear_screen
  ANSI.move_cursor(0, 0)
  print view.render.join("\e[2K \r\n")
  print view.cursor_position
end
render_diff(previous, current) click to toggle source
# File lib/omnibar/renderer.rb, line 14
def render_diff(previous, current)
  return render(current) if previous.nil?

  lines = [previous.length, current.length].max
  lines.times.each do |i|
    next if previous[i] == current[i]

    ANSI.move_cursor(i, 0)
    print "\e[2K"
    print current[i]
  end

  print current.cursor_position
end