TermBuf::Cursor
Stability: stable — changes only in a major release.
A place to write, and the state to write it in.
A cursor is where streamed output goes: it holds a position, a Style, and
the Region it lives inside, and it works out which cell each grapheme
cluster lands in as text arrives. Wrapping and scrolling happen against the
region's edges, so a cursor bound to a pane behaves like a small terminal
inside that pane.
It is not the terminal's own cursor. That one is a property of the device,
associated with a cursor of this kind through Terminal#hardware_cursor=
and moved to match it after each paint.
A cursor is application-side state and emits the same commands the drawing
API does, so it needs no privileged access to the buffer and works against
a Batcher as readily as against a Terminal. Nothing here is fibre-safe:
a cursor belongs to whoever made it.
Constructors
A cursor over the whole of a columns by rows screen.
A cursor writing into region of target, starting at the region's top
left. Terminal#cursor is the usual way in: it makes one of these and
hands it the buffer's own #policy, which a cursor built here does not
get.
Instance methods
Whether text running past the right edge continues on the next row.
With this off the cursor stops at the right margin and each further
character replaces the one standing there, which is what a terminal with
DECAWM reset does.
Whether text running past the right edge continues on the next row.
With this off the cursor stops at the right margin and each further
character replaces the one standing there, which is what a terminal with
DECAWM reset does.
An IO that writes here, so printf, Colorize, and anything else
expecting an IO can be pointed at a region of the screen.
Moves columns right and rows down, negative going the other way.
Puts the cursor at (x, y), in buffer coordinates, clamped to the
region. Coordinates are absolute everywhere in this shard, and a cursor
is no exception; #home is the one that speaks in the region's terms.
A carriage return and a line feed, which is what a \n does here: the
terminal is in raw mode, so nothing else is going to add the return.
How clusters are measured, which has to match what the buffer being
written to uses or the cursor and the cells disagree about where the next
character goes. Terminal#cursor sets it from the buffer's.
How clusters are measured, which has to match what the buffer being
written to uses or the cursor and the cells disagree about where the next
character goes. Terminal#cursor sets it from the buffer's.
Writes text, one grapheme cluster per cell, wrapping and scrolling at the region's edges.
Writes text, one grapheme cluster per cell, wrapping and scrolling at the region's edges.
Whether written text is scanned for escape sequences.
Off by default. Turn it on for an application that changes appearance by
assigning to #style and never writes an escape sequence of its own: the
scan is skipped outright, which is worth having on the path that carries
every character.
Whether written text is scanned for escape sequences.
Off by default. Turn it on for an application that changes appearance by
assigning to #style and never writes an escape sequence of its own: the
scan is skipped outright, which is worth having on the path that carries
every character.
Scrolls the region by lines, positive moving content up.
The vacated rows take the cursor's background and nothing else. Carrying the whole style would leave underlines and strike-throughs hanging in empty space, and dropping the background as well would punch holes in a tinted pane.
Whether a line feed on the bottom row scrolls the region. With this off the cursor stays on the bottom row and writing there overwrites it.
Whether a line feed on the bottom row scrolls the region. With this off the cursor stays on the bottom row and writing there overwrites it.
Columns between tab stops, measured from the region's left edge.
Writes UTF-8 bytes.
A character split by the end of bytes is held until the rest of it arrives, since a write boundary lands wherever the caller's buffer happened to fill.