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

Instance Method Details

#draw(tree = nil, &block) ⇒ Object

Draws the given UI node tree to the terminal.

See Also:



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.

Returns:



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.

See Also:

  • RatatuiRuby.insert_before


52
53
54
# File 'lib/ratatui_ruby/tui/core.rb', line 52

def insert_before(height, widget = nil, &)
  RatatuiRuby.insert_before(height, widget, &)
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_areaObject

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_areaObject

Gets the Rect of the viewport



62
63
64
# File 'lib/ratatui_ruby/tui/core.rb', line 62

def viewport_area
  RatatuiRuby.viewport_area
end