ui

package
v0.0.0-...-d80aada Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package ui provides unified UI components for the CLI

Package ui provides input handling for CLI

Package ui provides user interface components

Package ui provides unified markdown rendering support

Package ui 提供 Bubble Tea UI 組件

Package ui provides terminal user interface components

Package ui provides syntax highlighting support

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CodeBlockStyle

func CodeBlockStyle() lipgloss.Style

CodeBlockStyle returns a style for code blocks

func ContainsMarkdown

func ContainsMarkdown(content string) bool

ContainsMarkdown checks if content likely contains markdown

func CreateConfirm

func CreateConfirm(title, description string) *huh.Form

CreateConfirm creates a confirmation dialog

func CreateForm

func CreateForm(fields ...huh.Field) *huh.Form

CreateForm creates a Huh form for user input

func CreateInput

func CreateInput(title, placeholder string) *huh.Form

CreateInput creates a text input dialog

func CreateSelect

func CreateSelect[T comparable](title string, options []huh.Option[T]) *huh.Form

CreateSelect creates a selection dialog

func DetectLanguage

func DetectLanguage(code string) string

DetectLanguage attempts to detect the programming language

func FormatCodeBlock

func FormatCodeBlock(code, language string, indent string) string

FormatCodeBlock formats a code block with proper indentation

func InlineCodeStyle

func InlineCodeStyle() lipgloss.Style

InlineCodeStyle returns a style for inline code

func RenderInlineCode

func RenderInlineCode(code string) string

RenderInlineCode renders inline code with styling

func ShowLoadingScreen

func ShowLoadingScreen(updateFunc func(*LoadingScreen))

ShowLoadingScreen displays a loading screen with progress updates

Types

type Command

type Command struct {
	Name        string
	Description string
	Shortcut    string
	Category    string
	Action      tea.Cmd
}

Command represents a single command in the command palette

type CommandPalette

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

CommandPalette command palette for executing commands

func NewCommandPalette

func NewCommandPalette() CommandPalette

NewCommandPalette create new CommandPalette

func (*CommandPalette) Hide

func (cp *CommandPalette) Hide()

Hide 隱藏命令面板

func (CommandPalette) IsVisible

func (cp CommandPalette) IsVisible() bool

IsVisible check if the command palette is visible

func (*CommandPalette) SetCommands

func (cp *CommandPalette) SetCommands(commands []Command)

SetCommands setter for commands

func (*CommandPalette) Show

func (cp *CommandPalette) Show()

Show 顯示命令面板

func (*CommandPalette) Toggle

func (cp *CommandPalette) Toggle()

Toggle 切換顯示狀態

func (CommandPalette) Update

func (cp CommandPalette) Update(msg tea.Msg) (CommandPalette, tea.Cmd)

Update handles updates to the command palette

func (CommandPalette) View

func (cp CommandPalette) View() string

View 渲染命令面板

type Components

type Components struct {
	Spinner spinner.Model
	Styles  *Styles
}

Components holds all UI components for reuse

func NewComponents

func NewComponents() *Components

NewComponents creates a new set of UI components

type InputReader

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

InputReader handles reading user input

func NewInputReader

func NewInputReader(r io.Reader) *InputReader

NewInputReader creates a new input reader

func (*InputReader) ReadLine

func (r *InputReader) ReadLine() (string, error)

ReadLine reads a line of input from the user

func (*InputReader) ReadMultiLine

func (r *InputReader) ReadMultiLine() (string, error)

ReadMultiLine reads multiple lines until EOF or empty line

type LoadingAnimation

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

LoadingAnimation provides a simple loading animation

func NewLoadingAnimation

func NewLoadingAnimation(message string) *LoadingAnimation

NewLoadingAnimation creates a new loading animation

func (*LoadingAnimation) Init

func (l *LoadingAnimation) Init() tea.Cmd

Init implements tea.Model

func (*LoadingAnimation) Stop

func (l *LoadingAnimation) Stop()

Stop stops the loading animation

func (*LoadingAnimation) Update

func (l *LoadingAnimation) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model

func (*LoadingAnimation) View

func (l *LoadingAnimation) View() string

View implements tea.Model

type LoadingScreen

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

LoadingScreen provides a beautiful loading screen with Bubble Tea

func NewLoadingScreen

func NewLoadingScreen() *LoadingScreen

NewLoadingScreen initializes with default status and zero progress

func (*LoadingScreen) Finish

func (l *LoadingScreen) Finish()

Finish marks the loading as complete

func (*LoadingScreen) Start

func (l *LoadingScreen) Start()

Start starts the loading screen display

func (*LoadingScreen) UpdateProgress

func (l *LoadingScreen) UpdateProgress(percent float64)

UpdateProgress updates the progress percentage

func (*LoadingScreen) UpdateStatus

func (l *LoadingScreen) UpdateStatus(status string)

UpdateStatus updates the status message

type MarkdownConfig

type MarkdownConfig struct {
	// Width sets the maximum width for word wrapping (0 = no limit)
	Width int

	// Indentation sets the indentation prefix for all lines
	Indentation string

	// EnableEmoji enables emoji rendering
	EnableEmoji bool

	// EnableSyntaxHighlighting enables syntax highlighting for code blocks
	EnableSyntaxHighlighting bool

	// StylePath sets the glamour style ("dark", "light", "notty", etc.)
	StylePath string

	// PreserveNewLines preserves new lines in the rendered output
	PreserveNewLines bool
}

MarkdownConfig holds configuration options for the markdown renderer

func DefaultMarkdownConfig

func DefaultMarkdownConfig() MarkdownConfig

DefaultMarkdownConfig returns the default configuration

type MarkdownRenderer

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

MarkdownRenderer handles markdown rendering for various contexts

func NewMarkdownRenderer

func NewMarkdownRenderer(config MarkdownConfig) (*MarkdownRenderer, error)

NewMarkdownRenderer creates a new markdown renderer with the given configuration

func NewSimpleMarkdownRenderer

func NewSimpleMarkdownRenderer() (*MarkdownRenderer, error)

NewSimpleMarkdownRenderer creates a markdown renderer with default settings

func (*MarkdownRenderer) DetectAndRenderCode

func (r *MarkdownRenderer) DetectAndRenderCode(content string) (string, error)

DetectAndRenderCode detects code blocks in content and renders them

func (*MarkdownRenderer) DetectMarkdown

func (r *MarkdownRenderer) DetectMarkdown(content string) bool

DetectMarkdown checks if content likely contains markdown

func (*MarkdownRenderer) GetConfig

func (r *MarkdownRenderer) GetConfig() MarkdownConfig

GetConfig returns the current configuration

func (*MarkdownRenderer) IsEnabled

func (r *MarkdownRenderer) IsEnabled() bool

IsEnabled returns whether markdown rendering is enabled

func (*MarkdownRenderer) Render

func (r *MarkdownRenderer) Render(content string) (string, error)

Render renders markdown content

func (*MarkdownRenderer) RenderCodeBlock

func (r *MarkdownRenderer) RenderCodeBlock(code, language string) (string, error)

RenderCodeBlock renders a code block with optional syntax highlighting

func (*MarkdownRenderer) SetEnabled

func (r *MarkdownRenderer) SetEnabled(enabled bool)

SetEnabled toggles markdown rendering

func (*MarkdownRenderer) WithConfig

func (r *MarkdownRenderer) WithConfig(config MarkdownConfig) (*MarkdownRenderer, error)

WithConfig creates a new renderer with updated configuration

type OutputFormatter

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

OutputFormatter formats AI output

func NewOutputFormatter

func NewOutputFormatter() *OutputFormatter

NewOutputFormatter creates new output formatter

func (*OutputFormatter) FormatJSON

func (f *OutputFormatter) FormatJSON(content string) string

FormatJSON formats JSON content

func (*OutputFormatter) FormatOutput

func (f *OutputFormatter) FormatOutput(content string) string

FormatOutput formats output content

func (*OutputFormatter) FormatTable

func (f *OutputFormatter) FormatTable(headers []string, rows [][]string) string

FormatTable format output as a table

func (*OutputFormatter) FormatWarning

func (f *OutputFormatter) FormatWarning(message string) string

FormatWarning formats a warning message

type Progress

type Progress struct {
	Current int
	Total   int
	Width   int
	Style   lipgloss.Style
}

Progress shows a progress indicator with percentage

func NewProgress

func NewProgress(total int) *Progress

NewProgress creates a new progress bar

func (*Progress) Increment

func (p *Progress) Increment()

Increment increases the current progress

func (*Progress) View

func (p *Progress) View() string

View renders the progress bar

type Spinner

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

Spinner provides a simple animated spinner for indicating progress

func NewSpinner

func NewSpinner(message string) *Spinner

NewSpinner uses Unicode braille characters for smooth animation

func NewSpinnerWithPrefix

func NewSpinnerWithPrefix(prefix, message string) *Spinner

NewSpinnerWithPrefix preserves static prefix text during animation

func (*Spinner) Start

func (s *Spinner) Start()

Start begins the spinner animation

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop stops the spinner animation

type Styles

type Styles struct {
	Title     lipgloss.Style
	Subtitle  lipgloss.Style
	Error     lipgloss.Style
	Success   lipgloss.Style
	Info      lipgloss.Style
	Warning   lipgloss.Style
	User      lipgloss.Style
	Assistant lipgloss.Style
	Tool      lipgloss.Style
	Timestamp lipgloss.Style
	Border    lipgloss.Style
	Focused   lipgloss.Style
	Unfocused lipgloss.Style
}

Styles holds all style definitions

func DefaultStyles

func DefaultStyles() *Styles

DefaultStyles returns the default style set

type SyntaxHighlighter

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

SyntaxHighlighter provides code syntax highlighting

func NewSyntaxHighlighter

func NewSyntaxHighlighter() *SyntaxHighlighter

NewSyntaxHighlighter creates a new syntax highlighter

func (*SyntaxHighlighter) Highlight

func (h *SyntaxHighlighter) Highlight(code, language string) (string, error)

Highlight applies syntax highlighting to code

func (*SyntaxHighlighter) HighlightInline

func (h *SyntaxHighlighter) HighlightInline(code string) string

HighlightInline highlights inline code snippets

type ToolExecution

type ToolExecution struct {
	Name      string
	Status    string // "running", "success", "error"
	StartTime time.Time
	EndTime   time.Time
	Result    string
}

ToolExecution shows tool execution status

func (*ToolExecution) View

func (t *ToolExecution) View(styles *Styles) string

View renders the tool execution status

Directories

Path Synopsis
components
chat
Package chat provides chat UI animations
Package chat provides chat UI animations
styles
Package styles provides shared UI styles and theming for the CLI interface.
Package styles provides shared UI styles and theming for the CLI interface.
Package render provides UI component builders for dynamic rendering
Package render provides UI component builders for dynamic rendering
views
conversations
Package conversations provides UI components for conversation management
Package conversations provides UI components for conversation management

Jump to

Keyboard shortcuts

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