Class: Przn::Controller
- Inherits:
-
Object
- Object
- Przn::Controller
- Defined in:
- lib/przn/controller.rb
Instance Method Summary collapse
-
#initialize(presentation, terminal, renderer) ⇒ Controller
constructor
A new instance of Controller.
- #run ⇒ Object
Constructor Details
#initialize(presentation, terminal, renderer) ⇒ Controller
Returns a new instance of Controller.
5 6 7 8 9 10 |
# File 'lib/przn/controller.rb', line 5 def initialize(presentation, terminal, renderer) @presentation = presentation @terminal = terminal @renderer = renderer @preload_gen = 0 end |
Instance Method Details
#run ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/przn/controller.rb', line 12 def run @terminal.enter_alt_screen @terminal.hide_cursor render_current @terminal.raw do loop do case read_key when :right, :down, 'l', 'j', ' ' @presentation. render_current when :left, :up, 'h', 'k' @presentation. render_current when 'g' @presentation. render_current when 'G' @presentation. render_current when 'q', "\x03" break end end end ensure @preload_gen += 1 @preload_thread&.join @terminal.write "\e]7772;bg-clear\a" @terminal.show_cursor @terminal.leave_alt_screen end |