Documentation
¶
Overview ¶
Package ui provides unified UI components for the CLI
Package ui provides user interface related functionality ¶
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 ¶
- func CodeBlockStyle() lipgloss.Style
- func ContainsMarkdown(content string) bool
- func CreateConfirm(title, description string) *huh.Form
- func CreateForm(fields ...huh.Field) *huh.Form
- func CreateInput(title, placeholder string) *huh.Form
- func CreateSelect[T comparable](title string, options []huh.Option[T]) *huh.Form
- func DetectLanguage(code string) string
- func FormatCodeBlock(code, language string, indent string) string
- func InlineCodeStyle() lipgloss.Style
- func RenderInlineCode(code string) string
- func ShowLoadingScreen(updateFunc func(*LoadingScreen))
- type Command
- type CommandPalette
- func (cp *CommandPalette) Hide()
- func (cp CommandPalette) IsVisible() bool
- func (cp *CommandPalette) SetCommands(commands []Command)
- func (cp *CommandPalette) Show()
- func (cp *CommandPalette) Toggle()
- func (cp CommandPalette) Update(msg tea.Msg) (CommandPalette, tea.Cmd)
- func (cp CommandPalette) View() string
- type Components
- type InputReader
- type LoadingAnimation
- type LoadingScreen
- type MarkdownConfig
- type MarkdownRenderer
- func (r *MarkdownRenderer) DetectAndRenderCode(content string) (string, error)
- func (r *MarkdownRenderer) DetectMarkdown(content string) bool
- func (r *MarkdownRenderer) GetConfig() MarkdownConfig
- func (r *MarkdownRenderer) IsEnabled() bool
- func (r *MarkdownRenderer) Render(content string) (string, error)
- func (r *MarkdownRenderer) RenderCodeBlock(code, language string) (string, error)
- func (r *MarkdownRenderer) SetEnabled(enabled bool)
- func (r *MarkdownRenderer) WithConfig(config MarkdownConfig) (*MarkdownRenderer, error)
- type OutputFormatter
- type Progress
- type Spinner
- type Styles
- type SyntaxHighlighter
- type ToolExecution
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CodeBlockStyle ¶
CodeBlockStyle returns a style for code blocks
func ContainsMarkdown ¶
ContainsMarkdown checks if content likely contains markdown
func CreateConfirm ¶
CreateConfirm creates a confirmation dialog
func CreateForm ¶
CreateForm creates a Huh form for user input
func CreateInput ¶
CreateInput creates a text input dialog
func CreateSelect ¶
CreateSelect creates a selection dialog
func DetectLanguage ¶
DetectLanguage attempts to detect the programming language
func FormatCodeBlock ¶
FormatCodeBlock formats a code block with proper indentation
func InlineCodeStyle ¶
InlineCodeStyle returns a style for inline code
func RenderInlineCode ¶
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) 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) Update ¶
func (cp CommandPalette) Update(msg tea.Msg) (CommandPalette, tea.Cmd)
Update handles updates to the command palette
type Components ¶
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
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 ¶
Progress shows a progress indicator with percentage
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner provides a simple animated spinner for indicating progress
func NewSpinner ¶
NewSpinner uses Unicode braille characters for smooth animation
func NewSpinnerWithPrefix ¶
NewSpinnerWithPrefix preserves static prefix text during 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
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
Source Files
¶
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 |