gitk: Highlight paths of interest in tree view as well
With this, when the file list window is in tree view mode, we highlight the paths of interest. Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras committed
May 20, 2006 at 22:56 UTC
45a9d5054d69f0c662b6a28e60934f63fa4ee9ef
1 file changed
+38
-26
gitk
+38
-26
@@ -950,7 +950,7 @@ proc treeview {w l openlevs} {
950
$w insert end $str
951
$w image create end -align center -image $bm -padx 1 \
952
-name a:$ix
953
- $w insert end $d
953
+ $w insert end $d [highlight_tag $prefix]
954
$w mark set s:$ix "end -1c"
955
$w mark gravity s:$ix left
956
}
@@ -962,7 +962,7 @@ proc treeview {w l openlevs} {
962
set str "\n"
963
for {set i 0} {$i < $lev} {incr i} {append str "\t"}
964
$w insert end $str
965
- $w insert end $tail
965
+ $w insert end $tail [highlight_tag $f]
966
}
967
lappend treecontents($prefix) $tail
968
}
@@ -999,6 +999,22 @@ proc linetoelt {l} {
999
}
1000
}
1001
1002
+proc highlight_tree {y prefix} {
1003
+ global treeheight treecontents cflist
1004
+
1005
+ foreach e $treecontents($prefix) {
1006
+ set path $prefix$e
1007
+ if {[highlight_tag $path] ne {}} {
1008
+ $cflist tag add bold $y.0 "$y.0 lineend"
1009
+ }
1010
+ incr y
1011
+ if {[string index $e end] eq "/" && $treeheight($path) > 1} {
1012
+ set y [highlight_tree $y $path]
1013
+ }
1014
+ }
1015
+ return $y
1016
+}
1017
+
1018
proc treeclosedir {w dir} {
1019
global treediropen treeheight treeparent treeindex
1020
@@ -1032,8 +1048,8 @@ proc treeopendir {w dir} {
1048
incr treeheight($x) $n
1049
}
1050
foreach e $treecontents($dir) {
1051
+ set de $dir$e
1052
if {[string index $e end] eq "/"} {
1036
- set de $dir$e
1053
set iy $treeindex($de)
1054
$w mark set d:$iy e:$ix
1055
$w mark gravity d:$iy left
@@ -1041,13 +1057,13 @@ proc treeopendir {w dir} {
1057
set treediropen($de) 0
1058
$w image create e:$ix -align center -image tri-rt -padx 1 \
1059
-name a:$iy
1044
- $w insert e:$ix $e
1060
+ $w insert e:$ix $e [highlight_tag $de]
1061
$w mark set s:$iy e:$ix
1062
$w mark gravity s:$iy left
1063
set treeheight($de) 1
1064
} else {
1065
$w insert e:$ix $str
1050
- $w insert e:$ix $e
1066
+ $w insert e:$ix $e [highlight_tag $de]
1067
}
1068
}
1069
$w mark gravity e:$ix left
@@ -1155,11 +1171,10 @@ proc highlight_tag {f} {
1171
}
1172
1173
proc highlight_filelist {} {
1158
- global flistmode cflist
1174
+ global cmitmode cflist
1175
1160
- global highlight_paths
1161
- if {$flistmode eq "flat"} {
1162
- $cflist conf -state normal
1176
+ $cflist conf -state normal
1177
+ if {$cmitmode ne "tree"} {
1178
set end [lindex [split [$cflist index end] .] 0]
1179
for {set l 2} {$l < $end} {incr l} {
1180
set line [$cflist get $l.0 "$l.0 lineend"]
@@ -1167,35 +1182,33 @@ proc highlight_filelist {} {
1182
$cflist tag add bold $l.0 "$l.0 lineend"
1183
}
1184
}
1170
- $cflist conf -state disabled
1185
+ } else {
1186
+ highlight_tree 2 {}
1187
}
1188
+ $cflist conf -state disabled
1189
}
1190
1191
proc unhighlight_filelist {} {
1175
- global flistmode cflist
1192
+ global cflist
1193
1177
- if {$flistmode eq "flat"} {
1178
- $cflist conf -state normal
1179
- $cflist tag remove bold 1.0 end
1180
- $cflist conf -state disabled
1181
- }
1194
+ $cflist conf -state normal
1195
+ $cflist tag remove bold 1.0 end
1196
+ $cflist conf -state disabled
1197
}
1198
1199
proc add_flist {fl} {
1185
- global flistmode cflist
1200
+ global cflist
1201
1187
- if {$flistmode eq "flat"} {
1188
- $cflist conf -state normal
1189
- foreach f $fl {
1190
- $cflist insert end "\n"
1191
- $cflist insert end $f [highlight_tag $f]
1192
- }
1193
- $cflist conf -state disabled
1202
+ $cflist conf -state normal
1203
+ foreach f $fl {
1204
+ $cflist insert end "\n"
1205
+ $cflist insert end $f [highlight_tag $f]
1206
}
1207
+ $cflist conf -state disabled
1208
}
1209
1210
proc sel_flist {w x y} {
1198
- global flistmode ctext difffilestart cflist cflist_top cmitmode
1211
+ global ctext difffilestart cflist cflist_top cmitmode
1212
1213
if {$cmitmode eq "tree"} return
1214
if {![info exists cflist_top]} return
@@ -5180,7 +5193,6 @@ set fastdate 0
5193
set uparrowlen 7
5194
set downarrowlen 7
5195
set mingaplen 30
5183
-set flistmode "flat"
5196
set cmitmode "patch"
5197
5198
set colors {green red blue magenta darkgrey brown orange}