ui
import "go-cli-template/internal/ui"Index
- func ApplyFrameListSize(model *list.Model, width, height int, opts FrameSizeOptions)
- func ApplyListFilterStyles(model *list.Model, theme Theme)
- func ApplyListStyles(model *list.Model, theme Theme)
- func ClipboardConfirm(theme Theme) string
- func ConfigureTextarea(input *textarea.Model, theme Theme, altEnterSubmit bool) (key.Binding, key.Binding)
- func ExitMessage(theme Theme, message string, mutedText bool) string
- func FrameStyle(theme Theme) lipgloss.Style
- func ListFullHelpSections(model list.Model, opts ListHelpOptions) [][]key.Binding
- func ListHelpView(model list.Model, short []key.Binding, full [][]key.Binding) string
- func NewListDelegate(theme Theme, opts ListDelegateOptions) list.ItemDelegate
- func NewListModel(items []list.Item, delegate list.ItemDelegate, width, height int, theme Theme) list.Model
- func PromptConfirmation(title, prompt string, theme Theme) (bool, error)
- func TextareaKeyBindings(altEnterSubmit bool) (key.Binding, key.Binding)
- func TextareaSubmitHelp(submitKey key.Binding, action string) string
- type Breakpoint
- type ConfirmationModel
- type FrameSizeOptions
- type ItemWithMetadata
- type ListDelegateOptions
- type ListHelpOptions
- type ResponsiveManager
- func NewResponsiveManager(width int) *ResponsiveManager
- func (rm *ResponsiveManager) AdaptiveFrameStyle(theme Theme) lipgloss.Style
- func (rm *ResponsiveManager) Breakpoint() Breakpoint
- func (rm *ResponsiveManager) GetContentInsets() (horizontal, vertical int)
- func (rm *ResponsiveManager) GetHelpHeight() int
- func (rm *ResponsiveManager) GetListDimensions(availableWidth, availableHeight int) (width, height int)
- func (rm *ResponsiveManager) IsAtLeast(bp Breakpoint) bool
- func (rm *ResponsiveManager) IsAtMost(bp Breakpoint) bool
- func (rm *ResponsiveManager) MaxContentWidth() int
- func (rm *ResponsiveManager) SetWidth(width int)
- func (rm *ResponsiveManager) ShouldShowBorders() bool
- func (rm *ResponsiveManager) ShouldShowFullHelp() bool
- func (rm *ResponsiveManager) Width() int
- type Theme
func ApplyFrameListSize
func ApplyFrameListSize(model *list.Model, width, height int, opts FrameSizeOptions)ApplyFrameListSize clamps a list to fit a framed container.
func ApplyListFilterStyles
func ApplyListFilterStyles(model *list.Model, theme Theme)ApplyListFilterStyles sets shared filter styles for lists.
func ApplyListStyles
func ApplyListStyles(model *list.Model, theme Theme)ApplyListStyles sets shared list styles.
func ClipboardConfirm
func ClipboardConfirm(theme Theme) stringClipboardConfirm renders the standard clipboard confirmation message.
func ConfigureTextarea
func ConfigureTextarea(input *textarea.Model, theme Theme, altEnterSubmit bool) (key.Binding, key.Binding)ConfigureTextarea applies shared styles and keybindings for multi-line input.
func ExitMessage
func ExitMessage(theme Theme, message string, mutedText bool) stringExitMessage renders a standard framed exit message.
func FrameStyle
func FrameStyle(theme Theme) lipgloss.StyleFrameStyle defines a shared container style for bordered views.
func ListFullHelpSections
func ListFullHelpSections(model list.Model, opts ListHelpOptions) [][]key.Bindingfunc ListHelpView
func ListHelpView(model list.Model, short []key.Binding, full [][]key.Binding) stringfunc NewListDelegate
func NewListDelegate(theme Theme, opts ListDelegateOptions) list.ItemDelegateNewListDelegate provides shared list focus styles.
func NewListModel
func NewListModel(items []list.Item, delegate list.ItemDelegate, width, height int, theme Theme) list.ModelNewListModel creates a list with shared styles applied.
func PromptConfirmation
func PromptConfirmation(title, prompt string, theme Theme) (bool, error)PromptConfirmation runs a confirmation dialog and returns the user’s choice
func TextareaKeyBindings
func TextareaKeyBindings(altEnterSubmit bool) (key.Binding, key.Binding)TextareaKeyBindings returns submit and newline bindings based on config.
func TextareaSubmitHelp
func TextareaSubmitHelp(submitKey key.Binding, action string) stringTextareaSubmitHelp formats the key help for a multi-line submit action.
type Breakpoint
Breakpoint defines responsive size categories.
type Breakpoint intconst ( // BreakpointXS represents extra small screens (< 40 columns). BreakpointXS Breakpoint = iota // BreakpointSM represents small screens (40-60 columns). BreakpointSM // BreakpointMD represents medium screens (60-80 columns). BreakpointMD // BreakpointLG represents large screens (80-100 columns). BreakpointLG // BreakpointXL represents extra large screens (>= 100 columns). BreakpointXL)type ConfirmationModel
ConfirmationModel is a reusable confirmation dialog component based on huh.Confirm. It provides a styled yes/no dialog with keyboard shortcuts.
Example usage as a standalone dialog:
confirmed, err := ui.PromptConfirmation("Delete file?", "Are you sure?", theme)if err != nil { return err}if confirmed { // perform action}Example usage embedded in another Bubble Tea model:
// In your model struct:type myModel struct { confirmMode bool confirm *ui.ConfirmationModel}
// To show the dialog:confirmModel := ui.NewConfirmationModel("Delete?", "Are you sure?", theme)m.confirmMode = truem.confirm = &confirmModelreturn m, confirmModel.Init()
// In Update method:if m.confirmMode { updated, cmd := m.confirm.Update(msg) if updatedConfirm, ok := updated.(ui.ConfirmationModel); ok { m.confirm = &updatedConfirm if cmd != nil { if _, isQuit := cmd().(tea.QuitMsg); isQuit { confirmed := m.confirm.ChoiceValue() m.confirmMode = false // handle result } } } return m, cmd}
// In View method:if m.confirmMode && m.confirm != nil { return m.confirm.View()}type ConfirmationModel struct { // contains filtered or unexported fields}func NewConfirmationModel
func NewConfirmationModel(title, prompt string, theme Theme) ConfirmationModelNewConfirmationModel creates a new confirmation dialog
func (ConfirmationModel) ChoiceValue
func (m ConfirmationModel) ChoiceValue() boolChoiceValue returns the user’s choice
func (ConfirmationModel) Init
func (m ConfirmationModel) Init() tea.CmdInit initializes the confirmation dialog
func (ConfirmationModel) Update
func (m ConfirmationModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)Update handles messages for the confirmation dialog
func (ConfirmationModel) View
func (m ConfirmationModel) View() stringView renders the confirmation dialog
type FrameSizeOptions
FrameSizeOptions configures shared list sizing inside framed views.
type FrameSizeOptions struct { HorizontalInset int VerticalInset int MinWidth int MinHeight int}func FrameSizeDefaults
func FrameSizeDefaults() FrameSizeOptionsFrameSizeDefaults returns base inset values for framed views.
type ItemWithMetadata
ItemWithMetadata is an optional interface that list items can implement to provide a third row of metadata under the description. Note: Currently items should embed metadata in Description() directly. This interface is reserved for future use when custom delegate rendering is implemented.
type ItemWithMetadata interface { list.Item Metadata() string}type ListDelegateOptions
ListDelegateOptions configures shared list presentation settings.
type ListDelegateOptions struct { Height int PaddingLeft int SelectedPaddingLeft int Spacing string // "compact", "tight", or "space" (default) ShowMetadata bool // Enable metadata row support MetadataIndent int // Indentation for metadata row (default: 1)}type ListHelpOptions
type ListHelpOptions struct { IncludeFilter bool IncludePaging bool IncludeQuit bool}type ResponsiveManager
ResponsiveManager tracks view width and provides responsive utilities.
type ResponsiveManager struct { // contains filtered or unexported fields}func NewResponsiveManager
func NewResponsiveManager(width int) *ResponsiveManagerNewResponsiveManager creates a new responsive manager with the given width.
func (*ResponsiveManager) AdaptiveFrameStyle
func (rm *ResponsiveManager) AdaptiveFrameStyle(theme Theme) lipgloss.StyleAdaptiveFrameStyle returns a frame style that adapts based on breakpoint. XS: No padding, no margin, no border SM: Padding only, no margin, no border MD+: Full styling with padding, margin, and border
func (*ResponsiveManager) Breakpoint
func (rm *ResponsiveManager) Breakpoint() BreakpointBreakpoint returns the current breakpoint category.
func (*ResponsiveManager) GetContentInsets
func (rm *ResponsiveManager) GetContentInsets() (horizontal, vertical int)GetContentInsets returns the horizontal and vertical insets for content based on the current breakpoint. These values account for padding, margins, and borders applied by AdaptiveFrameStyle.
func (*ResponsiveManager) GetHelpHeight
func (rm *ResponsiveManager) GetHelpHeight() intGetHelpHeight returns the recommended height for help text based on breakpoint.
func (*ResponsiveManager) GetListDimensions
func (rm *ResponsiveManager) GetListDimensions(availableWidth, availableHeight int) (width, height int)GetListDimensions returns responsive width and height for a list component. It accounts for frame insets and provides sensible defaults based on breakpoint.
func (*ResponsiveManager) IsAtLeast
func (rm *ResponsiveManager) IsAtLeast(bp Breakpoint) boolIsAtLeast checks if the current breakpoint is at least the given size.
func (*ResponsiveManager) IsAtMost
func (rm *ResponsiveManager) IsAtMost(bp Breakpoint) boolIsAtMost checks if the current breakpoint is at most the given size.
func (*ResponsiveManager) MaxContentWidth
func (rm *ResponsiveManager) MaxContentWidth() intMaxContentWidth returns the maximum usable content width accounting for padding/borders.
func (*ResponsiveManager) SetWidth
func (rm *ResponsiveManager) SetWidth(width int)SetWidth updates the tracked width and recalculates the breakpoint.
func (*ResponsiveManager) ShouldShowBorders
func (rm *ResponsiveManager) ShouldShowBorders() boolShouldShowBorders returns true if borders should be rendered (MD or larger).
func (*ResponsiveManager) ShouldShowFullHelp
func (rm *ResponsiveManager) ShouldShowFullHelp() boolShouldShowFullHelp returns true if there’s enough space to show full help.
func (*ResponsiveManager) Width
func (rm *ResponsiveManager) Width() intWidth returns the current tracked width.
type Theme
Theme holds configurable colors for UI output.
type Theme struct { Headings lipgloss.Color Primary lipgloss.Color Secondary lipgloss.Color Text lipgloss.Color TextHighlight lipgloss.Color DescriptionHighlight lipgloss.Color Tags lipgloss.Color Flags lipgloss.Color Muted lipgloss.Color Border lipgloss.Color}func ThemeFromConfig
func ThemeFromConfig(cfg domain.Config) ThemeThemeFromConfig builds a theme with safe fallbacks.
Source
See internal/ui/ for implementation details.