|
|
|
@ -26,10 +26,10 @@ var (
|
|
|
|
|
topstatusbuf *cview.TextView |
|
|
|
|
bottomstatusbuf *cview.TextView |
|
|
|
|
|
|
|
|
|
mainBufferText string |
|
|
|
|
mainBufferFiles []*LibraryEntry |
|
|
|
|
mainBufferCursor int |
|
|
|
|
mainBufferDirectory string |
|
|
|
|
mainBufferOrigin int |
|
|
|
|
|
|
|
|
|
seekStart, seekEnd int |
|
|
|
|
volumeStart, volumeEnd int |
|
|
|
@ -86,14 +86,6 @@ func browseFolder(browse string) {
|
|
|
|
|
|
|
|
|
|
mainBufferFiles = scanFolder(browse) |
|
|
|
|
|
|
|
|
|
var b strings.Builder |
|
|
|
|
b.WriteString("..") |
|
|
|
|
for _, entry := range mainBufferFiles { |
|
|
|
|
b.WriteRune('\n') |
|
|
|
|
|
|
|
|
|
b.WriteString(entry.String()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if len(mainBufferFiles) > 0 { |
|
|
|
|
mainBufferCursor = 1 |
|
|
|
|
} else { |
|
|
|
@ -101,8 +93,6 @@ func browseFolder(browse string) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
mainBufferDirectory = browse |
|
|
|
|
mainBufferText = b.String() |
|
|
|
|
|
|
|
|
|
app.QueueUpdateDraw(updateMain) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -135,28 +125,34 @@ func updateMain() {
|
|
|
|
|
var printed int |
|
|
|
|
|
|
|
|
|
var newBufferText string |
|
|
|
|
if mainBufferCursor == 0 { |
|
|
|
|
newBufferText += "[::r]" |
|
|
|
|
} |
|
|
|
|
var line string |
|
|
|
|
if mainBufferDirectory == "/" { |
|
|
|
|
line = "./" |
|
|
|
|
} else { |
|
|
|
|
line = "../" |
|
|
|
|
} |
|
|
|
|
newBufferText += line |
|
|
|
|
for i := len(line); i < screenWidth-2; i++ { |
|
|
|
|
newBufferText += " " |
|
|
|
|
} |
|
|
|
|
if mainBufferCursor == 0 { |
|
|
|
|
newBufferText += "[-]" |
|
|
|
|
} |
|
|
|
|
if len(mainBufferFiles) > 0 { |
|
|
|
|
newBufferText += "\n" |
|
|
|
|
if mainBufferOrigin == 0 { |
|
|
|
|
if mainBufferCursor == 0 { |
|
|
|
|
newBufferText += "[::r]" |
|
|
|
|
} |
|
|
|
|
var line string |
|
|
|
|
if mainBufferDirectory == "/" { |
|
|
|
|
line = "./" |
|
|
|
|
} else { |
|
|
|
|
line = "../" |
|
|
|
|
} |
|
|
|
|
newBufferText += line |
|
|
|
|
for i := len(line); i < screenWidth-2; i++ { |
|
|
|
|
newBufferText += " " |
|
|
|
|
} |
|
|
|
|
if mainBufferCursor == 0 { |
|
|
|
|
newBufferText += "[-]" |
|
|
|
|
} |
|
|
|
|
printed++ |
|
|
|
|
} |
|
|
|
|
printed++ |
|
|
|
|
|
|
|
|
|
for i, entry := range mainBufferFiles { |
|
|
|
|
if i < mainBufferOrigin-1 || i-mainBufferOrigin-1 > mainBufHeight-1 { |
|
|
|
|
continue |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if printed > 0 { |
|
|
|
|
newBufferText += "\n" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if i == mainBufferCursor-1 { |
|
|
|
|
newBufferText += "[::r]" |
|
|
|
|
} |
|
|
|
@ -175,13 +171,9 @@ func updateMain() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
printed++ |
|
|
|
|
if printed == mainBufHeight { |
|
|
|
|
if printed == mainBufHeight-2 { |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if i < len(mainBufferFiles)-1 { |
|
|
|
|
newBufferText += "\n" |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
mainbuf.SetText(newBufferText) |
|
|
|
@ -314,17 +306,16 @@ func selectTrack() {
|
|
|
|
|
browseFolder(path.Join(mainBufferDirectory, "..")) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
nextStreamer = nil |
|
|
|
|
nextFormat = beep.Format{} |
|
|
|
|
|
|
|
|
|
selected := mainBufferFiles[mainBufferCursor-1] |
|
|
|
|
if selected.File.IsDir() { |
|
|
|
|
browseFolder(path.Join(mainBufferDirectory, path.Base(selected.File.Name()))) |
|
|
|
|
entry := selectedEntry() |
|
|
|
|
if entry.File.IsDir() { |
|
|
|
|
browseFolder(path.Join(mainBufferDirectory, path.Base(entry.File.Name()))) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
audioFile, err := openFile(path.Join(mainBufferDirectory, mainBufferFiles[mainBufferCursor-1].File.Name())) |
|
|
|
|
audioFile, err := openFile(path.Join(mainBufferDirectory, entry.File.Name())) |
|
|
|
|
if err != nil { |
|
|
|
|
statusText = err.Error() |
|
|
|
|
go func() { |
|
|
|
|