Skip to content

Commit

Permalink
softcode cyclable views
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed May 17, 2020
1 parent e3375fb commit afd092c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/gui/arrangement.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (gui *Gui) currentCyclableViewName() string {
if currView != nil {
viewName := currView.Name()
usePreviousView := true
for _, view := range cyclableViews {
for _, view := range gui.getCyclableViews() {
if view == viewName {
currentCyclebleView = viewName
usePreviousView = false
Expand Down
6 changes: 5 additions & 1 deletion pkg/gui/view_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import (
"github.com/spkg/bom"
)

var cyclableViews = []string{"status", "files", "branches", "commits", "stash"}
func (gui *Gui) getCyclableViews() []string {
return []string{"status", "files", "branches", "commits", "stash"}
}

// models/views that we can refresh
const (
Expand Down Expand Up @@ -140,6 +142,7 @@ func (gui *Gui) refreshSidePanels(options refreshOptions) error {

func (gui *Gui) nextView(g *gocui.Gui, v *gocui.View) error {
var focusedViewName string
cyclableViews := gui.getCyclableViews()
if v == nil || v.Name() == cyclableViews[len(cyclableViews)-1] {
focusedViewName = cyclableViews[0]
} else {
Expand Down Expand Up @@ -176,6 +179,7 @@ func (gui *Gui) nextView(g *gocui.Gui, v *gocui.View) error {
}

func (gui *Gui) previousView(g *gocui.Gui, v *gocui.View) error {
cyclableViews := gui.getCyclableViews()
var focusedViewName string
if v == nil || v.Name() == cyclableViews[0] {
focusedViewName = cyclableViews[len(cyclableViews)-1]
Expand Down

0 comments on commit afd092c

Please sign in to comment.