@matheusbsbs / matheus-bagliano / commits / f96cd7b6c9
Fork 0

git-gui: Improve the coloring in blame viewer

The git-gui blame viewer has always been ugly as s**t. Linus Torvalds suggested the coloring scheme I'm using here, which is two different shades of grey for the background colors, and black text on a pale green background for the currently selected/focused commit. The difference is a massive improvement. The interface no longer will cause seizures in people who are prone to that sort of thing. It no longer uses a very offensive hot pink. The green being current actually makes sense. And not having the background of the other non-current lines change when you change the current commit is really a big deal. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Jun 1, 2007 at 00:38 UTC f96cd7b6c9e9664d2fd6ec50bbade126355ad4f4
1 file changed +30 -46
lib/blame.tcl
+30 -46
@@ -31,6 +31,12 @@ field r_orig_line ; # original line number
31 field r_final_line ; # final line number
32 field r_line_count ; # lines in this region
33
34 +variable active_color #98e1a0
35 +variable group_colors {
36 + #cbcbcb
37 + #e1e1e1
38 +}
39 +
40 constructor new {i_commit i_path} {
41 set commit $i_commit
42 set path $i_path
@@ -143,9 +149,6 @@ constructor new {i_commit i_path} {
149 $w_load \
150 $w_line \
151 $w_file] {
146 - $i tag conf in_sel \
147 - -background [$i cget -foreground] \
148 - -foreground [$i cget -background]
152 $i conf -yscrollcommand \
153 [list many2scrollbar [list \
154 $w_cgrp \
@@ -235,6 +238,8 @@ method _read_file {fd} {
238 } ifdeleted { catch {close $fd} }
239
240 method _read_blame {fd} {
241 + variable group_colors
242 +
243 $w_cgrp conf -state normal
244 while {[gets $fd line] >= 0} {
245 if {[regexp {^([a-z0-9]{40}) (\d+) (\d+) (\d+)$} $line line \
@@ -245,15 +250,14 @@ method _read_blame {fd} {
250 set r_line_count $line_count
251
252 if {[catch {set g $order($cmit)}]} {
248 - $w_cgrp tag conf g$cmit
249 - $w_line tag conf g$cmit
250 - $w_file tag conf g$cmit
253 + set bg [lindex $group_colors 0]
254 + set group_colors [lrange $group_colors 1 end]
255 + lappend group_colors $bg
256
252 - $w_cgrp tag raise in_sel
253 - $w_line tag raise in_sel
254 - $w_file tag raise in_sel
257 + $w_cgrp tag conf g$cmit -background $bg
258 + $w_line tag conf g$cmit -background $bg
259 + $w_file tag conf g$cmit -background $bg
260
256 - $w_file tag raise sel
261 set order($cmit) $commit_count
262 incr commit_count
263 lappend commit_list $cmit
@@ -273,6 +277,10 @@ method _read_blame {fd} {
277 $w_cgrp tag remove g$g $lno.0 $lno_e
278 $w_line tag remove g$g $lno.0 $lno_e
279 $w_file tag remove g$g $lno.0 $lno_e
280 +
281 + $w_cgrp tag remove a$g $lno.0 $lno_e
282 + $w_line tag remove a$g $lno.0 $lno_e
283 + $w_file tag remove a$g $lno.0 $lno_e
284 }
285
286 set line_commit($lno) $cmit
@@ -285,6 +293,10 @@ method _read_blame {fd} {
293 $w_line tag add g$cmit $lno.0 $lno_e
294 $w_file tag add g$cmit $lno.0 $lno_e
295
296 + $w_cgrp tag add a$cmit $lno.0 $lno_e
297 + $w_line tag add a$cmit $lno.0 $lno_e
298 + $w_file tag add a$cmit $lno.0 $lno_e
299 +
300 if {$highlight_line == -1} {
301 if {[lindex [$w_file yview] 0] == 0} {
302 $w_file see $lno.0
@@ -332,40 +344,18 @@ method _status {} {
344 method _click {cur_w pos} {
345 set lno [lindex [split [$cur_w index $pos] .] 0]
346 if {$lno eq {}} return
335 -
336 - set lno_e "$lno.0 + 1 line"
337 -
338 - $w_cgrp tag remove in_sel 0.0 end
339 - $w_line tag remove in_sel 0.0 end
340 - $w_file tag remove in_sel 0.0 end
341 -
342 - $w_cgrp tag add in_sel $lno.0 $lno_e
343 - $w_line tag add in_sel $lno.0 $lno_e
344 - $w_file tag add in_sel $lno.0 $lno_e
345 -
347 _showcommit $this $lno
348 }
349
349 -variable blame_colors {
350 - #ff4040
351 - #ff40ff
352 - #4040ff
353 -}
354 -
350 method _showcommit {lno} {
351 global repo_config
357 - variable blame_colors
352 + variable active_color
353
354 if {$highlight_commit ne {}} {
360 - set idx $order($highlight_commit)
361 - set i 0
362 - foreach c $blame_colors {
363 - set h [lindex $commit_list [expr {$idx - 1 + $i}]]
364 - $w_cgrp tag conf g$h -background white
365 - $w_line tag conf g$h -background white
366 - $w_file tag conf g$h -background white
367 - incr i
368 - }
355 + set cmit $highlight_commit
356 + $w_cgrp tag conf a$cmit -background {}
357 + $w_line tag conf a$cmit -background {}
358 + $w_file tag conf a$cmit -background {}
359 }
360
361 $w_cmit conf -state normal
@@ -374,15 +364,9 @@ method _showcommit {lno} {
364 set cmit {}
365 $w_cmit insert end "Loading annotation..."
366 } else {
377 - set idx $order($cmit)
378 - set i 0
379 - foreach c $blame_colors {
380 - set h [lindex $commit_list [expr {$idx - 1 + $i}]]
381 - $w_cgrp tag conf g$h -background $c
382 - $w_line tag conf g$h -background $c
383 - $w_file tag conf g$h -background $c
384 - incr i
385 - }
367 + $w_cgrp tag conf a$cmit -background $active_color
368 + $w_line tag conf a$cmit -background $active_color
369 + $w_file tag conf a$cmit -background $active_color
370
371 set author_name {}
372 set author_email {}