Module: Tuile::Canvas::Backend

Included in:
Buffer
Defined in:
lib/tuile/canvas/backend.rb,
sig/tuile.rbs

Overview

Where a Tuile::Canvas's cells land: three primitives taking a fully resolved style. Include it to be one — Buffer does, and needs no adapter:

Canvas.new(screen.buffer)

A backend is dumb by contract: no theme, no component, no background chain, no translation, and no default arguments — the canvas resolves all of that and hands down a whole style at a coordinate in the backend's own grid. What varies here is only where the cells go; how a write is transformed on the way there belongs to the Tuile::Canvas, which is final. See D_canvas.

include, never prepend. A class's own methods win over an included module's, which is what lets Buffer carry this while defining all three itself; prepended, these bodies would sit ahead of the class and every write would raise.

Out-of-range writes are dropped, not raised — the terminal-edge clip belongs here, which is what lets a component paint a row the terminal is too narrow for without checking first.

Constant Summary collapse

StyledString =

Returns:

  • (:Style style)

Instance Method Summary collapse

Instance Method Details

#fill(rect, style) ⇒ void

This method returns an undefined value.

@param rect — in this backend's own grid.

@param style — fully resolved; only its bg shows.

Parameters:



43
# File 'lib/tuile/canvas/backend.rb', line 43

def fill(rect, style) = raise(NotImplementedError, "#{self.class}#fill")

#set_char(x, y, grapheme, style) ⇒ Object

@param x — column, in this backend's own grid.

@param y — row, likewise.

@param grapheme — one grapheme cluster.

@param style — fully resolved.



38
# File 'lib/tuile/canvas/backend.rb', line 38

def set_char(x, y, grapheme, style) = raise(NotImplementedError, "#{self.class}#set_char")

#set_text(x, y, styled) ⇒ void

This method returns an undefined value.

@param x — starting column, in this backend's own grid — the canvas has already applied its Tuile::Canvas#origin.

@param y — row, likewise.

@param styled — the text of one row; newlines are not handled.

Parameters:



31
# File 'lib/tuile/canvas/backend.rb', line 31

def set_text(x, y, styled) = raise(NotImplementedError, "#{self.class}#set_text")