git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v2] git-gui: Add shortcut keys for Show More/Less Context
@ 2008-04-01 10:54 Jonathan del Strother
  2008-04-01 13:59 ` Jonathan del Strother
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan del Strother @ 2008-04-01 10:54 UTC (permalink / raw)
  To: git, spearce; +Cc: Jonathan del Strother

Bound to Ctrl/Cmd + left & right square brackets, depending on your platform.

Signed-off-by: Jonathan del Strother <jon.delStrother@bestbefore.tv>
---

Second attempt to add Show Context shortcuts to git gui.  This new version also adds the items to the Commit menu, complete with accelerator keys to make the shortcut more visible.

 git-gui/git-gui.sh |   36 ++++++++++++++++++++++++++++--------
 1 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index 5e97fbf..9ee2d32 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -1845,7 +1845,21 @@ proc add_range_to_selection {w x y} {
 	}
 	$w tag add in_sel $begin.0 [expr {$end + 1}].0
 }
+proc show_more_context {} {
+	global repo_config
+	if {$repo_config(gui.diffcontext) < 99} {
+		incr repo_config(gui.diffcontext)
+		reshow_diff
+	}
+}
 
+proc show_less_context {} {
+	global repo_config
+	if {$repo_config(gui.diffcontext) >= 1} {
+		incr repo_config(gui.diffcontext) -1
+		reshow_diff
+	}
+}
 ######################################################################
 ##
 ## ui construction
@@ -2046,6 +2060,16 @@ if {[is_enabled multicommit] || [is_enabled singlecommit]} {
 
 	.mbar.commit add separator
 
+	.mbar.commit add command -label [mc "Show Less Context"] \
+		-command show_less_context \
+		-accelerator $M1T-\[
+
+	.mbar.commit add command -label [mc "Show More Context"] \
+		-command show_more_context \
+		-accelerator $M1T-\]
+
+	.mbar.commit add separator
+
 	.mbar.commit add command -label [mc "Sign Off"] \
 		-command do_signoff \
 		-accelerator $M1T-S
@@ -2593,17 +2617,11 @@ lappend diff_actions [list $ctxm entryconf $ui_diff_applyhunk -state]
 $ctxm add separator
 $ctxm add command \
 	-label [mc "Show Less Context"] \
-	-command {if {$repo_config(gui.diffcontext) >= 1} {
-		incr repo_config(gui.diffcontext) -1
-		reshow_diff
-	}}
+	-command show_less_context
 lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
 $ctxm add command \
 	-label [mc "Show More Context"] \
-	-command {if {$repo_config(gui.diffcontext) < 99} {
-		incr repo_config(gui.diffcontext)
-		reshow_diff
-	}}
+	-command show_more_context
 lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
 $ctxm add separator
 $ctxm add command \
@@ -2695,6 +2713,8 @@ bind $ui_comm <$M1B-Key-v> {tk_textPaste %W; %W see insert; break}
 bind $ui_comm <$M1B-Key-V> {tk_textPaste %W; %W see insert; break}
 bind $ui_comm <$M1B-Key-a> {%W tag add sel 0.0 end;break}
 bind $ui_comm <$M1B-Key-A> {%W tag add sel 0.0 end;break}
+bind $ui_comm <$M1B-Key-\[> {show_less_context;break}
+bind $ui_comm <$M1B-Key-\]> {show_more_context;break}
 
 bind $ui_diff <$M1B-Key-x> {tk_textCopy %W;break}
 bind $ui_diff <$M1B-Key-X> {tk_textCopy %W;break}
-- 
1.5.5.rc2.1.g107f.dirty

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] git-gui: Add shortcut keys for Show More/Less Context
  2008-04-01 10:54 [PATCH v2] git-gui: Add shortcut keys for Show More/Less Context Jonathan del Strother
@ 2008-04-01 13:59 ` Jonathan del Strother
  2008-04-02  5:34   ` Shawn O. Pearce
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan del Strother @ 2008-04-01 13:59 UTC (permalink / raw)
  To: git, spearce

On Tue, Apr 1, 2008 at 11:54 AM, Jonathan del Strother
<maillist@steelskies.com> wrote:
> Bound to Ctrl/Cmd + left & right square brackets, depending on your platform.
>
>  Signed-off-by: Jonathan del Strother <jon.delStrother@bestbefore.tv>
>  ---
>
>  Second attempt to add Show Context shortcuts to git gui.  This new version also adds the items to the Commit menu, complete with accelerator keys to make the shortcut more visible.
>


... I've just noticed that the shortcut keys don't apply while the
diff view has keyboard focus.  Shall I replace "bind $ui_comm ... "
with "bind all ..."  ?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] git-gui: Add shortcut keys for Show More/Less Context
  2008-04-01 13:59 ` Jonathan del Strother
@ 2008-04-02  5:34   ` Shawn O. Pearce
  0 siblings, 0 replies; 3+ messages in thread
From: Shawn O. Pearce @ 2008-04-02  5:34 UTC (permalink / raw)
  To: Jonathan del Strother; +Cc: git

Jonathan del Strother <maillist@steelskies.com> wrote:
> On Tue, Apr 1, 2008 at 11:54 AM, Jonathan del Strother
> <maillist@steelskies.com> wrote:
> > Bound to Ctrl/Cmd + left & right square brackets, depending on your platform.

Thanks.
 
> ... I've just noticed that the shortcut keys don't apply while the
> diff view has keyboard focus.  Shall I replace "bind $ui_comm ... "
> with "bind all ..."  ?

No, "bind .".  I squashed this into your patch:

@@ -2758,6 +2760,8 @@ bind .   <$M1B-Key-t> do_add_selection
 bind .   <$M1B-Key-T> do_add_selection
 bind .   <$M1B-Key-i> do_add_all
 bind .   <$M1B-Key-I> do_add_all
+bind .   <$M1B-Key-\[> {show_less_context;break}
+bind .   <$M1B-Key-\]> {show_more_context;break}
 bind .   <$M1B-Key-Return> do_commit
 foreach i [list $ui_index $ui_workdir] {
        bind $i <Button-1>       "toggle_or_diff         $i %x %y; break"


-- 
Shawn.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-04-02  5:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-01 10:54 [PATCH v2] git-gui: Add shortcut keys for Show More/Less Context Jonathan del Strother
2008-04-01 13:59 ` Jonathan del Strother
2008-04-02  5:34   ` Shawn O. Pearce

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).