![]() |
libghostty-vt 0.0.0
|
Read a cell's colors and text attributes. More...
Read a cell's colors and text attributes.
A GhosttyStyle is how a cell looks: its foreground, background, and underline colors, and flags for bold, italic, underline, and other text decorations.
You get one from ghostty_grid_ref_style(), or from a render state when you draw. Its colors can be unset, which means you use your default.
Full program: c-vt-grid-traverse/src/main.c
See the Grid guide.
Typedefs | |
| typedef uint16_t | GhosttyStyleId |
| typedef uint16_t | GhosttyStyleFlags |
Enumerations | |
| enum | GhosttyStyleColorTag |
Functions | |
| GHOSTTY_API void | ghostty_style_default (GhosttyStyle *style) |
| GHOSTTY_API bool | ghostty_style_is_default (const GhosttyStyle *style) |
Macros | |
| #define | GHOSTTY_STYLE_FLAG_BOLD ((GhosttyStyleFlags)(1u << 0)) |
| #define | GHOSTTY_STYLE_FLAG_ITALIC ((GhosttyStyleFlags)(1u << 1)) |
| #define | GHOSTTY_STYLE_FLAG_FAINT ((GhosttyStyleFlags)(1u << 2)) |
| #define | GHOSTTY_STYLE_FLAG_BLINK ((GhosttyStyleFlags)(1u << 3)) |
| #define | GHOSTTY_STYLE_FLAG_INVERSE ((GhosttyStyleFlags)(1u << 4)) |
| #define | GHOSTTY_STYLE_FLAG_INVISIBLE ((GhosttyStyleFlags)(1u << 5)) |
| #define | GHOSTTY_STYLE_FLAG_STRIKETHROUGH ((GhosttyStyleFlags)(1u << 6)) |
| #define | GHOSTTY_STYLE_FLAG_OVERLINE ((GhosttyStyleFlags)(1u << 7)) |
| #define | GHOSTTY_STYLE_UNDERLINE_SHIFT 8 |
| #define | GHOSTTY_STYLE_UNDERLINE_MASK ((GhosttyStyleFlags)(0x7u << GHOSTTY_STYLE_UNDERLINE_SHIFT)) |
| #define | GHOSTTY_STYLE_UNDERLINE(style) |
Data Structures | |
| union | GhosttyStyleColorValue |
| struct | GhosttyStyleColor |
| struct | GhosttyStyle |
| typedef uint16_t GhosttyStyleFlags |
Style flags.
A 16-bit set of text attributes, laid out as follows:
| Bits | Meaning |
|---|---|
| 0 to 7 | On/off attributes, one GHOSTTY_STYLE_FLAG_* per bit |
| 8 to 10 | Underline style, a GhosttySgrUnderline value |
| 11 to 15 | Reserved, always zero |
Test an attribute with a bitwise AND against its GHOSTTY_STYLE_FLAG_* mask. Read the underline style with GHOSTTY_STYLE_UNDERLINE().
| typedef uint16_t GhosttyStyleId |
| enum GhosttyStyleColorTag |
Style color tags.
Identifies which kind of color a GhosttyStyleColor holds. The tag is stored in the one-byte tag field of GhosttyStyleColor, so compare that field against these values.
| GHOSTTY_API void ghostty_style_default | ( | GhosttyStyle * | style | ) |
Get the default style.
Initializes the style to the default values (no colors, no flags). The default style is all zero bytes.
| style | Pointer to the style to initialize |
| GHOSTTY_API bool ghostty_style_is_default | ( | const GhosttyStyle * | style | ) |
Check if a style is the default style.
Returns true if all colors are unset and all flags are off. Reserved bits are ignored.
| style | Pointer to the style to check |
| #define GHOSTTY_STYLE_FLAG_BLINK ((GhosttyStyleFlags)(1u << 3)) |
| #define GHOSTTY_STYLE_FLAG_BOLD ((GhosttyStyleFlags)(1u << 0)) |
Bold text.
| #define GHOSTTY_STYLE_FLAG_FAINT ((GhosttyStyleFlags)(1u << 2)) |
| #define GHOSTTY_STYLE_FLAG_INVERSE ((GhosttyStyleFlags)(1u << 4)) |
| #define GHOSTTY_STYLE_FLAG_INVISIBLE ((GhosttyStyleFlags)(1u << 5)) |
| #define GHOSTTY_STYLE_FLAG_ITALIC ((GhosttyStyleFlags)(1u << 1)) |
| #define GHOSTTY_STYLE_FLAG_OVERLINE ((GhosttyStyleFlags)(1u << 7)) |
| #define GHOSTTY_STYLE_FLAG_STRIKETHROUGH ((GhosttyStyleFlags)(1u << 6)) |
| #define GHOSTTY_STYLE_UNDERLINE | ( | style | ) |
Get the underline style of a GhosttyStyle.
The result is a GhosttySgrUnderline value. GHOSTTY_SGR_UNDERLINE_NONE (zero) means the text is not underlined, so the result can also be used as a true/false check.
| style | A GhosttyStyle value, not a pointer to one |
| #define GHOSTTY_STYLE_UNDERLINE_MASK ((GhosttyStyleFlags)(0x7u << GHOSTTY_STYLE_UNDERLINE_SHIFT)) |
The bits of GhosttyStyleFlags that hold the underline style.
| #define GHOSTTY_STYLE_UNDERLINE_SHIFT 8 |
The lowest bit of the underline style in GhosttyStyleFlags.