2022-04-14 16:32:39 +00:00
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
2022-04-27 22:13:05 +00:00
|
|
|
"strings"
|
|
|
|
|
2022-04-14 16:32:39 +00:00
|
|
|
"git.bullercodeworks.com/brian/wandle"
|
2022-04-20 21:22:43 +00:00
|
|
|
"github.com/nsf/termbox-go"
|
2022-04-14 16:32:39 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
BrowseId = iota << 5
|
|
|
|
AboutId
|
|
|
|
)
|
|
|
|
|
|
|
|
type Ui struct {
|
|
|
|
wandle *wandle.Program
|
|
|
|
|
|
|
|
browseScreen *browseScreen
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewUi() *Ui {
|
|
|
|
u := new(Ui)
|
|
|
|
u.browseScreen = NewBrowseScreen(u)
|
|
|
|
u.wandle = wandle.NewProgram(u.browseScreen)
|
2022-04-20 21:22:43 +00:00
|
|
|
//u.wandle = wandle.NewProgram(NewAboutScreen(u))
|
|
|
|
u.wandle.Style(wandle.NewStyle(
|
|
|
|
termbox.RGBToAttribute(uint8(0), uint8(255), uint8(0)),
|
|
|
|
termbox.RGBToAttribute(uint8(0), uint8(0), uint8(0)),
|
|
|
|
))
|
2022-04-14 16:32:39 +00:00
|
|
|
return u
|
|
|
|
}
|
|
|
|
|
|
|
|
func (u *Ui) Start() error { return u.wandle.Start() }
|
2022-04-27 22:13:05 +00:00
|
|
|
|
|
|
|
// A few Helper Functions
|
|
|
|
func pathToString(p []string) string { return strings.Join(p, " → ") }
|
|
|
|
func comparePaths(p1, p2 []string) bool {
|
|
|
|
return pathToString(p1) == pathToString(p2)
|
|
|
|
}
|