Module: LLM::Repl::Color

Defined in:
lib/llm/repl/color.rb

Overview

The LLM::Repl::Color module returns bitmasks that are understood as colors by the Curses library. They can be bitwise OR'ed with other attributes, such as Curses::A_BOLD.

Class Method Summary collapse

Class Method Details

.blackInteger

Returns:

  • (Integer)


33
34
35
# File 'lib/llm/repl/color.rb', line 33

def self.black
  Curses.color_pair(1)
end

.blueInteger

Returns:

  • (Integer)


39
40
41
# File 'lib/llm/repl/color.rb', line 39

def self.blue
  Curses.color_pair(2)
end

.cyanInteger

Returns:

  • (Integer)


45
46
47
# File 'lib/llm/repl/color.rb', line 45

def self.cyan
  Curses.color_pair(3)
end

.enablevoid

This method returns an undefined value.

Enable color and initialize 9 color pairs.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/llm/repl/color.rb', line 13

def self.enable
  Curses.start_color
  ##
  # The first argument is the color pairs ID, and
  # it is mapped back to a bitmask via {Curses.color_pair}.
  # The second argument is the foreground color, and
  # the third argument is the background color.
  Curses.init_pair(1, Curses::COLOR_BLACK   , Curses::COLOR_WHITE)
  Curses.init_pair(2, Curses::COLOR_BLUE    , Curses::COLOR_BLACK)
  Curses.init_pair(3, Curses::COLOR_CYAN    , Curses::COLOR_BLACK)
  Curses.init_pair(4, Curses::COLOR_GREEN   , Curses::COLOR_BLACK)
  Curses.init_pair(5, Curses::COLOR_MAGENTA , Curses::COLOR_BLACK)
  Curses.init_pair(6, Curses::COLOR_RED     , Curses::COLOR_BLACK)
  Curses.init_pair(7, Curses::COLOR_WHITE   , Curses::COLOR_BLACK)
  Curses.init_pair(8, Curses::COLOR_YELLOW  , Curses::COLOR_BLACK)
  Curses.init_pair(9, Curses::COLOR_WHITE, Curses::COLOR_BLUE)
end

.greenInteger

Returns:

  • (Integer)


51
52
53
# File 'lib/llm/repl/color.rb', line 51

def self.green
  Curses.color_pair(4)
end

.magnetaInteger

Returns:

  • (Integer)


57
58
59
# File 'lib/llm/repl/color.rb', line 57

def self.magneta
  Curses.color_pair(5)
end

.redInteger

Returns:

  • (Integer)


63
64
65
# File 'lib/llm/repl/color.rb', line 63

def self.red
  Curses.color_pair(6)
end

.statusbarInteger

Returns:

  • (Integer)


81
82
83
# File 'lib/llm/repl/color.rb', line 81

def self.statusbar
  Curses.color_pair(9)
end

.whiteInteger

Returns:

  • (Integer)


69
70
71
# File 'lib/llm/repl/color.rb', line 69

def self.white
  Curses.color_pair(7)
end

.yellowInteger

Returns:

  • (Integer)


75
76
77
# File 'lib/llm/repl/color.rb', line 75

def self.yellow
  Curses.color_pair(8)
end