123456789_123456789_123456789_123456789_123456789_

Class: Reline::Face

Relationships & Source Files
Namespace Children
Classes:
Inherits: Object
Defined in: lib/reline/face.rb

Constant Summary

  • SGR_PARAMETERS = private
    # File 'lib/reline/face.rb', line 4
    {
      foreground: {
        black: 30,
        red: 31,
        green: 32,
        yellow: 33,
        blue: 34,
        magenta: 35,
        cyan: 36,
        white: 37,
        bright_black: 90,
        gray: 90,
        bright_red: 91,
        bright_green: 92,
        bright_yellow: 93,
        bright_blue: 94,
        bright_magenta: 95,
        bright_cyan: 96,
        bright_white: 97
      },
      background: {
        black: 40,
        red: 41,
        green: 42,
        yellow: 43,
        blue: 44,
        magenta: 45,
        cyan: 46,
        white: 47,
        bright_black: 100,
        gray: 100,
        bright_red: 101,
        bright_green: 102,
        bright_yellow: 103,
        bright_blue: 104,
        bright_magenta: 105,
        bright_cyan: 106,
        bright_white: 107,
      },
      style: {
        reset: 0,
        bold: 1,
        faint: 2,
        italicized: 3,
        underlined: 4,
        slowly_blinking: 5,
        blinking: 5,
        rapidly_blinking: 6,
        negative: 7,
        concealed: 8,
        crossed_out: 9
      }
    }.freeze

Class Attribute Summary

Class Method Summary

Class Attribute Details

.truecolor?Boolean (readonly)

[ GitHub ]

  
# File 'lib/reline/face.rb', line 160

def self.truecolor?
  @force_truecolor || %w[truecolor 24bit].include?(ENV['COLORTERM'])
end

Class Method Details

.[](name)

[ GitHub ]

  
# File 'lib/reline/face.rb', line 169

def self.[](name)
  @configs[name]
end

.config(name, &block)

[ GitHub ]

  
# File 'lib/reline/face.rb', line 173

def self.config(name, &block)
  @configs ||= {}
  @configs[name] = Config.new(name, &block)
end

.configs

[ GitHub ]

  
# File 'lib/reline/face.rb', line 178

def self.configs
  @configs.transform_values(&:definition)
end

.force_truecolor

[ GitHub ]

  
# File 'lib/reline/face.rb', line 164

def self.force_truecolor
  @force_truecolor = true
  @configs&.each_value(&:reconfigure)
end

.load_initial_configs

[ GitHub ]

  
# File 'lib/reline/face.rb', line 182

def self.load_initial_configs
  config(:default) do |conf|
    conf.define :default, style: :reset
    conf.define :enhanced, style: :reset
    conf.define :scrollbar, style: :reset
  end
  config(:completion_dialog) do |conf|
    conf.define :default, foreground: :bright_white, background: :gray
    conf.define :enhanced, foreground: :black, background: :white
    conf.define :scrollbar, foreground: :white, background: :gray
  end
end

.reset_to_initial_configs

[ GitHub ]

  
# File 'lib/reline/face.rb', line 195

def self.reset_to_initial_configs
  @configs = {}
  load_initial_configs
end