Wrap selection back to beginning and viceversa
This commit is contained in:
parent
17bf35e591
commit
c96dcea8ac
|
@ -1,12 +1,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
//"fmt"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/jroimartin/gocui"
|
"github.com/jroimartin/gocui"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -20,8 +17,8 @@ func ui() {
|
||||||
}
|
}
|
||||||
defer g.Close()
|
defer g.Close()
|
||||||
g.SetManagerFunc(layout)
|
g.SetManagerFunc(layout)
|
||||||
g.Mouse = true
|
g.Mouse = false
|
||||||
g.Cursor = false
|
//g.Cursor = true
|
||||||
|
|
||||||
initKeybindings(g)
|
initKeybindings(g)
|
||||||
|
|
||||||
|
@ -83,7 +80,14 @@ func initKeybindings(g *gocui.Gui) error {
|
||||||
|
|
||||||
func scrollSongs(v *gocui.View, dy int) error {
|
func scrollSongs(v *gocui.View, dy int) error {
|
||||||
_, currentY := v.Cursor()
|
_, currentY := v.Cursor()
|
||||||
|
songs := v.BufferLines()
|
||||||
|
if currentY == len(songs)-2 && dy == +1 {
|
||||||
|
v.SetCursor(0, 0)
|
||||||
|
} else if currentY == 0 && dy == -1 {
|
||||||
|
v.SetCursor(0, len(songs)-2)
|
||||||
|
} else {
|
||||||
v.SetCursor(0, currentY+dy)
|
v.SetCursor(0, currentY+dy)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +100,9 @@ func playSong(g *gocui.Gui, v *gocui.View) error {
|
||||||
_, currentlySelected := v.Cursor()
|
_, currentlySelected := v.Cursor()
|
||||||
|
|
||||||
songs := v.BufferLines()
|
songs := v.BufferLines()
|
||||||
fmt.Fprintln(currentlyPlaying, fmt.Sprintf("Playing song number %v (%v)", currentlySelected, strings.TrimLeft(songs[currentlySelected], " ")))
|
fmt.Fprintln(currentlyPlaying, fmt.Sprintf("Playing song number %v (%v)", currentlySelected, songs[currentlySelected]))
|
||||||
|
// fmt.Fprintln(currentlyPlaying, len(songs))
|
||||||
|
// fmt.Fprintln(currentlyPlaying, currentlySelected)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue