@@ -26,8 +26,8 @@ field old_height ; # last known height of $w.file_pane
26
26
27
27
# Tk UI colors
28
28
#
29
- field active_color #c0edc5
30
- field group_colors {
29
+ variable active_color #c0edc5
30
+ variable group_colors {
31
31
# d6d6d6
32
32
# e1e1e1
33
33
# ececec
@@ -42,11 +42,9 @@ field current_fd {} ; # background process running
42
42
field highlight_line -1 ; # current line selected
43
43
field highlight_column {} ; # current commit column selected
44
44
field highlight_commit {} ; # sha1 of commit selected
45
- field old_bgcolor {} ; # background of current selection
46
45
47
46
field total_lines 0 ; # total length of file
48
47
field blame_lines 0 ; # number of lines computed
49
- field have_commit ; # array commit -> 1
50
48
field amov_data ; # list of {commit origfile origline}
51
49
field asim_data ; # list of {commit origfile origline}
52
50
@@ -62,6 +60,8 @@ field tooltip_commit {} ; # Commit(s) in tooltip
62
60
63
61
constructor new {i_commit i_path} {
64
62
global cursor_ptr
63
+ variable active_color
64
+ variable group_colors
65
65
66
66
set commit $i_commit
67
67
set path $i_path
@@ -250,6 +250,10 @@ constructor new {i_commit i_path} {
250
250
-command [cb _copycommit]
251
251
252
252
foreach i $w_columns {
253
+ for {set g 0} {$g < [llength $group_colors ]} {incr g} {
254
+ $i tag conf color$g -background [lindex $group_colors $g ]
255
+ }
256
+
253
257
$i conf -cursor $cursor_ptr
254
258
$i conf -yscrollcommand [list many2scrollbar \
255
259
$w_columns yview $w .file_pane.out.sby]
@@ -314,6 +318,8 @@ constructor new {i_commit i_path} {
314
318
}
315
319
316
320
method _load {jump} {
321
+ variable group_colors
322
+
317
323
_hide_tooltip $this
318
324
319
325
if {$total_lines != 0 || $current_fd ne {}} {
@@ -325,8 +331,10 @@ method _load {jump} {
325
331
foreach i $w_columns {
326
332
$i conf -state normal
327
333
$i delete 0.0 end
328
- foreach cmit [array names have_commit] {
329
- $i tag delete g$cmit
334
+ foreach g [$i tag names] {
335
+ if {[regexp {^g[0-9a-f]{40}$} $g ]} {
336
+ $i tag delete $g
337
+ }
330
338
}
331
339
$i conf -state disabled
332
340
}
@@ -339,7 +347,6 @@ method _load {jump} {
339
347
set highlight_column {}
340
348
set highlight_commit {}
341
349
set total_lines 0
342
- array unset have_commit
343
350
}
344
351
345
352
if {[winfo exists $w .status.c]} {
@@ -494,6 +501,7 @@ method _exec_blame {cur_w cur_d options cur_s} {
494
501
495
502
method _read_blame {fd cur_w cur_d cur_s} {
496
503
upvar #0 $cur_d line_data
504
+ variable group_colors
497
505
498
506
if {$fd ne $current_fd } {
499
507
catch {close $fd }
@@ -508,16 +516,6 @@ method _read_blame {fd cur_w cur_d cur_s} {
508
516
set r_orig_line $original_line
509
517
set r_final_line $final_line
510
518
set r_line_count $line_count
511
-
512
- if {[catch {set g $have_commit($cmit) }]} {
513
- set bg [lindex $group_colors 0]
514
- set group_colors [lrange $group_colors 1 end]
515
- lappend group_colors $bg
516
- foreach i $w_columns {
517
- $i tag conf g$cmit -background $bg
518
- }
519
- set have_commit($cmit ) 1
520
- }
521
519
} elseif {[string match {filename *} $line ]} {
522
520
set file [string range $line 9 end]
523
521
set n $r_line_count
@@ -563,6 +561,30 @@ method _read_blame {fd cur_w cur_d cur_s} {
563
561
incr first_lno -1
564
562
}
565
563
564
+ set color {}
565
+ if {$first_lno < $lno } {
566
+ foreach g [$w_file tag names $first_lno .0] {
567
+ if {[regexp {^color[0-9]+$} $g ]} {
568
+ set color $g
569
+ break
570
+ }
571
+ }
572
+ } else {
573
+ set i [lsort [concat \
574
+ [$w_file tag names " [ expr {$first_lno - 1}] .0" ] \
575
+ [$w_file tag names " [ expr {$lno + $n }] .0" ] \
576
+ ]]
577
+ for {set g 0} {$g < [llength $group_colors ]} {incr g} {
578
+ if {[lsearch -sorted -exact $i color$g ] == -1} {
579
+ set color color$g
580
+ break
581
+ }
582
+ }
583
+ }
584
+ if {$color eq {}} {
585
+ set color color0
586
+ }
587
+
566
588
while {$n > 0} {
567
589
set lno_e " $lno .0 lineend + 1c"
568
590
if {[lindex $line_data $lno ] ne {}} {
@@ -583,6 +605,14 @@ method _read_blame {fd cur_w cur_d cur_s} {
583
605
}
584
606
585
607
foreach i $w_columns {
608
+ if {$cur_w eq $w_amov } {
609
+ for {set g 0} \
610
+ {$g < [llength $group_colors ]} \
611
+ {incr g} {
612
+ $i tag remove color$g $lno .0 $lno_e
613
+ }
614
+ $i tag add $color $lno .0 $lno_e
615
+ }
586
616
$i tag add g$cmit $lno .0 $lno_e
587
617
}
588
618
@@ -616,6 +646,18 @@ method _read_blame {fd cur_w cur_d cur_s} {
616
646
} else {
617
647
$cur_w insert $lno .0 { |}
618
648
}
649
+
650
+ if {$cur_w eq $w_amov } {
651
+ foreach i $w_columns {
652
+ for {set g 0} \
653
+ {$g < [llength $group_colors ]} \
654
+ {incr g} {
655
+ $i tag remove color$g $lno .0 $lno_e
656
+ }
657
+ $i tag add $color $lno .0 $lno_e
658
+ }
659
+ }
660
+
619
661
incr lno
620
662
}
621
663
@@ -678,10 +720,11 @@ method _load_commit {cur_w cur_d pos} {
678
720
679
721
method _showcommit {cur_w lno} {
680
722
global repo_config
723
+ variable active_color
681
724
682
725
if {$highlight_commit ne {}} {
683
726
foreach i $w_columns {
684
- $i tag conf g$highlight_commit -background $old_bgcolor
727
+ $i tag conf g$highlight_commit -background {}
685
728
$i tag lower g$highlight_commit
686
729
}
687
730
}
@@ -704,7 +747,6 @@ method _showcommit {cur_w lno} {
704
747
set cmit [lindex $dat 0]
705
748
set file [lindex $dat 1]
706
749
707
- set old_bgcolor [$w_file tag cget g$cmit -background]
708
750
foreach i $w_columns {
709
751
$i tag conf g$cmit -background $active_color
710
752
$i tag raise g$cmit
0 commit comments