components

package
v0.0.1-alpha12 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package components contains reusable TUI components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyOverlayListStyles

func ApplyOverlayListStyles(m list.Model, st styles.Styles) list.Model

ApplyOverlayListStyles applies shared overlay foreground styling to list empty states.

func CalloutInnerWidth

func CalloutInnerWidth(st styles.Styles, width int) int

CalloutInnerWidth returns the content width available inside the callout shell.

func NewTextArea

func NewTextArea() textarea.Model

NewTextArea returns a textarea.Model pre-configured with macOS-compatible key bindings. Use this everywhere in the TUI instead of textarea.New().

textarea's default key map omits ctrl+right and ctrl+left for word movement, while textinput's default includes them. macOSTextAreaKeyMap restores that parity so ⌥+→/← works in both component types regardless of whether the terminal sends the CSI alt+right/alt+left sequence or the ctrl+right/ctrl+left sequence.

func NewTextInput

func NewTextInput() textinput.Model

NewTextInput returns a textinput.Model ready for use. Use this everywhere in the TUI instead of textinput.New() so that input construction is centralised and any future key-binding or style changes apply uniformly without hunting call sites.

The default textinput key map already covers all standard macOS terminal editing shortcuts (⌥+Backspace → alt+backspace, ⌘+Backspace → ctrl+u, ⌥+←/→ → alt+left/right, ⌘+←/→ → ctrl+a/ctrl+e, word movement via ctrl+left/ctrl+right). No extra bindings are required for textinput.

func PaneInnerSize

func PaneInnerSize(st styles.Styles, width, height int) (int, int)

PaneInnerSize returns the content box available inside a shared pane shell.

func RenderCallout

func RenderCallout(st styles.Styles, spec CalloutSpec) string

RenderCallout renders semantic bordered content.

func RenderDivider

func RenderDivider(st styles.Styles, width int) string

RenderDivider renders a full-width semantic divider.

func RenderHeaderBlock

func RenderHeaderBlock(st styles.Styles, spec HeaderBlockSpec) string

RenderHeaderBlock renders shared title/meta/divider workflow chrome.

func RenderKeyHints

func RenderKeyHints(st styles.Styles, hints []KeyHint, separator string) string

RenderKeyHints renders a semantic keybind row.

func RenderOverlayDivider

func RenderOverlayDivider(st styles.Styles, width int) string

RenderOverlayDivider renders a semantic divider line for overlay content.

func RenderOverlayFrame

func RenderOverlayFrame(st styles.Styles, frameWidth int, spec OverlayFrameSpec) string

RenderOverlayFrame renders the outer overlay shell around header, body, and footer content.

func RenderPane

func RenderPane(st styles.Styles, spec PaneSpec) string

RenderPane renders shared bordered pane chrome around already-sized content.

func RenderProgressBar

func RenderProgressBar(st styles.Styles, done, total, width int) string

RenderProgressBar renders a semantic text progress bar of the given width.

func RenderSplitOverlayBody

func RenderSplitOverlayBody(st styles.Styles, layout SplitOverlayLayout, spec SplitOverlaySpec) string

RenderSplitOverlayBody renders a split left/right pane body using a computed layout.

func RenderTabs

func RenderTabs(st styles.Styles, labels []string, active int, separator string) string

RenderTabs renders an active/inactive semantic tabs row.

func ToastTickCmd

func ToastTickCmd() tea.Cmd

ToastTickCmd returns a Cmd that fires after 1s.

Types

type CalloutSpec

type CalloutSpec struct {
	Body    string
	Width   int
	Variant CalloutVariant
}

CalloutSpec describes a bordered content box.

type CalloutVariant

type CalloutVariant int

CalloutVariant selects the semantic surface treatment.

const (
	CalloutDefault CalloutVariant = iota
	CalloutCard
	CalloutWarning
	CalloutRunning // active/accent border color for in-progress tool cards
	CalloutError   // error border color for failed tool cards
	CalloutTool    // completed tool call — more visible border than CalloutDefault
)

type ConfirmDialog

type ConfirmDialog struct {
	Title   string
	Message string
	OnYes   tea.Cmd
	Active  bool
	Styles  styles.Styles
}

ConfirmDialog is a generic yes/no confirmation modal.

func NewConfirmDialog

func NewConfirmDialog(st styles.Styles, title, message string, onYes tea.Cmd) ConfirmDialog

NewConfirmDialog creates an active confirmation dialog.

func (ConfirmDialog) View

func (d ConfirmDialog) View() string

View renders the dialog; returns empty string when inactive.

type ConfirmMsg

type ConfirmMsg struct{ Confirmed bool }

ConfirmMsg is emitted when the dialog is resolved.

type HeaderBlockSpec

type HeaderBlockSpec struct {
	Title   string
	Meta    string
	Width   int
	Divider bool
}

HeaderBlockSpec describes a semantic title/meta/divider block.

type KeyHint

type KeyHint struct {
	Key   string
	Label string
}

KeyHint is a semantic key/label pair.

type OverlayFrameSpec

type OverlayFrameSpec struct {
	HeaderLines []string
	Body        string
	Footer      string
	Focused     bool
}

OverlayFrameSpec describes the outer overlay shell.

type OverlayPaneSpec

type OverlayPaneSpec struct {
	Title        string
	DividerWidth int
	Body         string
	Focused      bool
}

OverlayPaneSpec describes a bordered pane inside a split overlay body.

type PaneSpec

type PaneSpec struct {
	Content string
	Width   int
	Height  int
	Focused bool
}

PaneSpec describes a bordered application pane.

type RenderedKeyHint

type RenderedKeyHint struct {
	Raw      string
	Rendered string
}

RenderedKeyHint preserves both rendered and plain-text forms for layout decisions.

func RenderKeyHintFragments

func RenderKeyHintFragments(st styles.Styles, hints []KeyHint) []RenderedKeyHint

RenderKeyHintFragments styles individual keybind hints for shared consumption.

type SplitOverlayLayout

type SplitOverlayLayout struct {
	FrameWidth      int
	ContentWidth    int
	InputWidth      int
	BodyHeight      int
	LeftPaneWidth   int
	RightPaneWidth  int
	LeftInnerWidth  int
	RightInnerWidth int
	ListHeight      int
	ViewportWidth   int
	ViewportHeight  int
}

SplitOverlayLayout is the computed geometry for rendering a split overlay.

func ComputeSplitOverlayLayout

func ComputeSplitOverlayLayout(termWidth, termHeight, chromeLines int, spec SplitOverlaySizingSpec) SplitOverlayLayout

ComputeSplitOverlayLayout calculates the shared geometry for split overlays.

type SplitOverlaySizingSpec

type SplitOverlaySizingSpec struct {
	MaxOverlayWidth   int
	LeftMinWidth      int
	RightMinWidth     int
	LeftWeight        int
	RightWeight       int
	MinBodyHeight     int
	DefaultBodyHeight int
	HeightRatioNum    int
	HeightRatioDen    int
	InputWidthOffset  int
}

SplitOverlaySizingSpec describes the geometry constraints for a split list/detail overlay.

type SplitOverlaySpec

type SplitOverlaySpec struct {
	LeftPane  OverlayPaneSpec
	RightPane OverlayPaneSpec
}

SplitOverlaySpec describes the split-pane body content.

type Toast

type Toast struct {
	Message string
	Level   ToastLevel
	Expires time.Time
	// contains filtered or unexported fields
}

type ToastLevel

type ToastLevel int
const (
	ToastInfo ToastLevel = iota
	ToastSuccess
	ToastWarning
	ToastError
)

type ToastModel

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

func NewToastModel

func NewToastModel(st styles.Styles) ToastModel

func (*ToastModel) AddToast

func (m *ToastModel) AddToast(msg string, level ToastLevel)

func (*ToastModel) HasToasts

func (m *ToastModel) HasToasts() bool

func (*ToastModel) Prune

func (m *ToastModel) Prune()

func (*ToastModel) SetWidth

func (m *ToastModel) SetWidth(terminalWidth int)

func (*ToastModel) StackView

func (m *ToastModel) StackView(pinned ...Toast) string

func (*ToastModel) View

func (m *ToastModel) View() string

type ToastTickMsg

type ToastTickMsg time.Time

ToastTickMsg is sent every second to prune expired toasts.

Jump to

Keyboard shortcuts

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