manager

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GlobalComponent = "Global"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component string

type ComponentManager

type ComponentManager struct {
	// contains filtered or unexported fields
}

ComponentManager is a helper to manage different Components and their key handlers, so that only the key handlers of the current component are executed

func NewComponentManager

func NewComponentManager() *ComponentManager

NewComponentManager creates a new ComponentManager

func (*ComponentManager) Broadcast

func (eh *ComponentManager) Broadcast(event EventMsg)

Broadcast sends an event to a specific component

func (*ComponentManager) CurrentComponent

func (eh *ComponentManager) CurrentComponent() Component

CurrentComponent returns the current component

func (*ComponentManager) PopComponent

func (eh *ComponentManager) PopComponent()

PopComponent removes the latest component from the component stack

func (*ComponentManager) PushComponent

func (eh *ComponentManager) PushComponent(component Component, subcomponents ...Component)

PushComponent adds a new component to the component stack

func (*ComponentManager) SendTo

func (eh *ComponentManager) SendTo(component Component, event EventMsg)

BroadcastTo sends an event to a specific component

func (*ComponentManager) Subscribe

func (eh *ComponentManager) Subscribe(component Component) chan EventMsg

Subscribe subscribes to events from a specific component

func (*ComponentManager) Unsubscribe

func (eh *ComponentManager) Unsubscribe(component Component, listener chan EventMsg)

Unsubscribe unsubscribes from events from a specific component

type EventMsg

type EventMsg struct {
	*tcell.EventKey
	Sender  Component
	Message interface{}
}

EventMsg is a wrapper for tcell.EventKey that also contains the sender of the event

type Listener

type Listener struct {
	Component Component
	Channel   chan EventMsg
}

Listener

Jump to

Keyboard shortcuts

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