addons

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var All []AddOn

All of add-ons

Functions

func Register

func Register(addOn AddOn)

Register add-on

Types

type AddOn

type AddOn interface {
	Desc() string

	Init(*Envoy)

	Start()

	Stop()

	Schedule()

	State() interface{}

	GetUI() UI
}

AddOn extend this utility with some useful features all add-ons should implements this interface

type ConfirmAware

type ConfirmAware interface {
	// OnEnter handle enter event
	OnEnter()
}

ConfirmAware can handle entry event when active

type DirectionAware

type DirectionAware interface {
	VerticalDirectionAware

	HorizontalDirectionAware
}

DirectionAware can handle all direction event when active

type Envoy

type Envoy struct {
	// Targets is the main targets, namely IP targets
	Targets []*protocol.NetworkTarget

	// Opt is options set when start
	Opt *options.Option

	// Ping provide major ping ability
	Ping *net.NPing
}

Envoy for the ability to communicate with engine and add-ons

type HorizontalDirectionAware

type HorizontalDirectionAware interface {
	// OnLeft handle up event
	OnLeft()

	// OnRight handle up event
	OnRight()
}

HorizontalDirectionAware can handle left/right event when active

type UI

type UI interface {
	// Render represents how the add-on looks like
	Render() *termui.Row

	// Init add-on state
	Init()

	// Activate  this add-on
	Activate()

	// Deactivate this add-on
	Deactivate()

	// ToggleKey activate/deactivate this add-on
	ToggleKey() string

	// RespondEvents declare events can handle
	RespondEvents() []types.EventMeta

	// HandleKeyEvent handle key event
	HandleKeyEvent(ev termui.Event)

	// ActivateAfterStart represents whether this add-on should be activated after startup
	ActivateAfterStart() bool

	// UpdateState update state
	UpdateState(activeTargets map[int]bool)
}

UI out of main board

type VerticalDirectionAware

type VerticalDirectionAware interface {
	// OnUp handle up event
	OnUp()

	// OnDown handle up event
	OnDown()
}

VerticalDirectionAware can handle up/down event when active

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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