class

TUI::Widget

Inherits Reference < Object

Constructors

new(x : Int32, y : Int32, width : Int32, height : Int32)
Source

Instance methods

absolute(row : Int32, col : Int32) : NamedTuple(row: Int32, col: Int32)

Translate a LOCAL (row, col) offset — as used by render's own coordinate space, e.g. Form#cursor_offset — into absolute 1-based terminal coordinates suitable for Term.move. Mirrors the arithmetic composite already performs internally via Screen#blit.

Source
composite(screen : Screen) : Nil

Called by the compositor (App) once per frame instead of render. Owns the buffer lifecycle: resizes/clears it, invokes the subclass's render, then blits the result onto the screen at (x, y).

Source
focus_if(condition : Bool) : Nil

The recommended way to manage focus when multiple widgets are visible at once: recompute it every frame from whatever state determines which widget is active (e.g. table_list.focus_if(nav.current.is_a?(NavTableList))) rather than mutating focused= incrementally at scattered call sites.

Source
focused=(focused : Bool)
Source
focused?
Source
handle_key(ev : KeyEvent) : Bool

Returns true if the key was consumed.

Source
height
Source
height=(height : Int32)
Source
local(row : Int32, col : Int32) : NamedTuple(row: Int32, col: Int32)

Inverse of #absolute: translate an ABSOLUTE 1-based terminal coordinate (e.g. a KeyEvent's mouse row/col) into this widget's LOCAL coordinate space. Result may fall outside [0, width)/[0, height) if the point is outside this widget's bounds — callers should bounds-check.

Source
render

Draw into @buffer using LOCAL coordinates (0, 0 = this widget's own top-left). Widgets never need to know their own x/y offset to draw themselves — that arithmetic is handled entirely by composite.

Source
render_to(buffer : Buffer) : Nil

Draws this widget into an arbitrary caller-supplied buffer instead of the screen — for a host that owns its own composed buffer rather than the real screen (e.g. ScrollableWidget, adapting a plain Widget into a SplitWindow pane, which only blits Scrollable content into a sub-buffer it controls). buffer must already be sized to width/height; unlike #composite this never blits anywhere itself, leaving that to the caller.

Source
status_hint

Plain text describing the actions available in the widget's current state. Rendered by the App in the global status bar at the bottom of the screen — widgets must NOT draw their own hint lines.

Source
width
Source
width=(width : Int32)
Source
x

1-based absolute terminal coordinates and size of this widget within the compositor (see #composite/Screen#blit) — never touched by the widget's own #render, which always draws in its own local (0, 0) space. focused? gates whether this widget's #handle_key should be given a chance to consume the current event; toggle it via #focus_if.

Source
x=(x : Int32)

1-based absolute terminal coordinates and size of this widget within the compositor (see #composite/Screen#blit) — never touched by the widget's own #render, which always draws in its own local (0, 0) space. focused? gates whether this widget's #handle_key should be given a chance to consume the current event; toggle it via #focus_if.

Source
y=(y : Int32)
Source