tui

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package tui provides shared lipgloss styles and bubbletea components for SSU.

These styles are used inside bubbletea Views (lipgloss only, NOT fatih/color). Outside bubbletea (--auto mode, non-TUI), the existing output package with fatih/color is used instead.

Index

Constants

View Source
const (
	SortByPath   = 0
	SortByStatus = 1
	SortByBehind = 2
)

Sort modes cycle through: path -> status -> behind -> path.

Variables

View Source
var (
	StatusPendingStyle  = lipgloss.NewStyle().Foreground(lipgloss.Color("2"))            // green
	StatusCurrentStyle  = lipgloss.NewStyle().Foreground(lipgloss.Color("6"))            // cyan
	StatusModifiedStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("3"))            // yellow
	StatusAheadStyle    = lipgloss.NewStyle().Foreground(lipgloss.Color("5"))            // magenta
	StatusConflictStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("1"))            // red
	StatusErrorStyle    = lipgloss.NewStyle().Foreground(lipgloss.Color("1")).Bold(true) // red bold
	StatusSkippedStyle  = lipgloss.NewStyle().Foreground(lipgloss.Color("240"))          // gray
	StatusMissingStyle  = lipgloss.NewStyle().Foreground(lipgloss.Color("240"))          // gray
)

Status-specific styles matching the bash version semantics from output/color.go.

View Source
var (
	RootPathStyle = lipgloss.NewStyle().Bold(true)
	HeaderStyle   = lipgloss.NewStyle().Bold(true)
	MutedStyle    = lipgloss.NewStyle().Foreground(lipgloss.Color("240"))
	TitleStyle    = lipgloss.NewStyle().Bold(true).Underline(true)
)

General-purpose styles shared across all TUI components.

Functions

func FilterAhead

func FilterAhead() func(SelectorItem) bool

FilterAhead returns a FilterFn that keeps only items with ahead status.

func FilterDetached added in v1.1.3

func FilterDetached() func(SelectorItem) bool

FilterDetached returns a FilterFn that keeps only items with detached HEAD.

func FilterPending

func FilterPending() func(SelectorItem) bool

FilterPending returns a FilterFn that keeps only items with pending status.

func PrintProgressLine

func PrintProgressLine(w io.Writer, done, total int, path string)

PrintProgressLine writes a simple text progress line for non-TTY/auto mode. Format: "Fetching done/total path..."

func StyleForStatus

func StyleForStatus(s git.SubmoduleStatus) lipgloss.Style

StyleForStatus returns the lipgloss style for the given submodule status.

Types

type ChangedSubmoduleItem

type ChangedSubmoduleItem struct {
	SubPath  string
	IsStaged bool
}

ChangedSubmoduleItem implements SelectorItem for submodule paths with changed pointer commits (used by the project command).

func (ChangedSubmoduleItem) DetailContent

func (c ChangedSubmoduleItem) DetailContent() string

DetailContent returns a short description for the detail pane.

func (ChangedSubmoduleItem) Label

func (c ChangedSubmoduleItem) Label() string

Label returns the submodule path for display.

func (ChangedSubmoduleItem) Metadata

func (c ChangedSubmoduleItem) Metadata() string

Metadata returns a status indicator.

func (ChangedSubmoduleItem) Path

func (c ChangedSubmoduleItem) Path() string

Path returns the submodule path.

type CheckoutCompleteMsg added in v1.1.3

type CheckoutCompleteMsg struct {
	Result *engine.CheckoutResult
	Err    error
}

CheckoutCompleteMsg is sent when a checkout operation completes.

type FetchCompleteMsg

type FetchCompleteMsg struct {
	Result interface{} // *engine.ScanResult (type-assert by caller)
	Err    error
}

FetchCompleteMsg signals that the fetch/scan operation finished.

type FetchProgressMsg

type FetchProgressMsg struct {
	Path  string
	Done  int
	Total int
	Err   error
}

FetchProgressMsg reports progress during parallel fetch.

type ProcessCompleteMsg

type ProcessCompleteMsg struct {
	Result interface{} // *engine.UpdateResult or *engine.PushResult
	Err    error
}

ProcessCompleteMsg signals that the update/push operation finished.

type ProcessItemMsg added in v1.1.2

type ProcessItemMsg struct {
	Type   engine.ProgressEventType // Started, Completed, Failed
	Path   string
	Action string // result text for completed items
	Err    error
	Done   int
	Total  int
}

ProcessItemMsg reports per-item state changes during push/update processing.

type ProcessModel added in v1.1.2

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

ProcessModel implements tea.Model for multi-line live status during push/update processing.

func NewProcessModel added in v1.1.2

func NewProcessModel(paths []string, operation string) ProcessModel

NewProcessModel creates a new multi-line process status model. paths is the list of submodule paths to process, operation is "push" or "update".

func (ProcessModel) Complete added in v1.1.2

func (m ProcessModel) Complete() bool

Complete reports whether the operation finished.

func (ProcessModel) Err added in v1.1.2

func (m ProcessModel) Err() error

Err returns any fatal error that occurred.

func (ProcessModel) Init added in v1.1.2

func (m ProcessModel) Init() tea.Cmd

Init implements tea.Model.

func (ProcessModel) Result added in v1.1.2

func (m ProcessModel) Result() interface{}

Result returns the stored result for the caller to type-assert.

func (ProcessModel) Update added in v1.1.2

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

Update implements tea.Model.

func (ProcessModel) View added in v1.1.2

func (m ProcessModel) View() string

View implements tea.Model.

type ProcessProgressMsg

type ProcessProgressMsg struct {
	Path   string
	Done   int
	Total  int
	Action string // e.g. "updating", "pushing"
	Err    error
}

ProcessProgressMsg reports progress during update/push processing.

type ProgressModel

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

ProgressModel implements tea.Model for displaying an animated progress bar with a count label and currently-processing submodule name.

func NewProgressModel

func NewProgressModel(total int) ProgressModel

NewProgressModel creates a new progress bar model.

func (ProgressModel) Complete

func (m ProgressModel) Complete() bool

Complete reports whether the operation finished.

func (ProgressModel) Err

func (m ProgressModel) Err() error

Err returns any fatal error that occurred.

func (ProgressModel) Init

func (m ProgressModel) Init() tea.Cmd

Init implements tea.Model. Progress is driven by external messages.

func (ProgressModel) Result

func (m ProgressModel) Result() interface{}

Result returns the stored result for the caller to type-assert.

func (ProgressModel) Update

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

Update implements tea.Model.

func (ProgressModel) View

func (m ProgressModel) View() string

View implements tea.Model.

type PushCompleteMsg

type PushCompleteMsg struct {
	Result *engine.PushResult
	Err    error
}

PushCompleteMsg is sent when a push operation completes.

type ScanCompleteMsg

type ScanCompleteMsg struct {
	Result *engine.ScanResult
	Err    error
}

ScanCompleteMsg is sent when a scan operation completes.

type SelectorItem

type SelectorItem interface {
	Path() string          // Submodule path (used for filtering)
	Label() string         // Display label
	Metadata() string      // Branch/behind/status badge string
	DetailContent() string // Content for the split-pane detail view
}

SelectorItem is the interface each item in the multi-select list must satisfy.

func ChangedSubmoduleItems

func ChangedSubmoduleItems(paths []string, staged map[string]bool) []SelectorItem

ChangedSubmoduleItems creates SelectorItems from a list of changed submodule paths.

func SubmoduleItems

func SubmoduleItems(infos []*engine.SubmoduleInfo) []SelectorItem

SubmoduleItems converts a slice of SubmoduleInfo pointers to SelectorItems.

type SelectorKeyMap

type SelectorKeyMap struct {
	Up      key.Binding
	Down    key.Binding
	Toggle  key.Binding
	All     key.Binding
	None    key.Binding
	Confirm key.Binding
	Quit    key.Binding
	Filter  key.Binding
	Help    key.Binding
	Detail  key.Binding
	Sort    key.Binding
}

SelectorKeyMap defines all keybindings for the multi-select selector.

func DefaultSelectorKeyMap

func DefaultSelectorKeyMap() SelectorKeyMap

DefaultSelectorKeyMap returns the default keybindings matching bash-era conventions plus new features (filter, help, detail, sort).

func (SelectorKeyMap) FullHelp

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

FullHelp implements help.KeyMap -- returns bindings for the full help display (two columns).

func (SelectorKeyMap) ShortHelp

func (k SelectorKeyMap) ShortHelp() []key.Binding

ShortHelp implements help.KeyMap -- returns bindings for the compact help line.

type SelectorModel

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

SelectorModel implements tea.Model for the multi-select submodule picker. It supports checkboxes, cursor navigation, filtering, split-pane changelog detail, help overlay, sorting, and a confirmation step.

func NewSelectorModel

func NewSelectorModel(items []SelectorItem, opts SelectorOpts) SelectorModel

NewSelectorModel creates a new multi-select selector model.

func (SelectorModel) Cancelled

func (m SelectorModel) Cancelled() bool

Cancelled reports whether the user cancelled selection.

func (SelectorModel) Confirmed

func (m SelectorModel) Confirmed() bool

Confirmed reports whether the user confirmed selection.

func (SelectorModel) Init

func (m SelectorModel) Init() tea.Cmd

Init implements tea.Model. Requests window size.

func (SelectorModel) Selected

func (m SelectorModel) Selected() []*engine.SubmoduleInfo

Selected returns the SubmoduleInfo pointers for all selected items.

func (SelectorModel) SelectedPaths

func (m SelectorModel) SelectedPaths() []string

SelectedPaths returns the Path() of all selected items regardless of concrete type.

func (*SelectorModel) SetOperation

func (m *SelectorModel) SetOperation(op string)

SetOperation sets the operation name used in the confirmation prompt.

func (*SelectorModel) SetTitle

func (m *SelectorModel) SetTitle(title string)

SetTitle sets the operation name used in the confirmation prompt.

func (SelectorModel) Update

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

Update implements tea.Model.

func (SelectorModel) View

func (m SelectorModel) View() string

View implements tea.Model.

type SelectorOpts

type SelectorOpts struct {
	Title      string                       // Title displayed at the top
	Subtitle   string                       // Informational line below the title
	ShowDetail bool                         // Show detail pane by default
	FilterFn   func(item SelectorItem) bool // Optional pre-filter
	Operation  string                       // Operation name for confirmation (e.g. "update", "push")
	SelectAll  bool                         // Pre-select all items (user deselects unwanted)
}

SelectorOpts configures the selector model.

type SpinnerModel added in v1.1.2

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

SpinnerModel implements tea.Model for displaying a MiniDot spinner with a counter and currently-processing path during the scan/fetch phase.

View: "⠹ Fetching 12/24 plugins/blog..."

func NewSpinnerModel added in v1.1.2

func NewSpinnerModel() SpinnerModel

NewSpinnerModel creates a new spinner model for scan progress.

func (SpinnerModel) Complete added in v1.1.2

func (m SpinnerModel) Complete() bool

Complete reports whether the operation finished.

func (SpinnerModel) Err added in v1.1.2

func (m SpinnerModel) Err() error

Err returns any fatal error that occurred.

func (SpinnerModel) Init added in v1.1.2

func (m SpinnerModel) Init() tea.Cmd

Init implements tea.Model. Starts the spinner tick.

func (SpinnerModel) Result added in v1.1.2

func (m SpinnerModel) Result() interface{}

Result returns the stored result for the caller to type-assert.

func (SpinnerModel) Update added in v1.1.2

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

Update implements tea.Model.

func (SpinnerModel) View added in v1.1.2

func (m SpinnerModel) View() string

View implements tea.Model.

type SubmoduleItem

type SubmoduleItem struct {
	Info *engine.SubmoduleInfo
}

SubmoduleItem adapts engine.SubmoduleInfo to the SelectorItem interface.

func (SubmoduleItem) DetailContent

func (s SubmoduleItem) DetailContent() string

DetailContent returns the changelog lines for the detail pane. Returns "No incoming changes" when the Changelog slice is empty.

func (SubmoduleItem) Label

func (s SubmoduleItem) Label() string

Label returns the submodule path for display.

func (SubmoduleItem) Metadata

func (s SubmoduleItem) Metadata() string

Metadata returns a formatted string showing branch, behind count, and status badge.

func (SubmoduleItem) Path

func (s SubmoduleItem) Path() string

Path returns the submodule path.

type UpdateCompleteMsg

type UpdateCompleteMsg struct {
	Result *engine.UpdateResult
	Err    error
}

UpdateCompleteMsg is sent when an update operation completes.

type UpdateProgressMsg

type UpdateProgressMsg struct {
	Path  string
	Done  int
	Total int
	Err   error
}

UpdateProgressMsg is sent for each submodule update progress event.

Jump to

Keyboard shortcuts

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