class RatatuiRuby::DSL
A wrapper class that provides a concise DSL for creating widgets and interacting with the terminal within the main_loop.
This class is yielded to the block provided to {RatatuiRuby.main_loop}. It uses metaprogramming to delegate method calls to {RatatuiRuby} module functions and to act as a factory for {RatatuiRuby} widget classes.
Features
-
**Widget Shorthand**: Provides factory methods for every widget class. Converts snake_case method calls (e.g.,
paragraph) into CamelCase class instantiations (e.g.,RatatuiRuby::Paragraph.new). -
**Method Shorthand**: Aliases module functions of {RatatuiRuby}, allowing you to call methods like
drawandpoll_eventdirectly on theDSLobject.
Example
RatatuiRuby.main_loop do |tui| # Create UI using shorthand methods view = tui.paragraph( text: "Hello World", block: tui.block(borders: [:all]) ) # Use module aliases to draw and handle events tui.draw(view) event = tui.poll_event break if event && event[:code] == "q" end