alert

package
v0.29.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 4 Imported by: 0

README

alert

import "github.com/lucasassuncao/yedit/internal/alert"

Package alert provides a modal alert/confirm component for bubbletea TUIs.

Use New for an informational modal with a single OK button, and NewConfirm for a Yes/No prompt that runs a tea.Cmd on confirmation.

Index

type DismissedMsg

DismissedMsg is sent when the user closes the alert.

type DismissedMsg struct{}

type Kind

Kind discriminates the alert flavour. Each kind changes the accent colour and the available actions.

type Kind int

const (
    KindError   Kind = iota // red border, OK button
    KindSuccess             // green border, OK button
    KindWarning             // orange border, OK button
    KindConfirm             // accent border, Yes/No buttons
)

type Model

Model is a centred modal that overlays a parent TUI.

confirmYes is only meaningful when Kind == KindConfirm. confirmCmd is the tea.Cmd dispatched when the user confirms (Yes / Enter while Yes is highlighted / y).

type Model struct {
    // contains filtered or unexported fields
}

func New
func New(title, message string, kind Kind, term theme.Size) Model

New builds an informational modal with a single OK button.

func NewConfirm
func NewConfirm(title, message string, confirmCmd tea.Cmd, term theme.Size) Model

NewConfirm builds a Yes/No modal that runs confirmCmd when the user picks Yes. Yes is the default focus.

func (Model) Resize
func (a Model) Resize(term theme.Size) Model

Resize updates the centre region the modal is rendered against. Call on tea.WindowSizeMsg if the parent forwards resizes.

func (Model) Update
func (a Model) Update(msg tea.KeyMsg) (Model, tea.Cmd)

Update processes a key event and returns the new model and any command. Non-key messages are ignored (the parent decides what reaches the modal).

func (Model) View
func (a Model) View() string

View renders the modal centred against totalW × totalH.

Generated by gomarkdoc

Documentation

Overview

Package alert provides a modal alert/confirm component for bubbletea TUIs.

Use New for an informational modal with a single OK button, and NewConfirm for a Yes/No prompt that runs a tea.Cmd on confirmation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DismissedMsg

type DismissedMsg struct{}

DismissedMsg is sent when the user closes the alert.

type Kind

type Kind int

Kind discriminates the alert flavour. Each kind changes the accent colour and the available actions.

const (
	KindError   Kind = iota // red border, OK button
	KindSuccess             // green border, OK button
	KindWarning             // orange border, OK button
	KindConfirm             // accent border, Yes/No buttons
)

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is a centred modal that overlays a parent TUI.

confirmYes is only meaningful when Kind == KindConfirm. confirmCmd is the tea.Cmd dispatched when the user confirms (Yes / Enter while Yes is highlighted / y).

func New

func New(title, message string, kind Kind, term theme.Size) Model

New builds an informational modal with a single OK button.

func NewConfirm

func NewConfirm(title, message string, confirmCmd tea.Cmd, term theme.Size) Model

NewConfirm builds a Yes/No modal that runs confirmCmd when the user picks Yes. Yes is the default focus.

func (Model) Resize

func (a Model) Resize(term theme.Size) Model

Resize updates the centre region the modal is rendered against. Call on tea.WindowSizeMsg if the parent forwards resizes.

func (Model) Update

func (a Model) Update(msg tea.KeyMsg) (Model, tea.Cmd)

Update processes a key event and returns the new model and any command. Non-key messages are ignored (the parent decides what reaches the modal).

func (Model) View

func (a Model) View() string

View renders the modal centred against totalW × totalH.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL