layout

package
v0.9.12 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Box added in v0.9.11

type Box struct {
	R cellbuf.Rectangle
}

Box wraps a cellbuf.Rectangle to provide a fluent API for layout calculations. It enables declarative layout syntax instead of manual rectangle arithmetic.

func NewBox added in v0.9.11

func NewBox(r cellbuf.Rectangle) Box

NewBox creates a new Box wrapping the given rectangle.

func (Box) Center added in v0.9.11

func (b Box) Center(w, h int) Box

Center returns a box of size w×h centered within this box. If the requested size is larger than available space, it's clamped.

func (Box) CutBottom added in v0.9.11

func (b Box) CutBottom(h int) (rest, bottom Box)

CutBottom cuts h cells from the bottom, returning the rest and the bottom box.

func (Box) CutLeft added in v0.9.11

func (b Box) CutLeft(w int) (left, rest Box)

CutLeft cuts w cells from the left, returning the left box and the rest.

func (Box) CutRight added in v0.9.11

func (b Box) CutRight(w int) (rest, right Box)

CutRight cuts w cells from the right, returning the rest and the right box.

func (Box) CutTop added in v0.9.11

func (b Box) CutTop(h int) (top, rest Box)

CutTop cuts h cells from the top, returning the top box and the rest.

func (Box) H added in v0.9.11

func (b Box) H(specs ...Spec) []Box

H splits the box horizontally (left to right) according to the given specs. Returns a slice of boxes, one for each spec.

func (Box) Inset added in v0.9.11

func (b Box) Inset(n int) Box

Inset returns a new Box with n cells of padding on all sides.

func (Box) V added in v0.9.11

func (b Box) V(specs ...Spec) []Box

V splits the box vertically (top to bottom) according to the given specs. Returns a slice of boxes, one for each spec.

type FillSpec added in v0.9.11

type FillSpec float64

FillSpec allocates space proportionally from remaining space after fixed/pct allocations. The weight determines the proportion: Fill(2) gets twice the space of Fill(1).

type Fixed

type Fixed int

Fixed represents a fixed size in cells.

type Percent

type Percent int

Percent represents a percentage (0-100) of the available space.

type Spec added in v0.9.11

type Spec interface {
	// contains filtered or unexported methods
}

Spec represents a layout specification that determines how space should be allocated. Both the existing Fixed/Percent types and the new FillSpec implement this interface.

func Fill added in v0.9.11

func Fill(weight float64) Spec

Fill creates a Spec that fills remaining space with the given weight. Multiple Fill specs share remaining space proportionally by their weights.

Jump to

Keyboard shortcuts

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