list

package
v0.0.0-...-40e63e7 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// one for each data type
	DataTypeFIXME      DataType = "FIXME"
	DataTypeWindow              = "window"
	DataTypeList                = "list"
	DataTypeLogLine             = "logline"
	DataTypeKeyBinding          = "keybinding"
	DataTypeTrack               = "track"
	DataTypeDevice              = "device"
	DataTypeAlbum               = "album"
	DataTypePlaylist            = "playlist"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

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

func New

func New() *Base

func (*Base) Add

func (s *Base) Add(row Row)

func (*Base) All

func (s *Base) All() []Row

func (*Base) Clear

func (s *Base) Clear()

func (*Base) ClearSelection

func (s *Base) ClearSelection()

ClearSelection removes all selection.

func (*Base) ColumnNames

func (s *Base) ColumnNames() []string

func (*Base) Columns

func (s *Base) Columns(names []string) []Column

func (*Base) CommitVisualSelection

func (s *Base) CommitVisualSelection()

CommitVisualSelection converts the visual selection to manual selection.

func (*Base) Copy

func (s *Base) Copy() List

Return a new list that contains all the rows of this list.

func (*Base) Cursor

func (s *Base) Cursor() int

Cursor returns the cursor position.

func (*Base) CursorRow

func (s *Base) CursorRow() Row

func (*Base) DisableVisualSelection

func (s *Base) DisableVisualSelection()

DisableVisualSelection disables visual selection.

func (*Base) EnableVisualSelection

func (s *Base) EnableVisualSelection()

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

func (*Base) HasLocalChanges

func (s *Base) HasLocalChanges() bool

Returns true if the tracklist has local changes that are not synced remotely.

func (*Base) HasRemote

func (s *Base) HasRemote() bool

Returns true if the tracklist represents a remote playlist.

func (*Base) HasVisualSelection

func (s *Base) HasVisualSelection() bool

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

func (*Base) ID

func (s *Base) ID() string

func (*Base) IDs

func (s *Base) IDs() []string

func (*Base) InRange

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

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

func (*Base) InsertList

func (s *Base) InsertList(source List, position int) error

func (*Base) Keys

func (s *Base) Keys() []string

func (*Base) Len

func (s *Base) Len() int

func (*Base) Less

func (s *Base) Less(i, j int) bool

Implements sort.Interface

func (*Base) Lock

func (s *Base) Lock()

func (*Base) ManuallySelected

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

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

func (*Base) MoveCursor

func (s *Base) MoveCursor(i int)

MoveCursor moves the cursor by the specified offset.

func (*Base) Name

func (s *Base) Name() string

func (*Base) NextOf

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

NextOf searches forwards or backwards for rows having different values in the specified tags. The index of the next song is returned.

func (*Base) Remove

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

func (*Base) RemoveIndices

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

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

func (*Base) Row

func (s *Base) Row(n int) Row

func (*Base) RowByID

func (s *Base) RowByID(id string) Row

func (*Base) RowNum

func (s *Base) RowNum(id string) (int, error)

func (*Base) Selected

func (s *Base) 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 (*Base) Selection

func (s *Base) Selection() List

Selection returns selected rows as a new list.

func (*Base) SelectionIndices

func (s *Base) 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 (*Base) SetCursor

func (s *Base) SetCursor(i int)

SetCursor sets the cursor to an absolute position.

func (*Base) SetCursorByID

func (s *Base) SetCursorByID(id string) error

SetCursor moves the cursor to the row with the specified ID.

func (*Base) SetID

func (s *Base) SetID(id string)

func (*Base) SetName

func (s *Base) SetName(name string)

func (*Base) SetRemote

func (s *Base) SetRemote(remote bool)

Declare that this tracklist represents a server-side playlist, enabling it to be saved back to the Spotify servers. The playlist ID is the same as the list ID.

func (*Base) SetSelected

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

SetSelection sets the selected status of a single song.

func (*Base) SetSyncedToRemote

func (s *Base) SetSyncedToRemote()

Use this function to indicate that the local and remote copies are in sync.

func (*Base) SetURI

func (s *Base) SetURI(uri spotify.URI)

func (*Base) SetUpdated

func (s *Base) SetUpdated()

SetUpdated sets the update timestamp of the songlist.

func (*Base) SetVisibleColumns

func (s *Base) SetVisibleColumns(names []string)

func (*Base) SetVisualSelection

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

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

func (*Base) Sort

func (s *Base) Sort(cols []string) error

Sort first sorts unstable, then stable, by all columns provided. Retains cursor position.

func (*Base) Swap

func (s *Base) Swap(i, j int)

Implements sort.Interface

func (*Base) ToggleVisualSelection

func (s *Base) ToggleVisualSelection()

ToggleVisualSelection toggles visual selection on and off.

func (*Base) URI

func (s *Base) URI() *spotify.URI

func (*Base) Unlock

func (s *Base) Unlock()

func (*Base) Updated

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

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

func (*Base) ValidateCursor

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

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

func (*Base) VisibleColumns

func (s *Base) VisibleColumns() []string

func (*Base) VisualSelection

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

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

func (*Base) VisuallySelected

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

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

type BaseRow

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

func NewRow

func NewRow(id string, kind DataType, fields map[string]string) *BaseRow

func (*BaseRow) Fields

func (row *BaseRow) Fields() map[string]string

func (*BaseRow) Get

func (row *BaseRow) Get(key string) string

func (*BaseRow) ID

func (row *BaseRow) ID() string

func (*BaseRow) Keys

func (row *BaseRow) Keys() []string

func (*BaseRow) Kind

func (row *BaseRow) Kind() DataType

func (*BaseRow) Set

func (row *BaseRow) Set(key, value string)

func (*BaseRow) SetFields

func (row *BaseRow) SetFields(fields map[string]string)

func (*BaseRow) SetID

func (row *BaseRow) SetID(id string)

func (*BaseRow) URI

func (row *BaseRow) URI() spotify.URI

type Collection

type Collection struct {
	Base
}

type Column

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

func (*Column) Add

func (c *Column) Add(item string)

func (*Column) Avg

func (c *Column) Avg() int

func (*Column) Max

func (c *Column) Max() int

func (*Column) Median

func (c *Column) Median() int

func (*Column) Remove

func (c *Column) Remove(item string)

func (*Column) Set

func (c *Column) Set(items []string)

type Cursor

type Cursor interface {
	Cursor() int
	CursorRow() Row
	MoveCursor(int)
	SetCursor(int)
	SetCursorByID(string) error
	ValidateCursor(int, int)
}

type DataType

type DataType string

type Item

type Item interface {
	Len() int
}

type List

type List interface {
	Cursor
	Metadata
	Selectable
	Remote
	Add(Row)
	All() []Row
	Clear()
	Copy() List
	IDs() []string
	InRange(int) bool
	InsertList(source List, position int) error
	Keys() []string
	Len() int
	Lock()
	NextOf([]string, int, int) int
	RemoveIndices(indices []int) error
	Row(int) Row
	RowByID(string) Row
	RowNum(string) (int, error)
	SetUpdated()
	Sort([]string) error
	Unlock()
	Updated() time.Time
}

type Metadata

type Metadata interface {
	ColumnNames() []string
	Columns([]string) []Column
	ID() string
	Name() string
	SetID(string)
	SetName(string)
	SetVisibleColumns([]string)
	VisibleColumns() []string
}

type Remote

type Remote interface {
	SetRemote(remote bool)
	HasRemote() bool
	HasLocalChanges() bool
	SetSyncedToRemote()
	URI() *spotify.URI
	SetURI(uri spotify.URI)
}

type Row

type Row interface {
	// Unique identifier of the data in the row.
	ID() string

	SetID(string)

	// Return a Spotify URI pointing to the track. device, album or playlist this row represents.
	URI() spotify.URI

	// Return the dataset.
	Fields() map[string]string

	SetFields(map[string]string)

	// Return the keys of the data.
	Keys() []string

	// Indicates what kind of data this row represents.
	Kind() DataType

	// Set a value in the dataset.
	Set(key, value string)

	// Get a value from the dataset.
	Get(key string) string
}

type Selectable

type Selectable interface {
	ClearSelection()
	CommitVisualSelection()
	DisableVisualSelection()
	EnableVisualSelection()
	HasVisualSelection() bool
	Selected(int) bool
	Selection() List
	SelectionIndices() []int
	SetSelected(int, bool)
	SetVisualSelection(int, int, int)
	ToggleVisualSelection()
}

Jump to

Keyboard shortcuts

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