songlist

package
v0.0.0-...-0cbbf0d Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseSonglist

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

func New

func New() (s *BaseSonglist)

func (*BaseSonglist) Add

func (s *BaseSonglist) Add(song *song.Song) error

Add adds a song to the songlist.

func (*BaseSonglist) AddFromAttrlist

func (s *BaseSonglist) AddFromAttrlist(attrlist []mpd.Attrs)

func (*BaseSonglist) AddList

func (s *BaseSonglist) AddList(songlist Songlist) error

AddList appends a songlist to this songlist.

func (*BaseSonglist) Clear

func (s *BaseSonglist) Clear() error

Clear clears the songlist by removing any songs.

func (*BaseSonglist) ClearSelection

func (s *BaseSonglist) ClearSelection()

ClearSelection removes all selection.

func (*BaseSonglist) Columns

func (s *BaseSonglist) Columns(columns []string) Columns

Columns returns a slice of columns, containing only the columns which has the specified tags.

func (*BaseSonglist) CommitVisualSelection

func (s *BaseSonglist) CommitVisualSelection()

CommitVisualSelection converts the visual selection to manual selection.

func (*BaseSonglist) Cursor

func (s *BaseSonglist) Cursor() int

Cursor returns the cursor position.

func (*BaseSonglist) CursorSong

func (s *BaseSonglist) CursorSong() *song.Song

CursorSong returns the song currently selected by the cursor.

func (*BaseSonglist) CursorToSong

func (s *BaseSonglist) CursorToSong(song *song.Song) error

func (*BaseSonglist) Delete

func (s *BaseSonglist) Delete() error

Delete deletes a songlist. This is a placeholder function that should be overridden by other classes that need to trigger an action on the MPD side.

func (*BaseSonglist) DisableVisualSelection

func (s *BaseSonglist) DisableVisualSelection()

DisableVisualSelection disables visual selection.

func (*BaseSonglist) Duplicate

func (s *BaseSonglist) Duplicate(dest Songlist) error

Duplicate makes a copy of the current songlist, and places it in dest.

func (*BaseSonglist) EnableVisualSelection

func (s *BaseSonglist) EnableVisualSelection()

EnableVisualSelection sets start and stop of the visual selection to the cursor position.

func (*BaseSonglist) HasVisualSelection

func (s *BaseSonglist) HasVisualSelection() bool

HasVisualSelection returns true if the songlist is in visual selection mode.

func (*BaseSonglist) InRange

func (s *BaseSonglist) InRange(index int) bool

InRange returns true if the provided index is within songlist range, false otherwise.

func (*BaseSonglist) IndexAtSong

func (s *BaseSonglist) IndexAtSong(i int, song *song.Song) bool

IndexAtSong returns true if the song at the specified index is at a song with the same ID, or the path if the songlist is not a queue.

func (*BaseSonglist) Indices

func (s *BaseSonglist) Indices(indices []int) Songlist

Indices accepts a slice of integers pointing to song positions, returns a new songlist with those songs. Any mismatching integers are ignored.

func (*BaseSonglist) Insert

func (s *BaseSonglist) Insert(song *song.Song, position int) error

Insert inserts a song at the specified position.

func (*BaseSonglist) InsertList

func (s *BaseSonglist) InsertList(list Songlist, position int) error

InsertList inserts the songs in a songlist into this songlist, at a specified position.

func (*BaseSonglist) Len

func (s *BaseSonglist) Len() int

func (*BaseSonglist) Locate

func (s *BaseSonglist) Locate(match *song.Song) (int, error)

func (*BaseSonglist) Lock

func (s *BaseSonglist) Lock()

func (*BaseSonglist) ManuallySelected

func (s *BaseSonglist) ManuallySelected(i int) bool

ManuallySelected returns true if the given song index is selected through manual selection.

func (*BaseSonglist) MoveCursor

func (s *BaseSonglist) MoveCursor(i int)

MoveCursorUp moves the cursor by the specified offset.

func (*BaseSonglist) MoveCursorDown

func (s *BaseSonglist) MoveCursorDown(i int)

MoveCursorUp moves the cursor down by the specified offset.

func (*BaseSonglist) MoveCursorUp

func (s *BaseSonglist) MoveCursorUp(i int)

MoveCursorUp moves the cursor up by the specified offset.

func (*BaseSonglist) Name

func (s *BaseSonglist) Name() string

func (*BaseSonglist) NextOf

func (s *BaseSonglist) NextOf(tags []string, index int, direction int) int

NextOf searches forwards or backwards for songs having different tags than the specified song. The index of the next song is returned.

func (*BaseSonglist) Remove

func (s *BaseSonglist) Remove(index int) error

func (*BaseSonglist) RemoveIndices

func (s *BaseSonglist) RemoveIndices(indices []int) error

RemoveIndices removes a selection of songs from the songlist, having the index defined by the int slice parameter.

func (*BaseSonglist) Replace

func (s *BaseSonglist) Replace(index int, song *song.Song) error

func (*BaseSonglist) Selected

func (s *BaseSonglist) Selected(i int) bool

Selected returns true if the given song index is selected, either through visual selection or manual selection. If the song is doubly selected, the selection is inversed.

func (*BaseSonglist) Selection

func (s *BaseSonglist) Selection() Songlist

Selection returns the current selection as a new Songlist.

func (*BaseSonglist) SelectionIndices

func (s *BaseSonglist) SelectionIndices() []int

SelectionIndices returns a slice of ints holding the position of each element in the current selection. If no elements are selected, the cursor position is returned.

func (*BaseSonglist) SetCursor

func (s *BaseSonglist) SetCursor(i int)

SetCursor sets the cursor to an absolute position.

func (*BaseSonglist) SetName

func (s *BaseSonglist) SetName(name string) error

func (*BaseSonglist) SetSelected

func (s *BaseSonglist) SetSelected(i int, selected bool)

SetSelection sets the selected status of a single song.

func (*BaseSonglist) SetUpdated

func (s *BaseSonglist) SetUpdated()

SetUpdated sets the update timestamp of the songlist.

func (*BaseSonglist) SetVisualSelection

func (s *BaseSonglist) SetVisualSelection(ymin, ymax, ystart int)

SetVisualSelection sets the range of the visual selection. Use negative integers to un-select all visually selected songs.

func (*BaseSonglist) Song

func (s *BaseSonglist) Song(i int) *song.Song

func (*BaseSonglist) Songs

func (s *BaseSonglist) Songs() []*song.Song

func (*BaseSonglist) Sort

func (s *BaseSonglist) Sort(fields []string) error

Sort sorts the songlist by the given tags. The first tag is sorted normally, while the remaining tags are used for stable sorting.

func (*BaseSonglist) ToggleVisualSelection

func (s *BaseSonglist) ToggleVisualSelection()

ToggleVisualSelection toggles visual selection on and off.

func (*BaseSonglist) Truncate

func (s *BaseSonglist) Truncate(length int) error

func (*BaseSonglist) Unlock

func (s *BaseSonglist) Unlock()

func (*BaseSonglist) Updated

func (s *BaseSonglist) Updated() time.Time

Updated returns the timestamp of when this songlist was last updated.

func (*BaseSonglist) ValidateCursor

func (s *BaseSonglist) ValidateCursor(ymin, ymax int)

ValidateCursor makes sure the cursor is within minimum and maximum boundaries.

func (*BaseSonglist) VisualSelection

func (s *BaseSonglist) VisualSelection() (int, int, int)

VisualSelection returns the min, max, and start position of visual select.

func (*BaseSonglist) VisuallySelected

func (s *BaseSonglist) VisuallySelected(i int) bool

VisuallySelected returns true if the given song index is selected through visual selection.

type Collection

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

Collection holds a set of songlists, and keeps track of movement between different lists.

func NewCollection

func NewCollection() *Collection

NewCollection returns Collection.

func (*Collection) Activate

func (c *Collection) Activate(s Songlist)

Activate activates the specified songlist. The songlist is not added to the collection. If the songlist is found in the collection, the index of that songlist is activated.

func (*Collection) ActivateIndex

func (c *Collection) ActivateIndex(i int) error

ActivateIndex activates the songlist pointed to by the specified index.

func (*Collection) Add

func (c *Collection) Add(s Songlist)

Add appends a songlist to the collection.

func (*Collection) Current

func (c *Collection) Current() Songlist

Current returns the active songlist.

func (*Collection) Index

func (c *Collection) Index() (int, error)

Index returns the current list cursor.

func (*Collection) Last

func (c *Collection) Last() Songlist

Last returns the last used songlist.

func (*Collection) Len

func (c *Collection) Len() int

Len returns the songlists count.

func (*Collection) Remove

func (c *Collection) Remove(index int) error

Remove removes a songlist from the collection.

func (*Collection) Replace

func (c *Collection) Replace(s Songlist)

Replace replaces an existing songlist with its new version. Checking is done on a type-level, so this function should not be used for lists where several of the same type is contained within the collection.

func (*Collection) SetUpdated

func (c *Collection) SetUpdated()

SetUpdated sets the update timestamp of the collection.

func (*Collection) Songlist

func (c *Collection) Songlist(index int) (Songlist, error)

func (*Collection) Updated

func (c *Collection) Updated() time.Time

Updated returns the timestamp of when this collection was last updated.

func (*Collection) ValidIndex

func (c *Collection) ValidIndex(i int) bool

func (*Collection) ValidateIndex

func (c *Collection) ValidateIndex(i int) error

type Column

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

func NewColumn

func NewColumn(tag string) *Column

NewColumn returns a new Column.

func (*Column) Add

func (c *Column) Add(song *song.Song)

Add a single song's width to the total and maximum width.

func (*Column) Avg

func (c *Column) Avg() int

Avg returns the average length of the tag values in this column.

func (*Column) MaxWidth

func (c *Column) MaxWidth() int

MaxWidth returns the length of the longest tag value in this column.

func (*Column) Remove

func (c *Column) Remove(song *song.Song)

Remove a single song's tag width from the total and maximum width.

func (*Column) Reset

func (c *Column) Reset()

Reset sets all values to zero.

func (*Column) Set

func (c *Column) Set(s Songlist)

Set calculates all song's widths.

func (*Column) SetWidth

func (c *Column) SetWidth(width int)

SetWidth sets the width that the column should consume.

func (*Column) Tag

func (c *Column) Tag() string

Tag returns the tag name.

func (*Column) Weight

func (c *Column) Weight(max int) float64

Weight returns the relative usefulness of this column. It might happen that a tag appears rarely, but is very long. In this case we reduce the field so that other tags get more space.

func (*Column) Width

func (c *Column) Width() int

Width returns the column width.

type ColumnMap

type ColumnMap map[string]*Column

func (ColumnMap) Add

func (c ColumnMap) Add(song *song.Song)

Add adds song tags to all applicable columns.

func (ColumnMap) Remove

func (c ColumnMap) Remove(song *song.Song)

Remove removes song tags from all applicable columns.

type Columns

type Columns []*Column

func (Columns) Expand

func (columns Columns) Expand(totalWidth int)

expand adjusts the column widths equally between the different columns, giving affinity to weight.

type Library

type Library struct {
	BaseSonglist
	// contains filtered or unexported fields
}

Library is a Songlist which represents the MPD song library.

func NewLibrary

func NewLibrary() (s *Library)

func (*Library) Clear

func (s *Library) Clear() error

func (*Library) CloseIndex

func (s *Library) CloseIndex() error

CloseIndex closes the Bleve search index.

func (*Library) Delete

func (s *Library) Delete() error

func (*Library) HasIndex

func (s *Library) HasIndex() bool

HasIndex returns true if the library has a search index.

func (*Library) IndexSynced

func (s *Library) IndexSynced() bool

IndexSynced returns true if the search index is up to date with the MPD version.

func (*Library) Isolate

func (s *Library) Isolate(songs Songlist, tags []string) (Songlist, error)

Isolate takes a songlist and a set of tag keys, and matches the tag values of the songlist against the search index.

func (*Library) Name

func (s *Library) Name() string

func (*Library) OpenIndex

func (s *Library) OpenIndex(path string) error

OpenIndex configures the library to use the Bleve search index at the specified path.

func (*Library) ReIndex

func (s *Library) ReIndex()

ReIndex starts an asynchronous reindexing job. In case this function is called again before reindexing is done, ReIndex will abort the old reindexing job.

func (*Library) Remove

func (s *Library) Remove(index int) error

func (*Library) RemoveIndices

func (s *Library) RemoveIndices(indices []int) error

func (*Library) Search

func (s *Library) Search(q string) (Songlist, error)

Search does a search in the Bleve index for a specific natural language query string, and returns a new Songlist with the search results.

func (*Library) SetName

func (s *Library) SetName(name string) error

func (*Library) SetVersion

func (s *Library) SetVersion(version int)

SetVersion sets the library version. This is expected to be a UNIX timestamp.

func (*Library) Sort

func (s *Library) Sort(fields []string) error

func (*Library) Version

func (s *Library) Version() int

Version returns the library version.

type Queue

type Queue struct {
	BaseSonglist
	// contains filtered or unexported fields
}

Queue is a Songlist which represents the MPD play queue.

func NewQueue

func NewQueue(mpdClient func() *mpd.Client) (s *Queue)

func (*Queue) Add

func (s *Queue) Add(song *song.Song) error

Add adds a song to MPD's queue.

func (*Queue) AddList

func (s *Queue) AddList(songlist Songlist) error

AddList appends a songlist to the queue.

func (*Queue) Clear

func (s *Queue) Clear() error

func (*Queue) Delete

func (s *Queue) Delete() error

func (*Queue) IndexAtSong

func (q *Queue) IndexAtSong(i int, song *song.Song) bool

IndexAtSong returns true if the song at the specified index is at a song with the same ID.

func (*Queue) Insert

func (s *Queue) Insert(song *song.Song, position int) error

Insert inserts a song at a specified position in the queue.

func (*Queue) InsertList

func (s *Queue) InsertList(list Songlist, position int) error

InsertList inserts the songs in a songlist into the queue, at a specified position.

func (*Queue) Merge

func (q *Queue) Merge(s Songlist) (*Queue, error)

Merge incorporates songs from another songlist, replacing songs that has the same position.

func (*Queue) Name

func (s *Queue) Name() string

func (*Queue) Remove

func (s *Queue) Remove(index int) error

func (*Queue) RemoveIndices

func (s *Queue) RemoveIndices(indices []int) error

RemoveIndices removes a selection of songs from MPD's queue.

func (*Queue) SetName

func (s *Queue) SetName(name string) error

func (*Queue) Sort

func (s *Queue) Sort(fields []string) error

type Songlist

type Songlist interface {
	Add(*song.Song) error
	AddList(Songlist) error
	Clear() error
	Delete() error
	Duplicate(Songlist) error
	Indices([]int) Songlist
	InRange(int) bool
	Insert(*song.Song, int) error
	InsertList(Songlist, int) error
	Len() int
	Locate(*song.Song) (int, error)
	Lock()
	Name() string
	NextOf([]string, int, int) int
	Remove(int) error
	RemoveIndices([]int) error
	Replace(int, *song.Song) error
	SetName(string) error
	Song(int) *song.Song
	Songs() []*song.Song
	Sort([]string) error
	Truncate(int) error
	Unlock()

	ClearSelection()
	Columns([]string) Columns
	CommitVisualSelection()
	Cursor() int
	CursorSong() *song.Song
	CursorToSong(*song.Song) error
	DisableVisualSelection()
	EnableVisualSelection()
	HasVisualSelection() bool
	IndexAtSong(int, *song.Song) bool
	MoveCursor(int)
	Selected(int) bool
	Selection() Songlist
	SelectionIndices() []int
	SetCursor(int)
	SetSelected(int, bool)
	SetUpdated()
	SetVisualSelection(int, int, int)
	ToggleVisualSelection()
	Updated() time.Time
	ValidateCursor(int, int)
}

Jump to

Keyboard shortcuts

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