parent
baa78056d8
commit
8b69a80866
8 changed files with 100 additions and 66 deletions
|
@ -1,3 +1,6 @@
|
|||
0.1.8:
|
||||
- Allow reordering interface elements
|
||||
|
||||
0.1.7:
|
||||
- Add scrollbar to lists
|
||||
- Add --disable-mouse option
|
||||
|
|
6
audio.go
6
audio.go
|
@ -186,7 +186,7 @@ func pause() {
|
|||
}
|
||||
|
||||
func nextTrack() {
|
||||
if queueList.GetCurrentItem() < len(queueFiles)-1 {
|
||||
if queueList.GetCurrentItemIndex() < len(queueFiles)-1 {
|
||||
queueNext()
|
||||
|
||||
entry := selectedQueueEntry()
|
||||
|
@ -213,7 +213,7 @@ func skipPrevious() {
|
|||
}
|
||||
|
||||
queuePrevious()
|
||||
go queueSelect(queueList.GetCurrentItem())
|
||||
go queueSelect(queueList.GetCurrentItemIndex())
|
||||
}
|
||||
|
||||
func skipNext() {
|
||||
|
@ -222,7 +222,7 @@ func skipNext() {
|
|||
}
|
||||
|
||||
queueNext()
|
||||
go queueSelect(queueList.GetCurrentItem())
|
||||
go queueSelect(queueList.GetCurrentItemIndex())
|
||||
}
|
||||
|
||||
func roundUnit(x, unit float64) float64 {
|
||||
|
|
|
@ -11,10 +11,12 @@ import (
|
|||
|
||||
type appConfig struct {
|
||||
Input map[string][]string // Keybinds
|
||||
Volume int // Starting volume
|
||||
Layout string
|
||||
Volume int // Starting volume
|
||||
}
|
||||
|
||||
var config = &appConfig{
|
||||
Layout: defaultLayout,
|
||||
Volume: 75,
|
||||
}
|
||||
|
||||
|
|
12
go.mod
12
go.mod
|
@ -5,18 +5,18 @@ go 1.15
|
|||
require (
|
||||
github.com/dhowden/tag v0.0.0-20200828214007-46e57f75dbfc
|
||||
github.com/faiface/beep v1.0.2
|
||||
github.com/gdamore/tcell/v2 v2.0.0-dev.0.20200908121250-0c5e1e1720f1
|
||||
github.com/gdamore/tcell/v2 v2.0.1-0.20201019142633-1057d5591ed1
|
||||
github.com/hajimehoshi/go-mp3 v0.3.1 // indirect
|
||||
github.com/hajimehoshi/oto v0.6.4 // indirect
|
||||
github.com/hajimehoshi/oto v0.6.6 // indirect
|
||||
github.com/jfreymuth/oggvorbis v1.0.1 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.9
|
||||
github.com/mewkiz/flac v1.0.6 // indirect
|
||||
github.com/mewkiz/pkg v0.0.0-20200702171441-dd47075182ea // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
gitlab.com/tslocum/cbind v0.1.2
|
||||
gitlab.com/tslocum/cview v1.4.9
|
||||
golang.org/x/exp v0.0.0-20200908183739-ae8ad444f925 // indirect
|
||||
golang.org/x/image v0.0.0-20200801110659-972c09e46d76 // indirect
|
||||
gitlab.com/tslocum/cbind v0.1.3
|
||||
gitlab.com/tslocum/cview v1.5.1-0.20201021172753-ac2b3155fd44
|
||||
golang.org/x/exp v0.0.0-20201008143054-e3b2a7f2fdc7 // indirect
|
||||
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5 // indirect
|
||||
golang.org/x/mobile v0.0.0-20200801112145-973feb4309de // indirect
|
||||
gopkg.in/yaml.v2 v2.3.0
|
||||
)
|
||||
|
|
31
go.sum
31
go.sum
|
@ -11,8 +11,8 @@ github.com/gdamore/tcell v1.1.1 h1:U73YL+jMem2XfhvaIUfPO6MpJawaG92B2funXVb9qLs=
|
|||
github.com/gdamore/tcell v1.1.1/go.mod h1:K1udHkiR3cOtlpKG5tZPD5XxrF7v2y7lDq7Whcj+xkQ=
|
||||
github.com/gdamore/tcell/v2 v2.0.0-dev h1:34h4ahbtQZ7ndLnAHAdamYk6eQ5W/piK9Vm5/JiYkfQ=
|
||||
github.com/gdamore/tcell/v2 v2.0.0-dev/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
|
||||
github.com/gdamore/tcell/v2 v2.0.0-dev.0.20200908121250-0c5e1e1720f1 h1:ec/DAe6ms4fBkpSHObVDYU4N/w6Swd929zkN01g8ozY=
|
||||
github.com/gdamore/tcell/v2 v2.0.0-dev.0.20200908121250-0c5e1e1720f1/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
|
||||
github.com/gdamore/tcell/v2 v2.0.1-0.20201019142633-1057d5591ed1 h1:gp9ujdOQmQf1gMvqOYYgxdMS5tRpRGE3HAgRH4Hgzd4=
|
||||
github.com/gdamore/tcell/v2 v2.0.1-0.20201019142633-1057d5591ed1/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
|
||||
github.com/go-audio/audio v1.0.0/go.mod h1:6uAu0+H2lHkwdGsAY+j2wHPNPpPoeg5AaEFh9FlA+Zs=
|
||||
github.com/go-audio/riff v1.0.0/go.mod h1:l3cQwc85y79NQFCRB7TiPoNiaijp6q8Z0Uv38rVG498=
|
||||
github.com/go-audio/wav v1.0.0/go.mod h1:3yoReyQOsiARkvPl3ERCi8JFjihzG6WhjYpZCf5zAWE=
|
||||
|
@ -31,8 +31,8 @@ github.com/hajimehoshi/oto v0.1.1/go.mod h1:hUiLWeBQnbDu4pZsAhOnGqMI1ZGibS6e2qhQ
|
|||
github.com/hajimehoshi/oto v0.3.1 h1:cpf/uIv4Q0oc5uf9loQn7PIehv+mZerh+0KKma6gzMk=
|
||||
github.com/hajimehoshi/oto v0.3.1/go.mod h1:e9eTLBB9iZto045HLbzfHJIc+jP3xaKrjZTghvb6fdM=
|
||||
github.com/hajimehoshi/oto v0.6.1/go.mod h1:0QXGEkbuJRohbJaxr7ZQSxnju7hEhseiPx2hrh6raOI=
|
||||
github.com/hajimehoshi/oto v0.6.4 h1:mrYgkuReD1rKty9PJ7xUR9VKGgvf7nAzi3NAHsD8nKE=
|
||||
github.com/hajimehoshi/oto v0.6.4/go.mod h1:0QXGEkbuJRohbJaxr7ZQSxnju7hEhseiPx2hrh6raOI=
|
||||
github.com/hajimehoshi/oto v0.6.6 h1:HYSZ8cYZqOL4iHugvbcfhNN2smiSOsBMaoSBi4nnWcw=
|
||||
github.com/hajimehoshi/oto v0.6.6/go.mod h1:0QXGEkbuJRohbJaxr7ZQSxnju7hEhseiPx2hrh6raOI=
|
||||
github.com/icza/bitio v1.0.0 h1:squ/m1SHyFeCA6+6Gyol1AxV9nmPPlJFT8c2vKdj3U8=
|
||||
github.com/icza/bitio v1.0.0/go.mod h1:0jGnlLAx8MKMr9VGnn/4YrvZiprkvBelsVIbA9Jjr9A=
|
||||
github.com/icza/mighty v0.0.0-20180919140131-cfd07d671de6 h1:8UsGZ2rr2ksmEru6lToqnXgA8Mz1DP11X4zSJ159C3k=
|
||||
|
@ -64,11 +64,10 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
|||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY=
|
||||
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
gitlab.com/tslocum/cbind v0.1.2-0.20200826214515-b5f2c6a8711a/go.mod h1:HfB7qAhHSZbn1rFK8M9SvSN5NG6ScAg/3h3iE6xdeeI=
|
||||
gitlab.com/tslocum/cbind v0.1.2 h1:ptDjO7WeOl1HglprsK18L8I9JeRkmtuBoBBaYw/6/Ow=
|
||||
gitlab.com/tslocum/cbind v0.1.2/go.mod h1:HfB7qAhHSZbn1rFK8M9SvSN5NG6ScAg/3h3iE6xdeeI=
|
||||
gitlab.com/tslocum/cview v1.4.9 h1:JXTXwqK3oC7WOQjCvs+NFq1WNUAyWOe0tqkj/tTVMSM=
|
||||
gitlab.com/tslocum/cview v1.4.9/go.mod h1:XWb+3I8x6aCVBa658HYVXb2wxsa9TK6TBc81W9pX/ss=
|
||||
gitlab.com/tslocum/cbind v0.1.3 h1:FT/fTQ4Yj3eo5021lB3IbkIt8eVtYGhrw/xur+cjvUU=
|
||||
gitlab.com/tslocum/cbind v0.1.3/go.mod h1:RvwYE3auSjBNlCmWeGspzn+jdLUVQ8C2QGC+0nP9ChI=
|
||||
gitlab.com/tslocum/cview v1.5.1-0.20201021172753-ac2b3155fd44 h1:4oN43HBOdpsUVdHKyGb0GiIJQ9IvJxdFCAV9c6VgRPY=
|
||||
gitlab.com/tslocum/cview v1.5.1-0.20201021172753-ac2b3155fd44/go.mod h1:IEfcfqcDG4Tm28XM+H8TEtbrqjpieAewfcJvQ9SgcRM=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
|
@ -76,15 +75,15 @@ golang.org/x/exp v0.0.0-20180710024300-14dda7b62fcd h1:nLIcFw7GiqKXUS7HiChg6OAYW
|
|||
golang.org/x/exp v0.0.0-20180710024300-14dda7b62fcd/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4=
|
||||
golang.org/x/exp v0.0.0-20200908183739-ae8ad444f925 h1:5XVKs2rlCg8EFyRcvO8/XFwYxh1oKJO1Q3X5vttIf9c=
|
||||
golang.org/x/exp v0.0.0-20200908183739-ae8ad444f925/go.mod h1:1phAWC201xIgDyaFpmDeZkgf70Q4Pd/CNqfRtVPtxNw=
|
||||
golang.org/x/exp v0.0.0-20201008143054-e3b2a7f2fdc7 h1:2/QncOxxpPAdiH+E00abYw/SaQG353gltz79Nl1zrYE=
|
||||
golang.org/x/exp v0.0.0-20201008143054-e3b2a7f2fdc7/go.mod h1:1phAWC201xIgDyaFpmDeZkgf70Q4Pd/CNqfRtVPtxNw=
|
||||
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81 h1:00VmoueYNlNz/aHIilyyQz/MHSqGoWJzpFv/HW8xpzI=
|
||||
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
|
||||
golang.org/x/image v0.0.0-20190220214146-31aff87c08e9/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20200801110659-972c09e46d76 h1:U7GPaoQyQmX+CBRWXKrvRzWTbd+slqeSh8uARsIyhAw=
|
||||
golang.org/x/image v0.0.0-20200801110659-972c09e46d76/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5 h1:QelT11PB4FXiDEXucrfNckHoFxwt8USGY1ajP1ZF5lM=
|
||||
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/mobile v0.0.0-20180806140643-507816974b79 h1:t2JRgCWkY7Qaa1J2jal+wqC9OjbyHCHwIA9rVlRUSMo=
|
||||
golang.org/x/mobile v0.0.0-20180806140643-507816974b79/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||
|
@ -108,9 +107,9 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||
golang.org/x/sys v0.0.0-20190429190828-d89cdac9e872/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200908134130-d2e65c121b96 h1:gJciq3lOg0eS9fSZJcoHfv7q1BfC6cJfnmSSKL1yu3Q=
|
||||
golang.org/x/sys v0.0.0-20200908134130-d2e65c121b96/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201013132646-2da7054afaeb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201020230747-6e5568b54d1a h1:e3IU37lwO4aq3uoRKINC7JikojFmE5gO7xhfxs8VC34=
|
||||
golang.org/x/sys v0.0.0-20201020230747-6e5568b54d1a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
|
|
87
gui.go
87
gui.go
|
@ -18,6 +18,8 @@ import (
|
|||
"gitlab.com/tslocum/cview"
|
||||
)
|
||||
|
||||
const defaultLayout = "main,queue,playing"
|
||||
|
||||
var (
|
||||
app *cview.Application
|
||||
mainList *cview.List
|
||||
|
@ -71,32 +73,59 @@ func initTUI() error {
|
|||
|
||||
app.SetBeforeFocusFunc(handleBeforeFocus)
|
||||
|
||||
grid := cview.NewGrid().SetRows(-2, -1, 1, 1).SetColumns(-1)
|
||||
grid := cview.NewGrid()
|
||||
grid.SetColumns(-1)
|
||||
|
||||
mainList = cview.NewList().
|
||||
ShowSecondaryText(false).
|
||||
SetScrollBarVisibility(cview.ScrollBarAlways).
|
||||
SetHighlightFullLine(true).
|
||||
SetSelectedTextColor(tcell.ColorBlack)
|
||||
queueList = cview.NewList().
|
||||
ShowSecondaryText(false).
|
||||
SetScrollBarVisibility(cview.ScrollBarAlways).
|
||||
SetHighlightFullLine(true).
|
||||
SetSelectedTextColor(tcell.ColorBlack)
|
||||
topstatusbuf = cview.NewTextView().SetWrap(false).SetWordWrap(false)
|
||||
bottomstatusbuf = cview.NewTextView().SetWrap(false).SetWordWrap(false)
|
||||
mainList = cview.NewList()
|
||||
mainList.ShowSecondaryText(false)
|
||||
mainList.SetScrollBarVisibility(cview.ScrollBarAlways)
|
||||
mainList.SetHighlightFullLine(true)
|
||||
mainList.SetSelectedTextColor(tcell.ColorBlack)
|
||||
|
||||
mainList.SetBorder(true).SetTitleAlign(cview.AlignLeft)
|
||||
queueList = cview.NewList()
|
||||
queueList.ShowSecondaryText(false)
|
||||
queueList.SetScrollBarVisibility(cview.ScrollBarAlways)
|
||||
queueList.SetHighlightFullLine(true)
|
||||
queueList.SetSelectedTextColor(tcell.ColorBlack)
|
||||
|
||||
topstatusbuf = cview.NewTextView()
|
||||
topstatusbuf.SetWrap(false)
|
||||
topstatusbuf.SetWordWrap(false)
|
||||
bottomstatusbuf = cview.NewTextView()
|
||||
bottomstatusbuf.SetWrap(false)
|
||||
bottomstatusbuf.SetWordWrap(false)
|
||||
|
||||
mainList.SetBorder(true)
|
||||
mainList.SetTitleAlign(cview.AlignLeft)
|
||||
mainList.SetSelectedFunc(handleMainSelection)
|
||||
|
||||
queueList.SetBorder(true).SetTitleAlign(cview.AlignLeft).SetTitle(" Queue ")
|
||||
queueList.SetBorder(true)
|
||||
queueList.SetTitleAlign(cview.AlignLeft)
|
||||
queueList.SetTitle(" Queue ")
|
||||
queueList.SetSelectedFunc(handleQueueSelection)
|
||||
queueList.SetSelectedAlwaysCentered(true)
|
||||
|
||||
grid.AddItem(mainList, 0, 0, 1, 1, 0, 0, false)
|
||||
grid.AddItem(queueList, 1, 0, 1, 1, 0, 0, false)
|
||||
grid.AddItem(topstatusbuf, 2, 0, 1, 1, 0, 0, false)
|
||||
grid.AddItem(bottomstatusbuf, 3, 0, 1, 1, 0, 0, false)
|
||||
var i int
|
||||
var rowHeights []int
|
||||
ls := strings.Split(config.Layout, ",")
|
||||
for _, l := range ls {
|
||||
l = strings.ToLower(strings.TrimSpace(l))
|
||||
switch l {
|
||||
case "main":
|
||||
grid.AddItem(mainList, i, 0, 1, 1, 0, 0, false)
|
||||
rowHeights = append(rowHeights, -2)
|
||||
case "queue":
|
||||
grid.AddItem(queueList, i, 0, 1, 1, 0, 0, false)
|
||||
rowHeights = append(rowHeights, -1)
|
||||
case "playing":
|
||||
grid.AddItem(topstatusbuf, i, 0, 1, 1, 0, 0, false)
|
||||
grid.AddItem(bottomstatusbuf, i+1, 0, 1, 1, 0, 0, false)
|
||||
rowHeights = append(rowHeights, 1, 1)
|
||||
i++ // Use two rows
|
||||
}
|
||||
i++
|
||||
}
|
||||
grid.SetRows(rowHeights...)
|
||||
|
||||
app.SetRoot(grid, true)
|
||||
|
||||
|
@ -140,7 +169,7 @@ func browseFolder(browse string) {
|
|||
|
||||
mainList.SetTitle(" " + cview.Escape(runewidth.Truncate(mainDirectory, screenWidth-4, "...")) + "... ")
|
||||
|
||||
placeCursorAtTop := mainList.GetCurrentItem() == 0
|
||||
placeCursorAtTop := mainList.GetCurrentItemIndex() == 0
|
||||
mainFiles = scanFolder(browse)
|
||||
if mainCursor == -1 {
|
||||
if !placeCursorAtTop && len(mainFiles) > 0 {
|
||||
|
@ -218,8 +247,8 @@ func updateMain() {
|
|||
|
||||
mainOffset := 0
|
||||
if mainCursor == -1 {
|
||||
mainCursor = mainList.GetCurrentItem()
|
||||
mainOffset = mainList.GetOffset()
|
||||
mainCursor = mainList.GetCurrentItemIndex()
|
||||
mainOffset, _ = mainList.GetOffset()
|
||||
}
|
||||
mainList.Clear()
|
||||
|
||||
|
@ -234,7 +263,7 @@ func updateMain() {
|
|||
}
|
||||
line = cview.Escape(line)
|
||||
|
||||
mainList.AddItem(line, "", 0, nil)
|
||||
mainList.AddItem(cview.NewListItem(line))
|
||||
|
||||
printed++
|
||||
|
||||
|
@ -252,7 +281,7 @@ func updateMain() {
|
|||
}
|
||||
line = cview.Escape(line)
|
||||
|
||||
mainList.AddItem(line, "", 0, nil)
|
||||
mainList.AddItem(cview.NewListItem(line))
|
||||
|
||||
printed++
|
||||
}
|
||||
|
@ -263,7 +292,7 @@ func updateMain() {
|
|||
mainList.SetCurrentItem(mainCursor)
|
||||
}
|
||||
|
||||
mainList.SetOffset(mainOffset)
|
||||
mainList.SetOffset(mainOffset, 0)
|
||||
mainCursor = -1
|
||||
}
|
||||
|
||||
|
@ -274,7 +303,7 @@ func updateQueue() {
|
|||
queueBuffer.Reset()
|
||||
|
||||
if queueCursor == -1 {
|
||||
queueCursor = queueList.GetCurrentItem()
|
||||
queueCursor = queueList.GetCurrentItemIndex()
|
||||
}
|
||||
queueList.Clear()
|
||||
|
||||
|
@ -286,7 +315,7 @@ func updateQueue() {
|
|||
//lineWidth := runewidth.StringWidth(line)
|
||||
line = cview.Escape(line)
|
||||
|
||||
queueList.AddItem(line, "", 0, nil)
|
||||
queueList.AddItem(cview.NewListItem(line))
|
||||
|
||||
/*m := entry.Metadata.Length / time.Minute
|
||||
length = fmt.Sprintf(" %d:%02d", m, (entry.Metadata.Length%(m*time.Minute))/time.Second)*/
|
||||
|
@ -467,10 +496,10 @@ func handleResize(width int, height int) {
|
|||
updateStatus()
|
||||
}
|
||||
|
||||
func handleMainSelection(i int, s string, s2 string, r rune) {
|
||||
func handleMainSelection(i int, item *cview.ListItem) {
|
||||
go listSelect(i)
|
||||
}
|
||||
|
||||
func handleQueueSelection(i int, s string, s2 string, r rune) {
|
||||
func handleQueueSelection(i int, item *cview.ListItem) {
|
||||
go queueSelect(i)
|
||||
}
|
||||
|
|
22
gui_list.go
22
gui_list.go
|
@ -41,9 +41,9 @@ func queueNext() {
|
|||
|
||||
func listSelectCurrent() {
|
||||
if queueFocused {
|
||||
go queueSelect(queueList.GetCurrentItem())
|
||||
go queueSelect(queueList.GetCurrentItemIndex())
|
||||
} else {
|
||||
go listSelect(mainList.GetCurrentItem())
|
||||
go listSelect(mainList.GetCurrentItemIndex())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ func queueSelect(cursor int) {
|
|||
}
|
||||
|
||||
func listQueue() {
|
||||
if mainList.GetCurrentItem() == 0 {
|
||||
if mainList.GetCurrentItemIndex() == 0 {
|
||||
// TODO Show error
|
||||
return
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ func listQueue() {
|
|||
queueLock.Unlock()
|
||||
|
||||
if !disableAutoplay && playingFileID == 0 && len(queueFiles) > 0 {
|
||||
queueSelect(queueList.GetCurrentItem())
|
||||
queueSelect(queueList.GetCurrentItemIndex())
|
||||
}
|
||||
go app.QueueUpdateDraw(updateQueue)
|
||||
return
|
||||
|
@ -134,7 +134,7 @@ func listQueue() {
|
|||
queueFiles = append(queueFiles, entry)
|
||||
|
||||
if !disableAutoplay && playingFileID == 0 {
|
||||
queueSelect(queueList.GetCurrentItem())
|
||||
queueSelect(queueList.GetCurrentItemIndex())
|
||||
}
|
||||
go app.QueueUpdateDraw(updateLists)
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ func listDelete() {
|
|||
queueLock.Lock()
|
||||
defer queueLock.Unlock()
|
||||
|
||||
cursor := queueList.GetCurrentItem()
|
||||
cursor := queueList.GetCurrentItemIndex()
|
||||
|
||||
if cursor < 0 || len(queueFiles) <= cursor {
|
||||
return
|
||||
|
@ -159,7 +159,7 @@ func listDelete() {
|
|||
}
|
||||
|
||||
func selectedMainEntry() *libraryEntry {
|
||||
cursor := mainList.GetCurrentItem()
|
||||
cursor := mainList.GetCurrentItemIndex()
|
||||
if cursor < 0 || cursor-1 > len(mainFiles) {
|
||||
return nil
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ func selectedMainEntry() *libraryEntry {
|
|||
}
|
||||
|
||||
func offsetMainEntry(offset int) *libraryEntry {
|
||||
cursor := mainList.GetCurrentItem()
|
||||
cursor := mainList.GetCurrentItemIndex()
|
||||
if (cursor-1)+offset < 0 || (cursor-1)+offset >= len(mainFiles) {
|
||||
return nil
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ func offsetMainEntry(offset int) *libraryEntry {
|
|||
}
|
||||
|
||||
func selectedQueueEntry() *libraryEntry {
|
||||
cursor := queueList.GetCurrentItem()
|
||||
cursor := queueList.GetCurrentItemIndex()
|
||||
if cursor < 0 || cursor-1 > len(queueFiles) {
|
||||
return nil
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ func selectedQueueEntry() *libraryEntry {
|
|||
}
|
||||
|
||||
func offsetQueueEntry(offset int) *libraryEntry {
|
||||
cursor := queueList.GetCurrentItem()
|
||||
cursor := queueList.GetCurrentItemIndex()
|
||||
if cursor+offset < 0 || cursor+offset >= len(queueFiles) {
|
||||
return nil
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ func listNextPage() {
|
|||
}
|
||||
|
||||
func listRefresh() {
|
||||
mainCursor = mainList.GetCurrentItem()
|
||||
mainCursor = mainList.GetCurrentItemIndex()
|
||||
d := mainDirectory
|
||||
|
||||
mainDirectory = ""
|
||||
|
|
1
main.go
1
main.go
|
@ -52,6 +52,7 @@ func main() {
|
|||
|
||||
flag.StringVar(&configPath, "config", "", "path to configuration file")
|
||||
flag.BoolVar(&printVersionInfo, "version", false, "print version information and exit")
|
||||
flag.StringVar(&config.Layout, "layout", defaultLayout, "layout of interface elements")
|
||||
flag.IntVar(&streamFdInt, "fd", -1, "stream audio to file descriptor")
|
||||
flag.IntVar(&startingVolumeFlag, "volume", -1, "initial volume level 0-100")
|
||||
flag.StringVar(&restrictLibrary, "restrict-library", "", "restrict library to path")
|
||||
|
|
Loading…
Reference in a new issue