ui

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Primary   = lipgloss.Color("#7C3AED") // Purple
	Secondary = lipgloss.Color("#06B6D4") // Cyan
	Success   = lipgloss.Color("#10B981") // Green
	Warning   = lipgloss.Color("#F59E0B") // Yellow
	Error     = lipgloss.Color("#EF4444") // Red
	Muted     = lipgloss.Color("#6B7280") // Gray
	Text      = lipgloss.Color("#F9FAFB") // Light
)

Color palette (default values, can be overridden by config)

View Source
var (
	TitleStyle = lipgloss.NewStyle().
				Foreground(Primary).
				Bold(true).
				Padding(0, 1)

	SubtitleStyle = lipgloss.NewStyle().
					Foreground(Secondary).
					Italic(true)

	SelectedItemStyle = lipgloss.NewStyle().
						Foreground(Text).
						Background(Primary).
						Bold(true).
						Padding(0, 1)

	NormalItemStyle = lipgloss.NewStyle().
					Foreground(Text).
					Padding(0, 1)

	CurrentItemStyle = lipgloss.NewStyle().
						Foreground(Success).
						Bold(true).
						Padding(0, 1)

	HelpStyle = lipgloss.NewStyle().
				Foreground(Muted).
				Italic(true).
				Margin(1, 0)

	ErrorStyle = lipgloss.NewStyle().
				Foreground(Error).
				Bold(true).
				Padding(0, 1)

	SuccessStyle = lipgloss.NewStyle().
					Foreground(Success).
					Bold(true).
					Padding(0, 1)

	WarningStyle = lipgloss.NewStyle().
					Foreground(Warning).
					Bold(true).
					Padding(0, 1)

	NormalStyle = lipgloss.NewStyle().
				Foreground(Text)

	BorderStyle = lipgloss.NewStyle().
				Border(lipgloss.RoundedBorder()).
				BorderForeground(Primary).
				Padding(1, 2)

	InputStyle = lipgloss.NewStyle().
				Foreground(Text).
				Background(lipgloss.Color("#374151")).
				Padding(0, 1).
				Margin(0, 1)
)

Base styles

Functions

func GetBranchIcon

func GetBranchIcon() string

GetBranchIcon returns an icon for branch

func GetPathIcon

func GetPathIcon() string

GetPathIcon returns an icon for path

func GetStatusIcon

func GetStatusIcon(isCurrent bool) string

GetStatusIcon returns an icon based on status

func GetTTYFiles

func GetTTYFiles(capability TTYCapability) (*os.File, *os.File, func(), error)

GetTTYFiles returns appropriate input/output files based on capability

func InitializeTheme

func InitializeTheme(cfg *config.Config)

InitializeTheme initializes the theme from config

func SimpleSelectWorktree

func SimpleSelectWorktree(worktrees []git.Worktree, output *os.File, input *os.File) (*git.Worktree, error)

SimpleSelectWorktree displays a numbered list of worktrees and prompts for selection This is used when full TUI is not available (e.g., in command substitution)

func SmartSelectWorktree

func SmartSelectWorktree(worktrees []git.Worktree) (*git.Worktree, error)

SmartSelectWorktree selects the best UI method based on TTY capabilities

Types

type ConfirmModel

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

func NewConfirm

func NewConfirm(title, message string) ConfirmModel

func (ConfirmModel) GetResult

func (m ConfirmModel) GetResult() ConfirmResult

func (ConfirmModel) Init

func (m ConfirmModel) Init() tea.Cmd

func (ConfirmModel) Update

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

func (ConfirmModel) View

func (m ConfirmModel) View() string

type ConfirmResult

type ConfirmResult struct {
	Confirmed bool // true if user selected yes, false if no or cancelled
	Cancelled bool // true if user cancelled (q/esc)
}

type FieldDependency

type FieldDependency struct {
	SourceIndex int                             // Index of the source field
	TargetIndex int                             // Index of the target field
	UpdateFunc  func(sourceValue string) string // Function to compute target value from source
}

FieldDependency defines a dependency relationship between input fields

type FileInterface

type FileInterface interface {
	io.ReadWriter
	Fd() uintptr
}

FileInterface defines the interface for file operations needed by the selector

type InputModel

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

func NewInput

func NewInput(title string, prompts []string, defaults []string) InputModel

func NewInputWithDependencies

func NewInputWithDependencies(title string, prompts []string, defaults []string, dependencies []FieldDependency) InputModel

func NewWorktreeInput

func NewWorktreeInput(title string, worktreePathPrefix string) InputModel

NewWorktreeInput creates an input dialog for new worktree with auto-path generation

func (InputModel) GetResult

func (m InputModel) GetResult() InputResult

func (InputModel) Init

func (m InputModel) Init() tea.Cmd

func (InputModel) Update

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

func (InputModel) View

func (m InputModel) View() string

type InputResult

type InputResult struct {
	Values    []string
	Submitted bool
}

type KeyboardSelector

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

KeyboardSelector provides arrow key navigation without full TUI

func NewKeyboardSelector

func NewKeyboardSelector(worktrees []git.Worktree, input, output *os.File) *KeyboardSelector

NewKeyboardSelector creates a new keyboard-based selector

func (*KeyboardSelector) Run

func (k *KeyboardSelector) Run() (*git.Worktree, error)

Run starts the keyboard selector

type SelectionResult

type SelectionResult struct {
	Worktree git.Worktree
	Action   string // "select", "delete", "create", "quit"
}

type SelectorModel

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

func NewSelector

func NewSelector(worktrees []git.Worktree, title, action string, allowDelete bool) SelectorModel

func (SelectorModel) GetResult

func (m SelectorModel) GetResult() SelectionResult

func (SelectorModel) Init

func (m SelectorModel) Init() tea.Cmd

func (SelectorModel) Update

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

func (SelectorModel) View

func (m SelectorModel) View() string

type TTYCapability

type TTYCapability int

TTYCapability represents the level of TTY control available

const (
	NoTTYControl TTYCapability = iota
	BasicTTYControl
	FullTTYControl
)

func DetectTTYCapability

func DetectTTYCapability() TTYCapability

DetectTTYCapability determines what level of TTY control is available

Jump to

Keyboard shortcuts

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