editmenu

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package editmenu provides a Bubble Tea sub-model for creating and editing tasks, including a form, validation, and contextual help.

Index

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
}

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.

func (Form) Update

func (f Form) Update(msg tea.Msg) (Form, tea.Cmd)

Update processes incoming messages for the form, cycling focus on SaveField and delegating updates to each sub-input.

func (Form) View

func (f Form) View() string

View renders the form

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

func New(task task.Task) Model

New constructs a new edit menu model with default styles and zeroed size. The size can be set later via SetSize.

func NewWithSize

func NewWithSize(
	width, height int,
	task task.Task,
) Model

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

func NewWithStyles(task task.Task, menuStyles Styles, formStyles Styles) Model

NewWithStyles constructs a new edit menu model with explicit styles for the outer edit menu and the inner form.

func (Model) Height

func (m Model) Height() int

Height returns the current height of the edit menu.

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) SetShowHelp

func (m Model) SetShowHelp(v bool) Model

SetShowHelp toggles rendering of the contextual help view.

func (Model) SetShowTitle

func (m Model) SetShowTitle(v bool) Model

SetShowTitle toggles rendering of the title bar.

func (Model) SetSize

func (m Model) SetSize(width int, height int) Model

SetSize updates the edit menu dimensions and internal help width.

func (Model) ShowHelp

func (m Model) ShowHelp() bool

ShowHelp reports whether the help view is currently enabled.

func (Model) ShowTitle

func (m Model) ShowTitle() bool

ShowTitle reports whether the title bar is currently enabled.

func (Model) Update

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

Update handles all messages for the edit menu

func (Model) View

func (m Model) View() string

View renders the edit menu

func (Model) Width

func (m Model) Width() int

Width returns the current width of the edit menu.

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.

Jump to

Keyboard shortcuts

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