Module: TermColor::Rule
Overview
Rule processor
}
Defined Under Namespace
Classes: Compiled
Constant Summary collapse
- Colors =
Named Standard ANSI Color constants (Basic named values for ‘fg` and `bg` rule option attributes)
{ black: 0, red: 1, green: 2, yellow: 3, blue: 4, magenta: 5, cyan: 6, white: 7, bright_black: 60, bright_red: 61, bright_green: 62, bright_yellow: 63, bright_blue: 64, bright_magenta: 65, bright_cyan: 66, bright_white: 67 }.freeze
- ColorTargets =
Numerical modifiers used with Color Values to target foreground or background.
-
For Named Standard Colors, value is added to given color’s numerical value
-
For XTerm 256/16m color codes, value is added to mode base
-
{ fg: 30, # Foreground target bg: 40 # Background target }.freeze
- Styles =
Style option constants (Values that can be included in style ‘enable` and `disable` rule option attributes)
{ bold: 1, ## # Alias for bold intense: 1, dim: 2, ## # Alias for dim dark: 2, italic: 3, underline: 4, inverse: 7, hidden: 8, strikethrough: 9 }.freeze
- StyleActions =
Style action codes (Numerical modifiers applied to Style Codes to enable/disable them based on which option attribute action was used)
{ # Enable style(s) action enable: 0, # Disable style(s) action disable: 20 }.freeze
- Resets =
Reset option constants (Values for ‘reset` rule option attribute)
{ # Reset everything all: 0, # Reset foreground color only fg: 39, # Reset background color only bg: 49, # Reset style style: StyleActions[:disable] }.freeze
- ResetOps =
Operations associated with reset
[ :reset, :keep ].freeze
- ResetsExtra =
[ :style ].freeze
- Parts =
Descriptive aliases for part names
{ # Style applied on rule open inside: :inside, # Style appled when rule close is given after: :after }.freeze
- Ops =
Valid rule operations mapped to accepted const values (colors [fg, bg] can also accept integers)
{ # Foreground color option fg: Colors.keys, # Background color option bg: Colors.keys, # Enable style(s) action enable: Styles.keys, # Disable style(s) action disable: Styles.keys, # Reset action reset: Resets.keys, # Keep action (opposite of reset) keep: Resets.keys }.freeze
- OpNormalize =
Normalize rules for ops; either ‘:keep` to not change original value, or `:array` to wrap single value inside array
{ fg: :keep, bg: :keep, enable: :array, disable: :array, reset: :array, keep: :array }.freeze
- PartOps =
Allowed ops by part
{ inside: [:fg, :bg, :enable, :disable], after: [:fg, :bg, :enable, :disable, :reset, :keep] }.freeze
- AfterOps =
Operations allowed within ‘after’
(Ops.filter{|k,v| PartOps[:after].include?(k)}).freeze
- InsideOps =
Operations allowed within ‘inside’
(Ops.filter {|k,v| PartOps[:inside].include?(k)}).freeze
- XTERM_COLOR_TARGET =
Value added to ColorTarget when using XTerm colors
8
- XTERM_COLOR_256 =
Mode constant for XTerm 256 Colors
5
- XTERM_COLOR_16M =
Mode constant for XTerm 16m Colors
2
Instance Method Summary collapse
-
#compile(rule, rs, is_reset = false) ⇒ Compiled
Compile rule into frozen instance of ‘Compiled` struct.
Instance Method Details
#compile(rule, rs, is_reset = false) ⇒ Compiled
Compile rule into frozen instance of ‘Compiled` struct
217 218 219 220 221 222 223 224 |
# File 'lib/term_color/rule.rb', line 217 def compile(rule, rs, is_reset=false) evaluated = evaluate(rule,rs,is_reset) return Compiled.new( rule, evaluated, codes(evaluated) ).freeze end |