@matheusbsbs / matheus-bagliano / commits / c91ee2bd61
Fork 0

git-gui: Add shortcut keys for Show More/Less Context

Bound to Ctrl/Cmd + left & right square brackets, depending on your platform. [sp: Added missing binds for . to allow shortcuts to work when not focused in the commit message area.] Signed-off-by: Jonathan del Strother <jon.delStrother@bestbefore.tv> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Jonathan del Strother committed Apr 1, 2008 at 11:54 UTC c91ee2bd61299737c2795bd7b798e17ef0714e47
1 file changed +32 -8
git-gui.sh
+32 -8
@@ -1846,6 +1846,22 @@ proc add_range_to_selection {w x y} {
1846 $w tag add in_sel $begin.0 [expr {$end + 1}].0
1847 }
1848
1849 +proc show_more_context {} {
1850 + global repo_config
1851 + if {$repo_config(gui.diffcontext) < 99} {
1852 + incr repo_config(gui.diffcontext)
1853 + reshow_diff
1854 + }
1855 +}
1856 +
1857 +proc show_less_context {} {
1858 + global repo_config
1859 + if {$repo_config(gui.diffcontext) >= 1} {
1860 + incr repo_config(gui.diffcontext) -1
1861 + reshow_diff
1862 + }
1863 +}
1864 +
1865 ######################################################################
1866 ##
1867 ## ui construction
@@ -2046,6 +2062,16 @@ if {[is_enabled multicommit] || [is_enabled singlecommit]} {
2062
2063 .mbar.commit add separator
2064
2065 + .mbar.commit add command -label [mc "Show Less Context"] \
2066 + -command show_less_context \
2067 + -accelerator $M1T-\[
2068 +
2069 + .mbar.commit add command -label [mc "Show More Context"] \
2070 + -command show_more_context \
2071 + -accelerator $M1T-\]
2072 +
2073 + .mbar.commit add separator
2074 +
2075 .mbar.commit add command -label [mc "Sign Off"] \
2076 -command do_signoff \
2077 -accelerator $M1T-S
@@ -2593,17 +2619,11 @@ lappend diff_actions [list $ctxm entryconf $ui_diff_applyhunk -state]
2619 $ctxm add separator
2620 $ctxm add command \
2621 -label [mc "Show Less Context"] \
2596 - -command {if {$repo_config(gui.diffcontext) >= 1} {
2597 - incr repo_config(gui.diffcontext) -1
2598 - reshow_diff
2599 - }}
2622 + -command show_less_context
2623 lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
2624 $ctxm add command \
2625 -label [mc "Show More Context"] \
2603 - -command {if {$repo_config(gui.diffcontext) < 99} {
2604 - incr repo_config(gui.diffcontext)
2605 - reshow_diff
2606 - }}
2626 + -command show_more_context
2627 lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
2628 $ctxm add separator
2629 $ctxm add command \
@@ -2695,6 +2715,8 @@ bind $ui_comm <$M1B-Key-v> {tk_textPaste %W; %W see insert; break}
2715 bind $ui_comm <$M1B-Key-V> {tk_textPaste %W; %W see insert; break}
2716 bind $ui_comm <$M1B-Key-a> {%W tag add sel 0.0 end;break}
2717 bind $ui_comm <$M1B-Key-A> {%W tag add sel 0.0 end;break}
2718 +bind $ui_comm <$M1B-Key-\[> {show_less_context;break}
2719 +bind $ui_comm <$M1B-Key-\]> {show_more_context;break}
2720
2721 bind $ui_diff <$M1B-Key-x> {tk_textCopy %W;break}
2722 bind $ui_diff <$M1B-Key-X> {tk_textCopy %W;break}
@@ -2738,6 +2760,8 @@ bind . <$M1B-Key-t> do_add_selection
2760 bind . <$M1B-Key-T> do_add_selection
2761 bind . <$M1B-Key-i> do_add_all
2762 bind . <$M1B-Key-I> do_add_all
2763 +bind . <$M1B-Key-\[> {show_less_context;break}
2764 +bind . <$M1B-Key-\]> {show_more_context;break}
2765 bind . <$M1B-Key-Return> do_commit
2766 foreach i [list $ui_index $ui_workdir] {
2767 bind $i <Button-1> "toggle_or_diff $i %x %y; break"