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
- .yellow ⇒ Integer
- .black ⇒ Integer
- .blue ⇒ Integer
- .cyan ⇒ Integer
- .green ⇒ Integer
- .magneta ⇒ Integer
- .red ⇒ Integer
- .white ⇒ Integer
-
.enable
Enable color and initialize 8 color pairs.
Class Method Details
.yellow ⇒ Integer
74 75 76 |
# File 'lib/llm/repl/color.rb', line 74 def self.yellow Curses.color_pair(8) end |
.black ⇒ Integer
32 33 34 |
# File 'lib/llm/repl/color.rb', line 32 def self.black Curses.color_pair(1) end |
.blue ⇒ Integer
38 39 40 |
# File 'lib/llm/repl/color.rb', line 38 def self.blue Curses.color_pair(2) end |
.cyan ⇒ Integer
44 45 46 |
# File 'lib/llm/repl/color.rb', line 44 def self.cyan Curses.color_pair(3) end |
.green ⇒ Integer
50 51 52 |
# File 'lib/llm/repl/color.rb', line 50 def self.green Curses.color_pair(4) end |
.magneta ⇒ Integer
56 57 58 |
# File 'lib/llm/repl/color.rb', line 56 def self.magneta Curses.color_pair(5) end |
.red ⇒ Integer
62 63 64 |
# File 'lib/llm/repl/color.rb', line 62 def self.red Curses.color_pair(6) end |
.white ⇒ 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 |