keyboard

package
v0.0.310 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

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 {
	HandlerID int
	AckEvent  struct {
		EventID string
	}
	SetEnabled *bool
}

type ControlOp

type ControlOp string

type Event

type Event struct {
	EventID      string
	Operation    EventOp
	StackUpdate  *observers.StackUpdateEvent
	CurrentState string
}

type EventOp

type EventOp string
const (
	OpStackUpdate EventOp = "op.stackupdate"
	OpSet         EventOp = "op.set"
)

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
	// Must only leave when chan Event is closed. OpSet events must be Acknowledged by writing to Control.
	Handle(context.Context, chan Event, chan<- Control)

	// The first state is the initial state as well.
	States() []HandlerState
}

type HandlerState added in v0.0.81

type HandlerState struct {
	State string
	Label string
}

Jump to

Keyboard shortcuts

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