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

.yellowInteger

Returns:

  • (Integer)


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

def self.yellow
  Curses.color_pair(8)
end

.blackInteger

Returns:

  • (Integer)


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

def self.black
  Curses.color_pair(1)
end

.blueInteger

Returns:

  • (Integer)


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

def self.blue
  Curses.color_pair(2)
end

.cyanInteger

Returns:

  • (Integer)


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

def self.cyan
  Curses.color_pair(3)
end

.greenInteger

Returns:

  • (Integer)


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

def self.green
  Curses.color_pair(4)
end

.magnetaInteger

Returns:

  • (Integer)


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

def self.magneta
  Curses.color_pair(5)
end

.redInteger

Returns:

  • (Integer)


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

def self.red
  Curses.color_pair(6)
end

.whiteInteger

Returns:

  • (Integer)


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

def self.white
  Curses.color_pair(7)
end

.enable

This method returns an undefined value.

Enable color and initialize 8 color pairs.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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)
end