Documentation
¶
Overview ¶
Package components contains reusable TUI components.
Index ¶
- func ApplyOverlayListStyles(m list.Model, st styles.Styles) list.Model
- func CalloutInnerWidth(st styles.Styles, width int) int
- func NewTextArea() textarea.Model
- func NewTextInput() textinput.Model
- func PaneInnerSize(st styles.Styles, width, height int) (int, int)
- func RenderCallout(st styles.Styles, spec CalloutSpec) string
- func RenderDivider(st styles.Styles, width int) string
- func RenderHeaderBlock(st styles.Styles, spec HeaderBlockSpec) string
- func RenderKeyHints(st styles.Styles, hints []KeyHint, separator string) string
- func RenderOverlayDivider(st styles.Styles, width int) string
- func RenderOverlayFrame(st styles.Styles, frameWidth int, spec OverlayFrameSpec) string
- func RenderPane(st styles.Styles, spec PaneSpec) string
- func RenderProgressBar(st styles.Styles, done, total, width int) string
- func RenderSplitOverlayBody(st styles.Styles, layout SplitOverlayLayout, spec SplitOverlaySpec) string
- func RenderTabs(st styles.Styles, labels []string, active int, separator string) string
- func ToastTickCmd() tea.Cmd
- type CalloutSpec
- type CalloutVariant
- type ConfirmDialog
- type ConfirmMsg
- type HeaderBlockSpec
- type KeyHint
- type OverlayFrameSpec
- type OverlayPaneSpec
- type PaneSpec
- type RenderedKeyHint
- type SplitOverlayLayout
- type SplitOverlaySizingSpec
- type SplitOverlaySpec
- type Toast
- type ToastLevel
- type ToastModel
- type ToastTickMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyOverlayListStyles ¶
ApplyOverlayListStyles applies shared overlay foreground styling to list empty states.
func CalloutInnerWidth ¶
CalloutInnerWidth returns the content width available inside the callout shell.
func NewTextArea ¶
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 ¶
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 ¶
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 ¶
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 ¶
RenderKeyHints renders a semantic keybind row.
func RenderOverlayDivider ¶
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 ¶
RenderPane renders shared bordered pane chrome around already-sized content.
func RenderProgressBar ¶
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 ¶
RenderTabs renders an active/inactive semantic tabs row.
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 ¶
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 ¶
HeaderBlockSpec describes a semantic title/meta/divider block.
type OverlayFrameSpec ¶
OverlayFrameSpec describes the outer overlay shell.
type OverlayPaneSpec ¶
OverlayPaneSpec describes a bordered pane inside a split overlay body.
type RenderedKeyHint ¶
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 ¶
ToastTickMsg is sent every second to prune expired toasts.