tui

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FuzzyMatch

func FuzzyMatch(query, target string) (bool, int)

FuzzyMatch checks whether all characters of query appear in target in order (case-insensitive). Returns whether it matched and a relevance score.

Scoring rewards:

  • consecutive character matches
  • matches at the start of the string
  • matches at word boundaries (after space, /, -, _)

func IsTTY

func IsTTY() bool

IsTTY returns true when stdin is connected to a terminal.

Types

type DigModel

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

DigModel is a full-screen Bubbletea timer model for focus sessions.

func NewDigModel

func NewDigModel(duration time.Duration, label string, taskLabel string) *DigModel

NewDigModel creates a new DigModel.

func (*DigModel) Init

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

func (*DigModel) Update

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

func (*DigModel) View

func (m *DigModel) View() string

type DigResult

type DigResult struct {
	Elapsed   time.Duration
	Completed bool // true if the full duration was reached
	Canceled  bool // true if user quit early
}

DigResult is returned when the dig TUI session ends.

func RunDig

func RunDig(duration time.Duration, label string, taskLabel string) (DigResult, error)

RunDig launches the full-screen dig timer TUI. taskLabel is optional: pass an empty string for an untargeted session.

type Item

type Item interface {
	// FilterValue returns the string used for fuzzy matching.
	FilterValue() string
	// Title returns the main display text.
	Title() string
	// Description returns optional secondary text (can be empty).
	Description() string
}

Item is the interface that list items must implement for the picker.

func Run

func Run(items []Item, opts ...PickerOption) (Item, error)

Run is the convenience entry point: show a picker and return the selected item. Returns nil and no error if the user canceled.

func RunWithOutput

func RunWithOutput(items []Item, output io.Writer, opts ...PickerOption) (Item, error)

RunWithOutput renders the picker UI to the provided writer. Useful when stdout is captured but an interactive TTY UI is still desired.

type Picker

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

Picker is a reusable fuzzy-search list selector built on Bubbletea. Use Run() for the common case, or create a Picker and drive it manually.

func NewPicker

func NewPicker(items []Item, opts ...PickerOption) *Picker

NewPicker creates a Picker with the given items and options.

func (*Picker) Init

func (p *Picker) Init() tea.Cmd

func (*Picker) Update

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

func (*Picker) View

func (p *Picker) View() string

type PickerOption

type PickerOption func(*Picker)

PickerOption configures a Picker.

func WithHeight

func WithHeight(h int) PickerOption

WithHeight sets the maximum visible items (0 = auto).

func WithPrompt

func WithPrompt(prompt string) PickerOption

WithPrompt sets the search prompt character(s).

func WithTitle

func WithTitle(title string) PickerOption

WithTitle sets the heading displayed above the picker.

type TodoAction

type TodoAction struct {
	Type        string // "toggle", "delete", "add", "schedule", "quit"
	ID          int
	Text        string
	Schedule    string  // for "schedule" actions
	ProjectPath *string // project context for "add" actions
}

TodoAction represents an action taken in the todo TUI.

func RunTodo

func RunTodo(todos []todo.Todo, projectPath *string, showAll bool) ([]TodoAction, error)

RunTodo launches the interactive todo TUI. Returns actions for the caller to apply. projectPath is the project context for new todos added via the TUI (may be nil). showAll enables @project annotations when displaying todos across all projects.

type TodoModel

type TodoModel struct {

	// pending actions to apply after quitting
	Actions []TodoAction
	// contains filtered or unexported fields
}

TodoModel is a full interactive Bubbletea model for managing todos.

func NewTodoModel

func NewTodoModel(todos []todo.Todo) *TodoModel

NewTodoModel creates a new TodoModel with the given todos.

func (*TodoModel) Init

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

func (*TodoModel) Update

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

func (*TodoModel) View

func (m *TodoModel) View() string

Jump to

Keyboard shortcuts

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