ui

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2026 License: MIT, Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package ui provides a Flutter-inspired widget, layout, and painting layer for terminal applications built with Vaxis.

Most applications start with Run:

err := ui.Run(ui.Text{Value: "hello"})

Widgets are immutable descriptions of UI. Stateful widgets create State values, call StateBase.SetState to schedule rebuilds, and return more widgets from Build. Built-in text inputs are controlled widgets: the Value field is the source of truth, and OnChanged is responsible for storing the next value in application state.

Build methods and lazy row builders should stay cheap. Cache expensive derived data, such as syntax-highlighted lines or parsed document structure, in State and invalidate that cache from StateUpdater.DidUpdateWidget or when theme-dependent inputs change. Builders may run often during scrolling, layout correction, and resize handling, so they should usually select from already-prepared data rather than recomputing whole-document results.

Layout flows through render objects using Constraints and Size in terminal cells. A widget that needs custom measurement or painting can implement RenderObjectWidget and produce a RenderObject; ordinary applications usually compose the built-in widgets instead.

Run uses the default Vaxis backend. Tests and integrations can use App, Runner, and Backend directly to drive events and frames without owning the terminal event loop.

Use WithPrimaryScreen or WithDynamicPrimaryScreen when the application should keep terminal scrollback instead of entering the alternate screen. In primary-screen mode the root widget is rendered into a live region, and event handlers can write normal terminal output before that region:

err := ui.Run(root, ui.WithDynamicPrimaryScreen())

button := ui.Button{Label: "log", OnPressed: func(ctx ui.EventContext) {
	ctx.AppendWidget(ui.Text{Value: "clicked"})
}}

Append, AppendString, AppendWriter, AppendText, AppendTextLn, and AppendWidget are available through EventContext when the backend supports primary-screen appends. AppendText writes styled inline spans without layout, so text can reflow naturally in terminal scrollback. AppendWidget appends a rendered snapshot, so soft-wrapped widget text becomes hard line breaks at the current terminal width.

Index

Examples

Constants

View Source
const (
	// MouseLeftButton aliases vaxis.MouseLeftButton.
	MouseNoButton     = vaxis.MouseNoButton
	MouseLeftButton   = vaxis.MouseLeftButton
	MouseMiddleButton = vaxis.MouseMiddleButton
	MouseRightButton  = vaxis.MouseRightButton
	MouseWheelUp      = vaxis.MouseWheelUp
	MouseWheelDown    = vaxis.MouseWheelDown
	MouseWheelLeft    = vaxis.MouseWheelLeft
	MouseWheelRight   = vaxis.MouseWheelRight
	// EventPress aliases vaxis.EventPress.
	EventPress   = vaxis.EventPress
	EventRelease = vaxis.EventRelease
	EventMotion  = vaxis.EventMotion
	// DarkMode aliases vaxis.DarkMode.
	DarkMode = vaxis.DarkMode
	// LightMode aliases vaxis.LightMode.
	LightMode = vaxis.LightMode
	// KeyBackspace aliases vaxis.KeyBackspace.
	KeyBackspace = vaxis.KeyBackspace
	KeyDelete    = vaxis.KeyDelete
	KeyLeft      = vaxis.KeyLeft
	KeyUp        = vaxis.KeyUp
	KeyRight     = vaxis.KeyRight
	KeyDown      = vaxis.KeyDown
	KeyPgDown    = vaxis.KeyPgDown
	KeyPgUp      = vaxis.KeyPgUp
	KeyHome      = vaxis.KeyHome
	KeyEnd       = vaxis.KeyEnd
)
View Source
const (
	// AttrNone aliases vaxis.AttrNone.
	AttrNone          = vaxis.AttrNone
	AttrBold          = vaxis.AttrBold
	AttrDim           = vaxis.AttrDim
	AttrItalic        = vaxis.AttrItalic
	AttrBlink         = vaxis.AttrBlink
	AttrReverse       = vaxis.AttrReverse
	AttrInvisible     = vaxis.AttrInvisible
	AttrStrikethrough = vaxis.AttrStrikethrough
	AttrOverline      = vaxis.AttrOverline
)
View Source
const (
	// UnderlineOff aliases vaxis.UnderlineOff.
	UnderlineOff    = vaxis.UnderlineOff
	UnderlineSingle = vaxis.UnderlineSingle
	UnderlineDouble = vaxis.UnderlineDouble
	UnderlineCurly  = vaxis.UnderlineCurly
	UnderlineDotted = vaxis.UnderlineDotted
	UnderlineDashed = vaxis.UnderlineDashed
)
View Source
const (
	// MouseShapeDefault aliases vaxis.MouseShapeDefault.
	MouseShapeDefault          = vaxis.MouseShapeDefault
	MouseShapeContextMenu      = vaxis.MouseShapeContextMenu
	MouseShapeTextInput        = vaxis.MouseShapeTextInput
	MouseShapeVerticalText     = vaxis.MouseShapeVerticalText
	MouseShapeClickable        = vaxis.MouseShapeClickable
	MouseShapeHelp             = vaxis.MouseShapeHelp
	MouseShapeBusyBackground   = vaxis.MouseShapeBusyBackground
	MouseShapeBusy             = vaxis.MouseShapeBusy
	MouseShapeAlias            = vaxis.MouseShapeAlias
	MouseShapeCopy             = vaxis.MouseShapeCopy
	MouseShapeMove             = vaxis.MouseShapeMove
	MouseShapeNoDrop           = vaxis.MouseShapeNoDrop
	MouseShapeNotAllowed       = vaxis.MouseShapeNotAllowed
	MouseShapeGrab             = vaxis.MouseShapeGrab
	MouseShapeGrabbing         = vaxis.MouseShapeGrabbing
	MouseShapeAllScroll        = vaxis.MouseShapeAllScroll
	MouseShapeCrosshair        = vaxis.MouseShapeCrosshair
	MouseShapeResizeColumn     = vaxis.MouseShapeResizeColumn
	MouseShapeResizeRow        = vaxis.MouseShapeResizeRow
	MouseShapeResizeNorth      = vaxis.MouseShapeResizeNorth
	MouseShapeResizeEast       = vaxis.MouseShapeResizeEast
	MouseShapeResizeSouth      = vaxis.MouseShapeResizeSouth
	MouseShapeResizeWest       = vaxis.MouseShapeResizeWest
	MouseShapeResizeNorthEast  = vaxis.MouseShapeResizeNorthEast
	MouseShapeResizeNorthWest  = vaxis.MouseShapeResizeNorthWest
	MouseShapeResizeSouthEast  = vaxis.MouseShapeResizeSouthEast
	MouseShapeResizeSouthWest  = vaxis.MouseShapeResizeSouthWest
	MouseShapeResizeHorizontal = vaxis.MouseShapeResizeHorizontal
	MouseShapeResizeVertical   = vaxis.MouseShapeResizeVertical
	MouseShapeResizeNESW       = vaxis.MouseShapeResizeNESW
	MouseShapeResizeNWSE       = vaxis.MouseShapeResizeNWSE
	MouseShapeZoomIn           = vaxis.MouseShapeZoomIn
	MouseShapeZoomOut          = vaxis.MouseShapeZoomOut
	MouseShapeCell             = vaxis.MouseShapeCell
)
View Source
const (
	// CursorDefault aliases vaxis.CursorDefault.
	CursorDefault           = vaxis.CursorDefault
	CursorBlockBlinking     = vaxis.CursorBlockBlinking
	CursorBlock             = vaxis.CursorBlock
	CursorUnderlineBlinking = vaxis.CursorUnderlineBlinking
	CursorUnderline         = vaxis.CursorUnderline
	CursorBeamBlinking      = vaxis.CursorBeamBlinking
	CursorBeam              = vaxis.CursorBeam
)
View Source
const DefaultFrameInterval = time.Second / 60

DefaultFrameInterval is the default 60Hz frame pacing interval.

View Source
const Unbounded = math.MaxInt

Unbounded marks an unconstrained maximum size.

Variables

View Source
var (
	// TopLeft aligns a child to the top-left corner.
	TopLeft = Alignment{X: -1, Y: -1}
	// TopCenter aligns a child to the top edge.
	TopCenter = Alignment{X: 0, Y: -1}
	// TopRight aligns a child to the top-right corner.
	TopRight = Alignment{X: 1, Y: -1}
	// CenterLeft aligns a child to the left edge.
	CenterLeft = Alignment{X: -1, Y: 0}
	// CenterAlign centers a child on both axes.
	CenterAlign = Alignment{X: 0, Y: 0}
	// CenterRight aligns a child to the right edge.
	CenterRight = Alignment{X: 1, Y: 0}
	// BottomLeft aligns a child to the bottom-left corner.
	BottomLeft = Alignment{X: -1, Y: 1}
	// BottomCenter aligns a child to the bottom edge.
	BottomCenter = Alignment{X: 0, Y: 1}
	// BottomRight aligns a child to the bottom-right corner.
	BottomRight = Alignment{X: 1, Y: 1}
)

Functions

func DefaultFuzzySelectFilter

func DefaultFuzzySelectFilter[T any](query string, items []T, item FuzzySelectItemFunc[T]) []T

DefaultFuzzySelectFilter filters items with title-weighted fuzzy matching.

func Depend

func Depend[T any](ctx BuildContext) (T, bool)

Depend returns the nearest provided value of type T and subscribes ctx to updates.

func EaseInOut

func EaseInOut(t float64) float64

EaseInOut returns a smoothstep curve for t clamped to the animation progress range.

func Linear

func Linear(t float64) float64

Linear returns t clamped to the animation progress range.

func MustDepend

func MustDepend[T any](ctx BuildContext) T

MustDepend returns the nearest provided value of type T or panics.

func Run

func Run(root Widget, opts ...Option) error

Run creates a vaxis-backed app for root and blocks until it exits.

Example
package main

import (
	"github.com/memcode-ai/memcode/internal/forks/vaxis/ui"
)

func main() {
	_ = ui.Run(ui.Center(ui.Text{Value: "hello"}))
}

Types

type ActionFunc

type ActionFunc func(EventContext, Intent) EventResult

ActionFunc handles an intent.

type Actions

type Actions struct {
	// Bindings maps intent types to handlers.
	Bindings map[IntentType]ActionFunc
	// Child is the subtree that can invoke these actions.
	Child Widget
}

Actions provides overridable intent handlers for its subtree.

When a descendant invokes an intent, the nearest matching Actions handler wins over any DefaultActions handler provided by the widget itself.

func (Actions) CreateElement

func (w Actions) CreateElement() element

type ActivateIntent

type ActivateIntent struct{}

ActivateIntent activates the focused control.

func (ActivateIntent) IntentType

func (ActivateIntent) IntentType() IntentType

type Align

type Align struct {
	// Alignment controls where the child is placed.
	Alignment Alignment
	// Child is laid out loosely within the available space.
	Child Widget
}

Align positions its child within the space allowed by its parent.

func (Align) CreateRenderObject

func (w Align) CreateRenderObject(ctx BuildContext) RenderObject

func (Align) UpdateRenderObject

func (w Align) UpdateRenderObject(ctx BuildContext, ro RenderObject)

func (Align) WidgetChild

func (w Align) WidgetChild() Widget

type Alignment

type Alignment struct{ X, Y int }

Alignment describes child placement within extra horizontal and vertical space.

type AnimationController

type AnimationController struct {
	// contains filtered or unexported fields
}

AnimationController drives frame-scheduled animation progress for a StateBase.

func (*AnimationController) Forward

func (c *AnimationController) Forward()

Forward starts the animation using the current wall-clock time.

func (*AnimationController) ForwardAt

func (c *AnimationController) ForwardAt(now time.Time)

ForwardAt starts the animation using now as its start time.

func (*AnimationController) RawValue

func (c *AnimationController) RawValue() float64

RawValue returns the uncurved animation progress.

func (*AnimationController) Reset

func (c *AnimationController) Reset()

Reset stops the animation and returns it to 0.

func (*AnimationController) Running

func (c *AnimationController) Running() bool

Running reports whether the controller is currently advancing.

func (*AnimationController) Status

Status returns the controller's current lifecycle state.

func (*AnimationController) Stop

func (c *AnimationController) Stop()

Stop pauses a running animation at its current value.

func (*AnimationController) Value

func (c *AnimationController) Value() float64

Value returns the curved animation progress.

type AnimationOptions

type AnimationOptions struct {
	// Duration is the time from progress 0 to progress 1.
	Duration time.Duration
	// Curve maps raw progress to the value returned by AnimationController.Value.
	Curve Curve
}

AnimationOptions configures a state-owned animation controller.

type AnimationStatus

type AnimationStatus int

AnimationStatus describes the lifecycle state of an animation controller.

const (
	// AnimationIdle indicates that the controller is stopped at its current value.
	AnimationIdle AnimationStatus = iota
	// AnimationForward indicates that the controller is advancing toward 1.
	AnimationForward
	// AnimationCompleted indicates that the controller reached the end value.
	AnimationCompleted
)

type App

type App struct {
	// contains filtered or unexported fields
}

App owns a widget tree and dispatches events, layout, painting, and focus.

func NewApp

func NewApp(root Widget, opts ...Option) *App

NewApp creates an app mounted with root.

func (*App) DebugSnapshot

func (a *App) DebugSnapshot() DebugSnapshot

DebugSnapshot returns a development snapshot of the mounted widget/render tree.

func (*App) FrameRequested

func (a *App) FrameRequested() bool

FrameRequested reports whether the app needs another frame.

func (*App) MouseShape

func (a *App) MouseShape() MouseShape

MouseShape returns the current requested pointer shape.

func (*App) Paint

func (a *App) Paint(p *Painter)

Paint paints the current render tree into p.

func (*App) ProfileOverlay

func (a *App) ProfileOverlay() bool

ProfileOverlay reports whether the profiling overlay is visible.

func (*App) Pump

func (a *App) Pump(size Size)

Pump rebuilds and lays out the widget tree for size.

func (*App) RequestFrame

func (a *App) RequestFrame()

RequestFrame marks the app as needing another frame.

func (*App) Send

func (a *App) Send(ev Event)

Send dispatches ev through the widget tree.

func (*App) SetProfileOverlay

func (a *App) SetProfileOverlay(visible bool)

SetProfileOverlay shows or hides the profiling overlay.

func (*App) SetScrollbackAppenders

func (a *App) SetScrollbackAppenders(appendBytes func([]byte), appendStr func(string), appendWriter func() io.Writer)

SetScrollbackAppenders installs scrollback append functions directly, bypassing the normal Runner/Backend wiring. It exists for lightweight harnesses (see ui/uitest) that pump/paint a widget tree without a real backend attached — so a code path that writes to scrollback (a slash-command echo, sysln, etc.) captures instead of hitting the "without primary screen support" panic. A nil argument leaves that appender untouched.

func (*App) SetTheme

func (a *App) SetTheme(theme Theme)

SetTheme replaces the app theme and rebuilds theme dependents.

func (*App) SetThemeMode

func (a *App) SetThemeMode(mode ThemeMode) bool

SetThemeMode switches to the matching theme from a ThemeSet, if configured.

func (*App) ShouldQuit

func (a *App) ShouldQuit() bool

ShouldQuit reports whether a quit request has been made.

func (*App) ToggleProfileOverlay

func (a *App) ToggleProfileOverlay() bool

ToggleProfileOverlay toggles the profiling overlay and returns its new state.

func (*App) UpdateRoot

func (a *App) UpdateRoot(root Widget)

UpdateRoot replaces the root widget while preserving compatible elements.

type AttributeMask

type AttributeMask = vaxis.AttributeMask

AttributeMask aliases vaxis.AttributeMask for convenience in ui code.

type Axis

type Axis int

Axis identifies the main direction for a Flex.

const (
	// Horizontal lays out children from left to right.
	Horizontal Axis = iota
	// Vertical lays out children from top to bottom.
	Vertical
)

type Backend

type Backend interface {
	Events() <-chan Event
	Size() Size
	Render(*Painter) error
	Dispatch(func())
	SetMouseShape(MouseShape)
	Close() error
}

Backend is the runtime boundary between ui and a terminal implementation.

type BaseColors

type BaseColors struct {
	Black   Color
	Red     Color
	Green   Color
	Yellow  Color
	Blue    Color
	Magenta Color
	Cyan    Color
	White   Color
}

BaseColors is the compact color input used to generate a Palette.

func DefaultBaseColors

func DefaultBaseColors() BaseColors

DefaultBaseColors returns the built-in vaxis/ui base colors.

type BoolChangedCallback

type BoolChangedCallback func(EventContext, bool)

BoolChangedCallback receives a boolean control value change.

type Border

type Border struct {
	// Style is used to draw border cells.
	Style Style
	// Top, Right, Bottom, and Left enable individual border edges.
	Top, Right, Bottom, Left bool
	// Chars customizes the border drawing characters.
	Chars BorderChars
}

Border describes which edges of a box should be drawn.

func BorderAll

func BorderAll(style Style) Border

BorderAll creates a border on every edge using style.

func BorderLine

func BorderLine(color Color) Border

BorderLine creates a one-cell border using color as the foreground.

type BorderChars

type BorderChars struct {
	// Horizontal and Vertical draw straight border edges.
	Horizontal, Vertical Character
	// TopLeft and TopRight draw the top corners.
	TopLeft, TopRight Character
	// BottomLeft and BottomRight draw the bottom corners.
	BottomLeft, BottomRight Character
}

BorderChars customizes the characters used to draw a border.

type BuildContext

type BuildContext struct {
	// contains filtered or unexported fields
}

BuildContext exposes tree-local services while building widgets.

func (BuildContext) EventContext

func (c BuildContext) EventContext() EventContext

EventContext returns an event context rooted at this build context's element.

This is useful for asynchronous widget callbacks that need to perform the same side effects available during event handling, such as notifications, title updates, or quitting the app.

func (BuildContext) FindRenderObject

func (c BuildContext) FindRenderObject() RenderObject

FindRenderObject returns the nearest render object for this context.

func (BuildContext) Runtime

func (c BuildContext) Runtime() Runtime

Runtime returns a dispatcher for scheduling work on the UI event loop.

func (BuildContext) Widget

func (c BuildContext) Widget() Widget

Widget returns the widget currently being built.

type Button

type Button struct {
	// Label is the text shown inside the button.
	Label string
	// OnPressed is called when the button is activated.
	OnPressed VoidCallback
	// Padding overrides the default button padding when non-zero.
	Padding Insets
	// MinWidth overrides the default button minimum width when greater than zero.
	MinWidth int
}

Button is a focusable control that invokes OnPressed on click, Enter, or Space.

func (Button) CreateState

func (w Button) CreateState() State

type ButtonTheme

type ButtonTheme struct {
	Normal         Style
	Focused        Style
	Hovered        Style
	FocusedHovered Style
	Pressed        Style
	Padding        Insets
	MinWidth       int
	Mouse          MouseShape
	FocusLeft      Character
	FocusRight     Character
}

ButtonTheme contains derived styling and sizing defaults for Button.

type Cell

type Cell = vaxis.Cell

Cell aliases vaxis.Cell for convenience in ui code.

type Character

type Character = vaxis.Character

Character aliases vaxis.Character for convenience in ui code.

type Checkbox

type Checkbox struct {
	// Checked controls whether the checkbox is painted as selected.
	Checked bool
	// Disabled prevents focus, hover, and activation when true.
	Disabled bool
	// Label is painted after the checkbox when non-empty.
	Label string
	// OnChanged is called with the next checked value when the checkbox is activated.
	OnChanged BoolChangedCallback
}

Checkbox is a controlled boolean input.

Checkbox calls OnChanged with the next checked value when activated by mouse, Enter, or Space. The caller owns updating Checked with the new value.

func (Checkbox) CreateState

func (w Checkbox) CreateState() State

type ChildOffsetProvider

type ChildOffsetProvider interface {
	ChildOffset(RenderObject) Offset
}

ChildOffsetProvider reports the paint offset of a child for hit testing.

type ClickAffordance

type ClickAffordance int

ClickAffordance controls the visual affordance automatically added to clickable text.

const (
	// ClickAffordanceDefault preserves the default behavior: clickable text is
	// underlined when no underline style is specified.
	ClickAffordanceDefault ClickAffordance = iota
	// ClickAffordanceUnderline always underlines clickable text.
	ClickAffordanceUnderline
	// ClickAffordanceNone leaves the caller-provided style unchanged.
	ClickAffordanceNone
)

type Color

type Color = vaxis.Color

Color aliases vaxis.Color for convenience in ui code.

func RGB

func RGB(r, g, b uint8) Color

RGB returns a 24-bit RGB color.

type ColorScale

type ColorScale struct {
	Tone50  Color
	Tone100 Color
	Tone200 Color
	Tone300 Color
	Tone400 Color
	Tone500 Color
	Tone600 Color
	Tone700 Color
	Tone800 Color
	Tone900 Color
	Tone950 Color
}

ColorScale contains generated tones for one color family. Lower tones are lighter, and higher tones are darker.

type ColorThemeMode

type ColorThemeMode = vaxis.ColorThemeMode

ColorThemeMode aliases vaxis.ColorThemeMode.

type ColorThemeUpdate

type ColorThemeUpdate = vaxis.ColorThemeUpdate

ColorThemeUpdate aliases vaxis.ColorThemeUpdate.

type CommandPalette

type CommandPalette struct {
	// Items are filtered, displayed, and activated by the palette.
	Items []CommandPaletteItem
	// Filter filters and ranks Items for the current query. When nil,
	// DefaultCommandPaletteFilter is used.
	Filter CommandPaletteFilter
	// Placeholder is shown in the search field when the query is empty.
	Placeholder string
	// EmptyText is shown when no items match the query.
	EmptyText string
	// Width is the panel content width when greater than zero.
	Width int
	// MaxVisibleRows limits visible result rows before scrolling.
	MaxVisibleRows int
	// OnDismiss is called when Escape is pressed.
	OnDismiss VoidCallback
	// OnSelected is called after the selected item's OnSelected callback.
	OnSelected CommandPaletteSelectedCallback
}

CommandPalette shows a searchable list of commands in a floating panel.

func (CommandPalette) Build

type CommandPaletteFilter

type CommandPaletteFilter func(query string, items []CommandPaletteItem) []CommandPaletteItem

CommandPaletteFilter filters and ranks command palette items for query.

type CommandPaletteItem

type CommandPaletteItem struct {
	// Title is the primary row text.
	Title string
	// Description is optional secondary row text.
	Description string
	// Aliases are additional strings matched by the default fuzzy filter.
	Aliases []string
	// Leading is painted before the title content when non-nil.
	Leading Widget
	// Trailing is painted at the end of the row when non-nil.
	Trailing Widget
	// Disabled prevents activation when true.
	Disabled bool
	// OnSelected is called when this item is activated.
	OnSelected VoidCallback
}

CommandPaletteItem describes one selectable command palette row.

func DefaultCommandPaletteFilter

func DefaultCommandPaletteFilter(query string, items []CommandPaletteItem) []CommandPaletteItem

DefaultCommandPaletteFilter filters command items with title-weighted fuzzy matching.

type CommandPaletteSelectedCallback

type CommandPaletteSelectedCallback func(EventContext, CommandPaletteItem)

CommandPaletteSelectedCallback receives a selected command palette item.

type ConstrainedBox

type ConstrainedBox struct {
	// Constraints are enforced inside the parent constraints.
	Constraints Constraints
	// Child is laid out with the combined constraints.
	Child Widget
}

ConstrainedBox applies additional constraints to its child.

func (ConstrainedBox) CreateRenderObject

func (w ConstrainedBox) CreateRenderObject(BuildContext) RenderObject

func (ConstrainedBox) UpdateRenderObject

func (w ConstrainedBox) UpdateRenderObject(_ BuildContext, ro RenderObject)

func (ConstrainedBox) WidgetChild

func (w ConstrainedBox) WidgetChild() Widget

type Constraints

type Constraints struct {
	// MinWidth is the smallest width a render object may choose.
	MinWidth int
	// MaxWidth is the largest width a render object may choose, or Unbounded.
	MaxWidth int
	// MinHeight is the smallest height a render object may choose.
	MinHeight int
	// MaxHeight is the largest height a render object may choose, or Unbounded.
	MaxHeight int
}

Constraints describes minimum and maximum sizes for layout.

func Loose

func Loose(size Size) Constraints

Loose returns constraints bounded by size with zero minimums.

func Tight

func Tight(size Size) Constraints

Tight returns constraints that force exactly size.

func (Constraints) Constrain

func (c Constraints) Constrain(size Size) Size

Constrain clamps size into the constraint range.

func (Constraints) Deflate

func (c Constraints) Deflate(in Insets) Constraints

Deflate subtracts insets from the constraint space.

func (Constraints) Enforce

func (c Constraints) Enforce(other Constraints) Constraints

Enforce clamps c so it also satisfies other.

func (Constraints) HasBoundedHeight

func (c Constraints) HasBoundedHeight() bool

HasBoundedHeight reports whether MaxHeight is finite.

func (Constraints) HasBoundedWidth

func (c Constraints) HasBoundedWidth() bool

HasBoundedWidth reports whether MaxWidth is finite.

type CopySelectionTextIntent

type CopySelectionTextIntent struct {
	// OnCopied is called with the copied text after a non-empty selection is
	// placed on the clipboard.
	OnCopied func(string)
}

CopySelectionTextIntent copies the current text selection.

func (CopySelectionTextIntent) IntentType

func (CopySelectionTextIntent) IntentType() IntentType

type CrossAxisAlignment

type CrossAxisAlignment int

CrossAxisAlignment controls how children are placed on a Flex cross axis.

const (
	// CrossAxisCenter centers children on the cross axis.
	CrossAxisCenter CrossAxisAlignment = iota
	// CrossAxisStart places children at the start of the cross axis.
	CrossAxisStart
	// CrossAxisEnd places children at the end of the cross axis.
	CrossAxisEnd
	// CrossAxisStretch tightens children to the maximum cross-axis size.
	CrossAxisStretch
)

type Cursor

type Cursor struct {
	// Col and Row locate the cursor relative to the child origin.
	Col, Row int
	// Shape is the terminal cursor style to request.
	Shape CursorStyle
	// Hidden suppresses the cursor while still painting the child.
	Hidden bool
	// Child is painted before the cursor is requested.
	Child Widget
}

Cursor requests a terminal cursor at a child-relative cell position.

func (Cursor) CreateRenderObject

func (w Cursor) CreateRenderObject(BuildContext) RenderObject

func (Cursor) UpdateRenderObject

func (w Cursor) UpdateRenderObject(_ BuildContext, ro RenderObject)

func (Cursor) WidgetChild

func (w Cursor) WidgetChild() Widget

type CursorState

type CursorState struct {
	Col   int
	Row   int
	Shape CursorStyle
}

CursorState describes the terminal cursor requested during paint.

type CursorStyle

type CursorStyle = vaxis.CursorStyle

CursorStyle aliases vaxis.CursorStyle.

type Curve

type Curve func(float64) float64

Curve maps a linear animation progress value in [0, 1] to an eased value.

type CustomScrollView

type CustomScrollView struct {
	// Controller can be used to inspect and change scroll position
	// programmatically after this view is mounted.
	Controller *ScrollController
	// FollowOutput keeps the viewport at the end when it is already at the end
	// before content grows. If the user scrolls away from the end, new content
	// does not move the viewport until it is scrolled back to the end.
	FollowOutput bool
	// Slivers are laid out vertically in order.
	Slivers []Widget
}

CustomScrollView composes row-based slivers in one vertical scroll viewport.

Mouse wheel events scroll by one line. Page Up and Page Down scroll by one viewport. Home and End jump to the start and end. Scrollbar can wrap a CustomScrollView because it exposes the same scroll metrics and commands as ScrollView. Slivers may report a scroll offset correction during layout when lazy measurement changes the logical position of visible content; the viewport applies the correction and lays out again so the current anchor row stays visually stable.

func (CustomScrollView) CreateState

func (w CustomScrollView) CreateState() State

type DebugCursor

type DebugCursor struct {
	Col   int         `json:"col"`
	Row   int         `json:"row"`
	Shape CursorStyle `json:"shape"`
}

DebugCursor describes the cursor from a rendered debug snapshot.

type DebugFocusTarget

type DebugFocusTarget struct {
	ID      string `json:"id"`
	Index   int    `json:"index"`
	Label   string `json:"label,omitempty"`
	Focused bool   `json:"focused,omitempty"`
}

DebugFocusTarget describes one keyboard focus stop.

type DebugNode

type DebugNode struct {
	ID           string             `json:"id"`
	Widget       string             `json:"widget"`
	Element      string             `json:"element"`
	State        string             `json:"state,omitempty"`
	Render       string             `json:"render,omitempty"`
	Size         *DebugSize         `json:"size,omitempty"`
	Offset       *DebugOffset       `json:"offset,omitempty"`
	Dirty        bool               `json:"dirty,omitempty"`
	NeedsLayout  bool               `json:"needsLayout,omitempty"`
	NeedsPaint   bool               `json:"needsPaint,omitempty"`
	ParentData   string             `json:"parentData,omitempty"`
	FocusTargets []DebugFocusTarget `json:"focusTargets,omitempty"`
	Children     []DebugNode        `json:"children,omitempty"`
}

DebugNode describes one mounted element in the UI tree.

type DebugOffset

type DebugOffset struct {
	X int `json:"x"`
	Y int `json:"y"`
}

DebugOffset is a JSON-friendly terminal cell offset.

type DebugProfileSample

type DebugProfileSample struct {
	Count  int     `json:"count"`
	LastMS float64 `json:"last_ms"`
	P95MS  float64 `json:"p95_ms"`
	P99MS  float64 `json:"p99_ms"`
}

DebugProfileSample contains timing stats for one profiled event or phase.

type DebugProfileSnapshot

type DebugProfileSnapshot struct {
	Window int                `json:"window"`
	Key    DebugProfileSample `json:"key"`
	Mouse  DebugProfileSample `json:"mouse"`
	Build  DebugProfileSample `json:"build"`
	Layout DebugProfileSample `json:"layout"`
	Paint  DebugProfileSample `json:"paint"`
	Render DebugProfileSample `json:"render"`
	Frame  DebugProfileSample `json:"frame"`
}

DebugProfileSnapshot contains timing stats for recent UI events and frames.

type DebugRenderedCell

type DebugRenderedCell struct {
	Col             int            `json:"col"`
	Row             int            `json:"row"`
	Grapheme        string         `json:"grapheme,omitempty"`
	Width           int            `json:"width,omitempty"`
	Foreground      Color          `json:"foreground,omitempty"`
	Background      Color          `json:"background,omitempty"`
	UnderlineColor  Color          `json:"underlineColor,omitempty"`
	UnderlineStyle  UnderlineStyle `json:"underlineStyle,omitempty"`
	Attribute       AttributeMask  `json:"attribute,omitempty"`
	Hyperlink       string         `json:"hyperlink,omitempty"`
	HyperlinkParams string         `json:"hyperlinkParams,omitempty"`
}

DebugRenderedCell describes one painted terminal cell.

type DebugRenderedSnapshot

type DebugRenderedSnapshot struct {
	Size   DebugSize           `json:"size"`
	Cursor *DebugCursor        `json:"cursor,omitempty"`
	Cells  []DebugRenderedCell `json:"cells"`
}

DebugRenderedSnapshot describes the last painted terminal frame.

type DebugSize

type DebugSize struct {
	Width  int `json:"width"`
	Height int `json:"height"`
}

DebugSize is a JSON-friendly terminal cell size.

type DebugSnapshot

type DebugSnapshot struct {
	Size       DebugSize          `json:"size"`
	Window     DebugWindow        `json:"window"`
	MouseShape MouseShape         `json:"mouseShape"`
	Focused    string             `json:"focused,omitempty"`
	Focusables []DebugFocusTarget `json:"focusables,omitempty"`
	Tree       *DebugNode         `json:"tree,omitempty"`
}

DebugSnapshot describes the current UI tree for development tooling.

type DebugWindow

type DebugWindow struct {
	Cols   int `json:"cols"`
	Rows   int `json:"rows"`
	XPixel int `json:"xPixel,omitempty"`
	YPixel int `json:"yPixel,omitempty"`
}

DebugWindow is a JSON-friendly terminal window size.

type Decoration

type Decoration struct {
	// Style is used for the background fill.
	Style Style
	// Fill is the character used to fill the box; a space is used when zero.
	Fill Character
	// Border describes the optional border drawn over the fill.
	Border Border
}

Decoration describes the fill, style, and border painted behind a child.

type DefaultActions

type DefaultActions struct {
	// Bindings maps intent types to fallback handlers.
	Bindings map[IntentType]ActionFunc
	// Child is the subtree that can invoke these actions.
	Child Widget
}

DefaultActions provides fallback intent handlers for its subtree.

Widgets use DefaultActions for their built-in behavior, so callers can override that behavior by placing Actions above them.

func (DefaultActions) CreateElement

func (w DefaultActions) CreateElement() element

type DeleteTextIntent

type DeleteTextIntent struct {
	Direction TextDeleteDirection
	Unit      TextMotionUnit
}

DeleteTextIntent deletes text near the caret.

func (DeleteTextIntent) IntentType

func (DeleteTextIntent) IntentType() IntentType

type Dialog

type Dialog struct {
	// Title is painted at the top of the dialog when non-empty.
	Title string
	// Child is the main dialog content.
	Child Widget
	// Actions are laid out horizontally at the bottom-right.
	Actions []Widget
	// Width fixes the dialog width when greater than zero.
	Width int
	// OnDismiss is called when Escape is pressed while focus is inside the dialog.
	OnDismiss VoidCallback
	// DisableFocusReclaim prevents the dialog from moving focus back to its first
	// focusable child on every rebuild after the initial autofocus.
	DisableFocusReclaim bool
}

Dialog presents modal content with trapped focus.

func (Dialog) CreateState

func (w Dialog) CreateState() State

type DismissIntent

type DismissIntent struct{}

DismissIntent dismisses the nearest dismissible UI surface.

func (DismissIntent) IntentType

func (DismissIntent) IntentType() IntentType

type Divider

type Divider struct {
	// Axis controls the divider orientation.
	Axis Axis
	// Character overrides the line character.
	Character Character
	// Style overrides Theme foreground when non-zero fields are set.
	Style Style
}

Divider paints a one-cell horizontal or vertical separator.

The zero value paints a horizontal divider using the box-drawing horizontal line. A vertical divider uses the box-drawing vertical line.

func (Divider) CreateRenderObject

func (w Divider) CreateRenderObject(ctx BuildContext) RenderObject

func (Divider) UpdateRenderObject

func (w Divider) UpdateRenderObject(ctx BuildContext, ro RenderObject)

type DryLayouter

type DryLayouter interface {
	DryLayout(LayoutContext, Constraints) Size
}

DryLayouter can compute a size for constraints without mutating layout state.

type Event

type Event = vaxis.Event

Event aliases vaxis.Event.

type EventCallback

type EventCallback func(EventContext, Event) EventResult

EventCallback handles an event and controls propagation.

type EventContext

type EventContext struct {
	// contains filtered or unexported fields
}

EventContext exposes the current event phase and runtime side effects.

func (EventContext) Append

func (c EventContext) Append(p []byte)

Append queues terminal output to be written before the primary-screen live region during the next frame. Append panics unless Run was configured with WithPrimaryScreen and the backend supports primary-screen appends.

func (EventContext) AppendString

func (c EventContext) AppendString(s string)

AppendString queues terminal output to be written before the primary-screen live region during the next frame. AppendString panics unless Run was configured with WithPrimaryScreen and the backend supports primary-screen appends.

func (EventContext) AppendText

func (c EventContext) AppendText(spans []TextSpan)

AppendText queues styled inline text before the primary-screen live region. Unlike AppendWidget, AppendText does not lay out or soft-wrap the spans; it encodes their styles and text directly, so terminal scrollback can wrap and reflow the text normally.

func (EventContext) AppendTextLn

func (c EventContext) AppendTextLn(spans []TextSpan)

AppendTextLn queues styled inline text followed by a newline before the primary-screen live region.

func (EventContext) AppendWidget

func (c EventContext) AppendWidget(widget Widget)

AppendWidget renders widget once offscreen and queues its visible text before the primary-screen live region. The widget is measured at the current terminal width, rendered with the current theme, converted to plain text, and appended with a trailing newline when non-empty.

AppendWidget appends a rendered snapshot: widget layout, including soft wrapping, is converted to hard line breaks at the current terminal width. Use AppendString, AppendWriter, or AppendText for prose or logs that should remain normal terminal output and reflow naturally in scrollback.

func (EventContext) AppendWriter

func (c EventContext) AppendWriter() io.Writer

AppendWriter returns an io.Writer that queues terminal output to be written before the primary-screen live region during frames. AppendWriter panics unless Run was configured with WithPrimaryScreen and the backend supports primary-screen appends.

func (EventContext) Copy

func (c EventContext) Copy(text string)

Copy asks the backend to place text on the clipboard.

func (EventContext) CopyToClipboard

func (c EventContext) CopyToClipboard(text string)

CopyToClipboard asks the backend to place text on the clipboard.

func (EventContext) FocusNext

func (c EventContext) FocusNext()

FocusNext moves focus to the next focusable widget.

func (EventContext) FocusPrevious

func (c EventContext) FocusPrevious()

FocusPrevious moves focus to the previous focusable widget.

func (EventContext) FractionalMousePoint

func (c EventContext) FractionalMousePoint(mouse Mouse) FractionalMousePoint

FractionalMousePoint converts mouse to fractional cell coordinates when pixel mouse reports and terminal pixel dimensions are available.

func (EventContext) Invoke

func (c EventContext) Invoke(intent Intent) EventResult

Invoke runs the nearest action for intent, resolving from the current event target. Default actions are used only when no regular action is found.

func (EventContext) Notify

func (c EventContext) Notify(title, body string)

Notify asks the backend to display a notification.

func (EventContext) Phase

func (c EventContext) Phase() EventPhase

Phase returns the current dispatch phase.

func (EventContext) ProfileOverlay

func (c EventContext) ProfileOverlay() bool

ProfileOverlay reports whether the profiling overlay is visible.

func (EventContext) Quit

func (c EventContext) Quit()

Quit requests that the current runner stop.

func (EventContext) Runtime

func (c EventContext) Runtime() Runtime

Runtime returns a dispatcher for scheduling work on the UI event loop.

func (EventContext) SetMouseShape

func (c EventContext) SetMouseShape(shape MouseShape)

SetMouseShape requests a mouse cursor shape for the current pointer location.

func (EventContext) SetProfileOverlay

func (c EventContext) SetProfileOverlay(visible bool)

SetProfileOverlay shows or hides the profiling overlay.

func (EventContext) SetTitle

func (c EventContext) SetTitle(title string)

SetTitle asks the backend to set the terminal title.

func (EventContext) ToggleProfileOverlay

func (c EventContext) ToggleProfileOverlay() bool

ToggleProfileOverlay toggles the profiling overlay and returns its new state.

type EventHandler

type EventHandler interface {
	HandleEvent(EventContext, Event) EventResult
}

EventHandler receives events during capture, target, or bubble dispatch.

type EventPhase

type EventPhase int

EventPhase identifies where an event is in capture, target, and bubble dispatch.

const (
	// CapturePhase is delivered from the root toward the target.
	CapturePhase EventPhase = iota
	// TargetPhase is delivered to the target element.
	TargetPhase
	// BubblePhase is delivered from the target's parent back toward the root.
	BubblePhase
)

type EventResult

type EventResult int

EventResult controls whether event propagation continues.

const (
	// EventIgnored allows event propagation to continue.
	EventIgnored EventResult = iota
	// EventHandled stops event propagation.
	EventHandled
)

type ExpandedWidget

type ExpandedWidget struct {
	// Flex is the share of remaining space assigned to the child.
	Flex int
	// Child is the wrapped child.
	Child Widget
}

ExpandedWidget gives a Flex child a tight share of remaining space.

func (ExpandedWidget) ApplyParentData

func (w ExpandedWidget) ApplyParentData(ro RenderObject)

func (ExpandedWidget) WidgetChild

func (w ExpandedWidget) WidgetChild() Widget

type Flex

type Flex struct {
	// Axis is the direction children are placed.
	Axis Axis
	// MainAxisSize controls whether the flex expands or shrinks on its main axis.
	MainAxisSize MainAxisSize
	// MainAxisAlignment controls how extra main-axis space is distributed.
	MainAxisAlignment MainAxisAlignment
	// CrossAxisAlignment controls child placement on the cross axis.
	CrossAxisAlignment CrossAxisAlignment
	// Children is the ordered list of children.
	Children []Widget
}

Flex lays out children in a horizontal or vertical run.

func (Flex) CreateRenderObject

func (w Flex) CreateRenderObject(ctx BuildContext) RenderObject

func (Flex) UpdateRenderObject

func (w Flex) UpdateRenderObject(ctx BuildContext, ro RenderObject)

func (Flex) WidgetChildren

func (w Flex) WidgetChildren() []Widget

type FlexFit

type FlexFit int

FlexFit controls how a flexible child uses its allocated main-axis space.

const (
	// FlexFitTight forces the child to fill its allocated flex space.
	FlexFitTight FlexFit = iota
	// FlexFitLoose allows the child to be smaller than its allocated flex space.
	FlexFitLoose
)

type FlexParentData

type FlexParentData struct {
	// Flex is the child's flex factor.
	Flex int
	// Fit controls whether the child must fill its flex allocation.
	Fit FlexFit
	// Offset is the child paint offset computed by renderFlex.
	Offset Offset
}

FlexParentData stores layout data for children of renderFlex.

func (FlexParentData) RenderOffset

func (d FlexParentData) RenderOffset() Offset

RenderOffset returns the child's paint offset.

type FlexibleWidget

type FlexibleWidget struct {
	// Flex is the share of remaining space assigned to the child.
	Flex int
	// Fit controls whether the child must fill its flex allocation.
	Fit FlexFit
	// Child is the wrapped child.
	Child Widget
}

FlexibleWidget gives a Flex child a configurable share of remaining space.

func (FlexibleWidget) ApplyParentData

func (w FlexibleWidget) ApplyParentData(ro RenderObject)

func (FlexibleWidget) WidgetChild

func (w FlexibleWidget) WidgetChild() Widget

type FloatTween

type FloatTween struct {
	// Begin is the value returned at progress 0.
	Begin float64
	// End is the value returned at progress 1.
	End float64
}

FloatTween interpolates between two float64 values.

Example
package main

import (
	"fmt"

	"github.com/memcode-ai/memcode/internal/forks/vaxis/ui"
)

func main() {
	tween := ui.FloatTween{Begin: 10, End: 20}

	fmt.Println(tween.At(ui.EaseInOut(0.5)))
}
Output:
15

func (FloatTween) At

func (t FloatTween) At(value float64) float64

At returns the interpolated value at progress value.

type FocusIn

type FocusIn = vaxis.FocusIn

FocusIn aliases vaxis.FocusIn.

type FocusNode

type FocusNode struct {
	// contains filtered or unexported fields
}

FocusNode controls and observes focus for a Focus widget.

func (*FocusNode) HasFocus

func (n *FocusNode) HasFocus() bool

HasFocus reports whether this node is currently focused.

func (*FocusNode) RequestFocus

func (n *FocusNode) RequestFocus()

RequestFocus moves focus to this node if it is attached.

type FocusOptions

type FocusOptions struct {
	// SkipTraversal removes this target from Tab and Shift+Tab traversal while
	// still allowing it to request focus directly.
	SkipTraversal bool
}

FocusOptions controls focus behavior.

type FocusOut

type FocusOut = vaxis.FocusOut

FocusOut aliases vaxis.FocusOut.

type FocusScope

type FocusScope struct {
	// Trap keeps Tab and Shift+Tab traversal inside Child while focus is inside
	// this scope.
	Trap bool
	// AutoFocus moves focus to the first descendant focus target after build
	// when focus is outside the scope.
	AutoFocus bool
	// ReclaimFocus moves focus back into the scope on rebuild when focus is
	// outside the scope after the initial autofocus.
	ReclaimFocus bool
	// Child is the scoped subtree.
	Child Widget
}

FocusScope controls traversal for focusable descendants.

func (FocusScope) CreateElement

func (w FocusScope) CreateElement() element

type FractionalMousePoint

type FractionalMousePoint struct {
	// Col is the horizontal cell coordinate. Values may include a fractional
	// offset within the cell when pixel mouse reports are available.
	Col float64
	// Row is the vertical cell coordinate. Values may include a fractional
	// offset within the cell when pixel mouse reports are available.
	Row float64
}

FractionalMousePoint is a mouse location in terminal cell coordinates.

type FrameScheduler

type FrameScheduler struct {
	// contains filtered or unexported fields
}

FrameScheduler coalesces frame requests and applies a minimum frame interval.

func NewFrameScheduler

func NewFrameScheduler(interval time.Duration) *FrameScheduler

NewFrameScheduler creates a scheduler using interval, or DefaultFrameInterval when interval is non-positive.

func (*FrameScheduler) DidFrame

func (s *FrameScheduler) DidFrame(now time.Time)

DidFrame records that a frame was rendered at now.

func (*FrameScheduler) Due

func (s *FrameScheduler) Due() time.Time

Due returns the due time for the pending frame.

func (*FrameScheduler) Request

func (s *FrameScheduler) Request(now time.Time) time.Time

Request schedules a frame and returns its due time.

func (*FrameScheduler) Scheduled

func (s *FrameScheduler) Scheduled() bool

Scheduled reports whether a frame is pending.

type FuzzySelect

type FuzzySelect[T any] struct {
	// Items are filtered, displayed, and activated by the picker.
	Items []T
	// Item converts an item into searchable and renderable row data.
	Item FuzzySelectItemFunc[T]
	// Filter filters and ranks Items for the current query. When nil,
	// DefaultFuzzySelectFilter is used.
	Filter FuzzySelectFilter[T]
	// Placeholder is shown in the search field when the query is empty.
	Placeholder string
	// EmptyText is shown when no items match the query.
	EmptyText string
	// Width is the panel content width when greater than zero.
	Width int
	// MaxVisibleRows limits visible result rows before scrolling.
	MaxVisibleRows int
	// RowStyle controls whether items render as one-line or two-line rows.
	RowStyle FuzzySelectRowStyle
	// OnDismiss is called when Escape is pressed.
	OnDismiss VoidCallback
	// OnSelected is called when an item is activated.
	OnSelected func(EventContext, T)
}

FuzzySelect shows a searchable list of items in a floating panel.

func (FuzzySelect[T]) CreateState

func (w FuzzySelect[T]) CreateState() State

type FuzzySelectFilter

type FuzzySelectFilter[T any] func(query string, items []T, item FuzzySelectItemFunc[T]) []T

FuzzySelectFilter filters and ranks fuzzy select items for query.

type FuzzySelectItem

type FuzzySelectItem struct {
	// Title is the primary row text.
	Title string
	// Description is optional secondary row text.
	Description string
	// Aliases are additional strings matched by the default fuzzy filter.
	Aliases []string
	// Leading is painted before the title content when non-nil.
	Leading Widget
	// Trailing is painted at the end of the row when non-nil.
	Trailing Widget
	// Disabled prevents activation when true.
	Disabled bool
}

FuzzySelectItem describes one selectable fuzzy select row.

type FuzzySelectItemFunc

type FuzzySelectItemFunc[T any] func(T) FuzzySelectItem

FuzzySelectItemFunc converts an item into searchable and renderable row data.

type FuzzySelectRowStyle

type FuzzySelectRowStyle int

FuzzySelectRowStyle controls how result rows are laid out.

const (
	// FuzzySelectTwoLine shows title and description rows. This is the default.
	FuzzySelectTwoLine FuzzySelectRowStyle = iota
	// FuzzySelectOneLine shows only title text and uses one terminal row per item.
	FuzzySelectOneLine
)

type HitTestResult

type HitTestResult struct{ Path []RenderObject }

HitTestResult stores a render-object hit path.

type Image

type Image = vaxis.Image

Image aliases vaxis.Image.

type IndexedStack

type IndexedStack struct {
	// Index selects the visible child.
	Index int
	// Alignment places the visible child inside the stack. The zero value is
	// CenterAlign.
	Alignment Alignment
	// Children is the ordered child list.
	Children []Widget
}

IndexedStack keeps every child mounted but paints only one child.

All children are laid out with the same loose constraints and the stack size is the maximum child size. Only Children[Index] is painted and hit-tested.

func (IndexedStack) CreateRenderObject

func (w IndexedStack) CreateRenderObject(BuildContext) RenderObject

func (IndexedStack) UpdateRenderObject

func (w IndexedStack) UpdateRenderObject(_ BuildContext, ro RenderObject)

func (IndexedStack) WidgetChildren

func (w IndexedStack) WidgetChildren() []Widget

type InsertLineBreakIntent

type InsertLineBreakIntent struct{}

InsertLineBreakIntent inserts a line break or submits single-line text.

func (InsertLineBreakIntent) IntentType

func (InsertLineBreakIntent) IntentType() IntentType

type InsertTextIntent

type InsertTextIntent struct {
	Text string
}

InsertTextIntent inserts text at the caret.

func (InsertTextIntent) IntentType

func (InsertTextIntent) IntentType() IntentType

type Insets

type Insets struct {
	Top, Right, Bottom, Left int
}

Insets describes top, right, bottom, and left padding.

func All

func All(v int) Insets

All returns equal insets on every side.

func Symmetric

func Symmetric(horizontal, vertical int) Insets

Symmetric returns insets with shared horizontal and vertical values.

type Intent

type Intent interface {
	IntentType() IntentType
}

Intent is a typed semantic command. Implementations may carry payload data.

type IntentType

type IntentType string

IntentType identifies the action used to handle an intent.

const (
	// ActivateIntentType activates the focused control.
	ActivateIntentType IntentType = "vaxis.activate"
	// DismissIntentType dismisses the nearest dismissible UI surface.
	DismissIntentType IntentType = "vaxis.dismiss"
	// NextFocusIntentType moves focus to the next focusable widget.
	NextFocusIntentType IntentType = "vaxis.next-focus"
	// PreviousFocusIntentType moves focus to the previous focusable widget.
	PreviousFocusIntentType IntentType = "vaxis.previous-focus"
	// ToggleProfileOverlayIntentType toggles the UI profiling overlay.
	ToggleProfileOverlayIntentType IntentType = "vaxis.toggle-profile-overlay"
)
const (
	// MoveCaretIntentType moves or extends the text selection.
	MoveCaretIntentType IntentType = "vaxis.text.move-caret"
	// DeleteTextIntentType deletes text near the caret.
	DeleteTextIntentType IntentType = "vaxis.text.delete"
	// InsertTextIntentType inserts text at the caret.
	InsertTextIntentType IntentType = "vaxis.text.insert"
	// InsertLineBreakIntentType inserts a line break or submits single-line text.
	InsertLineBreakIntentType IntentType = "vaxis.text.insert-line-break"
	// SelectAllTextIntentType selects all text.
	SelectAllTextIntentType IntentType = "vaxis.text.select-all"
	// CopySelectionTextIntentType copies the current text selection.
	CopySelectionTextIntentType IntentType = "vaxis.text.copy-selection"
)
const (
	// ScrollIntentType scrolls a viewport.
	ScrollIntentType IntentType = "vaxis.scroll"
)

type Key

type Key = vaxis.Key

Key aliases vaxis.Key.

type KeyCallback

type KeyCallback func(EventContext, Key) EventResult

KeyCallback handles a key event and controls propagation.

type KeyValue

type KeyValue string

KeyValue identifies a widget across rebuilds.

type Keyed

type Keyed interface {
	WidgetKey() KeyValue
}

Keyed gives a widget a stable identity among siblings of the same type.

type LayoutContext

type LayoutContext struct{}

LayoutContext carries helpers available while measuring and laying out render objects.

func (LayoutContext) Characters

func (LayoutContext) Characters(s string) []Character

Characters splits s into terminal-width grapheme characters.

func (LayoutContext) MeasureText

func (LayoutContext) MeasureText(s string, style Style) Size

MeasureText returns the terminal cell size needed to draw s on one line.

type LeafRenderObject

type LeafRenderObject struct{ RenderObjectBase }

LeafRenderObject is a RenderObjectBase for render objects without children.

func (*LeafRenderObject) HitTest

func (r *LeafRenderObject) HitTest(*HitTestResult, Point) bool

func (*LeafRenderObject) VisitChildren

func (r *LeafRenderObject) VisitChildren(func(RenderObject))

type ListTile

type ListTile struct {
	// Leading is painted before the title content when non-nil.
	Leading Widget
	// Title is the primary tile content.
	Title Widget
	// Subtitle is painted below Title when non-nil.
	Subtitle Widget
	// Trailing is painted at the end of the row when non-nil.
	Trailing Widget
	// Selected paints the tile with Theme primary colors.
	Selected bool
	// Disabled prevents focus, hover, and activation when true.
	Disabled bool
	// OnPressed is called when the tile is activated.
	OnPressed VoidCallback
	// Padding overrides the default tile padding when non-zero.
	Padding Insets
	// Gap overrides the default tile gap when greater than zero.
	Gap int
	// MinHeight overrides the default tile minimum height when greater than zero.
	MinHeight int
}

ListTile is a focusable row with optional leading, subtitle, and trailing slots.

ListTile calls OnPressed when activated by mouse, Enter, or Space. When Disabled is true the tile is not focusable and does not activate.

func (ListTile) CreateState

func (w ListTile) CreateState() State

type ListTileTheme

type ListTileTheme struct {
	Normal          Style
	Focused         Style
	Hovered         Style
	Selected        Style
	SelectedFocused Style
	SelectedHovered Style
	Disabled        Style
	Padding         Insets
	Gap             int
	MinHeight       int
	Mouse           MouseShape
}

ListTileTheme contains derived styling and sizing defaults for ListTile.

type MainAxisAlignment

type MainAxisAlignment int

MainAxisAlignment controls how free space is distributed on a Flex main axis.

const (
	// MainAxisStart places children at the start of the main axis.
	MainAxisStart MainAxisAlignment = iota
	// MainAxisEnd places children at the end of the main axis.
	MainAxisEnd
	// MainAxisCenter centers children on the main axis.
	MainAxisCenter
	// MainAxisSpaceBetween distributes free space between children.
	MainAxisSpaceBetween
	// MainAxisSpaceAround distributes free space around children.
	MainAxisSpaceAround
	// MainAxisSpaceEvenly distributes free space evenly before, between, and after children.
	MainAxisSpaceEvenly
)

type MainAxisSize

type MainAxisSize int

MainAxisSize controls how much space a Flex occupies on its main axis.

const (
	// MainAxisSizeMax expands the Flex to the incoming maximum main-axis size.
	MainAxisSizeMax MainAxisSize = iota
	// MainAxisSizeMin sizes the Flex to its children on the main axis.
	MainAxisSizeMin
)

type ModalBarrier

type ModalBarrier struct {
	// Color is the scrim target color. The zero value defaults to black.
	Color Color
	// Opacity controls the blend amount from 0 to 255. The zero value defaults to
	// a subtle modal dimming opacity.
	Opacity uint8
}

ModalBarrier applies a translucent scrim over already-painted content.

Place ModalBarrier in a Stack above background content and below a dialog or other modal surface. The barrier preserves existing graphemes and blends RGB foreground, background, and underline colors toward Color.

func (ModalBarrier) CreateRenderObject

func (w ModalBarrier) CreateRenderObject(BuildContext) RenderObject

func (ModalBarrier) UpdateRenderObject

func (w ModalBarrier) UpdateRenderObject(_ BuildContext, ro RenderObject)

type Mouse

type Mouse = vaxis.Mouse

Mouse aliases vaxis.Mouse.

type MouseButton

type MouseButton = vaxis.MouseButton

MouseButton aliases vaxis.MouseButton.

type MouseShape

type MouseShape = vaxis.MouseShape

MouseShape aliases vaxis.MouseShape.

type MouseShapeHandler

type MouseShapeHandler interface {
	MouseShape(EventContext, Mouse) MouseShape
}

MouseShapeHandler chooses the mouse cursor shape for a hovered element.

type MoveCaretIntent

type MoveCaretIntent struct {
	Motion          TextMotion
	Unit            TextMotionUnit
	ExtendSelection bool
}

MoveCaretIntent moves the caret or extends the selection.

func (MoveCaretIntent) IntentType

func (MoveCaretIntent) IntentType() IntentType

type MultiChildRenderObject

type MultiChildRenderObject struct {
	RenderObjectBase
	// contains filtered or unexported fields
}

MultiChildRenderObject is a RenderObjectBase for render objects with ordered children.

func (*MultiChildRenderObject) ChildOffset

func (r *MultiChildRenderObject) ChildOffset(child RenderObject) Offset

func (*MultiChildRenderObject) Children

func (r *MultiChildRenderObject) Children() []RenderObject

Children returns the current child render objects.

func (*MultiChildRenderObject) SetChildren

func (r *MultiChildRenderObject) SetChildren(children []RenderObject)

SetChildren replaces the current child render objects.

func (*MultiChildRenderObject) VisitChildren

func (r *MultiChildRenderObject) VisitChildren(fn func(RenderObject))

type NextFocusIntent

type NextFocusIntent struct{}

NextFocusIntent moves focus to the next focusable widget.

func (NextFocusIntent) IntentType

func (NextFocusIntent) IntentType() IntentType

type Offset

type Offset struct{ X, Y int }

Offset is a relative cell coordinate.

func (Offset) Add

func (o Offset) Add(other Offset) Offset

Add returns the sum of two offsets.

func (Offset) Negate

func (o Offset) Negate() Offset

Negate returns the opposite offset.

type Option

type Option func(*options)

Option configures an App or Run invocation.

func WithBaseColors

func WithBaseColors(base BaseColors) Option

WithBaseColors generates light and dark themes from base colors and switches between them on ColorThemeUpdate events.

func WithDynamicPrimaryScreen

func WithDynamicPrimaryScreen() Option

WithDynamicPrimaryScreen runs the UI on the terminal primary screen and sizes the live region to the root widget's preferred height each frame.

func WithPalette

func WithPalette(palette Palette) Option

WithPalette generates light and dark themes from palette and switches between them on ColorThemeUpdate events.

func WithPrimaryScreen

func WithPrimaryScreen(regionHeight int) Option

WithPrimaryScreen runs the UI on the terminal primary screen instead of the alternate screen. The root widget is rendered into a live region of regionHeight rows; use EventContext append methods to write output before that region.

func WithProfileOverlay

func WithProfileOverlay() Option

WithProfileOverlay draws recent UI profiling stats in the top-right corner.

func WithShortcuts

func WithShortcuts(shortcuts ShortcutMap) Option

WithShortcuts replaces the default app-level key-to-intent bindings.

Start from DefaultShortcuts when you want to keep the built-in bindings and add or change only a few keys.

Example
package main

import (
	"fmt"

	"github.com/memcode-ai/memcode/internal/forks/vaxis"
	"github.com/memcode-ai/memcode/internal/forks/vaxis/ui"
)

func main() {
	pressed := ""
	app := ui.NewApp(ui.Row(
		ui.Button{Label: "one", OnPressed: func(ctx ui.EventContext) { pressed = "one" }},
		ui.Button{Label: "two", OnPressed: func(ctx ui.EventContext) { pressed = "two" }},
	), ui.WithShortcuts(ui.ShortcutMap{
		"x": ui.NextFocusIntent{},
	}))
	app.Pump(ui.Size{Width: 20, Height: 1})
	app.Send(vaxis.Key{Text: "x", Keycode: 'x'})
	app.Send(vaxis.Key{Keycode: vaxis.KeyEnter})

	fmt.Println(pressed)
}
Output:
two

func WithTheme

func WithTheme(theme Theme) Option

WithTheme sets the theme used by built-in widgets.

func WithThemeSet

func WithThemeSet(themeSet ThemeSet) Option

WithThemeSet sets light and dark themes and switches between them on ColorThemeUpdate events.

type Overlay

type Overlay struct {
	// Child is the base subtree painted below all entries.
	Child Widget
	// Entries are painted in order above Child.
	Entries []OverlayEntry
}

Overlay paints entries above a stable child subtree.

Overlay is useful for app-level surfaces such as dialogs, command palettes, menus, and other popups. It keeps the child as the first child of an always-present Stack so showing or hiding entries does not change the root shape of the application body.

func (Overlay) Build

func (w Overlay) Build(BuildContext) Widget

type OverlayEntry

type OverlayEntry struct {
	// Child is painted for this overlay entry.
	Child Widget
	// Modal inserts a barrier behind Child.
	Modal bool
	// Barrier overrides the default ModalBarrier when Modal is true.
	Barrier Widget
	// Alignment wraps Child in Align when non-zero.
	Alignment Alignment
}

OverlayEntry describes one overlay surface.

type Painter

type Painter struct {
	// contains filtered or unexported fields
}

Painter records terminal cells and cursor state for a frame.

func NewPainter

func NewPainter(size Size) *Painter

NewPainter creates a painter with a blank cell buffer of size.

func (*Painter) Cell

func (p *Painter) Cell(x, y int) Cell

Cell returns the cell at x,y or an empty cell when out of bounds.

func (*Painter) Cells

func (p *Painter) Cells() []Cell

Cells returns the painter's backing cell buffer.

func (*Painter) Cursor

func (p *Painter) Cursor() (CursorState, bool)

Cursor returns the requested cursor state.

func (*Painter) DrawCell

func (p *Painter) DrawCell(pt Point, cell Cell)

DrawCell writes a single cell when pt is in bounds and unclipped.

func (*Painter) DrawText

func (p *Painter) DrawText(off Offset, s string, style Style)

DrawText writes s at off using style.

func (*Painter) Fill

func (p *Painter) Fill(r Rect, cell Cell)

Fill writes cell into every visible cell of r.

func (*Painter) HideCursor

func (p *Painter) HideCursor()

HideCursor clears any requested cursor.

func (*Painter) PopClip

func (p *Painter) PopClip()

PopClip restores the previous clip rectangle.

func (*Painter) PushClip

func (p *Painter) PushClip(r Rect)

PushClip restricts subsequent drawing to r.

func (*Painter) Scrim

func (p *Painter) Scrim(r Rect, color Color, opacity uint8)

Scrim blends every visible cell in r toward color by opacity.

Opacity ranges from 0, no effect, to 255, replace RGB colors with color. Non-RGB colors are left unchanged because their terminal palette values are not known to the painter.

func (*Painter) ShowCursor

func (p *Painter) ShowCursor(col, row int, shape CursorStyle)

ShowCursor records a visible cursor if the position is in bounds and unclipped.

func (*Painter) Size

func (p *Painter) Size() Size

Size returns the painter's cell buffer size.

type Palette

type Palette struct {
	Neutral ColorScale
	Red     ColorScale
	Green   ColorScale
	Yellow  ColorScale
	Blue    ColorScale
	Magenta ColorScale
	Cyan    ColorScale
}

Palette is the color scale available to a Theme.

func DefaultPalette

func DefaultPalette() Palette

DefaultPalette returns the built-in vaxis/ui color palette.

func PaletteFromBaseColors

func PaletteFromBaseColors(base BaseColors) Palette

PaletteFromBaseColors generates a color scale from base colors.

type ParentDataWidget

type ParentDataWidget interface {
	WidgetChild() Widget
	ApplyParentData(RenderObject)
}

ParentDataWidget writes layout data onto its child's render object.

type Point

type Point struct{ X, Y int }

Point is an absolute cell coordinate.

type Positioned

type Positioned struct {
	// Left is the child X offset.
	Left int
	// Top is the child Y offset.
	Top int
	// Child is the positioned child.
	Child Widget
}

Positioned places a child at an offset inside an ancestor Stack.

func (Positioned) ApplyParentData

func (w Positioned) ApplyParentData(ro RenderObject)

func (Positioned) WidgetChild

func (w Positioned) WidgetChild() Widget

type PreviousFocusIntent

type PreviousFocusIntent struct{}

PreviousFocusIntent moves focus to the previous focusable widget.

func (PreviousFocusIntent) IntentType

func (PreviousFocusIntent) IntentType() IntentType

type PrimaryScreenAppender

type PrimaryScreenAppender interface {
	Append([]byte)
	AppendString(string)
	AppendWriter() io.Writer
}

PrimaryScreenAppender is implemented by backends that support appending terminal output before a primary-screen live region.

type PrimaryScreenRegionSizer

type PrimaryScreenRegionSizer interface {
	SetPrimaryScreenRegionHeight(int)
}

PrimaryScreenRegionSizer is implemented by backends that can resize a primary-screen live region independently from the terminal size.

type ProgressBar

type ProgressBar struct {
	// Value is the completed fraction, from 0 to 1.
	Value float64
	// Width is used when greater than zero or when layout is unbounded.
	Width int
	// FilledStyle overrides the default progress filled style when non-zero.
	FilledStyle Style
	// EmptyStyle overrides the default progress empty style when non-zero.
	EmptyStyle Style
	// GradientStart is the filled color at the start of the bar when non-zero.
	GradientStart Color
	// GradientEnd is the filled color at the end of the bar when non-zero.
	GradientEnd Color
}

ProgressBar paints a determinate horizontal progress indicator.

Value is clamped to the range 0 through 1. The bar expands to the available width when bounded, otherwise it uses Width or a one-cell fallback.

func (ProgressBar) CreateRenderObject

func (w ProgressBar) CreateRenderObject(ctx BuildContext) RenderObject

func (ProgressBar) UpdateRenderObject

func (w ProgressBar) UpdateRenderObject(ctx BuildContext, ro RenderObject)

type ProgressBarTheme

type ProgressBarTheme struct {
	Filled Style
	Empty  Style
}

ProgressBarTheme contains derived styling defaults for ProgressBar.

type Provider

type Provider[T any] struct {
	// Value is the value exposed to descendants.
	Value T
	// Child is the subtree that can depend on Value.
	Child Widget
	// ShouldNotify controls whether dependents rebuild after Value changes.
	ShouldNotify func(old, next T) bool
}

Provider makes a typed value available to descendant widgets.

func (Provider[T]) CreateElement

func (p Provider[T]) CreateElement() element

func (Provider[T]) WidgetChild

func (p Provider[T]) WidgetChild() Widget

type Radio

type Radio[T comparable] struct {
	// Value is the value represented by this radio.
	Value T
	// GroupValue is the currently selected value for the radio group.
	GroupValue T
	// Disabled prevents focus, hover, and activation when true.
	Disabled bool
	// Label is painted after the radio when non-empty.
	Label string
	// OnChanged is called with Value when the radio is activated.
	OnChanged ValueChangedCallback[T]
}

Radio is a controlled mutually exclusive selection input.

Radio is selected when Value equals GroupValue. Activating the control by mouse, Enter, or Space calls OnChanged with Value. The caller owns updating GroupValue with the new value.

func (Radio[T]) CreateState

func (w Radio[T]) CreateState() State

type Rect

type Rect struct{ X, Y, Width, Height int }

Rect is a rectangular cell region.

type Redraw

type Redraw = vaxis.Redraw

Redraw aliases vaxis.Redraw.

type RenderObject

type RenderObject interface {
	Base() *RenderObjectBase
	Layout(LayoutContext, Constraints)
	Paint(*Painter, Offset)
	HitTest(*HitTestResult, Point) bool
	VisitChildren(func(RenderObject))
}

RenderObject is the layout, paint, and hit-test object produced by a widget.

type RenderObjectBase

type RenderObjectBase struct {
	// contains filtered or unexported fields
}

RenderObjectBase stores common render tree state.

func (*RenderObjectBase) Base

Base returns the embedded render object base.

func (*RenderObjectBase) ClearNeedsLayout

func (r *RenderObjectBase) ClearNeedsLayout()

ClearNeedsLayout clears the layout dirty flag.

func (*RenderObjectBase) ClearNeedsPaint

func (r *RenderObjectBase) ClearNeedsPaint()

ClearNeedsPaint clears the paint dirty flag.

func (*RenderObjectBase) MarkNeedsLayout

func (r *RenderObjectBase) MarkNeedsLayout()

MarkNeedsLayout marks this object and eligible ancestors dirty for layout.

func (*RenderObjectBase) MarkNeedsPaint

func (r *RenderObjectBase) MarkNeedsPaint()

MarkNeedsPaint marks this object dirty for paint and requests a frame.

func (*RenderObjectBase) NeedsLayout

func (r *RenderObjectBase) NeedsLayout() bool

NeedsLayout reports whether this object has pending layout work.

func (*RenderObjectBase) NeedsPaint

func (r *RenderObjectBase) NeedsPaint() bool

NeedsPaint reports whether this object has pending paint work.

func (*RenderObjectBase) ParentData

func (r *RenderObjectBase) ParentData() any

ParentData returns parent-specific layout data for this render object.

func (*RenderObjectBase) SetParentData

func (r *RenderObjectBase) SetParentData(v any)

SetParentData stores parent-specific layout data for this render object.

func (*RenderObjectBase) SetRelayoutBoundary

func (r *RenderObjectBase) SetRelayoutBoundary(v bool)

SetRelayoutBoundary controls whether layout invalidation bubbles to ancestors.

func (*RenderObjectBase) SetSize

func (r *RenderObjectBase) SetSize(size Size)

SetSize records the render object's layout size.

func (*RenderObjectBase) Size

func (r *RenderObjectBase) Size() Size

Size returns the render object's most recent layout size.

type RenderObjectWidget

type RenderObjectWidget interface {
	CreateRenderObject(BuildContext) RenderObject
	UpdateRenderObject(BuildContext, RenderObject)
}

RenderObjectWidget creates and updates a render object.

type Resize

type Resize = vaxis.Resize

Resize aliases vaxis.Resize.

type RichText

type RichText struct {
	// Spans are the styled text runs to display.
	Spans []TextSpan
	// SoftWrap wraps text to the available width.
	SoftWrap bool
	// Overflow controls painting when text exceeds its layout bounds.
	Overflow TextOverflow
	// MaxLines limits the number of laid-out display lines when greater than zero.
	MaxLines int
	// Align controls horizontal placement within the laid-out width.
	Align TextAlign
}

RichText displays multiple styled spans as one text layout.

RichText participates in ancestor SelectionArea widgets as one selectable text run. Selection and copy preserve the rendered span order, but not style.

func (RichText) CreateRenderObject

func (w RichText) CreateRenderObject(ctx BuildContext) RenderObject

func (RichText) UpdateRenderObject

func (w RichText) UpdateRenderObject(ctx BuildContext, ro RenderObject)

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner connects an App to a Backend and frame scheduler.

func NewRunner

func NewRunner(app *App, backend Backend, scheduler *FrameScheduler) *Runner

NewRunner creates a runner for app and backend.

func (*Runner) Done

func (r *Runner) Done() bool

Done reports whether the runner should stop.

func (*Runner) HandleEvent

func (r *Runner) HandleEvent(ev Event, now time.Time)

HandleEvent dispatches one backend event to the app.

func (*Runner) HandleFrame

func (r *Runner) HandleFrame(now time.Time) error

HandleFrame rebuilds, lays out, paints, and renders one frame if needed.

func (*Runner) NextFrame

func (r *Runner) NextFrame() (time.Time, bool)

NextFrame returns the next scheduled frame time.

func (*Runner) RequestFrame

func (r *Runner) RequestFrame(now time.Time)

RequestFrame asks the scheduler for another frame.

func (*Runner) Start

func (r *Runner) Start(now time.Time)

Start schedules the initial frame.

type Runtime

type Runtime interface{ Dispatch(func()) }

Runtime schedules work back onto the UI event loop.

type ScrollAlign

type ScrollAlign int

ScrollAlign controls how a scrolled-to item is placed in the viewport.

const (
	// ScrollAlignStart places the item at the top of the viewport.
	ScrollAlignStart ScrollAlign = iota
	// ScrollAlignCenter centers the item in the viewport.
	ScrollAlignCenter
	// ScrollAlignEnd places the item at the bottom of the viewport.
	ScrollAlignEnd
	// ScrollAlignNearest scrolls only enough to reveal the item.
	ScrollAlignNearest
)

type ScrollAxis

type ScrollAxis int

ScrollAxis identifies the direction a ScrollView scrolls.

const (
	// ScrollVertical scrolls a child vertically. This is the ScrollView default.
	ScrollVertical ScrollAxis = iota
	// ScrollHorizontal scrolls a child horizontally.
	ScrollHorizontal
)

type ScrollController

type ScrollController struct {
	// contains filtered or unexported fields
}

ScrollController controls a mounted CustomScrollView.

Methods return false when the controller is not attached to a mounted view or when the requested scroll command does not change the current offset. Metrics returns zero values until the controlled view has been laid out.

func (*ScrollController) Attached

func (c *ScrollController) Attached() bool

Attached reports whether the controller is attached to a mounted view.

func (*ScrollController) Metrics

func (c *ScrollController) Metrics() ScrollMetrics

Metrics returns the current scroll metrics.

func (*ScrollController) ScrollByLines

func (c *ScrollController) ScrollByLines(lines int) bool

ScrollByLines scrolls by line rows.

func (*ScrollController) ScrollByPages

func (c *ScrollController) ScrollByPages(pages int) bool

ScrollByPages scrolls by page viewports.

func (*ScrollController) ScrollToEnd

func (c *ScrollController) ScrollToEnd() bool

ScrollToEnd scrolls to the last valid row.

func (*ScrollController) ScrollToOffset

func (c *ScrollController) ScrollToOffset(row int) bool

ScrollToOffset scrolls to row.

func (*ScrollController) ScrollToStart

func (c *ScrollController) ScrollToStart() bool

ScrollToStart scrolls to the first row.

type ScrollDirection

type ScrollDirection int

ScrollDirection identifies the direction of a scroll command.

const (
	// ScrollBackward scrolls toward the start of the scroll axis.
	ScrollBackward ScrollDirection = iota
	// ScrollForward scrolls toward the end of the scroll axis.
	ScrollForward
)

type ScrollIntent

type ScrollIntent struct {
	Axis      ScrollAxis
	Direction ScrollDirection
	Unit      ScrollUnit
}

ScrollIntent scrolls a viewport along an axis.

func (ScrollIntent) IntentType

func (ScrollIntent) IntentType() IntentType

type ScrollMetrics

type ScrollMetrics struct {
	// ScrollOffset is the current visible row or column on the active axis.
	ScrollOffset int
	// MaxScrollOffset is the largest valid scroll offset.
	MaxScrollOffset int
	// ViewportHeight is the visible row count.
	ViewportHeight int
	// ViewportWidth is the visible column count.
	ViewportWidth int
	// ContentHeight is the total scrollable row count.
	ContentHeight int
	// ContentWidth is the total scrollable column count.
	ContentWidth int
}

ScrollMetrics describes the scroll state of a render object.

type ScrollPane

type ScrollPane struct {
	// Controller can be used to inspect and change the pane's row and column
	// offsets after it is mounted.
	Controller *ScrollPaneController
	// Child is laid out with unbounded width and height.
	Child Widget
}

ScrollPane clips a single child to a viewport and scrolls it vertically and horizontally.

Mouse wheel up and down scroll rows. Mouse wheel left and right scroll columns. Arrow keys and h/j/k/l scroll by one row or column. Page Up, Page Down, Space, Shift+Space, Home, and End operate on the vertical axis.

func (ScrollPane) CreateState

func (w ScrollPane) CreateState() State

type ScrollPaneController

type ScrollPaneController struct {
	// contains filtered or unexported fields
}

ScrollPaneController controls a mounted ScrollPane.

Methods return false when the controller is not attached to a mounted pane or when the requested scroll command does not change the current offset. Metrics returns zero values until the controlled pane has been laid out.

func (*ScrollPaneController) Attached

func (c *ScrollPaneController) Attached() bool

Attached reports whether the controller is attached to a mounted pane.

func (*ScrollPaneController) Metrics

Metrics returns the current scroll metrics for axis.

func (*ScrollPaneController) ScrollBy

func (c *ScrollPaneController) ScrollBy(cols, rows int) bool

ScrollBy scrolls by columns and rows.

func (*ScrollPaneController) ScrollTo

func (c *ScrollPaneController) ScrollTo(col, row int) bool

ScrollTo scrolls to column and row.

func (*ScrollPaneController) ScrollToEnd

func (c *ScrollPaneController) ScrollToEnd() bool

ScrollToEnd scrolls both axes to the end.

func (*ScrollPaneController) ScrollToStart

func (c *ScrollPaneController) ScrollToStart() bool

ScrollToStart scrolls both axes to the start.

type ScrollUnit

type ScrollUnit int

ScrollUnit identifies the unit for a scroll command.

const (
	// ScrollUnitLine scrolls by one row or column.
	ScrollUnitLine ScrollUnit = iota
	// ScrollUnitPage scrolls by one viewport.
	ScrollUnitPage
	// ScrollUnitEdge scrolls to the start or end.
	ScrollUnitEdge
)

type ScrollView

type ScrollView struct {
	// Controller can be used to inspect and change the view's offset after it is
	// mounted.
	Controller *ScrollController
	// Axis controls which direction is scrollable. The zero value is vertical.
	Axis ScrollAxis
	// Child is laid out at the viewport cross-axis size with unbounded space
	// along Axis.
	Child Widget
}

ScrollView clips a single child to a viewport and scrolls it on one axis. Mouse wheel events scroll by one row or column. Arrow keys and h/j/k/l scroll by one row or column. Page Up, Page Down, Space, and Shift+Space scroll by one viewport. Home and End jump to the start and end.

When used inside SelectionArea, selections that start outside the ScrollView include hidden rows, while selections that start inside it initially use the visible rows and expand as selection autoscroll moves the viewport.

func (ScrollView) CreateState

func (w ScrollView) CreateState() State

type Scrollbar

type Scrollbar struct {
	// Axis controls which edge the scrollbar occupies. The zero value is
	// vertical.
	Axis ScrollAxis
	// Child is expected to expose ScrollMetrics from its render object.
	Child Widget
	// ThumbStyle overrides the default scrollbar thumb style when non-zero.
	ThumbStyle Style
	// TrackStyle overrides the default scrollbar track style when non-zero.
	TrackStyle Style
	// FocusedThumbStyle overrides the default focused scrollbar thumb style when non-zero.
	FocusedThumbStyle Style
	// FocusedTrackStyle overrides the default focused scrollbar track style when non-zero.
	FocusedTrackStyle Style
}

Scrollbar paints and handles a scrollbar over a scrollable child.

func (Scrollbar) CreateState

func (w Scrollbar) CreateState() State

type ScrollbarTheme

type ScrollbarTheme struct {
	Thumb        Style
	Track        Style
	FocusedThumb Style
	FocusedTrack Style
}

ScrollbarTheme contains derived styling defaults for Scrollbar.

type Segment

type Segment = vaxis.Segment

Segment aliases vaxis.Segment for convenience in ui code.

type SegmentedControl

type SegmentedControl[T comparable] struct {
	// Value is the currently selected value.
	Value T
	// Segments is the ordered list of selectable segments.
	Segments []SegmentedItem[T]
	// Disabled prevents focus, hover, and activation for the whole control.
	Disabled bool
	// OnChanged is called when an enabled segment is selected.
	OnChanged ValueChangedCallback[T]
}

SegmentedControl is a controlled single-selection input rendered as a compact horizontal group.

Arrow keys and h/l move to the previous or next enabled segment. Mouse clicks, Enter, and Space select the active segment. The caller owns updating Value in response to OnChanged.

func (SegmentedControl[T]) CreateState

func (w SegmentedControl[T]) CreateState() State

type SegmentedControlTheme

type SegmentedControlTheme struct {
	Normal          Style
	Focused         Style
	Hovered         Style
	Selected        Style
	SelectedHovered Style
	Disabled        Style
	Separator       Style
	Mouse           MouseShape
}

SegmentedControlTheme contains derived styling defaults for SegmentedControl.

type SegmentedItem

type SegmentedItem[T comparable] struct {
	// Value is reported through OnChanged when the segment is selected.
	Value T
	// Label is the text shown for the segment.
	Label string
	// Disabled prevents mouse and keyboard selection for this segment.
	Disabled bool
}

SegmentedItem describes one option in a SegmentedControl.

type SelectAllTextIntent

type SelectAllTextIntent struct{}

SelectAllTextIntent selects all text.

func (SelectAllTextIntent) IntentType

func (SelectAllTextIntent) IntentType() IntentType

type SelectionArea

type SelectionArea struct {
	// Child is the subtree that can contain selectable text.
	Child Widget
}

SelectionArea enables read-only text selection for descendant Text and RichText widgets.

Users can drag to select text, double-click to select a word, triple-click to select a line, press Ctrl+A to select all selectable descendants, and press Ctrl+C to copy the current selection. TextField and TextArea manage their own editable selections and are skipped by SelectionArea traversal.

Mouse selections copy the visible text when they start inside clipped content. Selections that start outside a ScrollView include its hidden rows, and selections that start inside a ScrollView expand to hidden rows only when autoscrolling moves the viewport.

func (SelectionArea) CreateState

func (w SelectionArea) CreateState() State

type SelectionContainer

type SelectionContainer struct {
	// Disabled excludes Child from ancestor SelectionArea traversal when true.
	Disabled bool
	// Child is the wrapped subtree.
	Child Widget
}

SelectionContainer controls how a subtree participates in ancestor selection.

A non-disabled SelectionContainer is transparent. When Disabled is true, descendant selectable widgets are skipped by the nearest SelectionArea for drag selection, Ctrl+A, and copy. Use it around content such as controls, embedded editors, or decorative text that should not be copied as part of the surrounding read-only selection.

func (SelectionContainer) CreateRenderObject

func (w SelectionContainer) CreateRenderObject(BuildContext) RenderObject

func (SelectionContainer) UpdateRenderObject

func (w SelectionContainer) UpdateRenderObject(_ BuildContext, ro RenderObject)

func (SelectionContainer) WidgetChild

func (w SelectionContainer) WidgetChild() Widget

type ShortcutMap

type ShortcutMap map[string]Intent

ShortcutMap maps Key.MatchString patterns to intents.

func DefaultShortcuts

func DefaultShortcuts() ShortcutMap

DefaultShortcuts returns the default app-level key-to-intent bindings.

The returned map is a fresh copy that callers may modify before passing it to WithShortcuts.

type Shortcuts

type Shortcuts struct {
	// Bindings maps Key.MatchString patterns to intents.
	Bindings ShortcutMap
	// Child is the subtree that receives events after unhandled shortcuts.
	Child Widget
}

Shortcuts maps key bindings to intents.

Shortcuts only handles a key when invoking the mapped intent is handled by an Actions or DefaultActions provider. Otherwise, the key event continues down the normal event path.

Example
package main

import (
	"fmt"

	"github.com/memcode-ai/memcode/internal/forks/vaxis"
	"github.com/memcode-ai/memcode/internal/forks/vaxis/ui"
)

type exampleSaveIntent struct{}

func (exampleSaveIntent) IntentType() ui.IntentType {
	return "example.save"
}

func main() {
	saved := false
	app := ui.NewApp(ui.Actions{
		Bindings: map[ui.IntentType]ui.ActionFunc{
			exampleSaveIntent{}.IntentType(): func(ctx ui.EventContext, intent ui.Intent) ui.EventResult {
				saved = true
				return ui.EventHandled
			},
		},
		Child: ui.Shortcuts{
			Bindings: ui.ShortcutMap{"s": exampleSaveIntent{}},
			Child:    ui.Button{Label: "save"},
		},
	})
	app.Pump(ui.Size{Width: 10, Height: 1})
	app.Send(vaxis.Key{Text: "s", Keycode: 's'})

	fmt.Println(saved)
}
Output:
true

func (Shortcuts) CreateElement

func (w Shortcuts) CreateElement() element

type SingleChildRenderObject

type SingleChildRenderObject struct {
	RenderObjectBase
	// contains filtered or unexported fields
}

SingleChildRenderObject is a RenderObjectBase for render objects with one child.

func (*SingleChildRenderObject) Child

Child returns the current child render object.

func (*SingleChildRenderObject) ChildOffset

func (*SingleChildRenderObject) SetChild

func (r *SingleChildRenderObject) SetChild(child RenderObject)

SetChild replaces the current child render object.

func (*SingleChildRenderObject) VisitChildren

func (r *SingleChildRenderObject) VisitChildren(fn func(RenderObject))

type Size

type Size struct{ Width, Height int }

Size is a width and height in terminal cells.

func DryLayout

func DryLayout(ctx LayoutContext, ro RenderObject, c Constraints) Size

DryLayout computes ro's size for c without requiring a full layout pass.

func (Size) Inflate

func (s Size) Inflate(in Insets) Size

Inflate adds insets to a size.

type SizedBox

type SizedBox struct {
	// Width and Height are the fixed size requested for the child. Values less
	// than or equal to zero leave that axis unconstrained by the SizedBox.
	Width, Height int
	// Child is laid out with tight constraints for specified axes.
	Child Widget
}

SizedBox forces its child to a fixed cell size on specified axes.

func (SizedBox) CreateRenderObject

func (w SizedBox) CreateRenderObject(ctx BuildContext) RenderObject

func (SizedBox) UpdateRenderObject

func (w SizedBox) UpdateRenderObject(ctx BuildContext, ro RenderObject)

func (SizedBox) WidgetChild

func (w SizedBox) WidgetChild() Widget

type SliverConstraints

type SliverConstraints struct {
	// ViewportWidth is the available width in cells.
	ViewportWidth int
	// ViewportHeight is the viewport height in cells.
	ViewportHeight int
	// RemainingPaintExtent is the number of viewport rows left after previous
	// slivers.
	RemainingPaintExtent int
	// ScrollOffset is the number of rows scrolled into this sliver.
	ScrollOffset int
	// ObscuredLeadingExtent is the number of rows from this sliver's leading
	// edge that are hidden by viewport clipping or pinned content.
	ObscuredLeadingExtent int
}

SliverConstraints describes the portion of a sliver visible in a CustomScrollView.

type SliverFillRemaining

type SliverFillRemaining struct {
	// Child is laid out at the viewport width and fills any remaining rows.
	Child Widget
}

SliverFillRemaining sizes its child to at least the remaining viewport height.

If previous slivers do not fill the viewport, the child is expanded to cover the remaining rows. If the child needs more height than remains, it scrolls as normal content.

func (SliverFillRemaining) CreateRenderObject

func (w SliverFillRemaining) CreateRenderObject(BuildContext) RenderObject

func (SliverFillRemaining) UpdateRenderObject

func (w SliverFillRemaining) UpdateRenderObject(BuildContext, RenderObject)

func (SliverFillRemaining) WidgetChild

func (w SliverFillRemaining) WidgetChild() Widget

type SliverGeometry

type SliverGeometry struct {
	// ScrollExtent is the sliver's total logical height in rows.
	ScrollExtent int
	// PaintExtent is the number of rows this sliver can paint in the viewport.
	PaintExtent int
	// ScrollOffsetCorrection adjusts the viewport offset after newly measured
	// content changes the logical position of the current anchor row.
	ScrollOffsetCorrection int
}

SliverGeometry reports a sliver's scrollable and visible extent.

type SliverList

type SliverList struct {
	// Children are laid out vertically in order.
	Children []Widget
}

SliverList lays out an eager list of children as one scrollable sliver.

All children are built and laid out every pass. Use SliverList for small or already-materialized lists; use SliverListBuilder for large or dynamic lists.

func (SliverList) CreateRenderObject

func (w SliverList) CreateRenderObject(BuildContext) RenderObject

func (SliverList) UpdateRenderObject

func (w SliverList) UpdateRenderObject(BuildContext, RenderObject)

func (SliverList) WidgetChildren

func (w SliverList) WidgetChildren() []Widget

type SliverListBuilder

type SliverListBuilder struct {
	// Controller can be used to inspect and scroll this list by item index
	// after it is mounted in a CustomScrollView.
	Controller *SliverListController
	// Count is the number of logical rows available from Builder.
	Count int
	// ItemExtent is the fixed height of each item in cells when greater than
	// zero.
	ItemExtent int
	// EstimatedItemExtent is the height used for unmeasured rows when
	// ItemExtent is zero. A zero or negative value is treated as one row.
	EstimatedItemExtent int
	// Overscan builds this many extra items before and after the viewport.
	Overscan int
	// Builder returns the widget for index. It is only called for the active
	// visible range plus Overscan.
	Builder func(BuildContext, int) Widget
}

SliverListBuilder lazily builds rows for a CustomScrollView.

When ItemExtent is greater than zero, every row uses that fixed height and scroll offsets are exact. When ItemExtent is zero, rows are measured as they are laid out and EstimatedItemExtent is used for rows that have not been built yet. Overscan adds rows before and after the visible range so small scroll deltas can paint without waiting for another build.

In measured mode, row heights are cached per viewport width. Resizing clears the measurements for the old width, anchors the currently visible row, and corrects the viewport scroll offset after rows are measured at the new width.

func (SliverListBuilder) CreateState

func (w SliverListBuilder) CreateState() State

type SliverListController

type SliverListController struct {
	// contains filtered or unexported fields
}

SliverListController controls a mounted SliverListBuilder by item index.

The list must be mounted inside a CustomScrollView for ScrollToIndex to move the viewport. Variable-height lists use measured extents for rows that have been laid out and EstimatedItemExtent for unknown rows.

func (*SliverListController) Attached

func (c *SliverListController) Attached() bool

Attached reports whether the controller is attached to a mounted list.

func (*SliverListController) OffsetForIndex

func (c *SliverListController) OffsetForIndex(index int) (int, bool)

OffsetForIndex returns the list-local row offset for index.

func (*SliverListController) RevealIndex

func (c *SliverListController) RevealIndex(index int) bool

RevealIndex scrolls only enough to reveal index.

func (*SliverListController) ScrollToIndex

func (c *SliverListController) ScrollToIndex(index int, align ScrollAlign) bool

ScrollToIndex scrolls the containing CustomScrollView to index.

func (*SliverListController) VisibleRange

func (c *SliverListController) VisibleRange() (int, int, bool)

VisibleRange returns the first and exclusive-last visible item indices.

type SliverPinnedHeader

type SliverPinnedHeader struct {
	// Child is laid out at the viewport width with its natural height.
	Child Widget
}

SliverPinnedHeader keeps its child visible at the top of a CustomScrollView after it would otherwise scroll offscreen.

The header still contributes its normal height to scroll extent. While pinned, it paints after non-pinned slivers so it covers rows that scroll underneath it.

func (SliverPinnedHeader) CreateRenderObject

func (w SliverPinnedHeader) CreateRenderObject(BuildContext) RenderObject

func (SliverPinnedHeader) UpdateRenderObject

func (w SliverPinnedHeader) UpdateRenderObject(BuildContext, RenderObject)

func (SliverPinnedHeader) WidgetChild

func (w SliverPinnedHeader) WidgetChild() Widget

type SliverTableBuilder

type SliverTableBuilder struct {
	// Controller can be used to inspect and scroll this table by row index after
	// it is mounted in a CustomScrollView.
	Controller *SliverTableController
	// Columns controls each column's width. Missing columns are intrinsic.
	Columns []TableColumn
	// RowCount is the number of logical rows available from Builder.
	RowCount int
	// Builder returns the table row for row. It is only called for the active
	// visible range plus Overscan.
	Builder func(BuildContext, int) TableRow
	// EstimatedRowExtent is the height used for unmeasured rows. A zero or
	// negative value is treated as one row.
	EstimatedRowExtent int
	// Overscan builds this many extra rows before and after the viewport.
	Overscan int
}

SliverTableBuilder lazily builds table rows for a CustomScrollView.

It uses the same column sizing vocabulary as Table, but only materializes the visible rows plus Overscan. Row heights are measured as rows are laid out; unmeasured rows use EstimatedRowExtent.

func (SliverTableBuilder) CreateState

func (w SliverTableBuilder) CreateState() State

type SliverTableController

type SliverTableController struct {
	// contains filtered or unexported fields
}

SliverTableController controls a mounted SliverTableBuilder by row index.

The table must be mounted inside a CustomScrollView for ScrollToRow and RevealRow to move the viewport. Variable-height rows use measured extents for rows that have been laid out and EstimatedRowExtent for unknown rows.

func (*SliverTableController) Attached

func (c *SliverTableController) Attached() bool

Attached reports whether the controller is attached to a mounted table.

func (*SliverTableController) CellAt

func (c *SliverTableController) CellAt(pt Point) (int, int, bool)

CellAt returns the table cell at pt in the containing viewport's coordinates.

func (*SliverTableController) CellRect

func (c *SliverTableController) CellRect(row, col int) (Rect, bool)

CellRect returns a cell rectangle in the containing viewport's coordinates.

func (*SliverTableController) OffsetForRow

func (c *SliverTableController) OffsetForRow(row int) (int, bool)

OffsetForRow returns the table-local row offset for row.

func (*SliverTableController) RevealRow

func (c *SliverTableController) RevealRow(row int) bool

RevealRow scrolls only enough to reveal row.

func (*SliverTableController) RowRect

func (c *SliverTableController) RowRect(row int) (Rect, bool)

RowRect returns row's rectangle in the containing viewport's coordinates.

func (*SliverTableController) ScrollToRow

func (c *SliverTableController) ScrollToRow(row int, align ScrollAlign) bool

ScrollToRow scrolls the containing CustomScrollView to row.

func (*SliverTableController) VisibleRange

func (c *SliverTableController) VisibleRange() (int, int, bool)

VisibleRange returns the first and exclusive-last visible row indices.

func (*SliverTableController) VisibleRows

func (c *SliverTableController) VisibleRows() []VisibleTableRow

VisibleRows returns visible rows with viewport-relative rectangles.

type SliverToBox

type SliverToBox struct {
	// Child is laid out at the viewport width with unbounded height.
	Child Widget
}

SliverToBox adapts a normal box widget into a CustomScrollView sliver.

The child is laid out at the viewport width with unbounded height. Use this for headers, footers, and other one-off content mixed into a sliver viewport.

func (SliverToBox) CreateRenderObject

func (w SliverToBox) CreateRenderObject(BuildContext) RenderObject

func (SliverToBox) UpdateRenderObject

func (w SliverToBox) UpdateRenderObject(BuildContext, RenderObject)

func (SliverToBox) WidgetChild

func (w SliverToBox) WidgetChild() Widget

type Stack

type Stack struct {
	// Alignment places non-positioned children inside the stack. The zero value
	// is CenterAlign.
	Alignment Alignment
	// Children is the ordered back-to-front child list.
	Children []Widget
}

Stack paints children on top of each other.

Non-positioned children are laid out loosely and determine the stack's natural size. Positioned children are then laid out and painted at their requested offsets within that size. Later children paint above earlier children and receive pointer events first.

func (Stack) CreateRenderObject

func (w Stack) CreateRenderObject(BuildContext) RenderObject

func (Stack) UpdateRenderObject

func (w Stack) UpdateRenderObject(_ BuildContext, ro RenderObject)

func (Stack) WidgetChildren

func (w Stack) WidgetChildren() []Widget

type StackParentData

type StackParentData struct {
	// Positioned reports whether Left and Top should be used.
	Positioned bool
	// Left is the positioned X offset.
	Left int
	// Top is the positioned Y offset.
	Top int
	// Offset is the child paint offset computed by renderStack.
	Offset Offset
}

StackParentData stores layout data for children of Stack.

func (StackParentData) RenderOffset

func (d StackParentData) RenderOffset() Offset

RenderOffset returns the child's paint offset.

type State

type State interface{ Build(BuildContext) Widget }

State stores mutable widget state and builds a widget subtree.

type StateBase

type StateBase struct {
	// contains filtered or unexported fields
}

StateBase provides lifecycle helpers for State implementations.

func (*StateBase) Context

func (s *StateBase) Context() BuildContext

Context returns the build context for this state.

func (*StateBase) MarkNeedsBuild

func (s *StateBase) MarkNeedsBuild()

MarkNeedsBuild schedules this state to rebuild.

func (*StateBase) NewAnimation

func (s *StateBase) NewAnimation(opts AnimationOptions) *AnimationController

NewAnimation creates an animation controller owned by this state.

Example
package main

import (
	"fmt"
	"time"

	"github.com/memcode-ai/memcode/internal/forks/vaxis/ui"
)

type animatedLabel struct {
	Controller **ui.AnimationController
}

func (w animatedLabel) CreateState() ui.State {
	return &animatedLabelState{controller: w.Controller}
}

type animatedLabelState struct {
	ui.StateBase
	controller **ui.AnimationController
}

func (s *animatedLabelState) InitState() {
	controller := s.NewAnimation(ui.AnimationOptions{
		Duration: time.Second,
		Curve:    ui.EaseInOut,
	})
	controller.ForwardAt(time.Unix(0, 0))
	*s.controller = controller
}

func (s *animatedLabelState) Build(ui.BuildContext) ui.Widget {
	return ui.Text{Value: fmt.Sprintf("%.2f", (*s.controller).Value())}
}

func main() {
	var controller *ui.AnimationController
	app := ui.NewApp(animatedLabel{Controller: &controller})
	app.Pump(ui.Size{Width: 4, Height: 1})

	fmt.Println(controller.Running())
}
Output:
true

func (*StateBase) SetState

func (s *StateBase) SetState(fn func())

SetState applies fn and schedules this state to rebuild.

func (*StateBase) Widget

func (s *StateBase) Widget() Widget

Widget returns the current widget configuration for this state.

type StateDisposer

type StateDisposer interface{ Dispose() }

StateDisposer is implemented by State values that need unmount cleanup.

type StateInitializer

type StateInitializer interface{ InitState() }

StateInitializer is implemented by State values that need mount-time initialization.

type StateUpdater

type StateUpdater interface{ DidUpdateWidget(old Widget) }

StateUpdater is implemented by State values that observe compatible widget updates.

type StatefulWidget

type StatefulWidget interface{ CreateState() State }

StatefulWidget creates persistent State for a widget location.

Example
package main

import (
	"fmt"

	"github.com/memcode-ai/memcode/internal/forks/vaxis/ui"
	"github.com/memcode-ai/memcode/internal/forks/vaxis/ui/uitest"
)

type nameForm struct{}

func (nameForm) CreateState() ui.State {
	return &nameFormState{}
}

type nameFormState struct {
	ui.StateBase
	name string
}

func (s *nameFormState) Build(ui.BuildContext) ui.Widget {
	return ui.Column(
		ui.TextField{
			Value:       s.name,
			Placeholder: "Name",
			OnChanged: func(ctx ui.EventContext, next string) {
				s.SetState(func() { s.name = next })
			},
		},
		ui.Text{Value: "Hello, " + s.name},
	)
}

func main() {
	app := uitest.New(nameForm{})
	app.Pump(20, 2)
	app.Key("A")
	app.Pump(20, 2)

	fmt.Println(app.Contains("Hello, A"))
}
Output:
true

type StatelessWidget

type StatelessWidget interface{ Build(BuildContext) Widget }

StatelessWidget builds child widgets from configuration and context.

type Style

type Style = vaxis.Style

Style aliases vaxis.Style for convenience in ui code.

type SyncFunc

type SyncFunc = vaxis.SyncFunc

SyncFunc aliases vaxis.SyncFunc.

type Table

type Table struct {
	Columns   []TableColumn
	ColumnGap int
	RowGap    int
	Rows      []TableRow
}

Table lays out widgets in rows and columns.

Columns controls each column's width. When Columns is empty, the table infers a column for the widest row and sizes every column intrinsically.

func (Table) CreateRenderObject

func (w Table) CreateRenderObject(BuildContext) RenderObject

func (Table) UpdateRenderObject

func (w Table) UpdateRenderObject(_ BuildContext, ro RenderObject)

func (Table) WidgetChildren

func (w Table) WidgetChildren() []Widget

type TableColumn

type TableColumn struct {
	// contains filtered or unexported fields
}

TableColumn describes how a Table column chooses its width.

func FixedColumn

func FixedColumn(width int) TableColumn

FixedColumn sizes a column to width cells.

func FlexColumn

func FlexColumn(flex int) TableColumn

FlexColumn gives a column a proportional share of remaining width.

func IntrinsicColumn

func IntrinsicColumn() TableColumn

IntrinsicColumn sizes a column to the widest cell in that column.

type TableParentData

type TableParentData struct {
	Offset Offset
}

TableParentData stores layout data for children of Table.

func (TableParentData) RenderOffset

func (d TableParentData) RenderOffset() Offset

RenderOffset returns the child's paint offset.

type TableRow

type TableRow struct {
	Children []Widget
}

TableRow is one row of widgets in a Table.

type Text

type Text struct {
	// Value is the string to display.
	Value string
	// Style overrides Theme foreground when non-zero fields are set.
	Style Style
	// ClickAffordance controls the visual affordance added when OnPressed is set.
	ClickAffordance ClickAffordance
	// SoftWrap wraps text to the available width.
	SoftWrap bool
	// Overflow controls painting when text exceeds its layout bounds.
	Overflow TextOverflow
	// MaxLines limits the number of laid-out display lines when greater than zero.
	MaxLines int
	// Align controls horizontal placement within the laid-out width.
	Align TextAlign
	// OnPressed is called when the visible text is clicked or activated while focused.
	OnPressed VoidCallback
}

Text displays a single styled string.

Text participates in ancestor SelectionArea widgets. Mouse selection copies the laid-out visible text; Ctrl+A from SelectionArea copies the full value, including text hidden by clipping or ellipsis.

func (Text) CreateRenderObject

func (w Text) CreateRenderObject(ctx BuildContext) RenderObject

func (Text) UpdateRenderObject

func (w Text) UpdateRenderObject(ctx BuildContext, ro RenderObject)

type TextAlign

type TextAlign int
const (
	// TextAlignStart aligns text to the start edge.
	TextAlignStart TextAlign = iota
	// TextAlignEnd aligns text to the end edge.
	TextAlignEnd
	// TextAlignLeft aligns text to the left edge.
	TextAlignLeft
	// TextAlignRight aligns text to the right edge.
	TextAlignRight
	// TextAlignCenter centers text.
	TextAlignCenter
)

type TextArea

type TextArea struct {
	// Value is the current text. The widget does not mutate this field directly.
	Value string
	// Placeholder is shown when Value is empty and the area is not focused.
	Placeholder string
	// OnChanged is called with the next value after an edit.
	OnChanged TextChangedCallback
	// Padding overrides the default text field padding when non-zero.
	Padding Insets
	// MinWidth overrides the default text field minimum width when greater than zero.
	MinWidth int
	// MinHeight is the minimum content height, before padding.
	MinHeight int
	// MaxHeight is the maximum content height, before padding. When greater than zero,
	// the text area grows until MaxHeight and then scrolls internally.
	MaxHeight int
	// SoftWrap wraps long logical lines to the available width.
	SoftWrap bool
	// CursorOffset moves the cursor to a grapheme offset and clears selection when non-nil.
	CursorOffset *int
	// Selection sets the active selection and cursor when non-nil.
	Selection *TextSelection
	// CursorShape overrides the cursor shape while focused. Zero uses CursorBeam.
	CursorShape CursorStyle
	// AutoFocus requests focus when the text area is mounted.
	AutoFocus bool
}

TextArea is a controlled multiline text input.

func (TextArea) CreateState

func (w TextArea) CreateState() State

type TextBuffer

type TextBuffer struct {
	// contains filtered or unexported fields
}

TextBuffer stores editable text, cursor position, and selection state.

Example
package main

import (
	"fmt"

	"github.com/memcode-ai/memcode/internal/forks/vaxis/ui"
)

func main() {
	buffer := ui.NewTextBuffer("hello")
	buffer.SetCursorOffset(buffer.Len())
	buffer.Insert(", world")

	fmt.Println(buffer.Text())
}
Output:
hello, world

func NewTextBuffer

func NewTextBuffer(text string) TextBuffer

NewTextBuffer creates a text buffer initialized with text.

func (*TextBuffer) CollapseSelection

func (b *TextBuffer) CollapseSelection(pos TextPosition) bool

CollapseSelection moves the cursor to pos and clears selection.

func (TextBuffer) Cursor

func (b TextBuffer) Cursor() TextCursor

Cursor returns the cursor as a logical line and column.

func (TextBuffer) CursorCell

func (b TextBuffer) CursorCell(layout TextLayout) (row, col int, ok bool)

CursorCell maps the cursor to a laid-out cell.

func (TextBuffer) CursorOffset

func (b TextBuffer) CursorOffset() int

CursorOffset returns the cursor offset in grapheme characters.

func (*TextBuffer) DeleteBackward

func (b *TextBuffer) DeleteBackward() bool

DeleteBackward deletes the selection or the character before the cursor.

func (*TextBuffer) DeleteForward

func (b *TextBuffer) DeleteForward() bool

DeleteForward deletes the selection or the character after the cursor.

func (*TextBuffer) DeleteWordBackward

func (b *TextBuffer) DeleteWordBackward() bool

DeleteWordBackward deletes the selection or the word before the cursor.

func (*TextBuffer) DeleteWordForward

func (b *TextBuffer) DeleteWordForward() bool

DeleteWordForward deletes the selection or the word after the cursor.

func (*TextBuffer) ExtendEnd

func (b *TextBuffer) ExtendEnd() bool

ExtendEnd extends the selection to the end of the current line.

func (*TextBuffer) ExtendHome

func (b *TextBuffer) ExtendHome() bool

ExtendHome extends the selection to the start of the current line.

func (*TextBuffer) ExtendLeft

func (b *TextBuffer) ExtendLeft() bool

ExtendLeft extends the selection one character to the left.

func (*TextBuffer) ExtendLineDown

func (b *TextBuffer) ExtendLineDown() bool

ExtendLineDown extends the selection to the next logical line.

func (*TextBuffer) ExtendLineUp

func (b *TextBuffer) ExtendLineUp() bool

ExtendLineUp extends the selection to the previous logical line.

func (*TextBuffer) ExtendRight

func (b *TextBuffer) ExtendRight() bool

ExtendRight extends the selection one character to the right.

func (*TextBuffer) ExtendSelection

func (b *TextBuffer) ExtendSelection(pos TextPosition) bool

ExtendSelection moves the selection extent to pos.

func (*TextBuffer) ExtendVisualDown

func (b *TextBuffer) ExtendVisualDown(layout TextLayout) bool

ExtendVisualDown extends the selection one laid-out row down.

func (*TextBuffer) ExtendVisualUp

func (b *TextBuffer) ExtendVisualUp(layout TextLayout) bool

ExtendVisualUp extends the selection one laid-out row up.

func (*TextBuffer) ExtendWordLeft

func (b *TextBuffer) ExtendWordLeft() bool

ExtendWordLeft extends the selection to the previous word boundary.

func (*TextBuffer) ExtendWordRight

func (b *TextBuffer) ExtendWordRight() bool

ExtendWordRight extends the selection to the next word boundary.

func (TextBuffer) HasSelection

func (b TextBuffer) HasSelection() bool

HasSelection reports whether the selection is non-empty.

func (*TextBuffer) Insert

func (b *TextBuffer) Insert(text string) bool

Insert replaces the selection with text or inserts text at the cursor.

func (*TextBuffer) InsertSingleLine

func (b *TextBuffer) InsertSingleLine(text string) bool

InsertSingleLine inserts text after removing newline characters.

func (TextBuffer) Layout

Layout lays out the buffer text using opts.

func (TextBuffer) Len

func (b TextBuffer) Len() int

Len returns the number of grapheme characters in the buffer.

func (*TextBuffer) MoveEnd

func (b *TextBuffer) MoveEnd() bool

MoveEnd moves the cursor to the end of the current line.

func (*TextBuffer) MoveHome

func (b *TextBuffer) MoveHome() bool

MoveHome moves the cursor to the start of the current line.

func (*TextBuffer) MoveLeft

func (b *TextBuffer) MoveLeft() bool

MoveLeft moves the cursor left, collapsing any selection.

func (*TextBuffer) MoveLineDown

func (b *TextBuffer) MoveLineDown() bool

MoveLineDown moves the cursor to the next logical line.

func (*TextBuffer) MoveLineUp

func (b *TextBuffer) MoveLineUp() bool

MoveLineUp moves the cursor to the previous logical line.

func (*TextBuffer) MoveRight

func (b *TextBuffer) MoveRight() bool

MoveRight moves the cursor right, collapsing any selection.

func (*TextBuffer) MoveToCell

func (b *TextBuffer) MoveToCell(layout TextLayout, row, col int) bool

MoveToCell moves the cursor to the text position nearest a laid-out cell.

func (*TextBuffer) MoveVisualDown

func (b *TextBuffer) MoveVisualDown(layout TextLayout) bool

MoveVisualDown moves the cursor one laid-out row down.

func (*TextBuffer) MoveVisualUp

func (b *TextBuffer) MoveVisualUp(layout TextLayout) bool

MoveVisualUp moves the cursor one laid-out row up.

func (*TextBuffer) MoveWordLeft

func (b *TextBuffer) MoveWordLeft() bool

MoveWordLeft moves the cursor to the previous word boundary.

func (*TextBuffer) MoveWordRight

func (b *TextBuffer) MoveWordRight() bool

MoveWordRight moves the cursor to the next word boundary.

func (TextBuffer) Position

func (b TextBuffer) Position() TextPosition

Position returns the current cursor as a text position.

func (*TextBuffer) SelectAll

func (b *TextBuffer) SelectAll() bool

SelectAll selects the full buffer.

func (*TextBuffer) SelectLineAt

func (b *TextBuffer) SelectLineAt(pos TextPosition) bool

SelectLineAt selects the logical line containing pos, including its newline.

func (*TextBuffer) SelectWordAt

func (b *TextBuffer) SelectWordAt(pos TextPosition) bool

SelectWordAt selects the word-like run containing pos.

func (TextBuffer) SelectedText

func (b TextBuffer) SelectedText() string

SelectedText returns the selected text.

func (TextBuffer) Selection

func (b TextBuffer) Selection() TextSelection

Selection returns the current selection in text positions.

func (*TextBuffer) SetCursor

func (b *TextBuffer) SetCursor(cursor TextCursor)

SetCursor moves the cursor to a logical line and column.

func (*TextBuffer) SetCursorOffset

func (b *TextBuffer) SetCursorOffset(offset int)

SetCursorOffset moves the cursor to offset and clears selection.

func (*TextBuffer) SetPosition

func (b *TextBuffer) SetPosition(pos TextPosition) bool

SetPosition moves the cursor to pos and clears selection.

func (*TextBuffer) SetSelection

func (b *TextBuffer) SetSelection(selection TextSelection) bool

SetSelection sets the selection and returns false if either endpoint is invalid.

func (*TextBuffer) SetText

func (b *TextBuffer) SetText(text string)

SetText replaces the buffer contents and clamps the cursor and selection.

func (TextBuffer) Text

func (b TextBuffer) Text() string

Text returns the buffer contents as a string.

type TextCell

type TextCell struct {
	Text      string
	Width     int
	Style     Style
	Position  TextPosition
	Synthetic bool
}

TextCell describes one grapheme cell in a text layout.

func (TextCell) End

func (c TextCell) End() TextPosition

End returns the text position immediately after this cell.

type TextChangedCallback

type TextChangedCallback func(EventContext, string)

TextChangedCallback receives a text editing value change.

type TextCursor

type TextCursor struct {
	Line   int
	Column int
}

TextCursor identifies a logical line and grapheme column in a TextBuffer.

type TextCursorCellOptions

type TextCursorCellOptions struct {
	SoftWrap  bool
	WrapWidth int
}

TextCursorCellOptions controls cursor mapping at soft-wrap boundaries.

type TextDeleteDirection

type TextDeleteDirection int

TextDeleteDirection identifies deletion before or after the caret.

const (
	// TextDeleteBackward deletes before the caret.
	TextDeleteBackward TextDeleteDirection = iota
	// TextDeleteForward deletes after the caret.
	TextDeleteForward
)

type TextField

type TextField struct {
	// Value is the current text. The widget does not mutate this field directly.
	Value string
	// Placeholder is shown when Value is empty and the field is not focused.
	Placeholder string
	// OnChanged is called with the next value after an edit.
	OnChanged TextChangedCallback
	// OnSubmitted is called with the current value when Enter is pressed.
	OnSubmitted TextChangedCallback
	// Padding overrides the default text field padding when non-zero.
	Padding Insets
	// MinWidth overrides the default text field minimum width when greater than zero.
	MinWidth int
	// ObscureText hides the displayed value, useful for password-style fields.
	ObscureText bool
	// CursorOffset moves the cursor to a grapheme offset and clears selection when non-nil.
	CursorOffset *int
	// AutoFocus requests focus when the text field is mounted.
	AutoFocus bool
}

TextField is a controlled single-line text input.

Example
package main

import (
	"github.com/memcode-ai/memcode/internal/forks/vaxis/ui"
)

func main() {
	value := ""
	field := ui.TextField{
		Value:       value,
		Placeholder: "Name",
		OnChanged: func(ctx ui.EventContext, next string) {
			value = next
		},
	}

	_ = field
}

func (TextField) CreateState

func (w TextField) CreateState() State

type TextFieldTheme

type TextFieldTheme struct {
	Normal      Style
	Focused     Style
	Placeholder Style
	Cursor      Style
	Selection   Style
	Padding     Insets
	MinWidth    int
}

TextFieldTheme contains derived styling and sizing defaults for TextField and TextArea.

type TextLayout

type TextLayout struct {
	Lines []TextLine
	Size  Size
}

TextLayout is the measured line and cell representation of styled text.

func LayoutText

func LayoutText(spans []TextSpan, c Constraints, opts TextLayoutOptions) TextLayout

LayoutText lays out styled text spans into terminal display lines.

Example
package main

import (
	"fmt"

	"github.com/memcode-ai/memcode/internal/forks/vaxis/ui"
)

func main() {
	layout := ui.LayoutText(
		[]ui.TextSpan{{Text: "hello world"}},
		ui.Constraints{MaxWidth: 5, MaxHeight: ui.Unbounded},
		ui.TextLayoutOptions{SoftWrap: true},
	)

	fmt.Println(layout.Size)
}
Output:
{5 2}

func (TextLayout) CellForPosition

func (l TextLayout) CellForPosition(pos TextPosition) (row, col int, ok bool)

CellForPosition maps a text position to a layout row and column.

func (TextLayout) CursorCell

func (l TextLayout) CursorCell(pos TextPosition, opts TextCursorCellOptions) (row, col int, ok bool)

CursorCell maps a text position to the cell where a cursor should be shown.

func (TextLayout) PositionForCell

func (l TextLayout) PositionForCell(row, col int) (TextPosition, bool)

PositionForCell maps a layout row and column to a text position.

func (TextLayout) SelectionRanges

func (l TextLayout) SelectionRanges(selection TextSelection) []TextSelectionRange

SelectionRanges maps a text selection to visible layout cell ranges.

type TextLayoutOptions

type TextLayoutOptions struct {
	SoftWrap bool
	Overflow TextOverflow
	MaxLines int
	Align    TextAlign
}

TextLayoutOptions controls wrapping, overflow, line limits, and alignment.

type TextLine

type TextLine struct {
	Runs   []TextSpan
	Width  int
	Offset int
	Cells  []TextCell
	Start  TextPosition
	End    TextPosition
}

TextLine describes one laid-out display line.

type TextMotion

type TextMotion int

TextMotion identifies a caret movement direction.

const (
	// TextMotionLeft moves toward the previous character or word.
	TextMotionLeft TextMotion = iota
	// TextMotionRight moves toward the next character or word.
	TextMotionRight
	// TextMotionUp moves to the previous visual line.
	TextMotionUp
	// TextMotionDown moves to the next visual line.
	TextMotionDown
	// TextMotionLineStart moves to the start of the current line.
	TextMotionLineStart
	// TextMotionLineEnd moves to the end of the current line.
	TextMotionLineEnd
)

type TextMotionUnit

type TextMotionUnit int

TextMotionUnit identifies the granularity for text movement or deletion.

const (
	// TextMotionCharacter moves or deletes one user-perceived character.
	TextMotionCharacter TextMotionUnit = iota
	// TextMotionWord moves or deletes one word.
	TextMotionWord
)

type TextOverflow

type TextOverflow int

TextOverflow controls how text behaves when it exceeds its layout bounds.

const (
	// TextOverflowClip clips overflowing text.
	TextOverflowClip TextOverflow = iota
	// TextOverflowEllipsis replaces clipped text with an ellipsis where possible.
	TextOverflowEllipsis
	// TextOverflowVisible paints text outside its layout bounds.
	TextOverflowVisible
)

type TextPosition

type TextPosition struct {
	Span           int
	ByteOffset     int
	RuneOffset     int
	GraphemeOffset int
}

TextPosition identifies a location in styled text.

type TextSelection

type TextSelection struct {
	Base   TextPosition
	Extent TextPosition
}

TextSelection describes a directional text range from Base to Extent.

func NewTextSelection

func NewTextSelection(base, extent TextPosition) TextSelection

NewTextSelection creates a selection from base to extent.

func (TextSelection) Contains

func (s TextSelection) Contains(pos TextPosition) bool

Contains reports whether pos is inside the selection.

func (TextSelection) ContainsLineBreak

func (s TextSelection) ContainsLineBreak(line TextLine) bool

ContainsLineBreak reports whether the selection covers line's trailing line break.

func (TextSelection) IntersectsCell

func (s TextSelection) IntersectsCell(cell TextCell) bool

IntersectsCell reports whether the selection overlaps cell.

func (TextSelection) IsCollapsed

func (s TextSelection) IsCollapsed() bool

IsCollapsed reports whether the selection is empty.

func (TextSelection) Normalized

func (s TextSelection) Normalized() TextSelection

Normalized returns the selection ordered from earlier to later position.

type TextSelectionRange

type TextSelectionRange struct {
	Row   int
	Col   int
	Width int
}

TextSelectionRange describes a contiguous selected cell range on one row.

type TextSpan

type TextSpan struct {
	// Text is the span contents.
	Text string
	// Style is merged over Theme foreground for this span. Set Style.Hyperlink for OSC
	// 8 terminal links.
	Style Style
	// ClickAffordance controls the visual affordance added for clickable spans.
	ClickAffordance ClickAffordance
	// OnPressed is called when the span is clicked.
	OnPressed VoidCallback
	// OnHover is called when the mouse moves over the span.
	OnHover VoidCallback
	// OnHoverExit is called when the mouse leaves the span.
	OnHoverExit VoidCallback
	// OnFocus is called when keyboard focus enters the span.
	OnFocus func()
	// OnFocusExit is called when keyboard focus leaves the span.
	OnFocusExit func()
}

TextSpan is a styled run of text.

type Theme

type Theme struct {
	// Palette is the source color scale used to generate the semantic colors.
	Palette Palette
	// Mode is the light/dark mapping used to generate the semantic colors.
	Mode ThemeMode

	// Background is the app's base fill color.
	Background Color
	// Foreground is the default readable text/icon color for Background,
	// Surface*, Primary*, Accent, and status fills unless a component documents a
	// stronger pairing.
	Foreground Color

	// Surface is the default panel/control fill.
	Surface Color
	// SurfaceRaised is an elevated panel/popover fill, such as dialogs and
	// command palettes.
	SurfaceRaised Color
	// SurfaceHovered is the interactive hover/focus fill for surface controls.
	SurfaceHovered Color
	// SurfacePressed is the active/pressed fill for surface controls.
	SurfacePressed Color

	// Primary is the primary emphasis fill. Pair it with Foreground for text on
	// the fill; do not pair it with PrimaryText.
	Primary Color
	// PrimaryText is a primary-colored text/icon foreground for use on normal
	// backgrounds and surfaces. It is not intended as text on Primary fills.
	PrimaryText Color
	// PrimaryHovered is the hover/focus fill for primary controls. Pair it with
	// Foreground for text on the fill.
	PrimaryHovered Color
	// PrimaryPressed is the active/pressed fill for primary controls. Pair it with
	// Foreground for text on the fill.
	PrimaryPressed Color

	// Accent is a secondary emphasis fill. Pair it with Foreground for text on the
	// fill; do not pair it with AccentText.
	Accent Color
	// AccentText is an accent-colored text/icon foreground for use on normal
	// backgrounds and surfaces. It is not intended as text on Accent fills.
	AccentText Color

	// Success is a success-state fill. Pair it with Foreground for text on the
	// fill; do not pair it with SuccessText.
	Success Color
	// SuccessText is a success-colored text/icon foreground for use on normal
	// backgrounds and surfaces. It is not intended as text on Success fills.
	SuccessText Color
	// Warning is a warning-state fill. Pair it with Foreground for text on the
	// fill; do not pair it with WarningText.
	Warning Color
	// WarningText is a warning-colored text/icon foreground for use on normal
	// backgrounds and surfaces. It is not intended as text on Warning fills.
	WarningText Color
	// Danger is a danger/error-state fill. Pair it with Foreground for text on the
	// fill; do not pair it with DangerText.
	Danger Color
	// DangerText is a danger-colored text/icon foreground for use on normal
	// backgrounds and surfaces. It is not intended as text on Danger fills.
	DangerText Color

	// MutedForeground is low-emphasis readable text for secondary information.
	MutedForeground Color
	// DisabledForeground is low-contrast text for unavailable controls.
	DisabledForeground Color

	// Selection is the fill used behind selected text. Pair it with Foreground.
	Selection Color

	// Border is a subtle divider/border color.
	Border Color
}

Theme contains semantic colors used by built-in and custom widgets.

func DefaultTheme

func DefaultTheme() Theme

DefaultTheme returns the built-in vaxis/ui theme.

func ThemeFromPalette

func ThemeFromPalette(p Palette, mode ThemeMode) Theme

ThemeFromPalette maps a palette to contrast-aware semantic colors.

type ThemeMode

type ThemeMode int

ThemeMode selects how a palette is mapped to semantic UI colors.

const (
	// DarkTheme maps dark neutral tones to backgrounds and light tones to text.
	DarkTheme ThemeMode = iota
	// LightTheme maps light neutral tones to backgrounds and dark tones to text.
	LightTheme
)

type ThemeSet

type ThemeSet struct {
	Light Theme
	Dark  Theme
}

ThemeSet contains resolved themes for light and dark appearances.

func DefaultThemeSet

func DefaultThemeSet() ThemeSet

DefaultThemeSet returns the built-in vaxis/ui light and dark themes.

func ThemeSetFromBaseColors

func ThemeSetFromBaseColors(base BaseColors) ThemeSet

ThemeSetFromBaseColors generates light and dark themes from base colors.

func ThemeSetFromPalette

func ThemeSetFromPalette(p Palette) ThemeSet

ThemeSetFromPalette maps one palette to light and dark semantic themes.

func (ThemeSet) Theme

func (s ThemeSet) Theme(mode ThemeMode) Theme

Theme returns the theme matching mode.

type ToggleProfileOverlayIntent

type ToggleProfileOverlayIntent struct{}

ToggleProfileOverlayIntent toggles the UI profiling overlay.

func (ToggleProfileOverlayIntent) IntentType

type UnderlineStyle

type UnderlineStyle = vaxis.UnderlineStyle

UnderlineStyle aliases vaxis.UnderlineStyle for convenience in ui code.

type ValueChangedCallback

type ValueChangedCallback[T comparable] func(EventContext, T)

ValueChangedCallback receives a controlled value change.

type VisibleTableRow

type VisibleTableRow struct {
	// Row is the logical row index.
	Row int
	// Rect is the row rectangle in the containing viewport's coordinates.
	Rect Rect
}

VisibleTableRow describes a visible SliverTableBuilder row.

type VoidCallback

type VoidCallback func(EventContext)

VoidCallback handles an action with event context.

type Widget

type Widget = any

Widget is any value that implements one of the widget interfaces.

func Center

func Center(child Widget) Widget

Center returns a widget that centers child.

func Column

func Column(children ...Widget) Widget

Column creates a vertical Flex.

func DecoratedBox

func DecoratedBox(decoration Decoration, child Widget) Widget

DecoratedBox returns a widget that paints decoration behind child.

func Expanded

func Expanded(child Widget) Widget

Expanded wraps child with a tight flex factor of 1.

func Flexible

func Flexible(child Widget) Widget

Flexible wraps child with a loose flex factor of 1.

func Focus

func Focus(node *FocusNode, child Widget) Widget

Focus returns a focusable wrapper around child.

func FocusWithOptions

func FocusWithOptions(node *FocusNode, options FocusOptions, child Widget) Widget

FocusWithOptions returns a focusable wrapper around child with options.

func Padding

func Padding(in Insets, child Widget) Widget

Padding returns a widget that insets child.

func Row

func Row(children ...Widget) Widget

Row creates a horizontal Flex.

Directories

Path Synopsis
Package uitest provides small helpers for testing ui widgets without a terminal.
Package uitest provides small helpers for testing ui widgets without a terminal.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL