Method: CursesRenderer#draw

Defined in:
lib/delve/display/curses_renderer.rb

#draw(x, y, char, fg, bg) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/delve/display/curses_renderer.rb', line 38

def draw(x, y, char, fg, bg)
  pair = "#{fg.to_s},#{bg.to_s}"
  if !@pairs.include? pair
    @pairs.push pair
    Curses.init_pair(@pairs.index(pair)+1, @@colors[fg], @@colors[bg])
  end
  # Seem to need to flip x and y
  index = @pairs.index(pair)+1
  Curses.setpos(y, x)
  Curses.attron(Curses.color_pair(index)) do
    begin
      Curses.addstr(char)
    rescue TypeError => e
      raise 'The char was ' + char.to_s
    end
  end
end