$LOAD_PATH.unshift File.expand_path("../../lib", __dir__)
require "ratatui_ruby"
class VerifyQuickstartLifecycle
def run
RatatuiRuby.init_terminal
begin
loop do
view = RatatuiRuby::Widgets::Paragraph.new(
text: "Hello, Ratatui! Press 'q' to quit.",
alignment: :center,
block: RatatuiRuby::Widgets::Block.new(
title: "My Ruby TUI App",
title_alignment: :center,
borders: [:all],
border_style: { fg: "cyan" },
style: { fg: "white" }
)
)
RatatuiRuby.draw do |frame|
frame.render_widget(view, frame.area)
end
case RatatuiRuby.poll_event
in { type: :key, code: "q" } | { type: :key, code: "c", modifiers: ["ctrl"] }
break
else
nil
end
RatatuiRuby.guard_io do
end
end
ensure
RatatuiRuby.restore_terminal
end
end
end
VerifyQuickstartLifecycle.new.run if __FILE__ == $PROGRAM_NAME