{"thread":{"id":"9102","subject":"[PATCH] Mak gitk bind keyboard actions to the command key on Mac OS","startedAt":"2007-07-19T04:37:58Z","lastAt":"2007-07-19T04:37:58Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"47805","messageId":"20070719043758.GA14752@spearce.org","threadId":"9102","inReplyTo":null,"subject":"[PATCH] Mak gitk bind keyboard actions to the command key on Mac OS","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-07-19T04:37:58Z","receivedAt":"2007-07-19T04:37:58Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"git-gui already uses the command key for accelerators, but gitk has\nnever done so.  I'm actually finding it very hard to move back and\nforth between the two applications as git-gui is following the Mac\nOS X conventions and gitk is not.\n\nThis trick is the same one that git-gui uses to determine which\nkey to bind actions to.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n gitk |   75 +++++++++++++++++++++++++++++++++++++----------------------------\n 1 files changed, 43 insertions(+), 32 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex 39e452a..6f58803 100755\n--- a/gitk\n+++ b/gitk\n@@ -796,6 +796,12 @@ proc makewindow {} {\n         wm geometry . \"$geometry(main)\"\n     }\n \n+    if {[tk windowingsystem] eq {aqua}} {\n+        set M1B M1\n+    } else {\n+        set M1B Control\n+    }\n+\n     bind .pwbottom <Configure> {resizecdetpanes %W %w}\n     pack .ctop -fill both -expand 1\n     bindall <1> {selcanvline %W %x %y}\n@@ -814,12 +820,12 @@ proc makewindow {} {\n     bindkey <Key-Left> \"goback\"\n     bind . <Key-Prior> \"selnextpage -1\"\n     bind . <Key-Next> \"selnextpage 1\"\n-    bind . <Control-Home> \"allcanvs yview moveto 0.0\"\n-    bind . <Control-End> \"allcanvs yview moveto 1.0\"\n-    bind . <Control-Key-Up> \"allcanvs yview scroll -1 units\"\n-    bind . <Control-Key-Down> \"allcanvs yview scroll 1 units\"\n-    bind . <Control-Key-Prior> \"allcanvs yview scroll -1 pages\"\n-    bind . <Control-Key-Next> \"allcanvs yview scroll 1 pages\"\n+    bind . <$M1B-Home> \"allcanvs yview moveto 0.0\"\n+    bind . <$M1B-End> \"allcanvs yview moveto 1.0\"\n+    bind . <$M1B-Key-Up> \"allcanvs yview scroll -1 units\"\n+    bind . <$M1B-Key-Down> \"allcanvs yview scroll 1 units\"\n+    bind . <$M1B-Key-Prior> \"allcanvs yview scroll -1 pages\"\n+    bind . <$M1B-Key-Next> \"allcanvs yview scroll 1 pages\"\n     bindkey <Key-Delete> \"$ctext yview scroll -1 pages\"\n     bindkey <Key-BackSpace> \"$ctext yview scroll -1 pages\"\n     bindkey <Key-space> \"$ctext yview scroll 1 pages\"\n@@ -839,15 +845,15 @@ proc makewindow {} {\n     bindkey ? findprev\n     bindkey f nextfile\n     bindkey <F5> updatecommits\n-    bind . <Control-q> doquit\n-    bind . <Control-f> dofind\n-    bind . <Control-g> {findnext 0}\n-    bind . <Control-r> dosearchback\n-    bind . <Control-s> dosearch\n-    bind . <Control-equal> {incrfont 1}\n-    bind . <Control-KP_Add> {incrfont 1}\n-    bind . <Control-minus> {incrfont -1}\n-    bind . <Control-KP_Subtract> {incrfont -1}\n+    bind . <$M1B-q> doquit\n+    bind . <$M1B-f> dofind\n+    bind . <$M1B-g> {findnext 0}\n+    bind . <$M1B-r> dosearchback\n+    bind . <$M1B-s> dosearch\n+    bind . <$M1B-equal> {incrfont 1}\n+    bind . <$M1B-KP_Add> {incrfont 1}\n+    bind . <$M1B-minus> {incrfont -1}\n+    bind . <$M1B-KP_Subtract> {incrfont -1}\n     wm protocol . WM_DELETE_WINDOW doquit\n     bind . <Button-1> \"click %W\"\n     bind $fstring <Key-Return> dofind\n@@ -1088,12 +1094,17 @@ proc keys {} {\n \traise $w\n \treturn\n     }\n+    if {[tk windowingsystem] eq {aqua}} {\n+\tset M1T Cmd\n+    } else {\n+\tset M1T Ctrl\n+    }\n     toplevel $w\n     wm title $w \"Gitk key bindings\"\n-    message $w.m -text {\n+    message $w.m -text \"\n Gitk key bindings:\n \n-<Ctrl-Q>\t\tQuit\n+<$M1T-Q>\t\tQuit\n <Home>\t\tMove to first commit\n <End>\t\tMove to last commit\n <Up>, p, i\tMove up one commit\n@@ -1102,12 +1113,12 @@ Gitk key bindings:\n <Right>, x, l\tGo forward in history list\n <PageUp>\tMove up one page in commit list\n <PageDown>\tMove down one page in commit list\n-<Ctrl-Home>\tScroll to top of commit list\n-<Ctrl-End>\tScroll to bottom of commit list\n-<Ctrl-Up>\tScroll commit list up one line\n-<Ctrl-Down>\tScroll commit list down one line\n-<Ctrl-PageUp>\tScroll commit list up one page\n-<Ctrl-PageDown>\tScroll commit list down one page\n+<$M1T-Home>\tScroll to top of commit list\n+<$M1T-End>\tScroll to bottom of commit list\n+<$M1T-Up>\tScroll commit list up one line\n+<$M1T-Down>\tScroll commit list down one line\n+<$M1T-PageUp>\tScroll commit list up one page\n+<$M1T-PageDown>\tScroll commit list down one page\n <Shift-Up>\tMove to previous highlighted line\n <Shift-Down>\tMove to next highlighted line\n <Delete>, b\tScroll diff view up one page\n@@ -1115,20 +1126,20 @@ Gitk key bindings:\n <Space>\t\tScroll diff view down one page\n u\t\tScroll diff view up 18 lines\n d\t\tScroll diff view down 18 lines\n-<Ctrl-F>\t\tFind\n-<Ctrl-G>\t\tMove to next find hit\n+<$M1T-F>\t\tFind\n+<$M1T-G>\t\tMove to next find hit\n <Return>\tMove to next find hit\n /\t\tMove to next find hit, or redo find\n ?\t\tMove to previous find hit\n f\t\tScroll diff view to next file\n-<Ctrl-S>\t\tSearch for next hit in diff view\n-<Ctrl-R>\t\tSearch for previous hit in diff view\n-<Ctrl-KP+>\tIncrease font size\n-<Ctrl-plus>\tIncrease font size\n-<Ctrl-KP->\tDecrease font size\n-<Ctrl-minus>\tDecrease font size\n+<$M1T-S>\t\tSearch for next hit in diff view\n+<$M1T-R>\t\tSearch for previous hit in diff view\n+<$M1T-KP+>\tIncrease font size\n+<$M1T-plus>\tIncrease font size\n+<$M1T-KP->\tDecrease font size\n+<$M1T-minus>\tDecrease font size\n <F5>\t\tUpdate\n-} \\\n+\" \\\n \t    -justify left -bg white -border 2 -relief groove\n     pack $w.m -side top -fill both -padx 2 -pady 2\n     $w.m configure -font $uifont\n-- \n1.5.3.rc2.822.g75e72\n"}]}