summaryrefslogtreecommitdiffstats
path: root/pkg/gui/status_panel.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2018-08-13 20:26:02 +1000
committerJesse Duffield <jessedduffield@gmail.com>2018-08-13 20:26:02 +1000
commit97cff656121270e9c790432e28622d92ab7b0f1a (patch)
tree7425013e94dc0a19699b48bde6bb20c6f5b86c8a /pkg/gui/status_panel.go
parentf9c39ad64bddd1577636c0ce5606eda44bc704ef (diff)
progress on refactor
Diffstat (limited to 'pkg/gui/status_panel.go')
-rw-r--r--pkg/gui/status_panel.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/pkg/gui/status_panel.go b/pkg/gui/status_panel.go
new file mode 100644
index 000000000..822be2846
--- /dev/null
+++ b/pkg/gui/status_panel.go
@@ -0,0 +1,41 @@
+package gui
+
+import (
+ "fmt"
+
+ "github.com/fatih/color"
+ "github.com/jesseduffield/gocui"
+)
+
+func refreshStatus(g *gocui.Gui) error {
+ v, err := g.View("status")
+ if err != nil {
+ panic(err)
+ }
+ // 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 := git.UpstreamDifferenceCount()
+ fmt.Fprint(v, "↑"+pushables+"↓"+pullables)
+ branches := state.Branches
+ if err := updateHasMergeConflictStatus(); err != nil {
+ return err
+ }
+ if state.HasMergeConflicts {
+ fmt.Fprint(v, coloredString(" (merging)", color.FgYellow))
+ }
+
+ if len(branches) == 0 {
+ return nil
+ }
+ branch := branches[0]
+ name := coloredString(branch.Name, branch.getColor())
+ repo := getCurrentProject()
+ fmt.Fprint(v, " "+repo+" → "+name)
+ return nil
+ })
+
+ return nil
+}