ui

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: Apache-2.0 Imports: 24 Imported by: 5

Documentation

Index

Constants

View Source
const DefaultBPM = 123

DefaultBPM is a sane default of 123 beats per minute.

Variables

View Source
var DotFrames = SpinnerFrames{
	[]string{"⣾", "⣷", "⣧", "⣏", "⡟", "⡿", "⢿", "⢻", "⣹", "⣼"},
	ease.Linear,
}
View Source
var FadeFrames = SpinnerFrames{
	[]string{"█", "█", "▓", "▓", "▒", "▒", "░", "░", " ", " "},
	ease.InOutCubic,
}
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 = SpinnerFrames{
	[]string{"█", "█", "▇", "▆", "▅", "▄", "▃", "▂", "▁", " "},
	ease.InOutCubic,
}
View Source
var MiniDotFrames = SpinnerFrames{
	[]string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"},
	ease.Linear,
}

Functions

func ColorProfile added in v0.10.1

func ColorProfile() termenv.Profile

ColorProfile returns Ascii if, and only if, NO_COLOR or similar is set. Otherwise it returns termenv.ANSI, allowing colors to be used.

Note that color profiles beyond simple ANSI are not used by Progrock. 16 colors is all you need. Anything else disrespects the user's color scheme preferences.

func Frame

func Frame(fps float64) tea.Cmd

func NewOutput added in v0.10.1

func NewOutput(w io.Writer, opts ...termenv.OutputOption) *termenv.Output

NewOutput returns a termenv.Output that will always use color, regardless of whether w is a TTY, unless NO_COLOR is explicitly set.

Progrock is opinionated here. Termenv disables colors by default if stdout is not a TTY or if the CI env var is set. We don't want that, because folks deserve colorful output in CI too.

To disable colors, set NO_COLOR (https://no-color.org/).

Types

type FrameMsg

type FrameMsg time.Time

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 SpinnerFrames
	// 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 SpinnerFrames) (string, time.Time, int)

type SetFPSMsg

type SetFPSMsg float64

type Spinner

type Spinner interface {
	tea.Model

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

type SpinnerFrames added in v0.10.0

type SpinnerFrames struct {
	Frames []string
	Easing ease.Function
}

SpinnerFrames contains animation frames.

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) LastLine added in v0.8.0

func (term *Vterm) LastLine() string

LastLine returns the last line of visible text, with ANSI formatting, but without any trailing whitespace.

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