editor

package
v1.168.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: Apache-2.0 Imports: 42 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSupportedFileType

func IsSupportedFileType(path string) bool

IsSupportedFileType checks if a file has a supported extension.

func ParsePastedFiles

func ParsePastedFiles(s string) []string

ParsePastedFiles attempts to parse pasted content as file paths. It handles different terminal formats: - Unix: space-separated with backslash escaping - Windows: quoted and/or whitespace-separated paths, backslashes literal - Windows Terminal (incl. WSL): quote-wrapped paths - Single file: just the path

Returns nil if the content doesn't look like file paths.

Types

type AttachmentBar added in v1.168.0

type AttachmentBar interface {
	SetBounds(width, maxHeight int)
	View() string
	AttachmentAtPosition(x, y int) (AttachmentPreview, bool)
	CanExpand() bool
	ToggleAt(x, y int) bool
	Toggle()
	SetFocused(focused bool)
	Hover(x, y int) tea.Cmd
	Tick(tick animation.TickMsg)
	ClearHover()
}

AttachmentBar is the separately laid out attachment surface of the composer.

type AttachmentPreview

type AttachmentPreview struct {
	Title     string
	Content   string
	MIME      string
	ImageData []byte
	IsImage   bool
}

AttachmentPreview keeps encoded image bytes out of the terminal text path.

type ContentLineCounter added in v1.168.0

type ContentLineCounter interface {
	ContentLineCount(width int) int
}

ContentLineCounter measures draft rows at the requested input width, without counting any placeholder, suggestion, or editor chrome.

type Editor

type Editor interface {
	layout.Model
	layout.Sizeable
	layout.Focusable
	SetWorking(working bool) tea.Cmd
	AcceptSuggestion() tea.Cmd
	// TryStartArgumentCompletion opens the argument-completion popup for the
	// slash command at the start of the editor's value (e.g.
	// "/toolset-restart "), if that command exposes argument candidates.
	// Called from the Tab/switchFocus path, never from editor keypress
	// handling, so a bare space after a command never auto-opens a popup —
	// only Tab does. Returns nil (leaving editor state untouched) when
	// there's nothing to complete, so the caller can fall through to its own
	// Tab handling (e.g. focus switch).
	TryStartArgumentCompletion() tea.Cmd
	ScrollByWheel(delta int)
	// Value returns the current editor content
	Value() string
	// SetValue updates the editor content
	SetValue(content string)
	// InsertText inserts text at the current cursor position
	InsertText(text string)
	// AttachFile adds a file as an attachment and inserts @filepath into the editor
	AttachFile(filePath string) error
	Cleanup()
	GetSize() (width, height int)
	BannerHeight() int
	AttachmentAt(x int) (AttachmentPreview, bool)
	// SetRecording sets the recording mode which shows animated dots as the cursor
	SetRecording(recording bool) tea.Cmd
	// IsRecording returns true if the editor is in recording mode
	IsRecording() bool
	// IsHistorySearchActive returns true if the editor is in history search mode
	IsHistorySearchActive() bool
	// EnterHistorySearch activates incremental history search
	EnterHistorySearch() (layout.Model, tea.Cmd)
	// SendContent triggers sending the current editor content
	SendContent() tea.Cmd
}

Editor represents an input editor component

func New

func New(hist *history.History, opts ...Option) Editor

New creates a new editor component

type HistoryRecall added in v1.168.0

type HistoryRecall interface {
	IsHistoryRecall(msg tea.Msg) bool
}

HistoryRecall distinguishes history arrows from caret movement and search.

type Option added in v1.44.0

type Option func(*editor)

Option configures the Editor.

func WithAnimationRuntime added in v1.168.0

func WithAnimationRuntime(ar *animation.Runtime) Option

WithAnimationRuntime binds attachment hover to the owning program clock.

func WithCompletions added in v1.44.0

func WithCompletions(comps ...completions.Completion) Option

WithCompletions sets the available completions for the editor.

func WithPlaceholder added in v1.75.0

func WithPlaceholder(placeholder string) Option

WithPlaceholder sets the editor's placeholder text (shown while empty).

func WithReadOnly added in v1.74.0

func WithReadOnly() Option

WithReadOnly disables the editor so no new messages can be composed.

type TextOccupancy added in v1.164.0

type TextOccupancy interface {
	AppendOccupiedTextCells(dst []image.Rectangle, origin image.Point) []image.Rectangle
}

TextOccupancy appends the visible input glyph cells in screen coordinates, using origin as the editor view's top-left. Prompts, line numbers, padding, the attachment banner, placeholders, whitespace and ghosts are excluded.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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