@@ -56,9 +56,9 @@ field r_final_line ; # final line number
56
56
field r_line_count ; # lines in this region
57
57
58
58
field tooltip_wm {} ; # Current tooltip toplevel, if open
59
+ field tooltip_t {} ; # Text widget in $tooltip_wm
59
60
field tooltip_timer {} ; # Current timer event for our tooltip
60
- field tooltip_commit {} ; # Commit in tooltip
61
- field tooltip_text {} ; # Text in current tooltip
61
+ field tooltip_commit {} ; # Commit(s) in tooltip
62
62
63
63
constructor new {i_commit i_path} {
64
64
global cursor_ptr
@@ -653,6 +653,7 @@ method _showcommit {cur_w lno} {
653
653
if {$highlight_commit ne {}} {
654
654
foreach i $w_columns {
655
655
$i tag conf g$highlight_commit -background $old_bgcolor
656
+ $i tag lower g$highlight_commit
656
657
}
657
658
}
658
659
@@ -677,6 +678,7 @@ method _showcommit {cur_w lno} {
677
678
set old_bgcolor [$w_file tag cget g$cmit -background]
678
679
foreach i $w_columns {
679
680
$i tag conf g$cmit -background $active_color
681
+ $i tag raise g$cmit
680
682
}
681
683
682
684
set author_name {}
@@ -746,7 +748,7 @@ method _showcommit {cur_w lno} {
746
748
set highlight_line $lno
747
749
set highlight_commit $cmit
748
750
749
- if {$highlight_commit eq $tooltip_commit} {
751
+ if {[lsearch -exact $tooltip_commit $highlight_commit] != -1 } {
750
752
_hide_tooltip $this
751
753
}
752
754
}
@@ -765,26 +767,7 @@ method _copycommit {} {
765
767
}
766
768
767
769
method _show_tooltip {cur_w pos} {
768
- set lno [lindex [split [$cur_w index $pos] .] 0]
769
- if {$cur_w eq $w_amov} {
770
- set dat [lindex $amov_data $lno]
771
- } else {
772
- set dat [lindex $asim_data $lno]
773
- }
774
- if {$dat eq {}} {
775
- _hide_tooltip $this
776
- return
777
- }
778
- set cmit [lindex $dat 0]
779
-
780
- if {$cmit eq $highlight_commit} {
781
- _hide_tooltip $this
782
- return
783
- }
784
-
785
- if {$cmit eq $tooltip_commit} {
786
- _position_tooltip $this
787
- } elseif {$tooltip_wm ne {}} {
770
+ if {$tooltip_wm ne {}} {
788
771
_open_tooltip $this $cur_w
789
772
} elseif {$tooltip_timer eq {}} {
790
773
set tooltip_timer [after 1000 [cb _open_tooltip $cur_w]]
@@ -800,70 +783,101 @@ method _open_tooltip {cur_w} {
800
783
return
801
784
}
802
785
786
+ if {$tooltip_wm ne "$cur_w.tooltip"} {
787
+ _hide_tooltip $this
788
+
789
+ set tooltip_wm [toplevel $cur_w.tooltip -borderwidth 1]
790
+ wm overrideredirect $tooltip_wm 1
791
+ wm transient $tooltip_wm [winfo toplevel $cur_w]
792
+ set tooltip_t $tooltip_wm.label
793
+ text $tooltip_t \
794
+ -takefocus 0 \
795
+ -highlightthickness 0 \
796
+ -relief flat \
797
+ -borderwidth 0 \
798
+ -wrap none \
799
+ -background lightyellow \
800
+ -foreground black
801
+ $tooltip_t tag conf section_header -font font_uibold
802
+ pack $tooltip_t
803
+ } else {
804
+ $tooltip_t conf -state normal
805
+ $tooltip_t delete 0.0 end
806
+ }
807
+
803
808
set pos @[join [list \
804
809
[expr {$pos_x - [winfo rootx $cur_w]}] \
805
810
[expr {$pos_y - [winfo rooty $cur_w]}]] ,]
806
811
set lno [lindex [split [$cur_w index $pos] .] 0]
807
812
if {$cur_w eq $w_amov} {
808
813
set dat [lindex $amov_data $lno]
814
+ set org {}
809
815
} else {
810
816
set dat [lindex $asim_data $lno]
817
+ set org [lindex $amov_data $lno]
811
818
}
819
+
812
820
set cmit [lindex $dat 0]
813
- set file [lindex $dat 1 ]
821
+ set tooltip_commit [list $cmit ]
814
822
815
823
set author_name {}
816
- set author_email {}
824
+ set summary {}
817
825
set author_time {}
818
826
catch {set author_name $header($cmit,author)}
819
- catch {set author_email $header($cmit,author-mail )}
827
+ catch {set summary $header($cmit,summary )}
820
828
catch {set author_time [clock format \
821
829
$header($cmit,author-time) \
822
830
-format {%Y-%m-%d %H:%M:%S}
823
831
]}
824
832
825
- set committer_name {}
826
- set committer_email {}
827
- set committer_time {}
828
- catch {set committer_name $header($cmit,committer)}
829
- catch {set committer_email $header($cmit,committer-mail)}
830
- catch {set committer_time [clock format \
831
- $header($cmit,committer-time) \
832
- -format {%Y-%m-%d %H:%M:%S}
833
- ]}
833
+ $tooltip_t insert end "commit $cmit\n"
834
+ $tooltip_t insert end "$author_name $author_time\n"
835
+ $tooltip_t insert end "$summary"
834
836
835
- set summary {}
836
- catch {set summary $header($cmit,summary)}
837
+ if {$org ne {} && [lindex $org 0] ne $cmit} {
838
+ $tooltip_t insert 0.0 "Moved Here By:\n" section_header
839
+ set cmit [lindex $org 0]
840
+ set file [lindex $org 1]
841
+ lappend tooltip_commit $cmit
837
842
838
- set tooltip_commit $cmit
839
- set tooltip_text "commit $cmit
840
- $author_name $author_email $author_time
841
- $summary"
843
+ set author_name {}
844
+ set summary {}
845
+ set author_time {}
846
+ catch {set author_name $header($cmit,author)}
847
+ catch {set summary $header($cmit,summary)}
848
+ catch {set author_time [clock format \
849
+ $header($cmit,author-time) \
850
+ -format {%Y-%m-%d %H:%M:%S}
851
+ ]}
842
852
843
- if {$file ne $path} {
844
- append tooltip_text "
853
+ $tooltip_t insert end "\n\n"
854
+ $tooltip_t insert end "Originally By:\n" section_header
855
+ $tooltip_t insert end "commit $cmit\n"
856
+ $tooltip_t insert end "$author_name $author_time\n"
857
+ $tooltip_t insert end "$summary"
845
858
846
- Original File: $file"
859
+ if {$file ne $path} {
860
+ $tooltip_t insert end "\n"
861
+ $tooltip_t insert end "File: " section_header
862
+ $tooltip_t insert end $file
863
+ }
847
864
}
848
865
849
- if {$tooltip_wm ne "$cur_w.tooltip"} {
850
- _hide_tooltip $this
851
-
852
- set tooltip_wm [toplevel $cur_w.tooltip -borderwidth 1]
853
- wm overrideredirect $tooltip_wm 1
854
- wm transient $tooltip_wm [winfo toplevel $cur_w]
855
- pack [label $tooltip_wm.label \
856
- -background lightyellow \
857
- -foreground black \
858
- -textvariable @tooltip_text \
859
- -justify left]
860
- }
866
+ $tooltip_t conf -state disabled
861
867
_position_tooltip $this
862
868
}
863
869
864
870
method _position_tooltip {} {
865
- set req_w [winfo reqwidth $tooltip_wm.label]
866
- set req_h [winfo reqheight $tooltip_wm.label]
871
+ set max_h [lindex [split [$tooltip_t index end] .] 0]
872
+ set max_w 0
873
+ for {set i 1} {$i <= $max_h} {incr i} {
874
+ set c [lindex [split [$tooltip_t index "$i.0 lineend"] .] 1]
875
+ if {$c > $max_w} {set max_w $c}
876
+ }
877
+ $tooltip_t conf -width $max_w -height $max_h
878
+
879
+ set req_w [winfo reqwidth $tooltip_t]
880
+ set req_h [winfo reqheight $tooltip_t]
867
881
set pos_x [expr {[winfo pointerx .] + 5}]
868
882
set pos_y [expr {[winfo pointery .] + 10}]
869
883
0 commit comments