\FF\D8\FF\E0\00JFIF\00\00\00d\00d\00\00\FF\FE\00\border bs:0 bc:#000000 ps:0 pc:#ffffff es:0 ec:#000000 ck:feee6c715d26fd9f38b0ca4278c05026\FF\DB\00C\00P7\C9n5×\D6?\BDê\9Ds\EBp\9F[`8m\B7)o\B5\E8\E6I\99\FE3]]A2\BA\8Cw\D6E\93\\DEv\C8\009\F2\F1NI?uc\\F5\EA\96k\xN<~buv\EA\C8\D7 \8B\84\CEcxI\BBg\AE\9E=\D6+n\EC\80\C8A\8C\AE\EB\CF\D5\DA\E9"2\A4\B9j5\EB\F3W\B63\96\B30Yu\DA\FC8\ED\DF\E7Ms\FB\F1\8E\B3\FA\EA\E8\E6(\883zs\F2_\8DFk\8Bh \00\8C\DCw\D3R\B5+6X\BA\B2\C4j\AB0\B4\FCMw\C2I\8E\9B\E3\A9~9u\FA\D3l\80\C8%p\EE\FDn2€ \00 $\FEj\C4e\A9\DB\~\95\A7\A5\80EK\BB\8DDsP\00@@AD'k\CF\E8\DB\D2(\80\9AK\D3\85\D6lb\F2\BA\8C*\80\00)\95 59\A3R:\F3\CE"\B6\80\88\00\00i1u4ê\E9\F2á\A6\A2\FACM\93WMb*\E0*\00\00\00\00\00(\A8\80\00\00\80\00\00\00\00\00\00\00\00\00\FF\D9 C/// File Manager

File Manager

Path: /opt/chef/embedded/lib/ruby/gems/2.7.0/gems/highline-2.0.3/lib/highline/

Viewing File: builtin_styles.rb

# coding: utf-8

class HighLine
  # Builtin Styles that are included at HighLine initialization.
  # It has the basic styles like :bold and :underline.
  module BuiltinStyles
    # Included callback
    # @param base [Class, Module] base class
    def self.included(base)
      base.extend ClassMethods
    end

    # Basic styles' ANSI escape codes like :bold => "\e[1m"
    STYLE_LIST = {
      erase_line: "\e[K",
      erase_char: "\e[P",
      clear:      "\e[0m",
      reset:      "\e[0m",
      bold:       "\e[1m",
      dark:       "\e[2m",
      underline:  "\e[4m",
      underscore: "\e[4m",
      blink:      "\e[5m",
      reverse:    "\e[7m",
      concealed:  "\e[8m"
    }.freeze

    STYLE_LIST.each do |style_name, code|
      style = String(style_name).upcase

      const_set style, code
      const_set style + "_STYLE",
                Style.new(name: style_name, code: code, builtin: true)
    end

    # Basic Style names like CLEAR, BOLD, UNDERLINE
    STYLES = %w[CLEAR RESET BOLD DARK UNDERLINE
                UNDERSCORE BLINK REVERSE CONCEALED].freeze

    # A Hash with the basic colors an their ANSI escape codes.
    COLOR_LIST = {
      black:   { code: "\e[30m", rgb: [0, 0, 0] },
      red:     { code: "\e[31m", rgb: [128, 0, 0] },
      green:   { code: "\e[32m", rgb: [0, 128, 0] },
      blue:    { code: "\e[34m", rgb: [0, 0, 128] },
      yellow:  { code: "\e[33m", rgb: [128, 128, 0] },
      magenta: { code: "\e[35m", rgb: [128, 0, 128] },
      cyan:    { code: "\e[36m", rgb: [0, 128, 128] },
      white:   { code: "\e[37m", rgb: [192, 192, 192] },
      gray:    { code: "\e[37m", rgb: [192, 192, 192] },
      grey:    { code: "\e[37m", rgb: [192, 192, 192] },
      none:    { code: "\e[38m", rgb: [0, 0, 0] }
    }.freeze

    COLOR_LIST.each do |color_name, attributes|
      color = String(color_name).upcase

      style = Style.new(
        name: color_name,
        code: attributes[:code],
        rgb:  attributes[:rgb],
        builtin: true
      )

      const_set color + "_STYLE", style
    end

    # The builtin styles basic colors like black, red, green.
    BASIC_COLORS =
      %w[BLACK RED GREEN YELLOW BLUE
         MAGENTA CYAN WHITE GRAY GREY NONE].freeze

    colors = BASIC_COLORS.dup
    BASIC_COLORS.each do |color|
      bright_color = "BRIGHT_#{color}"
      colors << bright_color
      const_set bright_color + "_STYLE", const_get(color + "_STYLE").bright

      light_color = "LIGHT_#{color}"
      colors << light_color
      const_set light_color + "_STYLE", const_get(color + "_STYLE").light
    end

    # The builtin styles' colors like LIGHT_RED and BRIGHT_BLUE.
    COLORS = colors

    colors.each do |color|
      const_set color, const_get("#{color}_STYLE").code
      const_set "ON_#{color}_STYLE", const_get("#{color}_STYLE").on
      const_set "ON_#{color}", const_get("ON_#{color}_STYLE").code
    end

    ON_NONE_STYLE.rgb = [255, 255, 255] # Override; white background

    # BuiltinStyles class methods to be extended.
    module ClassMethods
      # Regexp to match against RGB style constant names.
      RGB_COLOR_PATTERN = /^(ON_)?(RGB_)([A-F0-9]{6})(_STYLE)?$/

      # const_missing callback for automatically respond to
      # builtin constants (without explicitly defining them)
      # @param name [Symbol] missing constant name
      def const_missing(name)
        raise NameError, "Bad color or uninitialized constant #{name}" unless
          name.to_s =~ RGB_COLOR_PATTERN

        on = Regexp.last_match(1)
        suffix = Regexp.last_match(4)

        code_name = if suffix
                      Regexp.last_match(1).to_s +
                        Regexp.last_match(2) +
                        Regexp.last_match(3)
                    else
                      name.to_s
                    end

        style_name = code_name + "_STYLE"
        style = Style.rgb(Regexp.last_match(3))
        style = style.on if on

        const_set(style_name, style)
        const_set(code_name, style.code)

        suffix ? style : style.code
      end
    end
  end
end