Module: Tui
- Defined in:
- lib/tui.rb
Overview
Usage pattern:
include Tui::Helpers
screen = Tui::Screen.new
screen.header.add_line { |line| line.write << Tui::Text.bold("📁 Try Selector") }
search_line = screen.body.add_line
search_line.write_dim("Search:").write(" ")
search_line.write << screen.input("Type to filter…", value: query, cursor: cursor)
list_line = screen.body.add_line(background: Tui::Palette::SELECTED_BG)
list_line.write << Tui::Text.highlight("→ ") << name
list_line.right.write_dim()
screen..add_line { |line| line.write_dim("↑↓ navigate Enter select Esc cancel") }
screen.flush
The screen owns a single InputField (enforced by #input). Lines support independent left/right writers, truncation, and per-line backgrounds. Right writers are rendered via rwrite-style positioning (clear line + move col).
Defined Under Namespace
Modules: ANSI, Helpers, Metrics, Palette, Text Classes: InputField, Line, Screen, Section, SegmentWriter, Terminal
Constant Summary collapse
- ANSI_STRIP_RE =
Precompiled regexes used in hot paths
/\e\[[0-9;]*[A-Za-z]/- ESCAPE_TERMINATOR_RE =
/[A-Za-z]/
Class Attribute Summary collapse
-
.colors_enabled ⇒ Object
Returns the value of attribute colors_enabled.
Class Method Summary collapse
Class Attribute Details
.colors_enabled ⇒ Object
Returns the value of attribute colors_enabled.
30 31 32 |
# File 'lib/tui.rb', line 30 def colors_enabled @colors_enabled end |
Class Method Details
.colors_enabled? ⇒ Boolean
32 33 34 |
# File 'lib/tui.rb', line 32 def colors_enabled? @colors_enabled end |
.disable_colors! ⇒ Object
36 37 38 |
# File 'lib/tui.rb', line 36 def disable_colors! @colors_enabled = false end |
.enable_colors! ⇒ Object
40 41 42 |
# File 'lib/tui.rb', line 40 def enable_colors! @colors_enabled = true end |