layout

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinWidth    = 40
	CompactMax  = 59
	StandardMax = 79
)

Width thresholds.

View Source
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) 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) 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

func CenterText(text string, style lipgloss.Style, width int) string

CenterText centers a styled text within a given width.

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) string

RenderPage composes the unified page layout: 1-line header + content + 1-line footer. The total output is exactly Height rows.

func RenderTooNarrow

func RenderTooNarrow(width, height int, t theme.Theme) string

RenderTooNarrow renders a centered "resize terminal" message when the terminal is below the minimum width threshold.

func ShowFooterCost

func ShowFooterCost(width int) bool

ShowFooterCost returns true when token/cost info should appear in the footer. Hidden below 80 cols.

func ShowFooterHints

func ShowFooterHints(width int) bool

ShowFooterHints returns true when keyboard shortcut hints should appear in the footer. Hidden below 60 cols.

func ShowHeaderRight

func ShowHeaderRight(width int) bool

ShowHeaderRight returns true when the header right zone (model badge, context meter) should be rendered. Hidden below 60 cols.

func ShowSidebar

func ShowSidebar(width int) bool

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.

Types

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 FooterInfo

type FooterInfo struct {
	Cwd           string   // working directory basename
	GitBranch     string   // current git branch
	Operation     string   // "thinking...", "responding...", phase name
	LeaderActive  bool     // leader key mode active
	KeyboardHints []string // e.g. "ctrl+p commands"
	TokenCount    int      // total tokens used
	Cost          float64  // session cost
	ShowCost      bool     // whether to display cost
	SpinnerFrame  string   // animated spinner character
}

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
}

HeaderInfo carries the data needed to render the unified header.

type PageChrome

type PageChrome struct {
	Width  int
	Height int
}

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.

Jump to

Keyboard shortcuts

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