Documentation
¶
Index ¶
- Constants
- func CalculateCenterCoordinates(foregroundLines []string, backgroundLines []string, ...) (int, int)
- func PlaceOverlay(x, y int, fg, bg string, shadow bool, center bool, opts ...WhitespaceOption) string
- type AnimPhase
- type ConfirmationOverlay
- type ContextMenu
- type ContextMenuItem
- type PickerOverlay
- func (p *PickerOverlay) HandleKeyPress(msg tea.KeyMsg) bool
- func (p *PickerOverlay) IsSubmitted() bool
- func (p *PickerOverlay) IsToggled() bool
- func (p *PickerOverlay) Render() string
- func (p *PickerOverlay) SetHint(hint string)
- func (p *PickerOverlay) SetSize(width, height int)
- func (p *PickerOverlay) Value() string
- type TextInputOverlay
- type TextOverlay
- type ToastManager
- func (tm *ToastManager) Error(msg string) string
- func (tm *ToastManager) GetPosition() (int, int)
- func (tm *ToastManager) HasActiveToasts() bool
- func (tm *ToastManager) Info(msg string) string
- func (tm *ToastManager) Loading(msg string) string
- func (tm *ToastManager) Resolve(id string, typ ToastType, msg string)
- func (tm *ToastManager) SetSize(width, height int)
- func (tm *ToastManager) Success(msg string) string
- func (tm *ToastManager) Tick()
- func (tm *ToastManager) View() string
- type ToastTickMsg
- type ToastType
- type WhitespaceOption
Constants ¶
const ( SlideInDuration = 300 * time.Millisecond SlideOutDuration = 200 * time.Millisecond InfoDismissAfter = 3 * time.Second SuccessDismissAfter = 3 * time.Second ErrorDismissAfter = 5 * time.Second MinToastWidth = 38 MaxToastWidth = 55 MaxToasts = 5 )
Animation and display constants.
Variables ¶
This section is empty.
Functions ¶
func PlaceOverlay ¶
func PlaceOverlay( x, y int, fg, bg string, shadow bool, center bool, opts ...WhitespaceOption, ) string
PlaceOverlay places fg on top of bg with an optional shadow effect. If center is true, the foreground is centered on the background; otherwise, the provided x and y are used.
Types ¶
type ConfirmationOverlay ¶
type ConfirmationOverlay struct {
// Whether the overlay has been dismissed
Dismissed bool
// Callback function to be called when the user confirms (presses 'y')
OnConfirm func()
// Callback function to be called when the user cancels (presses 'n' or 'esc')
OnCancel func()
// Custom confirm key (defaults to 'y')
ConfirmKey string
// Custom cancel key (defaults to 'n')
CancelKey string
// contains filtered or unexported fields
}
ConfirmationOverlay represents a confirmation dialog overlay
func NewConfirmationOverlay ¶
func NewConfirmationOverlay(message string) *ConfirmationOverlay
NewConfirmationOverlay creates a new confirmation dialog overlay with the given message
func (*ConfirmationOverlay) HandleKeyPress ¶
func (c *ConfirmationOverlay) HandleKeyPress(msg tea.KeyMsg) bool
HandleKeyPress processes a key press and updates the state Returns true if the overlay should be closed
func (*ConfirmationOverlay) Render ¶
func (c *ConfirmationOverlay) Render(opts ...WhitespaceOption) string
Render renders the confirmation overlay
func (*ConfirmationOverlay) SetWidth ¶
func (c *ConfirmationOverlay) SetWidth(width int)
SetWidth sets the width of the confirmation overlay
type ContextMenu ¶
type ContextMenu struct {
// contains filtered or unexported fields
}
ContextMenu displays a floating context menu with search and numbered shortcuts.
func NewContextMenu ¶
func NewContextMenu(x, y int, items []ContextMenuItem) *ContextMenu
NewContextMenu creates a context menu at the given screen position.
func (*ContextMenu) GetPosition ¶
func (c *ContextMenu) GetPosition() (int, int)
GetPosition returns the screen coordinates for overlay placement.
func (*ContextMenu) HandleKeyPress ¶
func (c *ContextMenu) HandleKeyPress(msg tea.KeyMsg) (string, bool)
HandleKeyPress processes key events. Returns the selected action string, or "" if no selection. Returns ("", false) if menu stays open, (action, true) if an item was selected, ("", true) if dismissed.
func (*ContextMenu) Render ¶
func (c *ContextMenu) Render() string
Render returns the styled menu string.
type ContextMenuItem ¶
type ContextMenuItem struct {
Label string
Action string // identifier returned when selected
Disabled bool
}
ContextMenuItem represents a single menu option.
type PickerOverlay ¶
type PickerOverlay struct {
// contains filtered or unexported fields
}
PickerOverlay shows a searchable list of options for selection.
func NewPickerOverlay ¶
func NewPickerOverlay(title string, items []string) *PickerOverlay
NewPickerOverlay creates a picker with a title and list of items.
func (*PickerOverlay) HandleKeyPress ¶
func (p *PickerOverlay) HandleKeyPress(msg tea.KeyMsg) bool
HandleKeyPress processes input. Returns true when the overlay should close.
func (*PickerOverlay) IsSubmitted ¶
func (p *PickerOverlay) IsSubmitted() bool
IsSubmitted returns true if the user pressed Enter.
func (*PickerOverlay) IsToggled ¶ added in v0.2.1
func (p *PickerOverlay) IsToggled() bool
IsToggled returns true if the user pressed Space (secondary action).
func (*PickerOverlay) Render ¶
func (p *PickerOverlay) Render() string
Render draws the picker overlay.
func (*PickerOverlay) SetHint ¶ added in v0.2.1
func (p *PickerOverlay) SetHint(hint string)
SetHint overrides the default hint text shown at the bottom of the picker.
func (*PickerOverlay) SetSize ¶
func (p *PickerOverlay) SetSize(width, height int)
func (*PickerOverlay) Value ¶
func (p *PickerOverlay) Value() string
Value returns the selected item, or empty string if cancelled or nothing selected.
type TextInputOverlay ¶
type TextInputOverlay struct {
Title string
FocusIndex int // 0 for text input, 1 for enter button
Submitted bool
Canceled bool
OnSubmit func()
// contains filtered or unexported fields
}
TextInputOverlay represents a text input overlay with state management.
func NewTextInputOverlay ¶
func NewTextInputOverlay(title string, initialValue string) *TextInputOverlay
NewTextInputOverlay creates a new text input overlay with the given title and initial value.
func (*TextInputOverlay) GetValue ¶
func (t *TextInputOverlay) GetValue() string
GetValue returns the current value of the text input.
func (*TextInputOverlay) HandleKeyPress ¶
func (t *TextInputOverlay) HandleKeyPress(msg tea.KeyMsg) bool
HandleKeyPress processes a key press and updates the state accordingly. Returns true if the overlay should be closed.
func (*TextInputOverlay) IsSubmitted ¶
func (t *TextInputOverlay) IsSubmitted() bool
IsSubmitted returns whether the form was submitted.
func (*TextInputOverlay) Render ¶
func (t *TextInputOverlay) Render() string
Render renders the text input overlay.
func (*TextInputOverlay) SetSize ¶
func (t *TextInputOverlay) SetSize(width, height int)
type TextOverlay ¶
type TextOverlay struct {
// Whether the overlay has been dismissed
Dismissed bool
// Callback function to be called when the overlay is dismissed
OnDismiss func()
// contains filtered or unexported fields
}
TextOverlay represents a text screen overlay
func NewTextOverlay ¶
func NewTextOverlay(content string) *TextOverlay
NewTextOverlay creates a new text screen overlay with the given title and content
func (*TextOverlay) HandleKeyPress ¶
func (t *TextOverlay) HandleKeyPress(msg tea.KeyMsg) bool
HandleKeyPress processes a key press and updates the state Returns true if the overlay should be closed
func (*TextOverlay) Render ¶
func (t *TextOverlay) Render(opts ...WhitespaceOption) string
Render renders the text overlay
func (*TextOverlay) SetWidth ¶
func (t *TextOverlay) SetWidth(width int)
type ToastManager ¶
type ToastManager struct {
// contains filtered or unexported fields
}
ToastManager manages the collection of active toast notifications.
func NewToastManager ¶
func NewToastManager(s *spinner.Model) *ToastManager
NewToastManager creates a new ToastManager with the given spinner model.
func (*ToastManager) Error ¶
func (tm *ToastManager) Error(msg string) string
Error creates an error toast and returns its ID.
func (*ToastManager) GetPosition ¶
func (tm *ToastManager) GetPosition() (int, int)
GetPosition returns the x, y coordinates for placing the toast overlay.
func (*ToastManager) HasActiveToasts ¶
func (tm *ToastManager) HasActiveToasts() bool
HasActiveToasts returns true if there are any toasts that have not completed their animation cycle.
func (*ToastManager) Info ¶
func (tm *ToastManager) Info(msg string) string
Info creates an informational toast and returns its ID.
func (*ToastManager) Loading ¶
func (tm *ToastManager) Loading(msg string) string
Loading creates a loading toast with no auto-dismiss and returns its ID.
func (*ToastManager) Resolve ¶
func (tm *ToastManager) Resolve(id string, typ ToastType, msg string)
Resolve transitions an existing loading toast to a new type and message. If the given ID does not match any current toast, this is a no-op.
func (*ToastManager) SetSize ¶
func (tm *ToastManager) SetSize(width, height int)
SetSize updates the available viewport dimensions for toast positioning.
func (*ToastManager) Success ¶
func (tm *ToastManager) Success(msg string) string
Success creates a success toast and returns its ID.
func (*ToastManager) Tick ¶
func (tm *ToastManager) Tick()
Tick advances all toast animation phases based on elapsed time. Toasts that have completed their full animation cycle (PhaseDone) are removed from the manager's slice.
func (*ToastManager) View ¶
func (tm *ToastManager) View() string
View renders all active toasts stacked vertically.
type ToastTickMsg ¶
type ToastTickMsg struct{}
ToastTickMsg is sent by the main app every ~50ms while toasts are active to drive animation phase transitions.
type WhitespaceOption ¶
type WhitespaceOption func(*whitespace)
WhitespaceOption sets a styling rule for rendering whitespace.