tui

package
v0.0.0-...-d6f5fe4 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MainView viewport = iota
	HelpView
)
View Source
const SHRINKWIDTH = 95

Variables

View Source
var (
	PrimaryColor = lipgloss.AdaptiveColor{
		Light: "#1db954",
		Dark:  "#1db954",
	}
	SecondaryColor = lipgloss.AdaptiveColor{
		Light: "#f5f5f5",
		Dark:  "#212121",
	}
	BorderColor = lipgloss.AdaptiveColor{
		Light: "#e0e0e0",
		Dark:  "#535353",
	}
	TextColor = lipgloss.AdaptiveColor{
		Light: "#333333",
		Dark:  "#b3b3b3",
	}
	WhiteTextColor = lipgloss.AdaptiveColor{
		Light: "#000000",
		Dark:  "#ffffff",
	}
	DangerColor = lipgloss.AdaptiveColor{
		Light: "#ff4444",
		Dark:  "#ff4444",
	}
)
View Source
var DefaultKeyMap = KeyMap{
	Quit: key.NewBinding(
		key.WithKeys("ctrl+c"),
		key.WithHelp("ctrl+c", "quit application"),
	),
	Up: key.NewBinding(
		key.WithKeys("k", "up"),
		key.WithHelp("↑/k", "move up"),
	),
	Down: key.NewBinding(
		key.WithKeys("j", "down"),
		key.WithHelp("↓/j", "move down"),
	),
	Left: key.NewBinding(
		key.WithKeys("h", "left"),
		key.WithHelp("←/h", "previous track"),
	),
	Right: key.NewBinding(
		key.WithKeys("l", "right"),
		key.WithHelp("→/l", "next track"),
	),
	Select: key.NewBinding(
		key.WithKeys("enter"),
		key.WithHelp("enter", "select track"),
	),
	AddToQueue: key.NewBinding(
		key.WithKeys("a"),
		key.WithHelp("a", "Add to queue"),
	),
	ViewQueue: key.NewBinding(
		key.WithKeys("q"),
		key.WithHelp("q", "View queue"),
	),
	CycleFocusForward: key.NewBinding(
		key.WithKeys("tab"),
		key.WithHelp("tab", "cycle focus forward"),
	),
	CycleFocusBackward: key.NewBinding(
		key.WithKeys("shift+tab"),
		key.WithHelp("shift+tab", "cycle focus backward"),
	),
	Copy: key.NewBinding(
		key.WithKeys("c"),
		key.WithHelp("c", "copy URL to clipboard"),
	),
	Help: key.NewBinding(
		key.WithKeys("?"),
		key.WithHelp("?", "show help view"),
	),
	VolumeUp: key.NewBinding(
		key.WithKeys("shift+up"),
		key.WithHelp("shift+↑", "increase volume"),
	),
	VolumeDown: key.NewBinding(
		key.WithKeys("shift+down"),
		key.WithHelp("shift+↓", "lower volume"),
	),
	Search: key.NewBinding(
		key.WithKeys("/"),
		key.WithHelp("/", "search"),
	),
	DeviceDialog: key.NewBinding(
		key.WithKeys("d"),
		key.WithHelp("d", "open device dialog"),
	),
	Return: key.NewBinding(
		key.WithKeys("esc"),
		key.WithHelp("esc", "return to previous view"),
	),
	Shuffle: key.NewBinding(
		key.WithKeys("s"),
		key.WithHelp("s", "toggle shuffle"),
	),
	Previous: key.NewBinding(
		key.WithKeys("p"),
		key.WithHelp("p", "previous song"),
	),
	PlayPause: key.NewBinding(
		key.WithKeys(" "),
		key.WithHelp("space", "play/pause"),
	),
	Next: key.NewBinding(
		key.WithKeys("n"),
		key.WithHelp("n", "next song"),
	),
	Repeat: key.NewBinding(
		key.WithKeys("r"),
		key.WithHelp("r", "cycle repeat mode"),
	),
	VolumeMute: key.NewBinding(
		key.WithKeys("m"),
		key.WithHelp("m", "mute/unmute volume"),
	),
}
View Source
var RoundedTableBorders = table.Border{
	Top:    "─",
	Left:   "│",
	Right:  "│",
	Bottom: "─",

	TopRight:    "╮",
	TopLeft:     "╭",
	BottomRight: "╯",
	BottomLeft:  "╰",

	TopJunction:    "─",
	LeftJunction:   "├",
	RightJunction:  "┤",
	BottomJunction: "─",
	InnerJunction:  "─",

	InnerDivider: " ",
}

Functions

func NavigateCmd(target FocusedModel, exitSearch bool, selectedID spotify.ID, vp tableView) tea.Cmd

func Run

func Run(ctx context.Context, c *config.Config, authenticator authenticator, tokenStorer tokenStorer) error

Types

type AutoplayNextTrackMsg

type AutoplayNextTrackMsg struct{}

AutoplayNextTrackMsg is emitted when a song ends and we need to autoplay the next track

type DialogAction

type DialogAction struct {
	Label string
	Key   key.Binding
	Cmd   tea.Cmd
}

type DialogContent

type DialogContent interface {
	tea.Model
	GetTitle() string
	SetSize(width, height int)
	HandleDialogKey(msg tea.KeyMsg) (bool, tea.Cmd)
	GetActions() []DialogAction
}

func NewDeviceDialog

func NewDeviceDialog(ctx context.Context, spotifyState *state.SpotifyState) DialogContent

type DialogMsg

type DialogMsg struct {
	Accepted bool
}

type ErrorTimerExpiredMsg

type ErrorTimerExpiredMsg struct{}

type FocusedModel

type FocusedModel int
const (
	FocusLibrary FocusedModel = iota
	FocusSearchBar
	FocusPlaylistView
	FocusSearchTracksView
	FocusSearchPlaylistsView
	FocusSearchArtistsView
	FocusSearchAlbumsView
	FocusQueue
)

type HideDialogMsg

type HideDialogMsg struct{}

type KeyMap

type KeyMap struct {
	Up    key.Binding
	Down  key.Binding
	Left  key.Binding
	Right key.Binding

	CycleFocusForward  key.Binding
	CycleFocusBackward key.Binding

	//Actions
	Select     key.Binding
	Copy       key.Binding
	Return     key.Binding
	AddToQueue key.Binding

	// System
	Quit         key.Binding
	Help         key.Binding
	Search       key.Binding
	ViewQueue    key.Binding
	DeviceDialog key.Binding

	// Media controls
	Shuffle    key.Binding
	Previous   key.Binding
	PlayPause  key.Binding
	Next       key.Binding
	Repeat     key.Binding
	VolumeMute key.Binding
	VolumeUp   key.Binding
	VolumeDown key.Binding
}
type NavigationMsg struct {
	Target     FocusedModel
	ExitSearch bool
	// contains filtered or unexported fields
}

type ShowDialogWithContentMsg

type ShowDialogWithContentMsg struct {
	Content DialogContent
}

type ShowToastMsg

type ShowToastMsg struct {
	Title   string
	Message string
}

type TrackRow

type TrackRow struct {
	Type     TrackRowType
	Track    *spotify.SimpleTrack
	Index    int
	IsQueued bool
}

type TrackRowType

type TrackRowType int
const (
	TrackRowLoaded TrackRowType = iota
	TrackRowLoading
)

Jump to

Keyboard shortcuts

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