gitk: Highlight entries in the file list as well
This applies a bold highlight to entries in the file list pane in the bottom right corner when it is displaying the list of changed files. This doesn't yet highlight file list entries when it is in tree view mode. Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras committed
May 20, 2006 at 21:31 UTC
63b791912112a0f8cbd793a943bc40c88cad6e51
1 file changed
+66
-5
gitk
+66
-5
@@ -527,6 +527,8 @@ proc makewindow {} {
527
global viewhlmenu selectedhlview
528
set viewhlmenu [tk_optionMenu .ctop.top.lbar.vhl selectedhlview None]
529
$viewhlmenu entryconf 0 -command delvhighlight
530
+ $viewhlmenu conf -font $uifont
531
+ .ctop.top.lbar.vhl conf -font $uifont
532
pack .ctop.top.lbar.vhl -side left -fill y
533
label .ctop.top.lbar.alabel -text " OR author/committer:" \
534
-font $uifont
@@ -595,6 +597,7 @@ proc makewindow {} {
597
pack $cflist -side left -fill both -expand 1
598
$cflist tag configure highlight \
599
-background [$cflist cget -selectbackground]
600
+ $cflist tag configure bold -font [concat $mainfont bold]
601
.ctop.cdet add .ctop.cdet.right
602
bind .ctop.cdet <Configure> {resizecdetpanes %W %w}
603
@@ -1140,16 +1143,55 @@ proc init_flist {first} {
1143
set difffilestart {}
1144
}
1145
1146
+proc highlight_tag {f} {
1147
+ global highlight_paths
1148
+
1149
+ foreach p $highlight_paths {
1150
+ if {[string match $p $f]} {
1151
+ return "bold"
1152
+ }
1153
+ }
1154
+ return {}
1155
+}
1156
+
1157
+proc highlight_filelist {} {
1158
+ global flistmode cflist
1159
+
1160
+ global highlight_paths
1161
+ if {$flistmode eq "flat"} {
1162
+ $cflist conf -state normal
1163
+ set end [lindex [split [$cflist index end] .] 0]
1164
+ for {set l 2} {$l < $end} {incr l} {
1165
+ set line [$cflist get $l.0 "$l.0 lineend"]
1166
+ if {[highlight_tag $line] ne {}} {
1167
+ $cflist tag add bold $l.0 "$l.0 lineend"
1168
+ }
1169
+ }
1170
+ $cflist conf -state disabled
1171
+ }
1172
+}
1173
+
1174
+proc unhighlight_filelist {} {
1175
+ global flistmode cflist
1176
+
1177
+ if {$flistmode eq "flat"} {
1178
+ $cflist conf -state normal
1179
+ $cflist tag remove bold 1.0 end
1180
+ $cflist conf -state disabled
1181
+ }
1182
+}
1183
+
1184
proc add_flist {fl} {
1185
global flistmode cflist
1186
1146
- $cflist conf -state normal
1187
if {$flistmode eq "flat"} {
1188
+ $cflist conf -state normal
1189
foreach f $fl {
1149
- $cflist insert end "\n$f"
1190
+ $cflist insert end "\n"
1191
+ $cflist insert end $f [highlight_tag $f]
1192
}
1193
+ $cflist conf -state disabled
1194
}
1152
- $cflist conf -state disabled
1195
}
1196
1197
proc sel_flist {w x y} {
@@ -1704,7 +1746,7 @@ proc askvhighlight {row id} {
1746
1747
proc hfiles_change {name ix op} {
1748
global highlight_files filehighlight fhighlights fh_serial
1707
- global mainfont
1749
+ global mainfont highlight_paths
1750
1751
if {[info exists filehighlight]} {
1752
# delete previous highlights
@@ -1715,7 +1757,9 @@ proc hfiles_change {name ix op} {
1757
unset fhighlights
1758
unbolden $rows
1759
}
1760
+ unhighlight_filelist
1761
}
1762
+ set highlight_paths {}
1763
after cancel do_file_hl $fh_serial
1764
incr fh_serial
1765
if {$highlight_files ne {}} {
@@ -1723,10 +1767,26 @@ proc hfiles_change {name ix op} {
1767
}
1768
}
1769
1770
+proc makepatterns {l} {
1771
+ set ret {}
1772
+ foreach e $l {
1773
+ set ee [string map {"*" "\\*" "?" "\\?" "\[" "\\\[" "\\" "\\\\"} $e]
1774
+ if {[string index $ee end] eq "/"} {
1775
+ lappend ret "$ee*"
1776
+ } else {
1777
+ lappend ret $ee
1778
+ lappend ret "$ee/*"
1779
+ }
1780
+ }
1781
+ return $ret
1782
+}
1783
+
1784
proc do_file_hl {serial} {
1727
- global highlight_files filehighlight
1785
+ global highlight_files filehighlight highlight_paths
1786
1787
if {[catch {set paths [shellsplit $highlight_files]}]} return
1788
+ set highlight_paths [makepatterns $paths]
1789
+ highlight_filelist
1790
set cmd [concat | git-diff-tree -r -s --stdin -- $paths]
1791
set filehighlight [open $cmd r+]
1792
fconfigure $filehighlight -blocking 0
@@ -5175,6 +5235,7 @@ set historyindex 0
5235
set fh_serial 0
5236
set highlight_names {}
5237
set nhl_names {}
5238
+set highlight_paths {}
5239
5240
set optim_delay 16
5241