1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-22 05:29:44 +02:00
lazygit/status_panel.go

44 lines
1.1 KiB
Go
Raw Normal View History

2018-06-02 08:35:49 +10:00
package main
import (
"fmt"
"time"
"github.com/fatih/color"
2018-06-05 18:47:31 +10:00
"github.com/jesseduffield/gocui"
2018-06-02 08:35:49 +10:00
)
func refreshStatus(g *gocui.Gui) error {
v, err := g.View("status")
if err != nil {
2018-06-02 13:51:03 +10:00
panic(err)
2018-06-02 08:35:49 +10:00
}
2018-06-02 13:51:03 +10:00
// for some reason if this isn't wrapped in an update the clear seems to
// be applied after the other things or something like that; the panel's
// contents end up cleared
g.Update(func(*gocui.Gui) error {
v.Clear()
pushables, pullables := gitUpstreamDifferenceCount()
fmt.Fprint(v, "↑"+pushables+"↓"+pullables)
branches := state.Branches
2018-06-09 19:06:33 +10:00
if err := updateHasMergeConflictStatus(); err != nil {
return err
}
if state.HasMergeConflicts {
colour := color.New(color.FgYellow)
fmt.Fprint(v, coloredString(" (merging)", colour))
}
2018-06-02 13:51:03 +10:00
if len(branches) == 0 {
return nil
}
branch := branches[0]
// utilising the fact these all have padding to only grab the name
// from the display string with the existing coloring applied
fmt.Fprint(v, " "+branch.DisplayString[4:])
2018-06-05 19:30:55 +10:00
colorLog(color.FgCyan, time.Now().Sub(startTime))
2018-06-02 08:35:49 +10:00
return nil
2018-06-02 13:51:03 +10:00
})
2018-06-02 08:35:49 +10:00
return nil
}