vidar: Index | Files

package bind

import ""

Package bind contains some of the types that the commander package uses to identify types to bind to user input or other events. It is kept in a separate package so that functions and methods can use these types in their signature without importing the commander package. The intent is to allow plugins to continue to work without the need to rebuild them every time the commander package changes.

For more information, see vidar's plugin package documentation.


Package Files


type Bindable Uses

type Bindable interface {
    // Name returns the name of the Bindable.  It must be unique.
    Name() string

A Bindable is the base type for all types that can be bound to events.

type Command Uses

type Command interface {

    // Menu returns the name of the menu that the command should be
    // displayed under.  All user-executed Bindings *must* have an
    // entry in the menu to make them more discoverable.
    Menu() string

    // Defaults returns the default bindings for this command.
    // Bindings may be arbitrary Stringer types.  Commands that
    // want to support bindings for multiple input.Handler types
    // may provide bindings in multiple formats.
    Defaults() []fmt.Stringer

A Command is a binding that happens due to the user explicitly requesting an event, usually via a key binding.

type HookedMultiOp Uses

type HookedMultiOp interface {

    // Bind is equivalent to HookedOp.Bind, but with different
    // return values.
    Bind(Bindable) (HookedMultiOp, error)

HookedMultiOp is to MultiOp as HookedOp is to Op.

type HookedOp Uses

type HookedOp interface {

    // Bind will be called for each Bindable that wants to bind to
    // events on the HookedOp.  A new HookedOp should be returned
    // with the Bindable bound to it, so that the original HookedOp
    // may continue to execute without the Bindable.
    Bind(Bindable) (HookedOp, error)

HookedOp is an Op that allows Bindables to bind to events that are created by it.

type MultiOp Uses

type MultiOp interface {

    // Reset must be implemented to reset the MultiExecutor's state

    // Store is called in the same way that Op.Exec is called;
    // once for each type in vidar's state.  Values may be
    // stored by the MultiOp to prepare for the final Exec
    // call.
    Store(interface{}) Status

    // Exec is called after Store has finished.  The return value
    // is a simple error because there are only two states it can
    // be in after running - success or failure.  There is no
    // "waiting" state for a MultiOp's Exec method.
    Exec() error

A MultiOp is a type that makes it easier to execute using multiple types in the editor hierarchy. The MultiOp can gather types that it needs before Exec is called.

type MultiOpHook Uses

type MultiOpHook interface {

    // OpNames returns the names of all bindings that this hook
    // wants to bind to.
    OpNames() []string

A MultiOpHook is a binding that is bound to multiple Ops. It is effectively the same as an OpHook, otherwise.

type Op Uses

type Op interface {

    // Exec executes the op.  It will be called once for each
    // element in the editor, including all other Bindables, and
    // should return a status indicating its state after executing
    // against elem.
    // A status that contains the Stop bit will mean that Exec
    // will not be called again.
    Exec(elem interface{}) Status

Op is a type that can execute an operation.

type OpHook Uses

type OpHook interface {

    // OpName returns the name of the binding that this hook
    // wants to bind to.
    OpName() string

An OpHook is a binding that is bound to an Op. It is up to the OpHook to ensure that it implements the interface required by the Op it is being bound to..

type Status Uses

type Status int
const (
    // Waiting means that the Executor is still waiting for types
    // that it *must* execute against.
    Waiting Status = 1 << iota

    // Executed means that the Executor has successfully executed.

    // Errored means that a required process in the Executor has
    // failed.

    // Stop means that the Executor should stop executing.  It does
    // not mean that there was a success or failure, but that there
    // is nothing more to do.

    // Executing means that the Executor has performed all required
    // operations, but there may be extra operations to perform.
    // This is most useful when an Executor *may* have more than
    // one type to execute against, but it only *needs* to execute
    // once.
    Executing = Executed | Waiting

    // Done means that the Executor has successfully performed
    // everything it wanted to perform and is finished.
    Done = Executed | Stop

    // Failed means that the Executor has errored and cannot perform
    // any additional tasks.
    Failed = Errored | Stop

Package bind imports 1 packages (graph) and is imported by 26 packages. Updated 2017-12-02. Refresh now. Tools for package owners.