Documentation
¶
Index ¶
- Constants
- func BuildFooter(info FooterInfo, width int, bp Breakpoint, t theme.Theme, ...) string
- func BuildHeader(info HeaderInfo, width int, bp Breakpoint, t theme.Theme, ...) string
- func CenterText(text string, style lipgloss.Style, width int) string
- func FitContent(content string, w, h int) string
- func RenderBox(content string, w, h int, opts ...BoxOption) string
- func RenderCard(title, content string, w int, border lipgloss.Border, ...) string
- func RenderDimmed(content string, t theme.Theme) string
- func RenderDimmedOverlay(base string, overlay string, width, height int, t theme.Theme) string
- func RenderModalOverlay(base string, modal string, width, height int, t theme.Theme) string
- func RenderOverlay(base string, overlay string, width, height, overlayWidth int, t theme.Theme) string
- func RenderPage(chrome PageChrome, content string, header HeaderInfo, footer FooterInfo, ...) string
- func RenderStack(width, height int, layers []StackLayer) string
- func RenderTooNarrow(width, height int, t theme.Theme) string
- func ShowFooterCost(width int) bool
- func ShowFooterHints(width int) bool
- func ShowHeaderRight(width int) bool
- func ShowSidebar(width int) bool
- func Solve(root *Box) string
- func SplitHorizontal(totalW int, count int, gap int, fixed ...int) []int
- func SplitVertical(totalH int, count int, gap int, fixed ...int) []int
- type Align
- type Box
- type BoxOption
- type Breakpoint
- type FlexDirection
- type FooterInfo
- type HeaderInfo
- type Insets
- type PageChrome
- type RenderFunc
- type Renderer
- type StackLayer
- type StaticRenderer
Constants ¶
const ( MinWidth = 40 CompactMax = 59 StandardMax = 79 )
Width thresholds.
const ChromeHeight = 2
ChromeHeight is the total number of rows consumed by the unified header and footer. Content height = terminal height - ChromeHeight.
Variables ¶
This section is empty.
Functions ¶
func BuildFooter ¶
func BuildFooter(info FooterInfo, width int, bp Breakpoint, t theme.Theme, cache *theme.StyleCache) string
BuildFooter renders the unified 1-line footer bar.
Layout (premium): ⌂ cwd ⎇ branch │ ⠹ responding... │ ctrl+p · ctrl+b $0.02 Uses │ separators to create distinct zones with visual weight.
func BuildHeader ¶
func BuildHeader(info HeaderInfo, width int, bp Breakpoint, t theme.Theme, cache *theme.StyleCache) string
BuildHeader renders the unified 1-line header bar.
Layout (premium): M31A │ breadcrumb ········ model [provider] [ctx] Uses │ separators and leader dots to create visual depth.
func CenterText ¶
CenterText centers a styled text within a given width.
func FitContent ¶ added in v1.2.0
FitContent ensures content fits within exactly w columns and h rows, padding with spaces or clipping as needed.
func RenderBox ¶ added in v1.2.0
RenderBox is a convenience function that creates a Box, solves it, and returns the rendered string. It handles the common case of a single bordered, padded container.
func RenderCard ¶ added in v1.2.0
func RenderCard(title, content string, w int, border lipgloss.Border, borderColor, bg lipgloss.Color) string
RenderCard renders a card-style box with title, content, border, and padding.
func RenderDimmed ¶ added in v1.2.0
RenderDimmed applies a dimming effect to content by prepending the ANSI faint attribute to each line, preserving existing styling.
func RenderDimmedOverlay ¶ added in v1.2.0
RenderDimmedOverlay composites a dimmed base with a centered overlay.
func RenderModalOverlay ¶ added in v1.2.0
RenderModalOverlay renders a modal centered on a dimmed background. Uses string-based line composition (left + modal + right segments joined by concatenation) to avoid corrupting ANSI escape codes that rune-by-rune stamping would break.
func RenderOverlay ¶
func RenderOverlay(base string, overlay string, width, height, overlayWidth int, t theme.Theme) string
RenderOverlay renders a sidebar or modal overlay on top of existing content. The overlay occupies the right portion of the terminal with a dimmed backdrop.
func RenderPage ¶
func RenderPage(chrome PageChrome, content string, header HeaderInfo, footer FooterInfo, t theme.Theme, cache *theme.StyleCache) string
RenderPage composes the unified page layout: 1-line header + content + 1-line footer. The total output is exactly Height rows.
func RenderStack ¶ added in v1.2.0
func RenderStack(width, height int, layers []StackLayer) string
RenderStack composites multiple layers at different Z-depths. Later layers render on top of earlier ones. The base layer is filled with spaces.
func RenderTooNarrow ¶
RenderTooNarrow renders a centered "resize terminal" message when the terminal is below the minimum width threshold.
func ShowFooterCost ¶
ShowFooterCost returns true when token/cost info should appear in the footer. Hidden below 80 cols.
func ShowFooterHints ¶
ShowFooterHints returns true when keyboard shortcut hints should appear in the footer. Hidden below 60 cols.
func ShowHeaderRight ¶
ShowHeaderRight returns true when the header right zone (model badge, context meter) should be rendered. Hidden below 60 cols.
func ShowSidebar ¶
ShowSidebar returns true when the sidebar should be displayed alongside content (width ≥ 80). Below this threshold the sidebar is hidden and can only be shown as an overlay via ctrl+b.
func Solve ¶ added in v1.2.0
Solve recursively resolves the layout tree and returns the rendered string. The root Box's Width and Height define the available space. If 0, content sizes itself.
func SplitHorizontal ¶ added in v1.2.0
SplitHorizontal splits available width among N children with optional gaps. Returns a slice of widths. Fixed widths are honored first, then remaining space is divided equally.
Types ¶
type Box ¶ added in v1.2.0
type Box struct {
// Fixed dimensions. 0 means auto (fill available space).
Width int
Height int
// Flex grow factor. Children with Flex > 0 share remaining space
// proportionally after fixed-size children are allocated.
Flex int
// Direction of child layout.
Direction FlexDirection
// Cross-axis alignment of children.
Align Align
// Gap between children in cells.
Gap int
// Inner padding.
Padding Insets
// Border style.
Border lipgloss.Border
// Border color.
BorderColor lipgloss.Color
// Background color.
Background lipgloss.Color
// Content is rendered when there are no children.
Content Renderer
// Children are laid out according to Direction and Flex.
Children []*Box
}
Box is the fundamental layout primitive. It arranges children either in a Row or Column, distributing space using flex factors.
func (*Box) WithBackground ¶ added in v1.2.0
WithBackground sets the background color and returns the Box.
func (*Box) WithBorder ¶ added in v1.2.0
WithBorder sets border and color and returns the Box.
func (*Box) WithContent ¶ added in v1.2.0
WithContent sets the content renderer and returns the Box.
func (*Box) WithPadding ¶ added in v1.2.0
WithPadding sets uniform padding and returns the Box.
type BoxOption ¶ added in v1.2.0
type BoxOption func(*Box)
BoxOption configures a Box for RenderBox.
func WithBoxBackground ¶ added in v1.2.0
WithBoxBackground sets the background color.
func WithBoxBorder ¶ added in v1.2.0
WithBoxBorder sets a border on the Box.
func WithBoxPadding ¶ added in v1.2.0
WithBoxPadding sets uniform padding.
type Breakpoint ¶
type Breakpoint int
Breakpoint classifies terminal width for responsive layout decisions.
const ( // UltraNarrow: < 40 cols — show "resize terminal" message only. UltraNarrow Breakpoint = iota // Compact: 40–59 cols — minimal chrome, no sidebar, no hints. Compact // Standard: 60–79 cols — full chrome, no sidebar. Standard // Full: ≥ 80 cols — sidebar visible, all chrome, full key hints. Full )
func Detect ¶
func Detect(width int) Breakpoint
Detect returns the breakpoint for a given terminal width.
type FlexDirection ¶ added in v1.2.0
type FlexDirection int
FlexDirection controls child arrangement within a Box.
const ( Column FlexDirection = iota Row )
type FooterInfo ¶
type FooterInfo struct {
}
FooterInfo carries the data needed to render the unified footer.
type HeaderInfo ¶
type HeaderInfo struct {
Brand string // "M31A"
Breadcrumb string // screen name, phase breadcrumb, or git branch
ModelName string // active model name
Provider string // provider short name (OR, ZEN)
CtxUsed int // context tokens used
CtxTotal int // context tokens total
CtxHistory []int // recent context usage readings for sparkline
}
HeaderInfo carries the data needed to render the unified header.
type Insets ¶ added in v1.2.0
Insets represents padding or margin on four sides.
func SymmetricInsets ¶ added in v1.2.0
SymmetricInsets creates insets with equal vertical and horizontal values.
func UniformInsets ¶ added in v1.2.0
UniformInsets creates insets with equal values on all sides.
func (Insets) Horizontal ¶ added in v1.2.0
Horizontal returns the sum of Left + Right.
type PageChrome ¶
PageChrome holds the computed header and footer strings along with dimensions used for content layout.
func (PageChrome) ContentHeight ¶
func (p PageChrome) ContentHeight() int
ContentHeight returns the number of rows available for screen content.
func (PageChrome) ContentWidth ¶
func (p PageChrome) ContentWidth() int
ContentWidth returns the width available for screen content.
type RenderFunc ¶ added in v1.2.0
RenderFunc adapts a function to the Renderer interface.
func (RenderFunc) Render ¶ added in v1.2.0
func (f RenderFunc) Render(width, height int) string
type StackLayer ¶ added in v1.2.0
type StackLayer struct {
Content string
X int // horizontal offset from left
Y int // vertical offset from top
Width int // 0 = auto from content
Height int // 0 = auto from content
}
StackLayer represents one layer in a Z-order composition.
type StaticRenderer ¶ added in v1.2.0
type StaticRenderer struct {
Content string
}
StaticRenderer wraps a pre-rendered string as a Renderer.
func (StaticRenderer) Render ¶ added in v1.2.0
func (s StaticRenderer) Render(_, _ int) string