@matheusbsbs / matheus-bagliano / commits / 322a8cc9b3
Fork 0

gitk: New algorithm for drawing the graph lines

This only draws as much of the graph lines as is visible. This can happen by adding coordinates on to an existing graph line or by creating a new line. This means that we only need to have laid out and optimized as much of the graph as is actually visible in order to draw it, including the lines (previously we didn't draw a graph line until we had laid out and optimized to the end of a segment of the line, i.e. down to a down-arrow or to the row where the line's commit is displayed). This also lets us get rid of the linesegends list, and gives us an easy workaround for the X server bug that causes long lines to be misdrawn. This also gets rid of the use of rowoffsets in drawlineseg et al. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Oct 15, 2006 at 18:03 UTC 322a8cc9b31217c883c42b9babbbdea7f522eeb7
1 file changed +297 -185
gitk
+297 -185
@@ -1750,7 +1750,7 @@ proc showview {n} {
1750 global selectedline currentid canv canvy0
1751 global matchinglines treediffs
1752 global pending_select phase
1753 - global commitidx rowlaidout rowoptim linesegends
1753 + global commitidx rowlaidout rowoptim
1754 global commfd
1755 global selectedview selectfirst
1756 global vparentlist vchildlist vdisporder vcmitlisted
@@ -1786,7 +1786,7 @@ proc showview {n} {
1786 set viewdata($curview) \
1787 [list $phase $rowidlist $rowoffsets $rowrangelist \
1788 [flatten idrowranges] [flatten idinlist] \
1789 - $rowlaidout $rowoptim $numcommits $linesegends]
1789 + $rowlaidout $rowoptim $numcommits]
1790 } elseif {![info exists viewdata($curview)]
1791 || [lindex $viewdata($curview) 0] ne {}} {
1792 set viewdata($curview) \
@@ -1832,7 +1832,6 @@ proc showview {n} {
1832 set rowlaidout [lindex $v 6]
1833 set rowoptim [lindex $v 7]
1834 set numcommits [lindex $v 8]
1835 - set linesegends [lindex $v 9]
1835 }
1836
1837 catch {unset colormap}
@@ -2506,7 +2505,7 @@ proc initlayout {} {
2505 global nextcolor
2506 global parentlist childlist children
2507 global colormap rowtextx
2509 - global linesegends selectfirst
2508 + global selectfirst
2509
2510 set numcommits 0
2511 set displayorder {}
@@ -2525,7 +2524,6 @@ proc initlayout {} {
2524 catch {unset colormap}
2525 catch {unset rowtextx}
2526 catch {unset idrowranges}
2528 - set linesegends {}
2527 set selectfirst 1
2528 }
2529
@@ -2608,8 +2606,7 @@ proc layoutmore {tmax allread} {
2606 }
2607
2608 proc showstuff {canshow} {
2611 - global numcommits commitrow pending_select selectedline
2612 - global linesegends idrangedrawn curview
2609 + global numcommits commitrow pending_select selectedline curview
2610 global displayorder selectfirst
2611
2612 if {$numcommits == 0} {
@@ -2617,33 +2614,16 @@ proc showstuff {canshow} {
2614 set phase "incrdraw"
2615 allcanvs delete all
2616 }
2620 - set row $numcommits
2617 + set r0 $numcommits
2618 set numcommits $canshow
2619 setcanvscroll
2620 set rows [visiblerows]
2624 - set r0 [lindex $rows 0]
2621 set r1 [lindex $rows 1]
2626 - set selrow -1
2627 - for {set r $row} {$r < $canshow} {incr r} {
2628 - foreach id [lindex $linesegends [expr {$r+1}]] {
2629 - set i -1
2630 - set ranges [rowranges $id]
2631 - foreach {s e} $ranges {
2632 - incr i
2633 - if {$e ne {} && $e < $numcommits && $s <= $r1 && $e >= $r0
2634 - && ![info exists idrangedrawn($id,$i)]} {
2635 - drawlineseg $id $i $ranges
2636 - set idrangedrawn($id,$i) 1
2637 - }
2638 - }
2639 - }
2622 + if {$r1 >= $canshow} {
2623 + set r1 [expr {$canshow - 1}]
2624 }
2641 - if {$canshow > $r1} {
2642 - set canshow $r1
2643 - }
2644 - while {$row < $canshow} {
2645 - drawcmitrow $row
2646 - incr row
2625 + if {$r0 <= $r1} {
2626 + drawcommits $r0 $r1
2627 }
2628 if {[info exists pending_select] &&
2629 [info exists commitrow($curview,$pending_select)] &&
@@ -2664,7 +2644,7 @@ proc layoutrows {row endrow last} {
2644 global rowidlist rowoffsets displayorder
2645 global uparrowlen downarrowlen maxwidth mingaplen
2646 global childlist parentlist
2667 - global idrowranges linesegends
2647 + global idrowranges
2648 global commitidx curview
2649 global idinlist rowchk rowrangelist
2650
@@ -2681,7 +2661,6 @@ proc layoutrows {row endrow last} {
2661 lappend oldolds $p
2662 }
2663 }
2684 - set lse {}
2664 set nev [expr {[llength $idlist] + [llength $newolds]
2665 + [llength $oldolds] - $maxwidth + 1}]
2666 if {$nev > 0} {
@@ -2698,7 +2677,6 @@ proc layoutrows {row endrow last} {
2677 set offs [incrange $offs $x 1]
2678 set idinlist($i) 0
2679 set rm1 [expr {$row - 1}]
2701 - lappend lse $i
2680 lappend idrowranges($i) [lindex $displayorder $rm1]
2681 if {[incr nev -1] <= 0} break
2682 continue
@@ -2709,7 +2687,6 @@ proc layoutrows {row endrow last} {
2687 lset rowidlist $row $idlist
2688 lset rowoffsets $row $offs
2689 }
2712 - lappend linesegends $lse
2690 set col [lsearch -exact $idlist $id]
2691 if {$col < 0} {
2692 set col [llength $idlist]
@@ -3004,95 +2981,206 @@ proc rowranges {id} {
2981 return $linenos
2982 }
2983
3007 -proc drawlineseg {id i ranges} {
3008 - global rowoffsets rowidlist
3009 - global displayorder
3010 - global canv colormap linespc
3011 - global numcommits commitrow curview
2984 +# work around tk8.4 refusal to draw arrows on diagonal segments
2985 +proc adjarrowhigh {coords} {
2986 + global linespc
2987
3013 - set downarrow 1
3014 - if {[info exists commitrow($curview,$id)]
3015 - && $commitrow($curview,$id) < $numcommits} {
3016 - set downarrow [expr {$i < [llength $ranges] / 2 - 1}]
3017 - } else {
3018 - set downarrow 1
3019 - }
3020 - set startrow [lindex $ranges [expr {2 * $i}]]
3021 - set row [lindex $ranges [expr {2 * $i + 1}]]
3022 - if {$startrow == $row} return
3023 - assigncolor $id
3024 - set coords {}
3025 - set col [lsearch -exact [lindex $rowidlist $row] $id]
3026 - if {$col < 0} {
3027 - puts "oops: drawline: id $id not on row $row"
3028 - return
2988 + set x0 [lindex $coords 0]
2989 + set x1 [lindex $coords 2]
2990 + if {$x0 != $x1} {
2991 + set y0 [lindex $coords 1]
2992 + set y1 [lindex $coords 3]
2993 + if {$y0 - $y1 <= 2 * $linespc && $x1 == [lindex $coords 4]} {
2994 + # we have a nearby vertical segment, just trim off the diag bit
2995 + set coords [lrange $coords 2 end]
2996 + } else {
2997 + set slope [expr {($x0 - $x1) / ($y0 - $y1)}]
2998 + set xi [expr {$x0 - $slope * $linespc / 2}]
2999 + set yi [expr {$y0 - $linespc / 2}]
3000 + set coords [lreplace $coords 0 1 $xi $y0 $xi $yi]
3001 + }
3002 }
3030 - set lasto {}
3031 - set ns 0
3003 + return $coords
3004 +}
3005 +
3006 +proc drawlineseg {id row endrow arrowlow} {
3007 + global rowidlist displayorder iddrawn linesegs
3008 + global canv colormap linespc curview maxlinelen
3009 +
3010 + set cols [list [lsearch -exact [lindex $rowidlist $row] $id]]
3011 + set le [expr {$row + 1}]
3012 + set arrowhigh 1
3013 while {1} {
3033 - set o [lindex $rowoffsets $row $col]
3034 - if {$o eq {}} break
3035 - if {$o ne $lasto} {
3036 - # changing direction
3037 - set x [xc $row $col]
3038 - set y [yc $row]
3039 - lappend coords $x $y
3040 - set lasto $o
3014 + set c [lsearch -exact [lindex $rowidlist $le] $id]
3015 + if {$c < 0} {
3016 + incr le -1
3017 + break
3018 + }
3019 + lappend cols $c
3020 + set x [lindex $displayorder $le]
3021 + if {$x eq $id} {
3022 + set arrowhigh 0
3023 + break
3024 }
3042 - incr col $o
3043 - incr row -1
3025 + if {[info exists iddrawn($x)] || $le == $endrow} {
3026 + set c [lsearch -exact [lindex $rowidlist [expr {$le+1}]] $id]
3027 + if {$c >= 0} {
3028 + lappend cols $c
3029 + set arrowhigh 0
3030 + }
3031 + break
3032 + }
3033 + incr le
3034 }
3045 - set x [xc $row $col]
3046 - set y [yc $row]
3047 - lappend coords $x $y
3048 - if {$i == 0} {
3049 - # draw the link to the first child as part of this line
3050 - incr row -1
3051 - set child [lindex $displayorder $row]
3052 - set ccol [lsearch -exact [lindex $rowidlist $row] $child]
3053 - if {$ccol >= 0} {
3054 - set x [xc $row $ccol]
3055 - set y [yc $row]
3056 - if {$ccol < $col - 1} {
3057 - lappend coords [xc $row [expr {$col - 1}]] [yc $row]
3058 - } elseif {$ccol > $col + 1} {
3059 - lappend coords [xc $row [expr {$col + 1}]] [yc $row]
3035 + if {$le <= $row} {
3036 + return $row
3037 + }
3038 +
3039 + set lines {}
3040 + set i 0
3041 + set joinhigh 0
3042 + if {[info exists linesegs($id)]} {
3043 + set lines $linesegs($id)
3044 + foreach li $lines {
3045 + set r0 [lindex $li 0]
3046 + if {$r0 > $row} {
3047 + if {$r0 == $le && [lindex $li 1] - $row <= $maxlinelen} {
3048 + set joinhigh 1
3049 + }
3050 + break
3051 + }
3052 + incr i
3053 + }
3054 + }
3055 + set joinlow 0
3056 + if {$i > 0} {
3057 + set li [lindex $lines [expr {$i-1}]]
3058 + set r1 [lindex $li 1]
3059 + if {$r1 == $row && $le - [lindex $li 0] <= $maxlinelen} {
3060 + set joinlow 1
3061 + }
3062 + }
3063 +
3064 + set x [lindex $cols [expr {$le - $row}]]
3065 + set xp [lindex $cols [expr {$le - 1 - $row}]]
3066 + set dir [expr {$xp - $x}]
3067 + if {$joinhigh} {
3068 + set ith [lindex $lines $i 2]
3069 + set coords [$canv coords $ith]
3070 + set ah [$canv itemcget $ith -arrow]
3071 + set arrowhigh [expr {$ah eq "first" || $ah eq "both"}]
3072 + set x2 [lindex $cols [expr {$le + 1 - $row}]]
3073 + if {$x2 ne {} && $x - $x2 == $dir} {
3074 + set coords [lrange $coords 0 end-2]
3075 + }
3076 + } else {
3077 + set coords [list [xc $le $x] [yc $le]]
3078 + }
3079 + if {$joinlow} {
3080 + set itl [lindex $lines [expr {$i-1}] 2]
3081 + set al [$canv itemcget $itl -arrow]
3082 + set arrowlow [expr {$al eq "last" || $al eq "both"}]
3083 + } elseif {$arrowlow &&
3084 + [lsearch -exact [lindex $rowidlist [expr {$row-1}]] $id] >= 0} {
3085 + set arrowlow 0
3086 + }
3087 + set arrow [lindex {none first last both} [expr {$arrowhigh + 2*$arrowlow}]]
3088 + for {set y $le} {[incr y -1] > $row} {} {
3089 + set x $xp
3090 + set xp [lindex $cols [expr {$y - 1 - $row}]]
3091 + set ndir [expr {$xp - $x}]
3092 + if {$dir != $ndir || $xp < 0} {
3093 + lappend coords [xc $y $x] [yc $y]
3094 + }
3095 + set dir $ndir
3096 + }
3097 + if {!$joinlow} {
3098 + if {$xp < 0} {
3099 + # join parent line to first child
3100 + set ch [lindex $displayorder $row]
3101 + set xc [lsearch -exact [lindex $rowidlist $row] $ch]
3102 + if {$xc < 0} {
3103 + puts "oops: drawlineseg: child $ch not on row $row"
3104 + } else {
3105 + if {$xc < $x - 1} {
3106 + lappend coords [xc $row [expr {$x-1}]] [yc $row]
3107 + } elseif {$xc > $x + 1} {
3108 + lappend coords [xc $row [expr {$x+1}]] [yc $row]
3109 + }
3110 + set x $xc
3111 }
3061 - lappend coords $x $y
3062 - }
3063 - }
3064 - if {[llength $coords] < 4} return
3065 - if {$downarrow} {
3066 - # This line has an arrow at the lower end: check if the arrow is
3067 - # on a diagonal segment, and if so, work around the Tk 8.4
3068 - # refusal to draw arrows on diagonal lines.
3069 - set x0 [lindex $coords 0]
3070 - set x1 [lindex $coords 2]
3071 - if {$x0 != $x1} {
3072 - set y0 [lindex $coords 1]
3073 - set y1 [lindex $coords 3]
3074 - if {$y0 - $y1 <= 2 * $linespc && $x1 == [lindex $coords 4]} {
3075 - # we have a nearby vertical segment, just trim off the diag bit
3076 - set coords [lrange $coords 2 end]
3112 + lappend coords [xc $row $x] [yc $row]
3113 + } else {
3114 + set xn [xc $row $xp]
3115 + set yn [yc $row]
3116 + # work around tk8.4 refusal to draw arrows on diagonal segments
3117 + if {$arrowlow && $xn != [lindex $coords end-1]} {
3118 + if {[llength $coords] < 4 ||
3119 + [lindex $coords end-3] != [lindex $coords end-1] ||
3120 + [lindex $coords end] - $yn > 2 * $linespc} {
3121 + set xn [xc $row [expr {$xp - 0.5 * $dir}]]
3122 + set yo [yc [expr {$row + 0.5}]]
3123 + lappend coords $xn $yo $xn $yn
3124 + }
3125 } else {
3078 - set slope [expr {($x0 - $x1) / ($y0 - $y1)}]
3079 - set xi [expr {$x0 - $slope * $linespc / 2}]
3080 - set yi [expr {$y0 - $linespc / 2}]
3081 - set coords [lreplace $coords 0 1 $xi $y0 $xi $yi]
3126 + lappend coords $xn $yn
3127 + }
3128 + }
3129 + if {!$joinhigh} {
3130 + if {$arrowhigh} {
3131 + set coords [adjarrowhigh $coords]
3132 + }
3133 + assigncolor $id
3134 + set t [$canv create line $coords -width [linewidth $id] \
3135 + -fill $colormap($id) -tags lines.$id -arrow $arrow]
3136 + $canv lower $t
3137 + bindline $t $id
3138 + set lines [linsert $lines $i [list $row $le $t]]
3139 + } else {
3140 + $canv coords $ith $coords
3141 + if {$arrow ne $ah} {
3142 + $canv itemconf $ith -arrow $arrow
3143 + }
3144 + lset lines $i 0 $row
3145 + }
3146 + } else {
3147 + set xo [lsearch -exact [lindex $rowidlist [expr {$row - 1}]] $id]
3148 + set ndir [expr {$xo - $xp}]
3149 + set clow [$canv coords $itl]
3150 + if {$dir == $ndir} {
3151 + set clow [lrange $clow 2 end]
3152 + }
3153 + set coords [concat $coords $clow]
3154 + if {!$joinhigh} {
3155 + lset lines [expr {$i-1}] 1 $le
3156 + if {$arrowhigh} {
3157 + set coords [adjarrowhigh $coords]
3158 }
3159 + } else {
3160 + # coalesce two pieces
3161 + $canv delete $ith
3162 + set b [lindex $lines [expr {$i-1}] 0]
3163 + set e [lindex $lines $i 1]
3164 + set lines [lreplace $lines [expr {$i-1}] $i [list $b $e $itl]]
3165 + }
3166 + $canv coords $itl $coords
3167 + if {$arrow ne $al} {
3168 + $canv itemconf $itl -arrow $arrow
3169 }
3170 }
3085 - set arrow [expr {2 * ($i > 0) + $downarrow}]
3086 - set arrow [lindex {none first last both} $arrow]
3087 - set t [$canv create line $coords -width [linewidth $id] \
3088 - -fill $colormap($id) -tags lines.$id -arrow $arrow]
3089 - $canv lower $t
3090 - bindline $t $id
3171 +
3172 + set linesegs($id) $lines
3173 + return $le
3174 }
3175
3093 -proc drawparentlinks {id row col olds} {
3094 - global rowidlist canv colormap
3176 +proc drawparentlinks {id row} {
3177 + global rowidlist canv colormap curview parentlist
3178 + global idpos
3179
3180 + set rowids [lindex $rowidlist $row]
3181 + set col [lsearch -exact $rowids $id]
3182 + if {$col < 0} return
3183 + set olds [lindex $parentlist $row]
3184 set row2 [expr {$row + 1}]
3185 set x [xc $row $col]
3186 set y [yc $row]
@@ -3110,9 +3198,7 @@ proc drawparentlinks {id row col olds} {
3198 if {$x2 > $rmx} {
3199 set rmx $x2
3200 }
3113 - set ranges [rowranges $p]
3114 - if {$ranges ne {} && $row2 == [lindex $ranges 0]
3115 - && $row2 < [lindex $ranges 1]} {
3201 + if {[lsearch -exact $rowids $p] < 0} {
3202 # drawlineseg will do this one for us
3203 continue
3204 }
@@ -3130,36 +3216,21 @@ proc drawparentlinks {id row col olds} {
3216 $canv lower $t
3217 bindline $t $p
3218 }
3133 - return $rmx
3219 + if {$rmx > [lindex $idpos($id) 1]} {
3220 + lset idpos($id) 1 $rmx
3221 + redrawtags $id
3222 + }
3223 }
3224
3225 proc drawlines {id} {
3137 - global colormap canv
3138 - global idrangedrawn
3139 - global children iddrawn commitrow rowidlist curview
3226 + global canv
3227
3141 - $canv delete lines.$id
3142 - set ranges [rowranges $id]
3143 - set nr [expr {[llength $ranges] / 2}]
3144 - for {set i 0} {$i < $nr} {incr i} {
3145 - if {[info exists idrangedrawn($id,$i)]} {
3146 - drawlineseg $id $i $ranges
3147 - }
3148 - }
3149 - foreach child $children($curview,$id) {
3150 - if {[info exists iddrawn($child)]} {
3151 - set row $commitrow($curview,$child)
3152 - set col [lsearch -exact [lindex $rowidlist $row] $child]
3153 - if {$col >= 0} {
3154 - drawparentlinks $child $row $col [list $id]
3155 - }
3156 - }
3157 - }
3228 + $canv itemconf lines.$id -width [linewidth $id]
3229 }
3230
3160 -proc drawcmittext {id row col rmx} {
3231 +proc drawcmittext {id row col} {
3232 global linespc canv canv2 canv3 canvy0 fgcolor
3162 - global commitlisted commitinfo rowidlist
3233 + global commitlisted commitinfo rowidlist parentlist
3234 global rowtextx idpos idtags idheads idotherrefs
3235 global linehtag linentag linedtag
3236 global mainfont canvxmax boldrows boldnamerows fgcolor
@@ -3173,10 +3244,18 @@ proc drawcmittext {id row col rmx} {
3244 -fill $ofill -outline $fgcolor -width 1 -tags circle]
3245 $canv raise $t
3246 $canv bind $t <1> {selcanvline {} %x %y}
3176 - set xt [xc $row [llength [lindex $rowidlist $row]]]
3177 - if {$xt < $rmx} {
3178 - set xt $rmx
3247 + set rmx [llength [lindex $rowidlist $row]]
3248 + set olds [lindex $parentlist $row]
3249 + if {$olds ne {}} {
3250 + set nextids [lindex $rowidlist [expr {$row + 1}]]
3251 + foreach p $olds {
3252 + set i [lsearch -exact $nextids $p]
3253 + if {$i > $rmx} {
3254 + set rmx $i
3255 + }
3256 + }
3257 }
3258 + set xt [xc $row $rmx]
3259 set rowtextx($row) $xt
3260 set idpos($id) [list $x $xt $y]
3261 if {[info exists idtags($id)] || [info exists idheads($id)]
@@ -3214,30 +3293,13 @@ proc drawcmittext {id row col rmx} {
3293
3294 proc drawcmitrow {row} {
3295 global displayorder rowidlist
3217 - global idrangedrawn iddrawn
3296 + global iddrawn
3297 global commitinfo parentlist numcommits
3298 global filehighlight fhighlights findstring nhighlights
3299 global hlview vhighlights
3300 global highlight_related rhighlights
3301
3302 if {$row >= $numcommits} return
3224 - foreach id [lindex $rowidlist $row] {
3225 - if {$id eq {}} continue
3226 - set i -1
3227 - set ranges [rowranges $id]
3228 - foreach {s e} $ranges {
3229 - incr i
3230 - if {$row < $s} continue
3231 - if {$e eq {}} break
3232 - if {$row <= $e} {
3233 - if {$e < $numcommits && ![info exists idrangedrawn($id,$i)]} {
3234 - drawlineseg $id $i $ranges
3235 - set idrangedrawn($id,$i) 1
3236 - }
3237 - break
3238 - }
3239 - }
3240 - }
3303
3304 set id [lindex $displayorder $row]
3305 if {[info exists hlview] && ![info exists vhighlights($row)]} {
@@ -3262,49 +3324,99 @@ proc drawcmitrow {row} {
3324 getcommit $id
3325 }
3326 assigncolor $id
3265 - set olds [lindex $parentlist $row]
3266 - if {$olds ne {}} {
3267 - set rmx [drawparentlinks $id $row $col $olds]
3268 - } else {
3269 - set rmx 0
3270 - }
3271 - drawcmittext $id $row $col $rmx
3327 + drawcmittext $id $row $col
3328 set iddrawn($id) 1
3329 }
3330
3275 -proc drawfrac {f0 f1} {
3276 - global numcommits canv
3277 - global linespc
3331 +proc drawcommits {row {endrow {}}} {
3332 + global numcommits iddrawn displayorder curview
3333 + global parentlist rowidlist
3334
3279 - set ymax [lindex [$canv cget -scrollregion] 3]
3280 - if {$ymax eq {} || $ymax == 0} return
3281 - set y0 [expr {int($f0 * $ymax)}]
3282 - set row [expr {int(($y0 - 3) / $linespc) - 1}]
3335 if {$row < 0} {
3336 set row 0
3337 }
3286 - set y1 [expr {int($f1 * $ymax)}]
3287 - set endrow [expr {int(($y1 - 3) / $linespc) + 1}]
3338 + if {$endrow eq {}} {
3339 + set endrow $row
3340 + }
3341 if {$endrow >= $numcommits} {
3342 set endrow [expr {$numcommits - 1}]
3343 }
3291 - for {} {$row <= $endrow} {incr row} {
3292 - drawcmitrow $row
3344 +
3345 + # make the lines join to already-drawn rows either side
3346 + set r [expr {$row - 1}]
3347 + if {$r < 0 || ![info exists iddrawn([lindex $displayorder $r])]} {
3348 + set r $row
3349 + }
3350 + set er [expr {$endrow + 1}]
3351 + if {$er >= $numcommits ||
3352 + ![info exists iddrawn([lindex $displayorder $er])]} {
3353 + set er $endrow
3354 + }
3355 + for {} {$r <= $er} {incr r} {
3356 + set id [lindex $displayorder $r]
3357 + set wasdrawn [info exists iddrawn($id)]
3358 + if {!$wasdrawn} {
3359 + drawcmitrow $r
3360 + }
3361 + if {$r == $er} break
3362 + set nextid [lindex $displayorder [expr {$r + 1}]]
3363 + if {$wasdrawn && [info exists iddrawn($nextid)]} {
3364 + catch {unset prevlines}
3365 + continue
3366 + }
3367 + drawparentlinks $id $r
3368 +
3369 + if {[info exists lineends($r)]} {
3370 + foreach lid $lineends($r) {
3371 + unset prevlines($lid)
3372 + }
3373 + }
3374 + set rowids [lindex $rowidlist $r]
3375 + foreach lid $rowids {
3376 + if {$lid eq {}} continue
3377 + if {$lid eq $id} {
3378 + # see if this is the first child of any of its parents
3379 + foreach p [lindex $parentlist $r] {
3380 + if {[lsearch -exact $rowids $p] < 0} {
3381 + # make this line extend up to the child
3382 + set le [drawlineseg $p $r $er 0]
3383 + lappend lineends($le) $p
3384 + set prevlines($p) 1
3385 + }
3386 + }
3387 + } elseif {![info exists prevlines($lid)]} {
3388 + set le [drawlineseg $lid $r $er 1]
3389 + lappend lineends($le) $lid
3390 + set prevlines($lid) 1
3391 + }
3392 + }
3393 }
3394 }
3395
3396 +proc drawfrac {f0 f1} {
3397 + global canv linespc
3398 +
3399 + set ymax [lindex [$canv cget -scrollregion] 3]
3400 + if {$ymax eq {} || $ymax == 0} return
3401 + set y0 [expr {int($f0 * $ymax)}]
3402 + set row [expr {int(($y0 - 3) / $linespc) - 1}]
3403 + set y1 [expr {int($f1 * $ymax)}]
3404 + set endrow [expr {int(($y1 - 3) / $linespc) + 1}]
3405 + drawcommits $row $endrow
3406 +}
3407 +
3408 proc drawvisible {} {
3409 global canv
3410 eval drawfrac [$canv yview]
3411 }
3412
3413 proc clear_display {} {
3302 - global iddrawn idrangedrawn
3414 + global iddrawn linesegs
3415 global vhighlights fhighlights nhighlights rhighlights
3416
3417 allcanvs delete all
3418 catch {unset iddrawn}
3307 - catch {unset idrangedrawn}
3419 + catch {unset linesegs}
3420 catch {unset vhighlights}
3421 catch {unset fhighlights}
3422 catch {unset nhighlights}
@@ -3538,7 +3650,7 @@ proc insertrow {row newcmit} {
3650 global displayorder parentlist childlist commitlisted
3651 global commitrow curview rowidlist rowoffsets numcommits
3652 global rowrangelist rowlaidout rowoptim numcommits
3541 - global linesegends selectedline
3653 + global selectedline
3654
3655 if {$row >= $numcommits} {
3656 puts "oops, inserting new row $row but only have $numcommits rows"
@@ -3592,8 +3704,6 @@ proc insertrow {row newcmit} {
3704 lset rowrangelist $rp1 $ranges
3705 }
3706
3595 - set linesegends [linsert $linesegends $row {}]
3596 -
3707 incr rowlaidout
3708 incr rowoptim
3709 incr numcommits
@@ -3708,13 +3818,13 @@ proc dofind {} {
3818 if {$matches == {}} continue
3819 set doesmatch 1
3820 if {$ty == "Headline"} {
3711 - drawcmitrow $l
3821 + drawcommits $l
3822 markmatches $canv $l $f $linehtag($l) $matches $mainfont
3823 } elseif {$ty == "Author"} {
3714 - drawcmitrow $l
3824 + drawcommits $l
3825 markmatches $canv2 $l $f $linentag($l) $matches $mainfont
3826 } elseif {$ty == "Date"} {
3717 - drawcmitrow $l
3827 + drawcommits $l
3828 markmatches $canv3 $l $f $linedtag($l) $matches $mainfont
3829 }
3830 }
@@ -3807,7 +3917,7 @@ proc stopfindproc {{done 0}} {
3917 proc markheadline {l id} {
3918 global canv mainfont linehtag
3919
3810 - drawcmitrow $l
3920 + drawcommits $l
3921 set bbox [$canv bbox $linehtag($l)]
3922 set t [$canv create rect $bbox -outline {} -tags matches -fill yellow]
3923 $canv lower $t
@@ -5302,10 +5412,11 @@ proc domktag {} {
5412
5413 proc redrawtags {id} {
5414 global canv linehtag commitrow idpos selectedline curview
5305 - global mainfont canvxmax
5415 + global mainfont canvxmax iddrawn
5416
5417 if {![info exists commitrow($curview,$id)]} return
5308 - drawcmitrow $commitrow($curview,$id)
5418 + if {![info exists iddrawn($id)]} return
5419 + drawcommits $commitrow($curview,$id)
5420 $canv delete tag.$id
5421 set xt [eval drawtags $id $idpos($id)]
5422 $canv coords $linehtag($commitrow($curview,$id)) $xt [lindex $idpos($id) 2]
@@ -6947,6 +7058,7 @@ set cmitmode "patch"
7058 set wrapcomment "none"
7059 set showneartags 1
7060 set maxrefs 20
7061 +set maxlinelen 200
7062
7063 set colors {green red blue magenta darkgrey brown orange}
7064 set bgcolor white