Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update: add placeholder for no lyrics found condition #60

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ type Update struct {
Index int
Playing bool

// ID of the current track.
ID string
Err error
}

Expand Down Expand Up @@ -83,6 +85,7 @@ func Listen(
Index: index,
Playing: state.Playing,
Err: state.Err,
ID: state.ID,
}
}
}
Expand Down
15 changes: 14 additions & 1 deletion ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ui

import (
"os"
"fmt"
"runtime"
"sptlrx/config"
"sptlrx/lyrics"
Expand Down Expand Up @@ -54,6 +55,10 @@ func (m *Model) Update(message tea.Msg) (tea.Model, tea.Cmd) {
case pool.Update:
m.state = msg

// set sptlrx window title
windowTitle := m.state.ID + " - sptlrx"
fmt.Print("\033]0;" + windowTitle + "\007")

if runtime.GOOS == "windows" {
w, h, err := term.GetSize(int(os.Stdout.Fd()))
if err == nil {
Expand Down Expand Up @@ -113,7 +118,15 @@ func (m *Model) View() string {
)
}
if len(m.state.Lines) == 0 {
return ""
placeholder := "<" + m.state.ID + ">" + "\n\nNo lyrics found"

return gloss.PlaceVertical(
m.h, gloss.Center,
m.styleAfter.
Align(gloss.Center).
Width(m.w).
Render( placeholder ),
)
}

curLine := m.styleCurrent.
Expand Down