jesseduffield / lazygit

simple terminal UI for git commands
MIT License
53.05k stars 1.85k forks source link

Setting for including "jump to panel" mapping in panel titles #2982

Closed MariaSolOs closed 1 year ago

MariaSolOs commented 1 year ago

Disclaimer: I'm not sure if this is already supported, so I apologize in advance if that's the case.

Is your feature request related to a problem? Please describe. I would like something similar to what gitui has of showing the mapping besides panel titles.

Describe the solution you'd like For there to be a setting for showing those mapping suffixes.

Describe alternatives you've considered Try to memorize the mappings :(

Additional context Here's a picture of what I would like: image

MariaSolOs commented 1 year ago

@jesseduffield What do you think about this? :) If you find this a reasonable feature, I can work on the PR.

jesseduffield commented 1 year ago

Go for it @MariaSolOs !

Lazygit is different to gitui in that a window can have multiple tabs, so the question is, where do we show the [1]? Some ideas that come to mind:

I like the idea of using the view subtitle.

What do you think?

MariaSolOs commented 1 year ago

@jesseduffield the subtitle idea sounds GTM!

I'm having some issues even reading the new setting though :/

So far I've added just this:

diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go
index 4df6b567..fe5a6baf 100644
--- a/pkg/config/user_config.go
+++ b/pkg/config/user_config.go
@@ -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:            false,
                        ShowFileTree:              true,
                        ShowRandomTip:             true,
                        ShowIcons:                 false,
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 4be909dc..2f2c2974 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -638,6 +638,8 @@ func (gui *Gui) Run(startArgs appTypes.StartArgs) error {

        gui.g.ShowListFooter = userConfig.Gui.ShowListFooter

+       gui.g.ShowPanelJumps = userConfig.Gui.ShowPanelJumps
+
        if userConfig.Gui.MouseEvents {
                gui.g.Mouse = true
        }

But I'm getting this error when running go run main.go:

# github.com/jesseduffield/lazygit/pkg/gui
pkg/gui/gui.go:641:8: gui.g.ShowPanelJumps undefined (type *gocui.Gui has no field or method ShowPanelJumps)

Am I missing some kind of build step before?

jesseduffield commented 1 year ago

From there it'll need to be gui.c.UserConfig.Gui.ShowPanelJumps :)

MariaSolOs commented 1 year ago

Thanks! You can notice that this is my first time opening a go file lol

jesseduffield commented 1 year ago

Depending on how you find Go as a language you might want it to be your last time opening a go file too haha

stefanhaller commented 1 year ago

I'm a bit concerned about using subtitles for this, for two reasons:

Showing it at the beginning of the tab title ([2] Files - Worktrees - Submodules) seems like a better option to me.

MariaSolOs commented 1 year ago

@stefanhaller I like your suggestion, and I agree that we should reserve subtitles for another use in the future.

MariaSolOs commented 1 year ago

@stefanhaller Unfortunately I'm a bit lost of where I can modify such title (I don't seem to be able to configure it in Run. Could I get some hints? :)

stefanhaller commented 1 year ago

I guess the easy way would be to include it in the tab title itself, i.e. simply prepend it here. But that's not quite right, because it would show the [1] in green when the Files tab is selected, but in white when one of the other tabs is showing. It might be acceptable, but I'm not sure.

If we want to do it properly (i.e. always show it in white), then I think this would need a change to gocui to make that possible. I'd have to look into this more to be sure.

But I'd suggest to wait with this to see what Jesse says about it; maybe he doesn't like the idea at all.

MariaSolOs commented 1 year ago

@stefanhaller, right, because of drawTitle the label will follow the "active tab" highlighting...

stefanhaller commented 1 year ago

The link you just posted doesn't point to the code we're using. We are using a fork of gocui, which has very different code for that function.

As you can see, it completely ignores the Title field when there are any Tabs. We could make it so that it still paints the Title before the Tabs. We'd then just set the Title to "[1]". I'm not sure how hard that would be; we'd also have to change the GetClickedTabIndex function, but maybe that's all.

MariaSolOs commented 1 year ago

@stefanhaller oh my bad, I was looking at the source code I have locally and trying to find the public link to it. I was actually confused about making changes to the vendor directory, but after better reading the CONTRIBUTING guide I understand it better now.

But you're right, before I continue I'll wait to hear back from @jesseduffield.

MariaSolOs commented 1 year ago

Okay I lied, I couldn't wait 😄 I updated the PR implementing @stefanhaller's suggestion.

jesseduffield commented 1 year ago

Your intuition served correct @MariaSolOs , you'll find @stefanhaller is often right about things ;)

I've got some feedback which I'll leave on the PR