class RatatuiRuby::Terminal
Terminal object for managing terminal lifecycle and rendering.
Instance-based API aligned with upstream Ratatui Terminal struct.
Example
terminal = RatatuiRuby::Terminal.new
terminal.draw { |frame| ... }
terminal.restore
Terminal configuration and viewport settings.
Your app needs to choose how it occupies the terminal. Fullscreen apps take over the whole screen and clear on exit. Inline apps run in a fixed region and persist in scrollback. Configuring this manually is error-prone.
This module handles the choice. It defines viewport modes and their parameters.
@see Terminal::Viewport
Attributes
:attr_reader: terminal_id Unique identifier for this terminal instance in Rust (Integer).
Public Class Methods
Source
# File lib/ratatui_ruby/terminal.rb, line 38 def initialize(viewport: :fullscreen, height: nil) @viewport = resolve_viewport(viewport, height) # Call Rust FFI to create instance and get ID # For now, only test backend is supported (real crossterm coming later) @terminal_id = self.class._init_test_terminal_instance( 80, # default width for test 24, # default height for test @viewport.type.to_s, @viewport.height ) end
Public Instance Methods
Source
# File lib/ratatui_ruby/terminal.rb, line 53 def size self.class._get_terminal_size_instance(@terminal_id) end
Returns the terminal size as a Layout::Rect Rust constructs the Rect object directly (not a hash!)