Documentation
¶
Index ¶
- Constants
- Variables
- func AllocateImageID() uint32
- func ApplyBackgroundToLine(line string, width int, bgFn func(string) string) string
- func CalculateImageRows(imageDimensions ImageDimensions, targetWidthCells int, ...) int
- func DecodeKittyPrintable(data string) (rune, bool)
- func DecodePrintableKey(data string) (rune, bool)
- func DeleteAllKittyImages() string
- func DeleteKittyImage(id uint32) string
- func EncodeITerm2(data []byte, options ImageRenderOptions) string
- func EncodeKitty(data []byte, options ImageRenderOptions) string
- func FuzzyFilter[T any](items []T, query string, getText func(T) string) []T
- func FuzzyFilterStrings(items []string, query string) []string
- func Hyperlink(text, url string) string
- func ImageFallback(alt string, args ...any) string
- func ImageFallbackDescription(mimeType string, dimensions *ImageDimensions, filename string) string
- func IsFocusable(component Component) bool
- func IsImageLine(line string) bool
- func IsKeyRelease(data string) bool
- func IsKeyRepeat(data string) bool
- func IsKittyProtocolActive() bool
- func IsPunctuationChar(char rune) bool
- func IsWhitespaceChar(char rune) bool
- func MatchesKey(data, spec string) bool
- func NormalizeTerminalOutput(s string) string
- func RenderImage(data []byte, options ImageRenderOptions) string
- func ResetCapabilitiesCache()
- func SetCapabilities(c TerminalCapabilities)
- func SetCellDimensions(d CellDimensions)
- func SetKeybindings(manager *KeybindingsManager)
- func SetKittyProtocolActive(active bool)
- func SliceByColumn(line string, startCol, length int, strict ...bool) string
- func TruncateToWidth(text string, maxWidth int, ellipsis string, pad ...bool) string
- func VisibleWidth(s string) int
- func WrapTextWithANSI(text string, width int) []string
- type ANSICode
- type AutocompleteItem
- type AutocompleteProvider
- type AutocompleteProviderFunc
- type AutocompleteSuggestions
- type Box
- type CancellableLoader
- func (l *CancellableLoader) Aborted() bool
- func (l *CancellableLoader) Cancel()
- func (l *CancellableLoader) Cancelled() bool
- func (l *CancellableLoader) Context() context.Context
- func (l *CancellableLoader) Dispose()
- func (l *CancellableLoader) HandleInput(data string)
- func (l *CancellableLoader) Signal() context.Context
- type CellDimensions
- type ColumnSlice
- type CombinedAutocompleteProvider
- func NewCombinedAutocompleteProvider(providers ...AutocompleteProvider) *CombinedAutocompleteProvider
- func NewCombinedAutocompleteProviderWithCommandItems(basePath string, commands []AutocompleteItem, ...) *CombinedAutocompleteProvider
- func NewCombinedAutocompleteProviderWithCommands(basePath string, commands []SlashCommand, providers ...AutocompleteProvider) *CombinedAutocompleteProvider
- func (p *CombinedAutocompleteProvider) Add(provider AutocompleteProvider)
- func (p *CombinedAutocompleteProvider) ApplyCompletion(lines []string, cursorLine, cursorCol int, item AutocompleteItem, ...) CompletionResult
- func (p *CombinedAutocompleteProvider) GetSuggestions(lines []string, cursorLine, cursorCol int, force bool) (*AutocompleteSuggestions, error)
- func (p *CombinedAutocompleteProvider) GetSuggestionsContext(ctx context.Context, lines []string, cursorLine, cursorCol int, force bool) (*AutocompleteSuggestions, error)
- func (p *CombinedAutocompleteProvider) SetBasePath(basePath string)
- func (p *CombinedAutocompleteProvider) SetCommandItems(commands []AutocompleteItem)
- func (p *CombinedAutocompleteProvider) SetCommands(commands []SlashCommand)
- func (p *CombinedAutocompleteProvider) ShouldTriggerFileCompletion(lines []string, cursorLine, cursorCol int) bool
- func (p *CombinedAutocompleteProvider) Suggestions(text string, cursor int) AutocompleteSuggestions
- type CompletionResult
- type Component
- type Container
- func (c *Container) AddChild(component Component)
- func (c *Container) ChildCount() int
- func (c *Container) Children() []Component
- func (c *Container) Clear()
- func (c *Container) InsertChild(index int, component Component)
- func (c *Container) Invalidate()
- func (c *Container) RemoveChild(component Component)
- func (c *Container) RemoveChildAt(index int) Component
- func (c *Container) Render(width int) []string
- func (c *Container) RenderWithSize(width, height int) []string
- func (c *Container) SetChildren(children []Component)
- type DefaultTextStyle
- type Editor
- func (e *Editor) AddToHistory(text string)
- func (e *Editor) GetAutocompleteMaxVisible() int
- func (e *Editor) GetCursor() (line, col int)
- func (e *Editor) GetExpandedText() string
- func (e *Editor) GetLines() []string
- func (e *Editor) GetMaxVisibleLines() int
- func (e *Editor) GetPaddingX() int
- func (e *Editor) GetText() string
- func (e *Editor) HandleInput(data string)
- func (e *Editor) InsertTextAtCursor(text string)
- func (e *Editor) Invalidate()
- func (e *Editor) IsShowingAutocomplete() bool
- func (e *Editor) PasteToEditor(text string)
- func (e *Editor) Render(width int) []string
- func (e *Editor) RenderWithSize(width, height int) []string
- func (e *Editor) SetAutocompleteMaxVisible(maxVisible int)
- func (e *Editor) SetAutocompleteProvider(provider AutocompleteProvider)
- func (e *Editor) SetBorderColor(fn func(string) string)
- func (e *Editor) SetMaxVisibleLines(lines int)
- func (e *Editor) SetOnChange(fn func(string))
- func (e *Editor) SetOnSubmit(fn func(string))
- func (e *Editor) SetPaddingX(padding int)
- func (e *Editor) SetText(text string)
- func (e *Editor) Text() string
- type EditorAppearanceComponent
- type EditorAutocompleteComponent
- type EditorChangeCallbackComponent
- type EditorComponent
- type EditorExpandedTextProvider
- type EditorHistoryComponent
- type EditorOptions
- type EditorSubmitCallbackComponent
- type EditorTextInserter
- type EditorTheme
- type ExtractedSegments
- type FocusState
- type Focusable
- type FuzzyMatch
- type Image
- type ImageCellSize
- type ImageDimensions
- func GetGifDimensions(data []byte) (ImageDimensions, error)
- func GetImageDimensions(data []byte) (ImageDimensions, error)
- func GetJpegDimensions(data []byte) (ImageDimensions, error)
- func GetPngDimensions(data []byte) (ImageDimensions, error)
- func GetWebpDimensions(data []byte) (ImageDimensions, error)
- type ImageOptions
- type ImageProtocol
- type ImageRenderOptions
- type ImageRenderResult
- type ImageTheme
- type Input
- type InputHandler
- type InputListener
- type InputListenerResult
- type KeyEvent
- type KeyEventType
- type KeyHelper
- func (KeyHelper) Alt(key string) string
- func (KeyHelper) AltCtrl(key string) string
- func (KeyHelper) AltShift(key string) string
- func (KeyHelper) AltSuper(key string) string
- func (KeyHelper) Ctrl(key string) string
- func (KeyHelper) CtrlAlt(key string) string
- func (KeyHelper) CtrlShift(key string) string
- func (KeyHelper) CtrlShiftAlt(key string) string
- func (KeyHelper) CtrlShiftSuper(key string) string
- func (KeyHelper) CtrlSuper(key string) string
- func (KeyHelper) Shift(key string) string
- func (KeyHelper) ShiftAlt(key string) string
- func (KeyHelper) ShiftCtrl(key string) string
- func (KeyHelper) ShiftSuper(key string) string
- func (KeyHelper) Super(key string) string
- func (KeyHelper) SuperAlt(key string) string
- func (KeyHelper) SuperCtrl(key string) string
- func (KeyHelper) SuperShift(key string) string
- type KeyID
- type KeyReleaseReceiver
- type Keybinding
- type KeybindingConflict
- type KeybindingDefinition
- type KeybindingDefinitions
- type Keybindings
- type KeybindingsConfig
- type KeybindingsManager
- func (m *KeybindingsManager) Bindings() Keybindings
- func (m *KeybindingsManager) Conflicts() []KeybindingConflict
- func (m *KeybindingsManager) Definition(action string) (KeybindingDefinition, bool)
- func (m *KeybindingsManager) GetConflicts() []KeybindingConflict
- func (m *KeybindingsManager) GetDefinition(action string) (KeybindingDefinition, bool)
- func (m *KeybindingsManager) GetKeys(action string) []string
- func (m *KeybindingsManager) GetResolvedBindings() KeybindingsConfig
- func (m *KeybindingsManager) GetUserBindings() KeybindingsConfig
- func (m *KeybindingsManager) Keys(action string) []string
- func (m *KeybindingsManager) Matches(data, action string) bool
- func (m *KeybindingsManager) Set(action string, keys []string)
- func (m *KeybindingsManager) SetUserBindings(config KeybindingsConfig)
- func (m *KeybindingsManager) UserBindings() KeybindingsConfig
- type KillRing
- type KillRingPushOptions
- type Loader
- type LoaderIndicatorOptions
- type Markdown
- type MarkdownOptions
- type MarkdownTheme
- type OverlayAnchor
- type OverlayHandle
- type OverlayMargin
- type OverlayOptions
- type ProcessTerminal
- func (t *ProcessTerminal) ClearFromCursor() error
- func (t *ProcessTerminal) ClearLine() error
- func (t *ProcessTerminal) ClearScreen() error
- func (t *ProcessTerminal) Columns() int
- func (t *ProcessTerminal) DrainInput(maxDuration, idle time.Duration) error
- func (t *ProcessTerminal) HideCursor() error
- func (t *ProcessTerminal) KittyProtocolActive() bool
- func (t *ProcessTerminal) MoveBy(lines int) error
- func (t *ProcessTerminal) Rows() int
- func (t *ProcessTerminal) SetProgress(active bool) error
- func (t *ProcessTerminal) SetSize(cols, rows int)
- func (t *ProcessTerminal) SetTitle(title string) error
- func (t *ProcessTerminal) ShowCursor() error
- func (t *ProcessTerminal) Start(onInput func(string), onResize func())
- func (t *ProcessTerminal) Stop()
- func (t *ProcessTerminal) Write(data string) error
- type SelectItem
- type SelectList
- func (s *SelectList) GetSelectedItem() (SelectItem, bool)
- func (s *SelectList) HandleInput(data string)
- func (s *SelectList) Invalidate()
- func (s *SelectList) Render(width int) []string
- func (s *SelectList) SelectedItem() (SelectItem, bool)
- func (s *SelectList) SetFilter(filter string)
- func (s *SelectList) SetSelectedIndex(index int)
- type SelectListLayoutOptions
- type SelectListTheme
- type SelectListTruncatePrimaryContext
- type SettingItem
- type SettingsList
- type SettingsListOptions
- type SettingsListTheme
- type SizeAwareComponent
- type SizeValue
- type SlashCommand
- type Spacer
- type StdinBuffer
- func (b *StdinBuffer) Clear()
- func (b *StdinBuffer) Destroy()
- func (b *StdinBuffer) Flush() []string
- func (b *StdinBuffer) GetBuffer() string
- func (b *StdinBuffer) OnData(fn func(string))
- func (b *StdinBuffer) OnPaste(fn func(string))
- func (b *StdinBuffer) Process(data string)
- func (b *StdinBuffer) ProcessBytes(data []byte)
- type StdinBufferEventMap
- type StdinBufferOptions
- type TUI
- func (t *TUI) AddInputListener(listener InputListener) func()
- func (t *TUI) ClearOnShrink() bool
- func (t *TUI) DrainInput(maxDuration, idle time.Duration) error
- func (t *TUI) FocusedComponent() Component
- func (t *TUI) FullRedraws() int
- func (t *TUI) GetClearOnShrink() bool
- func (t *TUI) GetFullRedraws() int
- func (t *TUI) GetShowHardwareCursor() bool
- func (t *TUI) HandleInput(data string)
- func (t *TUI) HasOverlay() bool
- func (t *TUI) HideOverlay()
- func (t *TUI) Invalidate()
- func (t *TUI) RemoveInputListener(listener InputListener)
- func (t *TUI) RequestRender(force ...bool)
- func (t *TUI) SetClearOnShrink(enabled bool)
- func (t *TUI) SetFocus(component Component)
- func (t *TUI) SetOnDebug(fn func())
- func (t *TUI) SetShowHardwareCursor(enabled bool)
- func (t *TUI) ShowHardwareCursor() bool
- func (t *TUI) ShowOverlay(component Component, options ...OverlayOptions) OverlayHandle
- func (t *TUI) Start()
- func (t *TUI) Stop()
- func (t *TUI) Terminal() Terminal
- type Terminal
- type TerminalCapabilities
- type Text
- type TextChunk
- type TruncatedText
- type TruncatedTextOptions
- type UndoStack
- type VirtualCell
- type VirtualColor
- type VirtualTerminal
Constants ¶
const (
CursorMarker = "\x1b_pi:c\x07"
)
Variables ¶
var Key = KeyHelper{
Escape: "escape", Esc: "esc", Enter: "enter", Return: "return", Tab: "tab", Space: "space",
Backspace: "backspace", Delete: "delete", Insert: "insert", Clear: "clear",
Home: "home", End: "end", PageUp: "pageUp", PageDown: "pageDown", Up: "up", Down: "down", Left: "left", Right: "right",
F1: "f1", F2: "f2", F3: "f3", F4: "f4", F5: "f5", F6: "f6", F7: "f7", F8: "f8", F9: "f9", F10: "f10", F11: "f11", F12: "f12",
Backtick: "`", Hyphen: "-", Equals: "=", LeftBracket: "[", RightBracket: "]",
Backslash: "\\", Semicolon: ";", Quote: "'", Comma: ",", Period: ".", Slash: "/",
Exclamation: "!", At: "@", Hash: "#", Dollar: "$", Percent: "%", Caret: "^",
Ampersand: "&", Asterisk: "*", LeftParen: "(", RightParen: ")",
Underscore: "_", Plus: "+", Pipe: "|", Tilde: "~",
LeftBrace: "{", RightBrace: "}", Colon: ":", LessThan: "<", GreaterThan: ">",
Question: "?",
}
var TUI_KEYBINDINGS = cloneKeybindingDefinitions(defaultKeybindingDefinitions)
Functions ¶
func AllocateImageID ¶
func AllocateImageID() uint32
func ApplyBackgroundToLine ¶
ApplyBackgroundToLine pads line to width and passes it through bgFn.
func CalculateImageRows ¶
func CalculateImageRows(imageDimensions ImageDimensions, targetWidthCells int, cellDimensions ...CellDimensions) int
func DecodeKittyPrintable ¶
func DecodePrintableKey ¶
func DeleteAllKittyImages ¶
func DeleteAllKittyImages() string
func DeleteKittyImage ¶
func EncodeITerm2 ¶
func EncodeITerm2(data []byte, options ImageRenderOptions) string
func EncodeKitty ¶
func EncodeKitty(data []byte, options ImageRenderOptions) string
func FuzzyFilter ¶
func FuzzyFilterStrings ¶
func ImageFallback ¶
func ImageFallbackDescription ¶
func ImageFallbackDescription(mimeType string, dimensions *ImageDimensions, filename string) string
func IsFocusable ¶
func IsImageLine ¶
func IsKeyRelease ¶
func IsKeyRepeat ¶
func IsKittyProtocolActive ¶
func IsKittyProtocolActive() bool
func IsPunctuationChar ¶
func IsWhitespaceChar ¶
func MatchesKey ¶
func NormalizeTerminalOutput ¶
NormalizeTerminalOutput rewrites codepoints that terminals commonly render as decomposed sequences. This keeps output width accounting aligned with what the terminal displays for Thai and Lao AM vowels.
func RenderImage ¶
func RenderImage(data []byte, options ImageRenderOptions) string
func ResetCapabilitiesCache ¶
func ResetCapabilitiesCache()
func SetCapabilities ¶
func SetCapabilities(c TerminalCapabilities)
func SetCellDimensions ¶
func SetCellDimensions(d CellDimensions)
func SetKeybindings ¶
func SetKeybindings(manager *KeybindingsManager)
func SetKittyProtocolActive ¶
func SetKittyProtocolActive(active bool)
func TruncateToWidth ¶
TruncateToWidth truncates text to maxWidth terminal cells. ANSI escapes are preserved when possible. The optional pad argument pads the result to maxWidth.
func VisibleWidth ¶
VisibleWidth returns the number of terminal cells occupied by s. It strips ANSI escape sequences, treats tabs as three cells, and uses a conservative width table for combining marks, CJK, and emoji.
func WrapTextWithANSI ¶
WrapTextWithANSI wraps text into terminal-width lines while preserving ANSI sequences. Newlines always force a break.
Types ¶
type AutocompleteItem ¶
type AutocompleteProvider ¶
type AutocompleteProvider interface {
Suggestions(text string, cursor int) AutocompleteSuggestions
}
type AutocompleteProviderFunc ¶
type AutocompleteProviderFunc func(text string, cursor int) AutocompleteSuggestions
func (AutocompleteProviderFunc) Suggestions ¶
func (f AutocompleteProviderFunc) Suggestions(text string, cursor int) AutocompleteSuggestions
type AutocompleteSuggestions ¶
type AutocompleteSuggestions struct {
Items []AutocompleteItem
Start int
End int
Prefix string
}
type Box ¶
type Box struct {
// contains filtered or unexported fields
}
func (*Box) Invalidate ¶
func (b *Box) Invalidate()
func (*Box) RemoveChild ¶
func (*Box) SetBackground ¶
type CancellableLoader ¶
type CancellableLoader struct {
*Loader
OnCancel func()
OnAbort func()
// contains filtered or unexported fields
}
func NewCancellableLoader ¶
func NewCancellableLoader(text string, options ...LoaderIndicatorOptions) *CancellableLoader
func (*CancellableLoader) Aborted ¶
func (l *CancellableLoader) Aborted() bool
func (*CancellableLoader) Cancel ¶
func (l *CancellableLoader) Cancel()
func (*CancellableLoader) Cancelled ¶
func (l *CancellableLoader) Cancelled() bool
func (*CancellableLoader) Context ¶
func (l *CancellableLoader) Context() context.Context
func (*CancellableLoader) Dispose ¶
func (l *CancellableLoader) Dispose()
func (*CancellableLoader) HandleInput ¶
func (l *CancellableLoader) HandleInput(data string)
func (*CancellableLoader) Signal ¶
func (l *CancellableLoader) Signal() context.Context
type CellDimensions ¶
func GetCellDimensions ¶
func GetCellDimensions() CellDimensions
type ColumnSlice ¶
func SliceWithWidth ¶
func SliceWithWidth(line string, startCol, length int, strict ...bool) ColumnSlice
type CombinedAutocompleteProvider ¶
type CombinedAutocompleteProvider struct {
// contains filtered or unexported fields
}
func NewCombinedAutocompleteProvider ¶
func NewCombinedAutocompleteProvider(providers ...AutocompleteProvider) *CombinedAutocompleteProvider
func NewCombinedAutocompleteProviderWithCommandItems ¶
func NewCombinedAutocompleteProviderWithCommandItems(basePath string, commands []AutocompleteItem, providers ...AutocompleteProvider) *CombinedAutocompleteProvider
func NewCombinedAutocompleteProviderWithCommands ¶
func NewCombinedAutocompleteProviderWithCommands(basePath string, commands []SlashCommand, providers ...AutocompleteProvider) *CombinedAutocompleteProvider
func (*CombinedAutocompleteProvider) Add ¶
func (p *CombinedAutocompleteProvider) Add(provider AutocompleteProvider)
func (*CombinedAutocompleteProvider) ApplyCompletion ¶
func (p *CombinedAutocompleteProvider) ApplyCompletion(lines []string, cursorLine, cursorCol int, item AutocompleteItem, prefix string) CompletionResult
func (*CombinedAutocompleteProvider) GetSuggestions ¶
func (p *CombinedAutocompleteProvider) GetSuggestions(lines []string, cursorLine, cursorCol int, force bool) (*AutocompleteSuggestions, error)
func (*CombinedAutocompleteProvider) GetSuggestionsContext ¶
func (p *CombinedAutocompleteProvider) GetSuggestionsContext(ctx context.Context, lines []string, cursorLine, cursorCol int, force bool) (*AutocompleteSuggestions, error)
func (*CombinedAutocompleteProvider) SetBasePath ¶
func (p *CombinedAutocompleteProvider) SetBasePath(basePath string)
func (*CombinedAutocompleteProvider) SetCommandItems ¶
func (p *CombinedAutocompleteProvider) SetCommandItems(commands []AutocompleteItem)
func (*CombinedAutocompleteProvider) SetCommands ¶
func (p *CombinedAutocompleteProvider) SetCommands(commands []SlashCommand)
func (*CombinedAutocompleteProvider) ShouldTriggerFileCompletion ¶
func (p *CombinedAutocompleteProvider) ShouldTriggerFileCompletion(lines []string, cursorLine, cursorCol int) bool
func (*CombinedAutocompleteProvider) Suggestions ¶
func (p *CombinedAutocompleteProvider) Suggestions(text string, cursor int) AutocompleteSuggestions
type CompletionResult ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
func NewContainer ¶
func NewContainer() *Container
func (*Container) ChildCount ¶
func (*Container) InsertChild ¶
func (*Container) Invalidate ¶
func (c *Container) Invalidate()
func (*Container) RemoveChild ¶
func (*Container) RemoveChildAt ¶
func (*Container) RenderWithSize ¶
func (*Container) SetChildren ¶
type DefaultTextStyle ¶
type Editor ¶
type Editor struct {
FocusState
OnSubmit func(string)
OnChange func(string)
OnAutocompleteChange func()
DisableSubmit bool
// contains filtered or unexported fields
}
func NewEditor ¶
func NewEditor(theme EditorTheme, options ...EditorOptions) *Editor
func (*Editor) AddToHistory ¶
func (*Editor) GetAutocompleteMaxVisible ¶
func (*Editor) GetExpandedText ¶
func (*Editor) GetMaxVisibleLines ¶
func (*Editor) GetPaddingX ¶
func (*Editor) HandleInput ¶
func (*Editor) InsertTextAtCursor ¶
func (*Editor) Invalidate ¶
func (e *Editor) Invalidate()
func (*Editor) IsShowingAutocomplete ¶
func (*Editor) PasteToEditor ¶
func (*Editor) RenderWithSize ¶
func (*Editor) SetAutocompleteMaxVisible ¶
func (*Editor) SetAutocompleteProvider ¶
func (e *Editor) SetAutocompleteProvider(provider AutocompleteProvider)
func (*Editor) SetBorderColor ¶
func (*Editor) SetMaxVisibleLines ¶
func (*Editor) SetOnChange ¶
func (*Editor) SetOnSubmit ¶
func (*Editor) SetPaddingX ¶
type EditorAutocompleteComponent ¶
type EditorAutocompleteComponent interface {
SetAutocompleteProvider(provider AutocompleteProvider)
}
type EditorChangeCallbackComponent ¶
type EditorChangeCallbackComponent interface {
SetOnChange(fn func(string))
}
type EditorComponent ¶
type EditorComponent interface {
Component
GetText() string
SetText(text string)
HandleInput(data string)
}
EditorComponent is the core contract for editor-like input widgets. Optional Pi editor capabilities are modeled as small extension interfaces below so custom Go editors can implement only the features they support.
type EditorExpandedTextProvider ¶
type EditorExpandedTextProvider interface {
GetExpandedText() string
}
type EditorHistoryComponent ¶
type EditorHistoryComponent interface {
AddToHistory(text string)
}
type EditorOptions ¶
type EditorSubmitCallbackComponent ¶
type EditorSubmitCallbackComponent interface {
SetOnSubmit(fn func(string))
}
type EditorTextInserter ¶
type EditorTextInserter interface {
InsertTextAtCursor(text string)
}
type EditorTheme ¶
type EditorTheme struct {
Border func(string) string
SelectList SelectListTheme
}
type ExtractedSegments ¶
func ExtractSegments ¶
func ExtractSegments(line string, beforeEnd, afterStart, afterLen int, strictAfter ...bool) ExtractedSegments
type FocusState ¶
type FocusState struct {
// contains filtered or unexported fields
}
FocusState can be embedded by focusable components.
func (*FocusState) Focused ¶
func (f *FocusState) Focused() bool
func (*FocusState) SetFocused ¶
func (f *FocusState) SetFocused(focused bool)
type FuzzyMatch ¶
func FuzzyMatchText ¶
func FuzzyMatchText(query, text string) FuzzyMatch
type Image ¶
type Image struct {
Data []byte
Options ImageOptions
Theme ImageTheme
// contains filtered or unexported fields
}
func NewImage ¶
func NewImage(data []byte, options ImageOptions, theme ...ImageTheme) *Image
func (*Image) GetImageID ¶
func (*Image) GetImageId ¶
func (*Image) Invalidate ¶
func (i *Image) Invalidate()
type ImageCellSize ¶
func CalculateImageCellSize ¶
func CalculateImageCellSize(imageDimensions ImageDimensions, maxWidthCells int, args ...any) ImageCellSize
type ImageDimensions ¶
func GetGifDimensions ¶
func GetGifDimensions(data []byte) (ImageDimensions, error)
func GetImageDimensions ¶
func GetImageDimensions(data []byte) (ImageDimensions, error)
func GetJpegDimensions ¶
func GetJpegDimensions(data []byte) (ImageDimensions, error)
func GetPngDimensions ¶
func GetPngDimensions(data []byte) (ImageDimensions, error)
func GetWebpDimensions ¶
func GetWebpDimensions(data []byte) (ImageDimensions, error)
type ImageOptions ¶
type ImageProtocol ¶
type ImageProtocol string
const ( ImageProtocolNone ImageProtocol = "none" ImageProtocolKitty ImageProtocol = "kitty" ImageProtocolITerm ImageProtocol = "iterm2" )
type ImageRenderOptions ¶
type ImageRenderResult ¶
func RenderImageWithDimensions ¶
func RenderImageWithDimensions(data []byte, imageDimensions ImageDimensions, options ImageRenderOptions) *ImageRenderResult
type ImageTheme ¶
type Input ¶
type Input struct {
FocusState
OnSubmit func(string)
OnEscape func()
OnChange func(string)
// contains filtered or unexported fields
}
func (*Input) HandleInput ¶
func (*Input) Invalidate ¶
func (i *Input) Invalidate()
type InputHandler ¶
type InputHandler interface {
HandleInput(data string)
}
InputHandler is implemented by components that receive focused keyboard input.
type InputListener ¶
type InputListener func(data string) InputListenerResult
type InputListenerResult ¶
func InputListenerData ¶
func InputListenerData(data string) InputListenerResult
type KeyEvent ¶
type KeyEventType ¶
type KeyEventType string
const ( KeyPress KeyEventType = "press" KeyRepeat KeyEventType = "repeat" KeyRelease KeyEventType = "release" )
type KeyHelper ¶
type KeyHelper struct {
Escape, Esc, Enter, Return, Tab, Space string
Backspace, Delete, Insert, Clear string
Home, End, PageUp, PageDown, Up, Down, Left, Right string
F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12 string
Backtick, Hyphen, Equals, LeftBracket, RightBracket string
Backslash, Semicolon, Quote, Comma, Period, Slash string
Exclamation, At, Hash, Dollar, Percent, Caret string
Ampersand, Asterisk, LeftParen, RightParen string
Underscore, Plus, Pipe, Tilde string
LeftBrace, RightBrace, Colon, LessThan, GreaterThan string
Question string
}
func (KeyHelper) CtrlShiftAlt ¶
func (KeyHelper) CtrlShiftSuper ¶
func (KeyHelper) ShiftSuper ¶
func (KeyHelper) SuperShift ¶
type KeyID ¶
type KeyID string
const ( KeyUp KeyID = "up" KeyDown KeyID = "down" KeyLeft KeyID = "left" KeyRight KeyID = "right" KeyEnter KeyID = "enter" KeyEscape KeyID = "escape" KeyTab KeyID = "tab" KeyBacktab KeyID = "shift+tab" KeyBackspace KeyID = "backspace" KeyDelete KeyID = "delete" KeyHome KeyID = "home" KeyEnd KeyID = "end" )
type KeyReleaseReceiver ¶
type KeyReleaseReceiver interface {
WantsKeyRelease() bool
}
type Keybinding ¶
type KeybindingConflict ¶
type KeybindingDefinition ¶
type KeybindingDefinitions ¶
type KeybindingDefinitions map[string]KeybindingDefinition
type Keybindings ¶
type Keybindings map[string]Keybinding
type KeybindingsConfig ¶
type KeybindingsManager ¶
type KeybindingsManager struct {
// contains filtered or unexported fields
}
func GetKeybindings ¶
func GetKeybindings() *KeybindingsManager
func NewKeybindingsManager ¶
func NewKeybindingsManager(config ...KeybindingsConfig) *KeybindingsManager
func NewKeybindingsManagerWithDefinitions ¶
func NewKeybindingsManagerWithDefinitions(definitions KeybindingDefinitions, userBindings ...KeybindingsConfig) *KeybindingsManager
func (*KeybindingsManager) Bindings ¶
func (m *KeybindingsManager) Bindings() Keybindings
func (*KeybindingsManager) Conflicts ¶
func (m *KeybindingsManager) Conflicts() []KeybindingConflict
func (*KeybindingsManager) Definition ¶
func (m *KeybindingsManager) Definition(action string) (KeybindingDefinition, bool)
func (*KeybindingsManager) GetConflicts ¶
func (m *KeybindingsManager) GetConflicts() []KeybindingConflict
func (*KeybindingsManager) GetDefinition ¶
func (m *KeybindingsManager) GetDefinition(action string) (KeybindingDefinition, bool)
func (*KeybindingsManager) GetKeys ¶
func (m *KeybindingsManager) GetKeys(action string) []string
func (*KeybindingsManager) GetResolvedBindings ¶
func (m *KeybindingsManager) GetResolvedBindings() KeybindingsConfig
func (*KeybindingsManager) GetUserBindings ¶
func (m *KeybindingsManager) GetUserBindings() KeybindingsConfig
func (*KeybindingsManager) Keys ¶
func (m *KeybindingsManager) Keys(action string) []string
func (*KeybindingsManager) Matches ¶
func (m *KeybindingsManager) Matches(data, action string) bool
func (*KeybindingsManager) Set ¶
func (m *KeybindingsManager) Set(action string, keys []string)
func (*KeybindingsManager) SetUserBindings ¶
func (m *KeybindingsManager) SetUserBindings(config KeybindingsConfig)
func (*KeybindingsManager) UserBindings ¶
func (m *KeybindingsManager) UserBindings() KeybindingsConfig
type KillRing ¶
type KillRing struct {
// contains filtered or unexported fields
}
KillRing stores Emacs-style kill/yank entries.
Consecutive kills can be accumulated into the newest entry. Backward deletions prepend killed text while forward deletions append it.
func NewKillRing ¶
func NewKillRing() *KillRing
func (*KillRing) Push ¶
func (k *KillRing) Push(text string, opts KillRingPushOptions)
type KillRingPushOptions ¶
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
func NewLoader ¶
func NewLoader(text string, options ...LoaderIndicatorOptions) *Loader
func (*Loader) Invalidate ¶
func (l *Loader) Invalidate()
func (*Loader) SetIndicator ¶
func (l *Loader) SetIndicator(options LoaderIndicatorOptions)
func (*Loader) SetMessage ¶
type LoaderIndicatorOptions ¶
type Markdown ¶
type Markdown struct {
// contains filtered or unexported fields
}
func NewMarkdown ¶
func NewMarkdown(text string, theme ...MarkdownTheme) *Markdown
func NewMarkdownWithOptions ¶
func NewMarkdownWithOptions(text string, options MarkdownOptions) *Markdown
func (*Markdown) Invalidate ¶
func (m *Markdown) Invalidate()
type MarkdownOptions ¶
type MarkdownOptions struct {
Theme MarkdownTheme
PaddingX int
PaddingY int
DefaultTextStyle *DefaultTextStyle
}
type MarkdownTheme ¶
type MarkdownTheme struct {
Text func(string) string
Heading func(string) string
Link func(string) string
LinkURL func(string) string
Code func(string) string
CodeBlock func(string) string
CodeBlockBorder func(string) string
Quote func(string) string
QuoteBorder func(string) string
HR func(string) string
ListBullet func(string) string
Bold func(string) string
Italic func(string) string
Strikethrough func(string) string
Underline func(string) string
HighlightCode func(code, lang string) []string
CodeBlockIndent string
}
type OverlayAnchor ¶
type OverlayAnchor string
const ( OverlayCenter OverlayAnchor = "center" OverlayTopLeft OverlayAnchor = "top-left" OverlayTopRight OverlayAnchor = "top-right" OverlayBottomLeft OverlayAnchor = "bottom-left" OverlayBottomRight OverlayAnchor = "bottom-right" OverlayTopCenter OverlayAnchor = "top-center" OverlayBottomCenter OverlayAnchor = "bottom-center" OverlayLeftCenter OverlayAnchor = "left-center" OverlayRightCenter OverlayAnchor = "right-center" )
type OverlayHandle ¶
type OverlayMargin ¶
type OverlayMargin struct {
Top, Right, Bottom, Left int
}
type OverlayOptions ¶
type ProcessTerminal ¶
type ProcessTerminal struct {
// contains filtered or unexported fields
}
ProcessTerminal owns raw terminal setup when stdin is an *os.File, routes input through StdinBuffer, and negotiates Kitty keyboard / modifyOtherKeys sequences the same way pi-tui does at the process boundary.
func NewProcessTerminal ¶
func NewProcessTerminal() *ProcessTerminal
func (*ProcessTerminal) ClearFromCursor ¶
func (t *ProcessTerminal) ClearFromCursor() error
func (*ProcessTerminal) ClearLine ¶
func (t *ProcessTerminal) ClearLine() error
func (*ProcessTerminal) ClearScreen ¶
func (t *ProcessTerminal) ClearScreen() error
func (*ProcessTerminal) Columns ¶
func (t *ProcessTerminal) Columns() int
func (*ProcessTerminal) DrainInput ¶
func (t *ProcessTerminal) DrainInput(maxDuration, idle time.Duration) error
func (*ProcessTerminal) HideCursor ¶
func (t *ProcessTerminal) HideCursor() error
func (*ProcessTerminal) KittyProtocolActive ¶
func (t *ProcessTerminal) KittyProtocolActive() bool
func (*ProcessTerminal) MoveBy ¶
func (t *ProcessTerminal) MoveBy(lines int) error
func (*ProcessTerminal) Rows ¶
func (t *ProcessTerminal) Rows() int
func (*ProcessTerminal) SetProgress ¶
func (t *ProcessTerminal) SetProgress(active bool) error
func (*ProcessTerminal) SetSize ¶
func (t *ProcessTerminal) SetSize(cols, rows int)
func (*ProcessTerminal) SetTitle ¶
func (t *ProcessTerminal) SetTitle(title string) error
func (*ProcessTerminal) ShowCursor ¶
func (t *ProcessTerminal) ShowCursor() error
func (*ProcessTerminal) Start ¶
func (t *ProcessTerminal) Start(onInput func(string), onResize func())
func (*ProcessTerminal) Stop ¶
func (t *ProcessTerminal) Stop()
func (*ProcessTerminal) Write ¶
func (t *ProcessTerminal) Write(data string) error
type SelectItem ¶
type SelectList ¶
type SelectList struct {
OnSelect func(SelectItem)
OnCancel func()
OnSelectionChange func(SelectItem)
// contains filtered or unexported fields
}
func NewSelectList ¶
func NewSelectList(items []SelectItem, maxVisible int, theme SelectListTheme, layout ...SelectListLayoutOptions) *SelectList
func (*SelectList) GetSelectedItem ¶
func (s *SelectList) GetSelectedItem() (SelectItem, bool)
func (*SelectList) HandleInput ¶
func (s *SelectList) HandleInput(data string)
func (*SelectList) Invalidate ¶
func (s *SelectList) Invalidate()
func (*SelectList) Render ¶
func (s *SelectList) Render(width int) []string
func (*SelectList) SelectedItem ¶
func (s *SelectList) SelectedItem() (SelectItem, bool)
func (*SelectList) SetFilter ¶
func (s *SelectList) SetFilter(filter string)
func (*SelectList) SetSelectedIndex ¶
func (s *SelectList) SetSelectedIndex(index int)
type SelectListLayoutOptions ¶
type SelectListLayoutOptions struct {
MinPrimaryColumnWidth int
MaxPrimaryColumnWidth int
TruncatePrimary func(SelectListTruncatePrimaryContext) string
}
type SelectListTheme ¶
type SelectListTruncatePrimaryContext ¶
type SelectListTruncatePrimaryContext struct {
Text string
MaxWidth int
ColumnWidth int
Item SelectItem
IsSelected bool
}
type SettingItem ¶
type SettingsList ¶
type SettingsList struct {
// contains filtered or unexported fields
}
func NewSettingsList ¶
func NewSettingsList(items []SettingItem, maxVisible int, theme SettingsListTheme, options ...SettingsListOptions) *SettingsList
func (*SettingsList) HandleInput ¶
func (s *SettingsList) HandleInput(data string)
func (*SettingsList) Invalidate ¶
func (s *SettingsList) Invalidate()
func (*SettingsList) Render ¶
func (s *SettingsList) Render(width int) []string
func (*SettingsList) UpdateValue ¶
func (s *SettingsList) UpdateValue(id string, newValue string)
type SettingsListOptions ¶
type SettingsListTheme ¶
type SizeAwareComponent ¶
SizeAwareComponent can opt into terminal-size-aware rendering while keeping the simple Component API available for standalone use.
type SizeValue ¶
func PercentFloat ¶
type SlashCommand ¶
type SlashCommand struct {
Name string
Description string
ArgumentHint string
GetArgumentCompletions func(argumentPrefix string) []AutocompleteItem
GetArgumentCompletionsContext func(ctx context.Context, argumentPrefix string) ([]AutocompleteItem, error)
}
type Spacer ¶
type Spacer struct {
// contains filtered or unexported fields
}
func (*Spacer) Invalidate ¶
func (s *Spacer) Invalidate()
type StdinBuffer ¶
type StdinBuffer struct {
// contains filtered or unexported fields
}
func NewStdinBuffer ¶
func NewStdinBuffer(options ...StdinBufferOptions) *StdinBuffer
func (*StdinBuffer) Clear ¶
func (b *StdinBuffer) Clear()
func (*StdinBuffer) Destroy ¶
func (b *StdinBuffer) Destroy()
func (*StdinBuffer) Flush ¶
func (b *StdinBuffer) Flush() []string
func (*StdinBuffer) GetBuffer ¶
func (b *StdinBuffer) GetBuffer() string
func (*StdinBuffer) OnData ¶
func (b *StdinBuffer) OnData(fn func(string))
func (*StdinBuffer) OnPaste ¶
func (b *StdinBuffer) OnPaste(fn func(string))
func (*StdinBuffer) Process ¶
func (b *StdinBuffer) Process(data string)
func (*StdinBuffer) ProcessBytes ¶
func (b *StdinBuffer) ProcessBytes(data []byte)
type StdinBufferEventMap ¶
type StdinBufferOptions ¶
type TUI ¶
type TUI struct {
*Container
// contains filtered or unexported fields
}
TUI manages component focus, input routing, overlays, and terminal rendering.
func (*TUI) AddInputListener ¶
func (t *TUI) AddInputListener(listener InputListener) func()
func (*TUI) ClearOnShrink ¶
func (*TUI) FocusedComponent ¶
func (*TUI) FullRedraws ¶
func (*TUI) GetClearOnShrink ¶
func (*TUI) GetFullRedraws ¶
func (*TUI) GetShowHardwareCursor ¶
func (*TUI) HandleInput ¶
func (*TUI) HasOverlay ¶
func (*TUI) HideOverlay ¶
func (t *TUI) HideOverlay()
func (*TUI) Invalidate ¶
func (t *TUI) Invalidate()
func (*TUI) RemoveInputListener ¶
func (t *TUI) RemoveInputListener(listener InputListener)
func (*TUI) RequestRender ¶
func (*TUI) SetClearOnShrink ¶
func (*TUI) SetOnDebug ¶
func (t *TUI) SetOnDebug(fn func())
func (*TUI) SetShowHardwareCursor ¶
func (*TUI) ShowHardwareCursor ¶
func (*TUI) ShowOverlay ¶
func (t *TUI) ShowOverlay(component Component, options ...OverlayOptions) OverlayHandle
type Terminal ¶
type Terminal interface {
Start(onInput func(string), onResize func())
Stop()
DrainInput(max, idle time.Duration) error
Write(data string) error
Columns() int
Rows() int
KittyProtocolActive() bool
MoveBy(lines int) error
HideCursor() error
ShowCursor() error
ClearLine() error
ClearFromCursor() error
ClearScreen() error
SetTitle(title string) error
SetProgress(active bool) error
}
Terminal is the output/input boundary used by TUI. Implementations can be a real process terminal, an xterm-headless test adapter, or an in-memory fake.
type TerminalCapabilities ¶
type TerminalCapabilities struct {
Images bool
Protocol ImageProtocol
TrueColor bool
Hyperlinks bool
}
func DetectCapabilities ¶
func DetectCapabilities() TerminalCapabilities
func GetCapabilities ¶
func GetCapabilities() TerminalCapabilities
type Text ¶
type Text struct {
// contains filtered or unexported fields
}
func (*Text) Invalidate ¶
func (t *Text) Invalidate()
func (*Text) SetCustomBackground ¶
func (*Text) SetCustomBgFn ¶
type TextChunk ¶
func WordWrapLine ¶
type TruncatedText ¶
type TruncatedText struct {
// contains filtered or unexported fields
}
func NewTruncatedText ¶
func NewTruncatedText(text string, paddingX, paddingY int, options ...TruncatedTextOptions) *TruncatedText
func (*TruncatedText) Invalidate ¶
func (t *TruncatedText) Invalidate()
func (*TruncatedText) Render ¶
func (t *TruncatedText) Render(width int) []string
func (*TruncatedText) SetText ¶
func (t *TruncatedText) SetText(text string)
type TruncatedTextOptions ¶
type UndoStack ¶
type UndoStack[S any] struct { // contains filtered or unexported fields }
UndoStack stores state snapshots. When constructed with a clone function, Push stores the cloned state so later caller mutations do not alter the snapshot. Without a clone function, S is copied by value.
func NewUndoStack ¶
type VirtualCell ¶
type VirtualCell = vtemu.VirtualCell
type VirtualColor ¶
type VirtualColor = vtemu.VirtualColor
type VirtualTerminal ¶
type VirtualTerminal = vtemu.VirtualTerminal
func NewVirtualTerminal ¶
func NewVirtualTerminal(columns, rows int) *VirtualTerminal