Documentation
¶
Index ¶
- Variables
- type AlertDefinition
- type AlertLevel
- type AlertSpec
- type FontStyle
- type Model
- func (m Model) HasActiveAlert() bool
- func (m Model) Init() tea.Cmd
- func (m Model) NewAlertCmd(spec AlertSpec, msg string) tea.Cmd
- func (m Model) Render(content string) string
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m Model) WithAllowEscToClose() Model
- func (m Model) WithMinWidth(min int) Model
- func (m Model) WithPosition(pos Position) Model
- func (m Model) WithQueueDepth(depth int) Model
- type Position
Constants ¶
This section is empty.
Variables ¶
var ( InfoAlert = AlertLevel{ // contains filtered or unexported fields } WarnAlert = AlertLevel{ // contains filtered or unexported fields } ErrorAlert = AlertLevel{ // contains filtered or unexported fields } DebugAlert = AlertLevel{ // contains filtered or unexported fields } )
Built-in alert levels — one per severity. Pass to NewAlertCmd; the model resolves the correct variant based on the FontStyle given to New().
Functions ¶
This section is empty.
Types ¶
type AlertDefinition ¶
type AlertDefinition struct {
Prefix string
ForeColor string
Position Position // zero value means use the model default
}
AlertDefinition holds the visual configuration for one alert level.
func (AlertDefinition) Resolve ¶ added in v0.2.0
func (d AlertDefinition) Resolve(_ FontStyle) AlertDefinition
Resolve implements AlertSpec. AlertDefinition is already fully specified, so it returns itself regardless of font style.
type AlertLevel ¶ added in v0.2.0
type AlertLevel struct {
// contains filtered or unexported fields
}
AlertLevel is a font-style-indexed bundle of three AlertDefinitions — one for ASCII, Unicode, and NerdFont. The model's stored FontStyle determines which variant is used at alert time.
func (AlertLevel) Resolve ¶ added in v0.2.0
func (l AlertLevel) Resolve(f FontStyle) AlertDefinition
Resolve implements AlertSpec, picking the variant that matches f.
type AlertSpec ¶ added in v0.2.0
type AlertSpec interface {
Resolve(FontStyle) AlertDefinition
}
AlertSpec is the common interface for anything that can be passed to NewAlertCmd. AlertDefinition satisfies it by returning itself; AlertLevel satisfies it by resolving to the right variant for the model's FontStyle.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model holds the toast overlay state.
func New ¶
New creates a Model. font is stored and used by NewAlertCmd to resolve the correct AlertDefinition variant when an AlertLevel is passed.
func (Model) HasActiveAlert ¶
HasActiveAlert reports whether there are any queued alerts.
func (Model) NewAlertCmd ¶
NewAlertCmd returns a tea.Cmd that enqueues an alert. spec may be an AlertLevel (resolved using the model's FontStyle) or a fully specified AlertDefinition. Uses def.Position if valid, otherwise falls back to the model's position.
func (Model) Render ¶
Render overlays the head alert on content and returns the composited string. Returns content unchanged if no alerts are queued.
func (Model) WithAllowEscToClose ¶
func (Model) WithMinWidth ¶
func (Model) WithPosition ¶
func (Model) WithQueueDepth ¶
type Position ¶
type Position string
Position specifies where on screen an Alert overlay appears.
const ( // UnspecifiedPosition is the zero value; callers must set a real position. UnspecifiedPosition Position = "" TopLeft Position = "top-left" TopCenter Position = "top-center" TopRight Position = "top-right" BottomLeft Position = "bottom-left" BottomCenter Position = "bottom-center" BottomRight Position = "bottom-right" )

