TermBuf::Encoder
Stability: internal
Turns paint operations into terminal bytes, as few of them as it can.
The encoder carries the state the terminal has: where the cursor is and
what style is in force. That is what lets it drop a MoveTo that is
already true, pick the shortest of the half-dozen ways to move the cursor a
few columns, and emit an SGR delta instead of a reset plus everything.
It also holds the capability mask, and is the only place a style is narrowed to what the terminal can actually render. Colours are downgraded here rather than at write time, so the buffer keeps full fidelity and a later repaint against a wider mask comes out better.
Constants
Operating system command, which is how a hyperlink is introduced.
Attributes with a reset of their own.
Attributes that share a reset with a sibling: turning one off turns the whole group off, so any member that should survive has to be reasserted.
String terminator. The seven bit form, since a terminal that takes OSC 8 at all takes this.
Constructors
Instance methods
What the terminal can do. Colours and attributes outside this are downgraded or dropped rather than emitted.
Replaces the capability mask, discarding the style cache built under the old one.
Where the terminal's cursor is, or nil when it is not known and the
next move has to be absolute.
Where the terminal's cursor is, or nil when it is not known and the
next move has to be absolute.
The style as this terminal can actually render it: unsupported attributes dropped, colours narrowed to the deepest supported space.
Forgets where the cursor is without forgetting the style, so that the next move is absolute and the next run of text costs no SGR. What something writing its own cursor move between frames needs.
Says that something this encoder did not write has reached the terminal,
so any hyperlink it left open has to be closed before the next unlinked
text. What Terminal calls after a passthrough.
Emits the shortest sequence that puts the cursor at (x, y).
Forgets what the terminal was showing. The next operation re-establishes the cursor and the style from scratch, which is what a forced repaint needs.
Tells the encoder the screen changed size, and forgets where the cursor was.