Skip to content

Commit

Permalink
[PATCH] gitk: Bind keyboard actions to the command key on Mac OS
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Shawn O. Pearce authored and Paul Mackerras committed Jul 22, 2007
1 parent 86da5b6 commit d23d98d
Showing 1 changed file with 43 additions and 32 deletions.
75 changes: 43 additions & 32 deletions gitk
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,12 @@ proc makewindow {} {
wm geometry . "$geometry(main)"
}

if {[tk windowingsystem] eq {aqua}} {
set M1B M1
} else {
set M1B Control
}

bind .pwbottom <Configure> {resizecdetpanes %W %w}
pack .ctop -fill both -expand 1
bindall <1> {selcanvline %W %x %y}
Expand All @@ -827,12 +833,12 @@ proc makewindow {} {
bindkey <Key-Left> "goback"
bind . <Key-Prior> "selnextpage -1"
bind . <Key-Next> "selnextpage 1"
bind . <Control-Home> "allcanvs yview moveto 0.0"
bind . <Control-End> "allcanvs yview moveto 1.0"
bind . <Control-Key-Up> "allcanvs yview scroll -1 units"
bind . <Control-Key-Down> "allcanvs yview scroll 1 units"
bind . <Control-Key-Prior> "allcanvs yview scroll -1 pages"
bind . <Control-Key-Next> "allcanvs yview scroll 1 pages"
bind . <$M1B-Home> "allcanvs yview moveto 0.0"
bind . <$M1B-End> "allcanvs yview moveto 1.0"
bind . <$M1B-Key-Up> "allcanvs yview scroll -1 units"
bind . <$M1B-Key-Down> "allcanvs yview scroll 1 units"
bind . <$M1B-Key-Prior> "allcanvs yview scroll -1 pages"
bind . <$M1B-Key-Next> "allcanvs yview scroll 1 pages"
bindkey <Key-Delete> "$ctext yview scroll -1 pages"
bindkey <Key-BackSpace> "$ctext yview scroll -1 pages"
bindkey <Key-space> "$ctext yview scroll 1 pages"
Expand All @@ -852,15 +858,15 @@ proc makewindow {} {
bindkey ? findprev
bindkey f nextfile
bindkey <F5> updatecommits
bind . <Control-q> doquit
bind . <Control-f> dofind
bind . <Control-g> {findnext 0}
bind . <Control-r> dosearchback
bind . <Control-s> dosearch
bind . <Control-equal> {incrfont 1}
bind . <Control-KP_Add> {incrfont 1}
bind . <Control-minus> {incrfont -1}
bind . <Control-KP_Subtract> {incrfont -1}
bind . <$M1B-q> doquit
bind . <$M1B-f> dofind
bind . <$M1B-g> {findnext 0}
bind . <$M1B-r> dosearchback
bind . <$M1B-s> dosearch
bind . <$M1B-equal> {incrfont 1}
bind . <$M1B-KP_Add> {incrfont 1}
bind . <$M1B-minus> {incrfont -1}
bind . <$M1B-KP_Subtract> {incrfont -1}
wm protocol . WM_DELETE_WINDOW doquit
bind . <Button-1> "click %W"
bind $fstring <Key-Return> dofind
Expand Down Expand Up @@ -1101,12 +1107,17 @@ proc keys {} {
raise $w
return
}
if {[tk windowingsystem] eq {aqua}} {
set M1T Cmd
} else {
set M1T Ctrl
}
toplevel $w
wm title $w "Gitk key bindings"
message $w.m -text {
message $w.m -text "
Gitk key bindings:
<Ctrl-Q> Quit
<$M1T-Q> Quit
<Home> Move to first commit
<End> Move to last commit
<Up>, p, i Move up one commit
Expand All @@ -1115,33 +1126,33 @@ Gitk key bindings:
<Right>, x, l Go forward in history list
<PageUp> Move up one page in commit list
<PageDown> Move down one page in commit list
<Ctrl-Home> Scroll to top of commit list
<Ctrl-End> Scroll to bottom of commit list
<Ctrl-Up> Scroll commit list up one line
<Ctrl-Down> Scroll commit list down one line
<Ctrl-PageUp> Scroll commit list up one page
<Ctrl-PageDown> Scroll commit list down one page
<$M1T-Home> Scroll to top of commit list
<$M1T-End> Scroll to bottom of commit list
<$M1T-Up> Scroll commit list up one line
<$M1T-Down> Scroll commit list down one line
<$M1T-PageUp> Scroll commit list up one page
<$M1T-PageDown> Scroll commit list down one page
<Shift-Up> Move to previous highlighted line
<Shift-Down> Move to next highlighted line
<Delete>, b Scroll diff view up one page
<Backspace> Scroll diff view up one page
<Space> Scroll diff view down one page
u Scroll diff view up 18 lines
d Scroll diff view down 18 lines
<Ctrl-F> Find
<Ctrl-G> Move to next find hit
<$M1T-F> Find
<$M1T-G> Move to next find hit
<Return> Move to next find hit
/ Move to next find hit, or redo find
? Move to previous find hit
f Scroll diff view to next file
<Ctrl-S> Search for next hit in diff view
<Ctrl-R> Search for previous hit in diff view
<Ctrl-KP+> Increase font size
<Ctrl-plus> Increase font size
<Ctrl-KP-> Decrease font size
<Ctrl-minus> Decrease font size
<$M1T-S> Search for next hit in diff view
<$M1T-R> Search for previous hit in diff view
<$M1T-KP+> Increase font size
<$M1T-plus> Increase font size
<$M1T-KP-> Decrease font size
<$M1T-minus> Decrease font size
<F5> Update
} \
" \
-justify left -bg white -border 2 -relief groove
pack $w.m -side top -fill both -padx 2 -pady 2
$w.m configure -font $uifont
Expand Down

0 comments on commit d23d98d

Please sign in to comment.