Class: FunCi::Tui::AdminTui
- Inherits:
-
Object
- Object
- FunCi::Tui::AdminTui
- Defined in:
- lib/fun_ci/tui/admin_tui.rb
Constant Summary collapse
- FAST_REFRESH =
0.1
- SLOW_REFRESH =
5.0
Instance Method Summary collapse
- #confirmation_run ⇒ Object
- #confirming? ⇒ Boolean
- #handle_key(key) ⇒ Object
-
#initialize(db:, output: $stdout, input: $stdin, width: 80, width_provider: nil, height_provider: nil, page_size: nil, animation_renderer: nil) ⇒ AdminTui
constructor
A new instance of AdminTui.
- #render_once ⇒ Object
- #resize(new_width) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(db:, output: $stdout, input: $stdin, width: 80, width_provider: nil, height_provider: nil, page_size: nil, animation_renderer: nil) ⇒ AdminTui
Returns a new instance of AdminTui.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/fun_ci/tui/admin_tui.rb', line 17 def initialize(db:, output: $stdout, input: $stdin, width: 80, width_provider: nil, height_provider: nil, page_size: nil, animation_renderer: nil) @board_data = BoardData.new(db, page_size: page_size) @terminal_input = TerminalInput.new(input: input, width_provider: width_provider) @key_handler = KeyHandler.new(board_data: @board_data) @renderer = BoardRenderer.new( screen: Screen.new(output: output, width: width), spinner: Spinner.new, animation_renderer: animation_renderer, height_provider: height_provider ) end |
Instance Method Details
#confirmation_run ⇒ Object
66 67 68 |
# File 'lib/fun_ci/tui/admin_tui.rb', line 66 def confirmation_run @key_handler.confirmation_run end |
#confirming? ⇒ Boolean
62 63 64 |
# File 'lib/fun_ci/tui/admin_tui.rb', line 62 def confirming? @key_handler.confirming? end |
#handle_key(key) ⇒ Object
70 71 72 |
# File 'lib/fun_ci/tui/admin_tui.rb', line 70 def handle_key(key) @key_handler.handle_key(key) end |
#render_once ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/fun_ci/tui/admin_tui.rb', line 31 def render_once update_width_from_provider @renderer.render( runs: @board_data.runs, streak: @board_data.streak, cursor_index: @key_handler.cursor_index, confirming: @key_handler.confirming? ) end |
#resize(new_width) ⇒ Object
58 59 60 |
# File 'lib/fun_ci/tui/admin_tui.rb', line 58 def resize(new_width) @renderer.resize(new_width) end |
#run ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/fun_ci/tui/admin_tui.rb', line 41 def run @renderer.clear begin @terminal_input.setup_raw_mode @terminal_input.setup_signal_trap loop do @renderer.begin_frame render_once key = @terminal_input.read_key_with_timeout(refresh_interval) break if key && @key_handler.handle_key(key) == :quit end ensure @terminal_input.restore_terminal end end |