keyboard

package
v0.0.75 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpStackUpdate EventOp = "op.stackupdate"
	OpSet         EventOp = "op.set"

	ControlAck ControlOp = "control.ack"
)

Variables

This section is empty.

Functions

func Handle

func Handle(ctx context.Context, opts HandleOpts) error

Handle processes user keystroke events and dev workflow updates. Here we also take care on calling `onDone` callback on user exiting.

Types

type Control

type Control struct {
	Operation ControlOp
	AckEvent  struct {
		HandlerID int
		EventID   string
	}
}

type ControlOp

type ControlOp string

type Event

type Event struct {
	HandlerID   int
	EventID     string
	Operation   EventOp
	StackUpdate struct {
		Env         *schema.Environment
		Stack       *schema.Stack
		Focus       []string
		NetworkPlan *storage.NetworkPlan
	}
	Enabled bool
}

type EventOp

type EventOp string

type HandleOpts

type HandleOpts struct {
	Provider    observers.SessionProvider
	Keybindings []Handler
	Handler     func(context.Context) error
}

type Handler

type Handler interface {
	// Key MUST be a pure function. E.g. "l"
	Key() string
	// Label MUST be a pure function. E.g. "stream logs"
	Label(bool) string
	// Must only leave when chan Event is closed. OpSet events must be Acknowledged by writing to Control.
	Handle(context.Context, chan Event, chan<- Control)
}

Jump to

Keyboard shortcuts

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