eddefs

package
v0.0.0-...-b77b3d7 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2018 License: BSD-2-Clause Imports: 10 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{types.EmptyMap}

Functions

func TestListingProviderFilter

func TestListingProviderFilter(t *testing.T, name string, ls ListingProvider, testcases []ListingProviderFilterTest)

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
	// Daemon returns the daemon client associated with the Editor.
	Daemon() *daemon.Client

	// 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)

	// 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)

	// 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)
}

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.

Jump to

Keyboard shortcuts

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