layout

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package layout computes pure Go flexbox geometry for an Element tree. It never touches a terminal or mutates its input.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapText

func WrapText(text string, width int) []string

WrapText breaks text into lines no wider than width, breaking on spaces where possible and hard-breaking a single word that's wider than width on its own.

Types

type Node

type Node struct {
	Element  types.Element
	Rect     Rect
	Children []Node
}

Node mirrors an Element with its computed Rect attached.

func Layout

func Layout(el types.Element, width, height int) Node

Layout computes the position and size of el and every descendant within a width x height viewport. It is deterministic and never mutates el.

type Rect

type Rect struct {
	X, Y, W, H int
}

Rect is an axis-aligned region in terminal cells.

func ContentRect

func ContentRect(rect Rect, s types.Style) Rect

ContentRect returns the area inside a Box's border and padding.

func (Rect) Intersect

func (r Rect) Intersect(o Rect) Rect

Intersect returns the overlapping region of r and o, with zero width/height if they don't overlap.

Jump to

Keyboard shortcuts

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