1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-02-03 13:21:56 +02:00

moving loader and adding previous view function (unfinished)

This commit is contained in:
Jesse Duffield 2018-07-22 12:07:36 +10:00
parent f0447be989
commit 5dbe262d2d
2 changed files with 32 additions and 9 deletions

9
gui.go
View File

@ -279,15 +279,6 @@ func fetch(g *gocui.Gui) {
refreshStatus(g)
}
func loader() string {
characters := "|/-\\"
now := time.Now()
nanos := now.UnixNano()
index := nanos / 50000000 % int64(len(characters))
devLog(characters[index : index+1])
return characters[index : index+1]
}
func updateLoader(g *gocui.Gui) {
if confirmationView, _ := g.View("confirmation"); confirmationView != nil {
content := trimmedContent(confirmationView)

View File

@ -4,6 +4,7 @@ import (
"fmt"
"sort"
"strings"
"time"
"github.com/jesseduffield/gocui"
)
@ -40,6 +41,29 @@ func nextView(g *gocui.Gui, v *gocui.View) error {
return switchFocus(g, v, focusedView)
}
func previousView(g *gocui.Gui, v *gocui.View) error {
var focusedViewName string
if v == nil || v.Name() == cyclableViews[len(cyclableViews)-1] {
focusedViewName = cyclableViews[0]
} else {
for i := range cyclableViews {
if v.Name() == cyclableViews[i] {
focusedViewName = cyclableViews[i-1] // TODO: make this work properly
break
}
if i == len(cyclableViews)-1 {
devLog(v.Name() + " is not in the list of views")
return nil
}
}
}
focusedView, err := g.View(focusedViewName)
if err != nil {
panic(err)
}
return switchFocus(g, v, focusedView)
}
func newLineFocused(g *gocui.Gui, v *gocui.View) error {
mainView, _ := g.View("main")
mainView.SetOrigin(0, 0)
@ -198,3 +222,11 @@ func optionsMapToString(optionsMap map[string]string) string {
func renderOptionsMap(g *gocui.Gui, optionsMap map[string]string) error {
return renderString(g, "options", optionsMapToString(optionsMap))
}
func loader() string {
characters := "|/-\\"
now := time.Now()
nanos := now.UnixNano()
index := nanos / 50000000 % int64(len(characters))
return characters[index : index+1]
}