Documentation
¶
Index ¶
- Constants
- Variables
- func Blue(text string) string
- func Bold(text string) string
- func CenterString(s string, width int) string
- func Clamp(value, min, max int) int
- func ContextWithTimeout(parent context.Context, seconds int) (context.Context, context.CancelFunc)
- func Cyan(text string) string
- func Dim(text string) string
- func DisplayWidth(s string) int
- func FormatDuration(seconds int) string
- func FormatFileSize(size int64) string
- func Green(text string) string
- func Input(ctx context.Context, message, placeholder string) (string, error)
- func IsCtrlC(key Key) bool
- func IsEnterPressed(key Key) bool
- func IsEscapePressed(key Key) bool
- func IsKeyPressed(key Key, target string) bool
- func Italic(text string) string
- func ListAvailableThemes() []string
- func Magenta(text string) string
- func Max(a, b int) int
- func Min(a, b int) int
- func PadString(s string, width int, padChar rune) string
- func Password(ctx context.Context, message string) (string, error)
- func Red(text string) string
- func RunTaskSequence(ctx context.Context, tasks []Task) error
- func ShowProgress(ctx context.Context, message string, max int, work func(func(int))) error
- func ShowSpinner(ctx context.Context, message string, work func()) error
- func ShowSpinnerInline(ctx context.Context, message string, work func()) error
- func TruncateString(s string, maxWidth int) string
- func White(text string) string
- func WrapText(text string, width int) []string
- func Yellow(text string) string
- type App
- type BoxUtils
- type BufferPool
- type Color
- type ColorUtils
- type Component
- type ConsoleReader
- type ConsoleTerminal
- type ConsoleWriter
- func (cw *ConsoleWriter) Clear() error
- func (cw *ConsoleWriter) ClearFromCursor() error
- func (cw *ConsoleWriter) ClearLine() error
- func (cw *ConsoleWriter) CursorDown(n int) error
- func (cw *ConsoleWriter) CursorUp(n int) error
- func (cw *ConsoleWriter) HideCursor() error
- func (cw *ConsoleWriter) MoveCursor(x, y int) error
- func (cw *ConsoleWriter) ShowCursor() error
- func (cw *ConsoleWriter) Write(p []byte) (n int, err error)
- func (cw *ConsoleWriter) WriteString(s string) (n int, err error)
- type Container
- func (c *Container) AddChild(child Component) *Container
- func (c *Container) HandleEvent(event Event) error
- func (c *Container) RemoveChild(child Component) *Container
- func (c *Container) Render(ctx context.Context) string
- func (c *Container) SetAlignment(alignment string) *Container
- func (c *Container) SetBorder(border bool) *Container
- func (c *Container) SetMargin(margin int) *Container
- func (c *Container) SetPadding(padding int) *Container
- func (c *Container) SetRounded(rounded bool) *Container
- func (c *Container) SetSize(width, height int) *Container
- func (c *Container) SetState(state State)
- func (c *Container) SetTheme(theme Theme)
- func (c *Container) SetTitle(title string) *Container
- func (c *Container) State() State
- type CustomTheme
- func (t *CustomTheme) Background() Style
- func (t *CustomTheme) Border() Style
- func (t *CustomTheme) Build() Theme
- func (t *CustomTheme) Error() Style
- func (t *CustomTheme) Focused() Style
- func (t *CustomTheme) Foreground() Style
- func (t *CustomTheme) Info() Style
- func (t *CustomTheme) Name() string
- func (t *CustomTheme) Primary() Style
- func (t *CustomTheme) Secondary() Style
- func (t *CustomTheme) SetBackground(style Style) *CustomTheme
- func (t *CustomTheme) SetBorder(style Style) *CustomTheme
- func (t *CustomTheme) SetError(style Style) *CustomTheme
- func (t *CustomTheme) SetFocused(style Style) *CustomTheme
- func (t *CustomTheme) SetForeground(style Style) *CustomTheme
- func (t *CustomTheme) SetInfo(style Style) *CustomTheme
- func (t *CustomTheme) SetPrimary(style Style) *CustomTheme
- func (t *CustomTheme) SetSecondary(style Style) *CustomTheme
- func (t *CustomTheme) SetSuccess(style Style) *CustomTheme
- func (t *CustomTheme) SetWarning(style Style) *CustomTheme
- func (t *CustomTheme) Success() Style
- func (t *CustomTheme) Warning() Style
- type DefaultTheme
- func (t *DefaultTheme) Background() Style
- func (t *DefaultTheme) Border() Style
- func (t *DefaultTheme) Error() Style
- func (t *DefaultTheme) Focused() Style
- func (t *DefaultTheme) Foreground() Style
- func (t *DefaultTheme) Info() Style
- func (t *DefaultTheme) Name() string
- func (t *DefaultTheme) Primary() Style
- func (t *DefaultTheme) Secondary() Style
- func (t *DefaultTheme) Success() Style
- func (t *DefaultTheme) Warning() Style
- type DiffCache
- type DraculaTheme
- func (t *DraculaTheme) Background() Style
- func (t *DraculaTheme) Border() Style
- func (t *DraculaTheme) Error() Style
- func (t *DraculaTheme) Focused() Style
- func (t *DraculaTheme) Foreground() Style
- func (t *DraculaTheme) Info() Style
- func (t *DraculaTheme) Name() string
- func (t *DraculaTheme) Primary() Style
- func (t *DraculaTheme) Secondary() Style
- func (t *DraculaTheme) Success() Style
- func (t *DraculaTheme) Warning() Style
- type Engine
- type Event
- type EventBus
- type EventEmitter
- func (ee *EventEmitter) EmitCustom(data any, source Component)
- func (ee *EventEmitter) EmitKey(key Key, source Component)
- func (ee *EventEmitter) EmitMouse(data any, source Component)
- func (ee *EventEmitter) EmitResize(width, height int, source Component)
- func (ee *EventEmitter) EmitTimer(data any, source Component)
- type EventHandler
- type EventType
- type GitHubTheme
- func (t *GitHubTheme) Background() Style
- func (t *GitHubTheme) Border() Style
- func (t *GitHubTheme) Error() Style
- func (t *GitHubTheme) Focused() Style
- func (t *GitHubTheme) Foreground() Style
- func (t *GitHubTheme) Info() Style
- func (t *GitHubTheme) Name() string
- func (t *GitHubTheme) Primary() Style
- func (t *GitHubTheme) Secondary() Style
- func (t *GitHubTheme) Success() Style
- func (t *GitHubTheme) Warning() Style
- type HStack
- func (h *HStack) AddChild(child Component) *HStack
- func (h *HStack) HandleEvent(event Event) error
- func (h *HStack) Render(ctx context.Context) string
- func (h *HStack) SetAlignment(alignment string) *HStack
- func (h *HStack) SetSpacing(spacing int) *HStack
- func (h *HStack) SetState(state State)
- func (h *HStack) SetTheme(theme Theme)
- func (h *HStack) State() State
- type InputUtils
- type Key
- type KeyEventManager
- type LoadingIndicator
- func (l *LoadingIndicator) HandleEvent(event Event) error
- func (l *LoadingIndicator) Render(ctx context.Context) string
- func (l *LoadingIndicator) SetMessage(message string) *LoadingIndicator
- func (l *LoadingIndicator) SetProgress(current, max int) *LoadingIndicator
- func (l *LoadingIndicator) SetShowProgress(show bool) *LoadingIndicator
- func (l *LoadingIndicator) SetState(state State)
- func (l *LoadingIndicator) SetTheme(theme Theme)
- func (l *LoadingIndicator) Start(message string) *LoadingIndicator
- func (l *LoadingIndicator) State() State
- func (l *LoadingIndicator) Stop(message string, success bool) *LoadingIndicator
- type MockReader
- type MockTerminal
- func (mt *MockTerminal) Close() error
- func (mt *MockTerminal) DisableRawMode() error
- func (mt *MockTerminal) EnableRawMode() error
- func (mt *MockTerminal) GetOutput() []string
- func (mt *MockTerminal) Reader() Reader
- func (mt *MockTerminal) SetKeySequence(keys []Key)
- func (mt *MockTerminal) Size() (width, height int, err error)
- func (mt *MockTerminal) Writer() Writer
- type MockWriter
- func (mw *MockWriter) Clear() error
- func (mw *MockWriter) GetAllOutput() string
- func (mw *MockWriter) GetLastOutput() string
- func (mw *MockWriter) GetOutput() []string
- func (mw *MockWriter) HideCursor() error
- func (mw *MockWriter) MoveCursor(x, y int) error
- func (mw *MockWriter) Reset()
- func (mw *MockWriter) ShowCursor() error
- func (mw *MockWriter) Write(p []byte) (n int, err error)
- func (mw *MockWriter) WriteString(s string) (n int, err error)
- type ModernTheme
- func (t *ModernTheme) Background() Style
- func (t *ModernTheme) Border() Style
- func (t *ModernTheme) Error() Style
- func (t *ModernTheme) Focused() Style
- func (t *ModernTheme) Foreground() Style
- func (t *ModernTheme) Info() Style
- func (t *ModernTheme) Name() string
- func (t *ModernTheme) Primary() Style
- func (t *ModernTheme) Secondary() Style
- func (t *ModernTheme) Success() Style
- func (t *ModernTheme) Warning() Style
- type MultiSelect
- type Option
- type PasswordInput
- type ProgressBar
- func (p *ProgressBar) Finish(message string) *ProgressBar
- func (p *ProgressBar) GetProgress() (current, max int, percentage float64)
- func (p *ProgressBar) HandleEvent(event Event) error
- func (p *ProgressBar) Increment(delta int) *ProgressBar
- func (p *ProgressBar) Render(ctx context.Context) string
- func (p *ProgressBar) SetCurrent(current int) *ProgressBar
- func (p *ProgressBar) SetMax(max int) *ProgressBar
- func (p *ProgressBar) SetMessage(message string) *ProgressBar
- func (p *ProgressBar) SetShowPercent(show bool) *ProgressBar
- func (p *ProgressBar) SetShowValue(show bool) *ProgressBar
- func (p *ProgressBar) SetState(state State)
- func (p *ProgressBar) SetStyle(style string) *ProgressBar
- func (p *ProgressBar) SetTheme(theme Theme)
- func (p *ProgressBar) SetWidth(width int) *ProgressBar
- func (p *ProgressBar) Start(message string) *ProgressBar
- func (p *ProgressBar) State() State
- type ProgressUtils
- type Reader
- type RealTimeStream
- func (rts *RealTimeStream) Append(chunk string) *RealTimeStream
- func (rts *RealTimeStream) Clear() *RealTimeStream
- func (rts *RealTimeStream) Complete()
- func (rts *RealTimeStream) GetContent() string
- func (rts *RealTimeStream) HandleEvent(event Event) error
- func (rts *RealTimeStream) OnChunk(callback func(chunk string)) *RealTimeStream
- func (rts *RealTimeStream) OnComplete(callback func(content string)) *RealTimeStream
- func (rts *RealTimeStream) OnStart(callback func()) *RealTimeStream
- func (rts *RealTimeStream) Render(ctx context.Context) string
- func (rts *RealTimeStream) SetMaxWidth(width int) *RealTimeStream
- func (rts *RealTimeStream) SetPrefix(prefix string) *RealTimeStream
- func (rts *RealTimeStream) SetPrefixStyle(style Style) *RealTimeStream
- func (rts *RealTimeStream) SetState(state State)
- func (rts *RealTimeStream) SetStyle(style Style) *RealTimeStream
- func (rts *RealTimeStream) SetTheme(theme Theme)
- func (rts *RealTimeStream) Start()
- func (rts *RealTimeStream) State() State
- type RenderEngine
- func (re *RenderEngine) AddComponent(component Component)
- func (re *RenderEngine) RemoveComponent(component Component) error
- func (re *RenderEngine) Render(component Component) error
- func (re *RenderEngine) SetTerminal(terminal Terminal)
- func (re *RenderEngine) Start(ctx context.Context) error
- func (re *RenderEngine) Stop() error
- type RenderFunc
- type Select
- func (s *Select[T]) AddOption(value T, label, hint string) *Select[T]
- func (s *Select[T]) Blur()
- func (s *Select[T]) Focus()
- func (s *Select[T]) GetSelectedValue() (T, bool)
- func (s *Select[T]) HandleEvent(event Event) error
- func (s *Select[T]) OnCancel(callback func()) *Select[T]
- func (s *Select[T]) OnChange(callback func(T)) *Select[T]
- func (s *Select[T]) OnSubmit(callback func(T)) *Select[T]
- func (s *Select[T]) Render(ctx context.Context) string
- func (s *Select[T]) SetMaxItems(maxItems int) *Select[T]
- func (s *Select[T]) SetMessage(message string) *Select[T]
- func (s *Select[T]) SetOptions(options []Option[T]) *Select[T]
- func (s *Select[T]) SetSearchable(searchable bool) *Select[T]
- func (s *Select[T]) SetState(state State)
- func (s *Select[T]) SetTheme(theme Theme)
- func (s *Select[T]) SetWidth(width int) *Select[T]
- func (s *Select[T]) State() State
- type Spinner
- func (s *Spinner) HandleEvent(event Event) error
- func (s *Spinner) IsRunning() bool
- func (s *Spinner) Render(ctx context.Context) string
- func (s *Spinner) SetInterval(interval time.Duration) *Spinner
- func (s *Spinner) SetMessage(message string) *Spinner
- func (s *Spinner) SetState(state State)
- func (s *Spinner) SetStyle(style string) *Spinner
- func (s *Spinner) SetTheme(theme Theme)
- func (s *Spinner) Start(message string) *Spinner
- func (s *Spinner) State() State
- func (s *Spinner) Stop(message string, success bool) *Spinner
- type Split
- func (s *Split) HandleEvent(event Event) error
- func (s *Split) Render(ctx context.Context) string
- func (s *Split) SetLeft(component Component) *Split
- func (s *Split) SetOrientation(orientation string) *Split
- func (s *Split) SetRatio(ratio float64) *Split
- func (s *Split) SetRight(component Component) *Split
- func (s *Split) SetSeparator(separator bool) *Split
- func (s *Split) SetSize(width, height int) *Split
- func (s *Split) SetState(state State)
- func (s *Split) SetTheme(theme Theme)
- func (s *Split) State() State
- type State
- type StateManager
- func (sm *StateManager) GetState(component Component) State
- func (sm *StateManager) ListStates() map[Component]State
- func (sm *StateManager) RemoveState(component Component)
- func (sm *StateManager) SetState(component Component, state State)
- func (sm *StateManager) UpdateState(component Component, updateFunc func(State) State)
- type StateType
- type StringUtils
- func (StringUtils) CountLines(s string) int
- func (StringUtils) IsEmpty(s string) bool
- func (StringUtils) JoinLines(lines []string) string
- func (StringUtils) PadCenter(s string, width int, padChar rune) string
- func (StringUtils) PadLeft(s string, width int, padChar rune) string
- func (StringUtils) PadRight(s string, width int, padChar rune) string
- func (StringUtils) RemoveAnsiCodes(s string) string
- func (StringUtils) Repeat(s string, count int) string
- func (StringUtils) SplitLines(s string) []string
- func (StringUtils) Truncate(s string, maxWidth int, suffix string) string
- type Style
- func (s Style) Apply(text string) string
- func (s Style) Background(color Color) Style
- func (s Style) Foreground(color Color) Style
- func (s Style) SetBlink(blink bool) Style
- func (s Style) SetBold(bold bool) Style
- func (s Style) SetDim(dim bool) Style
- func (s Style) SetItalic(italic bool) Style
- func (s Style) SetReverse(reverse bool) Style
- func (s Style) SetStrikethrough(strikethrough bool) Style
- func (s Style) SetUnderline(underline bool) Style
- func (s Style) String() string
- type Task
- type Terminal
- type TextArea
- type TextDisplay
- func (td *TextDisplay) GetText() string
- func (td *TextDisplay) HandleEvent(event Event) error
- func (td *TextDisplay) Render(ctx context.Context) string
- func (td *TextDisplay) SetAlign(align string) *TextDisplay
- func (td *TextDisplay) SetBorder(border, rounded bool) *TextDisplay
- func (td *TextDisplay) SetMarkdown(markdown bool) *TextDisplay
- func (td *TextDisplay) SetMaxWidth(maxWidth int) *TextDisplay
- func (td *TextDisplay) SetPadding(padding int) *TextDisplay
- func (td *TextDisplay) SetPrefix(prefix string) *TextDisplay
- func (td *TextDisplay) SetPrefixStyle(style Style) *TextDisplay
- func (td *TextDisplay) SetState(state State)
- func (td *TextDisplay) SetStyle(style Style) *TextDisplay
- func (td *TextDisplay) SetSuffix(suffix string) *TextDisplay
- func (td *TextDisplay) SetText(text string) *TextDisplay
- func (td *TextDisplay) SetTheme(theme Theme)
- func (td *TextDisplay) SetWidth(maxWidth, minWidth int) *TextDisplay
- func (td *TextDisplay) SetWordWrap(wordWrap bool) *TextDisplay
- func (td *TextDisplay) State() State
- type TextInput
- func (t *TextInput) Blur()
- func (t *TextInput) Focus()
- func (t *TextInput) GetValue() string
- func (t *TextInput) HandleEvent(event Event) error
- func (t *TextInput) OnCancel(callback func()) *TextInput
- func (t *TextInput) OnChange(callback func(string)) *TextInput
- func (t *TextInput) OnSubmit(callback func(string)) *TextInput
- func (t *TextInput) Render(ctx context.Context) string
- func (t *TextInput) SetMaxLength(maxLength int) *TextInput
- func (t *TextInput) SetMessage(message string) *TextInput
- func (t *TextInput) SetMultiline(multiline bool, height int) *TextInput
- func (t *TextInput) SetPlaceholder(placeholder string) *TextInput
- func (t *TextInput) SetState(state State)
- func (t *TextInput) SetTheme(theme Theme)
- func (t *TextInput) SetValidator(validator ValidatorFunc[string]) *TextInput
- func (t *TextInput) SetValue(value string) *TextInput
- func (t *TextInput) SetWidth(width int) *TextInput
- func (t *TextInput) State() State
- type TextUtils
- type Theme
- type VSCodeTheme
- func (t *VSCodeTheme) Background() Style
- func (t *VSCodeTheme) Border() Style
- func (t *VSCodeTheme) Error() Style
- func (t *VSCodeTheme) Focused() Style
- func (t *VSCodeTheme) Foreground() Style
- func (t *VSCodeTheme) Info() Style
- func (t *VSCodeTheme) Name() string
- func (t *VSCodeTheme) Primary() Style
- func (t *VSCodeTheme) Secondary() Style
- func (t *VSCodeTheme) Success() Style
- func (t *VSCodeTheme) Warning() Style
- type VStack
- func (v *VStack) AddChild(child Component) *VStack
- func (v *VStack) HandleEvent(event Event) error
- func (v *VStack) Render(ctx context.Context) string
- func (v *VStack) SetAlignment(alignment string) *VStack
- func (v *VStack) SetSpacing(spacing int) *VStack
- func (v *VStack) SetState(state State)
- func (v *VStack) SetTheme(theme Theme)
- func (v *VStack) SetWidth(width int) *VStack
- func (v *VStack) State() State
- type ValidatorFunc
- type Writer
Constants ¶
const ( // Direction arrows ArrowUp = "↑" ArrowDown = "↓" ArrowLeft = "←" ArrowRight = "→" // Status symbols CheckMark = "✓" CrossMark = "✗" Question = "?" Info = "ⓘ" Warning = "⚠" Error = "✗" // Progress symbols ProgressEmpty = "░" ProgressFull = "█" ProgressLight = "▒" ProgressMed = "▓" // Border symbols BoxVertical = "│" BoxHorizontal = "─" BoxTopLeft = "┌" BoxTopRight = "┐" BoxBottomLeft = "└" BoxBottomRight = "┘" BoxVerticalRight = "├" BoxVerticalLeft = "┤" BoxHorizontalDown = "┬" BoxHorizontalUp = "┴" BoxCross = "┼" // Rounded border BoxRoundTopLeft = "╭" BoxRoundTopRight = "╮" BoxRoundBottomLeft = "╰" BoxRoundBottomRight = "╯" // Selection symbols RadioSelected = "●" RadioUnselected = "○" CheckboxSelected = "☑" CheckboxUnselected = "☐" CheckboxIndeterminate = "☒" // Loading symbols SpinnerDot = "⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏" SpinnerLine = "|/-\\" SpinnerCircle = "◐◓◑◒" SpinnerSquare = "▖▘▝▗" )
Symbols defines various Unicode symbol constants
Variables ¶
var ( // Basic styles StyleDefault = NewStyle() StyleBold = NewStyle().SetBold(true) StyleDim = NewStyle().SetDim(true) StyleItalic = NewStyle().SetItalic(true) // Color styles StyleRed = NewStyle().Foreground(ColorRed) StyleGreen = NewStyle().Foreground(ColorGreen) StyleYellow = NewStyle().Foreground(ColorYellow) StyleBlue = NewStyle().Foreground(ColorBlue) StyleMagenta = NewStyle().Foreground(ColorMagenta) StyleCyan = NewStyle().Foreground(ColorCyan) StyleWhite = NewStyle().Foreground(ColorWhite) // Bright color styles StyleBrightRed = NewStyle().Foreground(ColorBrightRed) StyleBrightGreen = NewStyle().Foreground(ColorBrightGreen) StyleBrightYellow = NewStyle().Foreground(ColorBrightYellow) StyleBrightBlue = NewStyle().Foreground(ColorBrightBlue) StyleBrightMagenta = NewStyle().Foreground(ColorBrightMagenta) StyleBrightCyan = NewStyle().Foreground(ColorBrightCyan) StyleBrightWhite = NewStyle().Foreground(ColorBrightWhite) )
Predefined styles
var ( ThemeDefault = NewDefaultTheme() ThemeModern = NewModernTheme() ThemeGitHub = NewGitHubTheme() ThemeVSCode = NewVSCodeTheme() ThemeDracula = NewDraculaTheme() )
var ( String = StringUtils{} Box = BoxUtils{} ProgressU = ProgressUtils{} ColorU = ColorUtils{} InputU = InputUtils{} Text = TextUtils{} )
Global utility instances
Functions ¶
func CenterString ¶
CenterString centers a string within specified width
func ContextWithTimeout ¶
ContextWithTimeout creates context with timeout
func DisplayWidth ¶
DisplayWidth calculates the display width of a string (considering ANSI escape sequences and Unicode characters)
func IsEnterPressed ¶
IsEnterPressed checks if Enter key is pressed
func IsEscapePressed ¶
IsEscapePressed checks if ESC key is pressed
func IsKeyPressed ¶
IsKeyPressed checks if specific key is pressed
func ListAvailableThemes ¶
func ListAvailableThemes() []string
func ShowProgress ¶
ShowProgress displays a progress bar dialog with inline mode to avoid screen clearing issues
func ShowSpinner ¶
ShowSpinner displays a spinner dialog using inline mode
func ShowSpinnerInline ¶
ShowSpinnerInline displays an inline spinner without clearing the screen
func TruncateString ¶
TruncateString truncates string to specified display width
Types ¶
type App ¶
type App interface {
SetTheme(theme Theme) App
AddComponent(component Component) App
RemoveComponent(component Component) App
Run(ctx context.Context) (any, error)
SetTitle(title string) App
SetSize(width, height int) App
}
App defines the application interface
type BoxUtils ¶
type BoxUtils struct{}
BoxUtils provides border utility functions
func (BoxUtils) DrawHorizontalLine ¶
DrawHorizontalLine draws a horizontal line
type BufferPool ¶
type BufferPool struct {
// contains filtered or unexported fields
}
BufferPool provides a pool for reusing string buffers
func (*BufferPool) Put ¶
func (bp *BufferPool) Put(buffer []string)
Put returns a buffer to the pool
type ColorUtils ¶
type ColorUtils struct{}
ColorUtils provides color utility functions
func (ColorUtils) Gradient ¶
func (ColorUtils) Gradient(text string, startColor, endColor Color) string
Gradient creates gradient colored text (simple implementation)
func (ColorUtils) Rainbow ¶
func (ColorUtils) Rainbow(text string) string
Rainbow creates rainbow colored text
type Component ¶
type Component interface {
Render(ctx context.Context) string
HandleEvent(event Event) error
SetTheme(theme Theme)
State() State
SetState(state State)
}
Component defines the base interface for all UI components
type ConsoleReader ¶
type ConsoleReader struct {
// contains filtered or unexported fields
}
ConsoleReader console reader
func NewConsoleReader ¶
func NewConsoleReader() *ConsoleReader
NewConsoleReader creates a console reader
func (*ConsoleReader) Read ¶
func (cr *ConsoleReader) Read(p []byte) (n int, err error)
Read reads byte data
func (*ConsoleReader) ReadKey ¶
func (cr *ConsoleReader) ReadKey() (Key, error)
ReadKey reads key events
func (*ConsoleReader) SetNonBlocking ¶
func (cr *ConsoleReader) SetNonBlocking(nonBlocking bool) error
SetNonBlocking sets non-blocking mode
type ConsoleTerminal ¶
type ConsoleTerminal struct {
// contains filtered or unexported fields
}
ConsoleTerminal console terminal implementation
func (*ConsoleTerminal) DisableRawMode ¶
func (ct *ConsoleTerminal) DisableRawMode() error
DisableRawMode disables raw mode
func (*ConsoleTerminal) EnableRawMode ¶
func (ct *ConsoleTerminal) EnableRawMode() error
EnableRawMode enables raw mode
func (*ConsoleTerminal) Reader ¶
func (ct *ConsoleTerminal) Reader() Reader
Reader returns the input reader
func (*ConsoleTerminal) Size ¶
func (ct *ConsoleTerminal) Size() (width, height int, err error)
Size gets terminal size
func (*ConsoleTerminal) Writer ¶
func (ct *ConsoleTerminal) Writer() Writer
Writer returns the output writer
type ConsoleWriter ¶
type ConsoleWriter struct {
// contains filtered or unexported fields
}
ConsoleWriter console writer
func NewConsoleWriter ¶
func NewConsoleWriter() *ConsoleWriter
NewConsoleWriter creates a console writer
func (*ConsoleWriter) ClearFromCursor ¶
func (cw *ConsoleWriter) ClearFromCursor() error
ClearFromCursor clears from cursor position to end of line
func (*ConsoleWriter) ClearLine ¶
func (cw *ConsoleWriter) ClearLine() error
ClearLine clears current line
func (*ConsoleWriter) CursorDown ¶
func (cw *ConsoleWriter) CursorDown(n int) error
CursorDown moves cursor down
func (*ConsoleWriter) CursorUp ¶
func (cw *ConsoleWriter) CursorUp(n int) error
CursorUp moves cursor up
func (*ConsoleWriter) HideCursor ¶
func (cw *ConsoleWriter) HideCursor() error
HideCursor hides the cursor
func (*ConsoleWriter) MoveCursor ¶
func (cw *ConsoleWriter) MoveCursor(x, y int) error
MoveCursor moves cursor to specified position
func (*ConsoleWriter) ShowCursor ¶
func (cw *ConsoleWriter) ShowCursor() error
ShowCursor shows the cursor
func (*ConsoleWriter) Write ¶
func (cw *ConsoleWriter) Write(p []byte) (n int, err error)
Write writes byte data
func (*ConsoleWriter) WriteString ¶
func (cw *ConsoleWriter) WriteString(s string) (n int, err error)
WriteString writes string
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container container component
func (*Container) HandleEvent ¶
HandleEvent handles events
func (*Container) RemoveChild ¶
RemoveChild removes child component
func (*Container) SetAlignment ¶
SetAlignment sets alignment
func (*Container) SetPadding ¶
SetPadding sets padding
func (*Container) SetRounded ¶
SetRounded sets rounded corners
type CustomTheme ¶
type CustomTheme struct {
// contains filtered or unexported fields
}
CustomTheme represents a custom theme builder
func NewCustomTheme ¶
func NewCustomTheme(name string) *CustomTheme
func (*CustomTheme) Background ¶
func (t *CustomTheme) Background() Style
func (*CustomTheme) Border ¶
func (t *CustomTheme) Border() Style
func (*CustomTheme) Build ¶
func (t *CustomTheme) Build() Theme
func (*CustomTheme) Error ¶
func (t *CustomTheme) Error() Style
func (*CustomTheme) Focused ¶
func (t *CustomTheme) Focused() Style
func (*CustomTheme) Foreground ¶
func (t *CustomTheme) Foreground() Style
func (*CustomTheme) Info ¶
func (t *CustomTheme) Info() Style
func (*CustomTheme) Name ¶
func (t *CustomTheme) Name() string
func (*CustomTheme) Primary ¶
func (t *CustomTheme) Primary() Style
func (*CustomTheme) Secondary ¶
func (t *CustomTheme) Secondary() Style
func (*CustomTheme) SetBackground ¶
func (t *CustomTheme) SetBackground(style Style) *CustomTheme
func (*CustomTheme) SetBorder ¶
func (t *CustomTheme) SetBorder(style Style) *CustomTheme
func (*CustomTheme) SetError ¶
func (t *CustomTheme) SetError(style Style) *CustomTheme
func (*CustomTheme) SetFocused ¶
func (t *CustomTheme) SetFocused(style Style) *CustomTheme
func (*CustomTheme) SetForeground ¶
func (t *CustomTheme) SetForeground(style Style) *CustomTheme
func (*CustomTheme) SetInfo ¶
func (t *CustomTheme) SetInfo(style Style) *CustomTheme
func (*CustomTheme) SetPrimary ¶
func (t *CustomTheme) SetPrimary(style Style) *CustomTheme
func (*CustomTheme) SetSecondary ¶
func (t *CustomTheme) SetSecondary(style Style) *CustomTheme
func (*CustomTheme) SetSuccess ¶
func (t *CustomTheme) SetSuccess(style Style) *CustomTheme
func (*CustomTheme) SetWarning ¶
func (t *CustomTheme) SetWarning(style Style) *CustomTheme
func (*CustomTheme) Success ¶
func (t *CustomTheme) Success() Style
func (*CustomTheme) Warning ¶
func (t *CustomTheme) Warning() Style
type DefaultTheme ¶
type DefaultTheme struct {
// contains filtered or unexported fields
}
DefaultTheme represents the default theme
func (*DefaultTheme) Background ¶
func (t *DefaultTheme) Background() Style
func (*DefaultTheme) Border ¶
func (t *DefaultTheme) Border() Style
func (*DefaultTheme) Error ¶
func (t *DefaultTheme) Error() Style
func (*DefaultTheme) Focused ¶
func (t *DefaultTheme) Focused() Style
func (*DefaultTheme) Foreground ¶
func (t *DefaultTheme) Foreground() Style
func (*DefaultTheme) Info ¶
func (t *DefaultTheme) Info() Style
func (*DefaultTheme) Name ¶
func (t *DefaultTheme) Name() string
func (*DefaultTheme) Primary ¶
func (t *DefaultTheme) Primary() Style
func (*DefaultTheme) Secondary ¶
func (t *DefaultTheme) Secondary() Style
func (*DefaultTheme) Success ¶
func (t *DefaultTheme) Success() Style
func (*DefaultTheme) Warning ¶
func (t *DefaultTheme) Warning() Style
type DiffCache ¶
type DiffCache struct {
// contains filtered or unexported fields
}
DiffCache provides differential caching for rendering performance optimization
func NewDiffCache ¶
NewDiffCache creates a new differential cache
type DraculaTheme ¶
type DraculaTheme struct {
// contains filtered or unexported fields
}
DraculaTheme represents a Dracula theme
func (*DraculaTheme) Background ¶
func (t *DraculaTheme) Background() Style
func (*DraculaTheme) Border ¶
func (t *DraculaTheme) Border() Style
func (*DraculaTheme) Error ¶
func (t *DraculaTheme) Error() Style
func (*DraculaTheme) Focused ¶
func (t *DraculaTheme) Focused() Style
func (*DraculaTheme) Foreground ¶
func (t *DraculaTheme) Foreground() Style
func (*DraculaTheme) Info ¶
func (t *DraculaTheme) Info() Style
func (*DraculaTheme) Name ¶
func (t *DraculaTheme) Name() string
func (*DraculaTheme) Primary ¶
func (t *DraculaTheme) Primary() Style
func (*DraculaTheme) Secondary ¶
func (t *DraculaTheme) Secondary() Style
func (*DraculaTheme) Success ¶
func (t *DraculaTheme) Success() Style
func (*DraculaTheme) Warning ¶
func (t *DraculaTheme) Warning() Style
type Engine ¶
type Engine interface {
Start(ctx context.Context) error
Stop() error
Render(component Component) error
SetTerminal(terminal Terminal)
AddComponent(component Component)
RemoveComponent(component Component) error
}
Engine defines the rendering engine interface
type Event ¶
type Event struct {
Type EventType
Key Key // Key info when Type is EventTypeKey
Data any // Additional event data
Timestamp time.Time
Source Component
}
Event represents a system or user event
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
EventBus represents an event bus
func (*EventBus) PublishBlocking ¶
PublishBlocking publishes an event (blocking)
func (*EventBus) Subscribe ¶
func (eb *EventBus) Subscribe(eventType EventType, handler EventHandler)
Subscribe subscribes to events
func (*EventBus) Unsubscribe ¶
Unsubscribe unsubscribes from events (removes all handlers of this type)
type EventEmitter ¶
type EventEmitter struct {
// contains filtered or unexported fields
}
EventEmitter represents an event emitter
func NewEventEmitter ¶
func NewEventEmitter(bus *EventBus) *EventEmitter
NewEventEmitter creates an event emitter
func (*EventEmitter) EmitCustom ¶
func (ee *EventEmitter) EmitCustom(data any, source Component)
EmitCustom emits a custom event
func (*EventEmitter) EmitKey ¶
func (ee *EventEmitter) EmitKey(key Key, source Component)
EmitKey emits a key event
func (*EventEmitter) EmitMouse ¶
func (ee *EventEmitter) EmitMouse(data any, source Component)
EmitMouse emits a mouse event
func (*EventEmitter) EmitResize ¶
func (ee *EventEmitter) EmitResize(width, height int, source Component)
EmitResize emits a window resize event
func (*EventEmitter) EmitTimer ¶
func (ee *EventEmitter) EmitTimer(data any, source Component)
EmitTimer emits a timer event
type EventHandler ¶
type GitHubTheme ¶
type GitHubTheme struct {
// contains filtered or unexported fields
}
GitHubTheme represents a GitHub-style theme
func (*GitHubTheme) Background ¶
func (t *GitHubTheme) Background() Style
func (*GitHubTheme) Border ¶
func (t *GitHubTheme) Border() Style
func (*GitHubTheme) Error ¶
func (t *GitHubTheme) Error() Style
func (*GitHubTheme) Focused ¶
func (t *GitHubTheme) Focused() Style
func (*GitHubTheme) Foreground ¶
func (t *GitHubTheme) Foreground() Style
func (*GitHubTheme) Info ¶
func (t *GitHubTheme) Info() Style
func (*GitHubTheme) Name ¶
func (t *GitHubTheme) Name() string
func (*GitHubTheme) Primary ¶
func (t *GitHubTheme) Primary() Style
func (*GitHubTheme) Secondary ¶
func (t *GitHubTheme) Secondary() Style
func (*GitHubTheme) Success ¶
func (t *GitHubTheme) Success() Style
func (*GitHubTheme) Warning ¶
func (t *GitHubTheme) Warning() Style
type HStack ¶
type HStack struct {
// contains filtered or unexported fields
}
HStack horizontal stack layout
func (*HStack) HandleEvent ¶
HandleEvent handles events
func (*HStack) SetAlignment ¶
SetAlignment sets alignment
func (*HStack) SetSpacing ¶
SetSpacing sets spacing
type InputUtils ¶
type InputUtils struct{}
InputUtils provides input-related utility functions
func (InputUtils) IsAlphaNumeric ¶
func (InputUtils) IsAlphaNumeric(r rune) bool
IsAlphaNumeric checks if character is alphanumeric
func (InputUtils) IsControlChar ¶
func (InputUtils) IsControlChar(r rune) bool
IsControlChar checks if character is a control character
func (InputUtils) IsPrintable ¶
func (InputUtils) IsPrintable(r rune) bool
IsPrintable checks if character is printable
func (InputUtils) SanitizeInput ¶
func (InputUtils) SanitizeInput(s string) string
SanitizeInput cleans input text
func (InputUtils) ValidateEmail ¶
func (InputUtils) ValidateEmail(email string) bool
ValidateEmail performs simple email validation
type Key ¶
type Key struct {
Name string // Key name (e.g. "a", "enter", "escape")
Rune rune // Unicode character
Ctrl bool // Ctrl key pressed
Alt bool // Alt key pressed
Shift bool // Shift key pressed
Meta bool // Meta key pressed (macOS Command key)
}
Key represents a keyboard input
func ParseKeySequence ¶
ParseKeySequence parses key sequence string
type KeyEventManager ¶
type KeyEventManager struct {
// contains filtered or unexported fields
}
KeyEventManager manages key events
func NewKeyEventManager ¶
func NewKeyEventManager(emitter *EventEmitter) *KeyEventManager
NewKeyEventManager creates a key event manager
func (*KeyEventManager) BindKey ¶
func (km *KeyEventManager) BindKey(keyName string, handler EventHandler)
BindKey binds a key handler
func (*KeyEventManager) HandleKeyEvent ¶
func (km *KeyEventManager) HandleKeyEvent(event Event) error
HandleKeyEvent handles key events
func (*KeyEventManager) UnbindKey ¶
func (km *KeyEventManager) UnbindKey(keyName string)
UnbindKey unbinds a key handler
type LoadingIndicator ¶
type LoadingIndicator struct {
// contains filtered or unexported fields
}
LoadingIndicator represents a composite loading indicator
func NewLoadingIndicator ¶
func NewLoadingIndicator() *LoadingIndicator
func (*LoadingIndicator) HandleEvent ¶
func (l *LoadingIndicator) HandleEvent(event Event) error
func (*LoadingIndicator) SetMessage ¶
func (l *LoadingIndicator) SetMessage(message string) *LoadingIndicator
func (*LoadingIndicator) SetProgress ¶
func (l *LoadingIndicator) SetProgress(current, max int) *LoadingIndicator
func (*LoadingIndicator) SetShowProgress ¶
func (l *LoadingIndicator) SetShowProgress(show bool) *LoadingIndicator
func (*LoadingIndicator) SetState ¶
func (l *LoadingIndicator) SetState(state State)
func (*LoadingIndicator) SetTheme ¶
func (l *LoadingIndicator) SetTheme(theme Theme)
func (*LoadingIndicator) Start ¶
func (l *LoadingIndicator) Start(message string) *LoadingIndicator
func (*LoadingIndicator) State ¶
func (l *LoadingIndicator) State() State
func (*LoadingIndicator) Stop ¶
func (l *LoadingIndicator) Stop(message string, success bool) *LoadingIndicator
type MockReader ¶
type MockReader struct {
// contains filtered or unexported fields
}
MockReader mock reader
func (*MockReader) Read ¶
func (mr *MockReader) Read(p []byte) (n int, err error)
Read reads byte data
func (*MockReader) SetKeySequence ¶
func (mr *MockReader) SetKeySequence(keys []Key)
SetKeySequence sets key sequence
func (*MockReader) SetNonBlocking ¶
func (mr *MockReader) SetNonBlocking(nonBlocking bool) error
SetNonBlocking sets non-blocking mode
type MockTerminal ¶
type MockTerminal struct {
// contains filtered or unexported fields
}
MockTerminal mock terminal for testing
func (*MockTerminal) DisableRawMode ¶
func (mt *MockTerminal) DisableRawMode() error
DisableRawMode disables raw mode
func (*MockTerminal) EnableRawMode ¶
func (mt *MockTerminal) EnableRawMode() error
EnableRawMode enables raw mode
func (*MockTerminal) GetOutput ¶
func (mt *MockTerminal) GetOutput() []string
GetOutput gets output content
func (*MockTerminal) SetKeySequence ¶
func (mt *MockTerminal) SetKeySequence(keys []Key)
SetKeySequence sets key sequence
func (*MockTerminal) Size ¶
func (mt *MockTerminal) Size() (width, height int, err error)
Size returns terminal size
type MockWriter ¶
type MockWriter struct {
// contains filtered or unexported fields
}
MockWriter mock writer
func (*MockWriter) GetAllOutput ¶
func (mw *MockWriter) GetAllOutput() string
GetAllOutput gets all output combined as single string
func (*MockWriter) GetLastOutput ¶
func (mw *MockWriter) GetLastOutput() string
GetLastOutput gets last output
func (*MockWriter) MoveCursor ¶
func (mw *MockWriter) MoveCursor(x, y int) error
MoveCursor moves cursor
func (*MockWriter) Write ¶
func (mw *MockWriter) Write(p []byte) (n int, err error)
Write writes byte data
func (*MockWriter) WriteString ¶
func (mw *MockWriter) WriteString(s string) (n int, err error)
WriteString writes string
type ModernTheme ¶
type ModernTheme struct {
// contains filtered or unexported fields
}
ModernTheme represents a modern theme
func (*ModernTheme) Background ¶
func (t *ModernTheme) Background() Style
func (*ModernTheme) Border ¶
func (t *ModernTheme) Border() Style
func (*ModernTheme) Error ¶
func (t *ModernTheme) Error() Style
func (*ModernTheme) Focused ¶
func (t *ModernTheme) Focused() Style
func (*ModernTheme) Foreground ¶
func (t *ModernTheme) Foreground() Style
func (*ModernTheme) Info ¶
func (t *ModernTheme) Info() Style
func (*ModernTheme) Name ¶
func (t *ModernTheme) Name() string
func (*ModernTheme) Primary ¶
func (t *ModernTheme) Primary() Style
func (*ModernTheme) Secondary ¶
func (t *ModernTheme) Secondary() Style
func (*ModernTheme) Success ¶
func (t *ModernTheme) Success() Style
func (*ModernTheme) Warning ¶
func (t *ModernTheme) Warning() Style
type MultiSelect ¶
MultiSelect represents a multi-selection component
func NewMultiSelect ¶
func NewMultiSelect[T any]() *MultiSelect[T]
NewMultiSelect creates a new multi-select component
func (*MultiSelect[T]) GetSelectedValues ¶
func (m *MultiSelect[T]) GetSelectedValues() []T
GetSelectedValues returns all selected values
func (*MultiSelect[T]) HandleEvent ¶
func (m *MultiSelect[T]) HandleEvent(event Event) error
HandleEvent handles events for multi-select
func (*MultiSelect[T]) OnSelectionChange ¶
func (m *MultiSelect[T]) OnSelectionChange(callback func([]T)) *MultiSelect[T]
OnSelectionChange sets the selection change callback
type Option ¶
type Option[T any] struct { Value T // Option value Label string // Display label Hint string // Hint text Disabled bool // Whether disabled }
Option represents a selectable item
type PasswordInput ¶
type PasswordInput struct {
*TextInput
// contains filtered or unexported fields
}
PasswordInput represents a password input component
func NewPasswordInput ¶
func NewPasswordInput() *PasswordInput
NewPasswordInput creates a password input component
func (*PasswordInput) SetShowPassword ¶
func (p *PasswordInput) SetShowPassword(show bool) *PasswordInput
SetShowPassword sets whether to show password
func (*PasswordInput) TogglePasswordVisibility ¶
func (p *PasswordInput) TogglePasswordVisibility()
TogglePasswordVisibility toggles password visibility
type ProgressBar ¶
type ProgressBar struct {
// contains filtered or unexported fields
}
ProgressBar represents a progress bar component
func NewProgressBar ¶
func NewProgressBar() *ProgressBar
func (*ProgressBar) Finish ¶
func (p *ProgressBar) Finish(message string) *ProgressBar
func (*ProgressBar) GetProgress ¶
func (p *ProgressBar) GetProgress() (current, max int, percentage float64)
func (*ProgressBar) HandleEvent ¶
func (p *ProgressBar) HandleEvent(event Event) error
func (*ProgressBar) Increment ¶
func (p *ProgressBar) Increment(delta int) *ProgressBar
func (*ProgressBar) SetCurrent ¶
func (p *ProgressBar) SetCurrent(current int) *ProgressBar
func (*ProgressBar) SetMax ¶
func (p *ProgressBar) SetMax(max int) *ProgressBar
func (*ProgressBar) SetMessage ¶
func (p *ProgressBar) SetMessage(message string) *ProgressBar
func (*ProgressBar) SetShowPercent ¶
func (p *ProgressBar) SetShowPercent(show bool) *ProgressBar
func (*ProgressBar) SetShowValue ¶
func (p *ProgressBar) SetShowValue(show bool) *ProgressBar
func (*ProgressBar) SetState ¶
func (p *ProgressBar) SetState(state State)
func (*ProgressBar) SetStyle ¶
func (p *ProgressBar) SetStyle(style string) *ProgressBar
func (*ProgressBar) SetTheme ¶
func (p *ProgressBar) SetTheme(theme Theme)
func (*ProgressBar) SetWidth ¶
func (p *ProgressBar) SetWidth(width int) *ProgressBar
func (*ProgressBar) Start ¶
func (p *ProgressBar) Start(message string) *ProgressBar
func (*ProgressBar) State ¶
func (p *ProgressBar) State() State
type ProgressUtils ¶
type ProgressUtils struct{}
ProgressUtils provides progress-related utility functions
func (ProgressUtils) DrawProgressBar ¶
func (ProgressUtils) DrawProgressBar(current, max, width int, style string) string
DrawProgressBar draws a progress bar
func (ProgressUtils) GetSpinnerFrame ¶
func (ProgressUtils) GetSpinnerFrame(frameIndex int, style string) string
GetSpinnerFrame gets a loading animation frame
type Reader ¶
type Reader interface {
Read(p []byte) (n int, err error)
ReadKey() (Key, error)
SetNonBlocking(nonBlocking bool) error
}
Reader defines input reading interface
type RealTimeStream ¶
type RealTimeStream struct {
// contains filtered or unexported fields
}
RealTimeStream real-time streaming component - suitable for real AI application scenarios
func NewAIRealTimeStream ¶
func NewAIRealTimeStream() *RealTimeStream
NewAIRealTimeStream creates AI-specific real-time streaming component
func NewRealTimeStream ¶
func NewRealTimeStream() *RealTimeStream
NewRealTimeStream creates real-time streaming component
func NewSystemRealTimeStream ¶
func NewSystemRealTimeStream() *RealTimeStream
NewSystemRealTimeStream creates system-specific real-time streaming component
func NewUserRealTimeStream ¶
func NewUserRealTimeStream() *RealTimeStream
NewUserRealTimeStream creates user-specific real-time streaming component (though users typically don't need streaming)
func (*RealTimeStream) Append ¶
func (rts *RealTimeStream) Append(chunk string) *RealTimeStream
Append appends and immediately displays new text chunk
func (*RealTimeStream) Clear ¶
func (rts *RealTimeStream) Clear() *RealTimeStream
Clear clears content
func (*RealTimeStream) Complete ¶
func (rts *RealTimeStream) Complete()
Complete marks streaming display as finished
func (*RealTimeStream) GetContent ¶
func (rts *RealTimeStream) GetContent() string
GetContent gets current accumulated complete content
func (*RealTimeStream) HandleEvent ¶
func (rts *RealTimeStream) HandleEvent(event Event) error
HandleEvent handles events
func (*RealTimeStream) OnChunk ¶
func (rts *RealTimeStream) OnChunk(callback func(chunk string)) *RealTimeStream
OnChunk sets chunk callback
func (*RealTimeStream) OnComplete ¶
func (rts *RealTimeStream) OnComplete(callback func(content string)) *RealTimeStream
OnComplete sets completion callback
func (*RealTimeStream) OnStart ¶
func (rts *RealTimeStream) OnStart(callback func()) *RealTimeStream
OnStart sets start callback
func (*RealTimeStream) Render ¶
func (rts *RealTimeStream) Render(ctx context.Context) string
Render renders component (returns complete content)
func (*RealTimeStream) SetMaxWidth ¶
func (rts *RealTimeStream) SetMaxWidth(width int) *RealTimeStream
SetMaxWidth sets maximum width
func (*RealTimeStream) SetPrefix ¶
func (rts *RealTimeStream) SetPrefix(prefix string) *RealTimeStream
SetPrefix sets prefix
func (*RealTimeStream) SetPrefixStyle ¶
func (rts *RealTimeStream) SetPrefixStyle(style Style) *RealTimeStream
SetPrefixStyle sets prefix style
func (*RealTimeStream) SetState ¶
func (rts *RealTimeStream) SetState(state State)
SetState sets state
func (*RealTimeStream) SetStyle ¶
func (rts *RealTimeStream) SetStyle(style Style) *RealTimeStream
SetStyle sets text style
func (*RealTimeStream) SetTheme ¶
func (rts *RealTimeStream) SetTheme(theme Theme)
SetTheme sets theme
func (*RealTimeStream) Start ¶
func (rts *RealTimeStream) Start()
Start begins streaming display (shows prefix)
type RenderEngine ¶
type RenderEngine struct {
// contains filtered or unexported fields
}
RenderEngine implements the rendering engine
func NewRenderEngine ¶
func NewRenderEngine() *RenderEngine
func (*RenderEngine) AddComponent ¶
func (re *RenderEngine) AddComponent(component Component)
AddComponent adds a component to the render engine
func (*RenderEngine) RemoveComponent ¶
func (re *RenderEngine) RemoveComponent(component Component) error
RemoveComponent removes a component from the render engine
func (*RenderEngine) Render ¶
func (re *RenderEngine) Render(component Component) error
func (*RenderEngine) SetTerminal ¶
func (re *RenderEngine) SetTerminal(terminal Terminal)
SetTerminal sets the terminal for rendering
func (*RenderEngine) Stop ¶
func (re *RenderEngine) Stop() error
type RenderFunc ¶
type Select ¶
type Select[T any] struct { // contains filtered or unexported fields }
Select represents a single selection component
func (*Select[T]) GetSelectedValue ¶
GetSelectedValue returns the selected value
func (*Select[T]) HandleEvent ¶
HandleEvent handles events
func (*Select[T]) SetMaxItems ¶
SetMaxItems sets the maximum number of items to display
func (*Select[T]) SetMessage ¶
SetMessage sets the message text
func (*Select[T]) SetOptions ¶
SetOptions sets all options for the select
func (*Select[T]) SetSearchable ¶
SetSearchable sets whether the select is searchable
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner represents a loading spinner component
func NewSpinner ¶
func NewSpinner() *Spinner
func (*Spinner) HandleEvent ¶
func (*Spinner) SetMessage ¶
type Split ¶
type Split struct {
// contains filtered or unexported fields
}
Split split layout component
func (*Split) HandleEvent ¶
HandleEvent handles events
func (*Split) SetOrientation ¶
SetOrientation sets orientation
func (*Split) SetSeparator ¶
SetSeparator sets whether to show separator
type State ¶
type State struct {
Type StateType
Value any
Error error
Cursor int // Cursor position
Selected []int // Selected item indices for multi-select components
Focused bool // Whether component has focus
Visible bool // Whether component is visible
Dirty bool // Whether component needs re-rendering
}
State represents component state
type StateManager ¶
type StateManager struct {
// contains filtered or unexported fields
}
StateManager manages component state
func (*StateManager) GetState ¶
func (sm *StateManager) GetState(component Component) State
GetState gets component state
func (*StateManager) ListStates ¶
func (sm *StateManager) ListStates() map[Component]State
ListStates lists all states
func (*StateManager) RemoveState ¶
func (sm *StateManager) RemoveState(component Component)
RemoveState removes component state
func (*StateManager) SetState ¶
func (sm *StateManager) SetState(component Component, state State)
SetState sets component state
func (*StateManager) UpdateState ¶
func (sm *StateManager) UpdateState(component Component, updateFunc func(State) State)
UpdateState updates component state
type StringUtils ¶
type StringUtils struct{}
StringUtils provides string utility functions
func (StringUtils) CountLines ¶
func (StringUtils) CountLines(s string) int
CountLines counts the number of lines in string
func (StringUtils) IsEmpty ¶
func (StringUtils) IsEmpty(s string) bool
IsEmpty checks if string is empty (including whitespace-only)
func (StringUtils) JoinLines ¶
func (StringUtils) JoinLines(lines []string) string
JoinLines joins multi-line text
func (StringUtils) PadCenter ¶
func (StringUtils) PadCenter(s string, width int, padChar rune) string
PadCenter centers string with padding
func (StringUtils) PadLeft ¶
func (StringUtils) PadLeft(s string, width int, padChar rune) string
PadLeft pads string on the left
func (StringUtils) PadRight ¶
func (StringUtils) PadRight(s string, width int, padChar rune) string
PadRight pads string on the right
func (StringUtils) RemoveAnsiCodes ¶
func (StringUtils) RemoveAnsiCodes(s string) string
RemoveAnsiCodes removes ANSI escape sequences
func (StringUtils) Repeat ¶
func (StringUtils) Repeat(s string, count int) string
Repeat repeats a string
func (StringUtils) SplitLines ¶
func (StringUtils) SplitLines(s string) []string
SplitLines splits multi-line text
type Style ¶
type Style struct {
FgColor Color // Foreground color
BgColor Color // Background color
Bold bool // Bold text
Italic bool // Italic text
Underline bool // Underlined text
Strikethrough bool // Strikethrough text
Dim bool // Dimmed text
Blink bool // Blinking text
Reverse bool // Reverse foreground and background colors
}
Style defines text styling options
func (Style) Background ¶
Background sets background color
func (Style) Foreground ¶
Foreground sets foreground color
func (Style) SetReverse ¶
SetReverse sets reverse video
func (Style) SetStrikethrough ¶
SetStrikethrough sets strikethrough text
func (Style) SetUnderline ¶
SetUnderline sets underlined text
type Terminal ¶
type Terminal interface {
Reader() Reader
Writer() Writer
Size() (width, height int, err error)
EnableRawMode() error
DisableRawMode() error
Close() error
}
Terminal abstracts terminal I/O operations
type TextArea ¶
type TextArea struct {
*TextInput
// contains filtered or unexported fields
}
TextArea represents a multi-line text input component
func NewTextArea ¶
func NewTextArea() *TextArea
NewTextArea creates a multi-line text input component
func (*TextArea) SetLineNumbers ¶
SetLineNumbers sets whether to show line numbers
type TextDisplay ¶
type TextDisplay struct {
// contains filtered or unexported fields
}
TextDisplay general text display component
func NewAIMessage ¶
func NewAIMessage(text string) *TextDisplay
NewAIMessage creates AI message style TextDisplay
func NewCodeBlock ¶
func NewCodeBlock(code string) *TextDisplay
NewCodeBlock creates code block style TextDisplay
func NewSystemMessage ¶
func NewSystemMessage(text string) *TextDisplay
NewSystemMessage creates system message style TextDisplay
func NewTextDisplay ¶
func NewTextDisplay() *TextDisplay
NewTextDisplay creates a new text display component
func NewUserMessage ¶
func NewUserMessage(text string) *TextDisplay
NewUserMessage creates user message style TextDisplay
func (*TextDisplay) HandleEvent ¶
func (td *TextDisplay) HandleEvent(event Event) error
HandleEvent handles events (text display components typically don't handle events)
func (*TextDisplay) Render ¶
func (td *TextDisplay) Render(ctx context.Context) string
Render renders component
func (*TextDisplay) SetAlign ¶
func (td *TextDisplay) SetAlign(align string) *TextDisplay
SetAlign sets alignment
func (*TextDisplay) SetBorder ¶
func (td *TextDisplay) SetBorder(border, rounded bool) *TextDisplay
SetBorder sets border
func (*TextDisplay) SetMarkdown ¶
func (td *TextDisplay) SetMarkdown(markdown bool) *TextDisplay
SetMarkdown sets Markdown rendering
func (*TextDisplay) SetMaxWidth ¶
func (td *TextDisplay) SetMaxWidth(maxWidth int) *TextDisplay
SetMaxWidth sets maximum width (simplified version for method chaining)
func (*TextDisplay) SetPadding ¶
func (td *TextDisplay) SetPadding(padding int) *TextDisplay
SetPadding sets padding
func (*TextDisplay) SetPrefix ¶
func (td *TextDisplay) SetPrefix(prefix string) *TextDisplay
SetPrefix sets prefix
func (*TextDisplay) SetPrefixStyle ¶
func (td *TextDisplay) SetPrefixStyle(style Style) *TextDisplay
SetPrefixStyle sets prefix style
func (*TextDisplay) SetStyle ¶
func (td *TextDisplay) SetStyle(style Style) *TextDisplay
SetStyle sets text style
func (*TextDisplay) SetSuffix ¶
func (td *TextDisplay) SetSuffix(suffix string) *TextDisplay
SetSuffix sets suffix
func (*TextDisplay) SetText ¶
func (td *TextDisplay) SetText(text string) *TextDisplay
SetText sets display text
func (*TextDisplay) SetWidth ¶
func (td *TextDisplay) SetWidth(maxWidth, minWidth int) *TextDisplay
SetWidth sets width
func (*TextDisplay) SetWordWrap ¶
func (td *TextDisplay) SetWordWrap(wordWrap bool) *TextDisplay
SetWordWrap sets automatic word wrapping
type TextInput ¶
type TextInput struct {
// contains filtered or unexported fields
}
TextInput represents a text input component
func (*TextInput) HandleEvent ¶
HandleEvent handles events
func (*TextInput) SetMaxLength ¶
SetMaxLength sets the maximum input length
func (*TextInput) SetMessage ¶
SetMessage sets the prompt message
func (*TextInput) SetMultiline ¶
SetMultiline sets multiline mode
func (*TextInput) SetPlaceholder ¶
SetPlaceholder sets the placeholder text
func (*TextInput) SetValidator ¶
func (t *TextInput) SetValidator(validator ValidatorFunc[string]) *TextInput
SetValidator sets the input validator
type TextUtils ¶
type TextUtils struct{}
TextUtils provides text processing utility functions
func (TextUtils) IndentText ¶
IndentText indents text
type Theme ¶
type Theme interface {
Name() string
Primary() Style
Secondary() Style
Success() Style
Error() Style
Warning() Style
Info() Style
Background() Style
Foreground() Style
Border() Style
Focused() Style
}
Theme defines the theming interface
func GetThemeByName ¶
type VSCodeTheme ¶
type VSCodeTheme struct {
// contains filtered or unexported fields
}
VSCodeTheme represents a VSCode dark theme
func (*VSCodeTheme) Background ¶
func (t *VSCodeTheme) Background() Style
func (*VSCodeTheme) Border ¶
func (t *VSCodeTheme) Border() Style
func (*VSCodeTheme) Error ¶
func (t *VSCodeTheme) Error() Style
func (*VSCodeTheme) Focused ¶
func (t *VSCodeTheme) Focused() Style
func (*VSCodeTheme) Foreground ¶
func (t *VSCodeTheme) Foreground() Style
func (*VSCodeTheme) Info ¶
func (t *VSCodeTheme) Info() Style
func (*VSCodeTheme) Name ¶
func (t *VSCodeTheme) Name() string
func (*VSCodeTheme) Primary ¶
func (t *VSCodeTheme) Primary() Style
func (*VSCodeTheme) Secondary ¶
func (t *VSCodeTheme) Secondary() Style
func (*VSCodeTheme) Success ¶
func (t *VSCodeTheme) Success() Style
func (*VSCodeTheme) Warning ¶
func (t *VSCodeTheme) Warning() Style
type VStack ¶
type VStack struct {
// contains filtered or unexported fields
}
VStack vertical stack layout
func (*VStack) HandleEvent ¶
HandleEvent handles events
func (*VStack) SetAlignment ¶
SetAlignment sets alignment
func (*VStack) SetSpacing ¶
SetSpacing sets spacing