class

TermBuf::StyleTable

Inherits Reference < Object

Stability: internal

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.

Constants

DEFAULT = 0_u32

The id of Style::DEFAULT, which every table assigns first.

Constructors

Instance methods

[](id : StyleId) : Style

The style id refers to.

Source
[]?(id : StyleId) : Style | Nil

The style id refers to, or nil if it was never assigned.

Source
each

Yields every interned style with its id, in the order they were added.

Source
id(style : Style) : StyleId

The id for style, assigning one if this is the first time it is seen.

Source
size

Number of distinct styles interned so far.

Source