ui

package
v0.4.13 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: 0BSD Imports: 14 Imported by: 0

Documentation

Overview

Package ui provides the terminal user interface for the td application.

Index

Constants

View Source
const (
	DefaultMaxUndoSize = 100
	DefaultDataFile    = "~/.td.json"
)

Default UI settings

View Source
const (
	ModeNameNormal   = "Normal"
	ModeNameDoneList = "Completed Tasks"
	ModeNameAdd      = "Add Task"
	ModeNameEdit     = "Edit Task"
	ModeNameHelp     = "Help"
)

UI mode names for display

View Source
const (
	FilterNameAll    = "All"
	FilterNameNone   = "None"
	FilterNameLow    = "Low Priority"
	FilterNameMedium = "Medium Priority"
	FilterNameHigh   = "High Priority"
)

Filter mode names

View Source
const (
	ModeNormal = iota
	ModeDoneTaskList
	ModeAdditional
	ModeEdit
	ModeHelp
)

Variables

This section is empty.

Functions

func SanitizeTaskName

func SanitizeTaskName(name string) string

SanitizeTaskName sanitizes a task name by trimming whitespace and removing dangerous characters.

func ValidatePriorityInput

func ValidatePriorityInput(priority int) error

ValidatePriorityInput validates priority input.

func ValidateTaskName

func ValidateTaskName(name string) error

ValidateTaskName validates a task name input.

Types

type FilterMode

type FilterMode int

FilterMode represents different task filtering modes.

const (
	FilterAll FilterMode = iota
	FilterNone
	FilterLow
	FilterMedium
	FilterHigh
)

type KeyMap

type KeyMap struct {
	Add      key.Binding
	Up       key.Binding
	Down     key.Binding
	Delete   key.Binding
	Left     key.Binding
	Right    key.Binding
	Edit     key.Binding
	Enter    key.Binding
	ListType key.Binding
	Escape   key.Binding
	Help     key.Binding
	Quit     key.Binding
	Filter   key.Binding
	Undo     key.Binding
	Redo     key.Binding
	// New shortcuts
	PriorityNone   key.Binding
	PriorityLow    key.Binding
	PriorityMedium key.Binding
	PriorityHigh   key.Binding
	Home           key.Binding
	End            key.Binding
	ClearCompleted key.Binding
}

KeyMap defines the key bindings for the UI.

func (KeyMap) FullHelp

func (k KeyMap) FullHelp() [][]key.Binding

FullHelp returns the full help view for all key bindings.

type Mode

type Mode int

Mode represents different UI modes.

type Model

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

Model represents the main UI model.

func NewModel

func NewModel(cfg *config.Config, taskManager *task.TaskManager) *Model

NewModel creates a new UI model with the given configuration and task manager.

func NewTestModel added in v0.4.5

func NewTestModel(cfg *config.Config, taskManager *task.TaskManager) (*Model, error)

NewTestModel creates a minimal UI model for testing purposes. It skips initializing Bubble Tea input components that require a TTY.

func (*Model) GetConfig

func (m *Model) GetConfig() *config.Config

GetConfig returns the configuration.

func (*Model) GetTaskManager

func (m *Model) GetTaskManager() *task.TaskManager

GetTaskManager returns the task manager.

func (*Model) Init

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

Init initializes the Bubble Tea model.

func (*Model) Update

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

Update handles UI updates based on messages.

func (*Model) View

func (m *Model) View() string

View renders the current UI state.

Jump to

Keyboard shortcuts

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