TextElement

io.worxbend.tui.dsl.TextElement
final case class TextElement(content: String, overflow: Overflow = ..., alignment: Alignment = ..., props: ElementProps = ...) extends Element

A block of plain text; one row per newline-separated line.

Two things about how the text meets the edges of its area can be asked for here. Overflow decides what happens to a line longer than the area is wide: io.worxbend.tui.widgets.Overflow.Clip, the default, cuts it off at the right edge, while .wrapped breaks it onto as many rows as it needs. Alignment decides where a line shorter than the area sits: at the left edge by default, or in the middle with .centered, or against the right edge with .rightAligned.

Both were already parameters of the widgets.Paragraph this node renders through, but the node built that paragraph with the defaults and offered no way to say otherwise, so a paragraph of prose in the DSL was clipped at the first screen column it ran past and every heading had to be centred by hand with padding.

Wrapping also changes what the node claims from its container, and it has to: a wrapping paragraph does not want a column per character of its longest line — it wants whatever width it is given and however many rows that width makes it into. A clipping paragraph still claims its exact unwrapped box, which is what makes row(text("ab"), text("cd")) put the two next to each other rather than letting the first eat the row.

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Element
class Object
trait Matchable
class Any
Show all

Members list

Type members

Types

type Self = TextElement

This node's own type, so a fluent extension gives back what it was handed: progressBar(0.5).fill.bare type-checks because .fill returns a ProgressBarElement, not an abstract Element. Every concrete node fixes it to itself with one line, type Self = ThatNodeType.

This node's own type, so a fluent extension gives back what it was handed: progressBar(0.5).fill.bare type-checks because .fill returns a ProgressBarElement, not an abstract Element. Every concrete node fixes it to itself with one line, type Self = ThatNodeType.

Attributes

Value members

Concrete methods

def aligned(alignment: Alignment): TextElement

Positions each line within the area's width: left (the default), centre, or right.

Positions each line within the area's width: left (the default), centre, or right.

Attributes

Centres every line in the area — the alignment a title or a placeholder message usually wants.

Centres every line in the area — the alignment a title or a placeholder message usually wants.

Attributes

Cuts each line at the right edge of the area, the default. Undoes a .wrapped on an element built elsewhere.

Cuts each line at the right edge of the area, the default. Undoes a .wrapped on an element built elsewhere.

Attributes

override def debugName: String

The factory-style name of this node — panel, button, scrollView — for the element-tree snapshot and any other diagnostic that has to say what a node is without reflecting over its class. Every node type declares its own; a decorator answers with the name of the node it wraps. The default is only there so a node added without one still renders — ElementTreeSnapshotSpec fails the build until the override is written.

The factory-style name of this node — panel, button, scrollView — for the element-tree snapshot and any other diagnostic that has to say what a node is without reflecting over its class. Every node type declares its own; a decorator answers with the name of the node it wraps. The default is only there so a node added without one still renders — ElementTreeSnapshotSpec fails the build until the override is written.

Attributes

Definition Classes

Every line pinned to the left edge — the default, spelled out; undoes a .centered on an element built elsewhere.

Every line pinned to the left edge — the default, spelled out; undoes a .centered on an element built elsewhere.

Attributes

Pushes every line against the right edge, for a column of numbers or a right-hand caption.

Pushes every line against the right edge, for a column of numbers or a right-hand caption.

Attributes

Breaks lines that do not fit onto further rows instead of cutting them off at the right edge.

Breaks lines that do not fit onto further rows instead of cutting them off at the right edge.

The break happens at a grapheme-cluster boundary — never inside a wide character, an emoji or a combining sequence — rather than at a word boundary, so a long word is split across rows rather than moved down whole.

Attributes

Inherited methods

def accessibleName: String

What this node is called when it is announced — button Save, checkbox agree — before the interaction states ElementHost.accessibleLabel appends. Defaults to debugName; a node with a label of its own says it.

What this node is called when it is announced — button Save, checkbox agree — before the interaction states ElementHost.accessibleLabel appends. Defaults to debugName; a node with a label of its own says it.

Attributes

Inherited from:
Element
def children: Seq[Element]

Attributes

Inherited from:
Element
def pointerShape: Option[PointerShape]

The mouse pointer this node wants shown over it, when it wants one: the hand over a button or a link, the I-beam over a text field. None leaves the pointer as it is. An explicit .pointer(shape) on the node lands in props.pointerShape and takes precedence; the interactive nodes override this with their own default.

The mouse pointer this node wants shown over it, when it wants one: the hand over a button or a link, the I-beam over a text field. None leaves the pointer as it is. An explicit .pointer(shape) on the node lands in props.pointerShape and takes precedence; the interactive nodes override this with their own default.

Attributes

Inherited from:
Element
def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product
def style(style: Style): Self

This element with style as its own — the content style on every node: a text's text, a list's body, a panel's children and inner area. A container's border is frameStyle instead. The fluent builders (.fg, .bold, .styled(...)) edit the same style rather than replacing it.

This element with style as its own — the content style on every node: a text's text, a list's body, a panel's children and inner area. A container's border is frameStyle instead. The fluent builders (.fg, .bold, .styled(...)) edit the same style rather than replacing it.

Attributes

Inherited from:
Element
def style: Style

Attributes

Inherited from:
Element

Concrete fields

lazy val widget: Widget