eddefs

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2018 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package eddefs contains types used in the Editor. It is separate package so that editor plugins do not need to depend on the edit package.

Index

Constants

This section is empty.

Variables

View Source
var EmptyBindingMap = BindingMap{vals.EmptyMap}

Functions

func TestListingProviderFilter

func TestListingProviderFilter(name string, ls ListingProvider, testcases []ListingProviderFilterTest) error

Types

type Action

type Action int

Action is used in the SetAction method of the Editor to schedule a special Action after a keybinding has been executed.

const (
	NoAction Action = iota
	// ReprocessKey makes the editor to reprocess the keybinding.
	ReprocessKey
	// CommitLine makes the editor return with the current line.
	CommitLine
	// CommitEOF makes the editor return with an EOF.
	CommitEOF
)

type BindingMap

type BindingMap struct {
	hashmap.Map
}

BindingMap is a special Map that converts its key to ui.Key and ensures that its values satisfy eval.CallableValue.

func MakeBindingMap

func MakeBindingMap(raw hashmap.Map) (BindingMap, error)

func (BindingMap) Assoc

func (bt BindingMap) Assoc(k, v interface{}) (interface{}, error)

Assoc converts the index to ui.Key, ensures that the value is CallableValue, uses the Assoc of the inner Map and converts the result to a BindingTable.

func (BindingMap) Dissoc

func (bt BindingMap) Dissoc(k interface{}) interface{}

Dissoc converts the key to ui.Key and calls the Dissoc method of the inner map.

func (BindingMap) GetKey

func (bt BindingMap) GetKey(k ui.Key) eval.Callable

func (BindingMap) GetOrDefault

func (bt BindingMap) GetOrDefault(k ui.Key) eval.Callable

func (BindingMap) HasKey

func (bt BindingMap) HasKey(k interface{}) bool

func (BindingMap) Index

func (bt BindingMap) Index(index interface{}) (interface{}, error)

Index converts the index to ui.Key and uses the Index of the inner Map.

func (BindingMap) Repr

func (bt BindingMap) Repr(indent int) string

Repr returns the representation of the binding table as if it were an ordinary map keyed by strings.

type Editor

type Editor interface {
	// ReadLine reads a line interactively.
	ReadLine() (string, error)
	// Close releases resources used by the editor.
	Close()

	// Evaler returns the Evaler associated with the Editor.
	Evaler() *eval.Evaler

	// Buffer returns the current content and dot position of the buffer.
	Buffer() (string, int)
	// SetBuffer sets the current content and dot position of the buffer.
	SetBuffer(buffer string, dot int)
	// ParsedBuffer returns the node from parsing the buffer.
	ParsedBuffer() *parse.Chunk
	// InsertAtDot inserts text at the dot and moves the dot after it.
	InsertAtDot(text string)

	// SetPrompt sets the prompt of the editor.
	SetPrompt(prompt Prompt)
	// SetPrompt sets the rprompt of the editor.
	SetRPrompt(rprompt Prompt)

	// SetMode sets the current mode of the Editor.
	SetMode(m Mode)
	// SetModeInsert sets the current mode of the Editor to insert mode.
	SetModeInsert()
	// SetModeListing sets the current mode of the Editor to listing mode with
	// the supplied binding and provider.
	SetModeListing(b BindingMap, p ListingProvider)
	// RefreshListing refreshes the listing mode, recalculating the listing
	// items. It is useful when the underlying listing provider has been
	// changed. If the editor is not in listing mode, it does nothing.
	RefreshListing()

	// AddTip adds a message to the tip area.
	AddTip(format string, args ...interface{})
	// Notify writes out a message in a way that does not interrupt the editor
	// display. When the editor is not active, it simply writes the message to
	// the terminal. When the editor is active, it appends the message to the
	// notification queue, which will be written out during the update cycle. It
	// can be safely used concurrently.
	Notify(format string, args ...interface{})

	// LastKey returns the last key received from the user. It is useful mainly
	// in keybindings.
	LastKey() ui.Key

	// SetAction sets the action to execute after the key binding has finished.
	SetAction(a Action)

	// AddAfterReadline adds a hook function that runs after readline ends.
	AddAfterReadline(func(string))
}

Editor is the interface for the Elvish line editor.

type ListingProvider

type ListingProvider interface {
	Len() int
	Show(i int) (string, ui.Styled)
	Filter(filter string) int
	Accept(i int, ed Editor)
	ModeTitle(int) string
}

type ListingProviderFilterTest

type ListingProviderFilterTest struct {
	Filter     string
	WantShowns []ListingShown
}

type ListingShown

type ListingShown struct {
	Header  string
	Content ui.Styled
}

type Mode

type Mode interface {
	ModeLine() ui.Renderer
	Binding(ui.Key) eval.Callable
	Teardown()
}

Mode is an editor mode.

type Prompt

type Prompt interface {
	// Chan returns a prompt on which the content of the prompt is made
	// available.
	Chan() <-chan []*ui.Styled
	// Update signifies that the prompt should be updated.
	Update(force bool)
	// Last returns the last content written to Chan. If Chan was never written,
	// it should return some content representing an unknown prompt.
	Last() []*ui.Styled
	// Close releases resources associated with the prompt.
	Close() error
}

Prompt is the interface for a general prompt.

Jump to

Keyboard shortcuts

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