{"thread":{"id":"12902","subject":"[PATCH] git-gui: Add shortcut keys for Show More/Less Context","startedAt":"2008-03-28T13:22:47Z","lastAt":"2008-03-29T05:44:40Z","messageCount":2,"participants":["Jonathan del Strother","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"73260","messageId":"57518fd10803280622v3a5f6ae8lcfd35270ab9ede1e@mail.gmail.com","threadId":"12902","inReplyTo":null,"subject":"[PATCH] git-gui: Add shortcut keys for Show More/Less Context","fromName":"Jonathan del Strother","fromEmail":"maillist@steelskies.com","sentAt":"2008-03-28T13:22:47Z","receivedAt":"2008-03-28T13:22:47Z","isPatch":true,"sender":{"key":"jon.delstrother@bestbefore.tv","avatar":"https://gravatar.com/avatar/754e21ab701c00e2d21fc261187254c34b2a1c0b959d9ee5be1a295990be3081?d=mp&s=160"},"body":"Bound to Ctrl/Cmd (depending on your platform) + left & right square brackets.\n---\n\nI'm not at all familiar with Tcl, so I apologise in advance for any\nwrongness.  I frequently find myself repeatedly right-clicking->Show\nLess Context in order to stage a specific hunk, seems like a shortcut\nfor this would be useful.  Thoughts?\n\n git-gui/git-gui.sh |   26 ++++++++++++++++++--------\n 1 files changed, 18 insertions(+), 8 deletions(-)\n\ndiff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh\nindex 5e97fbf..c476753 100755\n--- a/git-gui/git-gui.sh\n+++ b/git-gui/git-gui.sh\n@@ -1845,7 +1845,21 @@ proc add_range_to_selection {w x y} {\n \t}\n \t$w tag add in_sel $begin.0 [expr {$end + 1}].0\n }\n+proc show_more_context {} {\n+\tglobal repo_config\n+\tif {$repo_config(gui.diffcontext) < 99} {\n+\t\tincr repo_config(gui.diffcontext)\n+\t\treshow_diff\n+\t}\n+}\n\n+proc show_less_context {} {\n+\tglobal repo_config\n+\tif {$repo_config(gui.diffcontext) >= 1} {\n+\t\tincr repo_config(gui.diffcontext) -1\n+\t\treshow_diff\n+\t}\n+}\n ######################################################################\n ##\n ## ui construction\n@@ -2593,17 +2607,11 @@ lappend diff_actions [list $ctxm entryconf\n$ui_diff_applyhunk -state]\n $ctxm add separator\n $ctxm add command \\\n \t-label [mc \"Show Less Context\"] \\\n-\t-command {if {$repo_config(gui.diffcontext) >= 1} {\n-\t\tincr repo_config(gui.diffcontext) -1\n-\t\treshow_diff\n-\t}}\n+\t-command show_less_context\n lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]\n $ctxm add command \\\n \t-label [mc \"Show More Context\"] \\\n-\t-command {if {$repo_config(gui.diffcontext) < 99} {\n-\t\tincr repo_config(gui.diffcontext)\n-\t\treshow_diff\n-\t}}\n+\t-command show_more_context\n lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]\n $ctxm add separator\n $ctxm add command \\\n@@ -2695,6 +2703,8 @@ bind $ui_comm <$M1B-Key-v> {tk_textPaste %W; %W\nsee insert; break}\n bind $ui_comm <$M1B-Key-V> {tk_textPaste %W; %W see insert; break}\n bind $ui_comm <$M1B-Key-a> {%W tag add sel 0.0 end;break}\n bind $ui_comm <$M1B-Key-A> {%W tag add sel 0.0 end;break}\n+bind $ui_comm <$M1B-Key-\\[> {show_less_context;break}\n+bind $ui_comm <$M1B-Key-\\]> {show_more_context;break}\n\n bind $ui_diff <$M1B-Key-x> {tk_textCopy %W;break}\n bind $ui_diff <$M1B-Key-X> {tk_textCopy %W;break}\n-- \n1.5.4.3.450.gb92176.dirty\n"},{"id":"73298","messageId":"20080329054440.GP4759@spearce.org","threadId":"12902","inReplyTo":"57518fd10803280622v3a5f6ae8lcfd35270ab9ede1e@mail.gmail.com","subject":"Re: [PATCH] git-gui: Add shortcut keys for Show More/Less Context","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-03-29T05:44:40Z","receivedAt":"2008-03-29T05:44:40Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jonathan del Strother <maillist@steelskies.com> wrote:\n> Bound to Ctrl/Cmd (depending on your platform) + left & right square brackets.\n> ---\n> \n> I'm not at all familiar with Tcl, so I apologise in advance for any\n> wrongness.  I frequently find myself repeatedly right-clicking->Show\n> Less Context in order to stage a specific hunk, seems like a shortcut\n> for this would be useful.  Thoughts?\n\nLooks good to me.  FWIW your patch was sent with a content-type of\nformat=flawed, so I had to manually unwrap the diff hunk headers\nto get it to apply.\n\nI think we should also put these into the menu bar too, like say\nthe commit menu, so users can see what the keyboard action is to\ninvoke the increase/decrease.\n\nAlso, missing a Signed-off-by line.  If you can contribute\nthis change according to the statement outlined in\nDocumentation/SubmittingPatches please send me one.\n \n-- \nShawn.\n"}]}