Documentation
¶
Index ¶
- func ClearLineSeq() string
- func ClearToEndOfLineSeq() string
- func DebugEnabled() bool
- func DebugPrintf(format string, args ...interface{})
- func MoveCursorSeq(x, y int) string
- func RegisterCleanup(fn func() error)
- func RegisterComponent(componentType string, factory ComponentFactory) error
- func ResetScrollRegionSeq() string
- func RunCleanup()
- func SetScrollRegionSeq(top, bottom int) string
- type AutoLayoutManager
- func (alm *AutoLayoutManager) AddResizeCallback(callback func(width, height int))
- func (alm *AutoLayoutManager) GetContentRegion() (Region, error)
- func (alm *AutoLayoutManager) GetScrollRegion() (top, bottom int)
- func (alm *AutoLayoutManager) GetTerminalSize() (int, int)
- func (alm *AutoLayoutManager) Initialize() error
- func (alm *AutoLayoutManager) InitializeForTest(width, height int)
- func (alm *AutoLayoutManager) OnTerminalResize(width, height int)
- func (alm *AutoLayoutManager) PrintDebugLayout()
- func (alm *AutoLayoutManager) RegisterComponent(name string, info *ComponentInfo)
- func (alm *AutoLayoutManager) SetComponentHeight(name string, height int)
- func (alm *AutoLayoutManager) SetComponentVisible(name string, visible bool)
- func (alm *AutoLayoutManager) TestLayout(width, height int)
- func (alm *AutoLayoutManager) UpdateComponentInfo(name string, updater func(*ComponentInfo))
- type BaseComponent
- func (bc *BaseComponent) CanHandleInput() bool
- func (bc *BaseComponent) Cleanup() error
- func (bc *BaseComponent) Controller() *TerminalController
- func (bc *BaseComponent) Events() EventBus
- func (bc *BaseComponent) GetRegion() string
- func (bc *BaseComponent) HandleInput(input []byte) (bool, error)
- func (bc *BaseComponent) ID() string
- func (bc *BaseComponent) Init(ctx context.Context, deps Dependencies) error
- func (bc *BaseComponent) Layout() LayoutManager
- func (bc *BaseComponent) NeedsRedraw() bool
- func (bc *BaseComponent) PublishEvent(eventType string, data interface{})
- func (bc *BaseComponent) Render() error
- func (bc *BaseComponent) SetNeedsRedraw(needs bool)
- func (bc *BaseComponent) SetRegion(region string)
- func (bc *BaseComponent) Start() error
- func (bc *BaseComponent) State() StateManager
- func (bc *BaseComponent) Stop() error
- func (bc *BaseComponent) Terminal() TerminalManager
- func (bc *BaseComponent) Type() string
- type BufferStats
- type CIOutputHandler
- func (h *CIOutputHandler) IsCI() bool
- func (h *CIOutputHandler) IsInteractive() bool
- func (h *CIOutputHandler) PrintProgress()
- func (h *CIOutputHandler) PrintSummary()
- func (h *CIOutputHandler) Printf(format string, args ...interface{})
- func (h *CIOutputHandler) ShouldShowProgress() bool
- func (h *CIOutputHandler) UpdateMetrics(totalTokens, contextTokens, maxContextTokens, iteration int, totalCost float64)
- func (h *CIOutputHandler) Write(p []byte) (n int, err error)
- func (h *CIOutputHandler) WriteString(s string) error
- type CLIOutputHandler
- func (h *CLIOutputHandler) Close() error
- func (h *CLIOutputHandler) Flush() error
- func (h *CLIOutputHandler) Mode() OutputMode
- func (h *CLIOutputHandler) Print(format string, args ...interface{})
- func (h *CLIOutputHandler) Printf(format string, args ...interface{})
- func (h *CLIOutputHandler) Println(args ...interface{})
- func (h *CLIOutputHandler) Write(p []byte) (int, error)
- type Component
- type ComponentConfig
- type ComponentFactory
- type ComponentInfo
- type ComponentRegistry
- type Config
- type ConsoleApp
- type ConsoleBuffer
- func (cb *ConsoleBuffer) AddContent(content string)
- func (cb *ConsoleBuffer) AddLine(line string)
- func (cb *ConsoleBuffer) Clear()
- func (cb *ConsoleBuffer) Debug() string
- func (cb *ConsoleBuffer) GetStats() BufferStats
- func (cb *ConsoleBuffer) GetVisibleLines(viewportHeight int) []string
- func (cb *ConsoleBuffer) RedrawBuffer(terminal TerminalManager, viewportHeight int) error
- func (cb *ConsoleBuffer) ScrollDown(lines int)
- func (cb *ConsoleBuffer) ScrollToBottom()
- func (cb *ConsoleBuffer) ScrollUp(lines int)
- func (cb *ConsoleBuffer) SetTerminalWidth(width int)
- type ContentUpdate
- type Dependencies
- type DualOutputHandler
- func (doh *DualOutputHandler) Buffer() *ConsoleBuffer
- func (doh *DualOutputHandler) Mode() OutputMode
- func (doh *DualOutputHandler) Print(format string, args ...interface{})
- func (doh *DualOutputHandler) Printf(format string, args ...interface{})
- func (doh *DualOutputHandler) Println(args ...interface{})
- func (doh *DualOutputHandler) Redraw()
- func (doh *DualOutputHandler) SetAutoRedraw(auto bool)
- func (doh *DualOutputHandler) SetMode(mode OutputMode)
- func (doh *DualOutputHandler) Write(p []byte) (n int, err error)
- type Event
- type EventBus
- type EventFilter
- type EventHandler
- type FooterUpdate
- type InputEvent
- type InputEventType
- type InputHandler
- type InputRouter
- func (ir *InputRouter) PublishEvent(event InputEvent) bool
- func (ir *InputRouter) RegisterHandler(handler InputHandler)
- func (ir *InputRouter) RestoreDefaultHandler()
- func (ir *InputRouter) SendInterrupt() bool
- func (ir *InputRouter) SendKeystroke(data []byte) bool
- func (ir *InputRouter) SetActiveHandler(handlerID string) bool
- func (ir *InputRouter) SetDefaultHandler(handler InputHandler)
- func (ir *InputRouter) Start()
- func (ir *InputRouter) UnregisterHandler(handlerID string)
- type InteractiveOutputHandler
- func (h *InteractiveOutputHandler) Close() error
- func (h *InteractiveOutputHandler) Flush() error
- func (h *InteractiveOutputHandler) Mode() OutputMode
- func (h *InteractiveOutputHandler) Print(format string, args ...interface{})
- func (h *InteractiveOutputHandler) Printf(format string, args ...interface{})
- func (h *InteractiveOutputHandler) Println(args ...interface{})
- func (h *InteractiveOutputHandler) Write(p []byte) (int, error)
- type KeystrokeData
- type LayoutManager
- type LogInputHandler
- func (lih *LogInputHandler) Activate()
- func (lih *LogInputHandler) CreateReader() *bufio.Reader
- func (lih *LogInputHandler) Deactivate()
- func (lih *LogInputHandler) GetHandlerID() string
- func (lih *LogInputHandler) HandleInput(event InputEvent) bool
- func (lih *LogInputHandler) ReadString(delim byte) (string, error)
- type OutputHandler
- type OutputMode
- type Region
- type RenderMessage
- type RenderOp
- type ResizableComponent
- type StateCallback
- type StateManager
- type TerminalCleanupHandler
- type TerminalController
- func (tc *TerminalController) AcquireRawMode(reason string) (func(), error)
- func (tc *TerminalController) Cleanup() error
- func (tc *TerminalController) ClearLine() error
- func (tc *TerminalController) ClearScreen() error
- func (tc *TerminalController) ClearScrollback() error
- func (tc *TerminalController) ClearToEndOfLine() error
- func (tc *TerminalController) ClearToEndOfScreen() error
- func (tc *TerminalController) DisableMouseTracking() error
- func (tc *TerminalController) EnableMouseTracking() error
- func (tc *TerminalController) EnterAltScreen() error
- func (tc *TerminalController) ExitAltScreen() error
- func (tc *TerminalController) Flush() error
- func (tc *TerminalController) GetSize() (width, height int, err error)
- func (tc *TerminalController) HideCursor() error
- func (tc *TerminalController) Init() error
- func (tc *TerminalController) IsAltScreen() bool
- func (tc *TerminalController) IsRawMode() bool
- func (tc *TerminalController) MoveCursor(x, y int) error
- func (tc *TerminalController) OnResize(callback func(width, height int))
- func (tc *TerminalController) QueueRender(op RenderOp)
- func (tc *TerminalController) RegisterComponent(name string, component Component, order int)
- func (tc *TerminalController) ReleaseRawMode(reason string)
- func (tc *TerminalController) ResetScrollRegion() error
- func (tc *TerminalController) RestoreCursor() error
- func (tc *TerminalController) SaveCursor() error
- func (tc *TerminalController) ScrollDown(lines int) error
- func (tc *TerminalController) ScrollUp(lines int) error
- func (tc *TerminalController) SetInterruptHandler(handler func())
- func (tc *TerminalController) SetRawMode(enabled bool) error
- func (tc *TerminalController) SetScrollRegion(top, bottom int) error
- func (tc *TerminalController) ShowCursor() error
- func (tc *TerminalController) WithPrimaryScreen(fn func() error) error
- func (tc *TerminalController) WithRawMode(reason string, fn func() error) error
- func (tc *TerminalController) Write(p []byte) (n int, err error)
- func (tc *TerminalController) WriteAt(x, y int, data []byte) error
- func (tc *TerminalController) WriteString(s string) error
- func (tc *TerminalController) WriteText(text string) (int, error)
- type TerminalManager
- type UIHandler
- type UIRenderer
- func (ur *UIRenderer) AppendContent(text string) error
- func (ur *UIRenderer) EnableBatching(enabled bool)
- func (ur *UIRenderer) RegisterComponent(name string, component Component)
- func (ur *UIRenderer) SendMessage(msg RenderMessage) error
- func (ur *UIRenderer) SendMessageSync(msg RenderMessage) error
- func (ur *UIRenderer) SetBatchInterval(interval time.Duration)
- func (ur *UIRenderer) Start()
- func (ur *UIRenderer) Stop()
- func (ur *UIRenderer) UpdateFooter(update FooterUpdate) error
- type WrappedLine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearLineSeq ¶ added in v0.7.0
func ClearLineSeq() string
ClearLineSeq returns the escape sequence to clear the entire current line.
func ClearToEndOfLineSeq ¶ added in v0.7.0
func ClearToEndOfLineSeq() string
ClearToEndOfLineSeq returns the escape sequence to clear from cursor to end of line.
func DebugEnabled ¶ added in v0.7.0
func DebugEnabled() bool
DebugEnabled returns true if debug output is enabled
func DebugPrintf ¶ added in v0.7.0
func DebugPrintf(format string, args ...interface{})
DebugPrintf prints debug output to stderr if debugging is enabled
func MoveCursorSeq ¶ added in v0.7.0
MoveCursorSeq returns the escape sequence to move the cursor to (x,y) Note: ANSI uses row (y) first, then column (x).
func RegisterCleanup ¶ added in v0.7.0
func RegisterCleanup(fn func() error)
RegisterCleanup registers a global cleanup function
func RegisterComponent ¶ added in v0.7.0
func RegisterComponent(componentType string, factory ComponentFactory) error
RegisterComponent registers a component factory globally
func ResetScrollRegionSeq ¶ added in v0.7.0
func ResetScrollRegionSeq() string
ResetScrollRegionSeq resets the scrolling region to the full screen.
func RunCleanup ¶ added in v0.7.0
func RunCleanup()
RunCleanup runs all registered cleanup functions
func SetScrollRegionSeq ¶ added in v0.7.0
SetScrollRegionSeq returns the escape sequence to set the scrolling region (1-based, inclusive).
Types ¶
type AutoLayoutManager ¶ added in v0.7.0
type AutoLayoutManager struct { LayoutManager // Embed the existing interface // contains filtered or unexported fields }
AutoLayoutManager automatically manages component positioning
func NewAutoLayoutManager ¶ added in v0.7.0
func NewAutoLayoutManager() *AutoLayoutManager
NewAutoLayoutManager creates an enhanced layout manager
func (*AutoLayoutManager) AddResizeCallback ¶ added in v0.7.0
func (alm *AutoLayoutManager) AddResizeCallback(callback func(width, height int))
AddResizeCallback adds a callback for resize events
func (*AutoLayoutManager) GetContentRegion ¶ added in v0.7.0
func (alm *AutoLayoutManager) GetContentRegion() (Region, error)
GetContentRegion returns the region allocated for scrollable content
func (*AutoLayoutManager) GetScrollRegion ¶ added in v0.7.0
func (alm *AutoLayoutManager) GetScrollRegion() (top, bottom int)
GetScrollRegion returns the scroll region boundaries for terminal setup (1-based)
func (*AutoLayoutManager) GetTerminalSize ¶ added in v0.7.0
func (alm *AutoLayoutManager) GetTerminalSize() (int, int)
GetTerminalSize returns current terminal dimensions
func (*AutoLayoutManager) Initialize ¶ added in v0.7.0
func (alm *AutoLayoutManager) Initialize() error
Initialize sets up the auto layout manager
func (*AutoLayoutManager) InitializeForTest ¶ added in v0.7.0
func (alm *AutoLayoutManager) InitializeForTest(width, height int)
InitializeForTest sets up the auto layout manager without requiring a terminal
func (*AutoLayoutManager) OnTerminalResize ¶ added in v0.7.0
func (alm *AutoLayoutManager) OnTerminalResize(width, height int)
OnTerminalResize handles terminal resize events
func (*AutoLayoutManager) PrintDebugLayout ¶ added in v0.7.0
func (alm *AutoLayoutManager) PrintDebugLayout()
PrintDebugLayout prints current layout for debugging
func (*AutoLayoutManager) RegisterComponent ¶ added in v0.7.0
func (alm *AutoLayoutManager) RegisterComponent(name string, info *ComponentInfo)
RegisterComponent registers a component for automatic layout
func (*AutoLayoutManager) SetComponentHeight ¶ added in v0.7.0
func (alm *AutoLayoutManager) SetComponentHeight(name string, height int)
SetComponentHeight sets the height for a component
func (*AutoLayoutManager) SetComponentVisible ¶ added in v0.7.0
func (alm *AutoLayoutManager) SetComponentVisible(name string, visible bool)
SetComponentVisible sets visibility for a component
func (*AutoLayoutManager) TestLayout ¶ added in v0.7.0
func (alm *AutoLayoutManager) TestLayout(width, height int)
TestLayout manually sets up layout for testing without requiring terminal
func (*AutoLayoutManager) UpdateComponentInfo ¶ added in v0.7.0
func (alm *AutoLayoutManager) UpdateComponentInfo(name string, updater func(*ComponentInfo))
UpdateComponentInfo updates component layout information
type BaseComponent ¶
type BaseComponent struct { // Protected fields - accessible by embedding components Deps Dependencies // contains filtered or unexported fields }
BaseComponent provides common functionality for components
func NewBaseComponent ¶
func NewBaseComponent(id, componentType string) *BaseComponent
NewBaseComponent creates a new base component
func (*BaseComponent) CanHandleInput ¶
func (bc *BaseComponent) CanHandleInput() bool
CanHandleInput returns if component can handle input
func (*BaseComponent) Cleanup ¶
func (bc *BaseComponent) Cleanup() error
Cleanup cleans up component resources
func (*BaseComponent) Controller ¶ added in v0.8.3
func (bc *BaseComponent) Controller() *TerminalController
Controller returns the terminal controller
func (*BaseComponent) Events ¶
func (bc *BaseComponent) Events() EventBus
Events returns the event bus
func (*BaseComponent) GetRegion ¶
func (bc *BaseComponent) GetRegion() string
GetRegion returns the component's region
func (*BaseComponent) HandleInput ¶
func (bc *BaseComponent) HandleInput(input []byte) (bool, error)
HandleInput handles input
func (*BaseComponent) Init ¶
func (bc *BaseComponent) Init(ctx context.Context, deps Dependencies) error
Init initializes the component with dependencies
func (*BaseComponent) Layout ¶
func (bc *BaseComponent) Layout() LayoutManager
Layout returns the layout manager
func (*BaseComponent) NeedsRedraw ¶
func (bc *BaseComponent) NeedsRedraw() bool
NeedsRedraw returns if component needs redrawing
func (*BaseComponent) PublishEvent ¶
func (bc *BaseComponent) PublishEvent(eventType string, data interface{})
PublishEvent publishes an event from this component
func (*BaseComponent) SetNeedsRedraw ¶
func (bc *BaseComponent) SetNeedsRedraw(needs bool)
SetNeedsRedraw marks component for redraw
func (*BaseComponent) SetRegion ¶
func (bc *BaseComponent) SetRegion(region string)
SetRegion sets the component's region
func (*BaseComponent) State ¶
func (bc *BaseComponent) State() StateManager
State returns the state manager
func (*BaseComponent) Terminal ¶
func (bc *BaseComponent) Terminal() TerminalManager
Terminal returns the terminal manager
type BufferStats ¶ added in v0.6.0
BufferStats contains buffer statistics
type CIOutputHandler ¶ added in v0.7.0
type CIOutputHandler struct {
// contains filtered or unexported fields
}
CIOutputHandler manages output formatting for CI/non-interactive environments
func NewCIOutputHandler ¶ added in v0.7.0
func NewCIOutputHandler(writer io.Writer) *CIOutputHandler
NewCIOutputHandler creates a new CI output handler
func (*CIOutputHandler) IsCI ¶ added in v0.7.0
func (h *CIOutputHandler) IsCI() bool
IsCI returns true if running in CI environment
func (*CIOutputHandler) IsInteractive ¶ added in v0.7.0
func (h *CIOutputHandler) IsInteractive() bool
IsInteractive returns true if running in an interactive terminal
func (*CIOutputHandler) PrintProgress ¶ added in v0.7.0
func (h *CIOutputHandler) PrintProgress()
PrintProgress prints a progress update in CI-friendly format
func (*CIOutputHandler) PrintSummary ¶ added in v0.7.0
func (h *CIOutputHandler) PrintSummary()
PrintSummary prints a final summary
func (*CIOutputHandler) Printf ¶ added in v0.7.0
func (h *CIOutputHandler) Printf(format string, args ...interface{})
Printf writes formatted output
func (*CIOutputHandler) ShouldShowProgress ¶ added in v0.7.0
func (h *CIOutputHandler) ShouldShowProgress() bool
ShouldShowProgress returns true if progress should be shown
func (*CIOutputHandler) UpdateMetrics ¶ added in v0.7.0
func (h *CIOutputHandler) UpdateMetrics(totalTokens, contextTokens, maxContextTokens, iteration int, totalCost float64)
UpdateMetrics updates the tracked metrics
func (*CIOutputHandler) Write ¶ added in v0.7.0
func (h *CIOutputHandler) Write(p []byte) (n int, err error)
Write implements io.Writer interface
func (*CIOutputHandler) WriteString ¶ added in v0.7.0
func (h *CIOutputHandler) WriteString(s string) error
WriteString writes a string with appropriate formatting
type CLIOutputHandler ¶ added in v0.8.3
type CLIOutputHandler struct {
// contains filtered or unexported fields
}
CLIOutputHandler handles simple CLI mode output (direct to stdout)
func NewCLIOutputHandler ¶ added in v0.8.3
func NewCLIOutputHandler() *CLIOutputHandler
NewCLIOutputHandler creates a new CLI output handler
func (*CLIOutputHandler) Close ¶ added in v0.8.3
func (h *CLIOutputHandler) Close() error
Close cleans up resources (no-op for CLI)
func (*CLIOutputHandler) Flush ¶ added in v0.8.3
func (h *CLIOutputHandler) Flush() error
Flush ensures output is written (no-op for CLI)
func (*CLIOutputHandler) Mode ¶ added in v0.8.3
func (h *CLIOutputHandler) Mode() OutputMode
Mode returns the output mode
func (*CLIOutputHandler) Print ¶ added in v0.8.3
func (h *CLIOutputHandler) Print(format string, args ...interface{})
Print writes formatted output
func (*CLIOutputHandler) Printf ¶ added in v0.8.3
func (h *CLIOutputHandler) Printf(format string, args ...interface{})
Printf writes formatted output
func (*CLIOutputHandler) Println ¶ added in v0.8.3
func (h *CLIOutputHandler) Println(args ...interface{})
Println writes output with newline
type Component ¶
type Component interface { // Lifecycle methods Init(ctx context.Context, deps Dependencies) error Start() error Stop() error Cleanup() error // Component identity ID() string Type() string // Rendering Render() error NeedsRedraw() bool // Input handling HandleInput(input []byte) (handled bool, err error) CanHandleInput() bool // Region management GetRegion() string SetRegion(region string) }
Component is the base interface for all UI components
func CreateComponent ¶ added in v0.7.0
CreateComponent creates a component from the global registry
type ComponentConfig ¶
type ComponentConfig struct { ID string Type string Region string Config map[string]interface{} Enabled bool }
ComponentConfig configures a component
type ComponentFactory ¶ added in v0.7.0
type ComponentFactory func() Component
ComponentFactory creates component instances
type ComponentInfo ¶ added in v0.7.0
type ComponentInfo struct { Name string Position string // "top", "bottom", "content" Height int // Fixed height, 0 = flexible Priority int // Higher priority gets preference Visible bool ZOrder int }
ComponentInfo holds layout information for a component
type ComponentRegistry ¶ added in v0.7.0
type ComponentRegistry struct {
// contains filtered or unexported fields
}
ComponentRegistry manages component factories
func NewComponentRegistry ¶ added in v0.7.0
func NewComponentRegistry() *ComponentRegistry
NewComponentRegistry creates a new component registry
func (*ComponentRegistry) Create ¶ added in v0.7.0
func (r *ComponentRegistry) Create(componentType string) (Component, error)
Create creates a new component instance
func (*ComponentRegistry) ListTypes ¶ added in v0.7.0
func (r *ComponentRegistry) ListTypes() []string
ListTypes returns all registered component types
func (*ComponentRegistry) Register ¶ added in v0.7.0
func (r *ComponentRegistry) Register(componentType string, factory ComponentFactory) error
Register registers a component factory
type Config ¶
type Config struct { // Terminal settings RawMode bool MouseEnabled bool AltScreen bool // Layout settings MinWidth int MinHeight int // Component settings Components []ComponentConfig // Event settings EventQueueSize int // Debug settings Debug bool LogFile string }
Config holds application configuration
func ConfigForMode ¶ added in v0.8.3
func ConfigForMode(mode OutputMode) *Config
ConfigForMode returns a configuration appropriate for the given output mode
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default configuration (compatible with existing code)
type ConsoleApp ¶
type ConsoleApp interface { // Lifecycle Init(config *Config) error Start() error Stop() error Run() error Cleanup() error // Component management AddComponent(component Component) error RemoveComponent(componentID string) error GetComponent(componentID string) (Component, bool) ListComponents() []string // Service access Terminal() TerminalManager Layout() LayoutManager State() StateManager Events() EventBus Controller() *TerminalController // Configuration GetConfig() *Config UpdateConfig(config *Config) error }
ConsoleApp is the main application controller
func NewConsoleApp ¶
func NewConsoleApp() ConsoleApp
NewConsoleApp creates a new console application
func NewConsoleAppWithMode ¶ added in v0.8.3
func NewConsoleAppWithMode(mode OutputMode) ConsoleApp
NewConsoleAppWithMode creates a new console application with mode-aware configuration
type ConsoleBuffer ¶ added in v0.6.0
type ConsoleBuffer struct {
// contains filtered or unexported fields
}
ConsoleBuffer represents a scrollable buffer with line wrapping
func NewConsoleBuffer ¶ added in v0.6.0
func NewConsoleBuffer(maxLines int) *ConsoleBuffer
NewConsoleBuffer creates a new console buffer
func (*ConsoleBuffer) AddContent ¶ added in v0.6.0
func (cb *ConsoleBuffer) AddContent(content string)
AddContent adds content that may span multiple lines
func (*ConsoleBuffer) AddLine ¶ added in v0.6.0
func (cb *ConsoleBuffer) AddLine(line string)
AddLine adds a new line to the buffer
func (*ConsoleBuffer) Clear ¶ added in v0.6.0
func (cb *ConsoleBuffer) Clear()
Clear clears the buffer
func (*ConsoleBuffer) Debug ¶ added in v0.6.0
func (cb *ConsoleBuffer) Debug() string
Debug method for troubleshooting
func (*ConsoleBuffer) GetStats ¶ added in v0.6.0
func (cb *ConsoleBuffer) GetStats() BufferStats
GetStats returns buffer statistics
func (*ConsoleBuffer) GetVisibleLines ¶ added in v0.6.0
func (cb *ConsoleBuffer) GetVisibleLines(viewportHeight int) []string
GetVisibleLines returns the lines that should be visible in the given viewport
func (*ConsoleBuffer) RedrawBuffer ¶ added in v0.6.0
func (cb *ConsoleBuffer) RedrawBuffer(terminal TerminalManager, viewportHeight int) error
RedrawBuffer redraws the entire buffer content to the terminal
func (*ConsoleBuffer) ScrollDown ¶ added in v0.6.0
func (cb *ConsoleBuffer) ScrollDown(lines int)
ScrollDown scrolls the buffer down by the given number of lines
func (*ConsoleBuffer) ScrollToBottom ¶ added in v0.6.0
func (cb *ConsoleBuffer) ScrollToBottom()
ScrollToBottom scrolls to the bottom of the buffer
func (*ConsoleBuffer) ScrollUp ¶ added in v0.6.0
func (cb *ConsoleBuffer) ScrollUp(lines int)
ScrollUp scrolls the buffer up by the given number of lines
func (*ConsoleBuffer) SetTerminalWidth ¶ added in v0.6.0
func (cb *ConsoleBuffer) SetTerminalWidth(width int)
SetTerminalWidth updates the terminal width and marks for rewrapping
type ContentUpdate ¶ added in v0.7.0
type ContentUpdate struct {
Text string
}
ContentUpdate represents streaming content to append
type Dependencies ¶
type Dependencies struct { Terminal TerminalManager Controller *TerminalController Layout LayoutManager State StateManager Events EventBus }
Dependencies provides access to core services
type DualOutputHandler ¶ added in v0.8.3
type DualOutputHandler struct {
// contains filtered or unexported fields
}
DualOutputHandler implements OutputHandler with dual-mode support
func NewDualOutputHandler ¶ added in v0.8.3
func NewDualOutputHandler(cliOutput io.Writer, buffer *ConsoleBuffer) *DualOutputHandler
NewDualOutputHandler creates a new dual-mode output handler
func (*DualOutputHandler) Buffer ¶ added in v0.8.3
func (doh *DualOutputHandler) Buffer() *ConsoleBuffer
Buffer returns the console buffer
func (*DualOutputHandler) Mode ¶ added in v0.8.3
func (doh *DualOutputHandler) Mode() OutputMode
Mode returns the current output mode
func (*DualOutputHandler) Print ¶ added in v0.8.3
func (doh *DualOutputHandler) Print(format string, args ...interface{})
Print writes formatted output
func (*DualOutputHandler) Printf ¶ added in v0.8.3
func (doh *DualOutputHandler) Printf(format string, args ...interface{})
Printf writes formatted output
func (*DualOutputHandler) Println ¶ added in v0.8.3
func (doh *DualOutputHandler) Println(args ...interface{})
Println writes output with newline
func (*DualOutputHandler) Redraw ¶ added in v0.8.3
func (doh *DualOutputHandler) Redraw()
Redraw forces a redraw of the content
func (*DualOutputHandler) SetAutoRedraw ¶ added in v0.8.3
func (doh *DualOutputHandler) SetAutoRedraw(auto bool)
SetAutoRedraw controls whether to auto-redraw in interactive mode
func (*DualOutputHandler) SetMode ¶ added in v0.8.3
func (doh *DualOutputHandler) SetMode(mode OutputMode)
SetMode changes the output mode
type Event ¶
type Event struct { ID string Type string Source string Target string // Optional specific target Data interface{} Timestamp int64 }
Event represents a system event
type EventBus ¶
type EventBus interface { // Publishing Publish(event Event) error PublishAsync(event Event) // Subscriptions Subscribe(eventType string, handler EventHandler) string SubscribeToSource(source string, handler EventHandler) string Unsubscribe(subscriptionID string) // Event filtering SetFilter(filter EventFilter) // Control Start() error Stop() error }
EventBus provides component communication
type EventFilter ¶
EventFilter determines if an event should be processed
type FooterUpdate ¶ added in v0.7.0
type FooterUpdate struct {}
FooterUpdate represents footer state change
type InputEvent ¶ added in v0.7.0
type InputEvent struct { Type InputEventType Data interface{} }
InputEvent represents a keyboard input event
type InputEventType ¶ added in v0.7.0
type InputEventType int
InputEventType represents the type of input event
const ( KeystrokeEvent InputEventType = iota InterruptEvent ResizeEvent )
type InputHandler ¶ added in v0.7.0
type InputHandler interface { HandleInput(event InputEvent) bool // Returns true if event was handled GetHandlerID() string }
InputHandler interface that components can implement to receive input events
type InputRouter ¶ added in v0.7.0
type InputRouter struct {
// contains filtered or unexported fields
}
InputRouter manages routing input events to the currently active handler
func NewInputRouter ¶ added in v0.7.0
func NewInputRouter() *InputRouter
NewInputRouter creates a new input router
func (*InputRouter) PublishEvent ¶ added in v0.7.0
func (ir *InputRouter) PublishEvent(event InputEvent) bool
PublishEvent sends an input event to the active handler
func (*InputRouter) RegisterHandler ¶ added in v0.7.0
func (ir *InputRouter) RegisterHandler(handler InputHandler)
RegisterHandler registers a new input handler
func (*InputRouter) RestoreDefaultHandler ¶ added in v0.7.0
func (ir *InputRouter) RestoreDefaultHandler()
RestoreDefaultHandler switches back to the default handler
func (*InputRouter) SendInterrupt ¶ added in v0.7.0
func (ir *InputRouter) SendInterrupt() bool
SendInterrupt sends an interrupt event to the active handler
func (*InputRouter) SendKeystroke ¶ added in v0.7.0
func (ir *InputRouter) SendKeystroke(data []byte) bool
SendKeystroke sends a keystroke event to the active handler
func (*InputRouter) SetActiveHandler ¶ added in v0.7.0
func (ir *InputRouter) SetActiveHandler(handlerID string) bool
SetActiveHandler switches the active input handler
func (*InputRouter) SetDefaultHandler ¶ added in v0.7.0
func (ir *InputRouter) SetDefaultHandler(handler InputHandler)
SetDefaultHandler sets the default handler (usually the main console)
func (*InputRouter) Start ¶ added in v0.7.0
func (ir *InputRouter) Start()
Start begins processing input events
func (*InputRouter) UnregisterHandler ¶ added in v0.7.0
func (ir *InputRouter) UnregisterHandler(handlerID string)
UnregisterHandler removes an input handler
type InteractiveOutputHandler ¶ added in v0.8.3
type InteractiveOutputHandler struct {
// contains filtered or unexported fields
}
InteractiveOutputHandler handles interactive buffer mode output (Vim-like)
func NewInteractiveOutputHandler ¶ added in v0.8.3
func NewInteractiveOutputHandler(buffer *ConsoleBuffer, terminal TerminalManager) *InteractiveOutputHandler
NewInteractiveOutputHandler creates a new interactive output handler
func (*InteractiveOutputHandler) Close ¶ added in v0.8.3
func (h *InteractiveOutputHandler) Close() error
Close cleans up resources
func (*InteractiveOutputHandler) Flush ¶ added in v0.8.3
func (h *InteractiveOutputHandler) Flush() error
Flush ensures output is written to terminal
func (*InteractiveOutputHandler) Mode ¶ added in v0.8.3
func (h *InteractiveOutputHandler) Mode() OutputMode
Mode returns the output mode
func (*InteractiveOutputHandler) Print ¶ added in v0.8.3
func (h *InteractiveOutputHandler) Print(format string, args ...interface{})
Print writes formatted output
func (*InteractiveOutputHandler) Printf ¶ added in v0.8.3
func (h *InteractiveOutputHandler) Printf(format string, args ...interface{})
Printf writes formatted output
func (*InteractiveOutputHandler) Println ¶ added in v0.8.3
func (h *InteractiveOutputHandler) Println(args ...interface{})
Println writes output with newline
type KeystrokeData ¶ added in v0.7.0
KeystrokeData contains keystroke information
type LayoutManager ¶
type LayoutManager interface { // Region management DefineRegion(name string, region Region) error UpdateRegion(name string, region Region) error GetRegion(name string) (Region, error) RemoveRegion(name string) error ListRegions() []string // Layout calculations CalculateLayout(termWidth, termHeight int) error GetAvailableSpace() Region // Rendering control BeginBatch() EndBatch() error RequestRedraw(regionName string) ForceRedraw() // Z-order management SetZOrder(regionName string, zOrder int) error GetRenderOrder() []string }
LayoutManager manages screen regions and rendering order
func NewLayoutManager ¶
func NewLayoutManager(termWidth, termHeight int) LayoutManager
NewLayoutManager creates a new layout manager
type LogInputHandler ¶ added in v0.7.0
type LogInputHandler struct {
// contains filtered or unexported fields
}
LogInputHandler handles input for the interactive log command
func NewLogInputHandler ¶ added in v0.7.0
func NewLogInputHandler() *LogInputHandler
NewLogInputHandler creates a new log input handler
func (*LogInputHandler) Activate ¶ added in v0.7.0
func (lih *LogInputHandler) Activate()
Activate enables this handler to receive input
func (*LogInputHandler) CreateReader ¶ added in v0.7.0
func (lih *LogInputHandler) CreateReader() *bufio.Reader
CreateReader creates a bufio.Reader-compatible interface for the log handler
func (*LogInputHandler) Deactivate ¶ added in v0.7.0
func (lih *LogInputHandler) Deactivate()
Deactivate disables this handler from receiving input
func (*LogInputHandler) GetHandlerID ¶ added in v0.7.0
func (lih *LogInputHandler) GetHandlerID() string
GetHandlerID returns the handler identifier
func (*LogInputHandler) HandleInput ¶ added in v0.7.0
func (lih *LogInputHandler) HandleInput(event InputEvent) bool
HandleInput processes input events for log navigation
func (*LogInputHandler) ReadString ¶ added in v0.7.0
func (lih *LogInputHandler) ReadString(delim byte) (string, error)
ReadString mimics bufio.Reader.ReadString for compatibility with existing log code
type OutputHandler ¶ added in v0.8.3
type OutputHandler interface { // Mode returns the current output mode Mode() OutputMode // Print writes formatted output Print(format string, args ...interface{}) // Println writes output with newline Println(args ...interface{}) // Printf writes formatted output Printf(format string, args ...interface{}) // Write writes raw bytes Write(p []byte) (n int, err error) // Buffer returns the console buffer (nil in CLI mode) Buffer() *ConsoleBuffer // Redraw forces a redraw of the content (only in interactive mode) Redraw() // SetMode changes the output mode SetMode(mode OutputMode) }
OutputHandler defines the interface for dual-mode output handling
type OutputMode ¶ added in v0.8.3
type OutputMode int
OutputMode represents the different output modes
const ( // OutputModeCLI is simple CLI output (direct to stdout, cooked terminal) OutputModeCLI OutputMode = iota // OutputModeInteractive is interactive buffer mode (Vim-like, raw terminal) OutputModeInteractive )
type Region ¶
type Region struct {
X, Y int // Top-left corner (0-based)
Width, Height int
ZOrder int // Higher values are on top
Visible bool
}
Region represents a rectangular area on the terminal
type RenderMessage ¶ added in v0.7.0
type RenderMessage struct { Type string // "content", "footer", "input", "cursor" Component string // Component name Data interface{} // Type-specific data Priority int // Higher priority processes first Callback chan error // Optional callback for completion }
RenderMessage represents a UI update request
type RenderOp ¶ added in v0.7.0
type RenderOp struct { Type string Callback func() error Priority int // Higher priority ops execute first }
RenderOp represents a terminal rendering operation
type ResizableComponent ¶
type ResizableComponent interface {
OnResize(width, height int)
}
ResizableComponent is an interface for components that can handle resize events
type StateCallback ¶
type StateCallback func(key string, oldValue, newValue interface{})
StateCallback is called when state changes
type StateManager ¶
type StateManager interface { // State operations Get(key string) (interface{}, bool) Set(key string, value interface{}) Delete(key string) Clear() // Transactions BeginTransaction() Commit() Rollback() // Subscriptions Subscribe(pattern string, callback StateCallback) string Unsubscribe(subscriptionID string) // Persistence Save(path string) error Load(path string) error }
StateManager provides centralized state management
func NewStateManager ¶
func NewStateManager() StateManager
NewStateManager creates a new state manager
type TerminalCleanupHandler ¶ added in v0.7.0
type TerminalCleanupHandler struct {
// contains filtered or unexported fields
}
TerminalCleanupHandler ensures terminal is properly restored on exit
func NewTerminalCleanupHandler ¶ added in v0.7.0
func NewTerminalCleanupHandler() *TerminalCleanupHandler
NewTerminalCleanupHandler creates a new cleanup handler
func (*TerminalCleanupHandler) Cleanup ¶ added in v0.7.0
func (h *TerminalCleanupHandler) Cleanup()
Cleanup runs all registered cleanup functions
func (*TerminalCleanupHandler) EnsureCleanup ¶ added in v0.7.0
func (h *TerminalCleanupHandler) EnsureCleanup()
EnsureCleanup should be deferred in main to ensure cleanup on panic
func (*TerminalCleanupHandler) Register ¶ added in v0.7.0
func (h *TerminalCleanupHandler) Register(fn func() error)
Register adds a cleanup function to be called on exit
type TerminalController ¶ added in v0.7.0
type TerminalController struct {
// contains filtered or unexported fields
}
TerminalController centralizes all terminal operations and state management
func NewTerminalController ¶ added in v0.7.0
func NewTerminalController(tm TerminalManager, eventBus EventBus) *TerminalController
NewTerminalController creates a new centralized terminal controller
func (*TerminalController) AcquireRawMode ¶ added in v0.8.3
func (tc *TerminalController) AcquireRawMode(reason string) (func(), error)
AcquireRawMode increments the raw mode reference count and ensures raw mode is enabled. The returned release function should be called to decrement the reference count when done.
func (*TerminalController) Cleanup ¶ added in v0.7.0
func (tc *TerminalController) Cleanup() error
Cleanup shuts down the controller and restores terminal state
func (*TerminalController) ClearLine ¶ added in v0.7.0
func (tc *TerminalController) ClearLine() error
ClearLine clears current line immediately
func (*TerminalController) ClearScreen ¶ added in v0.7.0
func (tc *TerminalController) ClearScreen() error
ClearScreen clears the entire screen
func (*TerminalController) ClearScrollback ¶ added in v0.8.3
func (tc *TerminalController) ClearScrollback() error
ClearScrollback clears the scrollback buffer
func (*TerminalController) ClearToEndOfLine ¶ added in v0.7.0
func (tc *TerminalController) ClearToEndOfLine() error
ClearToEndOfLine clears from cursor to end of line (immediate)
func (*TerminalController) ClearToEndOfScreen ¶ added in v0.7.0
func (tc *TerminalController) ClearToEndOfScreen() error
ClearToEndOfScreen clears from cursor to end of screen
func (*TerminalController) DisableMouseTracking ¶ added in v0.8.3
func (tc *TerminalController) DisableMouseTracking() error
DisableMouseTracking disables terminal mouse reporting and clears the desired state.
func (*TerminalController) EnableMouseTracking ¶ added in v0.8.3
func (tc *TerminalController) EnableMouseTracking() error
EnableMouseTracking enables terminal mouse reporting and records the desired state.
func (*TerminalController) EnterAltScreen ¶ added in v0.8.3
func (tc *TerminalController) EnterAltScreen() error
EnterAltScreen enters the alternate screen buffer
func (*TerminalController) ExitAltScreen ¶ added in v0.8.3
func (tc *TerminalController) ExitAltScreen() error
ExitAltScreen exits the alternate screen buffer
func (*TerminalController) Flush ¶ added in v0.7.0
func (tc *TerminalController) Flush() error
Flush ensures all pending operations are rendered
func (*TerminalController) GetSize ¶ added in v0.7.0
func (tc *TerminalController) GetSize() (width, height int, err error)
GetSize returns current terminal dimensions
func (*TerminalController) HideCursor ¶ added in v0.7.0
func (tc *TerminalController) HideCursor() error
HideCursor hides the cursor (immediate)
func (*TerminalController) Init ¶ added in v0.7.0
func (tc *TerminalController) Init() error
Init initializes the terminal controller
func (*TerminalController) IsAltScreen ¶ added in v0.8.3
func (tc *TerminalController) IsAltScreen() bool
IsAltScreen returns true when the controller believes the alternate screen is active.
func (*TerminalController) IsRawMode ¶ added in v0.7.0
func (tc *TerminalController) IsRawMode() bool
IsRawMode returns current raw mode state
func (*TerminalController) MoveCursor ¶ added in v0.7.0
func (tc *TerminalController) MoveCursor(x, y int) error
MoveCursor moves cursor immediately (required for proper rendering)
func (*TerminalController) OnResize ¶ added in v0.7.0
func (tc *TerminalController) OnResize(callback func(width, height int))
OnResize registers a callback for terminal resize events
func (*TerminalController) QueueRender ¶ added in v0.7.0
func (tc *TerminalController) QueueRender(op RenderOp)
QueueRender adds a rendering operation to the queue
func (*TerminalController) RegisterComponent ¶ added in v0.7.0
func (tc *TerminalController) RegisterComponent(name string, component Component, order int)
RegisterComponent adds a component to the controller
func (*TerminalController) ReleaseRawMode ¶ added in v0.8.3
func (tc *TerminalController) ReleaseRawMode(reason string)
ReleaseRawMode decrements the raw mode reference count and applies the resulting mode.
func (*TerminalController) ResetScrollRegion ¶ added in v0.7.0
func (tc *TerminalController) ResetScrollRegion() error
ResetScrollRegion resets the scrolling region to the entire screen
func (*TerminalController) RestoreCursor ¶ added in v0.7.0
func (tc *TerminalController) RestoreCursor() error
RestoreCursor restores the saved cursor position (immediate)
func (*TerminalController) SaveCursor ¶ added in v0.7.0
func (tc *TerminalController) SaveCursor() error
SaveCursor saves the current cursor position (immediate)
func (*TerminalController) ScrollDown ¶ added in v0.7.0
func (tc *TerminalController) ScrollDown(lines int) error
ScrollDown scrolls the current region down by n lines
func (*TerminalController) ScrollUp ¶ added in v0.7.0
func (tc *TerminalController) ScrollUp(lines int) error
ScrollUp scrolls the current region up by n lines
func (*TerminalController) SetInterruptHandler ¶ added in v0.7.0
func (tc *TerminalController) SetInterruptHandler(handler func())
SetInterruptHandler sets the interrupt callback
func (*TerminalController) SetRawMode ¶ added in v0.7.0
func (tc *TerminalController) SetRawMode(enabled bool) error
SetRawMode enables or disables raw mode atomically
func (*TerminalController) SetScrollRegion ¶ added in v0.7.0
func (tc *TerminalController) SetScrollRegion(top, bottom int) error
SetScrollRegion sets scroll region immediately (critical for layout)
func (*TerminalController) ShowCursor ¶ added in v0.7.0
func (tc *TerminalController) ShowCursor() error
ShowCursor shows the cursor (immediate)
func (*TerminalController) WithPrimaryScreen ¶ added in v0.8.3
func (tc *TerminalController) WithPrimaryScreen(fn func() error) error
WithPrimaryScreen ensures operations run on the primary screen, temporarily leaving the alternate buffer when needed and restoring it afterward.
func (*TerminalController) WithRawMode ¶ added in v0.8.3
func (tc *TerminalController) WithRawMode(reason string, fn func() error) error
WithRawMode acquires raw mode, runs the callback, and releases raw mode afterward.
func (*TerminalController) Write ¶ added in v0.7.0
func (tc *TerminalController) Write(p []byte) (n int, err error)
Write implements io.Writer with raw mode handling
func (*TerminalController) WriteAt ¶ added in v0.7.0
func (tc *TerminalController) WriteAt(x, y int, data []byte) error
WriteAt writes data at a specific position
func (*TerminalController) WriteString ¶ added in v0.7.0
func (tc *TerminalController) WriteString(s string) error
WriteString writes a string with proper line ending handling
type TerminalManager ¶
type TerminalManager interface { // Initialization Init() error Cleanup() error // Size detection GetSize() (width, height int, err error) OnResize(callback func(width, height int)) // Terminal modes SetRawMode(enabled bool) error IsRawMode() bool // Cursor control MoveCursor(x, y int) error SaveCursor() error RestoreCursor() error HideCursor() error ShowCursor() error // Screen operations ClearScreen() error ClearScrollback() error ClearLine() error ClearToEndOfLine() error ClearToEndOfScreen() error EnterAltScreen() error ExitAltScreen() error EnableMouseReporting() error DisableMouseReporting() error // Scroll region support SetScrollRegion(top, bottom int) error ResetScrollRegion() error ScrollUp(lines int) error ScrollDown(lines int) error // Output Write(data []byte) (int, error) WriteText(text string) (int, error) // Automatically handles line endings for raw mode WriteAt(x, y int, data []byte) error Flush() error }
TerminalManager handles all terminal operations
func NewTerminalManager ¶
func NewTerminalManager() TerminalManager
NewTerminalManager creates a new terminal manager
type UIHandler ¶
type UIHandler struct {
// contains filtered or unexported fields
}
UIHandler manages UI events and coordinates component updates
func NewUIHandler ¶
func NewUIHandler(terminal TerminalManager) *UIHandler
NewUIHandler creates a new UI handler
func (*UIHandler) ForceRedraw ¶
func (h *UIHandler) ForceRedraw()
ForceRedraw forces all components to redraw
func (*UIHandler) Initialize ¶
Initialize sets up the UI handler and starts listening for events
func (*UIHandler) RegisterComponent ¶
func (h *UIHandler) RegisterComponent(id string, component ResizableComponent)
RegisterComponent registers a component for resize notifications
func (*UIHandler) UnregisterComponent ¶
UnregisterComponent removes a component from resize notifications
type UIRenderer ¶ added in v0.7.0
type UIRenderer struct {
// contains filtered or unexported fields
}
UIRenderer manages serialized UI updates through a message queue
func NewUIRenderer ¶ added in v0.7.0
func NewUIRenderer(tm TerminalManager) *UIRenderer
NewUIRenderer creates a new UI renderer
func (*UIRenderer) AppendContent ¶ added in v0.7.0
func (ur *UIRenderer) AppendContent(text string) error
AppendContent is a convenience method for streaming content
func (*UIRenderer) EnableBatching ¶ added in v0.7.0
func (ur *UIRenderer) EnableBatching(enabled bool)
EnableBatching enables update batching for efficiency
func (*UIRenderer) RegisterComponent ¶ added in v0.7.0
func (ur *UIRenderer) RegisterComponent(name string, component Component)
RegisterComponent registers a component for rendering
func (*UIRenderer) SendMessage ¶ added in v0.7.0
func (ur *UIRenderer) SendMessage(msg RenderMessage) error
SendMessage queues a render message
func (*UIRenderer) SendMessageSync ¶ added in v0.7.0
func (ur *UIRenderer) SendMessageSync(msg RenderMessage) error
SendMessageSync sends a message and waits for completion
func (*UIRenderer) SetBatchInterval ¶ added in v0.7.0
func (ur *UIRenderer) SetBatchInterval(interval time.Duration)
SetBatchInterval sets the batch flush interval
func (*UIRenderer) Start ¶ added in v0.7.0
func (ur *UIRenderer) Start()
Start begins the render loop
func (*UIRenderer) UpdateFooter ¶ added in v0.7.0
func (ur *UIRenderer) UpdateFooter(update FooterUpdate) error
UpdateFooter is a convenience method for footer updates
type WrappedLine ¶ added in v0.6.0
type WrappedLine struct { Content string // The wrapped line content OriginalID int // Index of the original line this came from WrapIndex int // Which wrap of the original line this is (0 = first) }
WrappedLine represents a line that has been wrapped for display
Source Files
¶
- ansi.go
- app.go
- auto_layout_manager.go
- ci_output_handler.go
- cli_output_handler.go
- component.go
- component_registry.go
- console_buffer.go
- debug.go
- event_bus.go
- input_router.go
- interactive_output_handler.go
- interfaces.go
- layout_manager.go
- log_input_handler.go
- output_handler.go
- signal_compat_unix.go
- state_manager.go
- terminal_cleanup.go
- terminal_controller.go
- terminal_manager_unix.go
- ui_handler.go
- ui_renderer.go