struct TermBuf::Cell

Overview

One cell of the terminal grid.

Sixteen bytes, fixed size, with no reference to anything on the heap, so a Grid is one flat Slice(Cell) and a row is a Slice view into it.

A wide character occupies two cells: the first carries the character with #width two, and the second is a continuation with #width zero. Neither half is ever written without the other; Grid enforces that.

Defined in:

termbuf/core/cell.cr

Constructors

Instance Method Summary

Constructor Detail

def self.blank(style : StyleId = StyleTable::DEFAULT) : Cell #

An empty cell carrying style, which is what a cleared or scrolled-away part of the screen holds.


[View source]
def self.continuation(style : StyleId = StyleTable::DEFAULT) : Cell #

The second half of a wide character.


[View source]
def self.new(char : Char, style : StyleId = StyleTable::DEFAULT, width : UInt8 = 1_u8, cluster : UInt32 = ClusterPool::NONE) #

[View source]

Instance Method Detail

def blank? : Bool #

Whether the cell holds a space and nothing else, ignoring its style.


[View source]
def char : Char #

The cell's character, or '\0' when this cell continues a wide one. When #cluster is set, this is the cluster's first code point and the full text lives in the pool.


[View source]
def cluster : UInt32 #

ClusterPool id for a multi code point grapheme cluster, or ClusterPool::NONE when #char says everything.


[View source]
def continuation? : Bool #

Whether this is the right half of a wide character.


[View source]
def style : StyleId #

Id into the buffer's StyleTable.


[View source]
def text(pool : ClusterPool) : String #

The text this cell paints, resolving a cluster id through pool. Falls back to the base character if pool does not know the cluster, so that rendering a grid against the wrong pool degrades rather than raising.


[View source]
def to_s(io : IO) : Nil #
Description copied from struct Struct

Same as #inspect(io).


[View source]
def wide? : Bool #

Whether this is the left half of a wide character.


[View source]
def width : UInt8 #

Cells this character occupies: zero for a continuation, one for a narrow character, two for a wide one.


[View source]