feat: add jump-to-panel label setting

This commit is contained in:
Maria José Solano 2023-09-06 18:16:53 -07:00 committed by Stefan Haller
parent 917eb88617
commit 387fbf6ab6
6 changed files with 30 additions and 0 deletions

View file

@ -76,6 +76,7 @@ gui:
showRandomTip: true
showBranchCommitHash: false # show commit hashes alongside branch names
showBottomLine: true # for hiding the bottom information line (unless it has important information to tell you)
showPanelJumps: true # for showing the jump-to-panel keybindings as panel subtitles
showCommandLog: true
showIcons: false # deprecated: use nerdFontsVersion instead
nerdFontsVersion: "" # nerd fonts version to use ("2" or "3"); empty means don't show nerd font icons

View file

@ -50,6 +50,7 @@ type GuiConfig struct {
ShowRandomTip bool `yaml:"showRandomTip"`
ShowCommandLog bool `yaml:"showCommandLog"`
ShowBottomLine bool `yaml:"showBottomLine"`
ShowPanelJumps bool `yaml:"showPanelJumps"`
ShowIcons bool `yaml:"showIcons"`
NerdFontsVersion string `yaml:"nerdFontsVersion"`
ShowBranchCommitHash bool `yaml:"showBranchCommitHash"`
@ -456,6 +457,7 @@ func GetDefaultConfig() *UserConfig {
ShowListFooter: true,
ShowCommandLog: true,
ShowBottomLine: true,
ShowPanelJumps: true,
ShowFileTree: true,
ShowRandomTip: true,
ShowIcons: false,

View file

@ -63,6 +63,7 @@ func (self *SubCommitsHelper) ViewSubCommits(opts ViewSubCommitsOpts) error {
subCommitsContext.SetShowBranchHeads(opts.ShowBranchHeads)
subCommitsContext.ClearSearchString()
subCommitsContext.GetView().ClearSearch()
subCommitsContext.GetView().TitlePrefix = opts.Context.GetView().TitlePrefix
err = self.c.PostRefreshUpdate(self.c.Contexts().SubCommits)
if err != nil {

View file

@ -109,6 +109,7 @@ func (self *RemotesController) enter(remote *models.Remote) error {
remoteBranchesContext.SetSelectedLineIdx(newSelectedLine)
remoteBranchesContext.SetTitleRef(remote.Name)
remoteBranchesContext.SetParentContext(self.Context())
remoteBranchesContext.GetView().TitlePrefix = self.Context().GetView().TitlePrefix
if err := self.c.PostRefreshUpdate(remoteBranchesContext); err != nil {
return err

View file

@ -84,6 +84,7 @@ func (self *SwitchToDiffFilesController) viewFiles(opts SwitchToCommitFilesConte
diffFilesContext.SetParentContext(opts.Context)
diffFilesContext.SetWindowName(opts.Context.GetWindowName())
diffFilesContext.ClearSearchString()
diffFilesContext.GetView().TitlePrefix = opts.Context.GetView().TitlePrefix
if err := self.c.Refresh(types.RefreshOptions{
Scope: []types.RefreshableView{types.COMMIT_FILES},

View file

@ -1,6 +1,8 @@
package gui
import (
"fmt"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/theme"
"github.com/samber/lo"
@ -186,5 +188,27 @@ func (gui *Gui) createAllViews() error {
gui.Views.Snake.Title = gui.c.Tr.SnakeTitle
gui.Views.Snake.FgColor = gocui.ColorGreen
if gui.c.UserConfig.Gui.ShowPanelJumps {
jumpBindings := gui.c.UserConfig.Keybinding.Universal.JumpToBlock
jumpLabels := lo.Map(jumpBindings, func(binding string, _ int) string {
return fmt.Sprintf("[%s]", binding)
})
gui.Views.Status.TitlePrefix = jumpLabels[0]
gui.Views.Files.TitlePrefix = jumpLabels[1]
gui.Views.Worktrees.TitlePrefix = jumpLabels[1]
gui.Views.Submodules.TitlePrefix = jumpLabels[1]
gui.Views.Branches.TitlePrefix = jumpLabels[2]
gui.Views.Remotes.TitlePrefix = jumpLabels[2]
gui.Views.Tags.TitlePrefix = jumpLabels[2]
gui.Views.Commits.TitlePrefix = jumpLabels[3]
gui.Views.ReflogCommits.TitlePrefix = jumpLabels[3]
gui.Views.Stash.TitlePrefix = jumpLabels[4]
}
return nil
}