module Opal

Overview

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).

Defined in:

opal.cr
opal/animation/animator.cr
opal/asciicast.cr
opal/asciicast/asciinema.cr
opal/asciicast/driver.cr
opal/asciicast/event.cr
opal/asciicast/header.cr
opal/asciicast/playback_engine.cr
opal/asciicast/reader.cr
opal/asciicast/screen_recorder.cr
opal/asciicast/uploader.cr
opal/asciicast/vcr.cr
opal/asciicast/writer.cr
opal/async/worker.cr
opal/cli.cr
opal/cli/app.cr
opal/cli/argument.cr
opal/cli/command.cr
opal/cli/completion.cr
opal/cli/context.cr
opal/cli/help.cr
opal/cli/main.cr
opal/cli/option.cr
opal/cli/parser.cr
opal/cli/tools/box_tool.cr
opal/cli/tools/chart_tool.cr
opal/cli/tools/choose_tool.cr
opal/cli/tools/color_picker_tool.cr
opal/cli/tools/confirm_tool.cr
opal/cli/tools/gauge_tool.cr
opal/cli/tools/input_reader.cr
opal/cli/tools/markdown_tool.cr
opal/cli/tools/misc_tools.cr
opal/cli/tools/palette_tool.cr
opal/cli/tools/remap_tool.cr
opal/cli/tools/table_tool.cr
opal/cli/tools/target_tool.cr
opal/cli/tools/tree_tool.cr
opal/clipboard.cr
opal/form.cr
opal/form/field.cr
opal/form/form.cr
opal/form/validator.cr
opal/game.cr
opal/game/loop.cr
opal/game/pong.cr
opal/gamepad.cr
opal/gamepad/focus_mapper.cr
opal/gamepad/mock_dsl.cr
opal/gamepad/types.cr
opal/gamepad/virtual_cursor.cr
opal/gamepad/xinput.cr
opal/graphics/grid_style.cr
opal/graphics/primitives_2d.cr
opal/graphics/primitives_3d.cr
opal/html.cr
opal/html/browser.cr
opal/html/parser.cr
opal/image.cr
opal/image/pixel_buffer.cr
opal/image/protocols.cr
opal/input.cr
opal/input/autocomplete.cr
opal/input/core/remap_model.cr
opal/input/dsl/remap_builder.cr
opal/input/fuzzy.cr
opal/input/key_map.cr
opal/input/mouse_map.cr
opal/input/text_input.cr
opal/mermaid.cr
opal/mermaid/ast.cr
opal/mermaid/parser.cr
opal/mermaid/renderer.cr
opal/mermaid/viewer.cr
opal/prompt.cr
opal/prompt/ask.cr
opal/prompt/confirm.cr
opal/prompt/multi_select.cr
opal/prompt/progress.cr
opal/prompt/select.cr
opal/prompt/spinner.cr
opal/shader.cr
opal/shader/context.cr
opal/shader/fast_math.cr
opal/shader/pass.cr
opal/shader/pipeline.cr
opal/shader/presets.cr
opal/style.cr
opal/style/animation.cr
opal/style/border.cr
opal/style/color.cr
opal/style/color_spaces.cr
opal/style/glyph_set.cr
opal/style/glyphs.cr
opal/style/layout.cr
opal/style/palette_formats.cr
opal/style/palette_model.cr
opal/style/style.cr
opal/style/theme.cr
opal/style/theme_store.cr
opal/style/visual_width.cr
opal/tea.cr
opal/tea/cmd.cr
opal/tea/model.cr
opal/tea/msg.cr
opal/tea/program.cr
opal/terminal.cr
opal/terminal/ansi_parser.cr
opal/terminal/ascii.cr
opal/terminal/driver.cr
opal/terminal/info.cr
opal/terminal/mock.cr
opal/terminal/osc.cr
opal/terminal/posix.cr
opal/terminal/raw_mode.cr
opal/terminal/screen.cr
opal/terminal/windows.cr
opal/testing.cr
opal/testing/buffer_assertions.cr
opal/testing/frame_recorder.cr
opal/testing/pilot.cr
opal/testing/teatest.cr
opal/ui.cr
opal/ui/buffer.cr
opal/ui/cell.cr
opal/ui/components/ascii_image.cr
opal/ui/components/badge.cr
opal/ui/components/barchart.cr
opal/ui/components/binary_metrics.cr
opal/ui/components/box.cr
opal/ui/components/button.cr
opal/ui/components/canvas_2d.cr
opal/ui/components/character_grid.cr
opal/ui/components/checkbox.cr
opal/ui/components/code_view.cr
opal/ui/components/collapsible.cr
opal/ui/components/color_picker.cr
opal/ui/components/color_picker_3d.cr
opal/ui/components/command_palette.cr
opal/ui/components/content_switcher.cr
opal/ui/components/curve_editor.cr
opal/ui/components/digits.cr
opal/ui/components/dropdown.cr
opal/ui/components/equation_viewer.cr
opal/ui/components/file_dialog.cr
opal/ui/components/filter_list.cr
opal/ui/components/footer.cr
opal/ui/components/gauge.cr
opal/ui/components/group.cr
opal/ui/components/header.cr
opal/ui/components/hex_viewer.cr
opal/ui/components/input_remapper.cr
opal/ui/components/line_graph.cr
opal/ui/components/link.cr
opal/ui/components/loading_indicator.cr
opal/ui/components/mask.cr
opal/ui/components/mesh_3d.cr
opal/ui/components/meter.cr
opal/ui/components/modal.cr
opal/ui/components/palette.cr
opal/ui/components/pie_chart.cr
opal/ui/components/placeholder.cr
opal/ui/components/radio_set.cr
opal/ui/components/rich_log.cr
opal/ui/components/rule.cr
opal/ui/components/scissor.cr
opal/ui/components/scrollbar.cr
opal/ui/components/slider.cr
opal/ui/components/sparkline.cr
opal/ui/components/split_view.cr
opal/ui/components/stack.cr
opal/ui/components/switch.cr
opal/ui/components/table.cr
opal/ui/components/tabs.cr
opal/ui/components/target_selector_2d.cr
opal/ui/components/text.cr
opal/ui/components/toast.cr
opal/ui/components/tree.cr
opal/ui/components/viewport.cr
opal/ui/components/window.cr
opal/ui/control.cr
opal/ui/diff_renderer.cr
opal/ui/dsl.cr
opal/ui/dsl_methods.cr
opal/ui/element.cr
opal/ui/engine.cr
opal/ui/input_hookable.cr
opal/ui/layer.cr
opal/ui/layer_stack.cr
opal/ui/layouts/dock.cr
opal/ui/layouts/grid.cr
opal/ui/markdown/renderer.cr
opal/ui/mask.cr
opal/ui/query.cr
opal/ui/rect.cr
opal/ui/screen.cr
opal/ui/screen_stack.cr
opal/ui/themable.cr
opal/version.cr

Constant Summary

VERSION = "0.1.65"

Class Method Summary

Class Method Detail

def self.ask(question : String, default : String | Nil = nil, required : Bool = false) : String #

Top-level Opal shortcuts


[View source]
def self.autocomplete(&block : Input::Autocomplete -> Nil) : Input::Autocomplete #

Convenience DSL to define an Autocomplete engine


[View source]
def self.cli(name : String, version : String = "0.1.0", &block : CLI::App -> Nil) : CLI::App #

Convenience DSL to define and configure a CLI application.


[View source]
def self.clipboard : Clipboard.class #

Access to the universal clipboard subsystem.


[View source]
def self.confirm(question : String, default : Bool = true) : Bool #

[View source]
def self.copy_to_clipboard(text : String, io : IO = STDOUT) : Bool #

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


[View source]
def self.discussion_link(repo : String, number : Int32 | String, label : String | Nil = nil, id : String | Nil = nil) : String #

Creates an OSC 8 hyperlink for a GitHub Discussion (Discussion #XX).


[View source]
def self.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


[View source]
def self.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.


[View source]
def self.form(title : String = "Form", &block : FormModule::Form -> Nil) : Hash(String, FormValue) | Nil #

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


[View source]
def self.github_link(repo : String, kind : Symbol | String, number : Int32 | String, label : String | Nil = nil, id : String | Nil = nil) : String #

Creates an OSC 8 hyperlink for a GitHub repository, RFC/Discussion, Issue, or PR.


[View source]
def self.hyperlink(text : String, url : String, id : String | Nil = nil) : String #

Creates a clickable OSC 8 hyperlink for modern terminals.


[View source]
def self.input_map(profile_name : String = "Default Controls", max_slots : Int32 = 2, conflict_policy : Input::Core::ConflictPolicy | Symbol | String = :allow, gamepad_style : Input::Core::GamepadStyle | Symbol | String = :dualshock, &) : Input::Core::InputRemapModel #

Top-level declarative helper for building an InputRemapModel


[View source]
def self.issue_link(repo : String, number : Int32 | String, label : String | Nil = nil, id : String | Nil = nil) : String #

Creates an OSC 8 hyperlink for a GitHub Issue (Issue #XX).


[View source]
def self.link(url : String, label : String | Nil = nil, id : String | Nil = nil) : String #

Declarative link(url, label) OSC 8 terminal hyperlink helper. If label is omitted, defaults to url. Also supports (label, url) if the second argument is a URI.


[View source]
def self.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.


[View source]
def self.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


[View source]
def self.multi_select(question : String, options : Array(String), default_indices : Array(Int32) = [] of Int32) : Array(String) #

[View source]
def self.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


[View source]
def self.on_key(&block : Input::KeyMap -> Nil) : Input::KeyMap #

Convenience DSL builder for key bindings


[View source]
def self.on_mouse(&block : Input::MouseMap -> Nil) : Input::MouseMap #

Convenience DSL builder for mouse routing


[View source]
def self.open_file_dialog(initial_path : String = ".", filters : Array(String) = [] of String, driver : Terminal::Driver | Nil = nil) : String | Nil #

High-level helper for opening files


[View source]
def self.open_folder_dialog(initial_path : String = ".", driver : Terminal::Driver | Nil = nil) : String | Nil #

High-level helper for choosing folders


[View source]
def self.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.


[View source]
def self.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


[View source]
def self.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.


[View source]
def self.pr_link(repo : String, number : Int32 | String, label : String | Nil = nil, id : String | Nil = nil) : String #

Creates an OSC 8 hyperlink for a GitHub Pull Request (PR #XX).


[View source]
def self.print_markdown(text : String, io : IO = STDOUT, width : Int32 | Nil = nil) : Nil #

Prints Markdown text directly to IO stream.


[View source]
def self.progress(total : Int32, bar_width : Int32 = 30, color : Color | Symbol | String = :cyan, title : String | Nil = nil, &block : Prompt::ProgressBar -> Nil) : Nil #

[View source]
def self.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


[View source]
def self.prompt_autocomplete(prompt : String = "> ", candidates : Array(String) = [] of String, driver : Terminal::Driver | Nil = nil) : String #

[View source]
def self.remap_inputs(remapper : UI::InputRemapper, driver : Terminal::Driver | Nil = nil, output : IO | Nil = nil) : Input::Core::InputRemapModel | Nil #

High-level interactive input remapper runner for CLI or modal invocation.


[View source]
def self.render_markdown(text : String, width : Int32 = 80) : String #

Renders Markdown text directly to an ANSI formatted string.


[View source]
def self.render_ui(width : Int32 = 80, height : Int32 = 24, with_ansi : Bool = false, &) : String #

Convenience shortcut to render a declarative UI tree


[View source]
def self.render_ui_ansi(width : Int32 = 80, height : Int32 = 24, &) : String #

Convenience shortcut to render a declarative UI tree with ANSI colors and OSC 8 hyperlinks


[View source]
def self.rfc_link(repo : String, number : Int32 | String, label : String | Nil = nil, id : String | Nil = nil) : String #

Creates an OSC 8 hyperlink for a GitHub RFC Discussion (RFC #XX).


[View source]
def self.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


[View source]
def self.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


[View source]
def self.select(question : String, options : Array(String), default_index : Int32 = 0) : String #

[View source]
def self.shader_pipeline(&block : Shader::Pipeline -> Nil) : Shader::Pipeline #

Shortcut to construct a shader pipeline.


[View source]
def self.spinner(text : String, &block : Prompt::Spinner -> T) : T forall T #

[View source]
def self.style : Style #

Convenience helper to create a new Style instance


[View source]
def self.terminal : Terminal::Info #

Returns terminal information object


[View source]
def self.terminal(&block : Terminal::Info -> T) : T forall T #

Executes a block with the terminal information DSL


[View source]
def self.theme(name : String, &block : ThemeBuilder -> Nil) : Theme #

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


[View source]
def self.theme : Theme #

Returns the current active Theme


[View source]
def self.theme=(theme : Theme | Symbol | String) : Theme #

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


[View source]
def self.theme_store : ThemeStore.class #

Returns the global ThemeStore registry


[View source]