@matheusbsbs / matheus-bagliano / commits / 476ca63dbc
Fork 0

gitk: Index [fnvr]highlights by id rather than row

This means that we don't have to keep clearing them out whenever we change the row numbers for some commits. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Jan 7, 2008 at 22:16 UTC 476ca63dbc659a5333c00cdc8993f2085b86a34f
1 file changed +33 -40
gitk
+33 -40
@@ -661,7 +661,6 @@ proc vtokcmp {v a b} {
661
662 proc modify_arc {v a {lim {}}} {
663 global varctok vtokmod varcmod varcrow vupptr curview vrowmod varccommits
664 - global vhighlights nhighlights fhighlights rhighlights
664
665 set vtokmod($v) [lindex $varctok($v) $a]
666 set varcmod($v) $a
@@ -680,10 +679,6 @@ proc modify_arc {v a {lim {}}} {
679 set vrowmod($v) $r
680 undolayout $r
681 }
683 - catch {unset nhighlights}
684 - catch {unset fhighlights}
685 - catch {unset vhighlights}
686 - catch {unset rhighlights}
682 }
683
684 proc update_arcrows {v} {
@@ -2850,20 +2845,20 @@ proc showview {n} {
2845
2846 # Stuff relating to the highlighting facility
2847
2853 -proc ishighlighted {row} {
2848 +proc ishighlighted {id} {
2849 global vhighlights fhighlights nhighlights rhighlights
2850
2856 - if {[info exists nhighlights($row)] && $nhighlights($row) > 0} {
2857 - return $nhighlights($row)
2851 + if {[info exists nhighlights($id)] && $nhighlights($id) > 0} {
2852 + return $nhighlights($id)
2853 }
2859 - if {[info exists vhighlights($row)] && $vhighlights($row) > 0} {
2860 - return $vhighlights($row)
2854 + if {[info exists vhighlights($id)] && $vhighlights($id) > 0} {
2855 + return $vhighlights($id)
2856 }
2862 - if {[info exists fhighlights($row)] && $fhighlights($row) > 0} {
2863 - return $fhighlights($row)
2857 + if {[info exists fhighlights($id)] && $fhighlights($id) > 0} {
2858 + return $fhighlights($id)
2859 }
2865 - if {[info exists rhighlights($row)] && $rhighlights($row) > 0} {
2866 - return $rhighlights($row)
2860 + if {[info exists rhighlights($id)] && $rhighlights($id) > 0} {
2861 + return $rhighlights($id)
2862 }
2863 return 0
2864 }
@@ -2901,7 +2896,7 @@ proc unbolden {} {
2896
2897 set stillbold {}
2898 foreach row $boldrows {
2904 - if {![ishighlighted $row]} {
2899 + if {![ishighlighted [commitonrow $row]]} {
2900 bolden $row mainfont
2901 } else {
2902 lappend stillbold $row
@@ -2911,7 +2906,7 @@ proc unbolden {} {
2906 }
2907
2908 proc addvhighlight {n} {
2914 - global hlview viewcomplete curview vhl_done vhighlights commitidx
2909 + global hlview viewcomplete curview vhl_done commitidx
2910
2911 if {[info exists hlview]} {
2912 delvhighlight
@@ -2950,7 +2945,7 @@ proc vhighlightmore {} {
2945 if {![highlighted $row]} {
2946 bolden $row mainfontbold
2947 }
2953 - set vhighlights($row) 1
2948 + set vhighlights($id) 1
2949 }
2950 }
2951 }
@@ -2961,12 +2956,12 @@ proc askvhighlight {row id} {
2956 global hlview vhighlights iddrawn
2957
2958 if {[commitinview $id $hlview]} {
2964 - if {[info exists iddrawn($id)] && ![ishighlighted $row]} {
2959 + if {[info exists iddrawn($id)] && ![ishighlighted $id]} {
2960 bolden $row mainfontbold
2961 }
2967 - set vhighlights($row) 1
2962 + set vhighlights($id) 1
2963 } else {
2969 - set vhighlights($row) 0
2964 + set vhighlights($id) 0
2965 }
2966 }
2967
@@ -3104,7 +3099,7 @@ proc askfilehighlight {row id} {
3099 global filehighlight fhighlights fhl_list
3100
3101 lappend fhl_list $id
3107 - set fhighlights($row) -1
3102 + set fhighlights($id) -1
3103 puts $filehighlight $id
3104 }
3105
@@ -3122,18 +3117,16 @@ proc readfhighlight {} {
3117 if {$i < 0} continue
3118 for {set j 0} {$j < $i} {incr j} {
3119 set id [lindex $fhl_list $j]
3125 - if {[commitinview $id $curview]} {
3126 - set fhighlights([rowofcommit $id]) 0
3127 - }
3120 + set fhighlights($id) 0
3121 }
3122 set fhl_list [lrange $fhl_list [expr {$i+1}] end]
3123 if {$line eq {}} continue
3124 if {![commitinview $line $curview]} continue
3125 set row [rowofcommit $line]
3133 - if {[info exists iddrawn($line)] && ![ishighlighted $row]} {
3126 + if {[info exists iddrawn($line)] && ![ishighlighted $line]} {
3127 bolden $row mainfontbold
3128 }
3136 - set fhighlights($row) 1
3129 + set fhighlights($line) 1
3130 }
3131 if {[eof $filehighlight]} {
3132 # strange...
@@ -3182,7 +3175,7 @@ proc askfindhighlight {row id} {
3175 }
3176 }
3177 if {$isbold && [info exists iddrawn($id)]} {
3185 - if {![ishighlighted $row]} {
3178 + if {![ishighlighted $id]} {
3179 bolden $row mainfontbold
3180 if {$isbold > 1} {
3181 bolden_name $row mainfontbold
@@ -3192,7 +3185,7 @@ proc askfindhighlight {row id} {
3185 markrowmatches $row $id
3186 }
3187 }
3195 - set nhighlights($row) $isbold
3188 + set nhighlights($id) $isbold
3189 }
3190
3191 proc markrowmatches {row id} {
@@ -3230,7 +3223,7 @@ proc vrel_change {name ix op} {
3223 # prepare for testing whether commits are descendents or ancestors of a
3224 proc rhighlight_sel {a} {
3225 global descendent desc_todo ancestor anc_todo
3233 - global highlight_related rhighlights
3226 + global highlight_related
3227
3228 catch {unset descendent}
3229 set desc_todo [list $a]
@@ -3337,11 +3330,11 @@ proc askrelhighlight {row id} {
3330 }
3331 }
3332 if {[info exists iddrawn($id)]} {
3340 - if {$isbold && ![ishighlighted $row]} {
3333 + if {$isbold && ![ishighlighted $id]} {
3334 bolden $row mainfontbold
3335 }
3336 }
3344 - set rhighlights($row) $isbold
3337 + set rhighlights($id) $isbold
3338 }
3339
3340 # Graph layout functions
@@ -4408,7 +4401,7 @@ proc drawcmittext {id row col} {
4401 set date [formatdate $date]
4402 set font mainfont
4403 set nfont mainfont
4411 - set isbold [ishighlighted $row]
4404 + set isbold [ishighlighted $id]
4405 if {$isbold > 0} {
4406 lappend boldrows $row
4407 set font mainfontbold
@@ -4445,16 +4438,16 @@ proc drawcmitrow {row} {
4438 if {$row >= $numcommits} return
4439
4440 set id [lindex $displayorder $row]
4448 - if {[info exists hlview] && ![info exists vhighlights($row)]} {
4441 + if {[info exists hlview] && ![info exists vhighlights($id)]} {
4442 askvhighlight $row $id
4443 }
4451 - if {[info exists filehighlight] && ![info exists fhighlights($row)]} {
4444 + if {[info exists filehighlight] && ![info exists fhighlights($id)]} {
4445 askfilehighlight $row $id
4446 }
4454 - if {$findpattern ne {} && ![info exists nhighlights($row)]} {
4447 + if {$findpattern ne {} && ![info exists nhighlights($id)]} {
4448 askfindhighlight $row $id
4449 }
4457 - if {$highlight_related ne [mc "None"] && ![info exists rhighlights($row)]} {
4450 + if {$highlight_related ne [mc "None"] && ![info exists rhighlights($id)]} {
4451 askrelhighlight $row $id
4452 }
4453 if {![info exists iddrawn($id)]} {
@@ -5045,15 +5038,15 @@ proc findmore {} {
5038 set arowend [expr {$arow + [llength $ids]}]
5039 }
5040 set id [lindex $ids [expr {$l - $arow}]]
5048 - if {![info exists fhighlights($l)]} {
5049 - # this sets fhighlights($l) to -1
5041 + if {![info exists fhighlights($id)]} {
5042 + # this sets fhighlights($id) to -1
5043 askfilehighlight $l $id
5044 }
5052 - if {$fhighlights($l) > 0} {
5045 + if {$fhighlights($id) > 0} {
5046 set found $domore
5047 break
5048 }
5056 - if {$fhighlights($l) < 0} {
5049 + if {$fhighlights($id) < 0} {
5050 if {$domore} {
5051 set domore 0
5052 set findcurline [expr {$l - $find_dirn}]