X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=gitk;h=8d25c32d653f9ffd30cb8c6543c33212de1d89c9;hb=39ad85705cb2e9665a71d55e2d84b6ab8bc40d6d;hp=5d65e74e425c0b1eb34527289c64481e6a07bcfd;hpb=173860663e62b517e51a71cefe9c6d463afb281d;p=git.git diff --git a/gitk b/gitk index 5d65e74e..8d25c32d 100755 --- a/gitk +++ b/gitk @@ -7,7 +7,7 @@ exec wish "$0" -- "${1+$@}" # and distributed under the terms of the GNU General Public Licence, # either version 2, or (at your option) any later version. -# CVS $Revision: 1.15 $ +# CVS $Revision: 1.17 $ proc getcommits {rargs} { global commits commfd phase canv mainfont @@ -257,6 +257,7 @@ proc makewindow {} { bindkey u "$ctext yview scroll -18 u" bindkey / findnext bindkey ? findprev + bindkey f nextfile bind . doquit bind . dofind bind . findnext @@ -395,13 +396,13 @@ proc about {} { toplevel $w wm title $w "About gitk" message $w.m -text { -Gitk version 0.95 +Gitk version 1.0 Copyright © 2005 Paul Mackerras Use and redistribute under the terms of the GNU General Public License -(CVS $Revision: 1.15 $)} \ +(CVS $Revision: 1.17 $)} \ -justify center -aspect 400 pack $w.m -side top -fill x -padx 20 -pady 20 button $w.ok -text Close -command "destroy $w" @@ -903,23 +904,37 @@ proc selectline {l} { $canv3 lower $t set y [expr {$canvy0 + $l * $linespc}] set ymax [lindex [$canv cget -scrollregion] 3] - set ytop [expr {($y - $linespc / 2.0 - 1) / $ymax}] - set ybot [expr {($y + $linespc / 2.0 + 1) / $ymax}] + set ytop [expr {$y - $linespc - 1}] + set ybot [expr {$y + $linespc + 1}] set wnow [$canv yview] - set scrincr [expr {$linespc * 1.0 / $ymax}] - set wtop [lindex $wnow 0] + set wtop [expr [lindex $wnow 0] * $ymax] + set wbot [expr [lindex $wnow 1] * $ymax] + set wh [expr {$wbot - $wtop}] + set newtop $wtop if {$ytop < $wtop} { - if {$ytop > $wtop - $scrincr} { - set ytop [expr {$wtop - $scrincr}] + if {$ybot < $wtop} { + set newtop [expr {$y - $wh / 2.0}] + } else { + set newtop $ytop + if {$newtop > $wtop - $linespc} { + set newtop [expr {$wtop - $linespc}] + } } - allcanvs yview moveto $ytop - } elseif {$ybot > [lindex $wnow 1]} { - set wh [expr {[lindex $wnow 1] - $wtop}] - set ytop [expr {$ybot - $wh}] - if {$ytop < $wtop + $scrincr} { - set ytop [expr {$wtop + $scrincr}] + } elseif {$ybot > $wbot} { + if {$ytop > $wbot} { + set newtop [expr {$y - $wh / 2.0}] + } else { + set newtop [expr {$ybot - $wh}] + if {$newtop < $wtop + $linespc} { + set newtop [expr {$wtop + $linespc}] + } } - allcanvs yview moveto $ytop + } + if {$newtop != $wtop} { + if {$newtop < 0} { + set newtop 0 + } + allcanvs yview moveto [expr $newtop * 1.0 / $ymax] } set selectedline $l @@ -1008,6 +1023,7 @@ proc gettreediffline {gdtf id} { proc getblobdiffs {id} { global parents diffopts blobdifffd env curdifftag curtagstart + global diffindex difffilestart set p [lindex $parents($id) 0] set env(GIT_DIFF_OPTS) $diffopts if [catch {set bdf [open "|git-diff-tree -r -p $p $id" r]} err] { @@ -1018,12 +1034,14 @@ proc getblobdiffs {id} { set blobdifffd($id) $bdf set curdifftag Comments set curtagstart 0.0 + set diffindex 0 + catch {unset difffilestart} fileevent $bdf readable "getblobdiffline $bdf $id" } proc getblobdiffline {bdf id} { global currentid blobdifffd ctext curdifftag curtagstart seenfile - global diffnexthead + global diffnexthead diffnextnote diffindex difffilestart set n [gets $bdf line] if {$n < 0} { if {[eof $bdf]} { @@ -1045,21 +1063,35 @@ proc getblobdiffline {bdf id} { $ctext tag add $curdifftag $curtagstart end set seenfile($curdifftag) 1 set curtagstart [$ctext index "end - 1c"] + set header $fname if {[info exists diffnexthead]} { set fname $diffnexthead + set header "$diffnexthead ($diffnextnote)" unset diffnexthead } + set difffilestart($diffindex) [$ctext index "end - 1c"] + incr diffindex set curdifftag "f:$fname" $ctext tag delete $curdifftag - set l [expr {(78 - [string length $fname]) / 2}] + set l [expr {(78 - [string length $header]) / 2}] set pad [string range "----------------------------------------" 1 $l] - $ctext insert end "$pad $fname $pad\n" filesep + $ctext insert end "$pad $header $pad\n" filesep } elseif {[string range $line 0 2] == "+++"} { # no need to do anything with this - } elseif {[regexp {^Created: (.*) \(mode: *[0-7]*\)} $line match fn]} { + } elseif {[regexp {^Created: (.*) \((mode: *[0-7]*)\)} $line match fn m]} { set diffnexthead $fn + set diffnextnote "created, mode $m" } elseif {[string range $line 0 8] == "Deleted: "} { set diffnexthead [string range $line 9 end] + set diffnextnote "deleted" + } elseif {[regexp {^diff --git a/(.*) b/} $line match fn]} { + # save the filename in case the next thing is "new file mode ..." + set diffnexthead $fn + set diffnextnote "modified" + } elseif {[regexp {^new file mode ([0-7]+)} $line match m]} { + set diffnextnote "new file, mode $m" + } elseif {[string range $line 0 11] == "deleted file"} { + set diffnextnote "deleted" } elseif {[regexp {^@@ -([0-9]+),([0-9]+) \+([0-9]+),([0-9]+) @@(.*)} \ $line match f1l f1c f2l f2c rest]} { $ctext insert end "\t" hunksep @@ -1074,6 +1106,9 @@ proc getblobdiffline {bdf id} { } elseif {$x == " "} { set line [string range $line 1 end] $ctext insert end "$line\n" + } elseif {$x == "\\"} { + # e.g. "\ No newline at end of file" + $ctext insert end "$line\n" filesep } else { # Something else we don't recognize if {$curdifftag != "Comments"} { @@ -1089,6 +1124,17 @@ proc getblobdiffline {bdf id} { $ctext conf -state disabled } +proc nextfile {} { + global difffilestart ctext + set here [$ctext index @0,0] + for {set i 0} {[info exists difffilestart($i)]} {incr i} { + if {[$ctext compare $difffilestart($i) > $here]} { + $ctext yview $difffilestart($i) + break + } + } +} + proc listboxsel {} { global ctext cflist currentid treediffs seenfile if {![info exists currentid]} return