editor

package
v1.78.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

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 Terminal: quote-wrapped paths - Single file: just the path

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

Types

type AttachmentPreview

type AttachmentPreview struct {
	Title   string
	Content string
}

AttachmentPreview describes an attachment and its contents for dialog display.

type Editor

type Editor interface {
	layout.Model
	layout.Sizeable
	layout.Focusable
	SetWorking(working bool) tea.Cmd
	AcceptSuggestion() 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 Option added in v1.44.0

type Option func(*editor)

Option configures the Editor.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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