@matheusbsbs / matheus-bagliano / commits / f4c54b3cc4
Fork 0

gitk: Synchronize highlighting in file view for 'f' and 'b' commands

This is based on a patch by Eric Raible <raible@gmail.com>, but does things a bit more simply. Previously, 'b', backspace, and delete all did the same thing. This changes 'b' to perform the inverse of 'f'. And both of them now highlight the filename of the currently diff. This makes it easier to review and navigate the diffs associated with a particular commit using only f, b, and space because the filename of the currently display diff will be dynamically highlighted. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed May 10, 2008 at 13:15 UTC f4c54b3cc4b1bbde34fe957ac03f9862ec970de3
1 file changed +25 -7
gitk
+25 -7
@@ -1016,7 +1016,7 @@ proc makewindow {} {
1016 bindkey k "selnextline 1"
1017 bindkey j "goback"
1018 bindkey l "goforw"
1019 - bindkey b "$ctext yview scroll -1 pages"
1019 + bindkey b prevfile
1020 bindkey d "$ctext yview scroll 18 units"
1021 bindkey u "$ctext yview scroll -18 units"
1022 bindkey / {dofind 1 1}
@@ -5479,26 +5479,44 @@ proc changediffdisp {} {
5479 $ctext tag conf d1 -elide [lindex $diffelide 1]
5480 }
5481
5482 +proc highlightfile {loc cline} {
5483 + global ctext cflist cflist_top
5484 +
5485 + $ctext yview $loc
5486 + $cflist tag remove highlight $cflist_top.0 "$cflist_top.0 lineend"
5487 + $cflist tag add highlight $cline.0 "$cline.0 lineend"
5488 + $cflist see $cline.0
5489 + set cflist_top $cline
5490 +}
5491 +
5492 proc prevfile {} {
5483 - global difffilestart ctext
5484 - set prev [lindex $difffilestart 0]
5493 + global difffilestart ctext cmitmode
5494 +
5495 + if {$cmitmode eq "tree"} return
5496 + set prev 0.0
5497 + set prevline 1
5498 set here [$ctext index @0,0]
5499 foreach loc $difffilestart {
5500 if {[$ctext compare $loc >= $here]} {
5488 - $ctext yview $prev
5501 + highlightfile $prev $prevline
5502 return
5503 }
5504 set prev $loc
5505 + incr prevline
5506 }
5493 - $ctext yview $prev
5507 + highlightfile $prev $prevline
5508 }
5509
5510 proc nextfile {} {
5497 - global difffilestart ctext
5511 + global difffilestart ctext cmitmode
5512 +
5513 + if {$cmitmode eq "tree"} return
5514 set here [$ctext index @0,0]
5515 + set line 1
5516 foreach loc $difffilestart {
5517 + incr line
5518 if {[$ctext compare $loc > $here]} {
5501 - $ctext yview $loc
5519 + highlightfile $loc $line
5520 return
5521 }
5522 }