Class: Reac::CursesView
Constant Summary
Constants inherited from View
Instance Method Summary collapse
-
#initialize(&block) ⇒ CursesView
constructor
A new instance of CursesView.
- #main_loop(now) ⇒ Object
- #put(y, x, reac) ⇒ Object
Methods inherited from View
Constructor Details
#initialize(&block) ⇒ CursesView
Returns a new instance of CursesView.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/reac/view/curses.rb', line 5 def initialize(&block) @top_window = Curses.init_screen @x = @y = 0 #Curses.noecho #Curses.nocbreak # disable buffering keyboard input Curses.clear Curses.refresh @reacs = [] #@top_window = Curses::Window.new(Curses.cols-2, Curses.lines-1, 0, 0) #y, x = 0 instance_eval(&block) if block end |
Instance Method Details
#main_loop(now) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/reac/view/curses.rb', line 22 def main_loop(now) @top_window.clear @reacs.each do |y, x, reac| yval = Reac.value(y, now) xval = Reac.value(x, now) @top_window.setpos(yval, xval) @top_window << Reac.value(reac, now).to_s @top_window.refresh end end |
#put(y, x, reac) ⇒ Object
18 19 20 |
# File 'lib/reac/view/curses.rb', line 18 def put(y, x, reac) @reacs << [y, x, reac] end |