Module: RatatuiRuby::TUI::Core
- Included in:
- RatatuiRuby::TUI
- Defined in:
- lib/ratatui_ruby/tui/core.rb
Overview
Core terminal methods delegated to RatatuiRuby module.
These are the fundamental operations for the render loop: drawing UI, polling events, and inspecting the buffer.
Instance Method Summary collapse
-
#draw(tree = nil, &block) ⇒ Object
Draws the given UI node tree to the terminal.
-
#draw_cell(x, y, cell) ⇒ Draw::CellCmd
Creates a Draw::CellCmd for placing a cell at coordinates.
-
#get_cell_at(x, y) ⇒ Object
Inspects the terminal buffer at specific coordinates.
-
#insert_before(height, widget = nil) ⇒ Object
Inserts content above an inline viewport.
-
#poll_event(timeout: 0.016) ⇒ Object
Checks for user input.
-
#terminal_area ⇒ Object
Gets the Rect of the entire terminal, regardless of viewport.
-
#viewport_area ⇒ Object
Gets the Rect of the viewport.
Instance Method Details
#draw(tree = nil, &block) ⇒ Object
Draws the given UI node tree to the terminal.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ratatui_ruby/tui/core.rb', line 17 def draw(tree = nil, &block) if tree && block raise ArgumentError, "Cannot provide both a tree and a block to draw" end unless tree || block raise ArgumentError, "Must provide either a tree or a block to draw" end if block RatatuiRuby.draw(&block) else RatatuiRuby.draw(tree) end end |
#draw_cell(x, y, cell) ⇒ Draw::CellCmd
Creates a Draw::CellCmd for placing a cell at coordinates.
46 47 48 |
# File 'lib/ratatui_ruby/tui/core.rb', line 46 def draw_cell(x, y, cell) Draw.cell(x, y, cell) end |
#get_cell_at(x, y) ⇒ Object
Inspects the terminal buffer at specific coordinates.
40 41 42 |
# File 'lib/ratatui_ruby/tui/core.rb', line 40 def get_cell_at(x, y) RatatuiRuby.get_cell_at(x, y) end |
#insert_before(height, widget = nil) ⇒ Object
Inserts content above an inline viewport.
52 53 54 |
# File 'lib/ratatui_ruby/tui/core.rb', line 52 def insert_before(height, = nil, &) RatatuiRuby.insert_before(height, , &) end |
#poll_event(timeout: 0.016) ⇒ Object
Checks for user input.
34 35 36 |
# File 'lib/ratatui_ruby/tui/core.rb', line 34 def poll_event(timeout: 0.016) RatatuiRuby.poll_event(timeout:) end |
#terminal_area ⇒ Object
Gets the Rect of the entire terminal, regardless of viewport
57 58 59 |
# File 'lib/ratatui_ruby/tui/core.rb', line 57 def terminal_area RatatuiRuby.terminal_area end |
#viewport_area ⇒ Object
Gets the Rect of the viewport
62 63 64 |
# File 'lib/ratatui_ruby/tui/core.rb', line 62 def RatatuiRuby. end |