Documentation
¶
Overview ¶
Package editmenu provides a Bubble Tea sub-model for creating and editing tasks, including a form, validation, and contextual help.
Index ¶
- type EditTaskKeyMap
- type ErrorMsg
- type EscapeEditMsg
- type Form
- type Model
- func (m Model) Height() int
- func (m Model) Init() tea.Cmd
- func (m Model) SetShowHelp(v bool) Model
- func (m Model) SetShowTitle(v bool) Model
- func (m Model) SetSize(width int, height int) Model
- func (m Model) ShowHelp() bool
- func (m Model) ShowTitle() bool
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m Model) View() string
- func (m Model) Width() int
- type SaveTaskMsg
- type Styles
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EditTaskKeyMap ¶
type EditTaskKeyMap struct {
SaveField key.Binding
EscapeEditMode key.Binding
SaveTask key.Binding
Help key.Binding
Quit key.Binding
DateUp key.Binding
DateDown key.Binding
DateNext key.Binding
DatePrevious key.Binding
DateFocusNext key.Binding
DateFocusPrev key.Binding
}
EditTaskKeyMap holds key bindings used within the edit menu for saving fields, exiting, toggling help, and saving the task.
func (EditTaskKeyMap) FullHelp ¶
func (e EditTaskKeyMap) FullHelp() [][]key.Binding
FullHelp implements the help.KeyMap interface for full help view.
func (EditTaskKeyMap) ShortHelp ¶
func (e EditTaskKeyMap) ShortHelp() []key.Binding
ShortHelp implements the help.KeyMap interface for condensed help.
type ErrorMsg ¶
type ErrorMsg struct {
ErrorStr string
}
ErrorMsg is a generic error message produced by the edit menu.
type EscapeEditMsg ¶
type EscapeEditMsg struct{}
EscapeEditMsg signals that the user wants to exit the edit menu without saving the current changes.
type Form ¶
type Form struct {
Title textinput.Model
Desc textinput.Model
Date datepicker.Model
Done bool
// contains filtered or unexported fields
}
Form is a Bubble Tea sub-model that encapsulates the editable task
func NewForm ¶
func NewForm( title, desc string, dueDate time.Time, done bool, keymap *EditTaskKeyMap, styles Styles, ) Form
NewForm constructs a Form with initial values for the task fields, defaulting the due date to now if it is zero.
type Model ¶
type Model struct {
// Identity / basic metadata
Title string
TaskID uuid.UUID
IsNew bool
// contains filtered or unexported fields
}
Model is the Bubble Tea model for the edit menu. It owns the embedded Form, layout state, styles, and key bindings used for editing or creating a task.
func New ¶
New constructs a new edit menu model with default styles and zeroed size. The size can be set later via SetSize.
func NewWithSize ¶
NewWithSize constructs a new edit menu model with an explicit initial width and height using the default styles.
func NewWithSizeAndStyles ¶
func NewWithSizeAndStyles( width, height int, task task.Task, menuStyles Styles, formStyles Styles, ) Model
NewWithSizeAndStyles is the core constructor used by all others. It allows callers (like the top-level app model) to inject styling for both the edit menu container and the inner form.
func NewWithStyles ¶
NewWithStyles constructs a new edit menu model with explicit styles for the outer edit menu and the inner form.
func (Model) SetShowHelp ¶
SetShowHelp toggles rendering of the contextual help view.
func (Model) SetShowTitle ¶
SetShowTitle toggles rendering of the title bar.
type SaveTaskMsg ¶
type SaveTaskMsg struct {
TaskID uuid.UUID
Title string
Desc string
Date time.Time
Done bool
IsNew bool
}
SaveTaskMsg carries the data needed to save a task from the edit menu back to the main application.
type Styles ¶
type Styles struct {
TitleBar lipgloss.Style
Title lipgloss.Style
HelpStyle lipgloss.Style
Focused lipgloss.Style
Blurred lipgloss.Style
Normal lipgloss.Style
StatusMessage lipgloss.Style
}
Styles defines the visual configuration for the edit menu, including title bar, help text, focused and normal field styles, and status message styling.
func DefaultStyles ¶
func DefaultStyles() (s Styles)
DefaultStyles returns the default Styles used by the edit menu.