struct
TermBuf::Color
- TermBuf::Color
- Struct
- Value
- Object
Overview
A foreground, background, or underline colour.
Colours are stored exactly as the application supplied them. Reducing a 24 bit colour to the 256 colour palette, or that palette to the sixteen system colours, happens at encode time against the terminal's capability mask — so raising the mask and repainting yields better colour with no information lost along the way.
Defined in:
termbuf/core/color.crConstant Summary
-
BLACK =
indexed(0) -
The eight basic system colours, by palette index.
-
BLUE =
indexed(4) -
BRIGHT_BLACK =
indexed(8) -
Their bright counterparts, which need
Capability::BrightColorsto come out bright rather than dim. -
BRIGHT_BLUE =
indexed(12) -
BRIGHT_CYAN =
indexed(14) -
BRIGHT_GREEN =
indexed(10) -
BRIGHT_MAGENTA =
indexed(13) -
BRIGHT_RED =
indexed(9) -
BRIGHT_WHITE =
indexed(15) -
BRIGHT_YELLOW =
indexed(11) -
CUBE_LEVELS =
StaticArray[0, 95, 135, 175, 215, 255] -
The six levels each channel takes in the 6x6x6 colour cube.
-
CYAN =
indexed(6) -
GREEN =
indexed(2) -
MAGENTA =
indexed(5) -
RED =
indexed(1) -
SYSTEM_COLORS =
StaticArray[0, 8388608, 32768, 8421376, 128, 8388736, 32896, 12632256, 8421504, 16711680, 65280, 16776960, 255, 16711935, 65535, 16777215] -
The sixteen system colours as xterm renders them. Terminals are free to remap these, which is exactly why an
Indexedcolour is never rewritten toRgb: only the reverse direction is a downgrade. -
WHITE =
indexed(7) -
YELLOW =
indexed(3)
Constructors
-
.default : Color
The terminal's default colour.
-
.indexed(index : Int) : Color
A colour from the 256 colour palette.
-
.rgb(red : Int, green : Int, blue : Int) : Color
A 24 bit colour.
-
.rgb(value : Int) : Color
A 24 bit colour from a packed
0xRRGGBBvalue.
Instance Method Summary
-
#blue : Int32
Red channel, meaningful only for an
Rgbcolour. -
#bright? : Bool
Whether this is one of the eight bright system colours, which some terminals reach through the
90-97and100-107codes rather than the palette. -
#channels : Tuple(Int32, Int32, Int32)
The colour's red, green, and blue channels.
-
#default? : Bool
Whether this is the terminal's own default colour.
-
#green : Int32
Red channel, meaningful only for an
Rgbcolour. -
#index : Int32
Palette index, meaningful only for an
Indexedcolour. -
#indexed? : Bool
Whether this is a palette index.
-
#kind : Kind
Which of
Kindthis colour is. -
#red : Int32
Red channel, meaningful only for an
Rgbcolour. -
#rgb? : Bool
Whether this is a 24 bit colour.
-
#to_indexed16 : Color
The nearest of the sixteen system colours.
-
#to_indexed256 : Color
The nearest colour in the 256 colour palette.
-
#to_s(io : IO) : Nil
Same as
#inspect(io).
Constructor Detail
A colour from the 256 colour palette. Indices 0 through 7 are the basic colours, 8 through 15 their bright counterparts, 16 through 231 the colour cube, and 232 through 255 the grey ramp.
Instance Method Detail
Red channel, meaningful only for an Rgb colour. #channels resolves a
palette index instead.
Whether this is one of the eight bright system colours, which some
terminals reach through the 90-97 and 100-107 codes rather than
the palette.
The colour's red, green, and blue channels. An Indexed colour resolves
through the standard xterm palette; a Default colour has no channels of
its own and reports black.
Red channel, meaningful only for an Rgb colour. #channels resolves a
palette index instead.
Red channel, meaningful only for an Rgb colour. #channels resolves a
palette index instead.
The nearest of the sixteen system colours. A Default colour passes
through unchanged; everything else resolves through its channels.
The nearest colour in the 256 colour palette. Default and Indexed
colours are already expressible and pass through unchanged.