class
TermBuf::StyleTable
- TermBuf::StyleTable
- Reference
- Object
Overview
Interns styles so a Cell can carry a four byte id rather than the whole
struct.
Two cells with equal styles always get the same id, which turns the paint diff's style comparison into an integer compare and lets the encoder cache one SGR byte string per id.
The table only grows. An application cycling through distinct styles — an animated colour gradient, say — accumulates entries at roughly 32 bytes each; a hundred thousand of them costs a few megabytes. Real applications use tens.
Defined in:
termbuf/core/style_table.crConstant Summary
-
DEFAULT =
0_u32 -
The id of
Style::DEFAULT, which every table assigns first.
Constructors
Instance Method Summary
-
#[](id : StyleId) : Style
The style id refers to.
-
#[]?(id : StyleId) : Style | Nil
The style id refers to, or
nilif it was never assigned. -
#each(& : StyleId, Style -> ) : Nil
Yields every interned style with its id, in the order they were added.
-
#id(style : Style) : StyleId
The id for style, assigning one if this is the first time it is seen.
-
#size : Int32
Number of distinct styles interned so far.
Constructor Detail
Instance Method Detail
The style id refers to, or nil if it was never assigned.
Yields every interned style with its id, in the order they were added.
The id for style, assigning one if this is the first time it is seen.