Class: CLAide::ANSI
- Inherits:
-
Object
- Object
- CLAide::ANSI
- Defined in:
- lib/claide/ansi.rb,
lib/claide/ansi/cursor.rb,
lib/claide/ansi/graphics.rb,
lib/claide/ansi/string_escaper.rb
Overview
Provides support for ANSI Escape sequences
For more information see:
This functionality has been inspired and derived from the following gems:
- colored
- colorize
Defined Under Namespace
Modules: Cursor, Graphics Classes: StringEscaper
Constant Summary collapse
- TEXT_ATTRIBUTES =
Returns The text attributes codes by their English name.
{ :bold => 1, :underline => 4, :blink => 5, :reverse => 7, :hidden => 8, }
- TEXT_DISABLE_ATTRIBUTES =
Returns The codes to disable a text attribute by their name.
{ :bold => 21, :underline => 24, :blink => 25, :reverse => 27, :hidden => 28, }
- RESET_SEQUENCE =
Return [String] The escape sequence to reset the graphics.
"\e[0m"
- COLORS =
Returns The colors codes by their English name.
{ :black => 0, :red => 1, :green => 2, :yellow => 3, :blue => 4, :magenta => 5, :cyan => 6, :white => 7, }
- DEFAULT_FOREGROUND_COLOR =
Return [String] The escape sequence for the default foreground color.
"\e[39m"
- DEFAULT_BACKGROUND_COLOR =
Return [String] The escape sequence for the default background color.
"\e[49m"
Class Attribute Summary collapse
-
.disabled ⇒ Bool
original string.
Class Method Summary collapse
-
.code_for_key(key, map) ⇒ Fixnum
The code of a key given the map.
Methods included from Cursor
erase_display, erase_line, move_cursor, restore_cursor_position, save_cursor_position, set_cursor_position
Methods included from Graphics
background_color, background_color_256, foreground_color, foreground_color_256, graphics_mode, text_attribute
Class Attribute Details
.disabled ⇒ Bool
original string. This method is intended to offer a central location where to disable ANSI logic without needed to implement conditionals across the code base of clients.
35 36 37 |
# File 'lib/claide/ansi.rb', line 35 def disabled @disabled end |
Class Method Details
.code_for_key(key, map) ⇒ Fixnum
Returns The code of a key given the map.
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/claide/ansi.rb', line 96 def self.code_for_key(key, map) unless key raise ArgumentError, 'A key must be provided' end code = map[key] unless code raise ArgumentError, "Unsupported key: `#{key}`" end code end |