diff options
| author | Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com> | 2018-12-05 01:24:48 +0300 |
|---|---|---|
| committer | Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com> | 2018-12-05 01:24:48 +0300 |
| commit | 357761313b00cb5799b2971631c4adfb2daaa98e (patch) | |
| tree | 24d56318bf578160c150b01c8e8f9ae06bc6da7b /pkg/gui/gui-util.go | |
| parent | queue converted to first in first out principle (diff) | |
| download | gitbatch-357761313b00cb5799b2971631c4adfb2daaa98e.tar.gz | |
added sorting
Diffstat (limited to 'pkg/gui/gui-util.go')
| -rw-r--r-- | pkg/gui/gui-util.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/pkg/gui/gui-util.go b/pkg/gui/gui-util.go index c09ae6c..d3f0934 100644 --- a/pkg/gui/gui-util.go +++ b/pkg/gui/gui-util.go @@ -1,6 +1,8 @@ package gui import ( + "sort" + "github.com/isacikgoz/gitbatch/pkg/git" "github.com/isacikgoz/gitbatch/pkg/helpers" "github.com/jroimartin/gocui" @@ -107,3 +109,26 @@ func writeRightHandSide(v *gocui.View, text string, cx, cy int) error { v.SetCursor(cx, cy) return nil } + +// sortByName sorts the repositories by A to Z order +func (gui *Gui) sortByName(g *gocui.Gui, v *gocui.View) error { + sort.Sort(git.Alphabetical(gui.State.Repositories)) + gui.refreshAfterSort(g) + return nil +} + +// sortByMod sorts the repositories according to last modifed date +// the top element will be the last modified +func (gui *Gui) sortByMod(g *gocui.Gui, v *gocui.View) error { + sort.Sort(git.LastModified(gui.State.Repositories)) + gui.refreshAfterSort(g) + return nil +} + +// utility function that refreshes main and side views after that +func (gui *Gui) refreshAfterSort(g *gocui.Gui) error { + gui.refreshMain(g) + entity := gui.getSelectedRepository() + gui.refreshViews(g, entity) + return nil +} |
