mirror of
https://github.com/issadarkthing/gomu.git
synced 2025-04-26 13:49:21 +08:00
add more configurable color
This commit is contained in:
parent
866b87c6a3
commit
1e9c5864cf
62
colors.go
62
colors.go
@ -10,12 +10,15 @@ import (
|
|||||||
|
|
||||||
type Colors struct {
|
type Colors struct {
|
||||||
accent tcell.Color
|
accent tcell.Color
|
||||||
foreground tcell.Color
|
|
||||||
background tcell.Color
|
background tcell.Color
|
||||||
|
foreground tcell.Color
|
||||||
// title refers to now_playing_title in config file
|
// title refers to now_playing_title in config file
|
||||||
title tcell.Color
|
title tcell.Color
|
||||||
popup tcell.Color
|
popup tcell.Color
|
||||||
playlist tcell.Color
|
playlistHi tcell.Color
|
||||||
|
playlistDir tcell.Color
|
||||||
|
queueHi tcell.Color
|
||||||
|
subtitle string
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -25,12 +28,15 @@ func init() {
|
|||||||
func newColor() *Colors {
|
func newColor() *Colors {
|
||||||
|
|
||||||
defaultColors := map[string]string{
|
defaultColors := map[string]string{
|
||||||
"Color.accent": "darkcyan",
|
"Color.accent": "darkcyan",
|
||||||
"Color.background": "none",
|
"Color.background": "none",
|
||||||
"Color.foreground": "white",
|
"Color.foreground": "white",
|
||||||
"Color.now_playing_title": "darkgreen",
|
"Color.popup": "black",
|
||||||
"Color.playlist": "white",
|
"Color.playlist_directory": "darkcyan",
|
||||||
"Color.popup": "black",
|
"Color.playlist_highlight": "darkcyan",
|
||||||
|
"Color.queue_highlight": "darkcyan",
|
||||||
|
"Color.now_playing_title": "darkgreen",
|
||||||
|
"Color.subtitle": "darkgoldenrod",
|
||||||
}
|
}
|
||||||
|
|
||||||
anko := gomu.anko
|
anko := gomu.anko
|
||||||
@ -47,38 +53,30 @@ func newColor() *Colors {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
accent := anko.GetString("Color.accent")
|
accent := anko.GetString("Color.accent")
|
||||||
foreground := anko.GetString("Color.foreground")
|
|
||||||
background := anko.GetString("Color.background")
|
background := anko.GetString("Color.background")
|
||||||
|
foreground := anko.GetString("Color.foreground")
|
||||||
popup := anko.GetString("Color.popup")
|
popup := anko.GetString("Color.popup")
|
||||||
|
playlistDir := anko.GetString("Color.playlist_directory")
|
||||||
|
playlistHi := anko.GetString("Color.playlist_highlight")
|
||||||
|
queueHi := anko.GetString("Color.queue_highlight")
|
||||||
title := anko.GetString("Color.now_playing_title")
|
title := anko.GetString("Color.now_playing_title")
|
||||||
playlist := anko.GetString("Color.playlist")
|
subtitle := anko.GetString("Color.subtitle")
|
||||||
|
|
||||||
color := &Colors{
|
color := &Colors{
|
||||||
accent: tcell.ColorNames[accent],
|
accent: tcell.ColorNames[accent],
|
||||||
foreground: tcell.ColorNames[foreground],
|
foreground: tcell.ColorNames[foreground],
|
||||||
background: tcell.ColorNames[background],
|
background: tcell.ColorNames[background],
|
||||||
popup: tcell.ColorNames[popup],
|
popup: tcell.ColorNames[popup],
|
||||||
title: tcell.ColorNames[title],
|
playlistDir: tcell.ColorNames[playlistDir],
|
||||||
playlist: tcell.ColorNames[playlist],
|
playlistHi: tcell.ColorNames[playlistHi],
|
||||||
|
queueHi: tcell.ColorNames[queueHi],
|
||||||
|
title: tcell.ColorNames[title],
|
||||||
|
subtitle: subtitle,
|
||||||
}
|
}
|
||||||
return color
|
return color
|
||||||
}
|
}
|
||||||
|
|
||||||
func isValidColor(x tcell.Color) bool {
|
|
||||||
return (x == tcell.ColorDefault) || x >= tcell.ColorBlack && x <= tcell.ColorYellowGreen
|
|
||||||
}
|
|
||||||
|
|
||||||
func intToColor(x int) tcell.Color {
|
|
||||||
|
|
||||||
if x == -1 {
|
|
||||||
return tcell.ColorDefault
|
|
||||||
}
|
|
||||||
|
|
||||||
return tcell.Color(x) + tcell.ColorBlack
|
|
||||||
}
|
|
||||||
|
|
||||||
func colorsPopup() tview.Primitive {
|
func colorsPopup() tview.Primitive {
|
||||||
|
|
||||||
textView := tview.NewTextView().
|
textView := tview.NewTextView().
|
||||||
|
@ -43,6 +43,7 @@ func newPlayingBar() *PlayingBar {
|
|||||||
|
|
||||||
textView := tview.NewTextView().SetTextAlign(tview.AlignCenter)
|
textView := tview.NewTextView().SetTextAlign(tview.AlignCenter)
|
||||||
textView.SetBackgroundColor(gomu.colors.background)
|
textView.SetBackgroundColor(gomu.colors.background)
|
||||||
|
textView.SetDynamicColors(true)
|
||||||
|
|
||||||
frame := tview.NewFrame(textView).SetBorders(1, 1, 1, 1, 1, 1)
|
frame := tview.NewFrame(textView).SetBorders(1, 1, 1, 1, 1, 1)
|
||||||
frame.SetBorder(true).SetTitle(" Now Playing ")
|
frame.SetBorder(true).SetTitle(" Now Playing ")
|
||||||
@ -113,10 +114,11 @@ func (p *PlayingBar) run() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gomu.app.QueueUpdateDraw(func() {
|
gomu.app.QueueUpdateDraw(func() {
|
||||||
p.text.SetText(fmt.Sprintf("%s ┃%s┫ %s\n\n%v",
|
p.text.SetText(fmt.Sprintf("%s ┃%s┫ %s\n\n[%s]%v[-]",
|
||||||
fmtDuration(start),
|
fmtDuration(start),
|
||||||
progressBar,
|
progressBar,
|
||||||
fmtDuration(end),
|
fmtDuration(end),
|
||||||
|
gomu.colors.subtitle,
|
||||||
lyricText,
|
lyricText,
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
|
20
playlist.go
20
playlist.go
@ -110,7 +110,7 @@ func newPlaylist(args Args) *Playlist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
root := tview.NewTreeNode(rootTextView).
|
root := tview.NewTreeNode(rootTextView).
|
||||||
SetColor(gomu.colors.accent)
|
SetColor(gomu.colors.playlistDir)
|
||||||
|
|
||||||
tree := tview.NewTreeView().SetRoot(root)
|
tree := tview.NewTreeView().SetRoot(root)
|
||||||
tree.SetBackgroundColor(gomu.colors.background)
|
tree.SetBackgroundColor(gomu.colors.background)
|
||||||
@ -128,7 +128,7 @@ func newPlaylist(args Args) *Playlist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
root.SetReference(rootAudioFile)
|
root.SetReference(rootAudioFile)
|
||||||
root.SetColor(gomu.colors.playlist)
|
root.SetColor(gomu.colors.playlistDir)
|
||||||
|
|
||||||
playlist.
|
playlist.
|
||||||
SetTitle(playlist.defaultTitle).
|
SetTitle(playlist.defaultTitle).
|
||||||
@ -419,15 +419,17 @@ func (p *Playlist) createPlaylist(name string) error {
|
|||||||
func (p *Playlist) setHighlight(currNode *tview.TreeNode) {
|
func (p *Playlist) setHighlight(currNode *tview.TreeNode) {
|
||||||
|
|
||||||
if p.prevNode != nil {
|
if p.prevNode != nil {
|
||||||
p.prevNode.SetColor(gomu.colors.foreground)
|
if p.prevNode.GetReference().(*AudioFile).isAudioFile {
|
||||||
|
p.prevNode.SetColor(gomu.colors.foreground)
|
||||||
|
} else {
|
||||||
|
p.prevNode.SetColor(gomu.colors.playlistDir)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
currNode.SetColor(gomu.colors.playlist)
|
|
||||||
|
currNode.SetColor(gomu.colors.playlistHi)
|
||||||
p.SetCurrentNode(currNode)
|
p.SetCurrentNode(currNode)
|
||||||
|
|
||||||
if currNode.GetReference().(*AudioFile).isAudioFile {
|
p.prevNode = currNode
|
||||||
p.prevNode = currNode
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Traverses the playlist and finds the AudioFile struct
|
// Traverses the playlist and finds the AudioFile struct
|
||||||
@ -719,7 +721,7 @@ func populate(root *tview.TreeNode, rootPath string) error {
|
|||||||
displayText := setDisplayText(audioFile)
|
displayText := setDisplayText(audioFile)
|
||||||
|
|
||||||
child.SetReference(audioFile)
|
child.SetReference(audioFile)
|
||||||
child.SetColor(gomu.colors.playlist)
|
child.SetColor(gomu.colors.playlistDir)
|
||||||
child.SetText(displayText)
|
child.SetText(displayText)
|
||||||
root.AddChild(child)
|
root.AddChild(child)
|
||||||
populate(child, path)
|
populate(child, path)
|
||||||
|
4
queue.go
4
queue.go
@ -409,8 +409,8 @@ func newQueue() *Queue {
|
|||||||
|
|
||||||
queue.
|
queue.
|
||||||
ShowSecondaryText(false).
|
ShowSecondaryText(false).
|
||||||
SetSelectedBackgroundColor(gomu.colors.accent).
|
SetSelectedBackgroundColor(gomu.colors.queueHi).
|
||||||
SetSelectedTextColor(tcell.ColorWhite).
|
SetSelectedTextColor(gomu.colors.foreground).
|
||||||
SetHighlightFullLine(true)
|
SetHighlightFullLine(true)
|
||||||
|
|
||||||
queue.
|
queue.
|
||||||
|
10
start.go
10
start.go
@ -227,9 +227,15 @@ module Color {
|
|||||||
accent = "darkcyan"
|
accent = "darkcyan"
|
||||||
background = "none"
|
background = "none"
|
||||||
foreground = "white"
|
foreground = "white"
|
||||||
now_playing_title = "darkgreen"
|
|
||||||
playlist = "white"
|
|
||||||
popup = "black"
|
popup = "black"
|
||||||
|
|
||||||
|
playlist_directory = "darkcyan"
|
||||||
|
playlist_highlight = "darkcyan"
|
||||||
|
|
||||||
|
queue_highlight = "darkcyan"
|
||||||
|
|
||||||
|
now_playing_title = "darkgreen"
|
||||||
|
subtitle = "darkgoldenrod"
|
||||||
}
|
}
|
||||||
|
|
||||||
# you can get the syntax highlighting for this language here:
|
# you can get the syntax highlighting for this language here:
|
||||||
|
11
test/config
11
test/config
@ -35,10 +35,15 @@ module Color {
|
|||||||
accent = "darkcyan"
|
accent = "darkcyan"
|
||||||
background = "none"
|
background = "none"
|
||||||
foreground = "white"
|
foreground = "white"
|
||||||
now_playing_title = "darkgreen"
|
|
||||||
# the color of the directory in playlist
|
|
||||||
playlist = "darkslategray"
|
|
||||||
popup = "black"
|
popup = "black"
|
||||||
|
|
||||||
|
playlist_directory = "darkcyan"
|
||||||
|
playlist_highlight = "darkcyan"
|
||||||
|
|
||||||
|
queue_highlight = "darkcyan"
|
||||||
|
|
||||||
|
now_playing_title = "darkgreen"
|
||||||
|
subtitle = "darkgoldenrod"
|
||||||
}
|
}
|
||||||
|
|
||||||
func fib(x) {
|
func fib(x) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user