package notty
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=74659fb14073db4438989891ab24f24bef81aa497dac16d9a67f9a1c9c200824
sha512=6e21d44fe39f3d80884b87635bebae55cb2b931ef74f9184ba4d74cc3e51cb0b3e976c3b6dc61d377288504e8bfabe21acdc1069eacb30df1fbf6686b80f7c6b
doc/notty/Notty/A/index.html
Module Notty.ASource
A is for attribute.
Construction and composition of styling characteristics of text.
Consult the basics for an overview.
Colors
An ineffable quality of light.
There are three kinds of colors:
Core 16 colors.
ANSI defines 8 color names, with the actual display colors considered an implementation detail. Historically, this palette was extended with their light (sometimes bright or high-intensity) counterparts. Their presentation is undefined too, but typically produces a brighter shade. These colors - often called the ANSI colors - tend to be unpredictable, but ubiquitously supported.
Extended 256-color palette.
This common feature extends the palette by further 240 colors. They come in two groups:
- The color cube, a 6*6*6 approximation to the usual 24-bit RGB color cube; and
- the grayscale ramp, containing (merely) 24 shades of gray.
XTerm was the first to support this extension. Many terminals have since cloned it, so the support is wide, but not universal.
As the extended colors are still palette-driven they do not have a fixed presentation, and the presentation can be changed in some terminals. Default palette tends to match XTerm's.
True color
A recently established convention allows directly sending 24-bit colors to the terminal. This has been adopted by a growing minority of terminals. A reasonably up-to-date status document maintained by the community can be found here.
Some of the technical and historical background can be found in XTerm's FAQ.
Note No attempt is made to remap colors depending on the terminal. Terminals might ignore, remap, or completely misinterpret unsupported colors.
Core 16 colors
The first 8 have their standard ANSI names.
Extended 256-color palette
rgb ~r:red ~g:green ~b:blue is an extended-palette color from the color cube.
All three channels must be in the range 0 - 5. XTerm default palette maps this to 0x00, 0x5f, 0x87, 0xaf, 0xd7, and 0xff independently per channel.
gray level is an extended-palette color from the grayscale ramp.
level must be in the range 0 - 23. XTerm default palette maps this to 8 + level * 10 on all three channels.
True Color
rgb_888 ~r:red ~g:green ~b:blue is a 24-bit color.
All three channels must be in the range 0 - 255.
Text styles
Additional text properties.
Attribute construction and composition
empty is the attribute with the default foreground and background color and empty style set.
a1 ++ a2 is the concatenation of a1 and a2, the attribute that has a2's foreground (resp. background), unless unset, in which case it is a1's, and the union of both style sets.
++ is left-associative, and forms a monoid with empty.