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, r chan int, k chan rune, m chan Menu)
- func InputLoop(exit chan int)
- func MenuActive(compare Menu) bool
- func PassKeystroke(c rune)
- func Redraw(mode int)
- func RenderLoop()
- func RenderTray(scr *goncurses.Window, w, h int)
- func StatusMessage(msg string)
- func UpdateDimensions(scr *goncurses.Window)
- type Downloads
- type Library
- type Menu
- type Player
- type Queue
Constants ¶
const ( RedrawAll = iota // Redraw everything RedrawMenu // Redraw just the menu RedrawTray // Redraw just the tray RedrawResize // Redraw and recalculate dimensions )
Redraw types
const (
InfoName = iota // Requesting the menu's name
)
Info request types
const ( // MessageTime is the time a message will show for MessageTime time.Duration = 2 * time.Second )
Variables ¶
var ( PlayerMenu *Player = new(Player) // Full screen player QueueMenu *Queue = new(Queue) // Player queue display DownloadMenu *Downloads = new(Downloads) LibraryMenu *Library = 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 and orders a redraw of the menu area This function will block until the new menu is being drawn
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 InputLoop ¶
func InputLoop(exit chan int)
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 MenuActive ¶
MenuActive returns true if the current menu claims to be of the same class as the passed menu
"compare" does not necessarily have to be exactly the same type as the current menu
func PassKeystroke ¶
func PassKeystroke(c rune)
PassKeystroke performs a keystroke passthrough for the active menu
func Redraw ¶
func Redraw(mode int)
Redraw signals to redraw a specific part of the UI
This call *will* block if a redraw is in progress but will not fail
func RenderLoop ¶
func RenderLoop()
RenderLoop is the main render callback for the program This is intended to run in its own thread
func RenderTray ¶
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
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 Downloads ¶ added in v1.1.1
type Downloads struct {
// contains filtered or unexported fields
}
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 {
// contains filtered or unexported fields
}
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
Source Files ¶
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. |