mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-21 00:30:00 +02:00
softcode cyclable views
This commit is contained in:
@ -172,7 +172,7 @@ func (gui *Gui) currentCyclableViewName() string {
|
|||||||
if currView != nil {
|
if currView != nil {
|
||||||
viewName := currView.Name()
|
viewName := currView.Name()
|
||||||
usePreviousView := true
|
usePreviousView := true
|
||||||
for _, view := range cyclableViews {
|
for _, view := range gui.getCyclableViews() {
|
||||||
if view == viewName {
|
if view == viewName {
|
||||||
currentCyclebleView = viewName
|
currentCyclebleView = viewName
|
||||||
usePreviousView = false
|
usePreviousView = false
|
||||||
|
@ -12,7 +12,9 @@ import (
|
|||||||
"github.com/spkg/bom"
|
"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
|
// models/views that we can refresh
|
||||||
const (
|
const (
|
||||||
@ -140,6 +142,7 @@ func (gui *Gui) refreshSidePanels(options refreshOptions) error {
|
|||||||
|
|
||||||
func (gui *Gui) nextView(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) nextView(g *gocui.Gui, v *gocui.View) error {
|
||||||
var focusedViewName string
|
var focusedViewName string
|
||||||
|
cyclableViews := gui.getCyclableViews()
|
||||||
if v == nil || v.Name() == cyclableViews[len(cyclableViews)-1] {
|
if v == nil || v.Name() == cyclableViews[len(cyclableViews)-1] {
|
||||||
focusedViewName = cyclableViews[0]
|
focusedViewName = cyclableViews[0]
|
||||||
} else {
|
} else {
|
||||||
@ -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 {
|
func (gui *Gui) previousView(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
cyclableViews := gui.getCyclableViews()
|
||||||
var focusedViewName string
|
var focusedViewName string
|
||||||
if v == nil || v.Name() == cyclableViews[0] {
|
if v == nil || v.Name() == cyclableViews[0] {
|
||||||
focusedViewName = cyclableViews[len(cyclableViews)-1]
|
focusedViewName = cyclableViews[len(cyclableViews)-1]
|
||||||
|
Reference in New Issue
Block a user