git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-gui: Add hotkeys to set widget focus

From
Birger Skogeng Pedersen <birger.sp@gmail.com>
Date
Sep 1, 2019, 18:24 UTC
Message-ID
<CAGr--=+x6rdb9wexJ3bo+yZu3_zgNB48Ku-jDbcAnQ2We77cSQ@mail.gmail.com>
In-Reply-To
<20190901113218.3lfu4ifsxhzrsw4g@yadavpratyush.com>
Hello Pratyush,
(New patch according to our discussion coming up)
On Sun, Sep 1, 2019 at 1:32 PM Pratyush Yadav <me@yadavpratyush.com> wrote:
> In case you haven't been following the list, Pat has been inactive
> recently, so I am acting as the interim maintainer of git-gui for now,
> because no one else stepped up and Junio would rather not maintain it.

I saw a discussion about it some time ago. But I didn't catch that you are the maintainer. That's great! I use git-gui all the time, so I'm happy to hear someone is going to maintain it.

> ... it would be great if you base them on my tree next
> time around.
Okay, I will.
> I have recently been going through the git-gui code, and my biggest
> gripe was non-descriptive single letter variable names. So maybe
> s/w/window/

I agree about non-descriptive variables. I was following the style of the rest of git-gui.

Show 8 quoted lines
> If some files are added/removed via an external command, that means the
> index we choose won't be the file the user last looked at, correct? What
> about using path names instead, so we know exactly which file to
> display, even though its index might have changed?
>
> But if it is not a trivial change, and needs a lot of work, I'm fine
> with the way things are. If the user changes stuff outside of git-gui,
> some side effects are to be expected.

A somewhat non-trivial change, for me at least. To implement what you're suggesting, I'm gonna need some help or the patch will be delayed quite a lot...

So honestly, I'd appreciate it if we could leave it like this (for now, at least).

Show 7 quoted lines
> > +
> > +             if {$_index eq {}} {
> > +                     set _index 1
> > +             } elseif {$_index > $_list_length} {
> > +                     set _index $_list_length
>
> Just to be sure: _index should start at 1 right, and not 0?
I'm quite sure this is correct. Setting the index to 0 throws an error.
Show 6 quoted lines
> If _list_length is 0 (iow, no files are staged/unstaged), this won't
> change the focus at all. Are you sure this is the desired behaviour?
> Would it make no sense if we switch to an empty pane? The user did
> explicitly hit the button combo to go there. Yes, they won't be able to
> actually do anything, but what is the harm in switching focus if the
> user explicitly requests it?

An error is thrown if we force focus to the "Unstaged Changes" widget when it has no files listed. The same goes for the "Staged Changes" widget. That's why I put the condition there.

> Do you expect these functions to be re-used somewhere in the near
> future?

Not really, but I feel the "key bindings" section of the script should have as little logic as possible (and just be a bunch of key bindings invoking functions). Also I think function names are a good way to describe what the code is doing, so personally I actually think it's better like this. But if you feel strongly that it should be like you suggested, I'm open to it.

Best regards, Birger

Previous: Junio C HamanoNext: Bert Wesarg
Message 12 of 46 in “git-gui, feature request: add hotkeys to focus different widgets”
  1. Birger Skogeng PedersenFeb 20, 2018
  2. git-gui: Add hotkeys to change focus between ui widgetsBirger Skogeng Pedersen, Feb 23, 2018
  3. Birger Skogeng PedersenFeb 23, 2018
  4. git-gui: Add hotkeys to change focus between ui widgetsBirger Skogeng Pedersen, Feb 28, 2018
  5. Johannes SchindelinMar 5, 2018
  6. Birger Skogeng PedersenMar 6, 2018
  7. Junio C HamanoMar 6, 2018
  8. git-gui: Add hotkeys to set widget focusBirger Skogeng Pedersen, Aug 31, 2019
  9. Birger Skogeng PedersenAug 31, 2019
  10. Pratyush YadavSep 1, 2019
  11. Junio C HamanoSep 1, 2019
  12. Birger Skogeng PedersenSep 1, 2019
  13. Bert WesargSep 1, 2019
  14. [PATCH] git-gui: Add hotkeys to set widget focusBirger Skogeng Pedersen, Sep 1, 2019
  15. Pratyush YadavSep 2, 2019
  16. Birger Skogeng PedersenSep 2, 2019
  17. Pratyush YadavSep 2, 2019
  18. Birger Skogeng PedersenSep 2, 2019
  19. Bert WesargSep 2, 2019
  20. Birger Skogeng PedersenSep 3, 2019
  21. Pratyush YadavSep 3, 2019
  22. git-gui: use path name instead of list index to track last clicked filePratyush Yadav, Sep 3, 2019
  23. git-gui: Add hotkeys to set widget focusBirger Skogeng Pedersen, Sep 3, 2019
  24. Birger Skogeng PedersenSep 3, 2019
  25. Birger Skogeng PedersenSep 3, 2019
  26. Pratyush YadavSep 3, 2019
  27. git-gui: Add hotkeys to set widget focusBirger Skogeng Pedersen, Sep 4, 2019
  28. Johannes SixtSep 4, 2019
  29. Birger Skogeng PedersenSep 4, 2019
  30. Johannes SixtSep 4, 2019
  31. Pratyush YadavSep 4, 2019
  32. Junio C HamanoSep 4, 2019
  33. Pratyush YadavSep 5, 2019
  34. Bert WesargSep 4, 2019
  35. Johannes SixtSep 4, 2019
  36. Pratyush YadavSep 10, 2019
  37. Birger Skogeng PedersenSep 11, 2019
  38. Pratyush YadavSep 11, 2019
  39. Johannes SixtSep 11, 2019
  40. Bert WesargSep 3, 2019
  41. Philip OakleySep 1, 2019
  42. Pratyush YadavSep 2, 2019
  43. Philip OakleySep 2, 2019
  44. Pratyush YadavSep 3, 2019
  45. Bert WesargSep 1, 2019
  46. Birger Skogeng PedersenSep 1, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.