cursor

package
v0.0.0-...-a380f54 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2018 License: BSD-2-Clause Imports: 4 Imported by: 2

Documentation

Overview

Package cursor defines types for constructing play cursors.

Index

Constants

View Source
const (
	ActionSet      Action = "set"
	ActionNext            = "next"
	ActionPrevious        = "previous"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string

type Cursor

type Cursor struct {
	sync.Mutex // protects Current, Next and Previous

	Current  Position `json:"current"`
	Next     Position `json:"next"`
	Previous Position `json:"previous"`
	// contains filtered or unexported fields
}

Cursor is a moveable marker on a playlist.

func NewCursor

func NewCursor(p *playlist.Playlist, c index.Collection) *Cursor

NewCursor creates a new Cursor for the playlist.Playlist using the index.Collection as the source of tracks.

func (*Cursor) Backward

func (c *Cursor) Backward() (err error)

Backward moves the cursor backwards. Returns an error if the previous track could not be found, and sets the Previous item to be empty.

func (*Cursor) Forward

func (c *Cursor) Forward() (err error)

Forward moves the cursor forwards. Returns an error if the next track could not be found, and sets the Next item to be empty.

func (*Cursor) Set

func (c *Cursor) Set(i int, p index.Path)

Set sets the value of the playlist cursor to the current position and index.Path.

type Position

type Position struct {
	Path  index.Path `json:"path"`
	Index int        `json:"index"`
}

Position is a type which stores a position in a playlist.

func (Position) Empty

func (p Position) Empty() bool

Empty returns true iff the Position is empty.

type RepAction

type RepAction struct {
	Name   string     `json:"name"`
	Action Action     `json:"action"`
	Path   index.Path `json:"path"`
	Index  int        `json:"index"`
}

func (RepAction) Apply

func (a RepAction) Apply(s Store, ps playlist.Store, collection index.Collection) error

type Store

type Store interface {
	// Get returns the cursor for the given name.
	Get(name string) *Cursor

	// Set sets the cursor for the given name.
	Set(name string, p *Cursor) error

	// Delete removes the cursor with the given name.
	Delete(name string) error
}

Store is an interface which defines methods for implementing a cursor store.

func NewStore

func NewStore(path string) (Store, error)

NewStore creates a basic implementation of a cursor store, using the given path as the source of data. If the file does not exist it will be created.

Jump to

Keyboard shortcuts

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