git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / Atom feed
From: harish k <harish2704@gmail.com>
To: git@vger.kernel.org
Cc: David Aguilar <davvid@gmail.com>, Pratyush Yadav <me@yadavpratyush.com>
Subject: Re: [PATCH] Feature: custom guitool commands can now have custom keyboard shortcuts
Date: Thu, 3 Oct 2019 20:18:06 +0530
Message-ID: <CACV9s2MQCP04QASgt0xhi3cSNPSKjwXTufxmZQXAUNvnWD9DSw@mail.gmail.com> (raw)
In-Reply-To: <CACV9s2MFiikZWq=s8kYQ+qwidQ=oO-SHyKWAs4MUkNcgDhJzeg@mail.gmail.com>

Hi All,
I', Just reopening this feature request.
A quick summary of my proposal is given below.

1. This PR will allow an additional configuration option
"guitool.<name>.gitgui-shortcut" which will allow us to specify
keyboard shortcut  for custom commands in git-gui

2. Even there exists a parameter called "guitool.<name>.shortcut"
which is used by git-cola, I suggest to keep this new additional
config parameter as an independent config parameter, which will not
interfere with git-cola in any way, because, both are different
applications and it may have different "built-in" shortcuts already
assigned. So, sharing shortcut scheme between two apps is not a good
idea.

3. New parameter will expect shortcut combinations specified in TCL/TK
's format and we will not be doing any processing on it. Will keep it
simple.

---
 Documentation/config/guitool.txt | 15 +++++++++++++++
 git-gui/lib/tools.tcl            | 15 ++++++++++++---
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/Documentation/config/guitool.txt b/Documentation/config/guitool.txt
index 43fb9466ff..79dac23ca3 100644
--- a/Documentation/config/guitool.txt
+++ b/Documentation/config/guitool.txt
@@ -48,3 +48,18 @@ guitool.<name>.prompt::
  Specifies the general prompt string to display at the top of
  the dialog, before subsections for 'argPrompt' and 'revPrompt'.
  The default value includes the actual command.
+
+guitool.<name>.gitgui-shortcut
+ Specifies a keyboard shortcut for the custom tool in the git-gui
+ application. The value must be a valid string ( without "<" , ">" wrapper )
+ understood by the TCL/TK 's bind command.See
https://www.tcl.tk/man/tcl8.4/TkCmd/bind.htm
+ for more details about the supported values. Avoid creating shortcuts that
+ conflict with existing built-in `git gui` shortcuts.
+ Example:
+ [guitool "Terminal"]
+ cmd = gnome-terminal -e zsh
+ noconsole = yes
+ gitgui-shortcut = "Control-y"
+ [guitool "Sync"]
+ cmd = "git pull; git push"
+ gitgui-shortcut = "Alt-s"
diff --git a/git-gui/lib/tools.tcl b/git-gui/lib/tools.tcl
index 413f1a1700..40db3f6395 100644
--- a/git-gui/lib/tools.tcl
+++ b/git-gui/lib/tools.tcl
@@ -38,7 +38,7 @@ proc tools_create_item {parent args} {
 }

 proc tools_populate_one {fullname} {
- global tools_menubar tools_menutbl tools_id
+ global tools_menubar tools_menutbl tools_id repo_config

  if {![info exists tools_id]} {
  set tools_id 0
@@ -61,9 +61,18 @@ proc tools_populate_one {fullname} {
  }
  }

- tools_create_item $parent command \
+ if {[info exists repo_config(guitool.$fullname.gitgui-shortcut)]} {
+ set gitgui_shortcut $repo_config(guitool.$fullname.gitgui-shortcut)
+ tools_create_item $parent command \
  -label [lindex $names end] \
- -command [list tools_exec $fullname]
+ -command [list tools_exec $fullname] \
+ -accelerator $gitgui_shortcut
+ bind . <$gitgui_shortcut> [list tools_exec $fullname]
+ } else {
+ tools_create_item $parent command \
+ -label [lindex $names end] \
+ -command [list tools_exec $fullname]
+ }
 }

 proc tools_exec {fullname} {
--
https://github.com/git/git/pull/220
--


On Fri, Apr 1, 2016 at 12:02 PM harish k <harish2704@gmail.com> wrote:
>
> Hi David,
>
> Actually Im a TCL primer.  This is the first time Im dealing with.
> That is why I kept it simple ( ie both accel-key and accel-label need
> to be defined in config ).
>
> I think, git-cola is using Qt style representation accel-key in the config file.
>
> Is git-cola is an official tool from git ? like git-gui?
> if not ,
> My suggesion is, it is better to seperate config fields according to
> application-domain
> like, "git-gui-accel = <Ctrl-l>" etc..
> Other vise there is good chance for conflicts. ( Eg: consider the case
>  that, <Ctrl-p> was assined to a custom tool by git-cola )
>
> Currently this patch will not handle any conflicting shortcuts. I
> think custom shortcuts will overwrite the other.
>
>
> On Thu, Mar 31, 2016 at 10:11 PM, David Aguilar <davvid@gmail.com> wrote:
> > Hello,
> >
> > On Tue, Mar 29, 2016 at 11:38:10AM +0000, Harish K wrote:
> >> ---
> >>  git-gui/lib/tools.tcl | 16 +++++++++++++---
> >>  1 file changed, 13 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/git-gui/lib/tools.tcl b/git-gui/lib/tools.tcl
> >> index 6ec9411..749bc67 100644
> >> --- a/git-gui/lib/tools.tcl
> >> +++ b/git-gui/lib/tools.tcl
> >> @@ -38,7 +38,7 @@ proc tools_create_item {parent args} {
> >>  }
> >>
> >>  proc tools_populate_one {fullname} {
> >> -     global tools_menubar tools_menutbl tools_id
> >> +     global tools_menubar tools_menutbl tools_id repo_config
> >>
> >>       if {![info exists tools_id]} {
> >>               set tools_id 0
> >> @@ -61,9 +61,19 @@ proc tools_populate_one {fullname} {
> >>               }
> >>       }
> >>
> >> -     tools_create_item $parent command \
> >> +     if {[info exists repo_config(guitool.$fullname.accelerator)] && [info exists repo_config(guitool.$fullname.accelerator-label)]} {
> >> +             set accele_key $repo_config(guitool.$fullname.accelerator)
> >> +             set accel_label $repo_config(guitool.$fullname.accelerator-label)
> >> +             tools_create_item $parent command \
> >>               -label [lindex $names end] \
> >> -             -command [list tools_exec $fullname]
> >> +             -command [list tools_exec $fullname] \
> >> +             -accelerator $accel_label
> >> +             bind . $accele_key [list tools_exec $fullname]
> >> +     } else {
> >> +             tools_create_item $parent command \
> >> +                     -label [lindex $names end] \
> >> +                     -command [list tools_exec $fullname]
> >> +     }
> >>  }
> >>
> >>  proc tools_exec {fullname} {
> >>
> >> --
> >> https://github.com/git/git/pull/220
> >
> > We also support "custom guitools" in git-cola using this same
> > mechanism.  If this gets accepted then we'll want to make
> > similar change there.
> >
> > There's always a small risk that user-defined tools can conflict
> > with builtin shortcuts, but otherwise this seems like a pretty
> > nice feature.  Curious, what is the behavior in the event of a
> > conflict?  Do the builtins win?  IIRC, Qt handles this by
> > disabling the shortcut and warning that it's ambiguous.
> >
> > Please documentation guitool.<name>.accellerator[-label] in
> > Documentation/config.txt otherwise users will not know that it
> > exists.
> >
> > It would also be good for the docs to clarify what the
> > accelerators look like in case we need to munge them when making
> > it work in cola via Qt, which has its own mechanism for
> > associating actions with shortcuts.  Documented examples with
> > one and two modifier keys would be helpful.
> >
> >
> > cheers,
> > --
> > David
>
>
>
> --
>
> -Regards
> Harish.K



-- 

-Thanks
Harish.K

  reply index

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-29 11:38 Harish K
2016-03-31 16:41 ` David Aguilar
2016-04-01  6:32   ` harish k
2019-10-03 14:48     ` harish k [this message]
2019-10-03 21:44       ` Pratyush Yadav
2019-10-04  8:49         ` Johannes Schindelin
2019-10-04 12:01           ` Pratyush Yadav
2019-10-05 20:16             ` Harish Karumuthil
2019-10-05 21:01               ` Pratyush Yadav
2019-10-06  9:49                 ` Johannes Schindelin
2019-10-06 18:39                   ` Pratyush Yadav
2019-10-06 19:37                     ` Philip Oakley
2019-10-06 20:27                     ` Johannes Schindelin
2019-10-06 21:06                       ` Pratyush Yadav
2019-10-07  9:20                         ` GitGUIGadget, was " Johannes Schindelin
2019-10-07 10:43                           ` Birger Skogeng Pedersen
2019-10-07 19:16                             ` Alban Gruin
2019-11-19 22:09                         ` Making GitGitGadget's list -> PR comment mirroring bidirectional, " Johannes Schindelin
2019-11-20 14:22                           ` Pratyush Yadav
2019-10-06 22:40                       ` Philip Oakley
2019-10-07  6:22                   ` Harish Karumuthil
2019-10-07 10:01                     ` Johannes Schindelin
2019-10-08 19:31                       ` Harish Karumuthil
2019-10-09 20:42                         ` Johannes Schindelin
2019-10-13 20:09                         ` Pratyush Yadav
2019-10-07  6:13                 ` Harish Karumuthil
2019-10-13 19:17                   ` Pratyush Yadav
  -- strict thread matches above, loose matches on Subject: below --
2016-03-29 11:29 Harish K
2016-03-31 16:49 ` David Aguilar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACV9s2MQCP04QASgt0xhi3cSNPSKjwXTufxmZQXAUNvnWD9DSw@mail.gmail.com \
    --to=harish2704@gmail.com \
    --cc=davvid@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=me@yadavpratyush.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

git@vger.kernel.org list mirror (unofficial, one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git