Documentation
¶
Index ¶
- Constants
- func Clock(d time.Duration) string
- func DrawDeck(s tcell.Screen, r Rect, st DeckState)
- func DrawHelp(s tcell.Screen, r Rect)
- func DrawTooSmall(s tcell.Screen, w, h int)
- func Fit(text string, width int) string
- func Marquee(text string, width, tick int) string
- func PutStr(s tcell.Screen, x, y int, text string, style tcell.Style) int
- func SaveNotice(name string, saved []library.Saved, err error, serverName func(string) string) string
- func SeekBarHit(r Rect, x int) float64
- type Action
- type Analyzer
- type App
- func (a *App) Draw()
- func (a *App) Handle(ev tcell.Event) bool
- func (a *App) Notify(msg string)
- func (a *App) Run(ctx context.Context) error
- func (a *App) SetAfterglow(on bool)
- func (a *App) SetBroadcaster(b Broadcaster)
- func (a *App) SetNights(n Nights)
- func (a *App) SetSaver(s Saver)
- func (a *App) SetSwitcher(sw Switcher)
- func (a *App) SetVisual(name string)
- type Broadcaster
- type Browser
- func (b *Browser) AlbumContext() ([]library.Track, bool)
- func (b *Browser) AlbumTracks(ctx context.Context, a library.Album) ([]library.Track, error)
- func (b *Browser) Back(ctx context.Context) bool
- func (b *Browser) CancelPicker()
- func (b *Browser) CurrentServerName() string
- func (b *Browser) Home(context.Context) bool
- func (b *Browser) InPicker() (*picker, bool)
- func (b *Browser) JumpLetter(ctx context.Context, r rune) bool
- func (b *Browser) List() *List
- func (b *Browser) LoadRecent(ctx context.Context) error
- func (b *Browser) LoadRoot(context.Context) error
- func (b *Browser) OpenAlbum(ctx context.Context, a library.Album) error
- func (b *Browser) OpenArtist(ctx context.Context, a library.Artist) error
- func (b *Browser) OpenArtists(ctx context.Context) error
- func (b *Browser) OpenNight(ctx context.Context, guild string) error
- func (b *Browser) OpenNights(ctx context.Context) error
- func (b *Browser) OpenPicker(ctx context.Context, tracks []library.Track, exclude string) error
- func (b *Browser) OpenPlaylist(ctx context.Context, p library.Playlist) error
- func (b *Browser) OpenPlaylists(ctx context.Context) error
- func (b *Browser) OpenServers(context.Context) error
- func (b *Browser) PlaylistDeleted(ctx context.Context, id string)
- func (b *Browser) PlaylistRenamed(ctx context.Context, id, name string)
- func (b *Browser) PlaylistTracks(ctx context.Context, p library.Playlist) ([]library.Track, error)
- func (b *Browser) PlaylistView() (*library.Playlist, int, bool)
- func (b *Browser) Prepare(ctx context.Context, h int)
- func (b *Browser) RefreshPlaylist(ctx context.Context, sel int) error
- func (b *Browser) RefreshRoot(ctx context.Context)
- func (b *Browser) ReloadPlaylists(ctx context.Context)
- func (b *Browser) Search(ctx context.Context, q string) error
- func (b *Browser) SetNights(n Nights)
- func (b *Browser) SetSwitcher(sw Switcher)
- func (b *Browser) SwitchServer(ctx context.Context, id string) bool
- func (b *Browser) TargetPlaylist() (*library.Playlist, bool)
- func (b *Browser) Title() string
- type DeckState
- type Layout
- type List
- type Mode
- type Nights
- type Rect
- type Row
- type Saver
- type SearchField
- type SpectrumSource
- type Switcher
Constants ¶
const ( MenuArtists = "artists" MenuRecent = "recent" MenuPlaylists = "playlists" MenuServers = "servers" MenuNights = "nights" )
const (
MinW, MinH = 80, 24
)
Variables ¶
This section is empty.
Functions ¶
func DrawTooSmall ¶
func Fit ¶
Fit cuts or pads text to exactly width cells. A wide glyph that would straddle the cut is replaced by a space.
func Marquee ¶
Marquee returns a width-cell window onto text. Text that fits is padded; longer text scrolls one grapheme every 4 ticks with a gap before it repeats.
func PutStr ¶
PutStr writes text at x,y one grapheme cluster at a time, advancing by each cluster's display width, and returns the cells used. It does not clip; callers pass text already cut to width (see Fit).
func SaveNotice ¶ added in v0.17.0
func SaveNotice(name string, saved []library.Saved, err error, serverName func(string) string) string
SaveNotice is saveNotice for callers outside the package, such as the Discord night save.
func SeekBarHit ¶
SeekBarHit maps a click at column x on the seek row to a fraction of the track, or -1 if the click is outside the bar.
Types ¶
type Action ¶
type Action int
const ( ActNone Action = iota ActQuit ActTogglePause ActNext ActPrev ActSeekBack ActSeekFwd ActVolUp ActVolDown ActTab ActSearch ActEnter ActAppend ActBack ActShuffle ActRepeat ActHelp ActUp ActDown ActPageUp ActPageDown ActEscape ActVisual ActSave ActClear ActRemove ActToPlaylist ActMoveUp ActMoveDown ActRename ActDelete ActBroadcast )
type Analyzer ¶
type Analyzer struct {
// Afterglow keeps the scope's previous trace on screen one frame longer, dim, like phosphor.
Afterglow bool
// contains filtered or unexported fields
}
func NewAnalyzer ¶
func NewAnalyzer(src SpectrumSource) *Analyzer
type App ¶
type App struct {
// OnVisual is told the new mode's name when v changes it, to persist it.
OnVisual func(name string)
// contains filtered or unexported fields
}
func (*App) SetAfterglow ¶ added in v0.14.0
SetAfterglow turns the oscilloscope's phosphor-style ghost on or off.
func (*App) SetBroadcaster ¶ added in v0.16.0
func (a *App) SetBroadcaster(b Broadcaster)
SetBroadcaster enables b; nil leaves b explaining how to set Discord up.
func (*App) SetNights ¶ added in v0.17.0
SetNights enables the Library's Nights menu over the Discord play history.
func (*App) SetSwitcher ¶
SetSwitcher enables the Servers menu for a multi-server library.
type Broadcaster ¶ added in v0.16.0
Broadcaster streams the player into a Discord voice channel.
type Browser ¶
type Browser struct {
// contains filtered or unexported fields
}
Browser is the Library tab: a stack of views, each a title and a row set. The root is a small menu; Artists is an index of every artist that loads a page at a time as the selection moves.
func NewBrowser ¶
func (*Browser) AlbumContext ¶
AlbumContext returns the album's tracks when the current view is an album.
func (*Browser) AlbumTracks ¶
AlbumTracks is what `a` on an album appends: the same call the view uses.
func (*Browser) CancelPicker ¶ added in v0.10.0
func (b *Browser) CancelPicker()
CancelPicker pops the picker if it is open.
func (*Browser) CurrentServerName ¶
CurrentServerName is shown in the tab row; empty with a single server.
func (*Browser) Home ¶ added in v0.9.3
Home drops every view above the root menu. It reports whether anything was open.
func (*Browser) InPicker ¶ added in v0.10.0
InPicker reports whether the open view is the picker and returns its payload.
func (*Browser) JumpLetter ¶
JumpLetter moves the selection to the first artist under r in the Artists view. It reports whether a jump happened.
func (*Browser) OpenArtist ¶
func (*Browser) OpenArtists ¶
OpenArtists opens the index: one row per artist, with only the first page fetched. Rows past it are placeholders until Prepare reaches them.
func (*Browser) OpenNight ¶ added in v0.17.0
OpenNight shows a server's most-played tracks as a playable list.
func (*Browser) OpenNights ¶ added in v0.17.0
OpenNights lists the servers with history, newest first.
func (*Browser) OpenPicker ¶ added in v0.10.0
OpenPicker pushes a list of the playlists on the tracks' server. It returns errNoPlaylists, pushing nothing, when there are none to offer.
func (*Browser) OpenPlaylist ¶ added in v0.9.0
OpenPlaylist pushes a playlist's tracks. It carries them as an album view does, so Enter on a track plays the playlist from there.
func (*Browser) OpenPlaylists ¶ added in v0.9.0
func (*Browser) OpenServers ¶
OpenServers lists the account's servers with the current one marked.
func (*Browser) PlaylistDeleted ¶ added in v0.15.0
PlaylistDeleted drops the playlist from the screen: pops its view if it is open, reloads the Playlists list, and removes its rows elsewhere.
func (*Browser) PlaylistRenamed ¶ added in v0.15.0
PlaylistRenamed updates what is on screen after a rename: the open view's title and header, rows that show the playlist, and the Playlists list if it is open.
func (*Browser) PlaylistTracks ¶ added in v0.9.0
PlaylistTracks is what `a` on a playlist row appends: the same call the view uses.
func (*Browser) PlaylistView ¶ added in v0.10.0
PlaylistView returns the open playlist and the selected entry's position (rows minus the header), or false when the open view is not a playlist.
func (*Browser) RefreshPlaylist ¶ added in v0.10.0
RefreshPlaylist re-fetches the open playlist view and selects position sel, clamped to the rows that came back. A failed fetch leaves the view untouched.
func (*Browser) RefreshRoot ¶
RefreshRoot rebuilds the root menu when the number of servers has changed since it was built, which happens as background connections finish. It does nothing when a deeper view is open.
func (*Browser) ReloadPlaylists ¶ added in v0.9.0
ReloadPlaylists refetches the list when it is the open view, keeping the selection, so a playlist saved a moment ago appears. Deeper views are left alone.
func (*Browser) SetSwitcher ¶
SetSwitcher enables the Servers menu and names servers in search results.
func (*Browser) SwitchServer ¶
SwitchServer makes id the current server for browsing and returns to the root menu. It reports whether the switch happened.
func (*Browser) TargetPlaylist ¶ added in v0.15.0
TargetPlaylist is the playlist a rename or delete acts on: the open playlist view, else the selected playlist row.
type Mode ¶ added in v0.3.0
type Mode int
Mode selects what the analyzer pane draws from the tap.
type Nights ¶ added in v0.17.0
type Nights interface {
Nights() ([]history.Night, error)
GuildName(id string) string
Night(ctx context.Context, guild string) (name string, tracks []library.Track, skipped int, err error)
}
OpenPlaylists pushes the list of every server's playlists. Nights is the Discord play history as the Library shows it.
type Row ¶
type Row struct {
Text, Right string
Header bool
Menu string // a root menu entry: MenuArtists, MenuRecent or MenuServers
ServerID string // a server row in the Servers view
Album *library.Album
Track *library.Track
Artist *library.Artist
Playlist *library.Playlist
Night string // guild ID of a row in the Nights menu
Playing bool
// contains filtered or unexported fields
}
func QueueRows ¶
QueueRows lists the queue; name, when given, is who asked for row i and shows before the duration.
func RequestRows ¶ added in v0.17.0
RequestRows is the read-only Requests section under the queue: who is waiting, how many songs, and their next one. Nil when nobody is waiting.
type Saver ¶ added in v0.9.0
type Saver interface {
SaveQueue(ctx context.Context, name string, tracks []library.Track) ([]library.Saved, error)
}
Saver saves a queue to the servers its tracks live on.