Added Update Function
This function will be useful to update the expanded view whenever user navigates the file browser. The expanded view is a table which shows the directory content.
This commit is contained in:
parent
a41e060866
commit
b4e6402a25
47
client.go
47
client.go
@ -2,6 +2,9 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/fhs/gompd/mpd"
|
"github.com/fhs/gompd/mpd"
|
||||||
|
// "github.com/gdamore/tcell/v2"
|
||||||
|
"github.com/rivo/tview"
|
||||||
|
// "fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func togglePlayBack(connection mpd.Client) error {
|
func togglePlayBack(connection mpd.Client) error {
|
||||||
@ -13,3 +16,47 @@ func togglePlayBack(connection mpd.Client) error {
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func join ( stringSlice [] string ) string{
|
||||||
|
var _s string = stringSlice[0]
|
||||||
|
for i:= 1; i<len(stringSlice);i++{
|
||||||
|
if ( _s != ""){
|
||||||
|
_s += ( "/" + stringSlice[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _s
|
||||||
|
}
|
||||||
|
|
||||||
|
func Update(conn mpd.Client, f []FileNode, currentDirectoryStructure [] string, inputTable *tview.Table) {
|
||||||
|
ab := join(currentDirectoryStructure)
|
||||||
|
for i,j := range(f){
|
||||||
|
if len(j.children) == 0 {
|
||||||
|
a, err := conn.ListAllInfo(ab)
|
||||||
|
if err == nil {
|
||||||
|
|
||||||
|
inputTable.SetCell(i, 0,
|
||||||
|
tview.NewTableCell("[#fbff00]" + a[0]["Title"]).
|
||||||
|
SetAlign(tview.AlignLeft))
|
||||||
|
|
||||||
|
inputTable.SetCell(i, 1,
|
||||||
|
tview.NewTableCell("[#000000]" + a[0]["Artist"]).
|
||||||
|
SetAlign(tview.AlignLeft))
|
||||||
|
|
||||||
|
inputTable.SetCell(i, 2,
|
||||||
|
tview.NewTableCell("[#ff0030]" + a[0]["Album"]).
|
||||||
|
SetAlign(tview.AlignLeft))
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
inputTable.SetCell(i, 0,
|
||||||
|
tview.NewTableCell("[#fbff00::b]" + j.path).
|
||||||
|
SetAlign(tview.AlignLeft))
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func addSong(conn mpd.Client, currentDirectoryStructure [] string, currentCellContent string){
|
||||||
|
conn.Add(join(currentDirectoryStructure) + "/" + currentCellContent)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user