@matheusbsbs / matheus-bagliano / commits / 8a48571ce5
Fork 0

gitk: Show the currently checked-out head in bold font

Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Jul 6, 2006 at 10:21 UTC 8a48571ce52e5182ea32ed168e298882f8c470b3
1 file changed +22 -5
gitk
+22 -5
@@ -312,7 +312,7 @@ proc getcommit {id} {
312
313 proc readrefs {} {
314 global tagids idtags headids idheads tagcontents
315 - global otherrefids idotherrefs
315 + global otherrefids idotherrefs mainhead
316
317 foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
318 catch {unset $v}
@@ -358,6 +358,13 @@ proc readrefs {} {
358 }
359 }
360 close $refd
361 + set mainhead {}
362 + catch {
363 + set thehead [exec git symbolic-ref HEAD]
364 + if {[string match "refs/heads/*" $thehead]} {
365 + set mainhead [string range $thehead 11 end]
366 + }
367 + }
368 }
369
370 proc show_error {w top msg} {
@@ -3150,9 +3157,9 @@ proc bindline {t id} {
3157 }
3158
3159 proc drawtags {id x xt y1} {
3153 - global idtags idheads idotherrefs
3160 + global idtags idheads idotherrefs mainhead
3161 global linespc lthickness
3155 - global canv mainfont commitrow rowtextx curview fgcolor
3162 + global canv mainfont commitrow rowtextx curview fgcolor bgcolor
3163
3164 set marks {}
3165 set ntags 0
@@ -3177,8 +3184,14 @@ proc drawtags {id x xt y1} {
3184 set yb [expr {$yt + $linespc - 1}]
3185 set xvals {}
3186 set wvals {}
3187 + set i -1
3188 foreach tag $marks {
3181 - set wid [font measure $mainfont $tag]
3189 + incr i
3190 + if {$i >= $ntags && $i < $ntags + $nheads && $tag eq $mainhead} {
3191 + set wid [font measure [concat $mainfont bold] $tag]
3192 + } else {
3193 + set wid [font measure $mainfont $tag]
3194 + }
3195 lappend xvals $xt
3196 lappend wvals $wid
3197 set xt [expr {$xt + $delta + $wid + $lthickness + $linespc}]
@@ -3189,6 +3202,7 @@ proc drawtags {id x xt y1} {
3202 foreach tag $marks x $xvals wid $wvals {
3203 set xl [expr {$x + $delta}]
3204 set xr [expr {$x + $delta + $wid + $lthickness}]
3205 + set font $mainfont
3206 if {[incr ntags -1] >= 0} {
3207 # draw a tag
3208 set t [$canv create polygon $x [expr {$yt + $delta}] $xl $yt \
@@ -3200,6 +3214,9 @@ proc drawtags {id x xt y1} {
3214 # draw a head or other ref
3215 if {[incr nheads -1] >= 0} {
3216 set col green
3217 + if {$tag eq $mainhead} {
3218 + lappend font bold
3219 + }
3220 } else {
3221 set col "#ddddff"
3222 }
@@ -3216,7 +3233,7 @@ proc drawtags {id x xt y1} {
3233 }
3234 }
3235 set t [$canv create text $xl $y1 -anchor w -text $tag -fill $fgcolor \
3219 - -font $mainfont -tags [list tag.$id text]]
3236 + -font $font -tags [list tag.$id text]]
3237 if {$ntags >= 0} {
3238 $canv bind $t <1> [list showtag $tag 1]
3239 }