module

Opal

Opal: Next-generation TUI and CLI DSL framework for Crystal. Unifies The Elm Architecture (Bubbletea), Declarative Layout (Ink), and Low-Level Double-Buffered Terminal Diffing (Blessed).

Constants

VERSION = "0.1.59"

Class methods

ask(question : String, default : String | Nil = nil, required : Bool = false) : String

Top-level Opal shortcuts

Source
autocomplete

Convenience DSL to define an Autocomplete engine

Source
cli(name : String, version : String = "0.1.0", &block : CLI::App -> Nil) : CLI::App

Convenience DSL to define and configure a CLI application.

Source
clipboard

Access to the universal clipboard subsystem.

Source
confirm(question : String, default : Bool = true) : Bool
Source
copy_to_clipboard(text : String, io : IO = STDOUT) : Bool

Copies text to the system clipboard using OSC 52 and native OS tools.

Source
file_dialog(initial_path : String = ".", mode : Symbol = :open_file, show_hidden : Bool = false, filters : Array(String) = [] of String, preview : Proc(String, String) | Nil = nil, driver : Terminal::Driver | Nil = nil) : String | Nil

High-level interactive file dialog helper

Source
filter(items : Array(String), title : String = "Filter Items", preview : Proc(String, String) | Nil = nil, driver : Terminal::Driver | Nil = nil) : String | Nil

High-level interactive filter prompt helper.

Source
form(title : String = "Form", &block : FormModule::Form -> Nil) : Hash(String, FormValue) | Nil

High-level entry point to declare and run an interactive form.

Source
manage_palette(palette : UI::Palette, driver : Terminal::Driver | Nil = nil, output : IO | Nil = nil) : PaletteModel | Nil

High-level interactive palette runner for CLI or embedding.

Source
mock_gamepad(driver : Input::Gamepad::Driver = Input::Gamepad::Driver.new, &block : Input::Gamepad::MockDSL -> Nil) : Input::Gamepad::Driver

Top-level helper for declarative mock gamepad testing

Source
multi_select(question : String, options : Array(String), default_indices : Array(Int32) = [] of Int32) : Array(String)
Source
new_file_dialog(initial_path : String = ".", is_folder : Bool = false, driver : Terminal::Driver | Nil = nil) : String | Nil

High-level helper for creating new files or folders

Source
on_key

Convenience DSL builder for key bindings

Source
on_mouse

Convenience DSL builder for mouse routing

Source
open_file_dialog(initial_path : String = ".", filters : Array(String) = [] of String, driver : Terminal::Driver | Nil = nil) : String | Nil

High-level helper for opening files

Source
open_folder_dialog(initial_path : String = ".", driver : Terminal::Driver | Nil = nil) : String | Nil

High-level helper for choosing folders

Source
pick_color(initial : Color = Color.hex("#89B4FA"), driver : Terminal::Driver | Nil = nil, mode : UI::ColorMode = UI::ColorMode::RGB, layout : UI::ColorPickerLayout = UI::ColorPickerLayout::Studio, show_harmonies : Bool = true, show_select_button : Bool = true, output : IO | Nil = nil) : Color | Nil

High-level interactive color picker helper.

Source
pick_color_3d(initial_shape : UI::ColorPickerShape = UI::ColorPickerShape::Cube3D, auto_rotate : Bool = false, driver : Terminal::Driver | Nil = nil) : Color | Nil

High-level standalone runner for 3D rotatable color picker

Source
pixel_buffer(width : Int32, height : Int32, default_color : Color = Color.none) : Image::PixelBuffer

Creates a new PixelBuffer with specified width, height, and optional default color.

Source
progress(total : Int32, bar_width : Int32 = 30, color : Color | Symbol | String = :cyan, title : String | Nil = nil, &block : Prompt::ProgressBar -> Nil) : Nil
Source
prompt_autocomplete(prompt : String = "> ", candidates : Array(String) = [] of String, driver : Terminal::Driver | Nil = nil, &block : Input::Autocomplete -> Nil) : String

Convenience DSL to prompt with tab autocomplete and ghost text

Source
prompt_autocomplete(prompt : String = "> ", candidates : Array(String) = [] of String, driver : Terminal::Driver | Nil = nil) : String
Source
render_markdown(text : String, width : Int32 = 80) : String

Renders Markdown text directly to an ANSI formatted string.

Source
render_ui(width : Int32 = 80, height : Int32 = 24, &) : String

Convenience shortcut to render a declarative UI tree

Source
run_tea(model : TEA::Model, driver : Terminal::Driver | Nil = nil, alt_screen : Bool = true, diff_render : Bool = true, mouse_enabled : Bool = true, record_cast : String | Nil = nil, cast_title : String = "Opal Session") : TEA::Model

Overload run_tea with record_cast support

Source
save_file_dialog(initial_path : String = ".", default_name : String = "untitled.txt", filters : Array(String) = [] of String, driver : Terminal::Driver | Nil = nil) : String | Nil

High-level helper for saving files

Source
select(question : String, options : Array(String), default_index : Int32 = 0) : String
Source
shader_pipeline

Shortcut to construct a shader pipeline.

Source
spinner(text : String, &block : Prompt::Spinner -> T) : T forall T
Source
style

Convenience helper to create a new Style instance

Source
terminal

Returns terminal information object

Source
terminal

Executes a block with the terminal information DSL

Source
theme(name : String, &block : ThemeBuilder -> Nil) : Theme

Top-level DSL helper: Opal.theme "my_theme" do |t| ... end

Source
theme

Returns the current active Theme

Source
theme=(theme : Theme | Symbol | String) : Theme

Sets the current active Theme by symbol, string, or Theme instance

Source
theme_store

Returns the global ThemeStore registry

Source

Nested types