Adding more sensible defaults.

1. After Selection during navigating the folder can be added to the
   playlist now.
2. Also Binded Escape to quit the BuffSearchView
This commit is contained in:
aditya-K2 2021-12-26 19:23:58 +05:30
parent 7b35d30ef7
commit a8ae5fb426

21
main.go
View File

@ -1,6 +1,7 @@
package main
import (
"fmt"
"strconv"
"time"
@ -161,6 +162,16 @@ func main() {
} else if ui.HasFocus("SearchView") {
r, _ := UI.ExpandedView.GetSelection()
client.AddToPlaylist(SearchContentSlice[r], false)
} else if ui.HasFocus("BuffSearchView") {
r, _ := UI.ExpandedView.GetSelection()
ui.SetFocus("FileBrowser")
err := CONN.Add(dirTree.Children[Matches[r].Index].AbsolutePath)
if err != nil {
Notify.Send(fmt.Sprintf("Could Not Add URI %s to the Playlist", dirTree.Children[Matches[r].Index].Path))
} else {
Notify.Send(fmt.Sprintf("URI Added %s to the Playlist", dirTree.Children[Matches[r].Index].Path))
}
ui.SetFocus("BuffSearchView")
}
},
"toggleRandom": func() {
@ -311,6 +322,16 @@ func main() {
}
})
UI.ExpandedView.SetDoneFunc(func(e tcell.Key) {
if e == tcell.KeyEscape {
if ui.HasFocus("BuffSearchView") {
ui.SetFocus("FileBrowser")
UI.SearchBar.SetText("")
Matches = nil
}
}
})
UI.SearchBar.SetChangedFunc(func(text string) {
if ui.HasFocus("BuffSearchView") {
var f client.FileNodes = dirTree.Children