ui

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 50 Imported by: 0

Documentation

Overview

Package ui implements the Bubbletea terminal application model for toe

Index

Constants

View Source
const (
	// CompletionMode is the keymap mode used while the completion popup is
	// focused
	CompletionMode = "COM"

	// CompletionAcceptAction accepts the selected completion item
	CompletionAcceptAction = "completion_accept"

	// CompletionCancelAction dismisses the completion popup
	CompletionCancelAction = "completion_cancel"

	// CompletionPreviousAction selects the previous completion item
	CompletionPreviousAction = "completion_previous"

	// CompletionNextAction selects the next completion item
	CompletionNextAction = "completion_next"

	// CompletionPageUpAction moves selection up by one completion page
	CompletionPageUpAction = "completion_page_up"

	// CompletionPageDownAction moves selection down by one completion page
	CompletionPageDownAction = "completion_page_down"

	// CompletionFirstAction selects the first completion item
	CompletionFirstAction = "completion_first"

	// CompletionLastAction selects the last completion item
	CompletionLastAction = "completion_last"
)
View Source
const (
	DefaultPickerSplitRatio = 0.5
	MinPickerSplitRatio     = 0.2
	MaxPickerSplitRatio     = 0.8
)
View Source
const PickerMaxPreview = 10 * 1024 * 1024

PickerMaxPreview is the largest file size a picker will preview inline

Variables

View Source
var (
	ErrNoFocusedDocument = errors.New("no focused document")
	ErrNoFocusedView     = errors.New("no focused view")
	ErrUnknownVariable   = errors.New("unknown variable")
	ErrInvalidUnicode    = errors.New("invalid Unicode codepoint")
	ErrShellExpansion    = errors.New("shell expansion failed")
	ErrInvalidRegister   = errors.New("invalid register")
)
View Source
var ErrInvalidImage = errors.New("invalid image")

ErrInvalidImage reports a file that cannot be decoded as an image

View Source
var ErrScrollbackNoMatch = errors.New("pattern not found in scrollback")

Functions

func AcceptDocumentID

func AcceptDocumentID(
	e *view.Editor, id view.DocumentId, action PickerAcceptAction,
) (*view.View, bool)

AcceptDocumentID opens the document by id, splitting per action, and returns the view now showing it

func AcceptPath

func AcceptPath(
	e *view.Editor, path string, action PickerAcceptAction,
) (*view.View, bool)

AcceptPath opens the file at path (switching to it if already open), splitting per action, and returns the view now showing it

func AlignAcceptedView

func AlignAcceptedView(e *view.Editor, v *view.View, doc *view.Document)

AlignAcceptedView scrolls the view so the accepted document's cursor is visible after a picker jump

func CloseAllTerminalPanes

func CloseAllTerminalPanes(e *view.Editor)

CloseAllTerminalPanes kills every open terminal's shell, including ones stashed behind a replacement, so the process doesn't orphan them on exit

func FromTeaKey

func FromTeaKey(k tea.KeyPressMsg) command.KeyEvent

FromTeaKey converts a Bubbletea v2 KeyPressMsg to a KeyEvent

func NewTokenExpander

func NewTokenExpander(e *view.Editor) command.TokenExpander

NewTokenExpander returns a TokenExpander that resolves percent-expansions using the current editor state (selections, registers, variables, shell)

func OpenPath

func OpenPath(
	e *view.Editor, path string, action PickerAcceptAction,
) (*view.View, bool, error)

OpenPath opens a text document or image pane at path

func SkipPickerPath

func SkipPickerPath(args SkipPickerPathArgs) bool

SkipPickerPath reports whether a walked entry should be excluded from a picker's file listing under the given ignore rules

func SortPickerItems

func SortPickerItems(items []PickerItem)

SortPickerItems sorts items by display text, the default ordering for static picker sources

Types

type BufferOverlayComponent

type BufferOverlayComponent interface {
	Component
	Layout(*Context, geom.Size) (geom.Area, bool)
	PaintBuffer(*Context, geom.Area) *tui.Buffer
}

BufferOverlayComponent extends Component for overlay layers that own their own cell buffer instead of drawing into the shared one

type BufferRenderer

type BufferRenderer interface {
	Component
	Render(*Context, geom.Size) *tui.Buffer
}

BufferRenderer exposes the raw cell buffer a base component rendered into, so overlay layers can draw directly onto it

type Callback

type Callback func(*Context, *Compositor) tea.Cmd

Callback lets a component push, pop, or mutate compositor layers without direct coupling — the compositor executes it after event propagation completes

type Component

type Component interface {
	HandleEvent(*Context, tea.Msg) (EventResult, tea.Cmd)
	Cursor(*Context, geom.Size) (tea.Cursor, bool)
}

Component is the interface every compositor layer must implement

type Compositor

type Compositor struct {
	// contains filtered or unexported fields
}

func (*Compositor) Cursor

func (c *Compositor) Cursor(cx *Context) (cur tea.Cursor, ok bool)

func (*Compositor) HandleEvent

func (c *Compositor) HandleEvent(cx *Context, msg tea.Msg) tea.Cmd

func (*Compositor) Pop

func (c *Compositor) Pop()

func (*Compositor) Push

func (c *Compositor) Push(layer Component)

func (*Compositor) Render

func (c *Compositor) Render(cx *Context) string

type Context

type Context struct {
	Editor  *view.Editor
	Keymaps *command.Keymaps
	Syntax  *syntax.Cache

	SingleLayer bool

	OverlayRegions        []geom.Area
	OverlayRegionsPrecise bool
	OverlaysChanged       bool
	// contains filtered or unexported fields
}

Context holds shared mutable state accessible to all compositor layers

func (*Context) StyleGen

func (c *Context) StyleGen() int

StyleGen returns a counter that increments whenever the active theme changes, letting cached overlay buffers know they must repaint even without their own content changing

func (*Context) Theme

func (c *Context) Theme() *theme.Theme

Theme returns the active theme, reloading it if the configured name changed, falling back to the embedded default on load failure

type Draggable

type Draggable interface {
	BeginDrag(*Context, geom.Point, tea.KeyMod) bool
	ContinueDrag(*Context, geom.Point) tea.Cmd
	EndDrag(*Context, geom.Point) tea.Cmd
	CancelDrag()
	DragTick(cx *Context, gen int, toTop bool) tea.Cmd
}

Draggable is a pane that handles mouse drags itself. Drags span several events with cross-event state, so they stay separate from PaneInput

type DynamicPickerSource

type DynamicPickerSource interface {
	PickerSource
	Search(query string)
}

DynamicPickerSource extends PickerSource with query-driven search

type EditorComponent

type EditorComponent struct {
	// contains filtered or unexported fields
}

func (*EditorComponent) Cursor

func (e *EditorComponent) Cursor(
	cx *Context, screen geom.Size,
) (tea.Cursor, bool)

func (*EditorComponent) HandleEvent

func (e *EditorComponent) HandleEvent(
	cx *Context, msg tea.Msg,
) (EventResult, tea.Cmd)

func (*EditorComponent) MacroRecordAction

func (e *EditorComponent) MacroRecordAction(
	ed *view.Editor,
) command.Continuation

MacroRecordAction starts or stops macro recording. When not recording, prompts for a register key and begins recording. When already recording, stops and saves the macro to the chosen register

func (*EditorComponent) MacroReplayAction

func (e *EditorComponent) MacroReplayAction(
	ed *view.Editor,
) command.Continuation

MacroReplayAction prompts for a register key and replays the macro stored there count times

func (*EditorComponent) Render

func (e *EditorComponent) Render(cx *Context, screen geom.Size) *tui.Buffer

Render returns the editor's cell buffer for the compositor to blit overlays onto, skipping an ANSI round-trip

type EventResult

type EventResult struct {
	Consumed bool
	Callback Callback
}

EventResult is returned by every Component.HandleEvent call

type Image

type Image struct {
	image.Image
	// contains filtered or unexported fields
}

Image holds decoded image data, its content identifier, and the decoded source format (e.g. "png") for transmission fast paths

func LoadImage

func LoadImage(path string) (*Image, error)

LoadImage reads path and returns a decoded image

func (*Image) ContentID

func (i *Image) ContentID() uint32

ContentID returns a stable identifier for the decoded image bytes

func (*Image) Size

func (i *Image) Size() geom.Size

Size returns the image bounds in pixels

type ImagePane

type ImagePane struct {
	// contains filtered or unexported fields
}

ImagePane displays an image in the editor's pane tree. It owns its own input: mouse wheel zooms via MouseHandler, and it shows no text cursor

func NewImagePane

func NewImagePane(e *view.Editor, path string) (*ImagePane, error)

NewImagePane loads path into an image pane

func (*ImagePane) Area

func (p *ImagePane) Area() geom.Area

Area returns the screen rectangle assigned by the layout tree

func (*ImagePane) Close

func (p *ImagePane) Close()

Close closes this image pane

func (*ImagePane) ConsumeDirty

func (p *ImagePane) ConsumeDirty() bool

ConsumeDirty reports and clears whether the pane changed

func (*ImagePane) Cursor

func (p *ImagePane) Cursor(*Context) (tea.Cursor, bool)

Cursor reports that an image pane shows no text cursor

func (*ImagePane) Discard

func (p *ImagePane) Discard()

Discard releases this displaced image pane

func (*ImagePane) HandleEvent

func (p *ImagePane) HandleEvent(
	_ *Context, msg tea.Msg,
) (EventResult, bool)

HandleEvent zooms the image on a wheel event and ignores everything else, letting keys and other input fall through to the editor

func (*ImagePane) ID

func (p *ImagePane) ID() view.Id

ID returns the pane identifier

func (*ImagePane) Image

func (p *ImagePane) Image() *Image

Image returns the decoded image

func (*ImagePane) MarkDirty

func (p *ImagePane) MarkDirty()

MarkDirty flags the pane as needing a repaint

func (*ImagePane) Mode

func (p *ImagePane) Mode() view.Mode

Mode reports image mode

func (*ImagePane) Path

func (p *ImagePane) Path() string

Path returns the loaded image path

func (*ImagePane) Reload

func (p *ImagePane) Reload() error

Reload re-decodes the backing file after an external change; the new bytes yield a new ContentID, so the display path retransmits automatically

func (*ImagePane) ResetZoom

func (p *ImagePane) ResetZoom()

ResetZoom restores the fitted image scale

func (*ImagePane) SaveSession

func (p *ImagePane) SaveSession(w *view.SessionWriter)

SaveSession stores the image path so the pane can be reopened

func (*ImagePane) SetArea

func (p *ImagePane) SetArea(a geom.Area)

SetArea sets the screen rectangle assigned by the layout tree

func (*ImagePane) SetID

func (p *ImagePane) SetID(id view.Id)

SetID sets the pane identifier

func (*ImagePane) Shutdown

func (p *ImagePane) Shutdown()

Shutdown releases external resources owned by this pane

func (*ImagePane) Split

func (p *ImagePane) Split() (view.Pane, error)

Split returns another pane displaying the same image

func (*ImagePane) Zoom

func (p *ImagePane) Zoom() int

Zoom returns the image scale as a percentage of its fitted size

func (*ImagePane) ZoomIn

func (p *ImagePane) ZoomIn()

ZoomIn increases the image scale

func (*ImagePane) ZoomOut

func (p *ImagePane) ZoomOut()

ZoomOut decreases the image scale

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is the root Bubbletea model — a thin wrapper around Compositor

func New

func New(editor *view.Editor, km *command.Keymaps) Model

New creates an initialized Model for the given editor and keymaps

func (Model) CmdModeAction

func (m Model) CmdModeAction() command.KeyAction

func (Model) CodeActionPickerAction

func (m Model) CodeActionPickerAction() command.KeyAction

func (Model) CommandPaletteAction

func (m Model) CommandPaletteAction() command.KeyAction

func (Model) CompletionAction

func (m Model) CompletionAction() command.KeyAction

func (Model) ExecTypable

func (m Model) ExecTypable(input string) Model

func (Model) GotoDeclarationAction

func (m Model) GotoDeclarationAction() command.KeyAction

func (Model) GotoDefinitionAction

func (m Model) GotoDefinitionAction() command.KeyAction

func (Model) GotoImplementationAction

func (m Model) GotoImplementationAction() command.KeyAction

func (Model) GotoReferenceAction

func (m Model) GotoReferenceAction() command.KeyAction

func (Model) GotoTypeDefinitionAction

func (m Model) GotoTypeDefinitionAction() command.KeyAction

func (Model) HoverAction

func (m Model) HoverAction() command.KeyAction

func (Model) Init

func (m Model) Init() tea.Cmd

Init fires the startup cmd if one was set before the program started

func (Model) LastPickerAction

func (m Model) LastPickerAction() command.KeyAction

func (Model) MacroRecordAction

func (m Model) MacroRecordAction(e *view.Editor) command.Continuation

func (Model) MacroReplayAction

func (m Model) MacroReplayAction(e *view.Editor) command.Continuation

func (Model) PickerAction

func (m Model) PickerAction(fn PickerFunc) command.KeyAction

func (Model) PickerLayoutOptions

func (m Model) PickerLayoutOptions() PickerLayoutOptions

PickerLayoutOptions returns the UI-owned picker layout settings

func (Model) RegexAction

func (m Model) RegexAction(prompt string, fn promptHandler) command.KeyAction

func (Model) RenameSymbolAction

func (m Model) RenameSymbolAction() command.KeyAction

func (Model) ResizeViewAction

func (m Model) ResizeViewAction(e *view.Editor) command.Continuation

ResizeViewAction enters an interactive resize mode: h/l (or left/right) and j/k (or up/down) push the focused split's border in that literal screen direction, one cell per keypress, until Escape or Enter exits

func (Model) SearchAction

func (m Model) SearchAction(forward bool) command.KeyAction

func (Model) SelectReferencesAction

func (m Model) SelectReferencesAction() command.KeyAction

func (Model) SetPickerLayoutOptions

func (m Model) SetPickerLayoutOptions(opts PickerLayoutOptions)

SetPickerLayoutOptions applies UI-owned picker layout settings

func (Model) ShellAction

func (m Model) ShellAction(prompt string, fn promptHandler) command.KeyAction

func (Model) SignatureHelpAction

func (m Model) SignatureHelpAction() command.KeyAction

func (Model) SymbolPickerAction

func (m Model) SymbolPickerAction() command.KeyAction

func (Model) TerminalAction

func (m Model) TerminalAction() command.KeyAction

TerminalAction opens the user's shell in the focused pane

func (Model) TerminalSearchAction

func (m Model) TerminalSearchAction() command.KeyAction

TerminalSearchAction opens a prompt that jumps the focused terminal's scrollback to the nearest match above the current view

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update delegates all events to the compositor

func (Model) View

func (m Model) View() tea.View

View renders the current frame via the compositor

func (Model) WithInitialPicker

func (m Model) WithInitialPicker(fn PickerFunc) Model

func (Model) WithStartupCmd

func (m Model) WithStartupCmd(cmd tea.Cmd) Model

func (Model) WithStartupMessage

func (m Model) WithStartupMessage(msg string) Model

WithStartupMessage sets a status bar message for the first frame

func (Model) WorkspaceSymbolPickerAction

func (m Model) WorkspaceSymbolPickerAction() command.KeyAction
type NavigablePickerSource interface {
	PickerSource
	Navigate(*view.Editor, PickerItem) PickerFunc
}

NavigablePickerSource extends PickerSource for pickers that can drill into sub-pickers. Navigate returns a PickerFunc to replace the current picker, or nil to fall through to Accept

type PaneCursor

type PaneCursor interface {
	Cursor(*Context) (tea.Cursor, bool)
}

PaneCursor is a pane that positions its own cursor

type PaneInput

type PaneInput interface {
	HandleEvent(*Context, tea.Msg) (EventResult, bool)
}

PaneInput is a pane that handles bubbletea key and mouse events itself. It receives the event first; an unconsumed event (handled=false) falls through to the editor's default keymap/document handling

type Pasteable

type Pasteable interface {
	Paste(text string)
}

Pasteable is a pane that consumes a paste itself instead of the document/selection paste

type Picker

type Picker struct {
	// contains filtered or unexported fields
}

Picker holds the runtime state for an open picker overlay

func CommandPalettePicker

func CommandPalettePicker(e *view.Editor, km *command.Keymaps) *Picker

CommandPalettePicker opens a picker listing all registered commands

func LSPWorkspaceCommandPicker

func LSPWorkspaceCommandPicker(e *view.Editor) *Picker

LSPWorkspaceCommandPicker opens commands exposed by language servers

func NewChangedFilePicker

func NewChangedFilePicker(e *view.Editor) *Picker

NewChangedFilePicker lists workspace files the version-control system reports as changed

func NewPicker

func NewPicker(e *view.Editor, source PickerSource) *Picker

NewPicker constructs a Picker for the given source, triggering Load immediately. The returned feedCmd (if any) must be dispatched by the caller after mounting the component

func (*Picker) MatchCount

func (p *Picker) MatchCount() int

MatchCount reports how many items currently match the query

func (*Picker) SelectIndex

func (p *Picker) SelectIndex(i int)

SelectIndex moves the cursor to i when it is a valid match index

type PickerAcceptAction

type PickerAcceptAction int
const (
	PickerAcceptReplace PickerAcceptAction = iota
	PickerAcceptHorizontalSplit
	PickerAcceptVerticalSplit
)

type PickerBase

type PickerBase struct {
	// contains filtered or unexported fields
}

PickerBase is an optional starting point a source can embed for default id, column, and fuzzy-match behavior; a source is free to implement those methods itself instead

func NewPickerBase

func NewPickerBase(
	id string, columns []string, matchColumn int, proportions []int,
) PickerBase

NewPickerBase builds the fixed metadata a source embeds: kebab-case id, column headers, the column matched against, and each column's flex weight

func (PickerBase) ColumnProportions

func (p PickerBase) ColumnProportions() []int

func (PickerBase) Columns

func (p PickerBase) Columns() []string

func (PickerBase) ID

func (p PickerBase) ID() string

func (PickerBase) Match

func (p PickerBase) Match(query string, item PickerItem) (int, []int, bool)

func (PickerBase) MatchColumn

func (p PickerBase) MatchColumn() int

type PickerComponent

type PickerComponent struct {
	// contains filtered or unexported fields
}

func (*PickerComponent) Cursor

func (p *PickerComponent) Cursor(
	*Context, geom.Size,
) (cur tea.Cursor, ok bool)

func (*PickerComponent) HandleEvent

func (p *PickerComponent) HandleEvent(
	cx *Context, msg tea.Msg,
) (EventResult, tea.Cmd)

func (*PickerComponent) Layout

func (p *PickerComponent) Layout(
	_ *Context, screen geom.Size,
) (geom.Area, bool)

func (*PickerComponent) PaintBuffer

func (p *PickerComponent) PaintBuffer(cx *Context, pl geom.Area) *tui.Buffer

type PickerFunc

type PickerFunc func(e *view.Editor) *Picker

PickerFunc constructs a Picker from the editor

type PickerIgnore

type PickerIgnore struct {
	// contains filtered or unexported fields
}

func LoadIgnoreFiles

func LoadIgnoreFiles(
	root, path string, opts PickerIgnoreOptions,
) []PickerIgnore

type PickerIgnoreOptions

type PickerIgnoreOptions struct {
	Hidden     bool
	Parents    bool
	Ignore     bool
	GitIgnore  bool
	GitGlobal  bool
	GitExclude bool
}

func DefaultPickerIgnoreOptions

func DefaultPickerIgnoreOptions() PickerIgnoreOptions

DefaultPickerIgnoreOptions is the ignore behavior file-walking pickers use when a caller does not need to customize it

type PickerItem

type PickerItem struct {
	Display     string
	Columns     []string
	StyleScopes []string
	SortKey     string
	Preview     PreviewRenderer
	Location    PickerLocation
	Payload     any
	DiffHunks   []view.DiffHunk
	DiffPreview bool
	DiffKind    view.FileChangeKind
	BasePath    string
}

PickerItem is a single row shown in the picker list

type PickerLayoutOptions

type PickerLayoutOptions struct {
	SplitRatios map[string]float64 `toml:"split-ratios"`
}

func (PickerLayoutOptions) SplitRatioFor

func (o PickerLayoutOptions) SplitRatioFor(key string) float64

SplitRatioFor returns the saved split ratio for a picker key

type PickerLineRange

type PickerLineRange struct {
	From int
	To   int
}

type PickerLocation

type PickerLocation struct {
	Target PickerTarget
	Lines  *PickerLineRange
}

PickerLocation holds a target and an optional line range

type PickerPreviewSkipper

type PickerPreviewSkipper interface {
	SkipPreview()
}

PickerPreviewSkipper marks picker sources that never render previews

type PickerSource

type PickerSource interface {
	ID() string
	Columns() []string
	MatchColumn() int
	ColumnProportions() []int
	Load(*view.Editor) ([]PickerItem, <-chan PickerItem, StopFunc)
	Accept(*view.Editor, PickerItem, PickerAcceptAction)
}

PickerSource is implemented by every picker data source

type PickerTarget

type PickerTarget struct {
	Path string
	ID   view.DocumentId
}

PickerTarget identifies a document by path or in-memory ID

func (PickerTarget) Valid

func (p PickerTarget) Valid() bool

Valid reports whether the target refers to a real document or path

type PreviewRenderer

type PreviewRenderer func(geom.Size) string

PreviewRenderer renders a picker item's preview at the given size

type PromptComponent

type PromptComponent struct {
	// contains filtered or unexported fields
}

func (*PromptComponent) Cursor

func (p *PromptComponent) Cursor(
	cx *Context, _ geom.Size,
) (cur tea.Cursor, ok bool)

func (*PromptComponent) HandleEvent

func (p *PromptComponent) HandleEvent(
	cx *Context, msg tea.Msg,
) (EventResult, tea.Cmd)

func (*PromptComponent) Layout

func (p *PromptComponent) Layout(
	cx *Context, screen geom.Size,
) (geom.Area, bool)

func (*PromptComponent) PaintBuffer

func (p *PromptComponent) PaintBuffer(cx *Context, pl geom.Area) *tui.Buffer

type SkipPickerPathArgs

type SkipPickerPathArgs struct {
	Rel     string
	Path    string
	Entry   os.DirEntry
	Ignores []PickerIgnore
	Opts    PickerIgnoreOptions
}

SkipPickerPathArgs holds the entry a picker file-walk is considering and the ignore state to test it against

type StaticPickerSource

type StaticPickerSource interface {
	PickerSource
	Match(query string, item PickerItem) (score int, indices []int, ok bool)
}

StaticPickerSource extends PickerSource with fuzzy-match filtering

type StopFunc

type StopFunc func()

StopFunc cancels an in-progress feed or search

type TerminalPane

type TerminalPane struct {
	// contains filtered or unexported fields
}

TerminalPane is a view.Pane backed by a real PTY and a VT100/xterm emulator, so full-screen programs (editors, pagers, TUIs) render correctly

func NewTerminalPane

func NewTerminalPane(
	e *view.Editor, shell string, size geom.Size,
) (*TerminalPane, error)

NewTerminalPane spawns shell in a PTY and pumps its output into a VT emulator sized w by h

func NewTerminalPaneInDir

func NewTerminalPaneInDir(
	e *view.Editor, shell, dir string, size geom.Size,
) (*TerminalPane, error)

NewTerminalPaneInDir spawns shell in dir

func (*TerminalPane) Area

func (t *TerminalPane) Area() geom.Area

Area returns the screen rectangle assigned by the layout engine

func (*TerminalPane) BeginDrag

func (t *TerminalPane) BeginDrag(
	cx *Context, at geom.Point, mod tea.KeyMod,
) bool

BeginDrag starts a selection if the shell hasn't grabbed mouse tracking, or forwards the click to it otherwise

func (*TerminalPane) CancelDrag

func (t *TerminalPane) CancelDrag()

CancelDrag stops any pending auto-scroll tick, without side effects

func (*TerminalPane) Close

func (t *TerminalPane) Close()

Close terminates this terminal and closes its pane

func (*TerminalPane) Closed

func (t *TerminalPane) Closed() <-chan struct{}

Closed delivers a signal once the shell process has exited

func (*TerminalPane) ConsumeBell

func (t *TerminalPane) ConsumeBell(focused bool) bool

ConsumeBell reports whether the bell has rung since it was last consumed. A rung bell only clears when read while focused, so it stays visible in the status line until the pane is actually looked at

func (*TerminalPane) ConsumeDirty

func (t *TerminalPane) ConsumeDirty() bool

ConsumeDirty reports whether the pane has changed since the last call, clearing the flag

func (*TerminalPane) ContinueDrag

func (t *TerminalPane) ContinueDrag(cx *Context, at geom.Point) tea.Cmd

ContinueDrag extends the selection to (x, y), auto-scrolling and scheduling further ticks if the drag has crossed the pane's top or bottom edge

func (*TerminalPane) Cursor

func (t *TerminalPane) Cursor(cx *Context) (tea.Cursor, bool)

Cursor reports the shell's cursor position, translated to screen space

func (*TerminalPane) Discard

func (t *TerminalPane) Discard()

Discard terminates this displaced terminal and everything behind it

func (*TerminalPane) DragTick

func (t *TerminalPane) DragTick(_ *Context, gen int, toTop bool) tea.Cmd

DragTick continues scrolling toward toTop if gen still matches the scheduling tick, or is a no-op if a newer drag has since superseded it

func (*TerminalPane) Emulator

func (t *TerminalPane) Emulator() *vt.SafeEmulator

Emulator returns the underlying VT emulator for rendering and input

func (*TerminalPane) EndDrag

func (t *TerminalPane) EndDrag(cx *Context, at geom.Point) tea.Cmd

EndDrag finalizes the selection at (x, y), copying it to the clipboard

func (*TerminalPane) HandleEvent

func (t *TerminalPane) HandleEvent(
	cx *Context, msg tea.Msg,
) (EventResult, bool)

HandleEvent routes key and mouse events to the shell

func (*TerminalPane) ID

func (t *TerminalPane) ID() view.Id

ID returns the pane identifier

func (*TerminalPane) IngestOutput

func (t *TerminalPane) IngestOutput(data []byte)

IngestOutput applies a chunk of output as if it had just been read from the PTY, letting tests simulate shell output without a real child process

func (*TerminalPane) MarkDirty

func (t *TerminalPane) MarkDirty()

MarkDirty flags the pane as needing a repaint on the next frame

func (*TerminalPane) Mode

func (t *TerminalPane) Mode() view.Mode

Mode reports view.ModeTerminal, since a terminal pane has no insert/select/normal distinction

func (*TerminalPane) MouseEnabled

func (t *TerminalPane) MouseEnabled() bool

MouseEnabled reports whether the program running in the shell has requested mouse tracking (e.g. vim, htop, tmux)

func (*TerminalPane) Paste

func (t *TerminalPane) Paste(text string)

Paste sends text to the shell, bracketing it with paste-mode escapes if the running program requested bracketed paste

func (*TerminalPane) Path

func (t *TerminalPane) Path() string

Path returns the shell working directory most recently reported by OSC 7

func (*TerminalPane) SaveSession

func (t *TerminalPane) SaveSession(w *view.SessionWriter)

SaveSession stores a terminal slot so a fresh shell can be reopened

func (*TerminalPane) ScrollLines

func (t *TerminalPane) ScrollLines(n int)

ScrollLines moves the view n lines back into scrollback (n < 0 moves toward live output); a no-op while the alt screen is active

func (*TerminalPane) ScrollOffset

func (t *TerminalPane) ScrollOffset() int

ScrollOffset returns the number of lines scrolled back from live output

func (*TerminalPane) ScrollToBottom

func (t *TerminalPane) ScrollToBottom()

ScrollToBottom returns the view to live output

func (*TerminalPane) SearchScrollback

func (t *TerminalPane) SearchScrollback(pattern string) bool

SearchScrollback jumps to the nearest line above the current view containing pattern (case-insensitive), reporting whether one was found

func (*TerminalPane) SendKey

func (t *TerminalPane) SendKey(k uv.KeyEvent)

SendKey forwards a key event to the shell. Printable text bypasses vt's encoder, which silently drops runes whose Mod is non-zero (e.g. shifted). Any keypress returns the view to live output, like a real terminal

func (*TerminalPane) SendMouse

func (t *TerminalPane) SendMouse(m uv.MouseEvent)

SendMouse forwards a mouse event to the shell

func (*TerminalPane) SetArea

func (t *TerminalPane) SetArea(a geom.Area)

SetArea updates the pane's screen rectangle and resizes the PTY and emulator to match, reflowing the shell

func (*TerminalPane) SetID

func (t *TerminalPane) SetID(id view.Id)

SetID sets the pane identifier (called by the tree on insertion)

func (*TerminalPane) Shutdown

func (t *TerminalPane) Shutdown()

Shutdown terminates this terminal and terminals behind it

func (*TerminalPane) Split

func (t *TerminalPane) Split() (view.Pane, error)

Split starts another terminal using the same shell

func (*TerminalPane) Stop

func (t *TerminalPane) Stop() error

Stop terminates the shell process and releases the PTY

func (*TerminalPane) Title

func (t *TerminalPane) Title() string

Title returns the terminal title most recently set by the shell or the program running in it (OSC 0/2), or "" if none has been set yet

func (*TerminalPane) Updates

func (t *TerminalPane) Updates() <-chan struct{}

Updates delivers a signal each time new output arrives from the shell

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL