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/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/option.cr
opal/cli/parser.cr
opal/form.cr
opal/form/field.cr
opal/form/form.cr
opal/form/validator.cr
opal/input.cr
opal/input/autocomplete.cr
opal/input/fuzzy.cr
opal/input/key_map.cr
opal/input/mouse_map.cr
opal/input/text_input.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/style.cr
opal/style/animation.cr
opal/style/border.cr
opal/style/color.cr
opal/style/layout.cr
opal/style/style.cr
opal/style/theme.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/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/ui.cr
opal/ui/buffer.cr
opal/ui/cell.cr
opal/ui/components/badge.cr
opal/ui/components/barchart.cr
opal/ui/components/box.cr
opal/ui/components/code_view.cr
opal/ui/components/command_palette.cr
opal/ui/components/filter_list.cr
opal/ui/components/gauge.cr
opal/ui/components/hex_viewer.cr
opal/ui/components/modal.cr
opal/ui/components/rule.cr
opal/ui/components/sparkline.cr
opal/ui/components/split_view.cr
opal/ui/components/stack.cr
opal/ui/components/table.cr
opal/ui/components/tabs.cr
opal/ui/components/text.cr
opal/ui/components/toast.cr
opal/ui/components/tree.cr
opal/ui/components/viewport.cr
opal/ui/diff_renderer.cr
opal/ui/dsl.cr
opal/ui/element.cr
opal/ui/markdown/renderer.cr
opal/version.cr

Constant Summary

VERSION = "0.1.0"

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.confirm(question : String, default : Bool = true) : Bool #

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

Copies text to the host system clipboard via OSC 52.


[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.hyperlink(text : String, url : String, id : String | Nil = nil) : String #

Creates a clickable OSC 8 hyperlink for modern terminals.


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

Alias for hyperlink


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

[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.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.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, &block : UI::Builder -> Nil) : String #

Convenience shortcut to render a declarative UI tree


[View source]
def self.run_tea(model : TEA::Model, driver : Terminal::Driver | Nil = nil, alt_screen : Bool = true) : TEA::Model #

Convenience helper to instantiate and run a TEA Program


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

[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 : 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]