aboutsummaryrefslogtreecommitdiff
path: root/gitk
diff options
context:
space:
mode:
authorRutger Nijlunsing <git@tux.tmfweb.nl>2006-04-05 10:24:03 +1000
committerPaul Mackerras <paulus@samba.org>2006-04-05 10:24:03 +1000
commit6e5f7203de440fd46c6709a9f71a7e0641363a5c (patch)
tree0055f397e4f7f8b511f689d3cd788fd37c5c9495 /gitk
parent4e95e1f738720e2f768098f73e76109c15a4e1ff (diff)
downloadgit-6e5f7203de440fd46c6709a9f71a7e0641363a5c.tar.gz
git-6e5f7203de440fd46c6709a9f71a7e0641363a5c.tar.xz
[PATCH] gitk: add key bindings for selecting first and last commit
For a keyboard addict like me some keys are still missing from gitk. Especially a key to select a commit when no commit is selected, like just after startup. While we're at it, complete the bindings for moving the view seperately from the selected line. Currently, the up and down keys act on the selected line while pageup and pagedown act on the commits viewed. The idea is to have to normal keys change the selected line: - Home selects first commit - End selects last commit - Up selects previous commit - Down selects next commit - PageUp moves selected line one page up - PageDown moves selected line one page down ...and together with the Control key, it moves the commits view: - Control-Home views first page of commits - Control-End views last page of commits - Control-Up moves commit view one line up - Control-Down moves commit view one line down - Control-PageUp moves commit view one page up - Control-PageDown moves commit view one page down Signed-off-By: Rutger Nijlunsing <gitk@tux.tmfweb.nl> and with some cleanups and simplifications... Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'gitk')
-rwxr-xr-xgitk75
1 files changed, 69 insertions, 6 deletions
diff --git a/gitk b/gitk
index 472c12afc..8aff933e4 100755
--- a/gitk
+++ b/gitk
@@ -504,12 +504,20 @@ proc makewindow {rargs} {
bindall <ButtonRelease-5> "allcanvs yview scroll 5 units"
bindall <2> "canvscan mark %W %x %y"
bindall <B2-Motion> "canvscan dragto %W %x %y"
+ bindkey <Home> selfirstline
+ bindkey <End> sellastline
bind . <Key-Up> "selnextline -1"
bind . <Key-Down> "selnextline 1"
- bind . <Key-Right> "goforw"
- bind . <Key-Left> "goback"
- bind . <Key-Prior> "allcanvs yview scroll -1 pages"
- bind . <Key-Next> "allcanvs yview scroll 1 pages"
+ bindkey <Key-Right> "goforw"
+ 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"
bindkey <Key-Delete> "$ctext yview scroll -1 pages"
bindkey <Key-BackSpace> "$ctext yview scroll -1 pages"
bindkey <Key-space> "$ctext yview scroll 1 pages"
@@ -731,12 +739,20 @@ proc keys {} {
Gitk key bindings:
<Ctrl-Q> Quit
+<Home> Move to first commit
+<End> Move to last commit
<Up>, p, i Move up one commit
<Down>, n, k Move down one commit
<Left>, z, j Go back in history list
<Right>, x, l Go forward in history list
-<Page up> Scroll commit list up one page
-<Page down> Scroll commit list down one page
+<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
<Delete>, b Scroll diff view up one page
<Backspace> Scroll diff view up one page
<Space> Scroll diff view down one page
@@ -2331,6 +2347,22 @@ proc appendwithlinks {text} {
$ctext tag bind link <Leave> { %W configure -cursor $curtextcursor }
}
+proc viewnextline {dir} {
+ global canv linespc
+
+ $canv delete hover
+ set ymax [lindex [$canv cget -scrollregion] 3]
+ set wnow [$canv yview]
+ set wtop [expr {[lindex $wnow 0] * $ymax}]
+ set newtop [expr {$wtop + $dir * $linespc}]
+ if {$newtop < 0} {
+ set newtop 0
+ } elseif {$newtop > $ymax} {
+ set newtop $ymax
+ }
+ allcanvs yview moveto [expr {$newtop * 1.0 / $ymax}]
+}
+
proc selectline {l isnew} {
global canv canv2 canv3 ctext commitinfo selectedline
global displayorder linehtag linentag linedtag
@@ -2466,6 +2498,18 @@ proc selectline {l isnew} {
}
}
+proc selfirstline {} {
+ unmarkmatches
+ selectline 0 1
+}
+
+proc sellastline {} {
+ global numcommits
+ unmarkmatches
+ set l [expr {$numcommits - 1}]
+ selectline $l 1
+}
+
proc selnextline {dir} {
global selectedline
if {![info exists selectedline]} return
@@ -2474,6 +2518,25 @@ proc selnextline {dir} {
selectline $l 1
}
+proc selnextpage {dir} {
+ global canv linespc selectedline numcommits
+
+ set lpp [expr {([winfo height $canv] - 2) / $linespc}]
+ if {$lpp < 1} {
+ set lpp 1
+ }
+ allcanvs yview scroll [expr {$dir * $lpp}] units
+ if {![info exists selectedline]} return
+ set l [expr {$selectedline + $dir * $lpp}]
+ if {$l < 0} {
+ set l 0
+ } elseif {$l >= $numcommits} {
+ set l [expr $numcommits - 1]
+ }
+ unmarkmatches
+ selectline $l 1
+}
+
proc unselectline {} {
global selectedline