@matheusbsbs / matheus-bagliano / commits / 0380081c65
Fork 0

gitk: Do only the parts of the layout that are needed

This changes layoutrows and optimize_rows to make it possible to lay out only a little bit more of the graph than is visible, rather than having to lay out the whole graph from top to bottom. To lay out some of the graph without starting at the top, we use the new make_idlist procedure for the first row, then lay it out proceeding downwards as before. Empty list elements in rowidlist are used to denote rows that haven't been laid out yet. Optimizing happens much as before except that we don't try to optimize unless we have three consecutive rows laid out (or the top 2 rows). We have a new list, rowisopt, to record which rows have been optimized. If we change a row that has already been drawn, we set a flag which causes drawcommits to throw away everything drawn on the canvas and redraw the visible rows. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Aug 29, 2007 at 21:45 UTC 0380081c65c3e8a46caad9aebe8e97ff65510453
1 file changed +263 -225
gitk
+263 -225
@@ -1949,13 +1949,13 @@ proc unflatten {var l} {
1949
1950 proc showview {n} {
1951 global curview viewdata viewfiles
1952 - global displayorder parentlist rowidlist
1952 + global displayorder parentlist rowidlist rowisopt
1953 global colormap rowtextx commitrow nextcolor canvxmax
1954 global numcommits commitlisted
1955 global selectedline currentid canv canvy0
1956 global treediffs
1957 global pending_select phase
1958 - global commitidx rowlaidout rowoptim
1958 + global commitidx
1959 global commfd
1960 global selectedview selectfirst
1961 global vparentlist vdisporder vcmitlisted
@@ -1987,11 +1987,11 @@ proc showview {n} {
1987 set vcmitlisted($curview) $commitlisted
1988 if {$phase ne {}} {
1989 set viewdata($curview) \
1990 - [list $phase $rowidlist $rowlaidout $rowoptim $numcommits]
1990 + [list $phase $rowidlist $rowisopt $numcommits]
1991 } elseif {![info exists viewdata($curview)]
1992 || [lindex $viewdata($curview) 0] ne {}} {
1993 set viewdata($curview) \
1994 - [list {} $rowidlist]
1994 + [list {} $rowidlist $rowisopt]
1995 }
1996 }
1997 catch {unset treediffs}
@@ -2021,12 +2021,11 @@ proc showview {n} {
2021 set parentlist $vparentlist($n)
2022 set commitlisted $vcmitlisted($n)
2023 set rowidlist [lindex $v 1]
2024 + set rowisopt [lindex $v 2]
2025 if {$phase eq {}} {
2026 set numcommits [llength $displayorder]
2027 } else {
2027 - set rowlaidout [lindex $v 2]
2028 - set rowoptim [lindex $v 3]
2029 - set numcommits [lindex $v 4]
2028 + set numcommits [lindex $v 3]
2029 }
2030
2031 catch {unset colormap}
@@ -2625,45 +2624,16 @@ proc shortids {ids} {
2624 return $res
2625 }
2626
2628 -proc incrange {l x o} {
2629 - set n [llength $l]
2630 - while {$x < $n} {
2631 - set e [lindex $l $x]
2632 - if {$e ne {}} {
2633 - lset l $x [expr {$e + $o}]
2634 - }
2635 - incr x
2636 - }
2637 - return $l
2638 -}
2639 -
2627 proc ntimes {n o} {
2628 set ret {}
2642 - for {} {$n > 0} {incr n -1} {
2643 - lappend ret $o
2644 - }
2645 - return $ret
2646 -}
2647 -
2648 -proc usedinrange {id l1 l2} {
2649 - global children commitrow curview
2650 -
2651 - if {[info exists commitrow($curview,$id)]} {
2652 - set r $commitrow($curview,$id)
2653 - if {$l1 <= $r && $r <= $l2} {
2654 - return [expr {$r - $l1 + 1}]
2655 - }
2656 - }
2657 - set kids $children($curview,$id)
2658 - foreach c $kids {
2659 - if {[info exists commitrow($curview,$c)]} {
2660 - set r $commitrow($curview,$c)
2661 - if {$l1 <= $r && $r <= $l2} {
2662 - return [expr {$r - $l1 + 1}]
2663 - }
2629 + set o [list $o]
2630 + for {set mask 1} {$mask <= $n} {incr mask $mask} {
2631 + if {($n & $mask) != 0} {
2632 + set ret [concat $ret $o]
2633 }
2634 + set o [concat $o $o]
2635 }
2666 - return 0
2636 + return $ret
2637 }
2638
2639 # Work out where id should go in idlist so that order-token
@@ -2689,20 +2659,8 @@ proc idcol {idlist id {i 0}} {
2659 return $i
2660 }
2661
2692 -proc makeuparrow {oid y x} {
2693 - global rowidlist uparrowlen displayorder
2694 -
2695 - for {set i 0} {$i < $uparrowlen && $y > 1} {incr i} {
2696 - incr y -1
2697 - set idl [lindex $rowidlist $y]
2698 - set x [idcol $idl $oid $x]
2699 - lset rowidlist $y [linsert $idl $x $oid]
2700 - }
2701 -}
2702 -
2662 proc initlayout {} {
2704 - global rowidlist displayorder commitlisted
2705 - global rowlaidout rowoptim
2663 + global rowidlist rowisopt displayorder commitlisted
2664 global numcommits canvxmax canv
2665 global nextcolor
2666 global parentlist
@@ -2714,9 +2672,8 @@ proc initlayout {} {
2672 set commitlisted {}
2673 set parentlist {}
2674 set nextcolor 0
2717 - set rowidlist {{}}
2718 - set rowlaidout 0
2719 - set rowoptim 0
2675 + set rowidlist {}
2676 + set rowisopt {}
2677 set canvxmax [$canv cget -width]
2678 catch {unset colormap}
2679 catch {unset rowtextx}
@@ -2752,54 +2709,18 @@ proc visiblerows {} {
2709 }
2710
2711 proc layoutmore {tmax allread} {
2755 - global rowlaidout rowoptim commitidx numcommits optim_delay
2756 - global uparrowlen curview rowidlist
2712 + global commitidx numcommits
2713 + global uparrowlen downarrowlen mingaplen curview
2714
2758 - set showlast 0
2759 - set showdelay $optim_delay
2760 - set optdelay [expr {$uparrowlen + 1}]
2761 - while {1} {
2762 - if {$rowoptim - $showdelay > $numcommits} {
2763 - showstuff [expr {$rowoptim - $showdelay}] $showlast
2764 - } elseif {$rowlaidout - $optdelay > $rowoptim} {
2765 - set nr [expr {$rowlaidout - $optdelay - $rowoptim}]
2766 - if {$nr > 100} {
2767 - set nr 100
2768 - }
2769 - optimize_rows $rowoptim 0 [expr {$rowoptim + $nr}]
2770 - incr rowoptim $nr
2771 - } elseif {$commitidx($curview) > $rowlaidout} {
2772 - set nr [expr {$commitidx($curview) - $rowlaidout}]
2773 - # may need to increase this threshold if uparrowlen or
2774 - # mingaplen are increased...
2775 - if {$nr > 200} {
2776 - set nr 200
2777 - }
2778 - set row $rowlaidout
2779 - set rowlaidout [layoutrows $row [expr {$row + $nr}] $allread]
2780 - if {$rowlaidout == $row} {
2781 - return 0
2782 - }
2783 - } elseif {$allread} {
2784 - set optdelay 0
2785 - set nrows $commitidx($curview)
2786 - if {[lindex $rowidlist $nrows] ne {}} {
2787 - layouttail
2788 - set rowlaidout $commitidx($curview)
2789 - } elseif {$rowoptim == $nrows} {
2790 - set showdelay 0
2791 - set showlast 1
2792 - if {$numcommits == $nrows} {
2793 - return 0
2794 - }
2795 - }
2796 - } else {
2797 - return 0
2798 - }
2799 - if {$tmax ne {} && [clock clicks -milliseconds] >= $tmax} {
2800 - return 1
2801 - }
2715 + set show $commitidx($curview)
2716 + if {!$allread} {
2717 + set delay [expr {$uparrowlen + $mingaplen + $downarrowlen + 3}]
2718 + set show [expr {$show - $delay}]
2719 + }
2720 + if {$show > $numcommits} {
2721 + showstuff $show $allread
2722 }
2723 + return 0
2724 }
2725
2726 proc showstuff {canshow last} {
@@ -2966,8 +2887,10 @@ proc nextuse {id row} {
2887
2888 if {[info exists children($curview,$id)]} {
2889 foreach kid $children($curview,$id) {
2969 - if {[info exists commitrow($curview,$kid)] &&
2970 - $commitrow($curview,$kid) > $row} {
2890 + if {![info exists commitrow($curview,$kid)]} {
2891 + return -1
2892 + }
2893 + if {$commitrow($curview,$kid) > $row} {
2894 return $commitrow($curview,$kid)
2895 }
2896 }
@@ -2978,97 +2901,171 @@ proc nextuse {id row} {
2901 return -1
2902 }
2903
2981 -proc layoutrows {row endrow last} {
2982 - global rowidlist displayorder
2983 - global uparrowlen downarrowlen maxwidth mingaplen
2984 - global children parentlist
2985 - global commitidx curview
2904 +proc make_idlist {row} {
2905 + global displayorder parentlist uparrowlen downarrowlen mingaplen
2906 + global commitidx curview ordertok children commitrow
2907
2987 - set idlist [lindex $rowidlist $row]
2988 - if {!$last && $endrow + $uparrowlen + $mingaplen > $commitidx($curview)} {
2989 - set endrow [expr {$commitidx($curview) - $uparrowlen - $mingaplen}]
2908 + set r [expr {$row - $mingaplen - $downarrowlen - 1}]
2909 + if {$r < 0} {
2910 + set r 0
2911 }
2991 - while {$row < $endrow} {
2992 - set id [lindex $displayorder $row]
2993 - if {$row > $downarrowlen} {
2994 - set termrow [expr {$row - $downarrowlen - 1}]
2995 - foreach p [lindex $parentlist $termrow] {
2996 - set i [lsearch -exact $idlist $p]
2997 - if {$i < 0} continue
2998 - set nr [nextuse $p $termrow]
2999 - if {$nr < 0 || $nr >= $row + $mingaplen + $uparrowlen} {
3000 - set idlist [lreplace $idlist $i $i]
3001 - }
2912 + set ra [expr {$row - $downarrowlen}]
2913 + if {$ra < 0} {
2914 + set ra 0
2915 + }
2916 + set rb [expr {$row + $uparrowlen}]
2917 + if {$rb > $commitidx($curview)} {
2918 + set rb $commitidx($curview)
2919 + }
2920 + set ids {}
2921 + for {} {$r < $ra} {incr r} {
2922 + set nextid [lindex $displayorder [expr {$r + 1}]]
2923 + foreach p [lindex $parentlist $r] {
2924 + if {$p eq $nextid} continue
2925 + set rn [nextuse $p $r]
2926 + if {$rn >= $row &&
2927 + $rn <= $r + $downarrowlen + $mingaplen + $uparrowlen} {
2928 + lappend ids [list $ordertok($curview,$p) $p]
2929 }
3003 - lset rowidlist $row $idlist
2930 }
3005 - set oldolds {}
3006 - set newolds {}
3007 - foreach p [lindex $parentlist $row] {
3008 - # is id the first child of this parent?
3009 - if {$id eq [lindex $children($curview,$p) 0]} {
3010 - lappend newolds $p
3011 - } elseif {[lsearch -exact $idlist $p] < 0} {
3012 - lappend oldolds $p
2931 + }
2932 + for {} {$r < $row} {incr r} {
2933 + set nextid [lindex $displayorder [expr {$r + 1}]]
2934 + foreach p [lindex $parentlist $r] {
2935 + if {$p eq $nextid} continue
2936 + set rn [nextuse $p $r]
2937 + if {$rn < 0 || $rn >= $row} {
2938 + lappend ids [list $ordertok($curview,$p) $p]
2939 }
2940 }
3015 - set col [lsearch -exact $idlist $id]
3016 - if {$col < 0} {
3017 - set col [idcol $idlist $id]
3018 - set idlist [linsert $idlist $col $id]
3019 - lset rowidlist $row $idlist
3020 - if {$children($curview,$id) ne {}} {
3021 - makeuparrow $id $row $col
2941 + }
2942 + set id [lindex $displayorder $row]
2943 + lappend ids [list $ordertok($curview,$id) $id]
2944 + while {$r < $rb} {
2945 + foreach p [lindex $parentlist $r] {
2946 + set firstkid [lindex $children($curview,$p) 0]
2947 + if {$commitrow($curview,$firstkid) < $row} {
2948 + lappend ids [list $ordertok($curview,$p) $p]
2949 }
2950 }
3024 - incr row
3025 - set idlist [lreplace $idlist $col $col]
3026 - set x $col
3027 - foreach i $newolds {
3028 - set x [idcol $idlist $i $x]
3029 - set idlist [linsert $idlist $x $i]
3030 - }
3031 - foreach oid $oldolds {
3032 - set x [idcol $idlist $oid $x]
3033 - set idlist [linsert $idlist $x $oid]
3034 - makeuparrow $oid $row $x
2951 + incr r
2952 + set id [lindex $displayorder $r]
2953 + if {$id ne {}} {
2954 + set firstkid [lindex $children($curview,$id) 0]
2955 + if {$firstkid ne {} && $commitrow($curview,$firstkid) < $row} {
2956 + lappend ids [list $ordertok($curview,$id) $id]
2957 + }
2958 }
3036 - lappend rowidlist $idlist
2959 }
3038 - return $row
2960 + set idlist {}
2961 + foreach idx [lsort -unique $ids] {
2962 + lappend idlist [lindex $idx 1]
2963 + }
2964 + return $idlist
2965 }
2966
3041 -proc addextraid {id row} {
3042 - global displayorder commitrow commitinfo
3043 - global commitidx commitlisted
3044 - global parentlist children curview
2967 +proc layoutrows {row endrow} {
2968 + global rowidlist rowisopt displayorder
2969 + global uparrowlen downarrowlen maxwidth mingaplen
2970 + global children parentlist
2971 + global commitidx curview commitrow
2972
3046 - incr commitidx($curview)
3047 - lappend displayorder $id
3048 - lappend commitlisted 0
3049 - lappend parentlist {}
3050 - set commitrow($curview,$id) $row
3051 - readcommit $id
3052 - if {![info exists commitinfo($id)]} {
3053 - set commitinfo($id) {"No commit information available"}
2973 + set idlist {}
2974 + if {$row > 0} {
2975 + foreach id [lindex $rowidlist [expr {$row - 1}]] {
2976 + if {$id ne {}} {
2977 + lappend idlist $id
2978 + }
2979 + }
2980 }
3055 - if {![info exists children($curview,$id)]} {
3056 - set children($curview,$id) {}
2981 + for {} {$row < $endrow} {incr row} {
2982 + set rm1 [expr {$row - 1}]
2983 + if {$rm1 < 0 || [lindex $rowidlist $rm1] eq {}} {
2984 + set idlist [make_idlist $row]
2985 + } else {
2986 + set id [lindex $displayorder $rm1]
2987 + set col [lsearch -exact $idlist $id]
2988 + set idlist [lreplace $idlist $col $col]
2989 + foreach p [lindex $parentlist $rm1] {
2990 + if {[lsearch -exact $idlist $p] < 0} {
2991 + set col [idcol $idlist $p $col]
2992 + set idlist [linsert $idlist $col $p]
2993 + }
2994 + }
2995 + set id [lindex $displayorder $row]
2996 + if {$row > $downarrowlen} {
2997 + set termrow [expr {$row - $downarrowlen - 1}]
2998 + foreach p [lindex $parentlist $termrow] {
2999 + set i [lsearch -exact $idlist $p]
3000 + if {$i < 0} continue
3001 + set nr [nextuse $p $termrow]
3002 + if {$nr < 0 || $nr >= $row + $mingaplen + $uparrowlen} {
3003 + set idlist [lreplace $idlist $i $i]
3004 + }
3005 + }
3006 + }
3007 + set col [lsearch -exact $idlist $id]
3008 + if {$col < 0} {
3009 + set col [idcol $idlist $id]
3010 + set idlist [linsert $idlist $col $id]
3011 + }
3012 + set r [expr {$row + $uparrowlen - 1}]
3013 + if {$r < $commitidx($curview)} {
3014 + set x $col
3015 + foreach p [lindex $parentlist $r] {
3016 + if {[lsearch -exact $idlist $p] >= 0} continue
3017 + set fk [lindex $children($curview,$p) 0]
3018 + if {$commitrow($curview,$fk) < $row} {
3019 + set x [idcol $idlist $p $x]
3020 + set idlist [linsert $idlist $x $p]
3021 + }
3022 + }
3023 + if {[incr r] < $commitidx($curview)} {
3024 + set p [lindex $displayorder $r]
3025 + if {[lsearch -exact $idlist $p] < 0} {
3026 + set fk [lindex $children($curview,$p) 0]
3027 + if {$fk ne {} && $commitrow($curview,$fk) < $row} {
3028 + set x [idcol $idlist $p $x]
3029 + set idlist [linsert $idlist $x $p]
3030 + }
3031 + }
3032 + }
3033 + }
3034 + }
3035 + set l [llength $rowidlist]
3036 + if {$row == $l} {
3037 + lappend rowidlist $idlist
3038 + lappend rowisopt 0
3039 + } elseif {$row < $l} {
3040 + if {$idlist ne [lindex $rowidlist $row]} {
3041 + lset rowidlist $row $idlist
3042 + changedrow $row
3043 + }
3044 + } else {
3045 + set rowidlist [concat $rowidlist [ntimes [expr {$row - $l}] {}]]
3046 + lappend rowidlist $idlist
3047 + set rowisopt [concat $rowisopt [ntimes [expr {$row - $l + 1}] 0]]
3048 + }
3049 }
3050 + return $row
3051 }
3052
3060 -proc layouttail {} {
3061 - global rowidlist commitidx curview
3053 +proc changedrow {row} {
3054 + global displayorder iddrawn rowisopt need_redisplay
3055
3063 - set row $commitidx($curview)
3064 - set idlist [lindex $rowidlist $row]
3065 - while {$idlist ne {}} {
3066 - set col [expr {[llength $idlist] - 1}]
3067 - set id [lindex $idlist $col]
3068 - addextraid $id $row
3069 - incr row
3070 - set idlist [lreplace $idlist $col $col]
3071 - lappend rowidlist $idlist
3056 + set l [llength $rowisopt]
3057 + if {$row < $l} {
3058 + lset rowisopt $row 0
3059 + if {$row + 1 < $l} {
3060 + lset rowisopt [expr {$row + 1}] 0
3061 + if {$row + 2 < $l} {
3062 + lset rowisopt [expr {$row + 2}] 0
3063 + }
3064 + }
3065 + }
3066 + set id [lindex $displayorder $row]
3067 + if {[info exists iddrawn($id)]} {
3068 + set need_redisplay 1
3069 }
3070 }
3071
@@ -3084,27 +3081,29 @@ proc insert_pad {row col npad} {
3081 set aft [lreplace $aft $i $i]
3082 }
3083 lset rowidlist $row [concat $bef $pad $aft]
3084 + changedrow $row
3085 }
3086
3087 proc optimize_rows {row col endrow} {
3090 - global rowidlist displayorder curview children
3088 + global rowidlist rowisopt displayorder curview children
3089
3090 if {$row < 1} {
3091 set row 1
3092 }
3095 - set idlist [lindex $rowidlist [expr {$row - 1}]]
3096 - if {$row >= 2} {
3097 - set previdlist [lindex $rowidlist [expr {$row - 2}]]
3098 - } else {
3099 - set previdlist {}
3100 - }
3101 - for {} {$row < $endrow} {incr row} {
3102 - set pprevidlist $previdlist
3103 - set previdlist $idlist
3104 - set idlist [lindex $rowidlist $row]
3093 + for {} {$row < $endrow} {incr row; set col 0} {
3094 + if {[lindex $rowisopt $row]} continue
3095 set haspad 0
3096 set y0 [expr {$row - 1}]
3097 set ym [expr {$row - 2}]
3098 + set idlist [lindex $rowidlist $row]
3099 + set previdlist [lindex $rowidlist $y0]
3100 + if {$idlist eq {} || $previdlist eq {}} continue
3101 + if {$ym >= 0} {
3102 + set pprevidlist [lindex $rowidlist $ym]
3103 + if {$pprevidlist eq {}} continue
3104 + } else {
3105 + set pprevidlist {}
3106 + }
3107 set x0 -1
3108 set xm -1
3109 for {} {$col < [llength $idlist]} {incr col} {
@@ -3180,7 +3179,6 @@ proc optimize_rows {row col endrow} {
3179 incr x0
3180 optimize_rows $y0 $x0 $row
3181 set previdlist [lindex $rowidlist $y0]
3183 - set pprevidlist [lindex $rowidlist $ym]
3182 }
3183 }
3184 if {!$haspad} {
@@ -3203,10 +3201,10 @@ proc optimize_rows {row col endrow} {
3201 # isn't the last column
3202 if {$x0 >= 0 && [incr col] < [llength $idlist]} {
3203 set idlist [linsert $idlist $col {}]
3204 + lset rowidlist $row $idlist
3205 + changedrow $row
3206 }
3207 }
3208 - lset rowidlist $row $idlist
3209 - set col 0
3208 }
3209 }
3210
@@ -3531,7 +3529,7 @@ proc drawcmittext {id row col} {
3529 global linespc canv canv2 canv3 canvy0 fgcolor curview
3530 global commitlisted commitinfo rowidlist parentlist
3531 global rowtextx idpos idtags idheads idotherrefs
3534 - global linehtag linentag linedtag
3532 + global linehtag linentag linedtag selectedline
3533 global mainfont canvxmax boldrows boldnamerows fgcolor nullid nullid2
3534
3535 # listed is 0 for boundary, 1 for normal, 2 for left, 3 for right
@@ -3607,6 +3605,9 @@ proc drawcmittext {id row col} {
3605 -text $name -font $nfont -tags text]
3606 set linedtag($row) [$canv3 create text 3 $y -anchor w -fill $fgcolor \
3607 -text $date -font $mainfont -tags text]
3608 + if {[info exists selectedline] && $selectedline == $row} {
3609 + make_secsel $row
3610 + }
3611 set xr [expr {$xt + [font measure $mainfont $headline]}]
3612 if {$xr > $canvxmax} {
3613 set canvxmax $xr
@@ -3615,7 +3616,7 @@ proc drawcmittext {id row col} {
3616 }
3617
3618 proc drawcmitrow {row} {
3618 - global displayorder rowidlist
3619 + global displayorder rowidlist nrows_drawn
3620 global iddrawn markingmatches
3621 global commitinfo parentlist numcommits
3622 global filehighlight fhighlights findstring nhighlights
@@ -3649,6 +3650,7 @@ proc drawcmitrow {row} {
3650 assigncolor $id
3651 drawcmittext $id $row $col
3652 set iddrawn($id) 1
3653 + incr nrows_drawn
3654 }
3655 if {$markingmatches} {
3656 markrowmatches $row $id
@@ -3656,8 +3658,8 @@ proc drawcmitrow {row} {
3658 }
3659
3660 proc drawcommits {row {endrow {}}} {
3659 - global numcommits iddrawn displayorder curview
3660 - global parentlist rowidlist
3661 + global numcommits iddrawn displayorder curview need_redisplay
3662 + global parentlist rowidlist uparrowlen downarrowlen nrows_drawn
3663
3664 if {$row < 0} {
3665 set row 0
@@ -3669,6 +3671,35 @@ proc drawcommits {row {endrow {}}} {
3671 set endrow [expr {$numcommits - 1}]
3672 }
3673
3674 + set rl1 [expr {$row - $downarrowlen - 3}]
3675 + if {$rl1 < 0} {
3676 + set rl1 0
3677 + }
3678 + set ro1 [expr {$row - 3}]
3679 + if {$ro1 < 0} {
3680 + set ro1 0
3681 + }
3682 + set r2 [expr {$endrow + $uparrowlen + 3}]
3683 + if {$r2 > $numcommits} {
3684 + set r2 $numcommits
3685 + }
3686 + for {set r $rl1} {$r < $r2} {incr r} {
3687 + if {[lindex $rowidlist $r] ne {}} {
3688 + if {$rl1 < $r} {
3689 + layoutrows $rl1 $r
3690 + }
3691 + set rl1 [expr {$r + 1}]
3692 + }
3693 + }
3694 + if {$rl1 < $r} {
3695 + layoutrows $rl1 $r
3696 + }
3697 + optimize_rows $ro1 0 $r2
3698 + if {$need_redisplay || $nrows_drawn > 2000} {
3699 + clear_display
3700 + drawvisible
3701 + }
3702 +
3703 # make the lines join to already-drawn rows either side
3704 set r [expr {$row - 1}]
3705 if {$r < 0 || ![info exists iddrawn([lindex $displayorder $r])]} {
@@ -3736,7 +3767,7 @@ proc drawvisible {} {
3767 }
3768
3769 proc clear_display {} {
3739 - global iddrawn linesegs
3770 + global iddrawn linesegs need_redisplay nrows_drawn
3771 global vhighlights fhighlights nhighlights rhighlights
3772
3773 allcanvs delete all
@@ -3746,6 +3777,8 @@ proc clear_display {} {
3777 catch {unset fhighlights}
3778 catch {unset nhighlights}
3779 catch {unset rhighlights}
3780 + set need_redisplay 0
3781 + set nrows_drawn 0
3782 }
3783
3784 proc findcrossings {id} {
@@ -3967,9 +4000,9 @@ proc show_status {msg} {
4000 # on that row and below will move down one row.
4001 proc insertrow {row newcmit} {
4002 global displayorder parentlist commitlisted children
3970 - global commitrow curview rowidlist numcommits
3971 - global rowlaidout rowoptim numcommits
3972 - global selectedline commitidx
4003 + global commitrow curview rowidlist rowisopt numcommits
4004 + global numcommits
4005 + global selectedline commitidx ordertok
4006
4007 if {$row >= $numcommits} {
4008 puts "oops, inserting new row $row but only have $numcommits rows"
@@ -3989,6 +4022,7 @@ proc insertrow {row newcmit} {
4022 set commitrow($curview,$id) $r
4023 }
4024 incr commitidx($curview)
4025 + set ordertok($curview,$newcmit) $ordertok($curview,$p)
4026
4027 set idlist [lindex $rowidlist $row]
4028 if {[llength $kids] == 1} {
@@ -3999,9 +4033,8 @@ proc insertrow {row newcmit} {
4033 lappend idlist $newcmit
4034 }
4035 set rowidlist [linsert $rowidlist $row $idlist]
4036 + set rowisopt [linsert $rowisopt $row 0]
4037
4003 - incr rowlaidout
4004 - incr rowoptim
4038 incr numcommits
4039
4040 if {[info exists selectedline] && $selectedline >= $row} {
@@ -4013,8 +4046,8 @@ proc insertrow {row newcmit} {
4046 # Remove a commit that was inserted with insertrow on row $row.
4047 proc removerow {row} {
4048 global displayorder parentlist commitlisted children
4016 - global commitrow curview rowidlist numcommits
4017 - global rowlaidout rowoptim numcommits
4049 + global commitrow curview rowidlist rowisopt numcommits
4050 + global numcommits
4051 global linesegends selectedline commitidx
4052
4053 if {$row >= $numcommits} {
@@ -4041,9 +4074,8 @@ proc removerow {row} {
4074 incr commitidx($curview) -1
4075
4076 set rowidlist [lreplace $rowidlist $row $row]
4077 + set rowisopt [lreplace $rowisopt $row $row]
4078
4045 - incr rowlaidout -1
4046 - incr rowoptim -1
4079 incr numcommits -1
4080
4081 if {[info exists selectedline] && $selectedline > $row} {
@@ -4485,9 +4517,27 @@ proc dispnexttag {} {
4517 }
4518 }
4519
4520 +proc make_secsel {l} {
4521 + global linehtag linentag linedtag canv canv2 canv3
4522 +
4523 + if {![info exists linehtag($l)]} return
4524 + $canv delete secsel
4525 + set t [eval $canv create rect [$canv bbox $linehtag($l)] -outline {{}} \
4526 + -tags secsel -fill [$canv cget -selectbackground]]
4527 + $canv lower $t
4528 + $canv2 delete secsel
4529 + set t [eval $canv2 create rect [$canv2 bbox $linentag($l)] -outline {{}} \
4530 + -tags secsel -fill [$canv2 cget -selectbackground]]
4531 + $canv2 lower $t
4532 + $canv3 delete secsel
4533 + set t [eval $canv3 create rect [$canv3 bbox $linedtag($l)] -outline {{}} \
4534 + -tags secsel -fill [$canv3 cget -selectbackground]]
4535 + $canv3 lower $t
4536 +}
4537 +
4538 proc selectline {l isnew} {
4489 - global canv canv2 canv3 ctext commitinfo selectedline
4490 - global displayorder linehtag linentag linedtag
4539 + global canv ctext commitinfo selectedline
4540 + global displayorder
4541 global canvy0 linespc parentlist children curview
4542 global currentid sha1entry
4543 global commentend idtags linknum
@@ -4536,19 +4586,7 @@ proc selectline {l isnew} {
4586 drawvisible
4587 }
4588
4539 - if {![info exists linehtag($l)]} return
4540 - $canv delete secsel
4541 - set t [eval $canv create rect [$canv bbox $linehtag($l)] -outline {{}} \
4542 - -tags secsel -fill [$canv cget -selectbackground]]
4543 - $canv lower $t
4544 - $canv2 delete secsel
4545 - set t [eval $canv2 create rect [$canv2 bbox $linentag($l)] -outline {{}} \
4546 - -tags secsel -fill [$canv2 cget -selectbackground]]
4547 - $canv2 lower $t
4548 - $canv3 delete secsel
4549 - set t [eval $canv3 create rect [$canv3 bbox $linedtag($l)] -outline {{}} \
4550 - -tags secsel -fill [$canv3 cget -selectbackground]]
4551 - $canv3 lower $t
4589 + make_secsel $l
4590
4591 if {$isnew} {
4592 addtohistory [list selectline $l 0]
@@ -5616,7 +5654,7 @@ proc arrowjump {id n y} {
5654 }
5655
5656 proc lineclick {x y id isnew} {
5619 - global ctext commitinfo children canv thickerline curview
5657 + global ctext commitinfo children canv thickerline curview commitrow
5658
5659 if {![info exists commitinfo($id)] && ![getcommit $id]} return
5660 unmarkmatches
@@ -7922,8 +7960,8 @@ set boldnamerows {}
7960 set diffelide {0 0}
7961 set markingmatches 0
7962 set linkentercount 0
7925 -
7926 -set optim_delay 16
7963 +set need_redisplay 0
7964 +set nrows_drawn 0
7965
7966 set nextviewnum 1
7967 set curview 0