view

package
v0.0.0-...-96d54e8 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FocusLeft = func(event *tcell.EventKey) bool {
	return event.Key() == tcell.KeyLeft
}
View Source
var FocusRight = func(event *tcell.EventKey) bool {
	return event.Key() == tcell.KeyRight
}
View Source
var SelectItem = func(event *tcell.EventKey) bool {
	return event.Key() == tcell.KeyEnter
}

Functions

func AudioPanelView

func AudioPanelView() *tview.TextView

func EpisodeMenu

func EpisodeMenu() *tview.List

func FeedMenu

func FeedMenu() *tview.List

func MainFlex

func MainFlex() *tview.Flex

func TopRow

func TopRow() *tview.Flex

Types

type APViewController

type APViewController struct {
	PanelStateAwareReceiverController
	// contains filtered or unexported fields
}

APViewController manages the updating of the tview.TextView that shows the current playing episode

func NewAPViewController

func NewAPViewController(lastPlayer *LastPlayer) *APViewController

NewAPViewController initialises the APViewController and provides an interface for dependency injection

func (*APViewController) InputHandler

func (a *APViewController) InputHandler(event *tcell.EventKey) *tcell.EventKey

InputHandler is used here to rerender the view with the updated player state on capture of the 'Play/Pause' control input

func (*APViewController) OnUpdate

func (a *APViewController) OnUpdate()

OnUpdate implements the audiopanel.PlayerStateSubscriber interface

func (*APViewController) Receive

func (a *APViewController) Receive(state domain.State)

Receive updates the internal tracking of the currently playing episode, if it has changed then the view is re-rendered

func (*APViewController) RenderState

func (a *APViewController) RenderState(state audiopanel.PlayerState)

RenderState updates the TextView that the APViewController controls

type BeforeDraw

type BeforeDraw func(_ tcell.Screen) bool

type Control

type Control func(event *tcell.EventKey) bool

Control is the abstraction of a keymapping

var CycleFocus Control = func(event *tcell.EventKey) bool {
	return event.Key() == tcell.KeyTab
}
var PlayPause Control = func(event *tcell.EventKey) bool {
	return event.Key() == tcell.KeyPause || unicode.ToLower(event.Rune()) == 'p'
}

type Controller

type Controller interface {
	InputHandler(event *tcell.EventKey) *tcell.EventKey
}

Controller is the interface for views that are expressed In terms of tview.Primitive implementations. Implementations of this interface must pass their InputHandler method into tview.Primitive.SetInputCapture on initialisation or any controls they define will be ignored

type Controllers

type Controllers struct {
	FeedMenu         *FeedsMenuController
	EpisodeMenu      *EpisodeMenuController
	RootController   *RootController
	APViewController *APViewController
}

Controllers is the declaration of the full set of controllers that must be supplied to the app on Build

type EpisodeMenuController

type EpisodeMenuController struct {
	ReceiverController
	// contains filtered or unexported fields
}

EpisodeMenuController Handles input captured from and updates to be displayed in the episode menu

func NewEpisodeMenuController

func NewEpisodeMenuController(lastPlayer *LastPlayer) *EpisodeMenuController

NewEpisodeMenuController Initialises the EpisodeMenuController

func (*EpisodeMenuController) InputHandler

func (e *EpisodeMenuController) InputHandler(event *tcell.EventKey) *tcell.EventKey

InputHandler implements the user input side of the controller interface

func (*EpisodeMenuController) Receive

func (e *EpisodeMenuController) Receive(state domain.State)

Receive is looking out for changes to the feed index

type FeedsMenuController

type FeedsMenuController struct {
	Controller
	// contains filtered or unexported fields
}

FeedsMenuController manages the feeds menu, it synchronises the current feed with the feed selection in the ui

func NewFeedsController

func NewFeedsController(application *LastPlayer) *FeedsMenuController

NewFeedsController initialises the FeedsMenuController

func (*FeedsMenuController) InputHandler

func (f *FeedsMenuController) InputHandler(event *tcell.EventKey) *tcell.EventKey

InputHandler invokes selectFeed on capturing a tcell.KeyEnter keypress

type LastPlayer

type LastPlayer struct {
	*tview.Application
	Controllers Controllers
	Views       Views
	FocusRing   []tview.Primitive
	State       *domain.State
	AudioPanel  *audiopanel.AudioPanel
	Config      app.Config
	LogFile     *os.File
	// contains filtered or unexported fields
}

LastPlayer extends the tview.Application with our custom functionality

func Build

func Build() *LastPlayer

Build and returns the LastPlayer, implement any additions to the user interface adding new primitives to the lastPlayer hierarchy in this function

func (*LastPlayer) GetLogger

func (lp *LastPlayer) GetLogger(prefix string) *log.Logger

GetLogger can be used to get a log.Logger with the prefix as passed. This can be accessed inside controllers etc.

func (*LastPlayer) Run

func (lp *LastPlayer) Run() error

Run overrides the tview.Application Run method and includes a deferred close of the logfile

type PanelStateAwareController

type PanelStateAwareController interface {
	Controller
	audiopanel.PlayerStateSubscriber
}

PanelStateAwareController is an interface that extends a Controller by requiring an implementation of OnUpdate which is periodically called with the audio panel state

type PanelStateAwareReceiverController

type PanelStateAwareReceiverController interface {
	Controller
	domain.Receiver
	audiopanel.PlayerStateSubscriber
}

PanelStateAwareReceiverController is an interface that combines the functionality of both PanelStateAwareController and ReceiverController

type ReceiverController

type ReceiverController interface {
	Controller
	domain.Receiver
}

ReceiverController is an interface that gives the controller the capability to be notified if the global state changes

type RootController

type RootController struct {
	Controller
	// contains filtered or unexported fields
}

RootController handles global controls

func NewRootController

func NewRootController(lastPlayer *LastPlayer) *RootController

NewRootController initialises the RootController

func (*RootController) InputHandler

func (r *RootController) InputHandler(event *tcell.EventKey) *tcell.EventKey

InputHandler implements the global controls. In some cases the events need to propagate through the hierarchy

type Views

type Views struct {
	Root        *tview.Flex
	TopRow      *tview.Flex
	EpisodeMenu *tview.List
	FeedMenu    *tview.List
	APView      *tview.TextView
}

Views is the declaration of the full set of views that must be supplied to the LastPlayer on Build

Jump to

Keyboard shortcuts

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