ui

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnabledIcon  = "●"
	DisabledIcon = "○"
	SuccessIcon  = "✓"
	FailIcon     = "✗"
)

Status indicators

View Source
const SomethingElse = "__something_else__"

Variables

This section is empty.

Functions

func ANSILen added in v0.0.6

func ANSILen(s string) int

ANSILen returns the display width of a string, ignoring ANSI codes

func CalcDiffWidth added in v0.0.5

func CalcDiffWidth(oldContent, newContent string) int

CalcDiffWidth calculates the required padding width for a diff The result is capped to the terminal-aware max content width

func GetRefinement

func GetRefinement() (string, error)

GetRefinement prompts the user for additional guidance

func InitTheme

func InitTheme(cfg ThemeConfig)

InitTheme initializes the theme from config

func PrintCompactDiff added in v0.0.5

func PrintCompactDiff(filePath, oldContent, newContent string, padWidth int)

PrintCompactDiff prints a compact diff with 2 lines of context and line numbers padWidth specifies the total line width for consistent backgrounds across diffs

func PromptApplyEdit added in v0.0.5

func PromptApplyEdit() bool

PromptApplyEdit asks the user whether to apply an edit Returns true if user wants to apply (Enter or y), false to skip (n)

func RunEditWithSpinner added in v0.0.6

func RunEditWithSpinner(ctx context.Context, provider llm.EditToolProvider, systemPrompt, userPrompt string, debug bool) ([]llm.EditToolCall, error)

RunEditWithSpinner shows a spinner while executing the edit request Returns edits, or error if cancelled or failed

func RunSetupWizard

func RunSetupWizard() (*config.Config, error)

RunSetupWizard runs the first-time setup wizard and returns the config

func RunUnifiedDiffWithSpinner added in v0.0.6

func RunUnifiedDiffWithSpinner(ctx context.Context, provider llm.UnifiedDiffProvider, systemPrompt, userPrompt string, debug bool) (string, error)

RunUnifiedDiffWithSpinner shows a spinner while executing the unified diff request Returns the diff string, or error if cancelled or failed

func RunWithSpinner

func RunWithSpinner(ctx context.Context, provider llm.Provider, req llm.SuggestRequest) ([]llm.CommandSuggestion, error)

RunWithSpinner shows a spinner while executing the LLM request Returns suggestions, or error if cancelled or failed

func SelectCommand

func SelectCommand(suggestions []llm.CommandSuggestion, shell string, provider llm.Provider, allowNonTTY bool) (string, error)

SelectCommand presents the user with a list of command suggestions and returns the selected one. Returns the selected command or SomethingElse if user wants to refine their request. If provider is non-nil and user presses 'h', shows help for the highlighted command. allowNonTTY permits a non-interactive fallback when no TTY is available.

func SetTheme

func SetTheme(t *Theme)

SetTheme sets the current active theme

func ShowCommand

func ShowCommand(cmd string)

ShowCommand displays the command that will be executed (to stderr, keeping stdout clean)

func ShowCommandHelp

func ShowCommandHelp(command, shell string, provider llm.Provider) error

ShowCommandHelp renders scrollable help for a command

func ShowEditSkipped added in v0.0.5

func ShowEditSkipped(filePath string, reason string)

ShowEditSkipped shows that an edit was skipped

func ShowError

func ShowError(msg string)

ShowError displays an error message

func StripANSI added in v0.0.6

func StripANSI(s string) string

StripANSI removes all ANSI escape codes from a string

func Truncate

func Truncate(s string, maxLen int) string

Truncate shortens a string to maxLen with ellipsis

Types

type Highlighter added in v0.0.6

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

Highlighter handles syntax highlighting for diff display

func NewHighlighter added in v0.0.6

func NewHighlighter(filePath string) *Highlighter

NewHighlighter creates a highlighter for the given file path. Returns nil if the language is not recognized.

func (*Highlighter) HighlightLine added in v0.0.6

func (h *Highlighter) HighlightLine(line string) string

HighlightLine applies syntax highlighting to a line without a background color.

func (*Highlighter) HighlightLineWithBg added in v0.0.6

func (h *Highlighter) HighlightLineWithBg(line string, bg [3]int) string

HighlightLineWithBg applies syntax highlighting to a line with a specific background color. bg is an RGB array [r, g, b] for true color background.

type Styles

type Styles struct {

	// Text styles
	Title       lipgloss.Style
	Subtitle    lipgloss.Style
	Success     lipgloss.Style
	Error       lipgloss.Style
	Muted       lipgloss.Style
	Bold        lipgloss.Style
	Highlighted lipgloss.Style

	// Table styles
	TableHeader lipgloss.Style
	TableCell   lipgloss.Style
	TableBorder lipgloss.Style

	// UI element styles
	Spinner lipgloss.Style
	Command lipgloss.Style
	Footer  lipgloss.Style

	// Diff styles
	DiffAdd     lipgloss.Style // Added lines (+)
	DiffRemove  lipgloss.Style // Removed lines (-)
	DiffContext lipgloss.Style // Context lines (unchanged)
	DiffHeader  lipgloss.Style // Diff header (@@ ... @@)
	// contains filtered or unexported fields
}

Styles returns styled text helpers bound to a renderer

func DefaultStyles

func DefaultStyles() *Styles

DefaultStyles returns styles for stderr (default TUI output)

func NewStyledWithTheme

func NewStyledWithTheme(output *os.File, theme *Theme) *Styles

NewStyledWithTheme creates styles with a specific theme

func NewStyles

func NewStyles(output *os.File) *Styles

NewStyles creates a new Styles instance for the given output

func (*Styles) FormatEnabled

func (s *Styles) FormatEnabled(enabled bool) string

FormatEnabled returns a styled enabled/disabled indicator

func (*Styles) FormatResult

func (s *Styles) FormatResult(success bool, msg string) string

FormatResult returns a styled success/fail result

func (*Styles) Theme

func (s *Styles) Theme() *Theme

Theme returns the theme used by these styles

type Theme

type Theme struct {
	// Primary colors
	Primary   lipgloss.Color // main accent color (commands, highlights)
	Secondary lipgloss.Color // secondary accent (headers, borders)

	// Semantic colors
	Success lipgloss.Color // success states, enabled
	Error   lipgloss.Color // error states, disabled
	Warning lipgloss.Color // warnings
	Muted   lipgloss.Color // dimmed/secondary text
	Text    lipgloss.Color // primary text

	// UI element colors
	Spinner    lipgloss.Color // loading spinner
	Border     lipgloss.Color // borders and dividers
	Background lipgloss.Color // background (if needed)

	// Diff backgrounds
	DiffAddBg     lipgloss.Color // background for added lines
	DiffRemoveBg  lipgloss.Color // background for removed lines
	DiffContextBg lipgloss.Color // background for context lines
}

Theme defines the color palette for the UI

func DefaultTheme

func DefaultTheme() *Theme

DefaultTheme returns the default color theme

func GetTheme

func GetTheme() *Theme

GetTheme returns the current active theme

func ThemeFromConfig

func ThemeFromConfig(cfg ThemeConfig) *Theme

ThemeFromConfig creates a theme with config overrides applied

type ThemeConfig

type ThemeConfig struct {
	Primary   string
	Secondary string
	Success   string
	Error     string
	Warning   string
	Muted     string
	Text      string
	Spinner   string
}

ThemeConfig mirrors the config.ThemeConfig for applying overrides

Jump to

Keyboard shortcuts

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