summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c17c175)
raw | patch | inline | side by side (parent: c17c175)
author | Shawn O. Pearce <spearce@spearce.org> | |
Sat, 2 Jun 2007 19:34:52 +0000 (15:34 -0400) | ||
committer | Shawn O. Pearce <spearce@spearce.org> | |
Wed, 6 Jun 2007 05:26:50 +0000 (01:26 -0400) |
The code to handle our three different text widgets is a bit
on the messy side as we issue the same command on all three
widgets one at a time. Adding (or removing) columns from the
viewer is messy, as a lot of locations need to have the new
column added into the sequence, or removed from it.
We also now delete the tags we create for each commit when
we switch to display another "commit:path" pair. This way the
text viewer doesn't get bogged down with a massive number of tags
as we traverse through history.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
on the messy side as we issue the same command on all three
widgets one at a time. Adding (or removing) columns from the
viewer is messy, as a lot of locations need to have the new
column added into the sequence, or removed from it.
We also now delete the tags we create for each commit when
we switch to display another "commit:path" pair. This way the
text viewer doesn't get bogged down with a massive number of tags
as we traverse through history.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
lib/blame.tcl | patch | blob | history |
diff --git a/lib/blame.tcl b/lib/blame.tcl
index 24965d99150c25f6ba255e4bf7a583f83aa66684..5fb3df4de756f1f04fea93e331475f678efa08ba 100644 (file)
--- a/lib/blame.tcl
+++ b/lib/blame.tcl
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 {}