field w ; # top window in this viewer
field w_back ; # our back button
field w_path ; # label showing the current file path
+field w_columns ; # list of all column widgets in the viewer
field w_line ; # text column: all line numbers
field w_cgrp ; # text column: abbreviated commit SHA-1s
field w_file ; # text column: actual file data
field current_fd {} ; # background process running
field highlight_line -1 ; # current line selected
field highlight_commit {} ; # sha1 of commit selected
+field old_bgcolor {} ; # background of current selection
field total_lines 0 ; # total length of file
field blame_lines 0 ; # number of lines computed
-xscrollcommand [list $w.file_pane.out.sbx set] \
-font font_diff
+ set w_columns [list $w_cgrp $w_line $w_file]
+
scrollbar $w.file_pane.out.sbx \
-orient h \
-command [list $w_file xview]
scrollbar $w.file_pane.out.sby \
-orient v \
- -command [list scrollbar2many [list \
- $w_line \
- $w_cgrp \
- $w_file \
- ] yview]
- grid \
- $w_cgrp \
- $w_line \
- $w_file \
- $w.file_pane.out.sby \
- -sticky nsew
- grid conf $w.file_pane.out.sbx -column 2 -sticky we
- grid columnconfigure $w.file_pane.out 2 -weight 1
+ -command [list scrollbar2many $w_columns yview]
+ eval grid $w_columns $w.file_pane.out.sby -sticky nsew
+ grid conf \
+ $w.file_pane.out.sbx \
+ -column [expr {[llength $w_columns] - 1}] \
+ -sticky we
+ grid columnconfigure \
+ $w.file_pane.out \
+ [expr {[llength $w_columns] - 1}] \
+ -weight 1
grid rowconfigure $w.file_pane.out 0 -weight 1
set w_cmit $w.file_pane.cm.t
-label "Copy Commit" \
-command [cb _copycommit]
- foreach i [list \
- $w_cgrp \
- $w_line \
- $w_file] {
+ foreach i $w_columns {
$i conf -cursor $cursor_ptr
- $i conf -yscrollcommand \
- [list many2scrollbar [list \
- $w_cgrp \
- $w_line \
- $w_file \
- ] yview $w.file_pane.out.sby]
+ $i conf -yscrollcommand [list many2scrollbar \
+ $w_columns yview $w.file_pane.out.sby]
bind $i <Button-1> "
[cb _hide_tooltip]
[cb _click $i @%x,%y]
"
}
- foreach i [list \
- $w_cgrp \
- $w_line \
- $w_file \
- $w_cmit] {
+ foreach i [concat $w_columns $w_cmit] {
bind $i <Key-Up> {catch {%W yview scroll -1 units};break}
bind $i <Key-Down> {catch {%W yview scroll 1 units};break}
bind $i <Key-Left> {catch {%W xview scroll -1 units};break}
set current_fd {}
}
+ foreach i $w_columns {
+ $i conf -state normal
+ $i delete 0.0 end
+ foreach cmit [array names have_commit] {
+ $i tag delete g$cmit
+ }
+ $i conf -state disabled
+ }
+
set highlight_line -1
set highlight_commit {}
set total_lines 0
array unset have_commit
array unset line_commit
array unset line_file
-
- $w_cgrp conf -state normal
- $w_line conf -state normal
- $w_file conf -state normal
-
- $w_cgrp delete 0.0 end
- $w_line delete 0.0 end
- $w_file delete 0.0 end
-
- $w_cgrp conf -state disabled
- $w_line conf -state disabled
- $w_file conf -state disabled
}
if {[winfo exists $w.status.c]} {
return
}
- $w_cgrp conf -state normal
- $w_line conf -state normal
- $w_file conf -state normal
+ foreach i $w_columns {$i conf -state normal}
while {[gets $fd line] >= 0} {
regsub "\r\$" $line {} line
incr total_lines
if {$total_lines > 1} {
- $w_cgrp insert end "\n"
- $w_line insert end "\n"
- $w_file insert end "\n"
+ foreach i $w_columns {$i insert end "\n"}
}
$w_line insert end "$total_lines" linenumber
$w_line conf -width $ln_wc
}
- $w_cgrp conf -state disabled
- $w_line conf -state disabled
- $w_file conf -state disabled
+ foreach i $w_columns {$i conf -state disabled}
if {[eof $fd]} {
close $fd
set bg [lindex $group_colors 0]
set group_colors [lrange $group_colors 1 end]
lappend group_colors $bg
-
- $w_cgrp tag conf g$cmit -background $bg
- $w_line tag conf g$cmit -background $bg
- $w_file tag conf g$cmit -background $bg
-
+ foreach i $w_columns {
+ $i tag conf g$cmit -background $bg
+ }
set have_commit($cmit) 1
}
} elseif {[string match {filename *} $line]} {
while {$n > 0} {
set lno_e "$lno.0 lineend + 1c"
if {![catch {set g g$line_commit($lno)}]} {
- $w_cgrp tag remove g$g $lno.0 $lno_e
- $w_line tag remove g$g $lno.0 $lno_e
- $w_file tag remove g$g $lno.0 $lno_e
-
- $w_cgrp tag remove a$g $lno.0 $lno_e
- $w_line tag remove a$g $lno.0 $lno_e
- $w_file tag remove a$g $lno.0 $lno_e
+ foreach i $w_columns {
+ $i tag remove g$g $lno.0 $lno_e
+ }
}
set line_commit($lno) $cmit
$w_cgrp insert $lno.0 { |}
}
- $w_cgrp tag add g$cmit $lno.0 $lno_e
- $w_line tag add g$cmit $lno.0 $lno_e
- $w_file tag add g$cmit $lno.0 $lno_e
-
- $w_cgrp tag add a$cmit $lno.0 $lno_e
- $w_line tag add a$cmit $lno.0 $lno_e
- $w_file tag add a$cmit $lno.0 $lno_e
+ foreach i $w_columns {
+ $i tag add g$cmit $lno.0 $lno_e
+ }
if {$highlight_line == -1} {
if {[lindex [$w_file yview] 0] == 0} {
global repo_config
if {$highlight_commit ne {}} {
- set cmit $highlight_commit
- $w_cgrp tag conf a$cmit -background {}
- $w_line tag conf a$cmit -background {}
- $w_file tag conf a$cmit -background {}
+ foreach i $w_columns {
+ $i tag conf g$highlight_commit -background $old_bgcolor
+ }
}
$w_cmit conf -state normal
set cmit {}
$w_cmit insert end "Loading annotation..."
} else {
- $w_cgrp tag conf a$cmit -background $active_color
- $w_line tag conf a$cmit -background $active_color
- $w_file tag conf a$cmit -background $active_color
+ set old_bgcolor [$w_file tag cget g$cmit -background]
+ foreach i $w_columns {
+ $i tag conf g$cmit -background $active_color
+ }
set author_name {}
set author_email {}