Website Managed Loop Verification
Verifies the full-screen managed loop example on the RatatuiRuby website.
This example exists as a documentation regression test. It ensures the websiteโs โBuild Something Realโ managed loop demo remains functional.
Usage
RatatuiRuby.run do |tui| loop do tui.draw do |frame| frame.render_widget( tui.paragraph( text: "Hello, RatatuiRuby!", alignment: :center, block: tui.block( title: "My App", titles: [{ content: "q: Quit", position: :bottom, alignment: :right }], borders: [:all], border_style: { fg: "cyan" } ) ), frame.area ) end case tui.poll_event in { type: :key, code: "q" } | { type: :key, code: "c", modifiers: ["ctrl"] } break else nil end end end
Features Demonstrated
-
Full-screen mode: Alternate screen with automatic terminal restoration
-
Managed lifecycle:
RatatuiRuby.runhandles setup/teardown -
Block with titles: Top title and bottom key hints
-
Keyboard handling:
qandCtrl+Cto quit -
Pattern matching: Ruby 3.x pattern matching for event handling