Module: Sai
- Extended by:
- Decorator::Delegator
- Defined in:
- lib/sai.rb,
lib/sai/ansi.rb,
lib/sai/support.rb,
lib/sai/registry.rb,
lib/sai/decorator.rb,
lib/sai/mode_selector.rb,
lib/sai/conversion/rgb.rb,
lib/sai/ansi/color_parser.rb,
lib/sai/ansi/style_parser.rb,
lib/sai/decorator/delegator.rb,
lib/sai/decorator/gradients.rb,
lib/sai/terminal/color_mode.rb,
lib/sai/decorator/hex_colors.rb,
lib/sai/decorator/rgb_colors.rb,
lib/sai/ansi/sequenced_string.rb,
lib/sai/terminal/capabilities.rb,
lib/sai/decorator/named_colors.rb,
lib/sai/decorator/named_styles.rb,
lib/sai/ansi/sequence_processor.rb,
lib/sai/conversion/color_sequence.rb,
lib/sai/conversion/rgb/color_space.rb,
lib/sai/conversion/rgb/color_indexer.rb,
lib/sai/decorator/color_manipulations.rb,
lib/sai/conversion/rgb/color_classifier.rb,
lib/sai/conversion/rgb/color_transformer.rb
Overview
An elegant color management system for crafting sophisticated CLI applications
Sai (彩) - meaning 'coloring' or 'paint' in Japanese - is a powerful and intuitive system for managing color output in command-line applications. Drawing inspiration from traditional Japanese artistic techniques, Sai brings vibrancy and harmony to terminal interfaces through its sophisticated color management
Sai empowers developers to create beautiful, colorful CLI applications that maintain visual consistency across different terminal capabilities. Like its artistic namesake, it combines simplicity and sophistication to bring rich, adaptive color to your terminal interfaces
When included in a class or module, Sai provides the following instance methods:
- #color_mode - Returns an interface to select Sai color modes
- #decorator - Returns a new instance of Decorator for method chaining
- #terminal_color_support - Returns the color support capabilities of the current terminal
The Sai module itself responds to all the same methods as Decorator, excluding methods used for applying decorations (apply, call, decorate, encode). These methods are directly delegated to a new Decorator instance
Defined Under Namespace
Modules: ANSI, Conversion, ModeSelector, Registry, Support, Terminal Classes: Decorator
Class Method Summary collapse
-
.mode ⇒ ModeSelector
The Sai mode selector.
-
.register(name, rgb_or_hex) ⇒ void
Register a custom name and color.
-
.sequence(text) ⇒ ANSI::SequencedString
Sequence a string with ANSI escape codes.
-
.support ⇒ Support
The supported color modes for the terminal.
-
.with_mode(mode) ⇒ Decorator
extended
from Decorator::Delegator
private
Apply a specific color mode to the Decorator instance.
Instance Method Summary collapse
-
#color_mode ⇒ ModeSelector
A helper method that provides Sai color modes.
-
#decorator(mode: Sai.mode.auto) ⇒ Decorator
A helper method to initialize an instance of Decorator.
-
#terminal_color_support ⇒ Support
The supported color modes for the terminal.
Class Method Details
.mode ⇒ ModeSelector
The Sai mode selector
71 72 73 |
# File 'lib/sai.rb', line 71 def mode ModeSelector end |
.register(name, rgb_or_hex) ⇒ void
This method returns an undefined value.
Register a custom name and color
93 94 95 |
# File 'lib/sai.rb', line 93 def register(name, rgb_or_hex) Registry.register(name, rgb_or_hex) end |
.sequence(text) ⇒ ANSI::SequencedString
Sequence a string with ANSI escape codes
111 112 113 |
# File 'lib/sai.rb', line 111 def sequence(text) ANSI::SequencedString.new(text) end |
.support ⇒ Support
The supported color modes for the terminal
131 132 133 |
# File 'lib/sai.rb', line 131 def support Support end |
.with_mode(mode) ⇒ Decorator Originally defined in module Decorator::Delegator
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Apply a specific color mode to the Sai::Decorator instance
Instance Method Details
#color_mode ⇒ ModeSelector
A helper method that provides Sai color modes
172 173 174 |
# File 'lib/sai.rb', line 172 def color_mode ModeSelector end |
#decorator(mode: Sai.mode.auto) ⇒ Decorator
A helper method to initialize an instance of Decorator
198 199 200 |
# File 'lib/sai.rb', line 198 def decorator(mode: Sai.mode.auto) Decorator.new(mode:) end |
#terminal_color_support ⇒ Support
The supported color modes for the terminal
222 223 224 |
# File 'lib/sai.rb', line 222 def terminal_color_support Support end |