model

package
v1.60.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Overview

Package ui implements the Bubbletea TUI for the CLIAMP terminal music player.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttachNotifier

func AttachNotifier(notifier playback.Notifier) tea.Msg

func ReservedKeys

func ReservedKeys() map[string]bool

ReservedKeys returns a fresh copy of the core-reserved key set. Handed to the Lua plugin manager at startup so it can reject conflicting plugin binds.

Types

type ConfigSaver

type ConfigSaver interface {
	Save(key, value string) error
}

ConfigSaver persists individual config key-value pairs. Satisfied by config.SaveFunc (the default) or a test stub.

type EQPreset

type EQPreset struct {
	Name  string
	Bands [eqBandCount]float64
}

EQPreset is a named 10-band EQ curve.

func EQPresetByName

func EQPresetByName(name string) (EQPreset, bool)

EQPresetByName looks up a built-in preset by case-insensitive name.

type Model

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

Model is the Bubbletea model for the CLIAMP TUI.

func New

func New(p player.Engine, pl *playlist.Playlist, providers []ProviderEntry, defaultProvider string, localProv playlist.Provider, themes []theme.Theme, luaMgr *luaplugin.Manager, cs ConfigSaver) Model

New creates a Model wired to the given player and playlist. providers is the ordered list of available providers (Radio, Navidrome, Spotify, Jellyfin, etc.). defaultProvider is the config key of the provider to select initially. localProv is an optional direct reference to the local provider for write ops.

func (Model) EQPresetName

func (m Model) EQPresetName() string

EQPresetName returns the current preset name, or "Custom".

func (Model) Init

func (m Model) Init() tea.Cmd

Init starts the tick timer and requests the terminal size.

func (*Model) RegisterLuaVisualizers

func (m *Model) RegisterLuaVisualizers(names []string, renderer ui.LuaVisRenderer)

RegisterLuaVisualizers adds Lua visualizer plugins to the visualizer cycle.

func (*Model) ResumePlaylist

func (m *Model) ResumePlaylist(name string, tracks []playlist.Track)

ResumePlaylist loads a playlist into the model for session resume.

func (Model) ResumeState

func (m Model) ResumeState() (path string, secs int, playlist string)

ResumeState returns the track path, playback position, and playlist name captured at exit. Called after prog.Run() returns (player already closed).

func (*Model) SetAutoPlay

func (m *Model) SetAutoPlay(v bool)

SetAutoPlay makes the player start playback immediately on Init.

func (*Model) SetCompact

func (m *Model) SetCompact(v bool)

SetCompact enables compact mode which caps the frame width at 80 columns.

func (*Model) SetEQPreset

func (m *Model) SetEQPreset(name string, bands *[10]float64)

SetEQPreset sets the preset by name. If it matches a built-in preset, those bands are applied. Otherwise the name is used as a custom label. If bands is non-nil, they are applied regardless of whether the name matches.

func (*Model) SetInitialDirectory

func (m *Model) SetInitialDirectory(dir string)

SetInitialDirectory sets the initial directory for the file browser.

func (*Model) SetLoadedPlaylist

func (m *Model) SetLoadedPlaylist(name string)

SetLoadedPlaylist records that the live queue exactly mirrors a local saved playlist, allowing path-based write-backs such as bookmarks and removals.

func (*Model) SetLowPower

func (m *Model) SetLowPower(v bool)

SetLowPower lowers UI cadences without affecting normal mode.

func (*Model) SetPendingURLs

func (m *Model) SetPendingURLs(urls []string)

SetPendingURLs stores remote URLs (feeds, M3U) for async resolution after Init.

func (*Model) SetResume

func (m *Model) SetResume(path string, secs int)

SetResume registers a path+position to seek to when that track first plays.

func (*Model) SetSeekStepLarge

func (m *Model) SetSeekStepLarge(d time.Duration)

SetSeekStepLarge configures the Shift+Left/Right seek jump amount.

func (*Model) SetTheme

func (m *Model) SetTheme(name string) bool

SetTheme finds a theme by name and applies it. Returns true if found.

func (*Model) SetVisVolumeLinked

func (m *Model) SetVisVolumeLinked(linked bool)

SetVisVolumeLinked controls whether the visualizer scales samples by the current volume before FFT analysis, making bar height follow volume.

func (*Model) SetVisualizer

func (m *Model) SetVisualizer(name string) bool

SetVisualizer sets the visualizer mode by name (case-insensitive). Returns true if a valid mode name was recognized. Does not modify state if the name is not found, matching the SetTheme guard pattern.

func (*Model) StartInProvider

func (m *Model) StartInProvider()

StartInProvider configures the model to begin in the provider browse view. Call this from main when no CLI tracks or pending URLs were given.

func (Model) ThemeName

func (m Model) ThemeName() string

ThemeName returns the current theme name.

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages: key presses, ticks, and window resizes.

func (Model) View

func (m Model) View() tea.View

View renders the full TUI frame.

func (*Model) VisualizerName

func (m *Model) VisualizerName() string

VisualizerName returns the current visualizer mode's display name.

type PluginQueueMsg

type PluginQueueMsg struct {
	Op    string // "add" | "jump" | "remove" | "move"
	Path  string // add
	Index int    // jump, remove, move (from)
	To    int    // move (to)
}

PluginQueueMsg is sent by Lua plugins (cliamp.queue.*) to mutate the queue. Mutations are routed through the Update loop rather than applied directly from the plugin goroutine so the model's derived state (cursor, current index, playback) stays consistent. Indices are 0-based.

type ProvAuthURLMsg

type ProvAuthURLMsg struct{ URL string }

ProvAuthURLMsg carries the OAuth URL produced by a provider's interactive auth flow so the TUI can display it. Used as a fallback when the launched browser doesn't reach the user (e.g. inside containers or headless envs).

type ProviderEntry

type ProviderEntry struct {
	Key      string            // config key: "radio", "navidrome", "spotify"
	Name     string            // display name: "Radio", "Navidrome", "Spotify"
	Provider playlist.Provider // nil if not configured
}

ProviderEntry pairs a display name with a key and provider implementation.

type SetEQPresetMsg

type SetEQPresetMsg struct {
	Name  string
	Bands *[10]float64 // nil = use built-in preset bands or keep current
}

SetEQPresetMsg is sent by Lua plugins to change the EQ preset by name. If Bands is non-nil, the bands are applied and the name becomes a custom label.

type ShowStatusMsg

type ShowStatusMsg struct {
	Text     string
	Duration time.Duration
}

ShowStatusMsg is sent by Lua plugins to display a message in the status bar. Duration <= 0 falls back to the default status TTL.

Jump to

Keyboard shortcuts

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