Sha256: b61702e4769e6c5cafb4b9aec5e7e6c7044b38e04208547970c4f89bfe732b4e

Contents?: true

Size: 1010 Bytes

Versions: 1

Compression:

Stored size: 1010 Bytes

Contents

require 'vedeu/configuration/configuration'
require 'vedeu/presentation/translator'
require 'vedeu/support/esc'

module Vedeu

  # The class represents one half (the other, can be found at
  # {Vedeu::Background}) of a terminal colour escape sequence.
  #
  # @api private
  #
  class Foreground < Translator

    private

    # Returns an escape sequence for a named foreground colour.
    #
    # Valid names are: `:black`, `:red`, `:green`, `:yellow`, `:blue`,
    # `:magenta`, `:cyan`, `:white` and `:default`.
    #
    # @return [String]
    def named
      ["\e[", Esc.foreground_codes[colour], 'm'].join
    end

    # Returns an escape sequence.
    #
    # @return [String]
    def numbered
      ["\e[38;5;", css_to_numbered, 'm'].join
    end

    # Returns an escape sequence.
    #
    # @return [String]
    def rgb
      if Configuration.colour_mode == 16777216
        sprintf("\e[38;2;%s;%s;%sm", *css_to_rgb)

      else
        numbered

      end
    end

  end # Foreground

end # Vedeu

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.3.5 lib/vedeu/presentation/foreground.rb