ui

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: Apache-2.0 Imports: 23 Imported by: 4

Documentation

Index

Constants

View Source
const DefaultBPM = 123

DefaultBPM is a sane default of 123 beats per minute.

View Source
const FramesPerBeat = 10

FramesPerBeat determines the granularity that the spinner's animation timing for each beat, i.e. 10 for tenths of a second.

Variables

View Source
var FadeFrames = [FramesPerBeat]string{
	0: "█",
	1: "█",
	2: "▓",
	3: "▓",
	4: "▒",
	5: "▒",
	6: "░",
	7: "░",
	8: " ",
	9: " ",
}
View Source
var Keys = KeyMap{
	Help: key.NewBinding(
		key.WithKeys("?"),
		key.WithHelp("?", "help"),
	),
	Quit: key.NewBinding(
		key.WithKeys("q", "esc", "ctrl+c"),
		key.WithHelp("q", "quit"),
	),

	Debug: key.NewBinding(
		key.WithKeys("d"),
		key.WithHelp("d", "debug ui"),
	),
	Rave: key.NewBinding(
		key.WithKeys("r"),
		key.WithHelp("r", "rave"),
	),
	EndRave: key.NewBinding(
		key.WithKeys("R"),
		key.WithHelp("R", "end rave"),
	),
	ForwardRave: key.NewBinding(
		key.WithKeys("+", "="),
		key.WithHelp("+/=", "seek forward"),
	),
	BackwardRave: key.NewBinding(
		key.WithKeys("-"),
		key.WithHelp("-", "seek backward"),
	),
	Up: key.NewBinding(
		key.WithKeys("up", "k"),
		key.WithHelp("↑/k", "move up"),
	),
	Down: key.NewBinding(
		key.WithKeys("down", "j"),
		key.WithHelp("↓/j", "move down"),
	),
	Home: key.NewBinding(
		key.WithKeys("home"),
		key.WithHelp("home", "go to top"),
	),
	End: key.NewBinding(
		key.WithKeys("end"),
		key.WithHelp("end", "go to bottom"),
	),
	PageDown: key.NewBinding(
		key.WithKeys("pgdown"),
		key.WithHelp("pgdn", "page down"),
	),
	PageUp: key.NewBinding(
		key.WithKeys("pgup"),
		key.WithHelp("pgup", "page up"),
	),
}
View Source
var MeterFrames = [FramesPerBeat]string{
	0: "█",
	1: "█",
	2: "▇",
	3: "▆",
	4: "▅",
	5: "▄",
	6: "▃",
	7: "▂",
	8: "▁",
	9: " ",
}

Functions

func Frame

func Frame(fps float64) tea.Cmd

Types

type FrameMsg

type FrameMsg time.Time

type Frames

type Frames [FramesPerBeat]string

Frames contains animation frames.

type KeyMap

type KeyMap struct {
	Rave         key.Binding
	EndRave      key.Binding
	ForwardRave  key.Binding
	BackwardRave key.Binding
	Debug        key.Binding
	Help         key.Binding
	Quit         key.Binding

	Up   key.Binding
	Down key.Binding

	Home, End        key.Binding
	PageUp, PageDown key.Binding
}

func (KeyMap) FullHelp

func (k KeyMap) FullHelp() [][]key.Binding

func (KeyMap) ShortHelp

func (k KeyMap) ShortHelp() []key.Binding

type Rave

type Rave struct {
	// Show extra details useful for debugging a desynced rave.
	ShowDetails bool

	// Address (host:port) on which to listen for auth callbacks.
	AuthCallbackAddr string

	// Configuration for syncing with Spotify.
	SpotifyAuth *spotifyauth.Authenticator

	// File path where tokens will be cached.
	SpotifyTokenPath string

	// The animation to display.
	Frames Frames
	// contains filtered or unexported fields
}

func NewRave

func NewRave() *Rave

func (*Rave) Desync

func (m *Rave) Desync() tea.Cmd

func (*Rave) Init

func (rave *Rave) Init() tea.Cmd

func (*Rave) Progress

func (sched *Rave) Progress(now time.Time) (int, float64)

func (*Rave) SpotifyCallbackURL

func (rave *Rave) SpotifyCallbackURL() string

func (*Rave) Sync

func (m *Rave) Sync() tea.Cmd

func (*Rave) Update

func (rave *Rave) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*Rave) View

func (rave *Rave) View() string

func (*Rave) ViewFancy

func (rave *Rave) ViewFancy() string

func (*Rave) ViewFrame

func (rave *Rave) ViewFrame(frames Frames) (string, time.Time, int)

type SetFPSMsg

type SetFPSMsg float64

type Spinner

type Spinner interface {
	tea.Model

	ViewFancy() string
	ViewFrame(Frames) (string, time.Time, int)
}

type Vterm

type Vterm struct {
	Offset int
	Height int
	Width  int

	Prefix string
	// contains filtered or unexported fields
}

func NewVterm

func NewVterm() *Vterm

func (*Vterm) Bytes added in v0.4.1

func (term *Vterm) Bytes(offset, height int) []byte

Bytes returns the output for the given region of the terminal, with ANSI formatting.

func (*Vterm) Init

func (term *Vterm) Init() tea.Cmd

func (*Vterm) Print

func (term *Vterm) Print(w io.Writer) error

Print prints the full log output without any formatting.

func (*Vterm) ScrollPercent

func (term *Vterm) ScrollPercent() float64

func (*Vterm) SetHeight

func (term *Vterm) SetHeight(height int)

func (*Vterm) SetPrefix

func (term *Vterm) SetPrefix(prefix string)

func (*Vterm) SetWidth

func (term *Vterm) SetWidth(width int)

func (*Vterm) Update

func (term *Vterm) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*Vterm) UsedHeight

func (term *Vterm) UsedHeight() int

func (*Vterm) View

func (term *Vterm) View() string

View returns the output for the current region of the terminal, with ANSI formatting.

func (*Vterm) Write

func (term *Vterm) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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