Documentation
¶
Overview ¶
Package ui implements podbit's main UI and front end user code.
This package runs mostly in a separate UI thread and is as thread-safe as possible.
Due to limitations in the C library ncurses, the render loop is designed to only let one thread use ncurses callbacks at a time, with as little loss in performance as possible. Threads will wait for the time to redraw using channels and modes. Usually, three separate threads will run at a time: the menu thread, tray thread and main thread. These all interact using the aforementioned channels to draw the screen in sync.
The "redraw" chanel is the main channel around which the UI code revolves. It is an integer channel which receives a "mode". This mode allows you to select which part of the UI to redraw. This *can* be all of them. The UI threads wait around for the redraw channel to instruct them as to when they should draw the screen.
The "exit" channel simply instructs us to exit immediately. This should *NEVER* be used inside a render callback, least a deadlock in the UI code be caused.
Index ¶
- Constants
- Variables
- func ActivateMenu(newMenu Menu)
- func Exit()
- func InitUI(scr *goncurses.Window, initialMenu Menu, hndl *ev.Handler, k chan rune, ...)
- func InputLoop(exit chan struct{})
- func PassKeystroke(c rune)
- func RenderLoop()
- func RenderTray(scr *goncurses.Window, w, h int)
- func StatusMessage(msg string)
- func UpdateDimensions(scr *goncurses.Window)
- type Downloads
- type Library
- func (l *Library) ChangeSelection(index int)
- func (l *Library) Input(c rune)
- func (l *Library) MoveSelection(direction int)
- func (l *Library) Name() string
- func (l *Library) Render(x, y int)
- func (l *Library) Should(event int) bool
- func (l *Library) StartDownload()
- func (l *Library) StartPlaying(immediate bool)
- type Menu
- type Player
- type Queue
Constants ¶
const ( // MessageTime is the maximum time a message will show for. MessageTime time.Duration = 2 * time.Second )
Variables ¶
var ( PlayerMenu = new(Player) // Full screen player. QueueMenu = new(Queue) // Player queue display. DownloadMenu = new(Downloads) // Shows ongoing downloads. LibraryMenu = new(Library) // Library of podcasts and episodes. )
Menu singletons.
Functions ¶
func ActivateMenu ¶
func ActivateMenu(newMenu Menu)
ActivateMenu sets the current menu to the requested value. This DOES NOT redraw the screen until manually caused by an event.
func Exit ¶
func Exit()
Exit requests that the input handler shuts down and gracefully exits the program via a return to the main function.
func InitUI ¶
func InitUI(scr *goncurses.Window, initialMenu Menu, hndl *ev.Handler, k chan rune, m chan Menu, r chan int8)
InitUI initialises the UI subsystem.
func InputLoop ¶
func InputLoop(exit chan struct{})
InputLoop - main UI input handler
Receives all key inputs serially, one character at a time If there is no global keybinding for this key, we pass it to the UI subsystem, which can deal with it from there.
Any and all key inputs causes an immediate and full UI redraw.
func PassKeystroke ¶
func PassKeystroke(c rune)
PassKeystroke performs a keystroke passthrough for the active menu.
func RenderLoop ¶
func RenderLoop()
RenderLoop is the main render callback for the program. This is intended to run in its own thread.
func RenderTray ¶
func RenderTray(scr *goncurses.Window, w, h int)
RenderTray renders the statusbar tray at the bottom of the screen. Tray takes up two vertical cells and the entirety of the width. The top cell is a horizontal line denoting a player status bar. The bottom cell is the status text.
func StatusMessage ¶
func StatusMessage(msg string)
StatusMessage sends a status message to the tray.
Will block for the previous message to finish first. Every message can be guaranteed MessageTime display time.
func UpdateDimensions ¶
UpdateDimensions changes the dimensions of the drawable area.
Called automatically on detected terminal resizes by the resizeLoop thread.
Types ¶
type Library ¶
type Library struct {
// contains filtered or unexported fields
}
Library represents the list menu type and state.
Library displays all detected and configured podcasts, along with associated episodes sorted into said podcasts.
func (*Library) ChangeSelection ¶
func (*Library) MoveSelection ¶
func (*Library) StartDownload ¶
func (l *Library) StartDownload()
StartDownload downloads the currently focused library entry.
func (*Library) StartPlaying ¶
StartPlaying begins playing the currently focused element. If the current focus requires downloading (and enough information is known to oblige) it will first be downloaded.
type Menu ¶
A Menu is a renderable UI element which takes up most of primary. screen space and is capable of handling unhandled keybinds.
type Player ¶
type Player struct{}
Player is the full screen player component.
Player displays the currently playing episode, the next up episode, progress through the episode etc.
This is mostly for user convenience and visual appeal.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package components implements re-usable sections of UI which can be used by multiple sections of the program in multiple different ways.
|
Package components implements re-usable sections of UI which can be used by multiple sections of the program in multiple different ways. |