editor

package
v0.0.0-...-8aadb99 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoTempDirectory indicates that Go's standard os.TempDir() did not return a directory.
	ErrNoTempDirectory = errors.New("could not identify the temp directory on this system")
	// ErrWrite indicates that we failed to write the buffer to the file.
	ErrWrite = errors.New("failed to write buffer to file")
	// ErrCreate indicates that we failed to create the temp buffer file.
	ErrCreate = errors.New("failed to create buffer file")
	// ErrOpen indicates that we failed to open the buffer file.
	ErrOpen = errors.New("failed to open buffer file")
	// ErrRemove indicates that we failed to delete the buffer file.
	ErrRemove = errors.New("failed to remove buffer file")
	// ErrRead indicates that we failed to read the buffer file's content.
	ErrRead = errors.New("failed to read buffer file")
)
View Source
var ErrStart = errors.New("failed to start editor")

ErrStart indicates that the command to start the editor failed.

Functions

This section is empty.

Types

type Buffers

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

Buffers is a list of registers in which to put yanked/cut contents. These buffers technically are Vim registers with full functionality.

func NewBuffers

func NewBuffers() *Buffers

NewBuffers is a required constructor to set up all the buffers/registers for the shell, because it contains maps that must be correctly initialized.

func (*Buffers) Active

func (reg *Buffers) Active() []rune

Active returns the contents of the active buffer/register (or the kill buffer if no active register is active), and resets the active register.

func (*Buffers) Complete

func (reg *Buffers) Complete() completion.Values

Complete returns the contents of all buffers as a structured list of completions.

func (*Buffers) EditBuffer

func (reg *Buffers) EditBuffer(buf []rune, filename, filetype string, emacs bool) ([]rune, error)

EditBuffer starts the system editor and opens the given buffer in it. If the filename is specified, the file will be created in the system temp directory under this name. If the filetype is not empty and if the system editor supports it, the file will be opened with the specified filetype passed to the editor.

func (*Buffers) Get

func (reg *Buffers) Get(register rune) []rune

Get returns the contents of a given register. If the rune is nil (rune(0)), it returns the value of the kill buffer (the " Vim register). If the rune is an alphanumeric comprised in the valid register IDs, their content is returned. If the register name is invalid, the function returns an empty rune slice.

func (*Buffers) GetKill

func (reg *Buffers) GetKill() []rune

GetKill returns the contents of the kill buffer.

func (*Buffers) IsSelected

func (reg *Buffers) IsSelected() (name string, selected bool)

IsSelected returns the name of the selected register, and true if one is indeed selected, or the default one and false.

func (*Buffers) Pop

func (reg *Buffers) Pop() []rune

Pop rotates the kill ring and returns the new top.

func (*Buffers) Reset

func (reg *Buffers) Reset()

Reset forgets any active/pending buffer/register, but does not delete its contents.

func (*Buffers) SetActive

func (reg *Buffers) SetActive(register rune)

SetActive sets the currently active register/buffer. Valid values are letters (lower/upper), digits (1-9), or read-only buffers ( . % : ).

func (*Buffers) Write

func (reg *Buffers) Write(content ...rune)

Write writes a slice to the currently active buffer, and/or to the kill one. After the operation, the buffers are reset, eg. none is considered active.

func (*Buffers) WriteTo

func (reg *Buffers) WriteTo(register rune, content ...rune)

WriteTo writes a slice directly to a target register. If the register name is invalid, nothing is written anywhere.

Jump to

Keyboard shortcuts

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