Documentation
¶
Index ¶
- Variables
- type AlertDefinition
- type FontStyle
- type Model
- func (m Model) HasActiveAlert() bool
- func (m Model) Init() tea.Cmd
- func (m Model) NewAlertCmd(def AlertDefinition, 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 ( InfoAlertASCII = AlertDefinition{Prefix: "(i)", ForeColor: "#00FF00"} InfoAlertUnicode = AlertDefinition{Prefix: "ⓘ", ForeColor: "#00FF00"} InfoAlertNerdFont = AlertDefinition{Prefix: "", ForeColor: "#00FF00"} WarnAlertASCII = AlertDefinition{Prefix: "(!)", ForeColor: "#FFFF00"} WarnAlertUnicode = AlertDefinition{Prefix: "⚠", ForeColor: "#FFFF00"} WarnAlertNerdFont = AlertDefinition{Prefix: "", ForeColor: "#FFFF00"} ErrorAlertASCII = AlertDefinition{Prefix: "[!!]", ForeColor: "#FF0000"} ErrorAlertUnicode = AlertDefinition{Prefix: "✘", ForeColor: "#FF0000"} ErrorAlertNerdFont = AlertDefinition{Prefix: "", ForeColor: "#FF0000"} DebugAlertASCII = AlertDefinition{Prefix: "(?)", ForeColor: "#FF00FF"} DebugAlertUnicode = AlertDefinition{Prefix: "?", ForeColor: "#FF00FF"} DebugAlertNerdFont = AlertDefinition{Prefix: "", ForeColor: "#FF00FF"} )
Built-in alert definitions — one per level × font style.
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.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model holds the toast overlay state.
func New ¶
New creates a Model. font selects which AlertDefinition variants the caller should pair with this model (the model itself is font-agnostic).
func (Model) HasActiveAlert ¶
HasActiveAlert reports whether there are any queued alerts.
func (Model) NewAlertCmd ¶
func (m Model) NewAlertCmd(def AlertDefinition, msg string) tea.Cmd
NewAlertCmd returns a tea.Cmd that enqueues an alert. 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" )