editor

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package editor is the multi-line input: history and history search, completion of slash commands and @file mentions, pasted text and images, and handing the input off to the user's $EDITOR.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(path string, done func(err error) tea.Msg) tea.Cmd

Open edits path with $VISUAL, $EDITOR or vi, and returns done's message when the editor exits.

Types

type Completion

type Completion struct {
	Name        string
	Aliases     []string
	Description string
	// Run sends the command on enter because it takes no arguments.
	Run bool
}

type Editor

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

func New

func New(commands func() []Completion, root func() string) *Editor

func (*Editor) Clear

func (e *Editor) Clear()

func (*Editor) Cursor

func (e *Editor) Cursor() *tea.Cursor

Cursor is relative to View.

func (*Editor) Dismiss

func (e *Editor) Dismiss() bool

Dismiss closes the menu or cancels a history search, restoring the input. It reports whether there was anything to dismiss.

func (*Editor) Empty

func (e *Editor) Empty() bool

Empty is false during a history search, even with no text.

func (*Editor) Insert

func (e *Editor) Insert(text string)

Insert prepends text to the input.

func (*Editor) Menu

func (e *Editor) Menu(width int) []string

func (*Editor) SetAccent

func (e *Editor) SetAccent(c color.Color)

func (*Editor) SetHistory

func (e *Editor) SetHistory(h *History)

func (*Editor) SetSession

func (e *Editor) SetSession(id string)

SetSession sets the session id that new history entries are recorded under.

func (*Editor) SetSuggestion

func (e *Editor) SetSuggestion(s string)

SetSuggestion shows s while the input is empty; tab or enter accepts it.

func (*Editor) SetWidth

func (e *Editor) SetWidth(w int)

func (*Editor) Update

func (e *Editor) Update(msg tea.Msg) (cmd tea.Cmd, in *Input)

Update returns a non-nil in when the user sent the input.

func (*Editor) View

func (e *Editor) View(width int) string

type Error

type Error struct{ Err error }

Error reports a failed paste or external edit to the TUI.

type History

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

History holds a project's inputs, newest first. All projects share one JSON lines file.

func NewHistory

func NewHistory(path, project string) *History

func (*History) Add

func (h *History) Add(text string, pasted map[int]string)

func (*History) Len

func (h *History) Len() int

func (*History) SetSession

func (h *History) SetSession(id string)

type Input

type Input struct {
	// Paste references in Text are already expanded.
	Text   string
	Images []litellm.Block
}

Jump to

Keyboard shortcuts

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