Class: Intent::UI::TermColor

Inherits:
Object
  • Object
show all
Defined in:
lib/intent/ui/term_color.rb

Overview

Shim to convert between Pastel to Paint gems without needing to edit existing call sites.

It might be helpful to normalize this convention with an API anyway as we generally want to use the 8/16 colour defaults as they pick up user terminal customisation properly, whereas going full 256 or 24 bit colour means generic RGB values are likely to look shit on customised terminal backgrounds.

This way we get the benefits of mostly sticking to the terminal defaults, while extending the range of colours with a few carefully chosen values.

Instance Method Summary collapse

Constructor Details

#initializeTermColor

Returns a new instance of TermColor.



16
17
18
# File 'lib/intent/ui/term_color.rb', line 16

def initialize
  @decoration_scope = []
end

Instance Method Details

#blue(text) ⇒ Object



40
41
42
43
# File 'lib/intent/ui/term_color.rb', line 40

def blue(text)
  decoration_scope.push(:blue)
  return_decorator(text)
end

#bold(text = nil) ⇒ Object



25
26
27
28
# File 'lib/intent/ui/term_color.rb', line 25

def bold(text=nil)
  decoration_scope.push(:bold)
  return_decorator(text)
end

#brown(text) ⇒ Object



60
61
62
63
# File 'lib/intent/ui/term_color.rb', line 60

def brown(text)
  decoration_scope.push('tan')
  return_decorator(text)
end

#cyan(text) ⇒ Object



50
51
52
53
# File 'lib/intent/ui/term_color.rb', line 50

def cyan(text)
  decoration_scope.push(:cyan)
  return_decorator(text)
end

#decorate(text, *args) ⇒ Object



20
21
22
23
# File 'lib/intent/ui/term_color.rb', line 20

def decorate(text, *args)
  decoration_scope.push(*args)
  return_decorator(text)
end

#green(text) ⇒ Object



35
36
37
38
# File 'lib/intent/ui/term_color.rb', line 35

def green(text)
  decoration_scope.push(:green)
  return_decorator(text)
end

#orange(text) ⇒ Object



55
56
57
58
# File 'lib/intent/ui/term_color.rb', line 55

def orange(text)
  decoration_scope.push('orange')
  return_decorator(text)
end

#red(text = nil) ⇒ Object



30
31
32
33
# File 'lib/intent/ui/term_color.rb', line 30

def red(text=nil)
  decoration_scope.push(:red)
  return_decorator(text)
end

#yellow(text) ⇒ Object



45
46
47
48
# File 'lib/intent/ui/term_color.rb', line 45

def yellow(text)
  decoration_scope.push(:yellow)
  return_decorator(text)
end