[PATCH] gitk: Bind keyboard actions to the command key on Mac OS
git-gui already uses the command key for accelerators, but gitk has never done so. I'm actually finding it very hard to move back and forth between the two applications as git-gui is following the Mac OS X conventions and gitk is not. This trick is the same one that git-gui uses to determine which key to bind actions to. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Shawn O. Pearce committed
Jul 19, 2007 at 00:37 UTC
d23d98d3ba21b2a7a1d30be049bfb5d9c0a4e943
1 file changed
+43
-32
gitk
+43
-32
@@ -809,6 +809,12 @@ proc makewindow {} {
809
wm geometry . "$geometry(main)"
810
}
811
812
+ if {[tk windowingsystem] eq {aqua}} {
813
+ set M1B M1
814
+ } else {
815
+ set M1B Control
816
+ }
817
+
818
bind .pwbottom <Configure> {resizecdetpanes %W %w}
819
pack .ctop -fill both -expand 1
820
bindall <1> {selcanvline %W %x %y}
@@ -827,12 +833,12 @@ proc makewindow {} {
833
bindkey <Key-Left> "goback"
834
bind . <Key-Prior> "selnextpage -1"
835
bind . <Key-Next> "selnextpage 1"
830
- bind . <Control-Home> "allcanvs yview moveto 0.0"
831
- bind . <Control-End> "allcanvs yview moveto 1.0"
832
- bind . <Control-Key-Up> "allcanvs yview scroll -1 units"
833
- bind . <Control-Key-Down> "allcanvs yview scroll 1 units"
834
- bind . <Control-Key-Prior> "allcanvs yview scroll -1 pages"
835
- bind . <Control-Key-Next> "allcanvs yview scroll 1 pages"
836
+ bind . <$M1B-Home> "allcanvs yview moveto 0.0"
837
+ bind . <$M1B-End> "allcanvs yview moveto 1.0"
838
+ bind . <$M1B-Key-Up> "allcanvs yview scroll -1 units"
839
+ bind . <$M1B-Key-Down> "allcanvs yview scroll 1 units"
840
+ bind . <$M1B-Key-Prior> "allcanvs yview scroll -1 pages"
841
+ bind . <$M1B-Key-Next> "allcanvs yview scroll 1 pages"
842
bindkey <Key-Delete> "$ctext yview scroll -1 pages"
843
bindkey <Key-BackSpace> "$ctext yview scroll -1 pages"
844
bindkey <Key-space> "$ctext yview scroll 1 pages"
@@ -852,15 +858,15 @@ proc makewindow {} {
858
bindkey ? findprev
859
bindkey f nextfile
860
bindkey <F5> updatecommits
855
- bind . <Control-q> doquit
856
- bind . <Control-f> dofind
857
- bind . <Control-g> {findnext 0}
858
- bind . <Control-r> dosearchback
859
- bind . <Control-s> dosearch
860
- bind . <Control-equal> {incrfont 1}
861
- bind . <Control-KP_Add> {incrfont 1}
862
- bind . <Control-minus> {incrfont -1}
863
- bind . <Control-KP_Subtract> {incrfont -1}
861
+ bind . <$M1B-q> doquit
862
+ bind . <$M1B-f> dofind
863
+ bind . <$M1B-g> {findnext 0}
864
+ bind . <$M1B-r> dosearchback
865
+ bind . <$M1B-s> dosearch
866
+ bind . <$M1B-equal> {incrfont 1}
867
+ bind . <$M1B-KP_Add> {incrfont 1}
868
+ bind . <$M1B-minus> {incrfont -1}
869
+ bind . <$M1B-KP_Subtract> {incrfont -1}
870
wm protocol . WM_DELETE_WINDOW doquit
871
bind . <Button-1> "click %W"
872
bind $fstring <Key-Return> dofind
@@ -1101,12 +1107,17 @@ proc keys {} {
1107
raise $w
1108
return
1109
}
1110
+ if {[tk windowingsystem] eq {aqua}} {
1111
+ set M1T Cmd
1112
+ } else {
1113
+ set M1T Ctrl
1114
+ }
1115
toplevel $w
1116
wm title $w "Gitk key bindings"
1106
- message $w.m -text {
1117
+ message $w.m -text "
1118
Gitk key bindings:
1119
1109
-<Ctrl-Q> Quit
1120
+<$M1T-Q> Quit
1121
<Home> Move to first commit
1122
<End> Move to last commit
1123
<Up>, p, i Move up one commit
@@ -1115,12 +1126,12 @@ Gitk key bindings:
1126
<Right>, x, l Go forward in history list
1127
<PageUp> Move up one page in commit list
1128
<PageDown> Move down one page in commit list
1118
-<Ctrl-Home> Scroll to top of commit list
1119
-<Ctrl-End> Scroll to bottom of commit list
1120
-<Ctrl-Up> Scroll commit list up one line
1121
-<Ctrl-Down> Scroll commit list down one line
1122
-<Ctrl-PageUp> Scroll commit list up one page
1123
-<Ctrl-PageDown> Scroll commit list down one page
1129
+<$M1T-Home> Scroll to top of commit list
1130
+<$M1T-End> Scroll to bottom of commit list
1131
+<$M1T-Up> Scroll commit list up one line
1132
+<$M1T-Down> Scroll commit list down one line
1133
+<$M1T-PageUp> Scroll commit list up one page
1134
+<$M1T-PageDown> Scroll commit list down one page
1135
<Shift-Up> Move to previous highlighted line
1136
<Shift-Down> Move to next highlighted line
1137
<Delete>, b Scroll diff view up one page
@@ -1128,20 +1139,20 @@ Gitk key bindings:
1139
<Space> Scroll diff view down one page
1140
u Scroll diff view up 18 lines
1141
d Scroll diff view down 18 lines
1131
-<Ctrl-F> Find
1132
-<Ctrl-G> Move to next find hit
1142
+<$M1T-F> Find
1143
+<$M1T-G> Move to next find hit
1144
<Return> Move to next find hit
1145
/ Move to next find hit, or redo find
1146
? Move to previous find hit
1147
f Scroll diff view to next file
1137
-<Ctrl-S> Search for next hit in diff view
1138
-<Ctrl-R> Search for previous hit in diff view
1139
-<Ctrl-KP+> Increase font size
1140
-<Ctrl-plus> Increase font size
1141
-<Ctrl-KP-> Decrease font size
1142
-<Ctrl-minus> Decrease font size
1148
+<$M1T-S> Search for next hit in diff view
1149
+<$M1T-R> Search for previous hit in diff view
1150
+<$M1T-KP+> Increase font size
1151
+<$M1T-plus> Increase font size
1152
+<$M1T-KP-> Decrease font size
1153
+<$M1T-minus> Decrease font size
1154
<F5> Update
1144
-} \
1155
+" \
1156
-justify left -bg white -border 2 -relief groove
1157
pack $w.m -side top -fill both -padx 2 -pady 2
1158
$w.m configure -font $uifont