commander

package
v0.0.0-...-bbcbdef Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: Unlicense Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BeforeExecutor

type BeforeExecutor interface {
	BeforeExec(interface{})
}

A BeforeExecutor is an Executor which has tasks to run prior to running Exec.

type Boundser

type Boundser interface {
	Bounds() math.Rect
}

type ColorSetter

type ColorSetter interface {
	// SetColor is called when a command element is displayed, so
	// that it matches the color theme of the commander.
	SetColor(gxui.Color)
}

ColorSetter is a type that can have its color set.

type Commander

type Commander struct {
	base.Container
	parts.BackgroundBorderPainter
	// contains filtered or unexported fields
}

Commander is a gxui.LinearLayout that takes care of displaying the command utilities around a controller.

func New

func New(driver gxui.Driver, theme *basic.Theme, root gxui.Window, controller Controller) *Commander

New creates and initializes a *Commander, then returns it.

func (*Commander) Bindable

func (c *Commander) Bindable(name string) bind.Bindable

Bindable looks up a bind.Bindable by name

func (*Commander) Binding

func (c *Commander) Binding(binding gxui.KeyboardEvent) bind.Command

Binding finds and returns the Command associated with bind.

func (*Commander) DesiredSize

func (c *Commander) DesiredSize(_, max math.Size) math.Size

func (*Commander) Elements

func (c *Commander) Elements() []interface{}

func (*Commander) Execute

func (c *Commander) Execute(e bind.Bindable)

func (*Commander) InputHandler

func (c *Commander) InputHandler() text.Handler

func (*Commander) KeyPress

func (c *Commander) KeyPress(event gxui.KeyboardEvent) (consume bool)

KeyPress handles key bindings for c.

func (*Commander) KeyStroke

func (c *Commander) KeyStroke(event gxui.KeyStrokeEvent) (consume bool)

func (*Commander) LayoutChildren

func (c *Commander) LayoutChildren()

func (*Commander) Paint

func (c *Commander) Paint(canvas gxui.Canvas)

func (*Commander) Pop

func (c *Commander) Pop() []bind.Bindable

Pop pops the most recent call to Bind, restoring the previous bind.

func (*Commander) Push

func (c *Commander) Push(bindables ...bind.Bindable)

Push binds all bindables to c, pushing the previous binding down in the stack.

type Completer

type Completer interface {
	bind.Command

	// Complete returns whether or not the event signals a completion
	// of the input.
	Complete(gxui.KeyboardEvent) bool
}

Completer is a type that may optionally be implemented by types returned from InputQueue.Next() to decide when they're complete. This allows them to consume enter events as newlines or trigger completeness off of key presses other than enter.

type Controllable

type Controllable interface {
	Controller() *gxui.TextBoxController
}

type Controller

type Controller interface {
	gxui.Control
	Editor() controller.MultiEditor
}

Controller is a type which is used by the Commander to control the main UI.

type Elementer

type Elementer interface {
	Elements() []interface{}
}

Elementer is a type which contains elements of its own.

type InputQueue

type InputQueue interface {
	bind.Command

	// Next returns the next element for reading user input. By
	// default, this is called every time the commander receives a
	// gxui.KeyEnter event in KeyPress.  If there are situations where
	// this is not the desired behavior, the returned gxui.Focusable
	// can consume the gxui.KeyboardEvent.  If the input element has
	// other keyboard events that would trigger completion, it can
	// implement Completer, which will allow it to define when it
	// is complete.
	//
	// Next will continue to be called until it returns nil, at which
	// point the command is assumed to be done.
	Next() gxui.Focusable
}

An InputQueue is a type of Command which needs to read user input.

type Starter

type Starter interface {
	bind.Command

	// Start starts the command.  The element that the command is
	// targeting will be passed in as target.  If the returned
	// status element is non-nil, it will be displayed as an
	// element to display the current status of the command to
	// the user.
	Start(target gxui.Control) (status gxui.Control)
}

A Starter is a type of Command which needs to initialize itself whenever the user wants to run it.

type Statuser

type Statuser interface {
	bind.Bindable

	// Status returns the element to display for the binding's status.
	// The element will be removed after some time.
	Status() gxui.Control
}

A Statuser is a Bindable that needs to display its status after being run. The bindings should use their discretion for status colors, but colors for some common message types are exported by this package to keep things consistent.

Directories

Path Synopsis
Package bind contains some of the types that the commander package uses to identify types to bind to user input or other events.
Package bind contains some of the types that the commander package uses to identify types to bind to user input or other events.
Package control contains types that the commander uses to identify as control flow types.
Package control contains types that the commander uses to identify as control flow types.

Jump to

Keyboard shortcuts

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