tui

package
v0.0.0-...-2323d9c Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package tui provides a terminal user interface for Thicket.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetailFullHelp

func DetailFullHelp() []helpSection

DetailFullHelp returns the full help content for detail view.

func DetailHelp

func DetailHelp() string

DetailHelp returns help text for detail view (abbreviated).

func FormFullHelp

func FormFullHelp() []helpSection

FormFullHelp returns the full help content for form view.

func FormHelp

func FormHelp() string

FormHelp returns help text for form view (abbreviated).

func HelpContentHeight

func HelpContentHeight(sections []helpSection) int

HelpContentHeight returns the total number of lines in the help content.

func ListFullHelp

func ListFullHelp() []helpSection

ListFullHelp returns the full help content for list view.

func ListHelp

func ListHelp() string

ListHelp returns help text for list view (abbreviated).

func RenderHelp

func RenderHelp(sections []helpSection, width, height int) string

RenderHelp renders the help overlay for the given sections.

func RenderHelpWithScroll

func RenderHelpWithScroll(sections []helpSection, width, height, scrollY int) string

RenderHelpWithScroll renders the help overlay with scroll support.

func Run

func Run(store *storage.Store, cfg *config.Config, ticketsPath string) error

Run starts the TUI application.

func WatchFile

func WatchFile(path string, debounce time.Duration) func() (chan FileChangedMsg, func())

WatchFile returns a command that watches the given file for changes. When the file changes, it sends a FileChangedMsg. The debounce parameter controls how long to wait after a change before sending the message (to avoid rapid repeated updates).

Types

type AddCommentMsg

type AddCommentMsg struct {
	TicketID string
}

AddCommentMsg is sent when the user wants to add a comment.

type BackToListMsg

type BackToListMsg struct{}

BackToListMsg is sent when the user wants to return to the list view.

type CommentSavedMsg

type CommentSavedMsg struct {
	TicketID string
}

CommentSavedMsg is sent after a comment has been saved.

type CreateTicketMsg

type CreateTicketMsg struct{}

CreateTicketMsg is sent when the user wants to create a new ticket.

type DetailModel

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

DetailModel handles the ticket detail view.

func NewDetailModel

func NewDetailModel(store *storage.Store) DetailModel

NewDetailModel creates a new detail model.

func (DetailModel) LoadTicket

func (m DetailModel) LoadTicket() tea.Cmd

LoadTicket loads the ticket details.

func (*DetailModel) SetSearchQuery

func (m *DetailModel) SetSearchQuery(query string)

SetSearchQuery sets the query to highlight.

func (*DetailModel) SetSize

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

SetSize sets the dimensions for the detail view.

func (*DetailModel) SetTicketID

func (m *DetailModel) SetTicketID(id string)

SetTicketID sets the ticket to display.

func (DetailModel) Update

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

Update handles messages for the detail view.

func (DetailModel) View

func (m DetailModel) View() string

View renders the detail view.

type EditTicketMsg

type EditTicketMsg struct {
	Ticket *ticket.Ticket
}

EditTicketMsg is sent when the user wants to edit a ticket.

type ErrorMsg

type ErrorMsg struct {
	Err error
}

ErrorMsg is sent when an error occurs.

type FileChangedMsg

type FileChangedMsg struct{}

FileChangedMsg is sent when the ticket database file changes.

type FilterState

type FilterState struct {
	Status *ticket.Status
	Query  string
}

FilterState holds the current filter settings.

type FormModel

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

FormModel handles the create/edit ticket form.

func NewFormModel

func NewFormModel(store *storage.Store, projectCode string, t *ticket.Ticket) FormModel

NewFormModel creates a new form model.

func (FormModel) Init

func (m FormModel) Init() tea.Cmd

Init initializes the form model.

func (*FormModel) SetSize

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

SetSize sets the dimensions for the form view.

func (FormModel) Update

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

Update handles messages for the form view.

func (FormModel) View

func (m FormModel) View() string

View renders the form view.

type HelpModel

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

HelpModel provides a help overlay for displaying keyboard shortcuts.

func NewHelp

func NewHelp() HelpModel

NewHelp creates a new help model.

func (*HelpModel) ResetScroll

func (h *HelpModel) ResetScroll()

ResetScroll resets the scroll position to the top.

func (*HelpModel) ScrollDown

func (h *HelpModel) ScrollDown(contentHeight, visibleHeight int)

ScrollDown scrolls the help content down by one line.

func (*HelpModel) ScrollUp

func (h *HelpModel) ScrollUp()

ScrollUp scrolls the help content up by one line.

func (*HelpModel) ScrollY

func (h *HelpModel) ScrollY() int

ScrollY returns the current scroll position.

func (*HelpModel) SetSize

func (h *HelpModel) SetSize(width, height int)

SetSize sets the dimensions for the help overlay.

type KeyMap

type KeyMap struct {
	// Global keys
	Quit key.Binding
	Help key.Binding

	// Navigation
	Up     key.Binding
	Down   key.Binding
	Top    key.Binding
	Bottom key.Binding

	// Actions
	Enter        key.Binding
	Back         key.Binding
	New          key.Binding
	Edit         key.Binding
	Close        key.Binding
	Comment      key.Binding
	Search       key.Binding
	Refresh      key.Binding
	PriorityUp   key.Binding
	PriorityDown key.Binding

	// Filtering
	FilterOpen   key.Binding
	FilterClosed key.Binding
	FilterIcebox key.Binding
	FilterAll    key.Binding

	// Type settings
	SetBug     key.Binding
	SetFeature key.Binding
	SetTask    key.Binding
	SetEpic    key.Binding
	SetCleanup key.Binding

	// Direct priority settings
	SetPriority0 key.Binding
	SetPriority1 key.Binding
	SetPriority2 key.Binding
	SetPriority3 key.Binding
	SetPriority4 key.Binding
	SetPriority5 key.Binding

	// Form navigation
	NextField key.Binding
	PrevField key.Binding
	Save      key.Binding
	Cancel    key.Binding
}

KeyMap defines all key bindings for the TUI.

func DefaultKeyMap

func DefaultKeyMap() KeyMap

DefaultKeyMap returns the default key bindings.

type ListModel

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

ListModel handles the ticket list view.

func NewListModel

func NewListModel(store *storage.Store) ListModel

NewListModel creates a new list model.

func (ListModel) Init

func (m ListModel) Init() tea.Cmd

Init initializes the list model.

func (ListModel) IsSearching

func (m ListModel) IsSearching() bool

IsSearching returns true if search mode is active.

func (ListModel) Refresh

func (m ListModel) Refresh() tea.Cmd

Refresh reloads the ticket list.

func (*ListModel) SetSize

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

SetSize sets the dimensions for the list view.

func (ListModel) Update

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

Update handles messages for the list view.

func (ListModel) View

func (m ListModel) View() string

View renders the list view.

type Model

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

Model is the root model for the TUI application.

func New

func New(store *storage.Store, cfg *config.Config, ticketsPath string) Model

New creates a new TUI model.

func (Model) Init

func (m Model) Init() tea.Cmd

Init implements tea.Model.

func (Model) Update

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

Update implements tea.Model.

func (Model) View

func (m Model) View() string

View implements tea.Model.

type PromptModel

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

PromptModel provides a reusable yes/no confirmation prompt. It captures keyboard input when active and invokes callbacks on confirm/cancel.

func NewPrompt

func NewPrompt() PromptModel

NewPrompt creates a new prompt model.

func (PromptModel) Active

func (p PromptModel) Active() bool

Active returns whether the prompt is currently displayed.

func (PromptModel) Context

func (p PromptModel) Context() string

Context returns the context data set when showing the prompt.

func (*PromptModel) Hide

func (p *PromptModel) Hide()

Hide deactivates the prompt.

func (*PromptModel) Show

func (p *PromptModel) Show(message string, context string)

Show activates the prompt with the given message. The context parameter can store additional data (e.g., ticket ID).

func (*PromptModel) Update

func (p *PromptModel) Update(msg tea.Msg) PromptResult

Update handles keyboard input for the prompt. Returns the result of the user's action.

func (PromptModel) View

func (p PromptModel) View() string

View renders the prompt if active. Returns an empty string if the prompt is not active.

type PromptResult

type PromptResult int

PromptResult represents the user's response to a prompt.

const (
	PromptPending PromptResult = iota
	PromptConfirmed
	PromptCancelled
)

type RefreshListMsg

type RefreshListMsg struct{}

RefreshListMsg is sent to refresh the ticket list.

type SelectorModel

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

SelectorModel provides a selection list for choosing from predefined options. Users cycle through options with left/right arrow keys when focused.

func NewSelector

func NewSelector(options []string) SelectorModel

NewSelector creates a new selector with the given options. The first option is selected by default.

func (*SelectorModel) Blur

func (s *SelectorModel) Blur()

Blur removes focus from the selector.

func (*SelectorModel) Focus

func (s *SelectorModel) Focus()

Focus sets the selector as focused.

func (SelectorModel) Focused

func (s SelectorModel) Focused() bool

Focused returns whether the selector is focused.

func (*SelectorModel) SetValue

func (s *SelectorModel) SetValue(value string)

SetValue sets the selection to the option matching the given value. If the value is not found, the selection is unchanged.

func (SelectorModel) Update

func (s SelectorModel) Update(msg tea.Msg) (SelectorModel, tea.Cmd)

Update handles keyboard input for the selector.

func (SelectorModel) Value

func (s SelectorModel) Value() string

Value returns the currently selected option.

func (SelectorModel) View

func (s SelectorModel) View() string

View renders the selector. Shows all options with the selected one highlighted.

type StatusMsg

type StatusMsg struct {
	Message string
	IsError bool
}

StatusMsg is sent to display a status message.

type TicketClosedMsg

type TicketClosedMsg struct {
	ID string
}

TicketClosedMsg is sent after a ticket has been closed.

type TicketLoadedMsg

type TicketLoadedMsg struct {
	Ticket    *ticket.Ticket
	Comments  []*ticket.Comment
	BlockedBy []*ticket.Ticket
	Blocking  []*ticket.Ticket
	Err       error
}

TicketLoadedMsg is sent when a single ticket's details have been loaded.

type TicketPriorityUpdatedMsg

type TicketPriorityUpdatedMsg struct {
	ID          string
	NewPriority int
}

TicketPriorityUpdatedMsg is sent after a ticket's priority has been updated.

type TicketSavedMsg

type TicketSavedMsg struct {
	ID      string
	IsNew   bool
	Message string
}

TicketSavedMsg is sent after a ticket has been saved.

type TicketTypeUpdatedMsg

type TicketTypeUpdatedMsg struct {
	ID      string
	NewType ticket.Type
}

TicketTypeUpdatedMsg is sent after a ticket's type has been updated.

type TicketsLoadedMsg

type TicketsLoadedMsg struct {
	Tickets  []*ticket.Ticket
	Comments []*ticket.Comment
	Err      error
}

TicketsLoadedMsg is sent when tickets have been loaded from storage.

type ViewTicketMsg

type ViewTicketMsg struct {
	ID string
}

ViewTicketMsg is sent when the user wants to view a ticket's details.

Jump to

Keyboard shortcuts

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