Module: Sai::ANSI Private

Defined in:
lib/sai/ansi.rb,
lib/sai/ansi/color_parser.rb,
lib/sai/ansi/style_parser.rb,
lib/sai/ansi/sequenced_string.rb,
lib/sai/ansi/sequence_processor.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

ANSI constants for encoding text styles and colors

Author:

Since:

  • 0.1.0

Defined Under Namespace

Classes: ColorParser, SequenceProcessor, SequencedString, StyleParser

Constant Summary collapse

COLORS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Standard ANSI color names and their RGB values

Returns:

  • (Hash{Symbol => Array<Integer>}) —

    the color names and RGB values

Author:

Since:

  • 0.3.1

{
  black: [0, 0, 0],
  red: [205, 0, 0],
  green: [0, 205, 0],
  yellow: [205, 205, 0],
  blue: [0, 0, 238],
  magenta: [205, 0, 205],
  cyan: [0, 205, 205],
  white: [229, 229, 229],
  bright_black: [127, 127, 127],
  bright_red: [255, 0, 0],
  bright_green: [0, 255, 0],
  bright_yellow: [255, 255, 0],
  bright_blue: [92, 92, 255],
  bright_magenta: [255, 0, 255],
  bright_cyan: [0, 255, 255],
  bright_white: [255, 255, 255]
}.freeze
COLOR_CODES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

ANSI color code mappings

Returns:

  • (Hash{Symbol => Integer}) —

    the color codes

Author:

Since:

  • 0.1.0

{
  black: 0,
  red: 1,
  green: 2,
  yellow: 3,
  blue: 4,
  magenta: 5,
  cyan: 6,
  white: 7
}.freeze
RESET =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

ANSI escape sequence for resetting text formatting

Returns:

  • (String) —

    the ANSI escape sequence

Author:

Since:

  • 0.1.0

"\e[0m"
STYLES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Standard ANSI style codes

Returns:

  • (Hash{Symbol => Integer}) —

    the style codes

Author:

Since:

  • 0.1.0

{
  bold: 1,
  dim: 2,
  italic: 3,
  underline: 4,
  blink: 5,
  rapid_blink: 6,
  reverse: 7,
  conceal: 8,
  strike: 9,
  normal_intensity: 22,
  no_italic: 23,
  no_underline: 24,
  no_blink: 25,
  no_reverse: 27,
  no_conceal: 28,
  no_strike: 29
}.freeze

Class Method Summary collapse

Class Method Details

.install ⇒ void

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.

This method returns an undefined value.

Install the ANSI colors

Author:

Since:

  • 0.4.0



103
104
105
# File 'lib/sai/ansi.rb', line 103

def self.install
  COLORS.each_pair { |name, color| Sai.register(name, color) }
end