1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-10-20 19:12:29 +03:00

Replace paging config with an array of pagers

This commit is contained in:
Stefan Haller
2025-10-08 16:22:17 +02:00
parent 765c9eb85c
commit e44d6ec330
9 changed files with 191 additions and 78 deletions

View File

@@ -1,6 +1,8 @@
package controllers
import (
"fmt"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
@@ -58,6 +60,13 @@ func (self *GlobalController) GetKeybindings(opts types.KeybindingsOpts) []*type
Handler: opts.Guards.NoPopupPanel(self.prevScreenMode),
Description: self.c.Tr.PrevScreenMode,
},
{
Key: opts.GetKey(opts.Config.Universal.CyclePagers),
Handler: opts.Guards.NoPopupPanel(self.cyclePagers),
GetDisabledReason: self.canCyclePagers,
Description: self.c.Tr.CyclePagers,
Tooltip: self.c.Tr.CyclePagersTooltip,
},
{
Key: opts.GetKey(opts.Config.Universal.Return),
Modifier: gocui.ModNone,
@@ -171,6 +180,27 @@ func (self *GlobalController) prevScreenMode() error {
return (&ScreenModeActions{c: self.c}).Prev()
}
func (self *GlobalController) cyclePagers() error {
self.c.State().GetPagerConfig().CyclePagers()
if self.c.Context().CurrentSide().GetKey() == self.c.Context().Current().GetKey() {
self.c.Context().CurrentSide().HandleFocus(types.OnFocusOpts{})
}
current, total := self.c.State().GetPagerConfig().CurrentPagerIndex()
self.c.Toast(fmt.Sprintf("Selected pager %d of %d", current+1, total))
return nil
}
func (self *GlobalController) canCyclePagers() *types.DisabledReason {
_, total := self.c.State().GetPagerConfig().CurrentPagerIndex()
if total <= 1 {
return &types.DisabledReason{
Text: self.c.Tr.CyclePagersDisabledReason,
}
}
return nil
}
func (self *GlobalController) createOptionsMenu() error {
return (&OptionsMenuAction{c: self.c}).Call()
}