diff options
| author | Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com> | 2018-12-08 03:12:52 +0300 |
|---|---|---|
| committer | Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com> | 2018-12-08 03:12:52 +0300 |
| commit | 46e22a8968f72895622c56b1e7fa554bb501371c (patch) | |
| tree | 61e5a168cadccebfc9e994613be1aeb8a1ac7542 /pkg/gui/stashview.go | |
| parent | reduced coupling in view navigation logic and minor refactor (diff) | |
| download | gitbatch-46e22a8968f72895622c56b1e7fa554bb501371c.tar.gz | |
status implementation cntd.. added display and navigation
Diffstat (limited to 'pkg/gui/stashview.go')
| -rw-r--r-- | pkg/gui/stashview.go | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/pkg/gui/stashview.go b/pkg/gui/stashview.go new file mode 100644 index 0000000..8cdc46c --- /dev/null +++ b/pkg/gui/stashview.go @@ -0,0 +1,47 @@ +package gui + +import ( + "fmt" + + "github.com/isacikgoz/gitbatch/pkg/git" + "github.com/jroimartin/gocui" +) + +// stash view +func (gui *Gui) openStashView(g *gocui.Gui) error { + maxX, maxY := g.Size() + + v, err := g.SetView(stashViewFeature.Name, 6, int(0.75*float32(maxY)), maxX-6, maxY-3) + if err != nil { + if err != gocui.ErrUnknownView { + return err + } + v.Title = stashViewFeature.Title + v.Wrap = true + } + entity := gui.getSelectedRepository() + if err := refreshStashView(g, entity); err != nil { + return err + } + return nil +} + +// refresh the main view and re-render the repository representations +func refreshStashView(g *gocui.Gui, entity *git.RepoEntity) error { + stashView, err := g.View(stashViewFeature.Name) + if err != nil { + return err + } + stashView.Clear() + _, cy := stashView.Cursor() + _, oy := stashView.Origin() + stashedItems := entity.Stasheds + for i, stashedItem := range stashedItems { + var prefix string + if i == cy+oy { + prefix = prefix + selectionIndicator + } + fmt.Fprintf(stashView, "%s%d %s: %s (%s)\n", prefix, stashedItem.StashID, cyan.Sprint(stashedItem.BranchName), stashedItem.Description, stashedItem.Hash) + } + return nil +}
\ No newline at end of file |
