io.worxbend.tui.core

Members list

Type members

Classlikes

final case class AdaptiveColor(light: Color, dark: Color)

A pair of colors picked by the terminal's background: light on a light terminal, dark on a dark one (Lip Gloss's AdaptiveColor). Resolve it against the theme or a detected background before styling — the render path only ever sees a concrete Color.

A pair of colors picked by the terminal's background: light on a light terminal, dark on a dark one (Lip Gloss's AdaptiveColor). Resolve it against the theme or a detected background before styling — the render path only ever sees a concrete Color.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final class Buffer(val area: Rect)

A mutable grid of Cells covering area, the in-memory render target for one frame.

A mutable grid of Cells covering area, the in-memory render target for one frame.

x/y arguments are absolute terminal coordinates (the same space as area's offset), not area-relative — widgets receive a Rect positioned in absolute space and write to the buffer at those coordinates. Writes outside area are silently clipped, never errors; reads outside area return Cell.Empty.

Mutability is an implementation detail of the render loop — it never escapes through Widget.render's contract.

Attributes

Supertypes
class Object
trait Matchable
class Any
final case class Cell(symbol: String, style: Style)

One rendered terminal cell.

One rendered terminal cell.

symbol is a String, not a Char, because a cell can hold a multi-codepoint grapheme cluster (combining characters, emoji ZWJ sequences). A wide (two-column) grapheme lives in its left cell; the cell to its right is a continuation filler that backends skip when flushing.

That filler is an ordinary Cell.Empty — a Cell carries no continuation state of its own. It is Buffer that records which of its cells are fillers, so the same value means "blank" in one position and "the right half of the grapheme next door" in another.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Cell

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Cell.type
object CharWidth

Terminal display-width arithmetic.

Terminal display-width arithmetic.

String.length counts UTF-16 code units, not terminal columns: CJK characters occupy two columns, combining marks occupy none, and one emoji ZWJ sequence can span many codepoints yet occupy two columns. All layout and rendering math in this library must go through this object — no code outside it may use String.length or String.substring for anything that affects layout.

Widths are derived from the Unicode Character Database: East Asian Width W/F codepoints (see WidthTable) are two columns; combining marks, format controls, and conjoining Hangul jamo are zero; everything else is one. Variation selectors override the base width — VS16 forces emoji presentation (two columns), VS15 text presentation (one) — but only after a base that has both presentations; after a letter or an ideograph they are inert. A regional-indicator pair (flag emoji) is two.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
CharWidth.type
enum Color

A terminal color: the 16 named ANSI colors (8 standard + 8 bright), a 24-bit RGB value, or a 256-color palette index.

A terminal color: the 16 named ANSI colors (8 standard + 8 bright), a 24-bit RGB value, or a 256-color palette index.

Reset restores the terminal's default foreground/background rather than naming a concrete color. The Bright* variants map to the SGR 90–97 / 100–107 codes; terminals downsample them to the standard 8 when they cannot show 16.

Attributes

Companion
object
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Color

Attributes

Companion
enum
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Color.type
enum Constraint

How much of a split axis one segment claims (see Layout.split).

How much of a split axis one segment claims (see Layout.split).

Length/Percentage/Ratio are fixed demands; Min is a floor that also competes for leftover space; Max is a cap that only takes leftover space; Fill divides leftover space by weight.

Attributes

Companion
object
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Constraint

Attributes

Companion
enum
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Constraint.type
enum Direction

The axis a Layout splits along: Horizontal divides an area into columns, Vertical into rows.

The axis a Layout splits along: Horizontal divides an area into columns, Vertical into rows.

It names the axis the constraints apply to, not the direction content flows — a Horizontal layout gives every segment the full height of the area and shares its width.

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
enum Event

Everything a running application can receive from its event source.

Everything a running application can receive from its event source.

Key/Mouse/Resize originate from the terminal backend; Tick is synthetic, injected by the runtime's runner at its configured tick rate — it lives in this ADT because consumers pattern-match all four together.

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
enum Flex

How a Layout distributes any space its segments do not consume (ratatui's Flex).

How a Layout distributes any space its segments do not consume (ratatui's Flex).

Flex only has an effect when the constraints leave leftover space — i.e. there is no Fill/Min greedily absorbing it. With such a growing constraint present the leftover is zero and every mode behaves like Flex.Start.

  • Start — pack segments at the start; leftover trails at the end (the default).
  • End — pack at the end; leftover leads at the start.
  • Center — center the block; leftover splits evenly before and after.
  • SpaceBetween — first and last segments touch the edges; leftover splits between segments.
  • SpaceAround — equal space around each segment (edges get a half-gap).
  • SpaceEvenly — equal space in every gap including both edges.

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
enum KeyCode

The key a key event reports: a printable character, a named editing/navigation key, or a function key.

The key a key event reports: a printable character, a named editing/navigation key, or a function key.

Char carries a Unicode code point, not a UTF-16 code unit, so keys outside the Basic Multilingual Plane (emoji, historic scripts) survive input decoding intact. KeyCode.Char('q') still compiles — a scala.Char widens to Int in both expression and pattern position — but code that binds the payload receives an Int; use text or Character.toString(codePoint) to turn it back into printable text.

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class KeyEvent(code: KeyCode, modifiers: KeyModifiers)

A key press: which key, plus the modifier keys held.

A key press: which key, plus the modifier keys held.

A standalone case class rather than an Event enum case so handler signatures like KeyEvent => Boolean can take exactly the key payload without partially matching an Event.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object KeyEvent

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
KeyEvent.type
object KeyModifiers

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
final case class Layout(direction: Direction, constraints: Seq[Constraint], spacing: Int, flex: Flex)

Splits a rectangle into segments along one axis according to a list of Constraints.

Splits a rectangle into segments along one axis according to a list of Constraints.

Solving happens in two passes: fixed demands first (Length, Percentage, Ratio, and Min's floor), then any leftover space is shared among the flexible constraints (Fill by weight, Min and Max with weight 1, Max additionally capped). Sizes use integer cells; distribution remainders go to the earliest segments with the largest fractional share, so results are deterministic. When the fixed demands exceed the available space, trailing segments are truncated (possibly to zero width) rather than failing — consistent with the library-wide silent-clipping philosophy.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Layout

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Layout.type
final case class Line(spans: Seq[Span])

One horizontal line of styled text, a sequence of differently-styled Spans.

One horizontal line of styled text, a sequence of differently-styled Spans.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Line

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Line.type
object Modifiers

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Modifiers.type
final case class MouseEvent(x: Int, y: Int, kind: MouseEventKind, modifiers: KeyModifiers)

A mouse action at an absolute terminal position.

A mouse action at an absolute terminal position.

Attributes

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

What the mouse did.

What the mouse did.

Drag is motion with a button held; Moved is motion with none. The terminal backend requests button-event tracking (DEC modes 1000/1002/1006), under which terminals only report motion while a button is down — so Moved is part of the vocabulary but no decoder in this library currently produces it.

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class Position(x: Int, y: Int)

An absolute terminal coordinate: x is the column, y the row, both zero-based.

An absolute terminal coordinate: x is the column, y the row, both zero-based.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class Rect(x: Int, y: Int, width: Int, height: Int)

A rectangular region of the terminal in absolute coordinates.

A rectangular region of the terminal in absolute coordinates.

x/y locate the top-left corner; the region spans width columns and height rows. The right and bottom edges (x + width, y + height) are exclusive.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Rect

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Rect.type
final case class Size(width: Int, height: Int)

A terminal extent in cells: width columns by height rows.

A terminal extent in cells: width columns by height rows.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class Span(content: String, style: Style)

A run of text rendered with a single Style.

A run of text rendered with a single Style.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Span

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Span.type
trait StatefulWidget[S]

A widget whose rendering reads mutable state owned by the caller (scroll offsets, selections).

A widget whose rendering reads mutable state owned by the caller (scroll offsets, selections).

The widget value itself stays immutable and reusable; all per-instance mutability lives in S, which the application owns and passes in at render time.

Attributes

Supertypes
class Object
trait Matchable
class Any
final case class Style(fg: Option[Color], bg: Option[Color], modifiers: Modifiers, link: Option[String], underlineColor: Option[Color], underlineStyle: UnderlineStyle)

How a cell is drawn: optional foreground/background colors plus text-attribute modifiers.

How a cell is drawn: optional foreground/background colors plus text-attribute modifiers.

None for a color means "leave the terminal default in effect". Builders return a new immutable Style; they are with-prefixed for the color fields because a case-class field and a def cannot share a name.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Style

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Style.type
final case class Text(lines: Seq[Line])

Multi-line styled text.

Multi-line styled text.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Text

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Text.type

The line drawn under a cell's glyph, independent of the plain underline modifier.

The line drawn under a cell's glyph, independent of the plain underline modifier.

Straight mirrors the classic Modifiers.Underline; the richer variants use the colon-parameterised SGR 4 extension (4:24:5) that modern terminals (kitty, VTE, WezTerm, iTerm2) understand and older ones ignore.

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
trait Widget

Something that can draw itself into a region of a frame buffer.

Something that can draw itself into a region of a frame buffer.

A single abstract method, so any (area, buffer) => () lambda is a valid widget. Implementations must confine their writes to area (the buffer clips stray writes, but relying on that is a defect) and must route all width/truncation math through CharWidth.

Attributes

Supertypes
class Object
trait Matchable
class Any

Types

opaque type KeyModifiers

Modifier keys held during a key or mouse event, packed into an Int bitset (same pattern as Modifiers).

Modifier keys held during a key or mouse event, packed into an Int bitset (same pattern as Modifiers).

Attributes

opaque type Modifiers

Text-attribute flags (bold, italic, …) packed into an Int bitset.

Text-attribute flags (bold, italic, …) packed into an Int bitset.

An opaque bitset rather than a Set[Modifier] on purpose: Style values are created per-cell, potentially thousands of times per frame, so Style must stay a small value with no boxed collection inside.

Attributes