Documentation
¶
Overview ¶
Package components contains reusable TUI components.
Index ¶
- Constants
- func ApplyOverlayListStyles(m list.Model, st styles.Styles) list.Model
- func BunnyCloseCmd() tea.Cmd
- func BunnyHopIdleCmd() tea.Cmd
- func BunnyHopPauseTick() tea.Cmd
- func BunnyHopTick(d time.Duration) tea.Cmd
- func BunnyOpenCmd() tea.Cmd
- func CalloutInnerWidth(st styles.Styles, width int) int
- func HopFrameDuration(frame int) time.Duration
- func HopFrameGap(frame int) int
- func HopFrameProgress(frame int) float64
- func NewTextArea() textarea.Model
- func NewTextInput() textinput.Model
- func PaneInnerSize(st styles.Styles, width, height int) (int, int)
- func RenderBunny(phase int, side BunnySide) string
- func RenderBunnyCrouch(phase int) string
- func RenderBunnyHop(phase int) string
- 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 BunnyBlinkMsg
- type BunnyHopStepMsg
- type BunnyHopTriggerMsg
- type BunnySide
- 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 ¶
const FramesPerHop = 5
FramesPerHop is the number of animation frames in a single hop. Frame sequence: crouch(0), rise(1), peak(2), fall(3), land(4).
Variables ¶
This section is empty.
Functions ¶
func ApplyOverlayListStyles ¶
ApplyOverlayListStyles applies shared overlay foreground styling to list empty states.
func BunnyCloseCmd ¶
BunnyCloseCmd schedules the eye-open 200 ms from now. It fires after the bunny has blinked, signalling time to reopen.
func BunnyHopIdleCmd ¶
BunnyHopIdleCmd waits 10–25 seconds and then fires a hop sequence. The hop count (2 or 3) is chosen at fire time so that multiple instances started at the same wall-clock second don't all hop in sync.
func BunnyHopPauseTick ¶
BunnyHopPauseTick schedules a BunnyHopStepMsg after the between-hop pause. This gives the bunny a moment on the box before launching again.
func BunnyHopTick ¶
BunnyHopTick schedules a BunnyHopStepMsg after the given duration.
func BunnyOpenCmd ¶
BunnyOpenCmd schedules the next blink 4 seconds from now. It fires after the bunny's eyes are already open, signalling time to blink.
func CalloutInnerWidth ¶
CalloutInnerWidth returns the content width available inside the callout shell.
func HopFrameDuration ¶
HopFrameDuration returns the tick duration for each frame within a hop. Crouch/land are short (impact), rise/fall are medium, peak is longest (apex hang).
func HopFrameGap ¶
HopFrameGap returns the number of blank lines between the bunny and the box for the given frame index within a hop. This creates the vertical arc: crouch/land on the box (0 gaps), rise/fall at low height (1 gap), peak at max height (2 gaps).
func HopFrameProgress ¶
HopFrameProgress returns the horizontal progress (0.0–1.0) through the current individual hop for the given frame. The bunny accelerates during the first half and decelerates during the second half, mimicking a natural parabolic arc.
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 RenderBunny ¶
RenderBunny returns the 3-line ASCII bunny art for the given blink phase and corner side. The bottom line is the feet; callers should join this string above a bordered box using the matching lipgloss alignment so the foot character touches the box corner.
func RenderBunnyCrouch ¶
RenderBunnyCrouch returns the 3-line crouched bunny art for the given blink phase. Like RenderBunnyHop, lines have no intrinsic horizontal position.
func RenderBunnyHop ¶
RenderBunnyHop returns the 3-line airborne bunny art for the given blink phase. Lines have no intrinsic horizontal position: the caller is responsible for padding each line to the desired offset within the container width.
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 BunnyBlinkMsg ¶
type BunnyBlinkMsg struct{ Phase int }
BunnyBlinkMsg is dispatched when the blink animation state should change. Phase 0 = eyes open, phase 1 = eyes closed.
type BunnyHopStepMsg ¶
type BunnyHopStepMsg struct{}
BunnyHopStepMsg advances the hop animation by one frame. It is reused for both in-hop frame advances and between-hop pauses.
type BunnyHopTriggerMsg ¶
type BunnyHopTriggerMsg struct{ Hops int }
BunnyHopTriggerMsg begins a hop sequence. Hops is the number of individual hops (2 or 3), chosen randomly at fire time. A 2-hop sequence touches the box once; a 3-hop sequence touches it twice.
type BunnySide ¶
type BunnySide int
BunnySide determines on which corner of the box the bunny sits. The value is chosen randomly at startup and held for the lifetime of the model.
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 ¶
type HeaderBlockSpec struct {
Title string
Meta string
Width int
Divider bool
// StatusLine, when non-empty and Divider is true, replaces the ─── divider
// row with this pre-rendered string. The header line count is unchanged;
// callers can use this to show a transient warning in-place without pushing
// subsequent content down.
StatusLine string
}
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.