Splash
Dismiss keys
Section titled “Dismiss keys”By default, Esc, Enter, Space, and q dismiss the splash. Override with SetDismissKeys:
splash := components.NewSplash(). SetDismissKeys([]components.DismissKey{ components.DismissEnter, components.DismissAnyKey, // any key press dismisses })Pre-defined dismiss key constants: DismissEscape, DismissEnter, DismissSpace, DismissQ, DismissAnyKey.
Auto-dismiss
Section titled “Auto-dismiss”splash.SetAutoDismiss(3 * time.Second) // dismiss after 3sAuto-dismiss and key-press dismissal are additive — whichever comes first wins.
splash.SetLogo(asciiArtString) // multi-line ASCII artThe logo is rendered with a gradient using the active theme’s accent color range. Width and height can be tuned with SetLogoSize.
Usage
splash := components.NewSplash(). SetLogo(" DADO "). SetStatus("Loading..."). SetColors([]string{"#89b4fa", "#cba6f7"}). SetAutoDismiss(3 * time.Second). SetDismissKeys([]components.DismissKey{ components.DismissEnter, components.DismissAnyKey, })
fmt.Println(splash != nil)Methods
| Method | Signature | Description |
|---|---|---|
Build | func (s *Splash) Build() *Splash | Build initializes the splash layout. Call this after setting all options. |
Close | func (s *Splash) Close() | Close triggers the close callback and stops any running timer. |
GetGradientType | func (s *Splash) GetGradientType() theme.GradientType | GetGradientType returns the current gradient type. |
GetThemeIndex | func (s *Splash) GetThemeIndex() int | GetThemeIndex returns the current theme index (for dev mode). |
SetAutoDismiss | func (s *Splash) SetAutoDismiss(d time.Duration) *Splash | SetAutoDismiss sets automatic dismissal after the given duration. Set to 0 to disable auto-dismiss. |
SetColors | func (s *Splash) SetColors(colors []string) *Splash | SetColors sets custom gradient colors. If nil, uses theme defaults. |
SetContent | func (s *Splash) SetContent(content tview.Primitive) *Splash | SetContent sets a custom primitive to display instead of logo/status. This overrides SetLogo and SetStatus. |
SetDevMode | func (s *Splash) SetDevMode(enabled bool) *Splash | SetDevMode enables or disables dev mode (T/G key cycling). |
SetDismissKeys | func (s *Splash) SetDismissKeys(keys []DismissKey) *Splash | SetDismissKeys sets which keys can dismiss the splash. Pass nil or empty slice to disable key dismissal. |
SetGradient | func (s *Splash) SetGradient(gradientType theme.GradientType) *Splash | SetGradient sets the gradient type for the logo. |
SetLogo | func (s *Splash) SetLogo(logo string) *Splash | SetLogo sets the ASCII art logo to display. |
SetLogoHeight | func (s *Splash) SetLogoHeight(height int) *Splash | SetLogoHeight sets the fixed height for the logo container. |
SetLogoWidth | func (s *Splash) SetLogoWidth(width int) *Splash | SetLogoWidth sets the fixed width for the logo container. |
SetOnClose | func (s *Splash) SetOnClose(fn func()) *Splash | SetOnClose sets the callback when the splash is closed. |
SetStatus | func (s *Splash) SetStatus(status string) *Splash | SetStatus sets the status/hint text below the logo. |
SetStatusHeight | func (s *Splash) SetStatusHeight(height int) *Splash | SetStatusHeight sets the height for the status text area. |
SetThemeIndex | func (s *Splash) SetThemeIndex(index int) *Splash | SetThemeIndex sets the current theme index (for dev mode). |
Types
type DismissKey struct DismissKey represents a key that can dismiss the splash screen. | Field | Type | Description |
|---|---|---|
Key | tcell.Key | |
Rune | rune |