Documentation
¶
Overview ¶
Package tui provides Pi-compatible terminal rendering, input, components, keybindings, and screen lifecycle management.
Index ¶
- Constants
- Variables
- func ActionKeyDisplayText(action string) string
- func ActionKeyDisplayTextOr(action, fallback string) string
- func AllocateImageID() int
- func AppKeyText(action, fallback string) string
- func BgClose() string
- func BgSeq(c color.RGBA, trueColor bool) string
- func BuildTerminalTitle(sessionName, cwd string) string
- func CalculateImageRows(imageDimensions ImageDimensions, targetWidthCells int, dims CellDimensions) int
- func CropKittyImageLine(line string, hiddenRows, visibleRows int) string
- func CustomMessageText(cm *CustomMessage) string
- func DecodeKittyPrintable(data string) (string, bool)
- func DecodePrintableKey(data string) (string, bool)
- func DeleteAllKittyImages() string
- func DeleteAllKittyPlacements() string
- func DeleteKittyImage(imageID int) string
- func DetectTheme()
- func EncodeITerm2(base64Data string, width any, height any, name string, preserveAspect bool) string
- func EncodeKitty(base64Data string, columns, rows, imageID int, moveCursor ...bool) string
- func EnterRawMode() (restore func(), err error)
- func FgSeq(c color.RGBA, trueColor bool) string
- func FormatAuthSelectorProviderType(authType string) string
- func FormatBashHeader(raw json.RawMessage) string
- func FormatBuiltinToolHeader(toolName string, args json.RawMessage, cwd string) string
- func FormatEditHeader(raw json.RawMessage, cwd string) string
- func FormatFindHeader(raw json.RawMessage) string
- func FormatGrepHeader(raw json.RawMessage) string
- func FormatKeyText(key string, capitalize bool) string
- func FormatLsHeader(raw json.RawMessage, cwd string) string
- func FormatReadHeader(raw json.RawMessage, cwd string) string
- func FormatShellHeader(raw json.RawMessage, prompt string) string
- func FormatToolArgs(raw json.RawMessage) string
- func FormatToolDuration(d time.Duration) string
- func FormatWriteHeader(raw json.RawMessage, cwd string) string
- func FuzzyFilter[T any](items []T, query string, getText func(T) string) []T
- func GetAltScreenSearchMatchKey(match AltScreenSearchMatch) string
- func GetDefaultTheme() string
- func GetModelSearchText(item ModelSearchItem) string
- func GetModelSelectorSearchText(item ModelSearchItem) string
- func HandleKeyboardProtocolNegotiationSequence(sequence string) bool
- func HasBuiltInToolRenderers(toolName string) bool
- func HeaderForTool(name string, args json.RawMessage, cwd string) string
- func HighlightCode(code, lang string) []string
- func Hyperlink(text, url string) string
- func ImageFallback(mimeType string, dimensions *ImageDimensions, filename string) string
- func IsAppleTerminalSession() bool
- func IsImageLine(line string) bool
- func IsKeyRelease(data string) bool
- func IsKittyProtocolActive() bool
- func IsNativeModifierPressed(key ModifierKey) bool
- func IsShellTool(toolName string) bool
- func JSNumberString(v float64) string
- func JSToFixed(v float64, digits int) string
- func JSToFixed1(v float64) string
- func KeyDisplayText(key string) string
- func KeyHint(key, description string) string
- func LanguageFromPath(path string) string
- func LoadThemeDir(dir string) (map[string]*Theme, error)
- func MatchesKeyID(data, keyID string) bool
- func NormalizeAppleTerminalInput(data string, isAppleTerminal, isShiftPressed bool) string
- func NormalizeNativeShiftEnterInput(data string, shouldDetectNativeShiftEnter, isShiftPressed bool) string
- func NormalizeProcessInputSequence(sequence string) string
- func ParseAutoThemeSetting(themeSetting string) (lightTheme, darkTheme string, ok bool)
- func ParseKey(data string) (string, bool)
- func RGBTo256(c color.RGBA) uint8
- func RawKeyHint(key, description string) string
- func ReadInput(r io.Reader) ([]byte, error)
- func RefreshActiveThemeColorMode()
- func RegisterKittyImageMetadata(metadata KittyImageMetadata)
- func RenderDiff(diffText string) string
- func RenderImage(base64Data string, imageDimensions ImageDimensions, options ImageRenderOptions) *renderedImage
- func RenderIntraLineDiff(oldContent, newContent string) (removedLine, addedLine string)
- func ResetCapabilitiesCache()
- func ResolveEscapeTimeoutMs(getenv func(string) string) float64
- func ResolveThemeSetting(themeSetting string, terminalTheme TerminalTheme) (string, bool)
- func RestoreTerminalFromSignal() bool
- func SetAppKeyTextResolver(resolver func(action string) string)
- func SetCapabilities(caps TerminalCapabilities)
- func SetCapabilityOverrides(overrides CapabilityOverrides)
- func SetCellDimensions(dims CellDimensions)
- func SetKeybindings(kb *TUIKeybindingsManager)
- func SetKittyProtocolActive(active bool)
- func SetTUIKeybindings(kb *TUIKeybindingsManager)
- func SetTerminalProgress(active bool)
- func SetTerminalTitle(title string)
- func SetTheme(name string)
- func SetThemeByName(name string)
- func SetThemeRegistry(r *ThemeRegistry)
- func SetThemeSetting(themeSetting string)
- func ShellToolPrompt(toolName string) (prompt string, ok bool)
- func ShouldDeliverKey(component Component, data string) bool
- func SupportsTrueColor() bool
- func TUIKeybindingDefinitionsFor(platform KeybindingPlatform) map[string]TUIKeybindingDef
- func ThemeHexBg(hex string) string
- func ThemeHexFg(hex string) string
- func ToolErrorBgOpen() string
- func ToolPendingBgOpen() string
- func ToolSuccessBgOpen() string
- func TreeVisibleLines(terminalHeight int) int
- func UseWindowsKeybindings(goos string, getenv func(string) string) bool
- func UserMessageBgOpen() string
- func ValidateThemeJSON(label string, data []byte) error
- func WrapText(s string, width int) []string
- type AltScreenFlashContainer
- func (c *AltScreenFlashContainer) Dispose()
- func (c *AltScreenFlashContainer) Flash(message string, durationMs int)
- func (i *AltScreenFlashContainer) Invalidate()
- func (i *AltScreenFlashContainer) IsDirty() bool
- func (i *AltScreenFlashContainer) NeedsRedraw() bool
- func (c *AltScreenFlashContainer) Render(width int) []string
- type AltScreenSearchComponent
- func (c *AltScreenSearchComponent) Focused() bool
- func (c *AltScreenSearchComponent) GetNavigationDirectionAt(row, column int) int
- func (c *AltScreenSearchComponent) HandleInput(data string)
- func (c *AltScreenSearchComponent) Invalidate()
- func (c *AltScreenSearchComponent) Render(width int) []string
- func (c *AltScreenSearchComponent) SetFocused(value bool)
- func (c *AltScreenSearchComponent) SetHoveredNavigationDirection(direction int) bool
- func (c *AltScreenSearchComponent) SetResult(index, count int)
- type AltScreenSearchIndex
- type AltScreenSearchMatch
- type AltScreenSearchSegment
- type AssistantMessageBlock
- func (i *AssistantMessageBlock) Invalidate()
- func (i *AssistantMessageBlock) IsDirty() bool
- func (i *AssistantMessageBlock) NeedsRedraw() bool
- func (b *AssistantMessageBlock) Render(width int) []string
- func (b *AssistantMessageBlock) SetContent(content []AssistantSegment)
- func (b *AssistantMessageBlock) SetHasToolCalls(v bool)
- func (b *AssistantMessageBlock) SetHiddenThinking(hidden bool)
- func (b *AssistantMessageBlock) SetMarkdownTransform(fn func(markdown string, width int) string)
- func (b *AssistantMessageBlock) SetMarkdownTransformState(fn func() string)
- func (b *AssistantMessageBlock) SetOutputPad(padding int)
- func (b *AssistantMessageBlock) SetTerminalError(stopReason, errorMessage string)
- func (b *AssistantMessageBlock) SetTextDelta(delta string)
- func (b *AssistantMessageBlock) SetThinkingDelta(delta string)
- func (b *AssistantMessageBlock) SetThinkingMarkdownTransform(fn func(markdown string, width int) string)
- func (b *AssistantMessageBlock) Text() string
- func (b *AssistantMessageBlock) Thinking() string
- type AssistantSegment
- type AsyncFileSearcher
- type AsyncSuggestionSource
- type AutocompleteItem
- type AutocompleteProvider
- type AutocompleteSuggestions
- type BaseComponent
- type BashExecutionBlock
- func (b *BashExecutionBlock) AppendOutput(chunk string)
- func (i *BashExecutionBlock) Invalidate()
- func (b *BashExecutionBlock) IsDirty() bool
- func (b *BashExecutionBlock) Loader() *Loader
- func (i *BashExecutionBlock) NeedsRedraw() bool
- func (b *BashExecutionBlock) Render(width int) []string
- func (b *BashExecutionBlock) SetComplete(exitCode *int, cancelled, truncated bool)
- func (b *BashExecutionBlock) SetCompleteWithOutput(exitCode *int, cancelled, truncated bool, output, fullOutputPath string)
- func (b *BashExecutionBlock) SetExpanded(expanded bool)
- type BorderedLoader
- func (bl *BorderedLoader) CancellableContext() *CancellableLoader
- func (bl *BorderedLoader) Dispose()
- func (bl *BorderedLoader) HandleInput(data string)
- func (i *BorderedLoader) Invalidate()
- func (i *BorderedLoader) IsDirty() bool
- func (i *BorderedLoader) NeedsRedraw() bool
- func (bl *BorderedLoader) NextFrame()
- func (bl *BorderedLoader) Render(width int) []string
- type Box
- func (b *Box) AddChild(component Component)
- func (b *Box) Clear()
- func (b *Box) HandleMouse(event TuiMouseEvent) *TuiMouseDispatchResult
- func (b *Box) Invalidate()
- func (i *Box) IsDirty() bool
- func (i *Box) NeedsRedraw() bool
- func (b *Box) RemoveChild(component Component)
- func (b *Box) Render(width int) []string
- func (b *Box) SetBgFn(bgFn func(string) string)
- type BranchSummaryComponent
- type CancellableLoader
- func (cl *CancellableLoader) Aborted() bool
- func (cl *CancellableLoader) Context() context.Context
- func (*CancellableLoader) Dispose()
- func (cl *CancellableLoader) HandleInput(data string)
- func (i *CancellableLoader) Invalidate()
- func (i *CancellableLoader) IsDirty() bool
- func (i *CancellableLoader) NeedsRedraw() bool
- func (cl *CancellableLoader) Signal() context.Context
- type CapabilityOverrides
- type CellDimensions
- type ColorMode
- type CombinedProvider
- func (p *CombinedProvider) ApplyCompletion(lines []string, cursorLine, cursorCol int, item AutocompleteItem, ...) ([]string, int, int)
- func (p *CombinedProvider) FileSearchTask(lines []string, cursorLine, cursorCol int) (string, func(context.Context) []AutocompleteItem, bool)
- func (p *CombinedProvider) GetSuggestions(lines []string, cursorLine, cursorCol int) *AutocompleteSuggestions
- func (p *CombinedProvider) GetSuggestionsForce(lines []string, cursorLine, cursorCol int) *AutocompleteSuggestions
- func (p *CombinedProvider) SetAsyncFileSearch(v bool)
- type CompactionSummaryComponent
- type Component
- type ConfigSelectorComponent
- func (cs *ConfigSelectorComponent) HandleInput(data string)
- func (i *ConfigSelectorComponent) Invalidate()
- func (i *ConfigSelectorComponent) IsDirty() bool
- func (i *ConfigSelectorComponent) NeedsRedraw() bool
- func (cs *ConfigSelectorComponent) Render(width int) []string
- func (cs *ConfigSelectorComponent) SetTerminalRows(rows int)
- type Container
- func (c *Container) Add(comp Component)
- func (c *Container) ChildCount() int
- func (c *Container) Clear()
- func (c *Container) HandleMouse(event TuiMouseEvent) *TuiMouseDispatchResult
- func (i *Container) Invalidate()
- func (i *Container) IsDirty() bool
- func (c *Container) IsEmpty() bool
- func (c *Container) LastTwoChildren() (Component, Component)
- func (i *Container) NeedsRedraw() bool
- func (c *Container) Remove(comp Component)
- func (c *Container) Render(width int) []string
- func (c *Container) Replace(oldComp, newComp Component) bool
- func (c *Container) SetChildren(children ...Component)
- func (c *Container) SetMaxLines(n int)
- type ConvertedImage
- type CountdownTimer
- type CustomMessage
- type CustomMessageComponent
- func (i *CustomMessageComponent) Invalidate()
- func (i *CustomMessageComponent) IsDirty() bool
- func (i *CustomMessageComponent) NeedsRedraw() bool
- func (c *CustomMessageComponent) Render(width int) []string
- func (c *CustomMessageComponent) SetExpanded(expanded bool)
- func (c *CustomMessageComponent) SetOutputPad(_ int)
- type DiffComponent
- type Disposable
- type DynamicBorder
- type Editor
- func (e *Editor) AddAsyncSuggestionSource(s AsyncSuggestionSource)
- func (e *Editor) AddToHistory(text string)
- func (e *Editor) AutocompleteAccept() (submit bool)
- func (e *Editor) AutocompleteCancel()
- func (e *Editor) AutocompleteMaxVisible() int
- func (e *Editor) AutocompleteMove(delta int)
- func (e *Editor) AutocompleteOpen() bool
- func (e *Editor) Clear()
- func (e *Editor) ClearAsyncSuggestionSources()
- func (e *Editor) ClearExtensionDecorations()
- func (e *Editor) ClearPastes()
- func (e *Editor) GetExpandedText() string
- func (e *Editor) HandleInput(data string)
- func (e *Editor) HandleMouse(event TuiMouseEvent) *TuiMouseDispatchResult
- func (e *Editor) InsertTextAtCursor(text string)
- func (i *Editor) Invalidate()
- func (e *Editor) IsBashMode() bool
- func (e *Editor) IsDirty() bool
- func (e *Editor) LockExtensionBorderColor()
- func (e *Editor) MaxVisibleLines() int
- func (e *Editor) NeedsRedraw() bool
- func (e *Editor) PaddingX() int
- func (e *Editor) Render(width int) []string
- func (e *Editor) SetAsyncApply(schedule func(func()))
- func (e *Editor) SetAutocomplete(p AutocompleteProvider)
- func (e *Editor) SetAutocompleteMaxVisible(maxVisible int)
- func (e *Editor) SetExtensionBorderColor(ansiPrefix, ansiSuffix string)
- func (e *Editor) SetExtensionModeLabel(label, ansiPrefix, ansiSuffix string)
- func (e *Editor) SetMaxVisibleLines(n int)
- func (e *Editor) SetPaddingX(padding int)
- func (e *Editor) SetText(text string)
- func (e *Editor) SetWorkingStatusIndicator(indicator *StatusIndicator)
- func (e *Editor) Text() string
- type ExtensionEditorComponent
- func (c *ExtensionEditorComponent) Cancelled() bool
- func (c *ExtensionEditorComponent) Done() bool
- func (c *ExtensionEditorComponent) HandleInput(data string)
- func (i *ExtensionEditorComponent) Invalidate()
- func (i *ExtensionEditorComponent) IsDirty() bool
- func (i *ExtensionEditorComponent) NeedsRedraw() bool
- func (c *ExtensionEditorComponent) Render(width int) []string
- func (c *ExtensionEditorComponent) SetDescription(description string)
- func (c *ExtensionEditorComponent) Value() string
- type ExtensionInputComponent
- func (e *ExtensionInputComponent) Cancelled() bool
- func (e *ExtensionInputComponent) Done() bool
- func (e *ExtensionInputComponent) HandleInput(data string)
- func (i *ExtensionInputComponent) Invalidate()
- func (i *ExtensionInputComponent) IsDirty() bool
- func (i *ExtensionInputComponent) NeedsRedraw() bool
- func (e *ExtensionInputComponent) Render(width int) []string
- func (e *ExtensionInputComponent) SetText(s string)
- func (e *ExtensionInputComponent) Text() string
- type ExtensionSelectorComponent
- func (e *ExtensionSelectorComponent) Cancelled() bool
- func (e *ExtensionSelectorComponent) Done() bool
- func (e *ExtensionSelectorComponent) HandleInput(data string)
- func (i *ExtensionSelectorComponent) Invalidate()
- func (i *ExtensionSelectorComponent) IsDirty() bool
- func (i *ExtensionSelectorComponent) NeedsRedraw() bool
- func (e *ExtensionSelectorComponent) Render(width int) []string
- func (e *ExtensionSelectorComponent) SelectedIndex() int
- func (e *ExtensionSelectorComponent) SelectedValue() string
- func (e *ExtensionSelectorComponent) SetDescription(description string)
- type FilterableList
- func (f *FilterableList) Cancelled() bool
- func (f *FilterableList) CursorIndex() int
- func (f *FilterableList) Done() bool
- func (f *FilterableList) FilterText() string
- func (f *FilterableList) HandleInput(data string)
- func (f *FilterableList) HandleMouse(event TuiMouseEvent) *TuiMouseDispatchResult
- func (i *FilterableList) Invalidate()
- func (i *FilterableList) IsDirty() bool
- func (i *FilterableList) NeedsRedraw() bool
- func (f *FilterableList) Render(width int) []string
- func (f *FilterableList) SelectedIndex() int
- func (f *FilterableList) SetCursor(idx int)
- type ForcefulAutocompleteProvider
- type FuzzyMatch
- type HStack
- type IdleStatus
- type Image
- type ImageBlock
- type ImageCellSize
- type ImageDimensions
- func GetGIFDimensions(base64Data string) *ImageDimensions
- func GetImageDimensions(base64Data, mimeType string) *ImageDimensions
- func GetJPEGDimensions(base64Data string) *ImageDimensions
- func GetPNGDimensions(base64Data string) *ImageDimensions
- func GetWebPDimensions(base64Data string) *ImageDimensions
- type ImageOptions
- type ImageProtocol
- type ImageRenderOptions
- type ImageTheme
- type InputHandler
- type InputOptions
- type KeyReleaseReceiver
- type KeybindingPlatform
- type KillRing
- type KittyImageConversion
- type KittyImageMetadata
- type KittyImagePlacement
- type LayoutBox
- type LayoutComponent
- type LayoutFrame
- type LayoutNode
- type LayoutRect
- type LayoutViewport
- type Loader
- type LoginDialog
- func (d *LoginDialog) Cancelled() bool
- func (d *LoginDialog) Done() bool
- func (d *LoginDialog) HandleInput(data string)
- func (i *LoginDialog) Invalidate()
- func (i *LoginDialog) IsDirty() bool
- func (i *LoginDialog) NeedsRedraw() bool
- func (d *LoginDialog) Render(width int) []string
- func (d *LoginDialog) ShowAuth(url, instructions string)
- func (d *LoginDialog) ShowInput(prompt, placeholder string) <-chan string
- func (d *LoginDialog) ShowProgress(msg string)
- func (d *LoginDialog) ShowWaiting(msg string)
- func (d *LoginDialog) Success()
- type Markdown
- type ModelItem
- type ModelScope
- type ModelSearchItem
- type ModelSelector
- func (m *ModelSelector) Cancelled() bool
- func (m *ModelSelector) Done() bool
- func (m *ModelSelector) HandleInput(data string)
- func (i *ModelSelector) Invalidate()
- func (i *ModelSelector) IsDirty() bool
- func (i *ModelSelector) NeedsRedraw() bool
- func (m *ModelSelector) Render(width int) []string
- func (m *ModelSelector) Scope() ModelScope
- func (m *ModelSelector) SelectedAsDefault() bool
- func (m *ModelSelector) SelectedFQ() string
- func (m *ModelSelector) SetDefaultModel(fq string)
- func (m *ModelSelector) SetError(text string)
- func (m *ModelSelector) SetFilter(query string)
- func (m *ModelSelector) SetRefreshSuccess(text string)
- func (m *ModelSelector) SetStatus(text string)
- func (m *ModelSelector) UpdateModels(models []ModelSelectorItem)
- func (m *ModelSelector) VisibleCount() int
- type ModelSelectorItem
- type ModifierKey
- type MouseHandler
- type MouseRegion
- type MouseRegionHandler
- type OAuthProvider
- type OAuthSelector
- func (s *OAuthSelector) Cancelled() bool
- func (s *OAuthSelector) Done() bool
- func (s *OAuthSelector) HandleInput(data string)
- func (i *OAuthSelector) Invalidate()
- func (i *OAuthSelector) IsDirty() bool
- func (i *OAuthSelector) NeedsRedraw() bool
- func (s *OAuthSelector) Render(width int) []string
- func (s *OAuthSelector) SelectedID() string
- type OverlayBounds
- type OverlayGeometry
- type OverlayHandle
- type OverlayMarginSpec
- type OverlayOptions
- type OverlaySpec
- type OverlayValue
- type ParsedSkillBlock
- type PlatformKeys
- type ProcessTerminal
- func (t *ProcessTerminal) ClearFromCursor()
- func (t *ProcessTerminal) ClearLine()
- func (t *ProcessTerminal) ClearScreen()
- func (t *ProcessTerminal) Columns() int
- func (t *ProcessTerminal) DrainInput(maxWait, idleWait time.Duration) error
- func (t *ProcessTerminal) EnterRawMode() (restore func(), err error)
- func (t *ProcessTerminal) HideCursor()
- func (*ProcessTerminal) KittyProtocolActive() bool
- func (t *ProcessTerminal) MoveBy(lines int)
- func (t *ProcessTerminal) Rows() int
- func (t *ProcessTerminal) SetProgress(active bool)
- func (t *ProcessTerminal) SetTitle(title string)
- func (t *ProcessTerminal) ShowCursor()
- func (t *ProcessTerminal) Start(onInput func([]byte), onResize func()) error
- func (t *ProcessTerminal) StartWithReadError(onInput func([]byte), onResize func(), onReadError func(error)) error
- func (t *ProcessTerminal) Stop()
- func (t *ProcessTerminal) Write(data string)
- type RefreshStatusKind
- type RenderOverflowError
- type Renderer
- type ResourceGroup
- type ResourceItem
- type ResourceSubgroup
- type ResourceType
- type RgbColor
- type ScopedModelsConfig
- type ScopedModelsList
- func (s *ScopedModelsList) ConsumeSave() ([]string, bool)
- func (s *ScopedModelsList) Done() bool
- func (s *ScopedModelsList) EnabledIDs() []string
- func (s *ScopedModelsList) HandleInput(data string)
- func (i *ScopedModelsList) Invalidate()
- func (i *ScopedModelsList) IsDirty() bool
- func (i *ScopedModelsList) NeedsRedraw() bool
- func (s *ScopedModelsList) Render(width int) []string
- func (s *ScopedModelsList) Result() ScopedModelsResult
- func (s *ScopedModelsList) SetRefreshStatus(message string, kind RefreshStatusKind)
- func (s *ScopedModelsList) UpdateModels(models []ModelItem, enabledIDs ...[]string)
- type ScopedModelsResult
- type ScrollLayoutNode
- type ScrollLayoutState
- type ScrollView
- func (s *ScrollView) Add(Component)
- func (s *ScrollView) Clear()
- func (s *ScrollView) Dispose()
- func (s *ScrollView) FollowEnd() bool
- func (s *ScrollView) GetContentWidth(width int) int
- func (i ScrollView) Invalidate()
- func (i ScrollView) IsDirty() bool
- func (s *ScrollView) IsFollowingEnd() bool
- func (s *ScrollView) IsScrollbarActive() bool
- func (s *ScrollView) IsScrollbarVisible() bool
- func (s *ScrollView) LayoutNode() LayoutNode
- func (i ScrollView) NeedsRedraw() bool
- func (s *ScrollView) Overscroll() string
- func (s *ScrollView) Primary() bool
- func (s *ScrollView) Remove(Component)
- func (s *ScrollView) Render(width int) []string
- func (s *ScrollView) ScrollBy(lines int) int
- func (s *ScrollView) ScrollTo(scrollTop int)
- func (s *ScrollView) ScrollToEnd()
- func (s *ScrollView) ScrollToStart()
- func (s *ScrollView) ScrollToWithOptions(scrollTop int, options ScrollViewScrollToOptions)
- func (s *ScrollView) ScrollTop() int
- func (s *ScrollView) Scrollbar() string
- func (s *ScrollView) ScrollbarThumbStyle() func(text string) string
- func (s *ScrollView) ScrollbarTrackStyle() func(text string) string
- func (s *ScrollView) SetScrollbar(scrollbar string)
- func (s *ScrollView) SetScrollbarActive(active bool)
- func (s *ScrollView) UpdateLayout(contentHeight, viewportHeight int, requestRender func())
- func (s *ScrollView) ViewportHeight() int
- type ScrollViewOptions
- type ScrollViewScrollToOptions
- type ScrollbarGeometry
- type SelectItem
- type SelectListTruncatePrimaryContext
- type SelectSubmenuComponent
- func (s *SelectSubmenuComponent) Cancelled() bool
- func (s *SelectSubmenuComponent) CurrentValue() string
- func (s *SelectSubmenuComponent) Done() bool
- func (s *SelectSubmenuComponent) HandleInput(data string)
- func (i *SelectSubmenuComponent) Invalidate()
- func (i *SelectSubmenuComponent) IsDirty() bool
- func (i *SelectSubmenuComponent) NeedsRedraw() bool
- func (s *SelectSubmenuComponent) Render(width int) []string
- func (s *SelectSubmenuComponent) SelectedValue() string
- func (s *SelectSubmenuComponent) String() string
- type SelectSubmenuOptions
- type SettingItem
- type SettingsList
- func (s *SettingsList) Cancelled() bool
- func (s *SettingsList) Done() bool
- func (s *SettingsList) HandleInput(data string)
- func (s *SettingsList) HandleMouse(event TuiMouseEvent) *TuiMouseDispatchResult
- func (i *SettingsList) Invalidate()
- func (i *SettingsList) IsDirty() bool
- func (i *SettingsList) NeedsRedraw() bool
- func (s *SettingsList) Render(width int) []string
- func (s *SettingsList) Reset()
- func (s *SettingsList) UpdateValue(id, newValue string)
- type ShowImagesSelectorComponent
- func (s *ShowImagesSelectorComponent) HandleInput(data string)
- func (i *ShowImagesSelectorComponent) Invalidate()
- func (i *ShowImagesSelectorComponent) IsDirty() bool
- func (s *ShowImagesSelectorComponent) List() *FilterableList
- func (i *ShowImagesSelectorComponent) NeedsRedraw() bool
- func (s *ShowImagesSelectorComponent) Render(width int) []string
- func (s *ShowImagesSelectorComponent) SelectedShowImages() (bool, bool)
- type SkillInvocationMessageComponent
- func (i *SkillInvocationMessageComponent) Invalidate()
- func (i *SkillInvocationMessageComponent) IsDirty() bool
- func (i *SkillInvocationMessageComponent) NeedsRedraw() bool
- func (s *SkillInvocationMessageComponent) Render(width int) []string
- func (s *SkillInvocationMessageComponent) SetExpanded(expanded bool)
- type SlashCommand
- type SlashOnlyProvider
- type Spacer
- type Stack
- func (s *Stack) Add(component Component)
- func (s *Stack) AddChild(component Component, options StackEntryOptions)
- func (s *Stack) Clear()
- func (i Stack) Invalidate()
- func (i Stack) IsDirty() bool
- func (s *Stack) LayoutNode() LayoutNode
- func (i Stack) NeedsRedraw() bool
- func (s *Stack) Remove(component Component)
- func (s *Stack) RemoveChild(component Component)
- type StackChild
- type StackEntryOptions
- type StackLayoutEntry
- type StackLayoutNode
- type StackOptions
- type StaticText
- type StatusIndicator
- type StopOptions
- type TUI
- func (t *TUI) ActiveOverlay() Component
- func (t *TUI) CancelPendingRender()
- func (t *TUI) CaptureRenderState() TUIRenderState
- func (t *TUI) ConsumeCellSizeResponse(data string) bool
- func (t *TUI) FocusedComponent() Component
- func (t *TUI) ForceFullRender()
- func (t *TUI) GetClearOnShrink() bool
- func (t *TUI) GetShowHardwareCursor() bool
- func (t *TUI) HasOverlay() bool
- func (t *TUI) Height() int
- func (t *TUI) HideCursor()
- func (t *TUI) OpenOverlay(c Component, opts OverlayOptions) *OverlayHandle
- func (t *TUI) QueryCellSize()
- func (t *TUI) Render()
- func (t *TUI) RenderSnapshot(width int) []string
- func (t *TUI) RepaintAll()
- func (t *TUI) RequestRender()
- func (t *TUI) RestoreRenderState(state TUIRenderState)
- func (t *TUI) SetClearOnShrink(enabled bool)
- func (t *TUI) SetFixedSize(cols, rows int)
- func (t *TUI) SetFocus(component Component)
- func (t *TUI) SetLogDirectory(dir string)
- func (t *TUI) SetOnHeightChange(fn func(height int))
- func (t *TUI) SetOnWidthChange(fn func(width int))
- func (t *TUI) SetOverlayCommandDispatcher(dispatch func(func()))
- func (t *TUI) SetRenderDispatcher(dispatch func(render func()))
- func (t *TUI) SetShowHardwareCursor(enabled bool)
- func (t *TUI) SetTickDispatcher(dispatch func(func()))
- func (t *TUI) ShowCursor()
- func (t *TUI) Stop()
- func (t *TUI) StopWithOptions(options StopOptions)
- func (t *TUI) Width() int
- type TUIKeybinding
- type TUIKeybindingConflict
- type TUIKeybindingDef
- type TUIKeybindingsManager
- func GetKeybindings() *TUIKeybindingsManager
- func GetTUIKeybindings() *TUIKeybindingsManager
- func NewKeybindingsManager(definitions map[string]TUIKeybindingDef, userBindings map[string][]string) *TUIKeybindingsManager
- func NewTUIKeybindingsManager(userBindings map[string][]string) *TUIKeybindingsManager
- func (m *TUIKeybindingsManager) GetConflicts() []TUIKeybindingConflict
- func (m *TUIKeybindingsManager) GetDefinition(action TUIKeybinding) (TUIKeybindingDef, bool)
- func (m *TUIKeybindingsManager) GetKeys(action TUIKeybinding) []string
- func (m *TUIKeybindingsManager) GetResolvedBindings() map[string]any
- func (m *TUIKeybindingsManager) GetUserBindings() map[string][]string
- func (m *TUIKeybindingsManager) HasBinding(action TUIKeybinding) bool
- func (m *TUIKeybindingsManager) Matches(data string, action TUIKeybinding) bool
- func (m *TUIKeybindingsManager) SetUserBindings(bindings map[string][]string)
- type TUIRenderState
- type Terminal
- type TerminalCapabilities
- type TerminalTheme
- type TerminalThemeDetection
- type TerminalThemeDetectionOptions
- type Text
- type TextInput
- func (t *TextInput) Cancelled() bool
- func (t *TextInput) Done() bool
- func (t *TextInput) HandleInput(data string)
- func (t *TextInput) HandleMouse(event TuiMouseEvent) *TuiMouseDispatchResult
- func (i *TextInput) Invalidate()
- func (i *TextInput) IsDirty() bool
- func (i *TextInput) NeedsRedraw() bool
- func (t *TextInput) Render(width int) []string
- func (t *TextInput) SetText(s string)
- func (t *TextInput) Text() string
- type Theme
- func (t *Theme) ANSIPalette() (map[string]string, map[string]string)
- func (t *Theme) Bg(token string) string
- func (t *Theme) ColorKeys() []string
- func (t *Theme) ColorMode() ColorMode
- func (t *Theme) Colors() map[string]string
- func (t *Theme) Fg(token string) string
- func (t *Theme) FgText(token, text string) string
- func (t *Theme) Inverse(text string) string
- func (t *Theme) WithColorMode(mode ColorMode) *Theme
- type ThemeColorValue
- type ThemeJSON
- type ThemeRegistry
- type ThemeSelectorComponent
- func (ts *ThemeSelectorComponent) HandleInput(data string)
- func (i *ThemeSelectorComponent) Invalidate()
- func (i *ThemeSelectorComponent) IsDirty() bool
- func (ts *ThemeSelectorComponent) List() *FilterableList
- func (i *ThemeSelectorComponent) NeedsRedraw() bool
- func (ts *ThemeSelectorComponent) Render(width int) []string
- type ThinkingBlock
- func (b *ThinkingBlock) Content() string
- func (i *ThinkingBlock) Invalidate()
- func (i *ThinkingBlock) IsDirty() bool
- func (i *ThinkingBlock) NeedsRedraw() bool
- func (b *ThinkingBlock) Render(width int) []string
- func (b *ThinkingBlock) SetContent(content string)
- func (b *ThinkingBlock) SetHidden(hidden bool)
- type ToolExecutionComponent
- func (c *ToolExecutionComponent) ApplyConvertedImage(req KittyImageConversion, converted *ConvertedImage) bool
- func (c *ToolExecutionComponent) Collapse()
- func (c *ToolExecutionComponent) Expand()
- func (c *ToolExecutionComponent) FinalizeAborted(elapsed time.Duration)
- func (i *ToolExecutionComponent) Invalidate()
- func (c *ToolExecutionComponent) IsDirty() bool
- func (c *ToolExecutionComponent) MarkExecutionStarted()
- func (i *ToolExecutionComponent) NeedsRedraw() bool
- func (c *ToolExecutionComponent) PendingKittyImageConversions() []KittyImageConversion
- func (c *ToolExecutionComponent) Render(width int) []string
- func (c *ToolExecutionComponent) SetArgsComplete()
- func (c *ToolExecutionComponent) SetExpanded(expanded bool)
- func (c *ToolExecutionComponent) SetImageWidthCells(width int)
- func (c *ToolExecutionComponent) SetResult(output string, isError bool, elapsed time.Duration)
- func (c *ToolExecutionComponent) SetRunning(argsPreview string)
- func (c *ToolExecutionComponent) SetShowImages(show bool)
- func (c *ToolExecutionComponent) SetStreaming(snapshot string)
- func (c *ToolExecutionComponent) SetStructuredArgs(args json.RawMessage)
- func (c *ToolExecutionComponent) Toggle()
- func (c *ToolExecutionComponent) UpdateArgs(name string, partialArgsJSON string)
- type ToolExecutionState
- type TreeNode
- type TreeNodeSearchableText
- type TreeNodeWithBranchLabel
- type TreeNodeWithFilterTags
- type TreeNodeWithLabelTimestamp
- type TreeSelect
- func (t *TreeSelect) Cancelled() bool
- func (t *TreeSelect) Done() bool
- func (t *TreeSelect) HandleInput(data string)
- func (i *TreeSelect) Invalidate()
- func (i *TreeSelect) IsDirty() bool
- func (i *TreeSelect) NeedsRedraw() bool
- func (t *TreeSelect) Render(width int) []string
- func (t *TreeSelect) SelectedID() string
- func (t *TreeSelect) SetInitialCursor(currentLeafID, initialSelectedID string)
- type TruncatedText
- type TuiAltScreen
- func (t *TuiAltScreen) ActiveOverlay() Component
- func (t *TuiAltScreen) CancelPendingRender()
- func (t *TuiAltScreen) ConsumeCellSizeResponse(data string) bool
- func (t *TuiAltScreen) CopyActiveSelectionToClipboard() bool
- func (t *TuiAltScreen) Flash(message string, durationMs int)
- func (t *TuiAltScreen) FocusedComponent() Component
- func (t *TuiAltScreen) ForceFullRender()
- func (t *TuiAltScreen) GetCopyOnSelect() bool
- func (t *TuiAltScreen) GetShowHardwareCursor() bool
- func (t *TuiAltScreen) HandleFocusedSearchInput(data string) bool
- func (t *TuiAltScreen) HandleViewportInput(data string) bool
- func (t *TuiAltScreen) HasActiveSelection() bool
- func (t *TuiAltScreen) HasOverlay() bool
- func (t *TuiAltScreen) Height() int
- func (t *TuiAltScreen) HideCursor()
- func (t *TuiAltScreen) IsFollowingOutput() bool
- func (t *TuiAltScreen) IsSearchFocused() bool
- func (t *TuiAltScreen) Mode() string
- func (t *TuiAltScreen) OpenOverlay(c Component, opts OverlayOptions) *OverlayHandle
- func (t *TuiAltScreen) QueryCellSize()
- func (t *TuiAltScreen) Render()
- func (t *TuiAltScreen) RenderSnapshot(width int) []string
- func (t *TuiAltScreen) RepaintAll()
- func (t *TuiAltScreen) RequestRender()
- func (t *TuiAltScreen) ScrollBy(lines int)
- func (t *TuiAltScreen) ScrollToBottom()
- func (t *TuiAltScreen) ScrollToTop()
- func (t *TuiAltScreen) SetClearOnShrink(bool)
- func (t *TuiAltScreen) SetCopyOnSelect(enabled bool)
- func (t *TuiAltScreen) SetFixedSize(cols, rows int)
- func (t *TuiAltScreen) SetFocus(component Component)
- func (t *TuiAltScreen) SetLayoutRoot(component Component)
- func (t *TuiAltScreen) SetOnHeightChange(fn func(height int))
- func (t *TuiAltScreen) SetOnWidthChange(fn func(width int))
- func (t *TuiAltScreen) SetOverlayCommandDispatcher(dispatch func(func()))
- func (t *TuiAltScreen) SetRenderDispatcher(dispatch func(render func()))
- func (t *TuiAltScreen) SetShowHardwareCursor(enabled bool)
- func (t *TuiAltScreen) SetTickDispatcher(dispatch func(func()))
- func (t *TuiAltScreen) ShowCursor()
- func (t *TuiAltScreen) Start()
- func (t *TuiAltScreen) Stop()
- func (t *TuiAltScreen) StopWithOptions(options StopOptions)
- func (t *TuiAltScreen) ViewportTop() int
- func (t *TuiAltScreen) Width() int
- type TuiAltScreenOptions
- type TuiMouseButton
- type TuiMouseDispatchResult
- type TuiMouseDispatchTarget
- type TuiMouseEvent
- type TuiMouseEventResult
- type TuiMouseEventType
- type UndoStack
- type UserMessageBlock
- type UserMessageSelector
- func (s *UserMessageSelector) Cancelled() bool
- func (s *UserMessageSelector) Done() bool
- func (s *UserMessageSelector) HandleInput(data string)
- func (i *UserMessageSelector) Invalidate()
- func (i *UserMessageSelector) IsDirty() bool
- func (i *UserMessageSelector) NeedsRedraw() bool
- func (s *UserMessageSelector) Render(width int) []string
- func (s *UserMessageSelector) SelectedIndex() int
- type VStack
- type ViewportTUI
- type VisualTruncateResult
Constants ¶
const ( // Scoped SGR resets mirror upstream Pi's theme helpers: // foreground styles close with 39m and background styles close with 49m. // Avoid using SGRResetAll inside bg-painted content because it also clears // background color and creates visual gaps/stripes. SGRResetAll = "\x1b[0m" SGRFgReset = "\x1b[39m" SGRBgReset = "\x1b[49m" SGRBoldDimReset = "\x1b[22m" SGRItalicReset = "\x1b[23m" SGRUnderlineReset = "\x1b[24m" SGRInverseReset = "\x1b[27m" SGRStrikeReset = "\x1b[29m" )
const TUICrashLogName = "pig-tui-crash.log"
TUICrashLogName is the crash log written when an over-wide row reaches the main screen's differential-render loop. Upstream writes pi-tui-crash.log; PiG uses its own product prefix, as it does for pig-debug.log.
Variables ¶
var DefaultSpinnerFrames = []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}
DefaultSpinnerFrames is the Braille spinner used by upstream.
var KeybindingPlatforms = []KeybindingPlatform{ KeybindingPlatformDarwin, KeybindingPlatformLinux, KeybindingPlatformLinuxWSL, KeybindingPlatformWin32, }
KeybindingPlatforms lists every platform column in inventory order.
Functions ¶
func ActionKeyDisplayText ¶
ActionKeyDisplayText formats every key the registry binds to action, capitalized and joined by "/", or "" when none is bound. Mirrors upstream keyDisplayText (coding-agent keybinding-hints.ts).
func ActionKeyDisplayTextOr ¶
ActionKeyDisplayTextOr is ActionKeyDisplayText for an action that may not be registered (app actions outside the interactive mode, such as in component tests), falling back to the upstream default keys.
func AllocateImageID ¶
func AllocateImageID() int
func AppKeyText ¶
AppKeyText formats the resolved keys for an app-level keybinding, falling back to the provided default raw key text when no resolver is installed.
func BuildTerminalTitle ¶
BuildTerminalTitle formats the pig terminal title from a session name (may be empty) and a cwd path. Matches upstream interactive-mode.ts pattern using APP_TITLE semantics.
func CalculateImageRows ¶
func CalculateImageRows(imageDimensions ImageDimensions, targetWidthCells int, dims CellDimensions) int
func CropKittyImageLine ¶
CropKittyImageLine rewrites a Kitty image line to show only rows [hiddenRows, hiddenRows+visibleRows) of the source image, adjusting the y/h/r controls. Returns the line unchanged when it carries no registered image or the crop is a no-op. Mirrors upstream cropKittyImageLine.
func CustomMessageText ¶
func CustomMessageText(cm *CustomMessage) string
CustomMessageText extracts text from a CustomMessage's Content field.
func DecodeKittyPrintable ¶
DecodeKittyPrintable decodes a printable Kitty CSI-u sequence into the corresponding character. Mirrors upstream decodeKittyPrintable().
func DecodePrintableKey ¶
DecodePrintableKey decodes printable terminal sequences from either Kitty CSI-u or xterm modifyOtherKeys formats.
func DeleteAllKittyImages ¶
func DeleteAllKittyImages() string
func DeleteAllKittyPlacements ¶
func DeleteAllKittyPlacements() string
DeleteAllKittyPlacements removes every Kitty image placement (visible renderings) while leaving the transmitted image data intact. Mirrors upstream deleteAllKittyPlacements.
func DeleteKittyImage ¶
func DetectTheme ¶
func DetectTheme()
DetectTheme auto-detects dark/light mode and sets the active theme. Uses COLORFGBG env var (same heuristic as upstream theme.ts). Falls back to dark if detection fails.
func EncodeITerm2 ¶
func EncodeKitty ¶
func EnterRawMode ¶
func EnterRawMode() (restore func(), err error)
EnterRawMode puts stdin into raw mode and returns a restore function.
This preserves pig's main-buffer rendering model from `tui.go`: no alternate screen, no hidden terminal reader, and callers continue to own the input loop.
func FgSeq ¶
FgSeq returns the SGR foreground sequence for c: 24-bit (38;2) when trueColor, else the nearest 256-color (38;5). BgSeq is the background equivalent.
func FormatAuthSelectorProviderType ¶
FormatAuthSelectorProviderType mirrors upstream formatAuthSelectorProviderType.
func FormatBashHeader ¶
func FormatBashHeader(raw json.RawMessage) string
FormatBashHeader returns the styled `$ command` header for bash tool calls.
func FormatBuiltinToolHeader ¶
func FormatBuiltinToolHeader(toolName string, args json.RawMessage, cwd string) string
FormatBuiltinToolHeader dispatches to the per-tool header formatter matching upstream's renderCall functions. cwd resolves relative paths to absolute file:// URLs for the OSC-8 hyperlink. Returns "" if the tool has no custom header format (falls back to FormatToolArgs).
func FormatEditHeader ¶
func FormatEditHeader(raw json.RawMessage, cwd string) string
FormatEditHeader returns the styled `edit <path>` header for edit tool calls. Mirrors upstream edit.ts formatEditCall.
func FormatFindHeader ¶
func FormatFindHeader(raw json.RawMessage) string
FormatFindHeader returns the styled find call. Mirrors upstream renderers/find.ts formatFindCall.
func FormatGrepHeader ¶
func FormatGrepHeader(raw json.RawMessage) string
FormatGrepHeader returns the styled grep call. Mirrors upstream renderers/grep.ts formatGrepCall: bold toolTitle `grep`, accent `/pattern/`, toolOutput ` in <path>` ($HOME shortened, "." by default), then optional ` (glob)` and ` limit N` suffixes. Non-string pattern or path arguments render as the invalid-arg marker.
func FormatKeyText ¶
FormatKeyText formats a raw key string for UI display. It mirrors upstream formatKeyText by splitting alternate combos on "/" and combo parts on "+", mapping alt → option on macOS, and optionally capitalizing each part.
func FormatLsHeader ¶
func FormatLsHeader(raw json.RawMessage, cwd string) string
FormatLsHeader returns the styled ls call. Mirrors upstream renderers/ls.ts formatLsCall: renderToolPath with emptyFallback ".".
func FormatReadHeader ¶
func FormatReadHeader(raw json.RawMessage, cwd string) string
FormatReadHeader returns the styled `read <path>` header for read tool calls. Mirrors upstream read.ts formatReadCall: bold toolTitle `read`, the path via renderToolPath (accent + ~/ + OSC-8 link), and a warning- colored `:start-end` line range.
func FormatShellHeader ¶
func FormatShellHeader(raw json.RawMessage, prompt string) string
FormatShellHeader renders a shell tool call. Mirrors upstream formatShellCall: the whole `<prompt> <command>` is toolTitle-colored and bold, followed by a muted ` (timeout Ns)` suffix when the timeout argument is truthy. A non-string command renders as the error-colored invalid-arg marker; an empty or missing command renders as a toolOutput "...".
func FormatToolArgs ¶
func FormatToolArgs(raw json.RawMessage) string
FormatToolArgs renders a JSON object as a compact `key:val, key:val` preview suitable for the tool-call header. Falls back to the raw JSON for non-object inputs. Long string values are truncated with "\u2026" so the header never overflows the terminal width.
Examples:
{"path":"x","limit":10} \u2192 path:"x", limit:10
{"command":"git status --porcelain"} \u2192 command:"git status \u2026"
[] \u2192 []
func FormatToolDuration ¶
FormatToolDuration mirrors upstream renderers/bash.ts formatDuration over the integer milliseconds Date.now() differences produce: seconds with one decimal under a minute, then "Xm Ys", then "Xh Ym Zs".
func FormatWriteHeader ¶
func FormatWriteHeader(raw json.RawMessage, cwd string) string
FormatWriteHeader returns the styled `write <path>` header for write tool calls. Mirrors upstream write.ts formatWriteCall.
func FuzzyFilter ¶
FuzzyFilter sorts items best-match-first and drops non-matchers. Tokens (separated by whitespace or `/`, upstream `split(/[\s/]+/)`) AND together: each token must match, so "openai-codex/gpt-5.5" matches the reordered text "gpt-5.5 openai-codex". Empty/whitespace-only query returns items unchanged.
func GetAltScreenSearchMatchKey ¶
func GetAltScreenSearchMatchKey(match AltScreenSearchMatch) string
GetAltScreenSearchMatchKey identifies a match by its first and last cells. Mirrors upstream getAltScreenSearchMatchKey.
func GetDefaultTheme ¶
func GetDefaultTheme() string
func GetModelSearchText ¶
func GetModelSearchText(item ModelSearchItem) string
GetModelSearchText mirrors upstream getModelSearchText: the bare id leads, followed by the provider, the provider/id pair, provider and id again, and the name when present.
func GetModelSelectorSearchText ¶
func GetModelSelectorSearchText(item ModelSearchItem) string
GetModelSelectorSearchText mirrors upstream getModelSelectorSearchText. The /model selector search should rank exact provider-prefixed queries before proxy-provider IDs like openrouter/openai/gpt-5, so the bare model ID stays out of the leading position.
func HandleKeyboardProtocolNegotiationSequence ¶
HandleKeyboardProtocolNegotiationSequence consumes one complete Kitty-flags or Device Attributes response emitted by the active process terminal.
func HasBuiltInToolRenderers ¶
HasBuiltInToolRenderers reports whether upstream createAllToolRenderers has an entry for toolName. withBuiltInRenderers falls back to that entry for a registered definition (for example an extension override of a built-in name) that supplies no renderCall or renderResult of its own.
func HeaderForTool ¶
func HeaderForTool(name string, args json.RawMessage, cwd string) string
HeaderForTool returns the fully styled call header for any tool: the builtin per-tool formatter when one matches, otherwise the upstream default of a bold toolTitle tool name followed by its compact args (tool-execution.ts:136 / formatToolExecution). The returned string is self-styled; renderHeaderInner emits it verbatim.
func HighlightCode ¶
HighlightCode highlights a code string using the given language hint and returns the result split on newlines. Each returned line has the language's syntax tokens wrapped in the theme's syntax* foreground colors.
Mirrors upstream .upstream/current/packages/coding-agent/src/modes/interactive/theme/theme.ts::highlightCode (1099-1118 in v0.69.0). Upstream uses cli-highlight (a Node binding to highlight.js); pig uses chroma (pure-Go lexer set covering 200+ languages). The behaviour contract is the same: return one styled line per source line, or fall back to a single-color render when no lexer is available.
When lang is empty or unrecognized, returns each line wrapped in SyntaxComment-ish "code block" colour (matches upstream's mdCodeBlock fallback path).
func ImageFallback ¶
func ImageFallback(mimeType string, dimensions *ImageDimensions, filename string) string
func IsAppleTerminalSession ¶
func IsAppleTerminalSession() bool
IsAppleTerminalSession mirrors terminal.ts isAppleTerminalSession.
func IsImageLine ¶
IsImageLine reports whether the line contains Kitty or iTerm2 image protocol bytes. Mirrors upstream terminal-image.ts isImageLine().
func IsKeyRelease ¶
IsKeyRelease reports whether a raw input chunk is a Kitty key-release event (flag 2, ":3" variants). Bracketed-paste content is never treated as a release even when it contains ":3" byte patterns. Mirrors upstream isKeyRelease.
Prefer ShouldDeliverKey when routing input to a focused component; call this directly only from a raw-input consumer.
func IsKittyProtocolActive ¶
func IsKittyProtocolActive() bool
IsKittyProtocolActive reports whether a Kitty protocol response was seen during the current raw-mode session.
func IsNativeModifierPressed ¶
func IsNativeModifierPressed(key ModifierKey) bool
IsNativeModifierPressed mirrors upstream native-modifiers.ts isNativeModifierPressed: it asks the operating system whether a modifier key is held right now, and reports false when no helper is available.
func IsShellTool ¶
IsShellTool reports whether toolName uses the shared shell renderers.
func JSNumberString ¶
JSNumberString mirrors JavaScript Number.prototype.toString() for finite values: the shortest round-trip digits, in plain notation for magnitudes in [1e-6, 1e21) and exponent notation (e.g. "1e-7", "1e+21") outside it.
func JSToFixed ¶
JSToFixed mirrors JavaScript Number.prototype.toFixed(digits) for values below 1e21: it rounds the exact binary magnitude and an exact tie rounds away from zero, unlike Go's round-half-even "%.*f".
func JSToFixed1 ¶
JSToFixed1 mirrors JavaScript Number.prototype.toFixed(1) for a finite, non-negative value: it rounds the exact binary value to one decimal, and an exact tie rounds up (0.25 → "0.3"), unlike Go's round-half-even "%.1f".
func KeyDisplayText ¶
KeyDisplayText formats a raw key string in display form.
func KeyHint ¶
KeyHint formats a keybinding hint: dim key + muted description. Example: KeyHint("Esc", "cancel") → "\x1b[…Esc\x1b[0m \x1b[…cancel\x1b[0m"
func LanguageFromPath ¶
LanguageFromPath returns a language identifier for the given file path, or empty if no mapping exists. Mirrors upstream getLanguageFromPath in theme.ts:1015-1077. The extension table is kept in lock-step with upstream so a file rendered through `read` displays identically in both implementations.
func LoadThemeDir ¶
LoadThemeDir scans a directory for .json theme files and returns a map of name → *Theme. Mirrors upstream theme discovery.
func MatchesKeyID ¶
MatchesKeyID checks if raw terminal data matches a key identifier string like "ctrl+c", "ctrl+shift+z", "enter", etc. Exported for use by extension shortcut dispatch in interactive mode.
func NormalizeAppleTerminalInput ¶
NormalizeAppleTerminalInput mirrors terminal.ts normalizeAppleTerminalInput.
func NormalizeNativeShiftEnterInput ¶
func NormalizeNativeShiftEnterInput(data string, shouldDetectNativeShiftEnter, isShiftPressed bool) string
NormalizeNativeShiftEnterInput mirrors terminal.ts normalizeNativeShiftEnterInput: a plain Return read while the native Shift key is held becomes the enhanced Shift+Enter sequence.
func NormalizeProcessInputSequence ¶
NormalizeProcessInputSequence applies the input normalization of upstream ProcessTerminal.forwardInputSequence to one complete StdinBuffer sequence. Apple Terminal (and the Windows console) can send plain Return for Shift+Enter even with enhanced key reporting requested, so Pi asks the local OS whether Shift is held. Pig's input loops split sequences outside ProcessTerminal, so each loop calls this before dispatch.
func ParseAutoThemeSetting ¶
ParseAutoThemeSetting parses the upstream automatic theme setting format "lightTheme/darkTheme". Empty or malformed values are not automatic.
func ParseKey ¶
ParseKey parses terminal input into Pi's canonical key identifier. The bool is false when the input is not one recognized key.
func RGBTo256 ¶
RGBTo256 maps a 24-bit color to the nearest xterm-256 palette index, choosing between the 6x6x6 color cube (16-231) and the 24-step grayscale ramp (232-255) by squared RGB distance, so near-gray colors use the finer gray ramp rather than a coarse cube step.
func RawKeyHint ¶
RawKeyHint formats a raw key string without going through a keybinding registry. Mirrors upstream's rawKeyHint which skips the keybinding lookup.
func ReadInput ¶
ReadInput blocks until stdin yields non-negotiation input or a read error. Keyboard protocol replies are consumed without returning an empty event.
func RefreshActiveThemeColorMode ¶
func RefreshActiveThemeColorMode()
RefreshActiveThemeColorMode re-activates the active theme in the color mode the terminal supports now. Upstream re-creates the theme from settings after applying capability overrides on reload.
func RegisterKittyImageMetadata ¶
func RegisterKittyImageMetadata(metadata KittyImageMetadata)
RegisterKittyImageMetadata records metadata for a transmitted Kitty image, evicting the oldest entry past the cap. Mirrors upstream registerKittyImageMetadata.
func RenderDiff ¶
RenderDiff renders a diff string with colored lines and intra-line highlighting. Uses theme colors for added/removed/context lines.
func RenderImage ¶
func RenderImage(base64Data string, imageDimensions ImageDimensions, options ImageRenderOptions) *renderedImage
func RenderIntraLineDiff ¶
RenderIntraLineDiff produces word-level diff with inverse highlighting on changes. Matches upstream's renderIntraLineDiff behavior.
func ResetCapabilitiesCache ¶
func ResetCapabilitiesCache()
func ResolveEscapeTimeoutMs ¶
ResolveEscapeTimeoutMs returns how long, in milliseconds, input handling waits for the rest of an escape sequence before dispatching a lone ESC as the Escape key. PI_TUI_ESC_TIMEOUT wins when it is a finite positive number; SSH sessions default to 100ms because legacy Alt+key input is ESC plus another byte and high-latency transports split them. Mirrors upstream resolveEscapeTimeoutMs (terminal.ts).
func ResolveThemeSetting ¶
func ResolveThemeSetting(themeSetting string, terminalTheme TerminalTheme) (string, bool)
ResolveThemeSetting resolves a stored theme setting to the concrete theme name for the detected terminal appearance. Non-automatic settings resolve to themselves unless they are malformed slash values.
func RestoreTerminalFromSignal ¶
func RestoreTerminalFromSignal() bool
RestoreTerminalFromSignal returns the terminal to the mode it had before pig took it over, and reports whether there was anything to restore.
This is the subset of raw-mode teardown that is safe to run from a signal goroutine: it disables the extended-key protocols in a single write and then runs one tcsetattr against a state captured at startup. It deliberately skips the rest of the normal teardown, which drains stdin for up to a second, because that would race the input reader and the render loop.
Without the tcsetattr, exiting on a signal leaves the terminal raw: ISIG stays off, so the user's shell has no working Ctrl+C until they run `reset`. Without the protocol disable, the Kitty flags pig pushed stay on the terminal's stack after pig is gone, so the shell that inherits the terminal receives CSI-u encoded keys it does not understand.
func SetAppKeyTextResolver ¶
SetAppKeyTextResolver installs a resolver for app-level keybinding IDs (for example, `app.tree.foldOrUp`) used by TUI components that can't import the codingagent package directly.
func SetCapabilities ¶
func SetCapabilities(caps TerminalCapabilities)
SetCapabilities overrides the cached capabilities. Mirrors upstream setCapabilities.
func SetCapabilityOverrides ¶
func SetCapabilityOverrides(overrides CapabilityOverrides)
SetCapabilityOverrides mirrors upstream setCapabilityOverrides: it replaces the overrides and drops the cache only when a field changed.
func SetCellDimensions ¶
func SetCellDimensions(dims CellDimensions)
func SetKeybindings ¶
func SetKeybindings(kb *TUIKeybindingsManager)
SetKeybindings mirrors upstream setKeybindings().
func SetKittyProtocolActive ¶
func SetKittyProtocolActive(active bool)
SetKittyProtocolActive mirrors upstream keys.ts global Kitty state.
func SetTUIKeybindings ¶
func SetTUIKeybindings(kb *TUIKeybindingsManager)
SetTUIKeybindings sets the global TUI keybinding manager.
func SetTerminalProgress ¶
func SetTerminalProgress(active bool)
SetTerminalProgress toggles the OSC 9;4 terminal progress indicator.
func SetTerminalTitle ¶
func SetTerminalTitle(title string)
SetTerminalTitle writes an OSC 0 sequence to stdout to update the terminal window title. An empty title clears back to terminal default.
func SetTheme ¶
func SetTheme(name string)
SetTheme switches the active theme by name ("dark" or "light").
func SetThemeByName ¶
func SetThemeByName(name string)
SetThemeByName switches the active theme using the global registry. Falls back to the built-in dark theme if name is not found.
func SetThemeRegistry ¶
func SetThemeRegistry(r *ThemeRegistry)
SetThemeRegistry sets the global theme registry.
func SetThemeSetting ¶
func SetThemeSetting(themeSetting string)
SetThemeSetting applies a stored theme setting. An empty setting means automatic built-in dark/light detection; a light/dark automatic setting may resolve to any registered theme name.
func ShellToolPrompt ¶
ShellToolPrompt returns the prompt upstream createAllToolRenderers assigns to a built-in shell tool: createShellRenderers("$") for bash and createShellRenderers("PS>") for powershell. ok is false for other tools.
func ShouldDeliverKey ¶
ShouldDeliverKey reports whether a raw input chunk may be handed to a focused component's HandleInput. Kitty key releases are dropped unless the component implements KeyReleaseReceiver and opts in.
This is the single decision point for focused-component key delivery, and every such handoff must route through it. A component that acts on a release fires each keystroke twice, because extendedKeyInit pushes \x1b[>7u, whose flag 2 makes the terminal report press, repeat, and release. Scattering the check across dispatch sites is what let extension dialogs move a selector cursor two rows per arrow press: the filter existed, but an earlier return bypassed it.
Raw-input consumers are a different contract and must not use this: terminal input listeners, alt-screen viewport handling, and extension shortcut listeners all see unfiltered input by design, matching upstream's addInputListener and handleViewportInput.
Mirrors upstream tui.ts:887 (isKeyRelease(data) && !wantsKeyRelease -> drop).
func SupportsTrueColor ¶
func SupportsTrueColor() bool
SupportsTrueColor reports whether the terminal advertises 24-bit color via the COLORTERM hint (truecolor/24bit) or Windows Terminal, matching the probe in DetectTerminalCapabilities. Terminals without the hint (Apple Terminal.app, plain xterm-256color) are treated as 256-color so callers downsample instead of emitting 24-bit SGR the terminal ignores, which would otherwise render the half-block art as a single default color.
func TUIKeybindingDefinitionsFor ¶
func TUIKeybindingDefinitionsFor(platform KeybindingPlatform) map[string]TUIKeybindingDef
TUIKeybindingDefinitionsFor returns the tui.* definition table for a platform: upstream TUI_KEYBINDINGS (packages/tui/src/keybindings.ts) with the per-platform tui.* defaults that coding-agent's KEYBINDINGS applies on top (core/keybindings.ts). Every call returns a fresh map.
func ThemeHexBg ¶
ThemeHexBg returns the active theme's background escape for a fixed hex color, in the theme's color mode.
func ThemeHexFg ¶
ThemeHexFg returns the active theme's foreground escape for a fixed hex color, in the theme's color mode.
func ToolErrorBgOpen ¶
func ToolErrorBgOpen() string
func ToolPendingBgOpen ¶
func ToolPendingBgOpen() string
func ToolSuccessBgOpen ¶
func ToolSuccessBgOpen() string
func TreeVisibleLines ¶
NewTreeSelect builds the flattened view from the given root. Root itself is not rendered; only its children.
Indent + connector rules mirror upstream tree-selector.ts:143-260 (flattenTree) and :631-666 (per-row prefix construction). Single-child chains stay at the same indent and skip the connector glyph; only branch points (parent with > 1 children) bump indent and draw `├─`/`└─`. TreeVisibleLines is upstream TreeSelectorComponent's row budget for a terminal of the given height.
func UseWindowsKeybindings ¶
UseWindowsKeybindings reports whether Windows default keys apply: native Windows, or Linux under WSL. WT_SESSION alone does not count, because Windows Terminal also hosts SSH sessions to other machines. Mirrors upstream useWindowsKeybindings(platform, env) in core/keybindings.ts; goos uses Go's runtime.GOOS names.
func UserMessageBgOpen ¶
func UserMessageBgOpen() string
Convenience accessors for component code that paints backgrounds. These read from the active theme so dark/light mode works automatically.
func ValidateThemeJSON ¶
ValidateThemeJSON validates one theme document (JSON text without a BOM) and returns an error naming the offending tokens, or nil. Mirrors upstream validateThemeJson.
Types ¶
type AltScreenFlashContainer ¶
type AltScreenFlashContainer struct {
// contains filtered or unexported fields
}
AltScreenFlashContainer holds transient reverse-video messages composited by the alternate-screen renderer. Ports pi-tui's AltScreenFlashContainer.
Forced Go mechanic: upstream's single-loop setTimeout(...).unref() removal is an owned time.AfterFunc guarded by a mutex, because each timer fires on its own goroutine and races Render/Flash/Dispose. The per-entry id is the identity guard: a fired-but-already-removed callback finds its id gone and no-ops. The requestRender callback runs after the lock is released so slow render work never holds the mutex. Go timers never keep the process alive, so unref() has no Go counterpart; Dispose stops every timer to avoid a goroutine leak.
func NewAltScreenFlashContainer ¶
func NewAltScreenFlashContainer(requestRender func()) *AltScreenFlashContainer
NewAltScreenFlashContainer constructs a flash container that calls requestRender whenever the visible set changes.
func (*AltScreenFlashContainer) Dispose ¶
func (c *AltScreenFlashContainer) Dispose()
Dispose stops all pending timers and clears the visible set.
func (*AltScreenFlashContainer) Flash ¶
func (c *AltScreenFlashContainer) Flash(message string, durationMs int)
Flash shows message in reverse video for durationMs, then removes it. The caller supplies altScreenFlashDefaultDurationMS for the optional upstream default; an explicit zero or negative duration is clamped to zero like Math.max(0, durationMs).
func (*AltScreenFlashContainer) Invalidate ¶
func (i *AltScreenFlashContainer) Invalidate()
func (*AltScreenFlashContainer) NeedsRedraw ¶
func (i *AltScreenFlashContainer) NeedsRedraw() bool
func (*AltScreenFlashContainer) Render ¶
func (c *AltScreenFlashContainer) Render(width int) []string
Render returns one reverse-video line per active flash, each padded-spaced and truncated to width. Mirrors upstream render.
type AltScreenSearchComponent ¶
type AltScreenSearchComponent struct {
// contains filtered or unexported fields
}
AltScreenSearchComponent is the transcript search box: an input, a result counter, and previous/next buttons in its bottom border. Mirrors upstream AltScreenSearchComponent. Navigation directions are -1 (previous), 1 (next), and 0 (none, upstream undefined).
func NewAltScreenSearchComponent ¶
func NewAltScreenSearchComponent(onQueryChange func(query string), navigationButtonStyle func(text string, hovered bool) string) *AltScreenSearchComponent
NewAltScreenSearchComponent creates the search box. A nil navigationButtonStyle leaves the buttons unstyled.
func (*AltScreenSearchComponent) Focused ¶
func (c *AltScreenSearchComponent) Focused() bool
Focused reports the Focusable state. Mirrors upstream get focused.
func (*AltScreenSearchComponent) GetNavigationDirectionAt ¶
func (c *AltScreenSearchComponent) GetNavigationDirectionAt(row, column int) int
GetNavigationDirectionAt returns the button under a component-local cell.
func (*AltScreenSearchComponent) HandleInput ¶
func (c *AltScreenSearchComponent) HandleInput(data string)
HandleInput edits the query and reports a changed query.
func (*AltScreenSearchComponent) Invalidate ¶
func (c *AltScreenSearchComponent) Invalidate()
Invalidate invalidates the input.
func (*AltScreenSearchComponent) Render ¶
func (c *AltScreenSearchComponent) Render(width int) []string
Render draws the box: top border, input row, and a bottom border carrying the navigation buttons. Mirrors upstream AltScreenSearchComponent.render.
func (*AltScreenSearchComponent) SetFocused ¶
func (c *AltScreenSearchComponent) SetFocused(value bool)
SetFocused updates the Focusable state and forwards it to the input.
func (*AltScreenSearchComponent) SetHoveredNavigationDirection ¶
func (c *AltScreenSearchComponent) SetHoveredNavigationDirection(direction int) bool
SetHoveredNavigationDirection records the hovered button and reports whether it changed.
func (*AltScreenSearchComponent) SetResult ¶
func (c *AltScreenSearchComponent) SetResult(index, count int)
SetResult sets the displayed match index (-1 for none) and count.
type AltScreenSearchIndex ¶
type AltScreenSearchIndex struct {
// contains filtered or unexported fields
}
AltScreenSearchIndex caches the searchable corpus and matches while the rendered transcript lines remain unchanged. Mirrors upstream AltScreenSearchIndex.
func (*AltScreenSearchIndex) Search ¶
func (i *AltScreenSearchIndex) Search(lines []string, query string) (matches []AltScreenSearchMatch, changed bool)
Search returns the matches for query over lines and whether they changed since the previous call. Mirrors upstream AltScreenSearchIndex.search.
type AltScreenSearchMatch ¶
type AltScreenSearchMatch struct {
Segments []AltScreenSearchSegment
}
AltScreenSearchMatch is one match, possibly spanning rows. Mirrors upstream AltScreenSearchMatch.
func FindAltScreenSearchMatches ¶
func FindAltScreenSearchMatches(lines []string, query string) []AltScreenSearchMatch
FindAltScreenSearchMatches searches lines for query without caching. Mirrors upstream findAltScreenSearchMatches.
type AltScreenSearchSegment ¶
AltScreenSearchSegment is one row-local cell range of a match. Mirrors upstream AltScreenSearchSegment.
type AssistantMessageBlock ¶
type AssistantMessageBlock struct {
// contains filtered or unexported fields
}
AssistantMessageBlock renders ordered text/thinking content and terminal diagnostics for one assistant turn.
func NewAssistantMessageBlock ¶
func NewAssistantMessageBlock(hiddenThinking bool) *AssistantMessageBlock
NewAssistantMessageBlock creates an empty block. Pass hiddenThinking=true when the user has toggled thinking visibility off (Ctrl+T).
func (*AssistantMessageBlock) Invalidate ¶
func (i *AssistantMessageBlock) Invalidate()
func (*AssistantMessageBlock) NeedsRedraw ¶
func (i *AssistantMessageBlock) NeedsRedraw() bool
func (*AssistantMessageBlock) Render ¶
func (b *AssistantMessageBlock) Render(width int) []string
Render implements Component. Returns nil when thinking, text, and terminal error state are all empty.
func (*AssistantMessageBlock) SetContent ¶
func (b *AssistantMessageBlock) SetContent(content []AssistantSegment)
SetContent replaces text/thinking content in message order for streaming or redraw. Blocks are trimmed, empty ones skipped, and consecutive thinking blocks form one run joined by a blank line. An empty text segment preserves an invisible boundary such as a tool call.
func (*AssistantMessageBlock) SetHasToolCalls ¶
func (b *AssistantMessageBlock) SetHasToolCalls(v bool)
SetHasToolCalls records that the assistant message contains tool calls. When true, the abort/error section is suppressed: tool execution components show their own error state. Mirrors upstream assistant-message.ts:128: `if (!hasToolCalls) { ... }`.
func (*AssistantMessageBlock) SetHiddenThinking ¶
func (b *AssistantMessageBlock) SetHiddenThinking(hidden bool)
SetHiddenThinking controls whether the thinking trace renders as full text or as the "Thinking..." indicator. Mirrors upstream setHideThinkingBlock.
func (*AssistantMessageBlock) SetMarkdownTransform ¶
func (b *AssistantMessageBlock) SetMarkdownTransform(fn func(markdown string, width int) string)
SetMarkdownTransform installs a display-only rewrite applied to the text section at its render width, before markdown parsing. Mirrors upstream MarkdownOptions.transform threaded through createMarkdownTransform in assistant-message.ts:112. Used for the built-in Mermaid transformer.
func (*AssistantMessageBlock) SetMarkdownTransformState ¶
func (b *AssistantMessageBlock) SetMarkdownTransformState(fn func() string)
SetMarkdownTransformState declares the external state the installed transform reads, so a change to it re-renders instead of serving the cached lines. Required whenever the transform is not a pure function of (markdown, width).
func (*AssistantMessageBlock) SetOutputPad ¶
func (b *AssistantMessageBlock) SetOutputPad(padding int)
SetOutputPad changes the horizontal content padding.
func (*AssistantMessageBlock) SetTerminalError ¶
func (b *AssistantMessageBlock) SetTerminalError(stopReason, errorMessage string)
SetTerminalError records length/error/abort state after partial assistant content. An empty error message renders "Unknown error"; tool calls suppress abort/error but not length diagnostics.
func (*AssistantMessageBlock) SetTextDelta ¶
func (b *AssistantMessageBlock) SetTextDelta(delta string)
SetTextDelta appends to the current text block, or starts one after thinking.
func (*AssistantMessageBlock) SetThinkingDelta ¶
func (b *AssistantMessageBlock) SetThinkingDelta(delta string)
SetThinkingDelta appends to the current thinking block, or starts one after text.
func (*AssistantMessageBlock) SetThinkingMarkdownTransform ¶
func (b *AssistantMessageBlock) SetThinkingMarkdownTransform(fn func(markdown string, width int) string)
SetThinkingMarkdownTransform installs the display-only rewrite for visible thinking, separate from the assistant-text transform context. Hidden thinking does not invoke it.
func (*AssistantMessageBlock) Text ¶
func (b *AssistantMessageBlock) Text() string
Text returns concatenated untrimmed text blocks, without display transformations.
func (*AssistantMessageBlock) Thinking ¶
func (b *AssistantMessageBlock) Thinking() string
Thinking returns the accumulated thinking content.
type AssistantSegment ¶
AssistantSegment is one text or thinking content block of a complete assistant message, in message order.
type AsyncFileSearcher ¶
type AsyncFileSearcher interface {
FileSearchTask(lines []string, cursorLine, cursorCol int) (prefix string, run func(context.Context) []AutocompleteItem, ok bool)
}
AsyncFileSearcher is an optional capability of the local autocomplete provider: it returns a deferred fd-backed @-file search that the editor runs off the input thread with cancellation. Mirrors upstream's async getFuzzyFileSuggestions (autocomplete.ts:717) so a deep directory walk cannot block keystrokes. When ok is false the editor falls back to the synchronous GetSuggestions result.
type AsyncSuggestionSource ¶
type AsyncSuggestionSource interface {
Suggest(ctx context.Context, lines []string, cursorLine, cursorCol int) *AutocompleteSuggestions
}
AsyncSuggestionSource is a remote / async autocomplete provider installed via the extension API. Implementations send the buffer to some out-of-process source (subprocess shim, network, etc.) and return suggestions or nil. The supplied context is cancelled when the editor's buffer mutates so implementations should abort in-flight RPCs to avoid wasting work.
pig-specific: upstream extensions install AutocompleteProvider objects directly into the in-process chain. pig can't run a per-keystroke synchronous chain across the subprocess boundary, so the bridge layer adapts the upstream factory pattern to this out-of-band source interface.
type AutocompleteItem ¶
type AutocompleteItem struct {
Value string // text inserted at cursor on accept
Label string // displayed primary text
Description string // optional secondary text (dim)
}
AutocompleteItem is one popup row.
type AutocompleteProvider ¶
type AutocompleteProvider interface {
// GetSuggestions returns suggestions for the given buffer state.
// Return nil when no popup should be shown (no match, wrong context).
GetSuggestions(lines []string, cursorLine, cursorCol int) *AutocompleteSuggestions
// ApplyCompletion edits the buffer to insert `item.Value` in place
// of the trailing `prefix`. Returns the new buffer + cursor.
ApplyCompletion(lines []string, cursorLine, cursorCol int, item AutocompleteItem, prefix string) (newLines []string, newLine, newCol int)
}
AutocompleteProvider is the editor-facing surface. Synchronous - upstream's async/AbortController machinery is deferred until extension-supplied providers need it (out of scope for 2.6a).
type AutocompleteSuggestions ¶
type AutocompleteSuggestions struct {
Items []AutocompleteItem
Prefix string
}
AutocompleteSuggestions is the provider return shape. Prefix is the buffer slice the popup is matching against: applyCompletion uses its length to know how many chars to replace.
type BaseComponent ¶
type BaseComponent struct {
// contains filtered or unexported fields
}
BaseComponent is the exported equivalent of invalidatable for components living in other packages.
func (*BaseComponent) Invalidate ¶
func (i *BaseComponent) Invalidate()
func (*BaseComponent) NeedsRedraw ¶
func (i *BaseComponent) NeedsRedraw() bool
type BashExecutionBlock ¶
type BashExecutionBlock struct {
// contains filtered or unexported fields
}
BashExecutionBlock displays a `!cmd` invocation with streaming output, top/bottom borders, and expand/collapse support.
func NewBashExecutionBlock ¶
func NewBashExecutionBlock(command string, excludeFromContext bool) *BashExecutionBlock
NewBashExecutionBlock returns a freshly-constructed bash-execution component in the running state.
func (*BashExecutionBlock) AppendOutput ¶
func (b *BashExecutionBlock) AppendOutput(chunk string)
AppendOutput streams a sanitized chunk into the block.
func (*BashExecutionBlock) Invalidate ¶
func (i *BashExecutionBlock) Invalidate()
func (*BashExecutionBlock) IsDirty ¶
func (b *BashExecutionBlock) IsDirty() bool
IsDirty reports whether the block needs re-rendering. While running it embeds an animated Loader spinner advanced by the 100ms tick loop, but the tick ticks the loader without Invalidating this block. Reporting dirty while running keeps the per-child render cache from freezing the spinner.
func (*BashExecutionBlock) Loader ¶
func (b *BashExecutionBlock) Loader() *Loader
Loader returns the embedded spinner when the block is still running, nil otherwise. The animation driver ticks it to advance the spinner.
func (*BashExecutionBlock) NeedsRedraw ¶
func (i *BashExecutionBlock) NeedsRedraw() bool
func (*BashExecutionBlock) Render ¶
func (b *BashExecutionBlock) Render(width int) []string
Render produces the block's lines. Output wraps to the current terminal width, and collapsed previews retain the last previewLines visual rows.
func (*BashExecutionBlock) SetComplete ¶
func (b *BashExecutionBlock) SetComplete(exitCode *int, cancelled, truncated bool)
SetComplete transitions the block out of the running state.
func (*BashExecutionBlock) SetCompleteWithOutput ¶
func (b *BashExecutionBlock) SetCompleteWithOutput(exitCode *int, cancelled, truncated bool, output, fullOutputPath string)
SetCompleteWithOutput replaces the streaming preview with the durable truncated output and records its full-output path before completing the block.
func (*BashExecutionBlock) SetExpanded ¶
func (b *BashExecutionBlock) SetExpanded(expanded bool)
SetExpanded forces the body open (true) or collapsed-to-preview (false). Driven by the global Ctrl+O toggle so all bash blocks land in the same state as their tool-execution peers.
type BorderedLoader ¶
type BorderedLoader struct {
// contains filtered or unexported fields
}
BorderedLoader renders a loader between two horizontal borders, optionally with an Esc cancel hint.
func NewBorderedLoader ¶
func NewBorderedLoader(message string, cancellable bool) *BorderedLoader
NewBorderedLoader creates a bordered loader. When cancellable is true, an Esc cancel hint is shown and HandleInput cancels on Esc.
func (*BorderedLoader) CancellableContext ¶
func (bl *BorderedLoader) CancellableContext() *CancellableLoader
CancellableContext returns the cancellable loader's context, or nil.
func (*BorderedLoader) HandleInput ¶
func (bl *BorderedLoader) HandleInput(data string)
HandleInput delegates to the cancellable loader if present.
func (*BorderedLoader) Invalidate ¶
func (i *BorderedLoader) Invalidate()
func (*BorderedLoader) NeedsRedraw ¶
func (i *BorderedLoader) NeedsRedraw() bool
func (*BorderedLoader) NextFrame ¶
func (bl *BorderedLoader) NextFrame()
NextFrame advances the spinner animation.
func (*BorderedLoader) Render ¶
func (bl *BorderedLoader) Render(width int) []string
Render produces border + loader + optional hint + border.
type Box ¶
type Box struct {
PaddingX int
PaddingY int
BgFn func(string) string
// contains filtered or unexported fields
}
Box component - a container that applies padding and background to children.
func (*Box) HandleMouse ¶
func (b *Box) HandleMouse(event TuiMouseEvent) *TuiMouseDispatchResult
HandleMouse forwards an event inside the padded content area to the child under the pointer. Mirrors upstream Box.handleMouse.
func (*Box) Invalidate ¶
func (b *Box) Invalidate()
func (*Box) NeedsRedraw ¶
func (i *Box) NeedsRedraw() bool
func (*Box) RemoveChild ¶
type BranchSummaryComponent ¶
type BranchSummaryComponent struct {
// contains filtered or unexported fields
}
BranchSummaryComponent renders a branch-summary boundary marker in the chat transcript. Replaces the single-row BranchSummaryChip.
Upstream: components/branch-summary-message.ts (BranchSummaryMessageComponent).
func NewBranchSummaryComponent ¶
func NewBranchSummaryComponent(summary string) *BranchSummaryComponent
NewBranchSummaryComponent creates a branch summary component. summary is the LLM-generated markdown text summarising the abandoned branch.
func (*BranchSummaryComponent) Invalidate ¶
func (i *BranchSummaryComponent) Invalidate()
func (*BranchSummaryComponent) NeedsRedraw ¶
func (i *BranchSummaryComponent) NeedsRedraw() bool
func (*BranchSummaryComponent) Render ¶
func (c *BranchSummaryComponent) Render(width int) []string
Render returns the lines for this component at the given terminal width. All column measurements are delegated to paintBgWith (which uses lineDisplayWidth / runewidth.StringWidth internally).
func (*BranchSummaryComponent) SetExpanded ¶
func (c *BranchSummaryComponent) SetExpanded(expanded bool)
SetExpanded opens or collapses the component body. InteractiveMode calls it from the global Ctrl+O toggle.
type CancellableLoader ¶
type CancellableLoader struct {
Loader
OnAbort func()
// contains filtered or unexported fields
}
CancellableLoader extends Loader with Esc-key cancellation.
func NewCancellableLoader ¶
func NewCancellableLoader(spinnerColor, messageColor, message string, frames []string) *CancellableLoader
NewCancellableLoader creates a cancellable loader.
func (*CancellableLoader) Aborted ¶
func (cl *CancellableLoader) Aborted() bool
Aborted returns true if cancelled.
func (*CancellableLoader) Context ¶
func (cl *CancellableLoader) Context() context.Context
Context returns the cancellation context.
func (*CancellableLoader) Dispose ¶
func (*CancellableLoader) Dispose()
Dispose stops loader animation ownership. Loader animation is host-driven in Pig, so there is no local timer to stop and cancellation state is unchanged.
func (*CancellableLoader) HandleInput ¶
func (cl *CancellableLoader) HandleInput(data string)
HandleInput cancels on the registry-bound tui.select.cancel key.
func (*CancellableLoader) Invalidate ¶
func (i *CancellableLoader) Invalidate()
func (*CancellableLoader) NeedsRedraw ¶
func (i *CancellableLoader) NeedsRedraw() bool
func (*CancellableLoader) Signal ¶
func (cl *CancellableLoader) Signal() context.Context
Signal returns the underlying cancellation context.
type CapabilityOverrides ¶
type CapabilityOverrides struct {
Images *ImageProtocol
TrueColor *bool
Hyperlinks *bool
}
CapabilityOverrides mirrors upstream Partial<TerminalCapabilities> as passed to setCapabilityOverrides. A nil field is absent. Images points at "" for upstream's null (no image protocol).
type CellDimensions ¶
func GetCellDimensions ¶
func GetCellDimensions() CellDimensions
type CombinedProvider ¶
type CombinedProvider struct {
// contains filtered or unexported fields
}
CombinedProvider handles both slash-command and @-file autocomplete. Mirrors upstream CombinedAutocompleteProvider (autocomplete.ts:238).
func NewCombinedProvider ¶
func NewCombinedProvider(cmds []SlashCommand, baseDir, fdPath string) *CombinedProvider
NewCombinedProvider creates a provider that handles both slash commands and @-file autocomplete. If fdPath is empty, @-file completion uses os.ReadDir fallback (prefix match in target directory only, no fuzzy tree walk). Mirrors upstream CombinedAutocompleteProvider constructor (autocomplete.ts:244-248).
func (*CombinedProvider) ApplyCompletion ¶
func (p *CombinedProvider) ApplyCompletion(lines []string, cursorLine, cursorCol int, item AutocompleteItem, prefix string) ([]string, int, int)
ApplyCompletion implements AutocompleteProvider. Routes to @ or slash completion based on prefix shape.
func (*CombinedProvider) FileSearchTask ¶
func (p *CombinedProvider) FileSearchTask(lines []string, cursorLine, cursorCol int) (string, func(context.Context) []AutocompleteItem, bool)
FileSearchTask returns a deferred, cancellable fd-backed @-file search for the cursor's @-prefix, or ok=false when async file search is disabled, fd is unavailable, or the buffer-before-cursor is not an @ query. The returned run closure executes fd under the caller's context so the editor can abort it on the next keystroke, mirroring upstream's async getFuzzyFileSuggestions + AbortSignal (autocomplete.ts:717).
func (*CombinedProvider) GetSuggestions ¶
func (p *CombinedProvider) GetSuggestions(lines []string, cursorLine, cursorCol int) *AutocompleteSuggestions
GetSuggestions implements AutocompleteProvider. Tries @ prefix first, then slash. Naked-path completion is force-only in shipped upstream UX: the popup opens on Tab, not while typing `./foo`.
func (*CombinedProvider) GetSuggestionsForce ¶
func (p *CombinedProvider) GetSuggestionsForce(lines []string, cursorLine, cursorCol int) *AutocompleteSuggestions
GetSuggestionsForce mirrors upstream getSuggestions(..., {force: true}). Triggered by Tab outside a slash-command-name context to force naked path completion even when the prefix doesn't look path-like yet.
func (*CombinedProvider) SetAsyncFileSearch ¶
func (p *CombinedProvider) SetAsyncFileSearch(v bool)
SetAsyncFileSearch enables deferred, cancellable fd-backed @-file search. Interactive mode enables this so a slow tree walk cannot block keystrokes.
type CompactionSummaryComponent ¶
type CompactionSummaryComponent struct {
// contains filtered or unexported fields
}
CompactionSummaryComponent renders a collapsible compaction marker. It preserves Pi's horizontal and vertical Box padding.
func NewCompactionSummaryComponent ¶
func NewCompactionSummaryComponent(summary string, tokensBefore int) *CompactionSummaryComponent
NewCompactionSummaryComponent creates a compaction summary component. summary is the markdown text of the compaction context; tokensBefore is the LLM token count before compaction (shown in the header).
func (*CompactionSummaryComponent) Invalidate ¶
func (i *CompactionSummaryComponent) Invalidate()
func (*CompactionSummaryComponent) NeedsRedraw ¶
func (i *CompactionSummaryComponent) NeedsRedraw() bool
func (*CompactionSummaryComponent) Render ¶
func (c *CompactionSummaryComponent) Render(width int) []string
Render returns the lines for this component at the given terminal width. All column measurements are delegated to paintBgWith (which uses lineDisplayWidth / runewidth.StringWidth internally).
func (*CompactionSummaryComponent) SetExpanded ¶
func (c *CompactionSummaryComponent) SetExpanded(expanded bool)
SetExpanded opens or collapses the component body. InteractiveMode calls it from the global Ctrl+O toggle.
type Component ¶
type Component interface {
Render(width int) []string
// Invalidate marks the component as needing a redraw on the next tick.
Invalidate()
}
Component is the base interface all TUI widgets implement. Render returns a slice of ANSI-annotated lines (no trailing newlines). Width is the available terminal columns.
type ConfigSelectorComponent ¶
type ConfigSelectorComponent struct {
OnCancel func()
OnExit func()
OnToggle func(item *ResourceItem, enabled bool)
OnOverride func(item *ResourceItem, state string) error
// contains filtered or unexported fields
}
ConfigSelectorComponent manages the resource configuration overlay.
func NewConfigSelector ¶
func NewConfigSelector(groups []*ResourceGroup, terminalRows int) *ConfigSelectorComponent
NewConfigSelector creates a config selector from resolved resource groups.
func NewScopedConfigSelector ¶
func NewScopedConfigSelector(global, project []*ResourceGroup, terminalRows int, writeScope string, projectModeAvailable bool) *ConfigSelectorComponent
NewScopedConfigSelector creates the global/project selector used by pig config.
func (*ConfigSelectorComponent) HandleInput ¶
func (cs *ConfigSelectorComponent) HandleInput(data string)
HandleInput processes keyboard input.
func (*ConfigSelectorComponent) Invalidate ¶
func (i *ConfigSelectorComponent) Invalidate()
func (*ConfigSelectorComponent) NeedsRedraw ¶
func (i *ConfigSelectorComponent) NeedsRedraw() bool
func (*ConfigSelectorComponent) Render ¶
func (cs *ConfigSelectorComponent) Render(width int) []string
Render produces the config selector overlay.
func (*ConfigSelectorComponent) SetTerminalRows ¶
func (cs *ConfigSelectorComponent) SetTerminalRows(rows int)
SetTerminalRows updates the selector's view budget to track terminal height.
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container stacks child components vertically.
func NewContainer ¶
func (*Container) ChildCount ¶
func (*Container) Clear ¶
func (c *Container) Clear()
Clear removes every child component. Used by /clear and /new.
func (*Container) HandleMouse ¶
func (c *Container) HandleMouse(event TuiMouseEvent) *TuiMouseDispatchResult
HandleMouse forwards an event to the child under the pointer. Mirrors upstream Container.handleMouse. Upstream also rewrites a focus result's focusTarget to the container when a Container subclass handles keyboard input; Go embedding has no subclass identity, so a type that embeds Container and handles input must override HandleMouse to do the same.
func (*Container) Invalidate ¶
func (i *Container) Invalidate()
func (*Container) LastTwoChildren ¶
func (*Container) NeedsRedraw ¶
func (i *Container) NeedsRedraw() bool
func (*Container) Render ¶
Render returns a fresh slice, matching upstream Container.render's observable array ownership. Package renderers use renderBorrowed to read the immutable cached concatenation without copying settled transcript history every frame.
func (*Container) Replace ¶
Replace swaps oldComp with newComp at the same child index. Returns true if oldComp was found.
func (*Container) SetChildren ¶
SetChildren atomically replaces all children.
func (*Container) SetMaxLines ¶
SetMaxLines caps how many lines Render() returns. When n>0, only the last n lines of all children's output are returned. When n==0 (default), all lines are returned. Used by the /tree selector to keep the chat scrolled to a minimum context window. pig-specific: upstream controls the full viewport; this cap is not needed there.
type ConvertedImage ¶
ConvertedImage is a base64 image and its MIME type, the result of upstream image-convert.ts convertToPng.
type CountdownTimer ¶
type CountdownTimer struct {
// contains filtered or unexported fields
}
CountdownTimer counts down from a duration, calling OnTick each second and OnExpire when it reaches zero.
func NewCountdownTimer ¶
func NewCountdownTimer(timeout time.Duration, onTick func(int), onExpire func()) *CountdownTimer
NewCountdownTimer creates a timer. It calls onTick immediately with the initial seconds value, then starts a 1-second ticker.
type CustomMessage ¶
CustomMessage holds the data for a custom message entry. Mirrors the upstream CustomMessage<T> shape.
type CustomMessageComponent ¶
type CustomMessageComponent struct {
CustomType string
Content string // text content (may contain markdown)
Expanded bool
// contains filtered or unexported fields
}
CustomMessageComponent renders a custom message entry from extensions.
func NewCustomMessageComponent ¶
func NewCustomMessageComponent(customType, content string) *CustomMessageComponent
NewCustomMessageComponent creates a custom message renderer.
func (*CustomMessageComponent) Invalidate ¶
func (i *CustomMessageComponent) Invalidate()
func (*CustomMessageComponent) NeedsRedraw ¶
func (i *CustomMessageComponent) NeedsRedraw() bool
func (*CustomMessageComponent) Render ¶
func (c *CustomMessageComponent) Render(width int) []string
Render produces the custom message lines. Mirrors upstream CustomMessageComponent which extends Container with a Box(1,1,bgFn). The Box adds paddingX=1 (space indent) and paddingY=1 (blank rows) with bg tint.
func (*CustomMessageComponent) SetExpanded ¶
func (c *CustomMessageComponent) SetExpanded(expanded bool)
SetExpanded toggles between collapsed and expanded rendering.
func (*CustomMessageComponent) SetOutputPad ¶
func (c *CustomMessageComponent) SetOutputPad(_ int)
SetOutputPad invalidates the default renderer, whose box keeps its fixed inset. Only registered custom renderers consume the configured horizontal padding.
type DiffComponent ¶
type DiffComponent struct {
// contains filtered or unexported fields
}
DiffComponent renders a diff string as colored output. It wraps RenderDiff from diff_render.go into the Component interface.
func NewDiffComponent ¶
func NewDiffComponent(diffText, filePath string) *DiffComponent
NewDiffComponent creates a diff display component.
func (*DiffComponent) Invalidate ¶
func (i *DiffComponent) Invalidate()
func (*DiffComponent) NeedsRedraw ¶
func (i *DiffComponent) NeedsRedraw() bool
func (*DiffComponent) Render ¶
func (d *DiffComponent) Render(width int) []string
Render produces colored diff lines.
func (*DiffComponent) SetDiff ¶
func (d *DiffComponent) SetDiff(text string)
SetDiff updates the diff text.
type Disposable ¶
type Disposable interface {
Dispose()
}
Disposable is implemented by components that need cleanup.
type DynamicBorder ¶
type DynamicBorder struct {
// contains filtered or unexported fields
}
DynamicBorder renders a full-width horizontal rule using "─".
func NewDynamicBorder ¶
func NewDynamicBorder(color string) *DynamicBorder
NewDynamicBorder creates a border. If color is empty, the active theme's border color is used at render time.
func (*DynamicBorder) Invalidate ¶
func (i *DynamicBorder) Invalidate()
func (*DynamicBorder) NeedsRedraw ¶
func (i *DynamicBorder) NeedsRedraw() bool
func (*DynamicBorder) Render ¶
func (d *DynamicBorder) Render(width int) []string
Render produces a single line of "─" repeated to fill width.
type Editor ¶
type Editor struct {
// EmbedWorkingStatus opts into the coding-agent status border.
EmbedWorkingStatus bool
// Focused mirrors upstream components/editor.ts Focusable support.
// When true, Render emits widthx.CursorMarker at the cursor position so
// TUI can place the hardware cursor for IME candidate windows.
Focused bool
// Thinking-level border color.
// Mirrors upstream `editor.ts::updateEditorBorderColor` which maps
// the thinking level to a per-level theme color. "off" uses borderMuted.
// Bash mode overrides this (bashHeaderColor takes precedence).
ThinkingLevel string // "off" | "low" | "medium" | "high"
// Mirrors upstream editor.ts public hooks / flags.
OnSubmit func(string)
OnChange func(string)
DisableSubmit bool
// contains filtered or unexported fields
}
Editor is a multi-line text input with undo/kill-ring support.
func (*Editor) AddAsyncSuggestionSource ¶
func (e *Editor) AddAsyncSuggestionSource(s AsyncSuggestionSource)
AddAsyncSuggestionSource appends a remote autocomplete provider. Multiple sources are queried in parallel and their results merged after the local provider's output.
func (*Editor) AddToHistory ¶
AddToHistory adds a submitted text to the input history for Up/Down navigation. Mirrors upstream editor.ts::addToHistory (line 341-350). Skips empty strings and consecutive duplicates. Capped at 100 entries.
func (*Editor) AutocompleteAccept ¶
AutocompleteAccept applies the currently-selected suggestion. Returns submit=true iff the host should now submit the editor (mirrors upstream editor.ts:644: Enter on a slash-name prefix inserts and falls through to submit).
func (*Editor) AutocompleteCancel ¶
func (e *Editor) AutocompleteCancel()
AutocompleteCancel dismisses the popup without applying.
func (*Editor) AutocompleteMaxVisible ¶
AutocompleteMaxVisible returns the maximum number of autocomplete rows.
func (*Editor) AutocompleteMove ¶
AutocompleteMove shifts the popup cursor by delta (clamped). No-op when the popup is closed.
func (*Editor) AutocompleteOpen ¶
AutocompleteOpen reports whether the popup is currently visible. Used by the host (interactive.go) to gate Esc/Enter handling.
func (*Editor) ClearAsyncSuggestionSources ¶
func (e *Editor) ClearAsyncSuggestionSources()
ClearAsyncSuggestionSources drops all installed async providers.
func (*Editor) ClearExtensionDecorations ¶
func (e *Editor) ClearExtensionDecorations()
ClearExtensionDecorations drops all extension-supplied decoration state. Called when an extension is unloaded or reload happens.
func (*Editor) ClearPastes ¶
func (e *Editor) ClearPastes()
ClearPastes drops the compact-paste store. Callers that consume the editor's text via GetExpandedText (e.g. submit) should call this after expanding so subsequent edits don't re-expand stale markers. Mirrors upstream submitValue() resetting pastes + pasteCounter.
func (*Editor) GetExpandedText ¶
GetExpandedText returns the editor content with any compact paste markers (`[paste #N +K lines]` / `[paste #N M chars]`) expanded back to their stored content. Mirrors upstream editor.ts::getExpandedText (.upstream/v0.69.0/packages/tui/src/components/editor.ts:929).
func (*Editor) HandleInput ¶
func (*Editor) HandleMouse ¶
func (e *Editor) HandleMouse(event TuiMouseEvent) *TuiMouseDispatchResult
HandleMouse activates autocomplete rows and positions the editor cursor on a synthesized left click. Press, drag, and release remain unhandled so the alternate-screen renderer can own text selection. Mirrors upstream Editor.handleMouse. Autocomplete clicks retain the pressed item across scrolling.
func (*Editor) InsertTextAtCursor ¶
InsertTextAtCursor is the public API for programmatic text insertion. Mirrors upstream editor.ts::insertTextAtCursor. Handles multi-line text.
func (*Editor) Invalidate ¶
func (i *Editor) Invalidate()
func (*Editor) IsBashMode ¶
IsBashMode reports whether the buffer is in bash-prefix mode (first non-whitespace char is `!`). Used to switch the editor border color and to suppress slash-autocomplete in this state.
func (*Editor) IsDirty ¶
IsDirty reports whether the editor's rendered lines changed since the last consume. The embedded status indicator is animated and relabelled by its owner (spinner ticks, working message, retry countdown) without touching the editor, so its own dirty flag counts too; otherwise the per-child render cache would keep the old border row until a keystroke dirtied the editor.
func (*Editor) LockExtensionBorderColor ¶
func (e *Editor) LockExtensionBorderColor()
LockExtensionBorderColor freezes the current border-color decoration. Mirrors upstream prompt-editor's lockBorderColor() behavior.
func (*Editor) MaxVisibleLines ¶
MaxVisibleLines returns the current visible-line cap (mostly for tests).
func (*Editor) NeedsRedraw ¶
NeedsRedraw consumes the editor's and the embedded indicator's dirty flags.
func (*Editor) SetAsyncApply ¶
func (e *Editor) SetAsyncApply(schedule func(func()))
SetAsyncApply installs a scheduler that runs the given closure on the host's main loop (single-threaded with keystroke handling). The editor uses it to apply async suggestion results without mutating its lock-free state from a worker goroutine. When unset, results are applied inline on the worker (single-threaded callers / tests only).
func (*Editor) SetAutocomplete ¶
func (e *Editor) SetAutocomplete(p AutocompleteProvider)
SetAutocomplete attaches an AutocompleteProvider. Pass nil to detach.
func (*Editor) SetAutocompleteMaxVisible ¶
SetAutocompleteMaxVisible changes the autocomplete row limit.
func (*Editor) SetExtensionBorderColor ¶
SetExtensionBorderColor installs (or clears) the border-color decoration from a subprocess extension. Subsequent calls are honored unless LockExtensionBorderColor() has been invoked, which mirrors prompt-editor's lockBorderColor() semantic.
func (*Editor) SetExtensionModeLabel ¶
SetExtensionModeLabel installs (or clears) the mode-label decoration from a subprocess extension. The prefix/suffix sandwiches the label text so themed color tokens captured on the Node side render correctly inside the pig top border.
pig-specific: no upstream equivalent. Upstream extensions extend CustomEditor; pig's subprocess shim captures the mode label here instead of routing per-keystroke input across the socket.
func (*Editor) SetMaxVisibleLines ¶
SetMaxVisibleLines updates the editor's maximum visible visual-line count. Mirrors upstream editor.ts maxVisibleLines (set from `max(5, floor(terminalRows * 0.3))` on resize). Clamped to ≥ 1.
func (*Editor) SetPaddingX ¶
SetPaddingX changes the editor's horizontal content padding.
func (*Editor) SetWorkingStatusIndicator ¶
func (e *Editor) SetWorkingStatusIndicator(indicator *StatusIndicator)
SetWorkingStatusIndicator selects the status displayed by an opted-in editor.
type ExtensionEditorComponent ¶
type ExtensionEditorComponent struct {
// contains filtered or unexported fields
}
ExtensionEditorComponent wraps a fresh Editor with bordered extension-editor chrome, matching upstream's layout exactly.
func NewExtensionEditorComponent ¶
func NewExtensionEditorComponent(title, prefill string) *ExtensionEditorComponent
NewExtensionEditorComponent creates the editor-slot extension editor. prefill pre-populates the editor content.
func (*ExtensionEditorComponent) Cancelled ¶
func (c *ExtensionEditorComponent) Cancelled() bool
Cancelled reports whether the user pressed Esc/Ctrl+C.
func (*ExtensionEditorComponent) Done ¶
func (c *ExtensionEditorComponent) Done() bool
Done reports whether the user submitted or cancelled.
func (*ExtensionEditorComponent) HandleInput ¶
func (c *ExtensionEditorComponent) HandleInput(data string)
HandleInput processes key events. Esc/Ctrl+C cancels; everything else is forwarded to the underlying Editor (which calls OnSubmit on Enter, handles Shift+Enter/Ctrl+J as newline).
func (*ExtensionEditorComponent) Invalidate ¶
func (i *ExtensionEditorComponent) Invalidate()
func (*ExtensionEditorComponent) NeedsRedraw ¶
func (i *ExtensionEditorComponent) NeedsRedraw() bool
func (*ExtensionEditorComponent) Render ¶
func (c *ExtensionEditorComponent) Render(width int) []string
Render mirrors upstream ExtensionEditorComponent layout:
DynamicBorder + Spacer + accent(title) indented 1 + Spacer + Editor (with its own internal dashed borders) + Spacer + hint line indented 1 + Spacer + DynamicBorder.
func (*ExtensionEditorComponent) SetDescription ¶
func (c *ExtensionEditorComponent) SetDescription(description string)
SetDescription sets optional explanatory text shown between the title and the editor. Mirrors upstream ExtensionEditorOptions.description.
func (*ExtensionEditorComponent) Value ¶
func (c *ExtensionEditorComponent) Value() string
Value returns the submitted text (empty if cancelled).
type ExtensionInputComponent ¶
type ExtensionInputComponent struct {
// contains filtered or unexported fields
}
ExtensionInputComponent wraps a bare TextInput with extension-style chrome.
func NewExtensionInputComponent ¶
func NewExtensionInputComponent(title, placeholder string) *ExtensionInputComponent
NewExtensionInputComponent creates the editor-slot extension input wrapper. Placeholder is accepted for API parity; upstream currently ignores it.
func (*ExtensionInputComponent) Cancelled ¶
func (e *ExtensionInputComponent) Cancelled() bool
Cancelled reports whether the user cancelled the input.
func (*ExtensionInputComponent) Done ¶
func (e *ExtensionInputComponent) Done() bool
Done reports whether the user submitted or cancelled the input.
func (*ExtensionInputComponent) HandleInput ¶
func (e *ExtensionInputComponent) HandleInput(data string)
HandleInput delegates to the wrapped input.
func (*ExtensionInputComponent) Invalidate ¶
func (i *ExtensionInputComponent) Invalidate()
func (*ExtensionInputComponent) NeedsRedraw ¶
func (i *ExtensionInputComponent) NeedsRedraw() bool
func (*ExtensionInputComponent) Render ¶
func (e *ExtensionInputComponent) Render(width int) []string
Render mirrors upstream ExtensionInputComponent layout: the title and the key hints are Text(..., 1, 0) children, so they wrap within the width.
func (*ExtensionInputComponent) SetText ¶
func (e *ExtensionInputComponent) SetText(s string)
SetText pre-fills the input.
func (*ExtensionInputComponent) Text ¶
func (e *ExtensionInputComponent) Text() string
Text returns the current value.
type ExtensionSelectorComponent ¶
type ExtensionSelectorComponent struct {
// contains filtered or unexported fields
}
ExtensionSelectorComponent is the editor-slot overlay component extensions and built-in flows use to ask the user to pick from a list of string options.
func NewExtensionSelector ¶
func NewExtensionSelector(title string, options []string, onToggleToolsExpanded ...func()) *ExtensionSelectorComponent
NewExtensionSelector creates a generic selector overlay. The first option is pre-selected. The component does not own its lifecycle - the caller (runEditorSlotExtensionSelector) drives input/render until Done() returns true.
func (*ExtensionSelectorComponent) Cancelled ¶
func (e *ExtensionSelectorComponent) Cancelled() bool
Cancelled reports whether Esc was pressed.
func (*ExtensionSelectorComponent) Done ¶
func (e *ExtensionSelectorComponent) Done() bool
Done reports whether the user picked an option (or cancelled).
func (*ExtensionSelectorComponent) HandleInput ¶
func (e *ExtensionSelectorComponent) HandleInput(data string)
HandleInput processes navigation, select, and cancel keys. Matches upstream's handleInput: Up/Down/k/j navigate, Enter selects, Esc cancels.
func (*ExtensionSelectorComponent) Invalidate ¶
func (i *ExtensionSelectorComponent) Invalidate()
func (*ExtensionSelectorComponent) NeedsRedraw ¶
func (i *ExtensionSelectorComponent) NeedsRedraw() bool
func (*ExtensionSelectorComponent) Render ¶
func (e *ExtensionSelectorComponent) Render(width int) []string
Render mirrors upstream extension-selector.ts, whose rows are Text(…, 1, 0) children between Spacer(1) and DynamicBorder rows:
DynamicBorder + Spacer + accent(bold(title)) + [Spacer + description] +
Spacer + one Text per option ("→ " prefix on selected) + Spacer +
navigate/select/cancel hint + Spacer + DynamicBorder.
Every Text wraps within one cell of padding on each side and pads to width, so no row is wider than the render width.
func (*ExtensionSelectorComponent) SelectedIndex ¶
func (e *ExtensionSelectorComponent) SelectedIndex() int
SelectedIndex returns the index of the selected option, or -1 if cancelled.
func (*ExtensionSelectorComponent) SelectedValue ¶
func (e *ExtensionSelectorComponent) SelectedValue() string
SelectedValue returns the selected option string, or "" if cancelled.
func (*ExtensionSelectorComponent) SetDescription ¶
func (e *ExtensionSelectorComponent) SetDescription(description string)
SetDescription sets optional explanatory text shown between the title and the options. Mirrors upstream ExtensionSelectorOptions.description.
type FilterableList ¶
type FilterableList struct {
Title string
Labels []string // display label per item
// EnableSearch controls whether the upstream-style search input row is
// rendered and whether printable input edits the filter. Default: true.
// Settings submenus use false to mirror upstream SelectList-based menus.
EnableSearch bool
// Descriptions, when non-nil and width allows, render in a second
// column to the right of each label. Mirrors upstream
// select-list.ts SelectItem.description handling. Length should
// match Labels; missing entries render as empty.
Descriptions []string
// MinPrimaryColumnWidth / MaxPrimaryColumnWidth bound the
// label column when descriptions render. Mirrors upstream
// SelectListLayoutOptions. Defaults to upstream's 32 cells.
MinPrimaryColumnWidth int
MaxPrimaryColumnWidth int
// TruncatePrimary overrides primary-column truncation. Its output is still
// clipped to MaxWidth, matching upstream SelectListLayoutOptions.
TruncatePrimary func(context SelectListTruncatePrimaryContext) string
// MaxVisible bounds the visible window. Mirrors upstream
// SelectList.maxVisible. Defaults to 20.
MaxVisible int
// contains filtered or unexported fields
}
FilterableList is a modal selector. After Done()==true callers inspect SelectedIndex (-1 on cancel) or Cancelled().
func NewFilterableList ¶
func NewFilterableList(title string, labels []string) *FilterableList
NewFilterableList creates a list with the given labels and an optional title shown in the overlay border.
func (*FilterableList) Cancelled ¶
func (f *FilterableList) Cancelled() bool
Cancelled reports whether the user pressed Esc.
func (*FilterableList) CursorIndex ¶
func (f *FilterableList) CursorIndex() int
CursorIndex returns the current index within the filtered view.
func (*FilterableList) Done ¶
func (f *FilterableList) Done() bool
Done reports whether the user has confirmed or cancelled.
func (*FilterableList) FilterText ¶
func (f *FilterableList) FilterText() string
FilterText returns the current filter query typed by the user. Used by ShowExtensionEditor to retrieve free-text input.
func (*FilterableList) HandleInput ¶
func (f *FilterableList) HandleInput(data string)
HandleInput updates the filter or moves the cursor.
func (*FilterableList) HandleMouse ¶
func (f *FilterableList) HandleMouse(event TuiMouseEvent) *TuiMouseDispatchResult
HandleMouse selects visible rows on press, activates them on click, and moves selection one item per wheel report without changing selection on hover. Mirrors upstream SelectList.handleMouse.
func (*FilterableList) Invalidate ¶
func (i *FilterableList) Invalidate()
func (*FilterableList) NeedsRedraw ¶
func (i *FilterableList) NeedsRedraw() bool
func (*FilterableList) Render ¶
func (f *FilterableList) Render(width int) []string
Render draws the optional filter input and SelectList rows, with unpadded muted status rows.
func (*FilterableList) SelectedIndex ¶
func (f *FilterableList) SelectedIndex() int
SelectedIndex returns the chosen index into Labels, or -1 on cancel.
func (*FilterableList) SetCursor ¶
func (f *FilterableList) SetCursor(idx int)
SetCursor positions the cursor on a specific filtered-view row.
type ForcefulAutocompleteProvider ¶
type ForcefulAutocompleteProvider interface {
GetSuggestionsForce(lines []string, cursorLine, cursorCol int) *AutocompleteSuggestions
}
ForcefulAutocompleteProvider is an optional extension implemented by providers that support "force" file-completion, triggered by Tab when the popup is closed and the buffer is not in a slash-command-name context. Mirrors upstream `AutocompleteProvider.getSuggestions` `{force: true}` branch (autocomplete.ts:281).
type FuzzyMatch ¶
FuzzyMatch is the result of matching a single query against a text. Matches=false means the query does not appear in text in order.
func FuzzyMatchScore ¶
func FuzzyMatchScore(query, text string) FuzzyMatch
FuzzyMatch performs a single-pass fuzzy match: returns Matches=true iff every char of `query` appears in `text` in order (case-insensitive). Score is lower-is-better.
type HStack ¶
type HStack struct {
*Stack
}
HStack ports pi-tui's HStack: children laid out left to right with flexbox widths and vertical alignment.
func NewHStack ¶
func NewHStack(children []StackChild, options StackOptions) *HStack
NewHStack constructs a horizontal stack.
func (HStack) Invalidate ¶
func (i HStack) Invalidate()
func (HStack) NeedsRedraw ¶
func (i HStack) NeedsRedraw() bool
type IdleStatus ¶
type IdleStatus struct{}
IdleStatus reserves the standalone loader's two rows after clearing it.
func (*IdleStatus) Invalidate ¶
func (*IdleStatus) Invalidate()
func (*IdleStatus) Render ¶
func (*IdleStatus) Render(width int) []string
type Image ¶
type Image struct {
Base64Data string
MIMEType string
Dimensions ImageDimensions
Theme ImageTheme
Options ImageOptions
// contains filtered or unexported fields
}
func NewImage ¶
func NewImage(base64Data, mimeType string, options ImageOptions, dimensions *ImageDimensions) *Image
func (*Image) GetImageID ¶
func (*Image) Invalidate ¶
func (i *Image) Invalidate()
func (*Image) NeedsRedraw ¶
func (i *Image) NeedsRedraw() bool
type ImageBlock ¶
ImageBlock describes one image from a tool result for rendering.
type ImageCellSize ¶
func CalculateImageCellSize ¶
func CalculateImageCellSize(imageDimensions ImageDimensions, maxWidthCells int, maxHeightCells int, dims CellDimensions) ImageCellSize
type ImageDimensions ¶
func GetGIFDimensions ¶
func GetGIFDimensions(base64Data string) *ImageDimensions
func GetImageDimensions ¶
func GetImageDimensions(base64Data, mimeType string) *ImageDimensions
func GetJPEGDimensions ¶
func GetJPEGDimensions(base64Data string) *ImageDimensions
func GetPNGDimensions ¶
func GetPNGDimensions(base64Data string) *ImageDimensions
func GetWebPDimensions ¶
func GetWebPDimensions(base64Data string) *ImageDimensions
type ImageOptions ¶
type ImageProtocol ¶
type ImageProtocol string
const ( ImageProtocolKitty ImageProtocol = "kitty" ImageProtocolITerm2 ImageProtocol = "iterm2" )
type ImageRenderOptions ¶
type ImageTheme ¶
type InputHandler ¶
type InputHandler interface {
HandleInput(data string)
}
InputHandler is implemented by components that want keyboard events.
type InputOptions ¶
type InputOptions struct {
Prompt *string
Placeholder string
PlaceholderStyle func(text string) string
}
InputOptions mirrors upstream InputOptions. A nil Prompt takes upstream's "> " default; nil PlaceholderStyle leaves the placeholder unstyled.
type KeyReleaseReceiver ¶
type KeyReleaseReceiver interface {
WantsKeyRelease() bool
}
KeyReleaseReceiver is implemented by components that want Kitty key-release events delivered to HandleInput. Mirrors upstream's optional Component.wantsKeyRelease (tui.ts:40), which defaults to false. Upstream opts in only for games (the space-invaders and doom-overlay example extensions), which need key-up to stop movement.
type KeybindingPlatform ¶
type KeybindingPlatform string
KeybindingPlatform selects a column of per-platform default keys. Upstream branches its default table on process.platform and on useWindowsKeybindings() (coding-agent core/keybindings.ts); these four values name every combination the table distinguishes. The values match the columns of the behavior-input inventory.
const ( KeybindingPlatformDarwin KeybindingPlatform = "darwin" KeybindingPlatformLinux KeybindingPlatform = "linux" KeybindingPlatformLinuxWSL KeybindingPlatform = "linuxWsl" KeybindingPlatformWin32 KeybindingPlatform = "win32" )
func HostKeybindingPlatform ¶
func HostKeybindingPlatform() KeybindingPlatform
HostKeybindingPlatform returns the platform column for this process.
func KeybindingPlatformFor ¶
func KeybindingPlatformFor(goos string, getenv func(string) string) KeybindingPlatform
KeybindingPlatformFor maps a runtime.GOOS value and an environment to the default-key column. Platforms upstream does not name (freebsd, etc.) take the Linux column, as process.platform comparisons fall through there.
func (KeybindingPlatform) UsesWindowsKeybindings ¶
func (p KeybindingPlatform) UsesWindowsKeybindings() bool
UsesWindowsKeybindings reports whether the platform takes Windows defaults.
type KillRing ¶
type KillRing struct {
// contains filtered or unexported fields
}
KillRing is an Emacs-style kill/yank ring buffer.
Tracks killed (deleted) text entries. Consecutive kills accumulate into a single entry via Push(accumulate=true). Supports yank (paste most recent) and yank-pop (cycle through older entries via Rotate).
Mirrors upstream kill-ring.ts.
func (*KillRing) Peek ¶
Peek returns the most recent entry without modifying the ring. Returns "" if the ring is empty.
type KittyImageConversion ¶
KittyImageConversion names one tool-result image that needs a PNG conversion before the Kitty graphics protocol can display it.
type KittyImageMetadata ¶
KittyImageMetadata is the public metadata for a registered Kitty image.
func GetKittyImageMetadata ¶
func GetKittyImageMetadata(line string) *KittyImageMetadata
GetKittyImageMetadata returns the public metadata for the Kitty image on a rendered line, or nil if the line carries no registered image. Mirrors upstream getKittyImageMetadata.
type KittyImagePlacement ¶
type KittyImagePlacement struct {
ImageID int
TransmissionGeneration int
TransmissionBytes int
EstimatedDecodedBytes int
Sequence string
ReplacementLine string
}
KittyImagePlacement is a placement-only command derived from a transmitted Kitty image line. Mirrors upstream KittyImagePlacement.
func GetKittyImagePlacement ¶
func GetKittyImagePlacement(line string) (KittyImagePlacement, bool)
GetKittyImagePlacement builds a placement-only command for an image line emitted by RenderImage, so the alt-screen renderer can re-place an already transmitted image without re-uploading its data. Returns ok=false for a line with no Kitty command or no registered metadata. Mirrors upstream getKittyImagePlacement.
type LayoutBox ¶
type LayoutBox struct {
Component Component
Rect LayoutRect
Clip LayoutRect
Children []*LayoutBox
Parent *LayoutBox
Lines []string
LineOffset int
ScrollView *ScrollView
ScrollContentLines []string
Layer int
}
LayoutBox is one node in the laid-out tree. Lines (non-nil) marks a leaf whose rendered lines paint directly; ScrollView/ScrollContentLines mark a scroll viewport. Optional upstream fields are zero values here.
func GetLayoutBoxesAt ¶
func GetLayoutBoxesAt(frame LayoutFrame, x, y int) []*LayoutBox
GetLayoutBoxesAt returns the visual hit path at a point, from the deepest component to the layout root, highest layer first. Mirrors upstream getLayoutBoxesAt.
func GetScrollViewBox ¶
func GetScrollViewBox(frame LayoutFrame, scrollView *ScrollView) *LayoutBox
GetScrollViewBox finds the layout box wrapping a given ScrollView, or nil. Mirrors upstream getScrollViewBox.
type LayoutComponent ¶
type LayoutComponent interface {
Component
LayoutNode() LayoutNode
}
LayoutComponent is a Component that exposes a layout node. It ports upstream's LayoutComponent interface; the LAYOUT_NODE symbol method becomes LayoutNode().
type LayoutFrame ¶
type LayoutFrame struct {
Root *LayoutBox
Width int
Height int
Lines []string
PrimaryScrollView *ScrollView
}
LayoutFrame is a fully laid-out and painted viewport.
func RenderLayoutFrame ¶
func RenderLayoutFrame(root Component, width, height int, requestRender func()) LayoutFrame
RenderLayoutFrame lays out a component tree into a width×height viewport and paints it. Mirrors upstream renderLayoutFrame.
type LayoutNode ¶
type LayoutNode interface {
// contains filtered or unexported methods
}
LayoutNode is the sealed union of layout node kinds (upstream's StackLayoutNode | ScrollLayoutNode discriminated union). Only the two node types in this package implement it.
type LayoutRect ¶
LayoutRect is an axis-aligned rectangle in terminal cells.
type LayoutViewport ¶
LayoutViewport is the available render area a stack entry's visibility predicate is evaluated against.
type Loader ¶
type Loader struct {
Message string
Frame int
Frames []string
SpinnerColor string // ANSI fg escape for spinner (optional)
MessageColor string // ANSI fg escape for message (optional)
IndicatorVerbatim bool // extension frames include their own formatting
// contains filtered or unexported fields
}
Loader shows an animated spinner with a message. Matches upstream Loader which extends Text(paddingX=1, paddingY=0).
func NewStyledLoader ¶
NewStyledLoader creates a Loader with ANSI color escapes.
func (*Loader) Invalidate ¶
func (i *Loader) Invalidate()
func (*Loader) NeedsRedraw ¶
func (i *Loader) NeedsRedraw() bool
func (*Loader) Render ¶
Render produces ["", paddedLine] matching upstream Loader.render(width) which returns ["", ...super.render(width)] where super is Text(paddingX=1).
func (*Loader) SetIndicator ¶
SetIndicator replaces the animation frames, restarts at the first frame, and marks the loader for repaint. nil frames select DefaultSpinnerFrames and an empty slice hides the indicator. verbatim renders caller-formatted frames without the spinner color. Mirrors upstream Loader.setIndicator; the owner that ticks the loader applies the frame interval.
func (*Loader) SetMessage ¶
SetMessage replaces the message and marks the loader for repaint. Mirrors upstream Loader.setMessage, which updates the text and requests a render.
type LoginDialog ¶
type LoginDialog struct {
// contains filtered or unexported fields
}
LoginDialog is a stateful bordered overlay for the OAuth device flow (port of LoginDialogComponent in login-dialog.ts).
func NewLoginDialog ¶
func NewLoginDialog(providerName string, onCancel func()) *LoginDialog
NewLoginDialog creates the dialog for providerName.
func (*LoginDialog) Cancelled ¶
func (d *LoginDialog) Cancelled() bool
Cancelled reports whether the user pressed Esc.
func (*LoginDialog) Done ¶
func (d *LoginDialog) Done() bool
Done reports whether the dialog is finished.
func (*LoginDialog) HandleInput ¶
func (d *LoginDialog) HandleInput(data string)
HandleInput processes Esc and, when input is active, text editing keys.
func (*LoginDialog) Invalidate ¶
func (i *LoginDialog) Invalidate()
func (*LoginDialog) NeedsRedraw ¶
func (i *LoginDialog) NeedsRedraw() bool
func (*LoginDialog) Render ¶
func (d *LoginDialog) Render(width int) []string
Render returns bordered ANSI lines.
func (*LoginDialog) ShowAuth ¶
func (d *LoginDialog) ShowAuth(url, instructions string)
ShowAuth sets the content to URL + hint.
func (*LoginDialog) ShowInput ¶
func (d *LoginDialog) ShowInput(prompt, placeholder string) <-chan string
ShowInput activates the text input row with a prompt. Returns a channel that receives the submitted string (closed on cancel).
func (*LoginDialog) ShowProgress ¶
func (d *LoginDialog) ShowProgress(msg string)
ShowProgress appends a progress line.
func (*LoginDialog) ShowWaiting ¶
func (d *LoginDialog) ShowWaiting(msg string)
ShowWaiting appends a waiting message.
func (*LoginDialog) Success ¶
func (d *LoginDialog) Success()
Success marks the dialog as completed successfully.
type Markdown ¶
type Markdown struct {
Content string
// Transform is an optional display-only rewrite of Content applied at the
// render width before parsing, mirroring upstream MarkdownOptions.transform
// (markdown.ts). Used to replace Mermaid code blocks with rendered diagrams.
// A Transform that reads state outside (Content, width) must report it through
// TransformState, or the render cache will serve a stale result.
Transform func(markdown string, width int) string
// TransformState reports external transform inputs so a retained Markdown component invalidates cached lines when those inputs change without a Content or width change.
TransformState func() string
// contains filtered or unexported fields
}
Markdown renders markdown text to ANSI-annotated lines. This is a lightweight port of pi-tui's markdown component.
func NewMarkdown ¶
func (*Markdown) Invalidate ¶
func (i *Markdown) Invalidate()
func (*Markdown) NeedsRedraw ¶
func (i *Markdown) NeedsRedraw() bool
func (*Markdown) SetDefaultColor ¶
SetDefaultColor sets the ANSI foreground applied to ordinary Markdown text tokens. Headings, code, list markers and blockquotes retain their own theme styles. Passing an empty string restores terminal-default foreground and invalidates the cache.
type ModelItem ¶
type ModelItem struct {
FullID string // "provider/model-id"
Name string // display name
Provider string
}
ModelItem describes one model in the scoped-models list.
type ModelScope ¶
type ModelScope int
ModelScope discriminates the two views of the picker.
const ( ModelScopeScoped ModelScope = iota ModelScopeAll )
type ModelSearchItem ¶
ModelSearchItem is the provider, bare id, and optional display name a model search text is built from. Mirrors upstream ModelSearchItem; an empty Name is upstream's absent (or empty) name.
type ModelSelector ¶
type ModelSelector struct {
Title string
// contains filtered or unexported fields
}
ModelSelector renders a fuzzy-filtered list of models with a scope-toggle header.
func NewModelSelector ¶
func NewModelSelector(title string, scoped, allReachable []ModelSelectorItem, current string) *ModelSelector
NewModelSelector constructs a picker. scoped contains the session's scoped models; allReachable contains all models with configured auth. current is the current provider-qualified model ID, or empty when none is selected. With no scoped models, the picker starts in all scope and shows the provider hint.
func (*ModelSelector) Cancelled ¶
func (m *ModelSelector) Cancelled() bool
func (*ModelSelector) Done ¶
func (m *ModelSelector) Done() bool
Done / Cancelled / SelectedFQ: modal contract.
func (*ModelSelector) HandleInput ¶
func (m *ModelSelector) HandleInput(data string)
func (*ModelSelector) Invalidate ¶
func (i *ModelSelector) Invalidate()
func (*ModelSelector) NeedsRedraw ¶
func (i *ModelSelector) NeedsRedraw() bool
func (*ModelSelector) Render ¶
func (m *ModelSelector) Render(width int) []string
Render lays out the upstream selector rows (model-selector.ts): top border, scope and hint (or the no-auth warning), search input, model list, scroll position, selected-model name, refresh status, selection hint, and bottom border. Every text row is a Text(..., 0, 0), so long rows wrap to the width.
func (*ModelSelector) Scope ¶
func (m *ModelSelector) Scope() ModelScope
Scope returns the current scope (exposed for tests).
func (*ModelSelector) SelectedAsDefault ¶
func (m *ModelSelector) SelectedAsDefault() bool
SelectedAsDefault reports whether the selection requested persistence via app.models.save.
func (*ModelSelector) SelectedFQ ¶
func (m *ModelSelector) SelectedFQ() string
func (*ModelSelector) SetDefaultModel ¶
func (m *ModelSelector) SetDefaultModel(fq string)
SetDefaultModel marks the settings default model ("<provider>/<id>"), which upstream badges with "· default", sorts after the current model, and matches for a "default" search.
func (*ModelSelector) SetError ¶
func (m *ModelSelector) SetError(text string)
func (*ModelSelector) SetFilter ¶
func (m *ModelSelector) SetFilter(query string)
func (*ModelSelector) SetRefreshSuccess ¶
func (m *ModelSelector) SetRefreshSuccess(text string)
SetRefreshSuccess shows the upstream "Model catalogs refreshed." status in the success color.
func (*ModelSelector) SetStatus ¶
func (m *ModelSelector) SetStatus(text string)
func (*ModelSelector) UpdateModels ¶
func (m *ModelSelector) UpdateModels(models []ModelSelectorItem)
UpdateModels replaces the available snapshot and refreshes scoped model metadata without dropping unavailable scoped entries. It retains the scope and query, reanchors on the current model (or clamps the cursor), then selects the best match when a query is active, like upstream loadModelsFromSnapshot followed by filterModels.
func (*ModelSelector) VisibleCount ¶
func (m *ModelSelector) VisibleCount() int
VisibleCount returns the number of items in the filtered view.
type ModelSelectorItem ¶
type ModelSelectorItem struct {
Provider string
ID string // bare model id (e.g. "gpt-4o")
// Name is the raw model display name (upstream model.name), empty when
// the source has none. Search text omits an empty name; the selected-model
// footer falls back to ID.
Name string
}
ModelSelectorItem is one row in the picker.
func (ModelSelectorItem) FQ ¶
func (m ModelSelectorItem) FQ() string
FQ returns the "<provider>/<id>" form used for switch dispatch.
type ModifierKey ¶
type ModifierKey string
ModifierKey mirrors upstream native-platform.ts ModifierKey.
const ( ModifierShift ModifierKey = "shift" ModifierCommand ModifierKey = "command" ModifierControl ModifierKey = "control" ModifierOption ModifierKey = "option" )
type MouseHandler ¶
type MouseHandler interface {
HandleMouse(event TuiMouseEvent) *TuiMouseDispatchResult
}
MouseHandler is implemented by components with a normalized mouse handler. Mirrors upstream Component.handleMouse.
type MouseRegion ¶
type MouseRegion struct {
// contains filtered or unexported fields
}
MouseRegion adds mouse handling to an existing component without changing its rendering. Ports pi-tui components/mouse-region.ts.
func NewMouseRegion ¶
func NewMouseRegion(child Component, onMouse MouseRegionHandler) *MouseRegion
NewMouseRegion wraps child with onMouse. Mirrors upstream new MouseRegion.
func (*MouseRegion) HandleMouse ¶
func (r *MouseRegion) HandleMouse(event TuiMouseEvent) *TuiMouseDispatchResult
HandleMouse gives nested mouse-aware children the first chance, then the region's own handler. Mirrors upstream MouseRegion.handleMouse.
func (*MouseRegion) Invalidate ¶
func (r *MouseRegion) Invalidate()
Invalidate invalidates the wrapped child.
func (*MouseRegion) Render ¶
func (r *MouseRegion) Render(width int) []string
Render renders the wrapped child unchanged.
type MouseRegionHandler ¶
type MouseRegionHandler func(event TuiMouseEvent) *TuiMouseEventResult
MouseRegionHandler handles a mouse event that no nested child handled. Mirrors upstream MouseRegionHandler; nil means unhandled.
type OAuthProvider ¶
type OAuthProvider struct {
ID string // e.g. "github-copilot"
Name string // display name
AuthType string // "oauth" or "api_key"
// Stored indicates auth.json contains a stored credential for this provider.
Stored bool
// StoredType is the type of the stored credential when Stored is true.
StoredType string // "oauth" or "api_key"
// AuthStatusSource/Label mirror ai.AuthStatus for API-key providers.
AuthStatusSource string // "", "stored", "environment", "runtime", "fallback", "models_json_key", "models_json_command"
AuthStatusLabel string
}
OAuthProvider is one entry in the auth provider selector.
type OAuthSelector ¶
type OAuthSelector struct {
// contains filtered or unexported fields
}
OAuthSelector renders the bordered provider picker (port of OAuthSelectorComponent in oauth-selector.ts).
func NewOAuthSelector ¶
func NewOAuthSelector(mode string, providers []OAuthProvider) *OAuthSelector
NewOAuthSelector constructs the picker.
func (*OAuthSelector) Cancelled ¶
func (s *OAuthSelector) Cancelled() bool
Cancelled reports whether Esc was pressed.
func (*OAuthSelector) Done ¶
func (s *OAuthSelector) Done() bool
Done reports whether the user selected or cancelled.
func (*OAuthSelector) HandleInput ¶
func (s *OAuthSelector) HandleInput(data string)
HandleInput processes navigation, select, and cancel keys.
func (*OAuthSelector) Invalidate ¶
func (i *OAuthSelector) Invalidate()
func (*OAuthSelector) NeedsRedraw ¶
func (i *OAuthSelector) NeedsRedraw() bool
func (*OAuthSelector) Render ¶
func (s *OAuthSelector) Render(width int) []string
Render returns ANSI lines for the bordered overlay.
func (*OAuthSelector) SelectedID ¶
func (s *OAuthSelector) SelectedID() string
SelectedID returns the selected provider ID, or "" on cancel.
type OverlayBounds ¶
OverlayBounds is an overlay's last rendered terminal-relative rectangle. Mirrors upstream OverlayBounds.
type OverlayGeometry ¶
OverlayGeometry is the resolved placement of an overlay.
func ResolveOverlayGeometry ¶
func ResolveOverlayGeometry(opts OverlayOptions, overlayHeight, termWidth, termHeight int) OverlayGeometry
ResolveOverlayGeometry resolves opts for a component of overlayHeight lines on a termWidth x termHeight screen, using the same resolver the compositor uses. Width is the width the component is rendered at.
type OverlayHandle ¶
type OverlayHandle struct {
// contains filtered or unexported fields
}
OverlayHandle lets callers control an overlay.
func (*OverlayHandle) Close ¶
func (h *OverlayHandle) Close()
Close permanently removes this overlay.
func (*OverlayHandle) GetBounds ¶
func (h *OverlayHandle) GetBounds() (OverlayBounds, bool)
GetBounds returns the most recent rendered bounds of a visible overlay. Mirrors upstream OverlayHandle.getBounds.
func (*OverlayHandle) IsFocused ¶
func (h *OverlayHandle) IsFocused() bool
IsFocused reports whether this overlay currently has focus.
type OverlayMarginSpec ¶
type OverlayMarginSpec struct {
Top, Right, Bottom, Left int
}
OverlayMarginSpec mirrors upstream OverlayMargin.
type OverlayOptions ¶
type OverlayOptions struct {
// WidthFraction, HeightFraction, and Title configure the private built-in
// modal wrapper.
WidthFraction float64
HeightFraction float64
Title string
// contains filtered or unexported fields
}
OverlayOptions controls the size/position of an overlay.
type OverlaySpec ¶
type OverlaySpec struct {
Width *OverlayValue
MinWidth *int
MaxHeight *OverlayValue
Anchor string
OffsetX int
OffsetY int
Row *OverlayValue
Col *OverlayValue
// Margin is the per-edge form; MarginAll the upstream numeric form.
Margin *OverlayMarginSpec
MarginAll *int
NonCapturing bool
}
OverlaySpec is the serialisable subset of upstream pi-tui OverlayOptions (everything except the visible callback). It lets callers outside this package, such as the subprocess extension bridge, open a component-framed overlay whose geometry resolves exactly like upstream showOverlay.
func (OverlaySpec) Options ¶
func (s OverlaySpec) Options() OverlayOptions
Options converts the spec into OverlayOptions. The result carries no modal title or fractions, so OpenOverlay mounts the component without a frame.
type OverlayValue ¶
type OverlayValue struct {
Value float64
Percent bool
// Invalid preserves a supplied but malformed size, distinct from omission.
Invalid bool
}
OverlayValue is a serialisable upstream SizeValue: an absolute cell count or, when Percent is set, a percentage of the terminal dimension.
type ParsedSkillBlock ¶
ParsedSkillBlock holds the parsed skill invocation data. Mirrors upstream's ParsedSkillBlock.
type PlatformKeys ¶
type PlatformKeys struct {
Other []string
Darwin []string
Windows []string
Win32 []string
LinuxWSL []string
}
PlatformKeys holds default keys that differ by platform. Other applies unless a narrower field is non-nil. Windows covers every platform that uses Windows keybindings (win32 and WSL); Win32, LinuxWSL, and Darwin override it for one platform. A non-nil empty slice means "no default key" on that platform, as upstream's `[]`.
func (PlatformKeys) For ¶
func (k PlatformKeys) For(platform KeybindingPlatform) []string
For returns the default keys for platform.
type ProcessTerminal ¶
type ProcessTerminal struct {
// contains filtered or unexported fields
}
ProcessTerminal is the concrete terminal control implementation backed by process stdin/stdout (or test doubles).
func NewProcessTerminal ¶
func NewProcessTerminal(stdin, stdout *os.File) *ProcessTerminal
NewProcessTerminal constructs a terminal helper around the provided stdin and stdout files.
func NewProcessTerminalWithOutput ¶
func NewProcessTerminalWithOutput(stdin, stdout *os.File, out io.Writer) *ProcessTerminal
NewProcessTerminalWithOutput constructs a terminal helper whose control bytes are written to out. Used by tests that want stdout-like behavior without touching the real terminal.
func (*ProcessTerminal) ClearFromCursor ¶
func (t *ProcessTerminal) ClearFromCursor()
ClearFromCursor clears from the cursor to the end of the screen.
func (*ProcessTerminal) ClearLine ¶
func (t *ProcessTerminal) ClearLine()
ClearLine clears from the cursor to the end of the current line.
func (*ProcessTerminal) ClearScreen ¶
func (t *ProcessTerminal) ClearScreen()
ClearScreen clears the screen and homes the cursor.
func (*ProcessTerminal) Columns ¶
func (t *ProcessTerminal) Columns() int
Columns returns the terminal width, falling back to COLUMNS or 80 when unavailable.
func (*ProcessTerminal) DrainInput ¶
func (t *ProcessTerminal) DrainInput(maxWait, idleWait time.Duration) error
DrainInput drains pending stdin bytes for up to maxWait, exiting early once no new bytes arrive within idleWait. This mirrors upstream's slow-SSH guard against key release sequences leaking into the parent shell on exit.
Disables the extended-key protocols first, as upstream's drainInput does: a drain that runs while the terminal is still reporting key events has no stable end, because releasing the keys pressed during the drain produces more input. Idempotent, so a caller that already disabled loses nothing.
func (*ProcessTerminal) EnterRawMode ¶
func (t *ProcessTerminal) EnterRawMode() (restore func(), err error)
EnterRawMode puts this terminal into raw mode and returns a restore closure that drains late extended-key releases before restoring cooked mode.
func (*ProcessTerminal) HideCursor ¶
func (t *ProcessTerminal) HideCursor()
HideCursor hides the terminal cursor.
func (*ProcessTerminal) KittyProtocolActive ¶
func (*ProcessTerminal) KittyProtocolActive() bool
KittyProtocolActive reports whether this raw-mode session received non-zero Kitty keyboard protocol flags.
func (*ProcessTerminal) MoveBy ¶
func (t *ProcessTerminal) MoveBy(lines int)
MoveBy moves the cursor relative to its current row.
func (*ProcessTerminal) Rows ¶
func (t *ProcessTerminal) Rows() int
Rows returns the terminal height, falling back to LINES or 24 when unavailable.
func (*ProcessTerminal) SetProgress ¶
func (t *ProcessTerminal) SetProgress(active bool)
SetProgress writes the OSC 9;4 progress indicator used during agent work and keeps it alive while active so terminals like Ghostty do not clear it during long-running operations.
func (*ProcessTerminal) SetTitle ¶
func (t *ProcessTerminal) SetTitle(title string)
SetTitle writes an OSC 0 title update sequence.
func (*ProcessTerminal) ShowCursor ¶
func (t *ProcessTerminal) ShowCursor()
ShowCursor shows the terminal cursor.
func (*ProcessTerminal) Start ¶
func (t *ProcessTerminal) Start(onInput func([]byte), onResize func()) error
Start mirrors upstream `ProcessTerminal.start(onInput, onResize)`. It enters raw mode, then spawns one goroutine that reads stdin in 256-byte chunks and invokes onInput for each, and registers a SIGWINCH handler goroutine that invokes onResize on terminal resize.
Use ProcessTerminal.StartWithReadError when the caller must distinguish terminal closure from user input.
Callers that prefer to own the read loop directly (the original pig pattern) should use `EnterRawMode` instead. Both patterns coexist.
Calling Start twice without an intervening Stop is a no-op and returns nil; the existing Start owns the lifecycle.
func (*ProcessTerminal) StartWithReadError ¶
func (t *ProcessTerminal) StartWithReadError(onInput func([]byte), onResize func(), onReadError func(error)) error
StartWithReadError starts terminal input and reports the error that ends the input loop. Cancellation through ProcessTerminal.Stop does not report an error.
func (*ProcessTerminal) Stop ¶
func (t *ProcessTerminal) Stop()
Stop mirrors upstream `ProcessTerminal.stop()`. It cancels and joins the input goroutine, removes the resize handler, and restores cooked mode without draining unread input. This lets a subsequent terminal owner receive bytes typed during focus handoff. Safe to call multiple times; Stop on a never-Started terminal is a no-op.
func (*ProcessTerminal) Write ¶
func (t *ProcessTerminal) Write(data string)
Write emits data to the terminal output.
type RefreshStatusKind ¶
type RefreshStatusKind string
RefreshStatusKind controls the refresh message emphasis.
const ( RefreshStatusMuted RefreshStatusKind = "muted" RefreshStatusSuccess RefreshStatusKind = "success" RefreshStatusWarning RefreshStatusKind = "warning" )
type RenderOverflowError ¶
RenderOverflowError is the value doRender panics with when an over-wide non-image row reaches the differential-render loop. Its message is the Error thrown by upstream TuiMainScreen.doRender (tui-main-screen.ts:536-544).
func (*RenderOverflowError) Error ¶
func (e *RenderOverflowError) Error() string
type Renderer ¶
type Renderer interface {
// Render performs a differential render pass now.
Render()
// RequestRender coalesces a render on the shared 16ms frame throttle.
RequestRender()
// CancelPendingRender invalidates a throttled frame already queued for owner-loop delivery.
CancelPendingRender()
// ForceFullRender marks the next frame as a full (non-differential) redraw.
ForceFullRender()
// RepaintAll forces an immediate full repaint.
RepaintAll()
// RenderSnapshot returns the rendered document lines at the given width.
RenderSnapshot(width int) []string
// Add mounts a component in the render tree.
Add(component Component)
// Invalidate marks the render tree dirty.
Invalidate()
// OpenOverlay pushes an overlay and returns its handle.
OpenOverlay(component Component, opts OverlayOptions) *OverlayHandle
// SetFocus records the non-overlay target restored after overlay teardown.
SetFocus(component Component)
// FocusedComponent returns the current keyboard focus target.
FocusedComponent() Component
// SetOverlayCommandDispatcher binds remote overlay commands to the owner loop.
SetOverlayCommandDispatcher(dispatch func(func()))
// HasOverlay reports whether any overlay is currently open.
HasOverlay() bool
// Width and Height report the current terminal geometry.
Width() int
Height() int
// QueryCellSize asks an image-capable terminal for its cell size.
QueryCellSize()
// ConsumeCellSizeResponse applies and consumes a cell-size response.
ConsumeCellSizeResponse(data string) bool
// ShowCursor and HideCursor toggle the terminal cursor directly.
ShowCursor()
HideCursor()
// SetShowHardwareCursor toggles hardware-cursor positioning.
SetShowHardwareCursor(enabled bool)
// SetClearOnShrink records the clear-on-shrink preference.
SetClearOnShrink(enabled bool)
// SetOnWidthChange registers a terminal-width-change callback.
SetOnWidthChange(fn func(width int))
// SetOnHeightChange registers a terminal-height-change callback.
SetOnHeightChange(fn func(height int))
// SetRenderDispatcher marshals timer-scheduled renders onto the driver loop.
SetRenderDispatcher(dispatch func(render func()))
// Stop tears down the renderer.
Stop()
// StopWithOptions tears down the renderer; PreserveScreen leaves the current
// screen intact for a live renderer swap (no end-of-session output).
StopWithOptions(options StopOptions)
}
Renderer is the interactive-driver-facing rendering contract implemented by both the main-screen (TUI) and alternate-screen (TuiAltScreen) renderers. It is the Go equivalent of upstream's TUI interface (packages/tui/src/tui.ts), which both TuiMainScreen and TuiAltScreen implement; the driver holds one of these and does not care which renderer backs it.
The interface is named Renderer rather than TUI (upstream's name) because pig reuses the identifier TUI for the concrete main-screen renderer struct (the layer-6 tui-main-screen naming reconciliation). This is a forced Go naming divergence, not a behavioral one.
type ResourceGroup ¶
type ResourceGroup struct {
Key string
Label string
Scope string
Origin string
Source string
Subgroups []*ResourceSubgroup
}
ResourceGroup is a top-level grouping (by origin + scope + source).
func BuildResourceGroups ¶
func BuildResourceGroups(resources []ResourceItem) []*ResourceGroup
BuildResourceGroups constructs groups from resolved resource data. This is a helper for callers that have raw path lists.
type ResourceItem ¶
type ResourceItem struct {
Path string
Enabled bool
ResourceType ResourceType
DisplayName string
GroupKey string
SubgroupKey string
Scope string // "user" or "project"
Origin string // "package" or "top-level"
Source string
BaseDir string // for package-relative pattern generation
Pattern string // authored Package-relative member path
Health string // empty or "missing"
Override string // "inherit", "load", or "unload" in project mode
Inherited bool
InheritedEnabled bool
}
ResourceItem is a single toggleable resource.
type ResourceSubgroup ¶
type ResourceSubgroup struct {
Type ResourceType
Label string
Items []*ResourceItem
}
ResourceSubgroup groups items by resource type within a group.
type ResourceType ¶
type ResourceType string
ResourceType identifies the kind of package resource.
const ( ResourceExtensions ResourceType = "extensions" ResourceSkills ResourceType = "skills" ResourcePrompts ResourceType = "prompts" ResourceThemes ResourceType = "themes" )
type RgbColor ¶
type ScopedModelsConfig ¶
type ScopedModelsConfig struct {
AllModels []ModelItem
EnabledModelIDs []string // nil = all enabled
RefreshStatus string
}
ScopedModelsConfig configures the scoped-models list.
type ScopedModelsList ¶
type ScopedModelsList struct {
// contains filtered or unexported fields
}
ScopedModelsList is the /scoped-models selector component.
func NewScopedModelsList ¶
func NewScopedModelsList(cfg ScopedModelsConfig) *ScopedModelsList
NewScopedModelsList creates a new scoped-models selector.
func (*ScopedModelsList) ConsumeSave ¶
func (s *ScopedModelsList) ConsumeSave() ([]string, bool)
ConsumeSave returns the most recent Ctrl+S save request and clears it.
func (*ScopedModelsList) Done ¶
func (s *ScopedModelsList) Done() bool
Done reports whether the user has confirmed, persisted, or cancelled.
func (*ScopedModelsList) EnabledIDs ¶
func (s *ScopedModelsList) EnabledIDs() []string
EnabledIDs returns the current enabled model IDs (nil = all).
func (*ScopedModelsList) HandleInput ¶
func (s *ScopedModelsList) HandleInput(data string)
HandleInput processes a keystroke.
func (*ScopedModelsList) Invalidate ¶
func (i *ScopedModelsList) Invalidate()
func (*ScopedModelsList) NeedsRedraw ¶
func (i *ScopedModelsList) NeedsRedraw() bool
func (*ScopedModelsList) Render ¶
func (s *ScopedModelsList) Render(width int) []string
Render draws the component. Mirrors upstream ScopedModelsSelectorComponent: every text row is a Text(..., 0, 0) between two DynamicBorders.
func (*ScopedModelsList) Result ¶
func (s *ScopedModelsList) Result() ScopedModelsResult
Result returns the outcome after Done()==true.
func (*ScopedModelsList) SetRefreshStatus ¶
func (s *ScopedModelsList) SetRefreshStatus(message string, kind RefreshStatusKind)
SetRefreshStatus replaces the catalog refresh message rendered above the footer.
func (*ScopedModelsList) UpdateModels ¶
func (s *ScopedModelsList) UpdateModels(models []ModelItem, enabledIDs ...[]string)
UpdateModels publishes a refreshed catalog while preserving the selected model. Supplying enabledIDs also replaces the selection; an explicit nil means all.
type ScopedModelsResult ¶
type ScopedModelsResult struct {
EnabledIDs []string // nil = all enabled
Persisted bool // retained for compatibility; Ctrl+S no longer closes the selector
Cancelled bool
}
ScopedModelsResult describes the outcome after Done()==true.
type ScrollLayoutNode ¶
type ScrollLayoutNode struct {
Component Component
State ScrollLayoutState
}
ScrollLayoutNode is a scroll layout node. State holds the narrow interface, not the concrete ScrollView, preserving upstream's intentional narrowing.
type ScrollLayoutState ¶
type ScrollLayoutState interface {
ScrollTop() int
Primary() bool
Overscroll() string
ViewportHeight() int
GetContentWidth(width int) int
UpdateLayout(contentHeight, viewportHeight int, requestRender func())
}
ScrollLayoutState is the narrow contract the layout engine sees for a scroll node; *ScrollView implements it and is passed as the node's State. Upstream's readonly fields (scrollTop, primary, overscroll, viewportHeight) are getter methods here because a Go interface cannot carry fields.
type ScrollView ¶
type ScrollView struct {
*Container
// contains filtered or unexported fields
}
ScrollView ports pi-tui's ScrollView. It embeds pig's Container (holding the single child) and owns the transient-scrollbar timer.
func GetScrollViewsAt ¶
func GetScrollViewsAt(frame LayoutFrame, x, y int) []*ScrollView
GetScrollViewsAt returns the scroll views under a point, deepest first. Mirrors upstream getScrollViewsAt.
func NewScrollView ¶
func NewScrollView(component Component, options ScrollViewOptions) *ScrollView
NewScrollView constructs a ScrollView. It panics on an unsupported axis, mirroring upstream's constructor throw.
func (*ScrollView) Add ¶
func (s *ScrollView) Add(Component)
Add panics: a ScrollView has exactly one child (upstream throw).
func (*ScrollView) Clear ¶
func (s *ScrollView) Clear()
Clear panics: a ScrollView's child cannot be cleared (upstream throw).
func (*ScrollView) Dispose ¶
func (s *ScrollView) Dispose()
Dispose stops the hide timer so no goroutine outlives the view.
func (*ScrollView) FollowEnd ¶
func (s *ScrollView) FollowEnd() bool
FollowEnd reports whether the view was configured to follow its end.
func (*ScrollView) GetContentWidth ¶
func (s *ScrollView) GetContentWidth(width int) int
GetContentWidth returns the child render width, reserving a column for an always-on scrollbar.
func (ScrollView) Invalidate ¶
func (i ScrollView) Invalidate()
func (*ScrollView) IsFollowingEnd ¶
func (s *ScrollView) IsFollowingEnd() bool
IsFollowingEnd reports whether the view is pinned to the end.
func (*ScrollView) IsScrollbarActive ¶
func (s *ScrollView) IsScrollbarActive() bool
IsScrollbarActive reports whether the pointer is hovering or dragging the scrollbar.
func (*ScrollView) IsScrollbarVisible ¶
func (s *ScrollView) IsScrollbarVisible() bool
IsScrollbarVisible reports whether the scrollbar should paint this frame.
func (*ScrollView) LayoutNode ¶
func (s *ScrollView) LayoutNode() LayoutNode
LayoutNode ports upstream ScrollView[LAYOUT_NODE](): a scroll node whose state is this ScrollView narrowed to ScrollLayoutState.
func (ScrollView) NeedsRedraw ¶
func (i ScrollView) NeedsRedraw() bool
func (*ScrollView) Overscroll ¶
func (s *ScrollView) Overscroll() string
Overscroll reports the overscroll mode.
func (*ScrollView) Primary ¶
func (s *ScrollView) Primary() bool
Primary reports whether this is the primary scroll view.
func (*ScrollView) Remove ¶
func (s *ScrollView) Remove(Component)
Remove panics: a ScrollView's child cannot be removed (upstream throw).
func (*ScrollView) Render ¶
func (s *ScrollView) Render(width int) []string
Render ports upstream ScrollView.render: render the child at the content width, padding each line by a column when a scrollbar column is reserved.
func (*ScrollView) ScrollBy ¶
func (s *ScrollView) ScrollBy(lines int) int
ScrollBy scrolls by a relative number of lines and returns the leftover lines that could not be applied (for overscroll chaining).
func (*ScrollView) ScrollTo ¶
func (s *ScrollView) ScrollTo(scrollTop int)
ScrollTo scrolls to an absolute offset, clamped to the scrollable range.
func (*ScrollView) ScrollToEnd ¶
func (s *ScrollView) ScrollToEnd()
ScrollToEnd scrolls to the bottom.
func (*ScrollView) ScrollToStart ¶
func (s *ScrollView) ScrollToStart()
ScrollToStart scrolls to the top.
func (*ScrollView) ScrollToWithOptions ¶
func (s *ScrollView) ScrollToWithOptions(scrollTop int, options ScrollViewScrollToOptions)
ScrollToWithOptions scrolls to an absolute offset, clamped to the scrollable range. Mirrors upstream scrollTo(scrollTop, options).
func (*ScrollView) ScrollTop ¶
func (s *ScrollView) ScrollTop() int
ScrollTop reports the current scroll offset.
func (*ScrollView) Scrollbar ¶
func (s *ScrollView) Scrollbar() string
Scrollbar reports the current scrollbar mode.
func (*ScrollView) ScrollbarThumbStyle ¶
func (s *ScrollView) ScrollbarThumbStyle() func(text string) string
ScrollbarThumbStyle returns the style function applied to scrollbar thumb cells.
func (*ScrollView) ScrollbarTrackStyle ¶
func (s *ScrollView) ScrollbarTrackStyle() func(text string) string
ScrollbarTrackStyle returns the style function applied to scrollbar track cells.
func (*ScrollView) SetScrollbar ¶
func (s *ScrollView) SetScrollbar(scrollbar string)
SetScrollbar changes the scrollbar mode.
func (*ScrollView) SetScrollbarActive ¶
func (s *ScrollView) SetScrollbarActive(active bool)
SetScrollbarActive marks the scrollbar as actively dragged (keeping it shown).
func (*ScrollView) UpdateLayout ¶
func (s *ScrollView) UpdateLayout(contentHeight, viewportHeight int, requestRender func())
UpdateLayout is called by the layout engine each pass with the measured content and viewport heights; it clamps the scroll offset and stores the render callback the hide timer will invoke.
func (*ScrollView) ViewportHeight ¶
func (s *ScrollView) ViewportHeight() int
ViewportHeight reports the current viewport height.
type ScrollViewOptions ¶
type ScrollViewOptions struct {
Axis string // "" (unset) or "vertical"
Follow string // "none" | "end"
Primary bool
Overscroll string // "chain" | "contain"
Scrollbar string // "hidden" | "auto" | "always"
ScrollbarTrackStyle func(text string) string
ScrollbarThumbStyle func(text string) string
ScrollbarHideDelayMs *int
}
ScrollViewOptions configure a ScrollView. Empty string fields take upstream's default; ScrollbarHideDelayMs nil defaults to 1000ms.
type ScrollViewScrollToOptions ¶
type ScrollViewScrollToOptions struct {
// DisableFollow keeps follow-end disabled even when the target is the
// current content end.
DisableFollow bool
}
ScrollViewScrollToOptions mirrors upstream ScrollViewScrollToOptions.
type ScrollbarGeometry ¶
type ScrollbarGeometry struct {
Column int
TrackTop int
TrackHeight int
ThumbTop int
ThumbHeight int
MaxScrollTop int
}
ScrollbarGeometry describes where a scroll viewport's scrollbar paints.
func GetScrollbarGeometry ¶
func GetScrollbarGeometry(box *LayoutBox) *ScrollbarGeometry
GetScrollbarGeometry computes where a scroll box's scrollbar paints, or nil if it should not paint. Mirrors upstream getScrollbarGeometry(box).
type SelectItem ¶
SelectItem mirrors upstream pi-tui's SelectItem shape for submenu-style selectors (value + label + optional description).
type SelectListTruncatePrimaryContext ¶
type SelectListTruncatePrimaryContext struct {
Text string
MaxWidth int
ColumnWidth int
Item SelectItem
IsSelected bool
}
SelectListTruncatePrimaryContext describes one primary-column truncation. Mirrors upstream SelectListTruncatePrimaryContext.
type SelectSubmenuComponent ¶
type SelectSubmenuComponent struct {
// contains filtered or unexported fields
}
SelectSubmenuComponent shows a titled select list with optional fuzzy search.
func NewSelectSubmenu ¶
func NewSelectSubmenu(title, description string, items []SelectItem, currentValue string, options ...SelectSubmenuOptions) *SelectSubmenuComponent
func (*SelectSubmenuComponent) Cancelled ¶
func (s *SelectSubmenuComponent) Cancelled() bool
func (*SelectSubmenuComponent) CurrentValue ¶
func (s *SelectSubmenuComponent) CurrentValue() string
func (*SelectSubmenuComponent) Done ¶
func (s *SelectSubmenuComponent) Done() bool
func (*SelectSubmenuComponent) HandleInput ¶
func (s *SelectSubmenuComponent) HandleInput(data string)
func (*SelectSubmenuComponent) Invalidate ¶
func (i *SelectSubmenuComponent) Invalidate()
func (*SelectSubmenuComponent) NeedsRedraw ¶
func (i *SelectSubmenuComponent) NeedsRedraw() bool
func (*SelectSubmenuComponent) Render ¶
func (s *SelectSubmenuComponent) Render(width int) []string
func (*SelectSubmenuComponent) SelectedValue ¶
func (s *SelectSubmenuComponent) SelectedValue() string
func (*SelectSubmenuComponent) String ¶
func (s *SelectSubmenuComponent) String() string
type SelectSubmenuOptions ¶
type SelectSubmenuOptions struct {
}
SelectSubmenuOptions enables fuzzy search and overrides the primary-column layout.
type SettingItem ¶
type SettingItem struct {
ID string // unique identifier
Label string // display label (left column)
Description string // shown below list when selected
CurrentValue string // right column
Values []string // Enter/Space cycles through these
}
SettingItem describes one toggle-able setting.
type SettingsList ¶
type SettingsList struct {
// Last change made (for the caller loop pattern).
ChangedID string
ChangedValue string
// contains filtered or unexported fields
}
SettingsList is a two-column selector that cycles setting values. After Done()==true, callers read ChangedID/ChangedValue for the last change, or Cancelled() if the user pressed Esc.
func NewSettingsList ¶
func NewSettingsList(items []SettingItem) *SettingsList
NewSettingsList creates the searchable settings list the /settings selector uses (upstream maxVisible 10, enableSearch true).
func NewSettingsListWithOptions ¶
func NewSettingsListWithOptions(items []SettingItem, maxVisible int, enableSearch bool) *SettingsList
NewSettingsListWithOptions mirrors upstream's SettingsList constructor arguments: maxVisible rows and SettingsListOptions.enableSearch. Nested settings menus pass Math.min(items.length, 10) and no search.
func (*SettingsList) Cancelled ¶
func (s *SettingsList) Cancelled() bool
Cancelled reports whether the user pressed Esc.
func (*SettingsList) Done ¶
func (s *SettingsList) Done() bool
Done reports whether the user confirmed a change or cancelled.
func (*SettingsList) HandleInput ¶
func (s *SettingsList) HandleInput(data string)
HandleInput processes keystrokes.
func (*SettingsList) HandleMouse ¶
func (s *SettingsList) HandleMouse(event TuiMouseEvent) *TuiMouseDispatchResult
HandleMouse moves selection by wheel, selects a visible row on press, and activates the pressed row on click. Pointer motion does not change selection. Mirrors upstream SettingsList.handleMouse.
func (*SettingsList) Invalidate ¶
func (i *SettingsList) Invalidate()
func (*SettingsList) NeedsRedraw ¶
func (i *SettingsList) NeedsRedraw() bool
func (*SettingsList) Render ¶
func (s *SettingsList) Render(width int) []string
Render draws the settings list. Matches upstream SettingsList.renderMainList.
func (*SettingsList) Reset ¶
func (s *SettingsList) Reset()
Reset clears done/cancelled so the list can be reused in a loop.
func (*SettingsList) UpdateValue ¶
func (s *SettingsList) UpdateValue(id, newValue string)
UpdateValue sets a new current value for the item with the given ID.
type ShowImagesSelectorComponent ¶
type ShowImagesSelectorComponent struct {
// contains filtered or unexported fields
}
ShowImagesSelectorComponent renders a yes/no selector for image display.
func NewShowImagesSelector ¶
func NewShowImagesSelector(currentValue bool, onSelect func(bool), onCancel func()) *ShowImagesSelectorComponent
NewShowImagesSelector creates the selector. currentValue pre-selects the matching entry. Confirm invokes onSelect; cancellation invokes onCancel.
func (*ShowImagesSelectorComponent) HandleInput ¶
func (s *ShowImagesSelectorComponent) HandleInput(data string)
HandleInput delegates to the list.
func (*ShowImagesSelectorComponent) Invalidate ¶
func (i *ShowImagesSelectorComponent) Invalidate()
func (*ShowImagesSelectorComponent) List ¶
func (s *ShowImagesSelectorComponent) List() *FilterableList
List returns the underlying FilterableList for input handling.
func (*ShowImagesSelectorComponent) NeedsRedraw ¶
func (i *ShowImagesSelectorComponent) NeedsRedraw() bool
func (*ShowImagesSelectorComponent) Render ¶
func (s *ShowImagesSelectorComponent) Render(width int) []string
Render wraps the list with dynamic borders.
func (*ShowImagesSelectorComponent) SelectedShowImages ¶
func (s *ShowImagesSelectorComponent) SelectedShowImages() (bool, bool)
SelectedShowImages returns the boolean result after selection. Returns (value, true) if a selection was made, (false, false) otherwise.
type SkillInvocationMessageComponent ¶
type SkillInvocationMessageComponent struct {
// contains filtered or unexported fields
}
SkillInvocationMessageComponent renders a skill invocation message.
func NewSkillInvocationMessage ¶
func NewSkillInvocationMessage(block ParsedSkillBlock) *SkillInvocationMessageComponent
NewSkillInvocationMessage creates a skill invocation component.
func (*SkillInvocationMessageComponent) Invalidate ¶
func (i *SkillInvocationMessageComponent) Invalidate()
func (*SkillInvocationMessageComponent) IsDirty ¶
func (i *SkillInvocationMessageComponent) IsDirty() bool
func (*SkillInvocationMessageComponent) NeedsRedraw ¶
func (i *SkillInvocationMessageComponent) NeedsRedraw() bool
func (*SkillInvocationMessageComponent) Render ¶
func (s *SkillInvocationMessageComponent) Render(width int) []string
Render produces the skill invocation lines. Mirrors upstream SkillInvocationMessageComponent which extends Box(paddingX=1, paddingY=1). In pig's line renderer, paddingY manifests as empty rows above and below content.
func (*SkillInvocationMessageComponent) SetExpanded ¶
func (s *SkillInvocationMessageComponent) SetExpanded(expanded bool)
SetExpanded toggles expanded/collapsed rendering.
type SlashCommand ¶
type SlashCommand struct {
Name string
Description string
ArgumentHint string
GetArgumentCompletions func(argPrefix string) []AutocompleteItem
}
SlashCommand is the autocomplete-side view of a registered slash command. Matches upstream's `SlashCommand` interface in autocomplete.ts. GetArgumentCompletions is optional; nil means the command takes no completable arguments.
type SlashOnlyProvider ¶
type SlashOnlyProvider struct {
Commands []SlashCommand
}
SlashOnlyProvider serves builtin slash commands and (when the buffer is `/<cmd> <args>`) delegates argument completion to the matched command's GetArgumentCompletions callback. No `@<file>`, no path completion, no async machinery: just slash.
Naming note: previously called "StaticProvider" during the port. Renamed to SlashOnlyProvider because the per-command GetArgumentCompletions callback makes it non-static (e.g. `/model` computes a fresh model list each invocation). The defining trait is "slash only, no @/path", which the name reflects.
func NewSlashOnlyProvider ¶
func NewSlashOnlyProvider(cmds []SlashCommand) *SlashOnlyProvider
NewSlashOnlyProvider constructs a provider over the given command list.
func (*SlashOnlyProvider) ApplyCompletion ¶
func (p *SlashOnlyProvider) ApplyCompletion(lines []string, cursorLine, cursorCol int, item AutocompleteItem, prefix string) ([]string, int, int)
ApplyCompletion replaces the trailing `prefix` chars of the current line with the completion text. Three behaviors:
- Slash-name completion (prefix starts with `/`, no space, at line start): inserts `/<value> ` (note trailing space). Cursor lands after the space. Mirrors autocomplete.ts:368-385.
- Argument completion (prefix is the arg text, line contains `/cmd `): inserts `value` at cursor. No trailing space.
- Other (defensive fallthrough): same as argument completion.
func (*SlashOnlyProvider) GetSuggestions ¶
func (p *SlashOnlyProvider) GetSuggestions(lines []string, cursorLine, cursorCol int) *AutocompleteSuggestions
GetSuggestions implements AutocompleteProvider. Three cases:
- Buffer doesn't start with `/` (after trim of leading line slice up to cursor) → return nil (popup off).
- `/<partial>` (no space) → fuzzy-filter command names.
- `/<cmd> <argPrefix>` (space present) → delegate to the matched command's GetArgumentCompletions.
Mirrors `CombinedAutocompleteProvider.getSuggestions` slash branch (autocomplete.ts:262-342): minus the `@`/path branches.
type Spacer ¶
type Spacer struct {
Lines int
// contains filtered or unexported fields
}
Spacer component that renders empty lines.
func (*Spacer) Invalidate ¶
func (i *Spacer) Invalidate()
func (*Spacer) NeedsRedraw ¶
func (i *Spacer) NeedsRedraw() bool
type Stack ¶
type Stack struct {
*Container
// contains filtered or unexported fields
}
Stack is the abstract base shared by HStack and VStack. It embeds pig's Container and maintains the parallel entries slice with flexbox metadata.
func (*Stack) Add ¶
Add shadows the promoted Container.Add so an options-free add still records an entry (equivalent to addChild with no options), keeping entries consistent.
func (*Stack) AddChild ¶
func (s *Stack) AddChild(component Component, options StackEntryOptions)
AddChild mirrors upstream Stack.addChild: it adds the component to the container and records its normalized flexbox entry. A provided option is normalized and stored; an omitted (nil) option is left unset so the allocator applies its default.
func (*Stack) Clear ¶
func (s *Stack) Clear()
Clear mirrors upstream Stack.clear: clear the container and the entries.
func (Stack) Invalidate ¶
func (i Stack) Invalidate()
func (*Stack) LayoutNode ¶
func (s *Stack) LayoutNode() LayoutNode
LayoutNode mirrors upstream Stack[LAYOUT_NODE](): the stack's layout node.
func (Stack) NeedsRedraw ¶
func (i Stack) NeedsRedraw() bool
func (*Stack) RemoveChild ¶
RemoveChild mirrors upstream Stack.removeChild: remove the component and its first matching entry.
type StackChild ¶
type StackChild struct {
Component Component
StackEntryOptions
}
StackChild is one child passed to a stack constructor. A bare component is StackChild{Component: c} with zero-value options (upstream's Component arm of the Component | StackEntry union); a configured child sets the options too.
type StackEntryOptions ¶
type StackEntryOptions struct {
Basis *int // nil == "auto"/undefined -> intrinsic size
Grow *int
Shrink *int
MinSize *int
MaxSize *int
Visible func(viewport LayoutViewport) bool
}
StackEntryOptions are the per-child flexbox options. A nil pointer field is upstream's "undefined": the allocator applies the default at read time (Basis nil == "auto" -> intrinsic, Grow 0, Shrink 1, MinSize 0, MaxSize maxSafeInteger).
type StackLayoutEntry ¶
type StackLayoutEntry struct {
Component Component
Basis *int
Grow *int
Shrink *int
MinSize *int
MaxSize *int
Visible func(viewport LayoutViewport) bool
}
StackLayoutEntry is one child in a stack with flexbox sizing. The pointer fields are upstream's optional properties: nil means "unset", and the allocator applies the upstream default (Basis nil == "auto" -> intrinsic size, Grow 0, Shrink 1, MinSize 0, MaxSize maxSafeInteger).
type StackLayoutNode ¶
type StackLayoutNode struct {
Type string
Entries []StackLayoutEntry
Gap int
Align string
}
StackLayoutNode is a vstack or hstack layout node. Type holds upstream's literal discriminant ("vstack" | "hstack"); Align holds "stretch" | "start" | "center" | "end".
type StackOptions ¶
StackOptions configure a stack. Gap nil defaults to 0; Align "" defaults to "stretch".
type StaticText ¶
type StaticText struct {
// contains filtered or unexported fields
}
StaticText is a Component that renders fixed pre-rendered lines. Used for content that never changes (e.g. login art/banner) but must survive full redraws because it's part of the TUI render buffer.
func NewStaticText ¶
func NewStaticText(lines []string) *StaticText
NewStaticText creates a StaticText component from pre-rendered lines.
func (*StaticText) Invalidate ¶
func (s *StaticText) Invalidate()
func (*StaticText) IsDirty ¶
func (s *StaticText) IsDirty() bool
func (*StaticText) NeedsRedraw ¶
func (s *StaticText) NeedsRedraw() bool
func (*StaticText) Render ¶
func (s *StaticText) Render(_ int) []string
type StatusIndicator ¶
StatusIndicator renders a loader either standalone or inside an editor border. Its owner advances animation and disposes operation timers on replacement.
func (StatusIndicator) Invalidate ¶
func (i StatusIndicator) Invalidate()
func (StatusIndicator) NeedsRedraw ¶
func (i StatusIndicator) NeedsRedraw() bool
func (*StatusIndicator) RenderInBorder ¶
func (s *StatusIndicator) RenderInBorder(width int) string
func (*StatusIndicator) RenderSpinnerInBorder ¶
func (s *StatusIndicator) RenderSpinnerInBorder(width int) string
type StopOptions ¶
type StopOptions struct {
// PreserveScreen leaves the alternate screen contents visible on exit
// instead of re-emitting the final frame into the main screen scrollback.
PreserveScreen bool
}
StopOptions controls alt-screen teardown. Mirrors upstream TuiStopOptions.
type TUI ¶
type TUI struct {
// contains filtered or unexported fields
}
TUI is the main-screen renderer: differential rendering into the terminal's main screen + scrollback, overlays, cursor, raw input. It ports pi-tui's TuiMainScreen (the concrete-type name TUI is kept for pig-wide call-site stability; the base machinery lives in the embedded tuiBase).
func NewWithOutput ¶
NewWithOutput creates a TUI that writes to a fixed io.Writer with fixed dimensions. Used only by tests; production code uses New().
func (*TUI) ActiveOverlay ¶
func (t *TUI) ActiveOverlay() Component
ActiveOverlay returns the currently focused eligible overlay component.
func (*TUI) CancelPendingRender ¶
func (t *TUI) CancelPendingRender()
CancelPendingRender invalidates a throttled frame, including one whose timer callback has already handed it to the owner loop. It maps the single-threaded JavaScript event-loop rule that a later state transition can consume a queued request before its callback runs.
func (*TUI) CaptureRenderState ¶
func (t *TUI) CaptureRenderState() TUIRenderState
CaptureRenderState snapshots the current inline-flow render state so a renderer swap can restore it. Mirrors upstream TuiMainScreen.captureRenderState.
func (*TUI) ConsumeCellSizeResponse ¶
ConsumeCellSizeResponse reports whether data is a complete cell-size response. A response with positive dimensions updates the cell dimensions, invalidates every mounted component so images re-render at the new size, and requests a render; a response with a zero dimension is still consumed. Any other input returns false so it reaches the focused component. Mirrors upstream tui.ts consumeCellSizeResponse.
func (*TUI) FocusedComponent ¶
func (t *TUI) FocusedComponent() Component
FocusedComponent returns the current overlay or non-overlay focus target.
func (*TUI) ForceFullRender ¶
func (t *TUI) ForceFullRender()
ForceFullRender marks the next Render() as a destructive full repaint. Use it when the physical buffer is invalid, including semantic transcript replacement, not for ordinary dynamic shrink or streaming updates.
func (*TUI) GetClearOnShrink ¶
GetClearOnShrink reports whether shrinking content triggers a full redraw to clear empty rows. Mirrors upstream TUI.getClearOnShrink().
func (*TUI) GetShowHardwareCursor ¶
func (t *TUI) GetShowHardwareCursor() bool
GetShowHardwareCursor reports whether the real terminal cursor is shown. Mirrors upstream TUI.getShowHardwareCursor().
func (*TUI) HasOverlay ¶
func (t *TUI) HasOverlay() bool
HasOverlay reports whether any overlay entry is mounted. The interactive driver uses this for the upstream hasOverlayEntries renderer-switch guard.
func (*TUI) HideCursor ¶
func (t *TUI) HideCursor()
func (*TUI) OpenOverlay ¶
func (t *TUI) OpenOverlay(c Component, opts OverlayOptions) *OverlayHandle
OpenOverlay pushes a component onto the overlay append stack and returns a targeted handle. Callers must Close when the overlay is dismissed.
func (*TUI) QueryCellSize ¶
func (t *TUI) QueryCellSize()
QueryCellSize writes the cell-size query when the terminal supports images, since only image rendering uses the cell size. Mirrors upstream tui.ts queryCellSize, which start() sends after the terminal starts.
func (*TUI) Render ¶
func (t *TUI) Render()
Render performs a differential render pass using inline-flow output.
Mirrors upstream pi-tui's `render()`. New content is appended with `\r\n`, which scrolls the viewport up and pushes older lines into the terminal's native scrollback. The terminal's normal scrolling makes our chat history reachable via the user's mouse wheel / Cmd-↑ after pig exits, just like a regular shell.
Algorithm sketch:
- Detect width/height change → fullRender(clear).
- First render → fullRender(no clear). Lines emitted with `\r\n` between them flow naturally.
- Diff prevLines vs newLines to find [firstChanged, lastChanged].
- If visible tail content shrinks and exposes rows above the old viewport, repaint only the new visible viewport.
- If only deletions remain, clear those rows in place.
- If firstChanged is above the current viewport → fullRender(clear).
- Otherwise: move cursor to firstChanged (scrolling if it's below the viewport bottom), rewrite affected lines, clear any extras.
func (*TUI) RenderSnapshot ¶
RenderSnapshot returns the current frame's fully rendered lines at the given width without writing to the terminal. Used by the /debug command to dump the frame. Mirrors upstream TUI.render(width) (tui.ts).
func (*TUI) RepaintAll ¶
func (t *TUI) RepaintAll()
HideCursor hides the terminal cursor. RepaintAll forces the next Render() to redo a full paint with screen clear, as if it were the first frame. Used after operations that hand the terminal to an external editor or suspend Pig to the shell. Those processes may leave arbitrary ANSI state behind.
func (*TUI) RequestRender ¶
func (t *TUI) RequestRender()
RequestRender asks the TUI to render soon, coalescing repeated calls and enforcing the upstream 16ms frame throttle. Use this for hot streaming paths (thinking/text deltas); direct Render() is reserved for low-frequency state changes and final flushes.
func (*TUI) RestoreRenderState ¶
func (t *TUI) RestoreRenderState(state TUIRenderState)
RestoreRenderState restores a previously captured render state so the next differential render is computed against the pre-switch screen. Image lines are blanked and the Kitty image-id set is cleared, since those images are no longer on the terminal after the switch. Mirrors upstream TuiMainScreen.restoreRenderState.
func (*TUI) SetClearOnShrink ¶
SetClearOnShrink configures whether shrinking content triggers a full redraw when no overlays are active. Mirrors upstream TUI.setClearOnShrink().
func (*TUI) SetFixedSize ¶
func (t *TUI) SetFixedSize(cols, rows int)
SetFixedSize changes the size of a renderer built with a fixed size (NewWithOutput), as a terminal resize would; the next render sees it. Renderers that read the real terminal size ignore it.
func (*TUI) SetFocus ¶
func (t *TUI) SetFocus(component Component)
SetFocus records a non-overlay target for focus restoration.
func (*TUI) SetLogDirectory ¶
SetLogDirectory sets the directory for the overflow crash log. Mirrors the upstream TuiBase logDirectory constructor argument (getAgentDir() in interactive mode). Empty selects the OS temp directory.
func (*TUI) SetOnHeightChange ¶
func (t *TUI) SetOnHeightChange(fn func(height int))
SetOnHeightChange registers a callback that fires whenever the terminal height changes between render frames. Thread-safe.
func (*TUI) SetOnWidthChange ¶
func (t *TUI) SetOnWidthChange(fn func(width int))
SetOnWidthChange registers a callback that fires whenever the terminal width changes between render frames. Thread-safe.
func (*TUI) SetOverlayCommandDispatcher ¶
func (t *TUI) SetOverlayCommandDispatcher(dispatch func(func()))
SetOverlayCommandDispatcher installs the ordered ingress used by remote producers. The dispatcher owns command ordering on the application loop.
func (*TUI) SetRenderDispatcher ¶
func (t *TUI) SetRenderDispatcher(dispatch func(render func()))
SetRenderDispatcher installs a hook that runs throttled scheduled renders on the caller's main loop. The dispatcher receives a render closure and is responsible for eventually invoking it on the goroutine that owns component-tree mutation (it may enqueue it on an event loop). When nil (default), scheduled renders run inline on the throttle-timer goroutine, which is correct for standalone / single-goroutine use. Thread-safe.
func (*TUI) SetShowHardwareCursor ¶
SetShowHardwareCursor controls whether the real terminal cursor is shown while still positioning it for IME/caret parity. Mirrors upstream TUI.setShowHardwareCursor().
func (*TUI) SetTickDispatcher ¶
func (t *TUI) SetTickDispatcher(dispatch func(func()))
SetTickDispatcher installs the blocking owner-loop seam for owned state-machine ticks (alt-screen selection auto-scroll). It must marshal fn onto the loop that owns rendering, backpressuring rather than dropping while that loop is alive; see the tickOnMain doc. When unset the tick runs inline. Thread-safe.
func (*TUI) StopWithOptions ¶
func (t *TUI) StopWithOptions(options StopOptions)
StopWithOptions tears down the main-screen renderer. With PreserveScreen set (a live tui-mode switch), it skips the final cursor-park-and-newline emission so the swap produces no end-of-session output; mirrors upstream TuiMainScreen.stop({ preserveScreen }). Plain Stop() keeps the shutdown behavior that parks the cursor below the content.
type TUIKeybinding ¶
type TUIKeybinding = string
TUIKeybinding is a named action for TUI components.
const ( KBAltScreenHalfPageUp TUIKeybinding = "tui.altScreen.halfPageUp" KBAltScreenHalfPageDown TUIKeybinding = "tui.altScreen.halfPageDown" KBAltScreenLineUp TUIKeybinding = "tui.altScreen.lineUp" KBAltScreenLineDown TUIKeybinding = "tui.altScreen.lineDown" KBAltScreenSearch TUIKeybinding = "tui.altScreen.search" KBAltScreenSearchNext TUIKeybinding = "tui.altScreen.searchNext" KBAltScreenSearchPrevious TUIKeybinding = "tui.altScreen.searchPrevious" KBAltScreenSearchClose TUIKeybinding = "tui.altScreen.searchClose" )
Alt-screen viewport actions added in pi-tui v0.87.1 keybindings.ts. The action names are defined here; their default keys join tuiKeybindingDefs with the per-platform TUI defaults.
const ( // Editor navigation and editing KBEditorCursorUp TUIKeybinding = "tui.editor.cursorUp" KBEditorCursorDown TUIKeybinding = "tui.editor.cursorDown" KBEditorHistoryPrevious TUIKeybinding = "tui.editor.historyPrevious" KBEditorHistoryNext TUIKeybinding = "tui.editor.historyNext" KBEditorCursorLeft TUIKeybinding = "tui.editor.cursorLeft" KBEditorCursorRight TUIKeybinding = "tui.editor.cursorRight" KBEditorCursorWordLeft TUIKeybinding = "tui.editor.cursorWordLeft" KBEditorCursorWordRight TUIKeybinding = "tui.editor.cursorWordRight" KBEditorCursorLineStart TUIKeybinding = "tui.editor.cursorLineStart" KBEditorCursorLineEnd TUIKeybinding = "tui.editor.cursorLineEnd" KBEditorJumpForward TUIKeybinding = "tui.editor.jumpForward" KBEditorJumpBackward TUIKeybinding = "tui.editor.jumpBackward" KBEditorPageUp TUIKeybinding = "tui.editor.pageUp" KBEditorPageDown TUIKeybinding = "tui.editor.pageDown" KBEditorDeleteCharBack TUIKeybinding = "tui.editor.deleteCharBackward" KBEditorDeleteCharForward TUIKeybinding = "tui.editor.deleteCharForward" KBEditorDeleteWordBack TUIKeybinding = "tui.editor.deleteWordBackward" KBEditorDeleteWordForward TUIKeybinding = "tui.editor.deleteWordForward" KBEditorDeleteToLineStart TUIKeybinding = "tui.editor.deleteToLineStart" KBEditorDeleteToLineEnd TUIKeybinding = "tui.editor.deleteToLineEnd" KBEditorYank TUIKeybinding = "tui.editor.yank" KBEditorYankPop TUIKeybinding = "tui.editor.yankPop" KBEditorUndo TUIKeybinding = "tui.editor.undo" // Generic input actions KBInputNewLine TUIKeybinding = "tui.input.newLine" KBInputSubmit TUIKeybinding = "tui.input.submit" KBInputTab TUIKeybinding = "tui.input.tab" KBInputCopy TUIKeybinding = "tui.input.copy" // Generic selection actions KBSelectUp TUIKeybinding = "tui.select.up" KBSelectDown TUIKeybinding = "tui.select.down" KBSelectPageUp TUIKeybinding = "tui.select.pageUp" KBSelectPageDown TUIKeybinding = "tui.select.pageDown" KBSelectConfirm TUIKeybinding = "tui.select.confirm" KBSelectCancel TUIKeybinding = "tui.select.cancel" // Alt-screen (fullscreen) viewport actions KBAltScreenPageUp TUIKeybinding = "tui.altScreen.pageUp" KBAltScreenPageDown TUIKeybinding = "tui.altScreen.pageDown" KBAltScreenPreviousPrompt TUIKeybinding = "tui.altScreen.previousPrompt" KBAltScreenNextPrompt TUIKeybinding = "tui.altScreen.nextPrompt" KBAltScreenTop TUIKeybinding = "tui.altScreen.top" KBAltScreenBottom TUIKeybinding = "tui.altScreen.bottom" )
TUI keybinding action constants: mirrors upstream Keybindings interface.
type TUIKeybindingConflict ¶
TUIKeybindingConflict records a key bound to multiple actions.
type TUIKeybindingDef ¶
TUIKeybindingDef defines a keybinding's default keys and description.
type TUIKeybindingsManager ¶
type TUIKeybindingsManager struct {
// contains filtered or unexported fields
}
TUIKeybindingsManager resolves keybindings for TUI components. Mirrors upstream KeybindingsManager in packages/tui/src/keybindings.ts.
func GetKeybindings ¶
func GetKeybindings() *TUIKeybindingsManager
GetKeybindings mirrors upstream getKeybindings().
func GetTUIKeybindings ¶
func GetTUIKeybindings() *TUIKeybindingsManager
GetTUIKeybindings returns the global TUI keybinding manager, creating a default one if none has been set.
func NewKeybindingsManager ¶
func NewKeybindingsManager(definitions map[string]TUIKeybindingDef, userBindings map[string][]string) *TUIKeybindingsManager
NewKeybindingsManager creates a manager over an explicit definition table. Mirrors upstream `new KeybindingsManager(definitions, userBindings)`; the coding agent passes its merged tui.* and app.* table here so components in this package resolve app actions (tree labels, thinking save) through the same manager, as upstream's single KEYBINDINGS table does.
func NewTUIKeybindingsManager ¶
func NewTUIKeybindingsManager(userBindings map[string][]string) *TUIKeybindingsManager
NewTUIKeybindingsManager creates a manager with the built-in TUI definitions for this host and optional user overrides.
func (*TUIKeybindingsManager) GetConflicts ¶
func (m *TUIKeybindingsManager) GetConflicts() []TUIKeybindingConflict
GetConflicts returns any user-binding conflicts detected.
func (*TUIKeybindingsManager) GetDefinition ¶
func (m *TUIKeybindingsManager) GetDefinition(action TUIKeybinding) (TUIKeybindingDef, bool)
GetDefinition returns the definition for a keybinding action.
func (*TUIKeybindingsManager) GetKeys ¶
func (m *TUIKeybindingsManager) GetKeys(action TUIKeybinding) []string
GetKeys returns the resolved keys for a keybinding action.
func (*TUIKeybindingsManager) GetResolvedBindings ¶
func (m *TUIKeybindingsManager) GetResolvedBindings() map[string]any
GetResolvedBindings returns the fully resolved binding table after applying defaults and user overrides. Mirrors upstream getResolvedBindings().
func (*TUIKeybindingsManager) GetUserBindings ¶
func (m *TUIKeybindingsManager) GetUserBindings() map[string][]string
GetUserBindings returns a defensive copy of the raw user overrides. Mirrors upstream KeybindingsManager.getUserBindings().
func (*TUIKeybindingsManager) HasBinding ¶
func (m *TUIKeybindingsManager) HasBinding(action TUIKeybinding) bool
HasBinding reports whether the manager owns an action, including an explicit empty user override for an app.* action bridged from coding-agent.
func (*TUIKeybindingsManager) Matches ¶
func (m *TUIKeybindingsManager) Matches(data string, action TUIKeybinding) bool
Matches checks whether raw terminal input data matches a keybinding action. Uses the same keyIDInputs lookup table as the app-level keybindings for legacy terminal sequence matching.
func (*TUIKeybindingsManager) SetUserBindings ¶
func (m *TUIKeybindingsManager) SetUserBindings(bindings map[string][]string)
SetUserBindings replaces user overrides and rebuilds.
type TUIRenderState ¶
type TUIRenderState struct {
PrevLines []string
PrevWidth int
PrevHeight int
CursorRow int
HardwareCursorRow int
MaxLinesRendered int
PrevViewportTop int
}
Stop cleanly shuts down the TUI. Moves the cursor to the end of rendered content, writes a newline, and shows the cursor. This preserves the screen content so the user sees the final state after exit. Mirrors upstream tui.ts stop() (lines 473-494). TUIRenderState is a snapshot of the main-screen renderer's inline-flow render state. It lets InteractiveMode preserve regular-mode scrollback position across a live tui-mode switch (a fullscreen round-trip discards and rebuilds the renderer). Mirrors upstream TuiMainScreenRenderState (tui-main-screen.ts:46).
type Terminal ¶
type Terminal interface {
// Start enters raw mode, spawns a goroutine that reads stdin and
// invokes onInput for each chunk, and registers a SIGWINCH handler
// that invokes onResize on terminal resize. Returns an error if raw
// mode could not be entered. Mirrors upstream `ProcessTerminal.start`.
Start(onInput func([]byte), onResize func()) error
// Stop reverses Start: cancels and joins the input goroutine, removes the
// resize handler, and restores cooked mode without draining unread input.
// Call DrainInput explicitly before Stop only at process shutdown.
Stop()
DrainInput(maxWait, idleWait time.Duration) error
Write(data string)
Columns() int
Rows() int
KittyProtocolActive() bool
MoveBy(lines int)
HideCursor()
ShowCursor()
ClearLine()
ClearFromCursor()
ClearScreen()
SetTitle(title string)
SetProgress(active bool)
}
Terminal mirrors the control surface of upstream `terminal.ts` in Go form.
Faithful port note: upstream's `start(onInput, onResize)` / `stop()` pair is provided here as `Start` / `Stop`. They are thin wrappers over `EnterRawMode` + a goroutine input loop + SIGWINCH notify, so legacy caller-owns-loop code paths (interactive mode, session selectors, the extension UI) keep working through `EnterRawMode` directly. New callers can use `Start`/`Stop` for a behavior-equivalent surface to upstream.
type TerminalCapabilities ¶
type TerminalCapabilities struct {
Images ImageProtocol
TrueColor bool
Hyperlinks bool
}
func DetectCapabilities ¶
func DetectCapabilities(tmuxForwardsHyperlink func() bool) TerminalCapabilities
DetectCapabilities mirrors upstream detectCapabilities: PI_HYPERLINKS, PI_IMAGE_PROTOCOL, and PI_TRUE_COLOR override auto-detection, and an explicit PI_HYPERLINKS replaces the tmux probe. A nil tmuxForwardsHyperlink uses the default tmux probe.
func GetCapabilities ¶
func GetCapabilities() TerminalCapabilities
GetCapabilities mirrors upstream getCapabilities: detection with the PI_* environment, then the settings overrides on top.
type TerminalTheme ¶
type TerminalTheme string
func GetThemeForRgbColor ¶
func GetThemeForRgbColor(rgb RgbColor) TerminalTheme
type TerminalThemeDetection ¶
type TerminalThemeDetection struct {
Theme TerminalTheme
Source string
Detail string
Confidence string
}
func DetectTerminalBackground ¶
func DetectTerminalBackground(options TerminalThemeDetectionOptions) TerminalThemeDetection
type Text ¶
type Text struct {
Content string
PaddingX int
PaddingY int
CustomBgFn func(string) string
Style string // pig compatibility: extra ANSI prefix applied per line
// contains filtered or unexported fields
}
Text component - displays multi-line text with word wrapping.
func NewPaddedText ¶
NewPaddedText creates a text component with explicit padding.
func NewText ¶
NewText creates a text component. pig keeps zero padding as the default for existing call sites; upstream-style padding is available via fields.
func (*Text) Invalidate ¶
func (t *Text) Invalidate()
func (*Text) NeedsRedraw ¶
func (i *Text) NeedsRedraw() bool
func (*Text) SetCustomBgFn ¶
type TextInput ¶
type TextInput struct {
Focused bool
OnSubmit func(value string)
OnEscape func()
// contains filtered or unexported fields
}
TextInput is a bare single-line text input component.
func NewInput ¶
func NewInput(options InputOptions) *TextInput
NewInput creates an input with upstream Input's options and its OnSubmit/OnEscape contract. Mirrors upstream new Input(options).
func NewTextInput ¶
NewTextInput creates a text input with the given title/prompt.
func (*TextInput) HandleInput ¶
HandleInput processes a key event.
func (*TextInput) HandleMouse ¶
func (t *TextInput) HandleMouse(event TuiMouseEvent) *TuiMouseDispatchResult
HandleMouse moves the cursor to a left press on the input row and requests focus. Mirrors upstream Input.handleMouse.
func (*TextInput) Invalidate ¶
func (i *TextInput) Invalidate()
func (*TextInput) NeedsRedraw ¶
func (i *TextInput) NeedsRedraw() bool
type Theme ¶
type Theme struct {
// Name of the theme (e.g. "dark", "light", or a custom name).
Name string
// ─── Core colors ─────────────────────────────────────────
Accent string // accent text (teal/cyan)
Success string // green
Error string // red
Warning string // yellow
Muted string // gray
Dim string // dim gray
Text string // default text (empty = terminal default)
// ─── Border colors ───────────────────────────────────────
Border string // blue
BorderAccent string // cyan
BorderMuted string // dark gray
// ─── Background colors ───────────────────────────────────
UserMessageBg string // ANSI bg escape
UserMessageText string // fg text on user message bg
ToolPendingBg string // tool running
ToolSuccessBg string // tool completed successfully
ToolErrorBg string // tool failed
ToolTitle string // tool header text
ToolOutput string // tool output text (gray)
SelectedBg string // selected item bg
CustomMessageBg string // custom message bg
CustomMessageText string // custom message text
CustomMessageLabel string // custom message label
// ─── Markdown colors ─────────────────────────────────────
MDHeading string
MDLink string
MDLinkUrl string
MDCode string
MDCodeBlock string
MDCodeBlockBorder string
MDQuote string
MDQuoteBorder string
MDHr string
MDListBullet string
// ─── Diff colors ─────────────────────────────────────────
ToolDiffAdded string
ToolDiffRemoved string
ToolDiffContext string
// ─── Syntax highlighting ─────────────────────────────────
SyntaxComment string
SyntaxKeyword string
SyntaxFunction string
SyntaxVariable string
SyntaxString string
SyntaxNumber string
SyntaxType string
SyntaxOperator string
SyntaxPunctuation string
// ─── Thinking level indicators ───────────────────────────
ThinkingText string
ThinkingOff string
ThinkingMinimal string
ThinkingLow string
ThinkingMedium string
ThinkingHigh string
ThinkingXhigh string
// ─── Misc ────────────────────────────────────────────────
BashMode string // bash mode indicator
// ─── Export colors (for HTML export) ─────────────────────
ExportPageBg string // hex string (not ANSI)
ExportCardBg string // hex string
ExportInfoBg string // hex string
// Reset escapes.
BgClose string
Reset string
// contains filtered or unexported fields
}
Theme holds the resolved color palette for the current session. All fields are pre-computed ANSI escape sequences (fg or bg).
func LoadBuiltinTheme ¶
LoadBuiltinTheme returns a built-in theme by name ("dark" or "light").
func LoadThemeFile ¶
LoadThemeFile reads a theme JSON file and returns the resolved Theme.
func (*Theme) ANSIPalette ¶
ANSIPalette returns every resolved token as foreground and background ANSI openings. It is used at process boundaries where theme helper functions cannot cross but their current immutable token table can.
func (*Theme) Bg ¶
Bg returns the ANSI background escape for a named color token. Mirrors upstream theme.bg(tokenName, text).
func (*Theme) ColorKeys ¶
ColorKeys returns the color token names in their original JSON insertion order. Used by HTML export to emit CSS variables in the same order as upstream.
func (*Theme) Colors ¶
Colors returns the resolved theme colors as CSS values keyed by token name, with 256-color indexes converted to hex and terminal-default colors mapped to Pi's light/dark HTML fallback (theme.ts getResolvedThemeColors). Used by HTML export to mirror upstream CSS variable generation.
func (*Theme) Fg ¶
Fg returns the ANSI foreground escape for a named color token. Mirrors upstream theme.fg(tokenName, text). Returns empty string if token not found (terminal default).
func (*Theme) FgText ¶
FgText returns text wrapped in the foreground color and reset. Mirrors upstream theme.fg(tokenName, text).
func (*Theme) WithColorMode ¶
WithColorMode returns this theme resolved in mode, mirroring theme.ts createTheme(themeJson, mode). Rebuilt themes are not cached, so obsolete themes can be collected. A theme without JSON source is returned unchanged.
type ThemeColorValue ¶
type ThemeColorValue struct {
Text string
Index int
IsIndex bool
// contains filtered or unexported fields
}
ThemeColorValue mirrors theme-json.ts ColorValue: a hex color, variable reference or empty string (Text), or a 256-color palette index (Index, when IsIndex is set).
func (*ThemeColorValue) UnmarshalJSON ¶
func (v *ThemeColorValue) UnmarshalJSON(data []byte) error
UnmarshalJSON accepts a JSON string or an integral JSON number. The 0..255 range is enforced by ValidateThemeJSON for user-authored themes.
type ThemeJSON ¶
type ThemeJSON struct {
Name string `json:"name"`
Vars map[string]ThemeColorValue `json:"vars"`
Colors map[string]ThemeColorValue `json:"colors"`
Export map[string]ThemeColorValue `json:"export,omitempty"`
// contains filtered or unexported fields
}
ThemeJSON is the upstream-compatible theme file schema. Mirrors upstream theme-schema.json.
type ThemeRegistry ¶
type ThemeRegistry struct {
// contains filtered or unexported fields
}
ThemeRegistry holds all loaded themes and enables switching.
func ActiveThemeRegistry ¶
func ActiveThemeRegistry() *ThemeRegistry
ActiveThemeRegistry returns the global theme registry. Initializes with built-in themes on first call.
func NewThemeRegistry ¶
func NewThemeRegistry() *ThemeRegistry
NewThemeRegistry creates a registry with the built-in dark and light themes.
func (*ThemeRegistry) Add ¶
func (r *ThemeRegistry) Add(t *Theme)
Add registers a theme. If a theme with the same name already exists, it is replaced. The name is derived from the theme's Name field.
func (*ThemeRegistry) Get ¶
func (r *ThemeRegistry) Get(name string) *Theme
Get returns a theme by name, or nil.
func (*ThemeRegistry) LoadDir ¶
func (r *ThemeRegistry) LoadDir(dir string) error
LoadDir scans a directory for .json theme files and registers them, recording each theme's source file so extensions can report it.
func (*ThemeRegistry) Names ¶
func (r *ThemeRegistry) Names() []string
Names returns the list of available theme names.
func (*ThemeRegistry) PathOf ¶
func (r *ThemeRegistry) PathOf(name string) string
PathOf returns the file a theme was loaded from, or "" for built-ins.
type ThemeSelectorComponent ¶
type ThemeSelectorComponent struct {
// contains filtered or unexported fields
}
ThemeSelectorComponent renders a theme picker with live preview.
func NewThemeSelector ¶
func NewThemeSelector( currentTheme string, onSelect func(string), onCancel func(), onPreview func(string), ) *ThemeSelectorComponent
NewThemeSelector creates a theme selector. currentTheme is pre-selected; onPreview fires on cursor movement for live preview.
func (*ThemeSelectorComponent) HandleInput ¶
func (ts *ThemeSelectorComponent) HandleInput(data string)
HandleInput delegates to the list.
func (*ThemeSelectorComponent) Invalidate ¶
func (i *ThemeSelectorComponent) Invalidate()
func (*ThemeSelectorComponent) List ¶
func (ts *ThemeSelectorComponent) List() *FilterableList
List returns the underlying FilterableList for input handling.
func (*ThemeSelectorComponent) NeedsRedraw ¶
func (i *ThemeSelectorComponent) NeedsRedraw() bool
func (*ThemeSelectorComponent) Render ¶
func (ts *ThemeSelectorComponent) Render(width int) []string
Render wraps the list with borders.
type ThinkingBlock ¶
type ThinkingBlock struct {
// contains filtered or unexported fields
}
ThinkingBlock is a TUI component that renders a thinking/reasoning block.
func NewThinkingBlock ¶
func NewThinkingBlock(hidden bool) *ThinkingBlock
NewThinkingBlock creates a thinking block. Pass hidden=true when the user has toggled visibility off (Ctrl+T). Content starts empty (invisible).
func (*ThinkingBlock) Content ¶
func (b *ThinkingBlock) Content() string
Content returns the current thinking text.
func (*ThinkingBlock) Invalidate ¶
func (i *ThinkingBlock) Invalidate()
func (*ThinkingBlock) NeedsRedraw ¶
func (i *ThinkingBlock) NeedsRedraw() bool
func (*ThinkingBlock) Render ¶
func (b *ThinkingBlock) Render(width int) []string
Render implements Component. Returns nil/empty when content is empty (invisible, takes zero height).
func (*ThinkingBlock) SetContent ¶
func (b *ThinkingBlock) SetContent(content string)
SetContent updates the thinking text (streaming or final).
func (*ThinkingBlock) SetHidden ¶
func (b *ThinkingBlock) SetHidden(hidden bool)
SetHidden controls whether the full text or a "Thinking..." indicator is shown.
type ToolExecutionComponent ¶
type ToolExecutionComponent struct {
Name string
Label string // human-readable display name (if set, used in header instead of Name)
// ArgsPreview is a short human-readable rendering of the tool args.
// Build it with FormatToolArgs() before assigning, or use SetRunning().
ArgsPreview string
// Cwd is the session working directory, used to resolve relative tool
// paths to absolute file:// URLs for OSC-8 hyperlinks in the header.
Cwd string
State ToolExecutionState
Output string
// Collapsed controls the renderer's expanded state. New tool cards start
// collapsed to match upstream; final results may apply tool-specific rules.
Collapsed bool
// Elapsed is shown on done/error states when > 0.
Elapsed time.Duration
// StartedAt records when the tool began executing. Used to render a live
// "Elapsed X.Xs" footer while a shell tool runs (mirrors upstream bash.ts
// renderResult, which ticks the elapsed every second during execution).
StartedAt time.Time
// Configurable thresholds. Zero values fall back to defaults.
AutoCollapseLines int // default 8
BodyMaxLines int // default 40
// BodyRenderer, when non-nil, replaces the default plain-text body
// rendering. Used for per-tool rich displays: unified diff for
// edit, line-numbered output for read, etc. The function receives
// the available width and the current expanded state so it can show
// a truncated preview or full output depending on Ctrl+O toggle.
//
// When set, the line-count annotation in the header is computed
// from the renderer's row count instead of the raw Output text so
// `(N lines, 1.2s)` accurately reflects what the user can see.
BodyRenderer func(width int, expanded bool) []string
// ImageBlocks holds image content blocks from tool results.
// When non-empty and ShowImages is true, they render after the body.
// Mirrors upstream tool-execution.ts imageComponents/imageSpacers.
ImageBlocks []ImageBlock
// ShowImages controls whether ImageBlocks are rendered.
// Mirrors upstream ToolExecutionOptions.showImages.
ShowImages bool
// ImageWidthCells caps the width of rendered images in columns.
// Mirrors upstream ToolExecutionOptions.imageWidthCells (default 60).
ImageWidthCells int
// IsPartial mirrors upstream tool-execution.ts isPartial. true while
// the tool is still being streamed/executed, false after final result.
// Controls the pending bg tint before execution completes.
IsPartial bool
// contains filtered or unexported fields
}
ToolExecutionComponent renders one tool call in the chat transcript.
Visual model (mirrors upstream per-tool renderCall functions):
$ expr 20 + 22 ← bash: bold "$ <command>" read README.md ← read: bold "read <path>" write out.txt ← write: bold "write <path>" edit main.go ← edit: bold "edit <path>" grep /pattern/ in . ← grep: bold "grep /<pat>/ in <path>" find *.go in . ← find: bold "find <pat> in <path>" ls src/ ← ls: bold "ls <path>"
No lifecycle markers (✓/▶/✗): upstream conveys state only via background color (pending, success, error). No "(N lines, Xs)" annotation in the header: upstream shows duration in body footer.
State transitions:
- SetRunning: state → Running, output cleared
- SetResult: state → Done or Error, body filled
Output thresholds:
- autoCollapseLines: outputs longer than this start collapsed (overridden to expanded for errors)
- bodyMaxLines: lines shown in the expanded view; overflow shows a "\u2026 (N more lines)" footer line.
func NewToolExecutionComponent ¶
func NewToolExecutionComponent(name, argsPreview string) *ToolExecutionComponent
NewToolExecutionComponent returns a Running-state component for the given tool. Args may be empty.
func (*ToolExecutionComponent) ApplyConvertedImage ¶
func (c *ToolExecutionComponent) ApplyConvertedImage(req KittyImageConversion, converted *ConvertedImage) bool
ApplyConvertedImage mirrors the resolution half of upstream maybeConvertImagesForKitty. A failed conversion (nil) or one that finishes after its image block was replaced is ignored (upstream issue #8577); otherwise the conversion is cached and the component invalidated. It reports whether the conversion was applied, so the caller knows to request a render.
func (*ToolExecutionComponent) Collapse ¶
func (c *ToolExecutionComponent) Collapse()
Collapse forces the body closed.
func (*ToolExecutionComponent) Expand ¶
func (c *ToolExecutionComponent) Expand()
Expand forces the body open.
func (*ToolExecutionComponent) FinalizeAborted ¶
func (c *ToolExecutionComponent) FinalizeAborted(elapsed time.Duration)
FinalizeAborted freezes a still-running tool when its turn is aborted mid-execution. It transitions out of Running so the live "Elapsed X.Xs" footer stops recomputing time.Since(StartedAt) on every subsequent render (which otherwise forced a repaint on every keystroke and agent chunk, breaking terminal scrollback) while keeping any partial streamed output. No-op if the tool already reached a terminal state.
func (*ToolExecutionComponent) Invalidate ¶
func (i *ToolExecutionComponent) Invalidate()
func (*ToolExecutionComponent) IsDirty ¶
func (c *ToolExecutionComponent) IsDirty() bool
IsDirty reports whether the component needs re-rendering. While a shell tool runs, the live "Elapsed X.Xs" footer recomputes time.Since(StartedAt) on every frame driven by the 100ms tick loop, but the tick does not Invalidate this component. Reporting dirty while that footer is live keeps the per-child render cache from freezing the elapsed counter.
func (*ToolExecutionComponent) MarkExecutionStarted ¶
func (c *ToolExecutionComponent) MarkExecutionStarted()
MarkExecutionStarted records that the tool has begun executing. Mirrors upstream tool-execution.ts markExecutionStarted.
func (*ToolExecutionComponent) NeedsRedraw ¶
func (i *ToolExecutionComponent) NeedsRedraw() bool
func (*ToolExecutionComponent) PendingKittyImageConversions ¶
func (c *ToolExecutionComponent) PendingKittyImageConversions() []KittyImageConversion
PendingKittyImageConversions mirrors the selection half of upstream maybeConvertImagesForKitty: on a Kitty terminal it returns every image block with data and a MIME type that is not PNG and has no conversion cached for its current source. The caller converts each one off the UI loop and hands the result to ApplyConvertedImage on the loop.
func (*ToolExecutionComponent) Render ¶
func (c *ToolExecutionComponent) Render(width int) []string
Render emits header + (optional) body lines, all bg-painted in the lifecycle color (pending / success / error). Row 2.9a.
Upstream wraps content in Box(paddingX=1, paddingY=1, bgFn) which adds 1-row vertical padding above and below, plus 1-column left padding on each content line. We replicate this layout exactly: top-pad, header, separator, body, bottom-pad: all bg-painted.
func (*ToolExecutionComponent) SetArgsComplete ¶
func (c *ToolExecutionComponent) SetArgsComplete()
SetArgsComplete records that the args JSON is finalized. Mirrors upstream tool-execution.ts setArgsComplete.
func (*ToolExecutionComponent) SetExpanded ¶
func (c *ToolExecutionComponent) SetExpanded(expanded bool)
SetExpanded forces the body open or closed and records the user's intent so subsequent SetResult calls don't snap it back. Used by global Ctrl+O (toggle-all-tools) so every component lands in the same state.
func (*ToolExecutionComponent) SetImageWidthCells ¶
func (c *ToolExecutionComponent) SetImageWidthCells(width int)
SetImageWidthCells updates the max image width. Mirrors upstream setImageWidthCells.
func (*ToolExecutionComponent) SetResult ¶
func (c *ToolExecutionComponent) SetResult(output string, isError bool, elapsed time.Duration)
SetResult finalises the component with output text and an error flag, applying the auto-collapse rule unless the user has already toggled.
func (*ToolExecutionComponent) SetRunning ¶
func (c *ToolExecutionComponent) SetRunning(argsPreview string)
SetRunning marks the component as in-flight with the given pre-formatted args preview. Idempotent.
func (*ToolExecutionComponent) SetShowImages ¶
func (c *ToolExecutionComponent) SetShowImages(show bool)
SetShowImages toggles image rendering. Mirrors upstream setShowImages.
func (*ToolExecutionComponent) SetStreaming ¶
func (c *ToolExecutionComponent) SetStreaming(snapshot string)
SetStreaming updates the live output body during execution without changing expansion state. Only SetExpanded or Toggle changes that state while running.
func (*ToolExecutionComponent) SetStructuredArgs ¶
func (c *ToolExecutionComponent) SetStructuredArgs(args json.RawMessage)
SetStructuredArgs enables the generic extension tool-details renderer and retains a valid argument value for width-aware collapsed and expanded views.
func (*ToolExecutionComponent) Toggle ¶
func (c *ToolExecutionComponent) Toggle()
Toggle flips the collapsed state and records that the user touched it so subsequent SetResult calls don't snap it back.
func (*ToolExecutionComponent) UpdateArgs ¶
func (c *ToolExecutionComponent) UpdateArgs(name string, partialArgsJSON string)
UpdateArgs updates the displayed header from partial/complete args. Called progressively during streaming as ToolCallDelta events arrive. Mirrors upstream tool-execution.ts updateArgs.
type ToolExecutionState ¶
type ToolExecutionState int
ToolExecutionState is the lifecycle stage of a tool call display.
const ( ToolStateRunning ToolExecutionState = iota ToolStateDone ToolStateError )
type TreeNode ¶
type TreeNode interface {
NodeID() string
NodeLabel() string // single-line display, no \n
NodeChildren() []TreeNode
}
TreeNode is the shape TreeSelect operates on. SessionTreeNode in codingagent satisfies this via a thin adapter.
type TreeNodeSearchableText ¶
type TreeNodeSearchableText interface {
// NodeSearchableText returns the lowercase-matchable text for the
// node, excluding any ANSI formatting.
NodeSearchableText() string
}
TreeNodeSearchableText is implemented by adapters that expose the plain-text a type-to-search query is matched against. Mirrors upstream `getSearchableText` (tree-selector.ts:559-600): the label plus role, message content, and entry-type fields. Adapters that don't implement it are matched on their NodeLabel only.
type TreeNodeWithBranchLabel ¶
type TreeNodeWithBranchLabel interface {
// NodeBranchLabel returns the user-set branch label, or "" when none is set.
NodeBranchLabel() string
}
TreeNodeWithBranchLabel is implemented by adapters that carry a user-set branch label. Upstream renders this label outside the entry text as theme.fg("warning", "[label] ") (tree-selector.ts:673); it must not be folded into NodeLabel(), otherwise it loses its warning colour and selected rows bold the label instead of only bolding entry content.
type TreeNodeWithFilterTags ¶
type TreeNodeWithFilterTags interface {
// NodeFilterTags returns zero or more semantic tags. Stable per
// node: the picker caches them at flatten time.
NodeFilterTags() []string
}
TreeNodeWithFilterTags is implemented by adapters that classify nodes for filter-mode skip-sets. Settings, tool, user, and labeled tags drive the default, no-tools, user-only, labeled-only, and all modes; the usage tag hides a node in every mode. Adapters without tags remain visible in every mode.
type TreeNodeWithLabelTimestamp ¶
type TreeNodeWithLabelTimestamp interface {
// NodeLabelTimestamp returns the upstream wire-format timestamp
// of the LabelEntry that set the label, or "" when no label is
// set or no timestamp is available.
NodeLabelTimestamp() string
}
TreeNodeWithLabelTimestamp is implemented by adapters that carry a user-set branch label with its set-time. When `T` toggles label timestamps on, the picker prepends `hh:mm` (or a longer form for cross-day stamps) to the row content. Adapters that don't implement this interface render with no timestamp - equivalent to upstream's silent-empty branch when `flatNode.node.labelTimestamp` is undefined (tree-selector.ts:678-682).
type TreeSelect ¶
type TreeSelect struct {
Title string
// MaxVisibleLines is the number of tree rows shown at once. Upstream
// TreeSelectorComponent uses max(5, floor(terminalHeight / 2)); see
// TreeVisibleLines. Zero uses treeWindow.
MaxVisibleLines int
// OnLabelEdit is called when the user commits a label (Enter).
// entryID is the target entry; label is the new name (empty string
// clears any existing label, matching upstream undefined→delete).
// The caller is responsible for persisting via Session.AppendLabelChange.
OnLabelEdit func(entryID, label string)
// contains filtered or unexported fields
}
TreeSelect overlay. Done()/Cancelled()/SelectedID() mirror the FilterableList contract.
func NewTreeSelect ¶
func NewTreeSelect(title string, root TreeNode) *TreeSelect
func (*TreeSelect) Cancelled ¶
func (t *TreeSelect) Cancelled() bool
func (*TreeSelect) Done ¶
func (t *TreeSelect) Done() bool
Done / Cancelled / SelectedID implement the modal contract.
func (*TreeSelect) HandleInput ¶
func (t *TreeSelect) HandleInput(data string)
HandleInput moves the cursor or commits the selection.
Ctrl+Left/Alt+Left folds the highlighted branch or moves to the current branch segment start. Ctrl+Right/Alt+Right unfolds it or moves to the next branch segment. Shift+T toggles label timestamps.
func (*TreeSelect) Invalidate ¶
func (i *TreeSelect) Invalidate()
func (*TreeSelect) NeedsRedraw ¶
func (i *TreeSelect) NeedsRedraw() bool
func (*TreeSelect) Render ¶
func (t *TreeSelect) Render(width int) []string
Render draws header + visible rows.
func (*TreeSelect) SelectedID ¶
func (t *TreeSelect) SelectedID() string
func (*TreeSelect) SetInitialCursor ¶
func (t *TreeSelect) SetInitialCursor(currentLeafID, initialSelectedID string)
SetInitialCursor positions the cursor on the current leaf (or an explicit initialSelectedID when given), so /tree opens where the user currently is rather than at the bottom row. When the target is filtered or folded out it walks up to the nearest visible ancestor. Mirrors upstream TreeSelectorComponent's `targetId = initialSelectedId ?? currentLeafId` initial selection (tree-selector.ts:143-145). When neither is resolvable the cursor keeps NewTreeSelect's last-visible-row default (upstream's fallback).
Must be called after construction (rows are built) and before the first render.
type TruncatedText ¶
type TruncatedText struct {
Content string
MaxLines int
PaddingX int
PaddingY int
// contains filtered or unexported fields
}
TruncatedText renders text truncated to fit viewport width.
func NewPaddedTruncatedText ¶
func NewPaddedTruncatedText(content string, paddingX, paddingY int) *TruncatedText
NewPaddedTruncatedText creates a truncated text with padding.
func NewTruncatedText ¶
func NewTruncatedText(content string, maxLines int) *TruncatedText
func (*TruncatedText) Invalidate ¶
func (i *TruncatedText) Invalidate()
func (*TruncatedText) NeedsRedraw ¶
func (i *TruncatedText) NeedsRedraw() bool
func (*TruncatedText) Render ¶
func (t *TruncatedText) Render(width int) []string
type TuiAltScreen ¶
type TuiAltScreen struct {
// contains filtered or unexported fields
}
TuiAltScreen is the alternate-screen renderer. It embeds tuiBase for the shared render machinery (requestRender coalescing, overlays, terminal I/O).
func NewTuiAltScreen ¶
func NewTuiAltScreen(options TuiAltScreenOptions) *TuiAltScreen
NewTuiAltScreen creates an alt-screen renderer writing to stdout at the current terminal size. Used in production by the fullscreen driver.
func NewTuiAltScreenWithOutput ¶
func NewTuiAltScreenWithOutput(out io.Writer, cols, rows int, options TuiAltScreenOptions) *TuiAltScreen
NewTuiAltScreenWithOutput creates a fixed-size alt-screen renderer for tests.
func (*TuiAltScreen) ActiveOverlay ¶
func (t *TuiAltScreen) ActiveOverlay() Component
ActiveOverlay returns the currently focused eligible overlay component.
func (*TuiAltScreen) CancelPendingRender ¶
func (t *TuiAltScreen) CancelPendingRender()
CancelPendingRender invalidates a throttled frame, including one whose timer callback has already handed it to the owner loop. It maps the single-threaded JavaScript event-loop rule that a later state transition can consume a queued request before its callback runs.
func (*TuiAltScreen) ConsumeCellSizeResponse ¶
ConsumeCellSizeResponse reports whether data is a complete cell-size response. A response with positive dimensions updates the cell dimensions, invalidates every mounted component so images re-render at the new size, and requests a render; a response with a zero dimension is still consumed. Any other input returns false so it reaches the focused component. Mirrors upstream tui.ts consumeCellSizeResponse.
func (*TuiAltScreen) CopyActiveSelectionToClipboard ¶
func (t *TuiAltScreen) CopyActiveSelectionToClipboard() bool
CopyActiveSelectionToClipboard copies the current selection and reports success.
func (*TuiAltScreen) Flash ¶
func (t *TuiAltScreen) Flash(message string, durationMs int)
Flash shows a transient message in the alternate-screen flash stack.
func (*TuiAltScreen) FocusedComponent ¶
func (t *TuiAltScreen) FocusedComponent() Component
FocusedComponent returns the current overlay or non-overlay focus target.
func (*TuiAltScreen) ForceFullRender ¶
func (t *TuiAltScreen) ForceFullRender()
ForceFullRender marks the next frame as a full redraw. The alt-screen detects a full redraw when previousScreen is empty, so this resets the render state. Mirrors TUI.ForceFullRender (the main-screen sets forceRedraw, consumed by its differential renderer).
func (*TuiAltScreen) GetCopyOnSelect ¶
func (t *TuiAltScreen) GetCopyOnSelect() bool
GetCopyOnSelect reports whether a completed selection is copied automatically.
func (*TuiAltScreen) GetShowHardwareCursor ¶
func (t *TuiAltScreen) GetShowHardwareCursor() bool
GetShowHardwareCursor reports whether the real terminal cursor is shown. Mirrors upstream TUI.getShowHardwareCursor().
func (*TuiAltScreen) HandleFocusedSearchInput ¶
func (t *TuiAltScreen) HandleFocusedSearchInput(data string) bool
HandleFocusedSearchInput delivers a key to the transcript search box when it has focus and reports whether it did. Upstream's TUI hands focused-component input to the search box itself; PiG's driver owns input routing, so the driver calls this where upstream would reach the focused component.
func (*TuiAltScreen) HandleViewportInput ¶
func (t *TuiAltScreen) HandleViewportInput(data string) bool
HandleViewportInput routes a raw input chunk that targets the viewport: focus reports, mouse reports, and viewport keybindings. It returns true when it consumed the input so the driver does not dispatch it as a keystroke. Mirrors upstream handleViewportInput.
func (*TuiAltScreen) HasActiveSelection ¶
func (t *TuiAltScreen) HasActiveSelection() bool
HasActiveSelection reports whether the fullscreen viewport has selected text.
func (*TuiAltScreen) HasOverlay ¶
func (t *TuiAltScreen) HasOverlay() bool
HasOverlay reports whether any overlay entry is mounted. The interactive driver uses this for the upstream hasOverlayEntries renderer-switch guard.
func (*TuiAltScreen) Height ¶
func (t *TuiAltScreen) Height() int
Height returns the current terminal height.
func (*TuiAltScreen) HideCursor ¶
func (t *TuiAltScreen) HideCursor()
func (*TuiAltScreen) IsFollowingOutput ¶
func (t *TuiAltScreen) IsFollowingOutput() bool
IsFollowingOutput reports whether the primary scroll view is pinned to the end.
func (*TuiAltScreen) IsSearchFocused ¶
func (t *TuiAltScreen) IsSearchFocused() bool
IsSearchFocused reports whether the transcript search box has focus.
func (*TuiAltScreen) Mode ¶
func (t *TuiAltScreen) Mode() string
Mode reports the renderer mode. Mirrors upstream `mode = "fullscreen"`.
func (*TuiAltScreen) OpenOverlay ¶
func (t *TuiAltScreen) OpenOverlay(c Component, opts OverlayOptions) *OverlayHandle
OpenOverlay pushes a component onto the overlay append stack and returns a targeted handle. Callers must Close when the overlay is dismissed.
func (*TuiAltScreen) QueryCellSize ¶
func (t *TuiAltScreen) QueryCellSize()
QueryCellSize writes the cell-size query when the terminal supports images, since only image rendering uses the cell size. Mirrors upstream tui.ts queryCellSize, which start() sends after the terminal starts.
func (*TuiAltScreen) Render ¶
func (t *TuiAltScreen) Render()
Render performs a differential render pass using inline-flow output.
Mirrors upstream pi-tui's `render()`. New content is appended with `\r\n`, which scrolls the viewport up and pushes older lines into the terminal's native scrollback. The terminal's normal scrolling makes our chat history reachable via the user's mouse wheel / Cmd-↑ after pig exits, just like a regular shell.
Algorithm sketch:
- Detect width/height change → fullRender(clear).
- First render → fullRender(no clear). Lines emitted with `\r\n` between them flow naturally.
- Diff prevLines vs newLines to find [firstChanged, lastChanged].
- If visible tail content shrinks and exposes rows above the old viewport, repaint only the new visible viewport.
- If only deletions remain, clear those rows in place.
- If firstChanged is above the current viewport → fullRender(clear).
- Otherwise: move cursor to firstChanged (scrolling if it's below the viewport bottom), rewrite affected lines, clear any extras.
func (*TuiAltScreen) RenderSnapshot ¶
func (t *TuiAltScreen) RenderSnapshot(width int) []string
RenderSnapshot returns the rendered document lines at the given width. Mirrors TUI.RenderSnapshot; the alt-screen renders the layout root (or base children) at natural height, matching upstream render(width).
func (*TuiAltScreen) RepaintAll ¶
func (t *TuiAltScreen) RepaintAll()
RepaintAll forces an immediate full repaint. Mirrors TUI.RepaintAll (which clears hasRendered then renders); the alt-screen clears its differential state.
func (*TuiAltScreen) RequestRender ¶
func (t *TuiAltScreen) RequestRender()
RequestRender asks the TUI to render soon, coalescing repeated calls and enforcing the upstream 16ms frame throttle. Use this for hot streaming paths (thinking/text deltas); direct Render() is reserved for low-frequency state changes and final flushes.
func (*TuiAltScreen) ScrollBy ¶
func (t *TuiAltScreen) ScrollBy(lines int)
ScrollBy scrolls the primary scroll view by the given number of lines.
func (*TuiAltScreen) ScrollToBottom ¶
func (t *TuiAltScreen) ScrollToBottom()
ScrollToBottom scrolls the primary scroll view to its end.
func (*TuiAltScreen) ScrollToTop ¶
func (t *TuiAltScreen) ScrollToTop()
ScrollToTop scrolls the primary scroll view to its start.
func (*TuiAltScreen) SetClearOnShrink ¶
func (t *TuiAltScreen) SetClearOnShrink(bool)
SetClearOnShrink is a no-op for the alt-screen, which always repaints a full-height screen (clearing via \x1b[2J on full redraw) and has no clear-on-shrink heuristic. Present to satisfy the Renderer contract. Mirrors TUI.SetClearOnShrink, whose shrink behavior only applies to the inline-flow main-screen renderer.
func (*TuiAltScreen) SetCopyOnSelect ¶
func (t *TuiAltScreen) SetCopyOnSelect(enabled bool)
SetCopyOnSelect changes automatic selection copy without rebuilding the renderer.
func (*TuiAltScreen) SetFixedSize ¶
func (t *TuiAltScreen) SetFixedSize(cols, rows int)
SetFixedSize changes the size of a renderer built with a fixed size (NewWithOutput), as a terminal resize would; the next render sees it. Renderers that read the real terminal size ignore it.
func (*TuiAltScreen) SetFocus ¶
func (t *TuiAltScreen) SetFocus(component Component)
SetFocus records a non-overlay target for focus restoration.
func (*TuiAltScreen) SetLayoutRoot ¶
func (t *TuiAltScreen) SetLayoutRoot(component Component)
SetLayoutRoot installs the fullscreen layout tree (transcript scroll view + pinned footer). nil falls back to the implicit scroll view wrapping the base document. Mirrors upstream setLayoutRoot.
func (*TuiAltScreen) SetOnHeightChange ¶
func (t *TuiAltScreen) SetOnHeightChange(fn func(height int))
SetOnHeightChange registers a callback that fires whenever the terminal height changes between render frames. Thread-safe.
func (*TuiAltScreen) SetOnWidthChange ¶
func (t *TuiAltScreen) SetOnWidthChange(fn func(width int))
SetOnWidthChange registers a callback that fires whenever the terminal width changes between render frames. Thread-safe.
func (*TuiAltScreen) SetOverlayCommandDispatcher ¶
func (t *TuiAltScreen) SetOverlayCommandDispatcher(dispatch func(func()))
SetOverlayCommandDispatcher installs the ordered ingress used by remote producers. The dispatcher owns command ordering on the application loop.
func (*TuiAltScreen) SetRenderDispatcher ¶
func (t *TuiAltScreen) SetRenderDispatcher(dispatch func(render func()))
SetRenderDispatcher installs a hook that runs throttled scheduled renders on the caller's main loop. The dispatcher receives a render closure and is responsible for eventually invoking it on the goroutine that owns component-tree mutation (it may enqueue it on an event loop). When nil (default), scheduled renders run inline on the throttle-timer goroutine, which is correct for standalone / single-goroutine use. Thread-safe.
func (*TuiAltScreen) SetShowHardwareCursor ¶
func (t *TuiAltScreen) SetShowHardwareCursor(enabled bool)
SetShowHardwareCursor toggles the hardware cursor and repaints if already rendered so the next frame emits the correct cursor visibility. Mirrors TUI.SetShowHardwareCursor.
func (*TuiAltScreen) SetTickDispatcher ¶
func (t *TuiAltScreen) SetTickDispatcher(dispatch func(func()))
SetTickDispatcher installs the blocking owner-loop seam for owned state-machine ticks (alt-screen selection auto-scroll). It must marshal fn onto the loop that owns rendering, backpressuring rather than dropping while that loop is alive; see the tickOnMain doc. When unset the tick runs inline. Thread-safe.
func (*TuiAltScreen) ShowCursor ¶
func (t *TuiAltScreen) ShowCursor()
ShowCursor shows the terminal cursor.
func (*TuiAltScreen) Start ¶
func (t *TuiAltScreen) Start()
Start enters the alternate screen and begins rendering. The driver calls this once at session start. Mirrors upstream beforeTerminalStart + the enter write.
func (*TuiAltScreen) Stop ¶
func (t *TuiAltScreen) Stop()
Stop tears down the alternate screen and reflows the transcript into the main-screen scrollback. Satisfies the Renderer interface (matching the driver's no-arg Stop call sites); use StopWithOptions for preserve-screen teardown.
func (*TuiAltScreen) StopWithOptions ¶
func (t *TuiAltScreen) StopWithOptions(options StopOptions)
StopWithOptions tears down the alternate screen. Mirrors upstream beforeTerminalStop + afterTerminalStop.
func (*TuiAltScreen) ViewportTop ¶
func (t *TuiAltScreen) ViewportTop() int
ViewportTop returns the primary scroll view's current scroll offset.
type TuiAltScreenOptions ¶
type TuiAltScreenOptions struct {
// WheelScrollLines is the number of logical lines moved per wheel event
// (default 1).
WheelScrollLines int
// Mouse captures mouse events for viewport scrolling and selection.
Mouse *bool
// CopyOnSelect copies a completed text selection. The default is true.
CopyOnSelect *bool
// CopySelection writes selected text to the host clipboard. OSC 52 is used when nil.
CopySelection func(text string) error
// OpenURL activates an OSC 8 hyperlink on primary-button click.
OpenURL func(url string)
// SearchMatchStyle styles a non-current transcript search match.
SearchMatchStyle func(text string) string
// SearchCurrentMatchStyle styles the current transcript search match.
SearchCurrentMatchStyle func(text string) string
SearchNavigationButtonStyle func(text string, hovered bool) string
// ScrollToEndIndicator renders a clickable jump-to-end label, centered on
// the last row of a follow-end primary scroll view while that view is
// scrolled away from its end.
ScrollToEndIndicator func() string
// OnRightClickPaste handles an unmodified secondary-button press for
// clipboard paste. Currently enabled on Windows only.
OnRightClickPaste func()
}
TuiAltScreenOptions configures the alt-screen renderer. Mirrors upstream TuiAltScreenOptions.
type TuiMouseButton ¶
type TuiMouseButton string
TuiMouseButton mirrors upstream TuiMouseButton.
const ( MouseButtonLeft TuiMouseButton = "left" MouseButtonMiddle TuiMouseButton = "middle" MouseButtonRight TuiMouseButton = "right" MouseButtonNone TuiMouseButton = "none" )
type TuiMouseDispatchResult ¶
type TuiMouseDispatchResult struct {
TuiMouseEventResult
Target TuiMouseDispatchTarget
// FocusTarget is the keyboard focus target, which may be a delegating
// parent container. nil means Target.Component.
FocusTarget Component
}
TuiMouseDispatchResult is a handled result bound to its target. Mirrors upstream TuiMouseDispatchResult. A handler returning a result whose Target.Component is nil has not been dispatched yet.
func DispatchMouseEvent ¶
func DispatchMouseEvent(component Component, event TuiMouseEvent) *TuiMouseDispatchResult
DispatchMouseEvent dispatches an event to a component and retains the exact target and coordinate transform. Containers use it to forward events to nested children. Mirrors upstream dispatchMouseEvent.
type TuiMouseDispatchTarget ¶
type TuiMouseDispatchTarget struct {
Component Component
OriginX int
OriginY int
Width int
Height int
}
TuiMouseDispatchTarget records the exact component a mouse event reached and the coordinate transform used to reach it. Mirrors upstream TuiMouseDispatchTarget.
type TuiMouseEvent ¶
type TuiMouseEvent struct {
Type TuiMouseEventType
Button TuiMouseButton
X int
Y int
ScreenX int
ScreenY int
Width int
Height int
Shift bool
Alt bool
Ctrl bool
// WheelDelta is the logical line delta of a wheel event (negative scrolls
// up); zero on every other event.
WheelDelta int
// ClickCount is the consecutive click count of a click event; zero on every
// other event.
ClickCount int
}
TuiMouseEvent is a normalized cell-based mouse event. Coordinates are zero-based. X/Y are local to the receiving component, ScreenX/ScreenY are absolute terminal coordinates, and Width/Height are the receiving component's current bounds. Mirrors upstream TuiMouseEvent.
func RetargetMouseEvent ¶
func RetargetMouseEvent(event TuiMouseEvent, target TuiMouseDispatchTarget) TuiMouseEvent
RetargetMouseEvent recreates local coordinates for a previously dispatched mouse target. Mirrors upstream retargetMouseEvent.
type TuiMouseEventResult ¶
type TuiMouseEventResult struct {
// Handled stops propagation and suppresses renderer-level fallback behavior.
Handled bool
// Capture routes subsequent drag/release events to this component. Implies
// Handled.
Capture bool
// Focus gives keyboard focus to this component. Implies Handled.
Focus bool
// Render explicitly requests (true) or suppresses (false) a render. nil
// takes the default: move and release do not render; press, click, drag,
// and wheel do.
Render *bool
}
TuiMouseEventResult mirrors upstream TuiMouseEventResult.
type TuiMouseEventType ¶
type TuiMouseEventType string
TuiMouseEventType mirrors upstream TuiMouseEventType.
const ( MousePress TuiMouseEventType = "press" MouseRelease TuiMouseEventType = "release" MouseMove TuiMouseEventType = "move" MouseDrag TuiMouseEventType = "drag" MouseClick TuiMouseEventType = "click" MouseWheel TuiMouseEventType = "wheel" )
type UndoStack ¶
type UndoStack[S any] struct { // contains filtered or unexported fields }
UndoStack stores detached state snapshots for undo/redo style flows.
type UserMessageBlock ¶
type UserMessageBlock struct {
// contains filtered or unexported fields
}
UserMessageBlock renders a user message in a styled box that the LLM cannot accidentally mimic. Replaces the prior markdown-blockquote rendering (`> **You:** ...`) which was ambiguous: any LLM output containing literal `> ` lines (e.g. when asked to recite documentation that quotes things) rendered with the same visual treatment as the user's own messages.
Why ANSI bg paint and not blockquote: the LLM emits markdown text; pig's chat renders that markdown via the standard markdown renderer. Markdown CANNOT produce raw ANSI escape sequences in its text output, so a user-message visual treatment that depends on raw ANSI bg is by construction non-mimickable.
Visual: each rendered line is left-padded by 1, padded to full width, and wrapped with a dark-grey background ANSI escape (`\x1b[48;5;236m...\x1b[49m`). Mirrors upstream `modes/interactive/components/user-message.ts::UserMessageComponent` (v0.69.0) which uses `theme.bg("userMessageBg", content)` with dark-theme `userMsgBg = #343541`. xterm-256 color 236 (~`#303030`) is the closest widely-supported approximation; truecolor would match exactly but a 256-color escape is universally rendered the same way across modern terminals.
The inner content is rendered through the existing Markdown component, so user messages still get bold/italic/code-fence formatting. The bg is painted AFTER markdown rendering so ANSI foreground sequences from inline code etc. compose correctly.
func NewUserMessageBlock ¶
func NewUserMessageBlock(text string) *UserMessageBlock
NewUserMessageBlock returns a component that renders text as a styled user-message block. The text is interpreted as markdown.
func (*UserMessageBlock) Invalidate ¶
func (i *UserMessageBlock) Invalidate()
func (*UserMessageBlock) NeedsRedraw ¶
func (i *UserMessageBlock) NeedsRedraw() bool
func (*UserMessageBlock) Render ¶
func (u *UserMessageBlock) Render(width int) []string
func (*UserMessageBlock) SetOutputPad ¶
func (u *UserMessageBlock) SetOutputPad(padding int)
SetOutputPad changes the horizontal content padding.
type UserMessageSelector ¶
type UserMessageSelector struct {
// contains filtered or unexported fields
}
UserMessageSelector renders the upstream /fork user-message picker in the editor slot. It mirrors user-message-selector.ts: a title, descriptive copy, dynamic borders, and a chronological user-message list with the newest message selected by default.
func NewUserMessageSelector ¶
func NewUserMessageSelector(messages []string) *UserMessageSelector
NewUserMessageSelector creates a selector for chronological user-message texts (oldest to newest). The newest message is selected initially.
func (*UserMessageSelector) Cancelled ¶
func (s *UserMessageSelector) Cancelled() bool
func (*UserMessageSelector) Done ¶
func (s *UserMessageSelector) Done() bool
func (*UserMessageSelector) HandleInput ¶
func (s *UserMessageSelector) HandleInput(data string)
func (*UserMessageSelector) Invalidate ¶
func (i *UserMessageSelector) Invalidate()
func (*UserMessageSelector) NeedsRedraw ¶
func (i *UserMessageSelector) NeedsRedraw() bool
func (*UserMessageSelector) Render ¶
func (s *UserMessageSelector) Render(width int) []string
func (*UserMessageSelector) SelectedIndex ¶
func (s *UserMessageSelector) SelectedIndex() int
SelectedIndex returns the selected chronological message index, or -1 when no message was selected.
type VStack ¶
type VStack struct {
*Stack
}
VStack ports pi-tui's VStack: children laid out top to bottom with flexbox heights.
func NewVStack ¶
func NewVStack(children []StackChild, options StackOptions) *VStack
NewVStack constructs a vertical stack.
func (VStack) Invalidate ¶
func (i VStack) Invalidate()
func (VStack) NeedsRedraw ¶
func (i VStack) NeedsRedraw() bool
type ViewportTUI ¶
type ViewportTUI interface {
Mode() string
ViewportTop() int
IsFollowingOutput() bool
SetLayoutRoot(component Component)
}
ViewportTUI is implemented by renderers with an application-owned scrollable viewport (the alt-screen renderer). Mirrors upstream ViewportTUI; the driver uses it to set the fullscreen layout root. Upstream's VIEWPORT_TUI Symbol brand is expressed here as a distinct Go interface.
type VisualTruncateResult ¶
VisualTruncateResult holds truncated lines and a skip count.
func TruncateToVisualLines ¶
func TruncateToVisualLines(text string, maxVisualLines, width int, paddingX ...int) VisualTruncateResult
TruncateToVisualLines truncates text to maxVisualLines from the end, wrapping lines at the given width. The optional padding matches Text's horizontal padding.
Source Files
¶
- alloc_hint.go
- alt_screen_flash.go
- alt_screen_keybindings.go
- alt_screen_search.go
- assistant_message_block.go
- autocomplete.go
- bash_execution.go
- bg_paint.go
- bordered_loader.go
- box.go
- branch_summary.go
- cancellable_loader.go
- cell_size.go
- color256.go
- compaction_summary.go
- config_selector.go
- countdown_timer.go
- custom_message.go
- diff_component.go
- diff_render.go
- doc.go
- dynamic_border.go
- editor.go
- editor_status.go
- extension_editor.go
- extension_input.go
- extension_selector.go
- file_autocomplete.go
- fuzzy.go
- graphemes.go
- highlight.go
- image.go
- key_match.go
- key_parse.go
- keybinding_hints.go
- keybindings.go
- keys_decode.go
- kill_ring.go
- kitty_metadata.go
- layout.go
- layout_node.go
- loader.go
- login_dialog.go
- markdown.go
- markdown_latex.go
- model_search.go
- model_select.go
- mouse.go
- mouse_region.go
- native_modifiers.go
- oauth_selector.go
- overlay_command.go
- overlay_compositor.go
- overlay_model.go
- overlay_spec.go
- redraw_debug.go
- render_capture.go
- render_overflow.go
- renderer.go
- scoped_models_list.go
- scroll_view.go
- select_filterable.go
- select_submenu.go
- settings_list.go
- shell_renderers.go
- show_images_selector.go
- signal_restore.go
- skill_invocation.go
- spacer.go
- stack.go
- static_text.go
- status_indicator.go
- terminal.go
- terminal_image.go
- terminal_native_shift_enter.go
- terminal_unix.go
- text.go
- text_input.go
- theme.go
- theme_json.go
- theme_loader.go
- theme_selector.go
- thinking_block.go
- tool_execution.go
- tool_path_render.go
- tool_renderers.go
- tree_select.go
- truncated_text.go
- tui.go
- tui_alt_screen.go
- tui_alt_screen_input.go
- tui_alt_screen_mouse.go
- tui_alt_screen_selection.go
- undo_stack.go
- user_message_block.go
- user_message_selector.go
- visual_truncate.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package parity provides the test harness for TUI byte-level and visible-state parity against upstream pi-tui.
|
Package parity provides the test harness for TUI byte-level and visible-state parity against upstream pi-tui. |
|
Package termsim is a headless ANSI terminal simulator for byte-level parity testing.
|
Package termsim is a headless ANSI terminal simulator for byte-level parity testing. |
|
Package widthx implements upstream pi-tui's visibleWidth + ANSI escape extraction with byte-level fidelity to the TypeScript algorithm.
|
Package widthx implements upstream pi-tui's visibleWidth + ANSI escape extraction with byte-level fidelity to the TypeScript algorithm. |