dialogs

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DarkBackdrop is a dark semi-transparent backdrop (60% opacity)
	DarkBackdrop = BackdropStyle{
		Enabled:   true,
		Opacity:   0.6,
		Color:     lipgloss.Color("#000000"),
		BlurChars: "",
	}

	// LightBackdrop is a light semi-transparent backdrop (40% opacity)
	LightBackdrop = BackdropStyle{
		Enabled:   true,
		Opacity:   0.4,
		Color:     lipgloss.Color("#FFFFFF"),
		BlurChars: "",
	}

	// BlurBackdrop is a backdrop with blur effect (70% opacity)
	BlurBackdrop = BackdropStyle{
		Enabled:   true,
		Opacity:   0.7,
		Color:     lipgloss.Color("#000000"),
		BlurChars: "░▒▓",
	}

	// NoBackdrop is an invisible backdrop (disabled)
	NoBackdrop = BackdropStyle{
		Enabled:   false,
		Opacity:   0.0,
		Color:     lipgloss.Color("#000000"),
		BlurChars: "",
	}

	// PurpleBackdrop is a purple-tinted backdrop matching AINative branding
	PurpleBackdrop = BackdropStyle{
		Enabled:   true,
		Opacity:   0.5,
		Color:     lipgloss.Color("#8B5CF6"),
		BlurChars: "",
	}

	// HeavyBlurBackdrop is a heavily blurred backdrop (80% opacity)
	HeavyBlurBackdrop = BackdropStyle{
		Enabled:   true,
		Opacity:   0.8,
		Color:     lipgloss.Color("#000000"),
		BlurChars: "░░▒▒▓▓",
	}
)

Pre-defined backdrop styles

View Source
var (
	// Dialog container styles
	DialogContainerStyle = lipgloss.NewStyle().
							Border(lipgloss.RoundedBorder()).
							BorderForeground(lipgloss.Color("#8B5CF6")).
							Padding(1, 2).
							Background(lipgloss.Color("#1A1A2E")).
							Foreground(lipgloss.Color("#E0E0E0")) // Light text

	// Dialog title styles
	DialogTitleStyle = lipgloss.NewStyle().
						Bold(true).
						Foreground(lipgloss.Color("#8B5CF6")).
						Align(lipgloss.Center).
						Width(40)

	// Dialog description styles
	DialogDescriptionStyle = lipgloss.NewStyle().
							Foreground(lipgloss.Color("#B0B0B0")).
							Align(lipgloss.Left).
							MarginTop(1).
							MarginBottom(1)

	// Button styles
	ButtonActiveStyle = lipgloss.NewStyle().
						Bold(true).
						Foreground(lipgloss.Color("#FFFFFF")).
						Background(lipgloss.Color("#8B5CF6")).
						Padding(0, 2).
						Margin(0, 1)

	ButtonInactiveStyle = lipgloss.NewStyle().
						Foreground(lipgloss.Color("#808080")).
						Background(lipgloss.Color("#2A2A3E")).
						Padding(0, 2).
						Margin(0, 1)

	// Input field styles
	InputFieldStyle = lipgloss.NewStyle().
					Border(lipgloss.NormalBorder()).
					BorderForeground(lipgloss.Color("#8B5CF6")).
					Padding(0, 1).
					Width(36)

	InputFieldFocusedStyle = lipgloss.NewStyle().
							Border(lipgloss.NormalBorder()).
							BorderForeground(lipgloss.Color("#A78BFA")).
							Padding(0, 1).
							Width(36)

	// List item styles for SelectDialog
	ListItemStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color("#E0E0E0")).
					Padding(0, 2)

	ListItemSelectedStyle = lipgloss.NewStyle().
							Bold(true).
							Foreground(lipgloss.Color("#FFFFFF")).
							Background(lipgloss.Color("#8B5CF6")).
							Padding(0, 2)

	ListItemHoverStyle = lipgloss.NewStyle().
						Foreground(lipgloss.Color("#A78BFA")).
						Padding(0, 2)

	// Error message styles
	ErrorTextStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color("#EF4444")).
					Bold(true).
					MarginTop(1)

	// Help text styles
	HelpTextStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color("#6B7280")).
					Italic(true).
					MarginTop(1).
					Align(lipgloss.Center)

	// Success message styles
	SuccessTextStyle = lipgloss.NewStyle().
						Foreground(lipgloss.Color("#10B981")).
						Bold(true)

	// Warning message styles
	WarningTextStyle = lipgloss.NewStyle().
						Foreground(lipgloss.Color("#F59E0B")).
						Bold(true)
)

Dialog styles following AINative branding

Functions

func CloseAllDialogs

func CloseAllDialogs() tea.Cmd

CloseAllDialogs creates a command to close all dialogs

func CloseDialog

func CloseDialog(dialogID string) tea.Cmd

CloseDialog creates a command to close a dialog

func CloseTopDialog

func CloseTopDialog() tea.Cmd

CloseTopDialog creates a command to close the top dialog

func NewConfirmDialogWithConfig

func NewConfirmDialogWithConfig(config ConfirmDialogConfig, modalConfig ModalConfig) (*ConfirmDialog, ModalConfig)

NewConfirmDialogWithConfig creates a confirm dialog with custom modal configuration

func OpenDialog

func OpenDialog(dialog Dialog) tea.Cmd

OpenDialog creates a command to open a dialog

func OpenModalWithConfig

func OpenModalWithConfig(dialog Dialog, config ModalConfig) tea.Cmd

OpenModalWithConfig creates a command to open a modal with configuration

func RenderBackdrop

func RenderBackdrop(width, height int) string

RenderBackdrop creates a semi-transparent backdrop (deprecated - use BackdropRenderer)

func RenderDialogBox

func RenderDialogBox(content string, width int) string

RenderDialogBox renders a dialog box at the center

func SendDialogResult

func SendDialogResult(dialogID string, result interface{}, err error) tea.Cmd

SendDialogResult creates a command to send a dialog result

Types

type AnimationConfig

type AnimationConfig struct {
	FadeIn       bool    // Enable fade-in effect
	FadeOut      bool    // Enable fade-out effect
	Duration     int     // Animation duration in milliseconds
	InitialAlpha float64 // Initial opacity (0.0 - 1.0)
	FinalAlpha   float64 // Final opacity (0.0 - 1.0)
}

AnimationConfig defines animation behavior for modals

type BackdropRenderer

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

BackdropRenderer creates semi-transparent overlays

func NewBackdropRenderer

func NewBackdropRenderer(width, height int, style BackdropStyle) *BackdropRenderer

NewBackdropRenderer creates a new backdrop renderer

func (*BackdropRenderer) Disable

func (b *BackdropRenderer) Disable()

Disable disables the backdrop

func (*BackdropRenderer) Enable

func (b *BackdropRenderer) Enable()

Enable enables the backdrop

func (*BackdropRenderer) GetOpacity

func (b *BackdropRenderer) GetOpacity() float64

GetOpacity returns the current backdrop opacity

func (*BackdropRenderer) GetStyle

func (b *BackdropRenderer) GetStyle() BackdropStyle

GetStyle returns the current backdrop style

func (*BackdropRenderer) IsEnabled

func (b *BackdropRenderer) IsEnabled() bool

IsEnabled returns true if the backdrop is enabled

func (*BackdropRenderer) Render

func (b *BackdropRenderer) Render() string

Render creates the backdrop overlay

func (*BackdropRenderer) SetOpacity

func (b *BackdropRenderer) SetOpacity(opacity float64)

SetOpacity updates the backdrop opacity

func (*BackdropRenderer) SetSize

func (b *BackdropRenderer) SetSize(width, height int)

SetSize updates the backdrop dimensions

func (*BackdropRenderer) SetStyle

func (b *BackdropRenderer) SetStyle(style BackdropStyle)

SetStyle updates the backdrop style

type BackdropStyle

type BackdropStyle struct {
	Enabled   bool           // Whether backdrop is enabled
	Opacity   float64        // Opacity level (0.0 - 1.0)
	Color     lipgloss.Color // Backdrop color
	BlurChars string         // Characters to use for blur effect (e.g., "░▒▓")
}

BackdropStyle defines backdrop appearance and behavior

type CloseAllDialogsMsg

type CloseAllDialogsMsg struct{}

CloseAllDialogsMsg signals to close all dialogs

type CloseDialogMsg

type CloseDialogMsg struct {
	// DialogID is optional - if empty, closes the top dialog
	DialogID string
}

CloseDialogMsg signals to close the top dialog

type CommandPaletteMsg

type CommandPaletteMsg struct{}

CommandPaletteMsg signals to open the command palette

type ConfirmDialog

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

ConfirmDialog represents a Yes/No confirmation dialog

func NewConfirmDialog

func NewConfirmDialog(config ConfirmDialogConfig) *ConfirmDialog

NewConfirmDialog creates a new confirm dialog

func (*ConfirmDialog) GetResult

func (d *ConfirmDialog) GetResult() *bool

GetResult returns the boolean result (convenience method)

func (*ConfirmDialog) ID

func (d *ConfirmDialog) ID() string

ID returns the dialog ID

func (*ConfirmDialog) Init

func (d *ConfirmDialog) Init() tea.Cmd

Init initializes the dialog

func (*ConfirmDialog) IsClosing

func (d *ConfirmDialog) IsClosing() bool

IsClosing returns true if the dialog is requesting to be closed

func (*ConfirmDialog) Result

func (d *ConfirmDialog) Result() interface{}

Result returns the dialog result

func (*ConfirmDialog) SetSize

func (d *ConfirmDialog) SetSize(width, height int)

SetSize updates the dialog dimensions

func (*ConfirmDialog) Update

func (d *ConfirmDialog) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages

func (*ConfirmDialog) View

func (d *ConfirmDialog) View() string

View renders the dialog

type ConfirmDialogConfig

type ConfirmDialogConfig struct {
	ID          string
	Title       string
	Description string
	YesLabel    string // Default: "Yes"
	NoLabel     string // Default: "No"
	DefaultYes  bool   // Default: false (No is selected)
}

ConfirmDialogConfig contains configuration for a confirm dialog

type Dialog

type Dialog interface {
	tea.Model
	// ID returns a unique identifier for this dialog
	ID() string
	// SetSize updates the dialog dimensions
	SetSize(width, height int)
	// IsClosing returns true if the dialog is requesting to be closed
	IsClosing() bool
	// Result returns the dialog result (if any)
	Result() interface{}
}

Dialog represents the interface that all dialogs must implement

type DialogManager

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

DialogManager manages a stack of modals with advanced features

func NewDialogManager

func NewDialogManager() *DialogManager

NewDialogManager creates a new dialog manager

func (*DialogManager) Clear

func (dm *DialogManager) Clear()

Clear removes all modals from the stack

func (*DialogManager) CloseByID

func (dm *DialogManager) CloseByID(id string) tea.Cmd

CloseByID closes a specific modal by ID

func (*DialogManager) CloseTop

func (dm *DialogManager) CloseTop() tea.Cmd

CloseTop closes the top modal and returns its result

func (*DialogManager) DisableFocusTrap

func (dm *DialogManager) DisableFocusTrap() tea.Cmd

DisableFocusTrap disables focus trapping

func (*DialogManager) EnableFocusTrap

func (dm *DialogManager) EnableFocusTrap() tea.Cmd

EnableFocusTrap enables focus trapping

func (*DialogManager) GetCount

func (dm *DialogManager) GetCount() int

GetCount returns the number of dialogs in the stack

func (*DialogManager) GetFocusTrap

func (dm *DialogManager) GetFocusTrap() *FocusTrap

GetFocusTrap returns the focus trap

func (*DialogManager) GetShortcutManager

func (dm *DialogManager) GetShortcutManager() *ShortcutManager

GetShortcutManager returns the shortcut manager

func (*DialogManager) GetTop

func (dm *DialogManager) GetTop() Dialog

GetTop returns the top dialog, or nil if stack is empty

func (*DialogManager) GetTopModal

func (dm *DialogManager) GetTopModal() *Modal

GetTopModal returns the top modal, or nil if stack is empty

func (*DialogManager) HasDialogs

func (dm *DialogManager) HasDialogs() bool

HasDialogs returns true if there are any dialogs open

func (*DialogManager) OpenModal

func (dm *DialogManager) OpenModal(dialog Dialog, config ModalConfig) tea.Cmd

OpenModal opens a modal with the specified configuration

func (*DialogManager) RegisterShortcut

func (dm *DialogManager) RegisterShortcut(key string, handler func() tea.Msg)

RegisterShortcut registers a global keyboard shortcut

func (*DialogManager) SetSize

func (dm *DialogManager) SetSize(width, height int)

SetSize updates the manager dimensions

func (*DialogManager) SetZIndex

func (dm *DialogManager) SetZIndex(id string, zIndex int) tea.Cmd

SetZIndex sets the z-index for a specific modal

func (*DialogManager) Update

func (dm *DialogManager) Update(msg tea.Msg) tea.Cmd

Update handles dialog-related messages

func (*DialogManager) View

func (dm *DialogManager) View() string

View renders all modals as layers

type DialogResultMsg

type DialogResultMsg struct {
	DialogID string
	Result   interface{}
	Error    error
}

DialogResultMsg is sent when a dialog completes with a result

type FilePickerMsg

type FilePickerMsg struct{}

FilePickerMsg signals to open the file picker

type FocusTrap

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

FocusTrap manages focus within modal boundaries It prevents Tab/Shift+Tab from leaving the modal

func NewFocusTrap

func NewFocusTrap() *FocusTrap

NewFocusTrap creates a new focus trap

func (*FocusTrap) Activate

func (f *FocusTrap) Activate()

Activate activates the focus trap

func (*FocusTrap) AddFocusableElement

func (f *FocusTrap) AddFocusableElement(id string)

AddFocusableElement adds a focusable element ID

func (*FocusTrap) ClearFocusableElements

func (f *FocusTrap) ClearFocusableElements()

ClearFocusableElements clears all focusable elements

func (*FocusTrap) Deactivate

func (f *FocusTrap) Deactivate()

Deactivate deactivates the focus trap

func (*FocusTrap) Disable

func (f *FocusTrap) Disable()

Disable disables focus trapping

func (*FocusTrap) Enable

func (f *FocusTrap) Enable()

Enable enables focus trapping

func (*FocusTrap) FocusFirst

func (f *FocusTrap) FocusFirst() string

FocusFirst sets focus to the first focusable element

func (*FocusTrap) FocusLast

func (f *FocusTrap) FocusLast() string

FocusLast sets focus to the last focusable element

func (*FocusTrap) GetCurrentFocusID

func (f *FocusTrap) GetCurrentFocusID() string

GetCurrentFocusID returns the ID of the currently focused element

func (*FocusTrap) GetCurrentFocusIndex

func (f *FocusTrap) GetCurrentFocusIndex() int

GetCurrentFocusIndex returns the current focus index

func (*FocusTrap) GetFocusableCount

func (f *FocusTrap) GetFocusableCount() int

GetFocusableCount returns the number of focusable elements

func (*FocusTrap) GetFocusableElements

func (f *FocusTrap) GetFocusableElements() []string

GetFocusableElements returns the list of focusable element IDs

func (*FocusTrap) HandleKey

func (f *FocusTrap) HandleKey(key string) (handled bool, nextFocus string)

HandleKey handles keyboard navigation within the focus trap Returns (handled, nextFocusID)

func (*FocusTrap) HandleMessage

func (f *FocusTrap) HandleMessage(msg tea.Msg) (handled bool, nextFocus string, cmd tea.Cmd)

HandleMessage handles Bubble Tea messages for focus navigation

func (*FocusTrap) HasFocusableElements

func (f *FocusTrap) HasFocusableElements() bool

HasFocusableElements returns true if there are any focusable elements

func (*FocusTrap) IsActive

func (f *FocusTrap) IsActive() bool

IsActive returns true if focus is currently trapped

func (*FocusTrap) IsEnabled

func (f *FocusTrap) IsEnabled() bool

IsEnabled returns true if focus trapping is enabled

func (*FocusTrap) NextFocusable

func (f *FocusTrap) NextFocusable() string

NextFocusable returns the ID of the next focusable element

func (*FocusTrap) PrevFocusable

func (f *FocusTrap) PrevFocusable() string

PrevFocusable returns the ID of the previous focusable element

func (*FocusTrap) RemoveFocusableElement

func (f *FocusTrap) RemoveFocusableElement(id string)

RemoveFocusableElement removes a focusable element ID

func (*FocusTrap) Reset

func (f *FocusTrap) Reset()

Reset resets the focus trap to its initial state

func (*FocusTrap) SetCurrentFocusIndex

func (f *FocusTrap) SetCurrentFocusIndex(index int)

SetCurrentFocusIndex sets the current focus index

func (*FocusTrap) SetFocusableElements

func (f *FocusTrap) SetFocusableElements(ids []string)

SetFocusableElements sets the list of focusable element IDs

type HelpMsg

type HelpMsg struct{}

HelpMsg signals to open the help dialog

type InputDialog

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

InputDialog represents a text input dialog with validation

func NewInputDialog

func NewInputDialog(config InputDialogConfig) *InputDialog

NewInputDialog creates a new input dialog

func (*InputDialog) GetResult

func (d *InputDialog) GetResult() *string

GetResult returns the string result (convenience method)

func (*InputDialog) ID

func (d *InputDialog) ID() string

ID returns the dialog ID

func (*InputDialog) Init

func (d *InputDialog) Init() tea.Cmd

Init initializes the dialog

func (*InputDialog) IsClosing

func (d *InputDialog) IsClosing() bool

IsClosing returns true if the dialog is requesting to be closed

func (*InputDialog) Result

func (d *InputDialog) Result() interface{}

Result returns the dialog result

func (*InputDialog) SetSize

func (d *InputDialog) SetSize(width, height int)

SetSize updates the dialog dimensions

func (*InputDialog) Update

func (d *InputDialog) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages

func (*InputDialog) View

func (d *InputDialog) View() string

View renders the dialog

type InputDialogConfig

type InputDialogConfig struct {
	ID           string
	Title        string
	Description  string
	Placeholder  string
	DefaultValue string
	Validator    func(string) error // Optional validation function
}

InputDialogConfig contains configuration for an input dialog

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

Modal wraps a Dialog with advanced modal features

func NewModal

func NewModal(dialog Dialog, config ModalConfig) *Modal

NewModal creates a new modal wrapper around a dialog

func (*Modal) CalculatePosition

func (m *Modal) CalculatePosition(containerWidth, containerHeight int)

CalculatePosition calculates the centered position for the modal

func (*Modal) GetConfig

func (m *Modal) GetConfig() ModalConfig

GetConfig returns the modal configuration

func (*Modal) GetDialog

func (m *Modal) GetDialog() Dialog

GetDialog returns the underlying dialog

func (*Modal) GetPosition

func (m *Modal) GetPosition() (int, int)

GetPosition returns the modal's position

func (*Modal) GetZIndex

func (m *Modal) GetZIndex() int

GetZIndex returns the modal's current z-index

func (*Modal) HasFocusTrap

func (m *Modal) HasFocusTrap() bool

HasFocusTrap returns true if focus should be trapped in this modal

func (*Modal) ID

func (m *Modal) ID() string

ID returns the modal's dialog ID

func (*Modal) Init

func (m *Modal) Init() tea.Cmd

Init initializes the modal

func (*Modal) IsClosing

func (m *Modal) IsClosing() bool

IsClosing returns true if the dialog is requesting to be closed

func (*Modal) IsFocused

func (m *Modal) IsFocused() bool

IsFocused returns true if the modal is focused

func (*Modal) IsVisible

func (m *Modal) IsVisible() bool

IsVisible returns true if the modal is visible

func (*Modal) Result

func (m *Modal) Result() interface{}

Result returns the dialog result

func (*Modal) SetFocused

func (m *Modal) SetFocused(focused bool)

SetFocused controls modal focus state

func (*Modal) SetPosition

func (m *Modal) SetPosition(x, y int)

SetPosition sets the modal's position

func (*Modal) SetSize

func (m *Modal) SetSize(width, height int)

SetSize updates the modal dimensions

func (*Modal) SetVisible

func (m *Modal) SetVisible(visible bool)

SetVisible controls modal visibility

func (*Modal) SetZIndex

func (m *Modal) SetZIndex(zIndex int)

SetZIndex updates the modal's z-index

func (*Modal) ShouldCloseOnBackdrop

func (m *Modal) ShouldCloseOnBackdrop() bool

ShouldCloseOnBackdrop returns true if clicking backdrop should close this modal

func (*Modal) ShouldCloseOnEsc

func (m *Modal) ShouldCloseOnEsc() bool

ShouldCloseOnEsc returns true if ESC should close this modal

func (*Modal) Update

func (m *Modal) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages for the modal

func (*Modal) View

func (m *Modal) View() string

View renders the modal

type ModalConfig

type ModalConfig struct {
	ZIndex          int              // Z-index for layering (default: auto-increment)
	Backdrop        BackdropStyle    // Backdrop appearance
	CloseOnEsc      bool             // Allow ESC key to close (default: true)
	CloseOnBackdrop bool             // Allow clicking backdrop to close (default: false)
	TrapFocus       bool             // Trap focus within modal (default: true)
	MaxWidth        int              // Maximum modal width (0 = no limit)
	MaxHeight       int              // Maximum modal height (0 = no limit)
	CenterX         bool             // Center horizontally (default: true)
	CenterY         bool             // Center vertically (default: true)
	AnimationConfig *AnimationConfig // Optional animation configuration
}

ModalConfig configures modal behavior and appearance

func BlurModalConfig

func BlurModalConfig() ModalConfig

BlurModalConfig returns a modal configuration with blur backdrop effect

func DefaultModalConfig

func DefaultModalConfig() ModalConfig

DefaultModalConfig returns a sensible default modal configuration

func MinimalModalConfig

func MinimalModalConfig() ModalConfig

MinimalModalConfig returns a minimal modal configuration with no backdrop

type OpenDialogMsg

type OpenDialogMsg struct {
	Dialog Dialog
}

OpenDialogMsg signals to open a new dialog

type OpenModalMsg

type OpenModalMsg struct {
	Dialog Dialog
	Config ModalConfig
}

OpenModalMsg signals to open a modal with custom configuration

type SearchMsg

type SearchMsg struct{}

SearchMsg signals to open the search dialog

type SelectDialog

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

SelectDialog represents a list selection dialog with search

func NewSelectDialog

func NewSelectDialog(config SelectDialogConfig) *SelectDialog

NewSelectDialog creates a new select dialog

func (*SelectDialog) GetResult

func (d *SelectDialog) GetResult() *string

GetResult returns the string result (convenience method)

func (*SelectDialog) GetSelectedOption

func (d *SelectDialog) GetSelectedOption() *SelectOption

GetSelectedOption returns the selected option (convenience method)

func (*SelectDialog) ID

func (d *SelectDialog) ID() string

ID returns the dialog ID

func (*SelectDialog) Init

func (d *SelectDialog) Init() tea.Cmd

Init initializes the dialog

func (*SelectDialog) IsClosing

func (d *SelectDialog) IsClosing() bool

IsClosing returns true if the dialog is requesting to be closed

func (*SelectDialog) Result

func (d *SelectDialog) Result() interface{}

Result returns the dialog result

func (*SelectDialog) SetSize

func (d *SelectDialog) SetSize(width, height int)

SetSize updates the dialog dimensions

func (*SelectDialog) Update

func (d *SelectDialog) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages

func (*SelectDialog) View

func (d *SelectDialog) View() string

View renders the dialog

type SelectDialogConfig

type SelectDialogConfig struct {
	ID          string
	Title       string
	Description string
	Options     []SelectOption
	DefaultIdx  int  // Default selected index
	Searchable  bool // Enable search mode
}

SelectDialogConfig contains configuration for a select dialog

type SelectOption

type SelectOption struct {
	Label       string
	Value       string
	Description string
}

SelectOption represents an option in the select dialog

type SettingsMsg

type SettingsMsg struct{}

SettingsMsg signals to open the settings dialog

type ShortcutHandler

type ShortcutHandler func() tea.Msg

ShortcutHandler is a function that handles a keyboard shortcut

type ShortcutInfo

type ShortcutInfo struct {
	Key         string // The key combination
	Description string // What the shortcut does
}

ShortcutInfo represents information about a shortcut

func GetCommonShortcutHelp

func GetCommonShortcutHelp() []ShortcutInfo

GetShortcutHelp returns help information for all registered shortcuts This is useful for displaying help dialogs

type ShortcutManager

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

ShortcutManager handles global modal keyboard shortcuts

func NewShortcutManager

func NewShortcutManager() *ShortcutManager

NewShortcutManager creates a new shortcut manager

func (*ShortcutManager) ClearShortcuts

func (s *ShortcutManager) ClearShortcuts()

ClearShortcuts removes all shortcuts

func (*ShortcutManager) Disable

func (s *ShortcutManager) Disable()

Disable disables shortcut handling

func (*ShortcutManager) Enable

func (s *ShortcutManager) Enable()

Enable enables shortcut handling

func (*ShortcutManager) GetAllShortcuts

func (s *ShortcutManager) GetAllShortcuts() map[string]ShortcutHandler

GetAllShortcuts returns all registered shortcuts

func (*ShortcutManager) GetShortcut

func (s *ShortcutManager) GetShortcut(key string) ShortcutHandler

GetShortcut returns the handler for a shortcut, or nil if not found

func (*ShortcutManager) GetShortcutCount

func (s *ShortcutManager) GetShortcutCount() int

GetShortcutCount returns the number of registered shortcuts

func (*ShortcutManager) GetShortcutKeys

func (s *ShortcutManager) GetShortcutKeys() []string

GetShortcutKeys returns all registered shortcut keys

func (*ShortcutManager) HandleKey

func (s *ShortcutManager) HandleKey(key string) (bool, tea.Cmd)

HandleKey processes a key event and triggers the appropriate shortcut Returns (handled, command)

func (*ShortcutManager) HandleMessage

func (s *ShortcutManager) HandleMessage(msg tea.Msg) (bool, tea.Cmd)

HandleMessage processes a Bubble Tea message for shortcuts

func (*ShortcutManager) HasShortcut

func (s *ShortcutManager) HasShortcut(key string) bool

HasShortcut checks if a shortcut is registered

func (*ShortcutManager) IsEnabled

func (s *ShortcutManager) IsEnabled() bool

IsEnabled returns true if shortcut handling is enabled

func (*ShortcutManager) RegisterCommandPalette

func (s *ShortcutManager) RegisterCommandPalette(handler ShortcutHandler)

RegisterCommandPalette registers Ctrl+K for command palette

func (*ShortcutManager) RegisterCommonShortcuts

func (s *ShortcutManager) RegisterCommonShortcuts()

RegisterCommonShortcuts registers all common shortcuts with default handlers

func (*ShortcutManager) RegisterFilePicker

func (s *ShortcutManager) RegisterFilePicker(handler ShortcutHandler)

RegisterFilePicker registers Ctrl+P for file picker

func (*ShortcutManager) RegisterHelp

func (s *ShortcutManager) RegisterHelp(handler ShortcutHandler)

RegisterHelp registers F1 or Ctrl+? for help

func (*ShortcutManager) RegisterSearch

func (s *ShortcutManager) RegisterSearch(handler ShortcutHandler)

RegisterSearch registers Ctrl+F for search

func (*ShortcutManager) RegisterSettings

func (s *ShortcutManager) RegisterSettings(handler ShortcutHandler)

RegisterSettings registers Ctrl+, for settings

func (*ShortcutManager) RegisterShortcut

func (s *ShortcutManager) RegisterShortcut(key string, handler ShortcutHandler)

RegisterShortcut adds a global shortcut

func (*ShortcutManager) Toggle

func (s *ShortcutManager) Toggle()

Toggle toggles shortcut handling on/off

func (*ShortcutManager) UnregisterShortcut

func (s *ShortcutManager) UnregisterShortcut(key string)

UnregisterShortcut removes a global shortcut

Jump to

Keyboard shortcuts

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