2 # Copyright (C) 2006, 2007 Shawn Pearce
6 image create photo ::blame::img_back_arrow -data {R0lGODlhGAAYAIUAAPwCBEzKXFTSZIz+nGzmhGzqfGTidIT+nEzGXHTqhGzmfGzifFzadETCVES+VARWDFzWbHzyjAReDGTadFTOZDSyRDyyTCymPARaFGTedFzSbDy2TCyqRCyqPARaDAyCHES6VDy6VCyiPAR6HCSeNByWLARyFARiDARqFGTifARiFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAYABgAAAajQIBwSCwaj8ikcsk0BppJwRPqHEypQwHBis0WDAdEFyBIKBaMAKLBdjQeSkFBYTBAIvgEoS6JmhUTEwIUDQ4VFhcMGEhyCgoZExoUaxsWHB0THkgfAXUGAhoBDSAVFR0XBnCbDRmgog0hpSIiDJpJIyEQhBUcJCIlwA22SSYVogknEg8eD82qSigdDSknY0IqJQXPYxIl1dZCGNvWw+Dm510GQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7}
8 # Persistant data (survives loads)
10 field history {}; # viewer history: {commit path}
11 field header ; # array commit,key -> header field
15 field w ; # top window in this viewer
16 field w_back ; # our back button
17 field w_path ; # label showing the current file path
18 field w_columns ; # list of all column widgets in the viewer
19 field w_line ; # text column: all line numbers
20 field w_amov ; # text column: annotations + move tracking
21 field w_asim ; # text column: annotations (simple computation)
22 field w_file ; # text column: actual file data
23 field w_cviewer ; # pane showing commit message
24 field status ; # status mega-widget instance
25 field old_height ; # last known height of $w.file_pane
29 variable active_color #c0edc5
30 variable group_colors {
36 # Current blame data; cleared/reset on each load
38 field commit ; # input commit to blame
39 field path ; # input filename to view in $commit
41 field current_fd {} ; # background process running
42 field highlight_line -1 ; # current line selected
43 field highlight_column {} ; # current commit column selected
44 field highlight_commit {} ; # sha1 of commit selected
46 field total_lines 0 ; # total length of file
47 field blame_lines 0 ; # number of lines computed
48 field amov_data ; # list of {commit origfile origline}
49 field asim_data ; # list of {commit origfile origline}
51 field r_commit ; # commit currently being parsed
52 field r_orig_line ; # original line number
53 field r_final_line ; # final line number
54 field r_line_count ; # lines in this region
56 field tooltip_wm {} ; # Current tooltip toplevel, if open
57 field tooltip_t {} ; # Text widget in $tooltip_wm
58 field tooltip_timer {} ; # Current timer event for our tooltip
59 field tooltip_commit {} ; # Commit(s) in tooltip
61 constructor new {i_commit i_path} {
70 wm title $top [append "[appname] ([reponame]): " [mc "File Viewer"]]
72 frame $w.header -background gold
73 label $w.header.commit_l \
74 -text [mc "Commit:"] \
79 set w_back $w.header.commit_b
81 -image ::blame::img_back_arrow \
87 -activebackground gold
88 bind $w_back <Button-1> "
89 if {\[$w_back cget -state\] eq {normal}} {
93 label $w.header.commit \
94 -textvariable @commit \
99 label $w.header.path_l \
105 set w_path $w.header.path
111 pack $w.header.commit_l -side left
112 pack $w_back -side left
113 pack $w.header.commit -side left
114 pack $w_path -fill x -side right
115 pack $w.header.path_l -side right
117 panedwindow $w.file_pane -orient vertical
118 frame $w.file_pane.out
119 frame $w.file_pane.cm
120 $w.file_pane add $w.file_pane.out \
125 $w.file_pane add $w.file_pane.cm \
131 set w_line $w.file_pane.out.linenumber_t
134 -highlightthickness 0 \
144 $w_line tag conf linenumber -justify right -rmargin 5
146 set w_amov $w.file_pane.out.amove_t
149 -highlightthickness 0 \
159 $w_amov tag conf author_abbr -justify right -rmargin 5
160 $w_amov tag conf curr_commit
161 $w_amov tag conf prior_commit -foreground blue -underline 1
162 $w_amov tag bind prior_commit \
164 "[cb _load_commit $w_amov @amov_data @%x,%y];break"
166 set w_asim $w.file_pane.out.asimple_t
169 -highlightthickness 0 \
179 $w_asim tag conf author_abbr -justify right
180 $w_asim tag conf curr_commit
181 $w_asim tag conf prior_commit -foreground blue -underline 1
182 $w_asim tag bind prior_commit \
184 "[cb _load_commit $w_asim @asim_data @%x,%y];break"
186 set w_file $w.file_pane.out.file_t
189 -highlightthickness 0 \
198 -xscrollcommand [list $w.file_pane.out.sbx set] \
201 set w_columns [list $w_amov $w_asim $w_line $w_file]
203 scrollbar $w.file_pane.out.sbx \
205 -command [list $w_file xview]
206 scrollbar $w.file_pane.out.sby \
208 -command [list scrollbar2many $w_columns yview]
209 eval grid $w_columns $w.file_pane.out.sby -sticky nsew
211 $w.file_pane.out.sbx \
212 -column [expr {[llength $w_columns] - 1}] \
214 grid columnconfigure \
216 [expr {[llength $w_columns] - 1}] \
218 grid rowconfigure $w.file_pane.out 0 -weight 1
220 set w_cviewer $w.file_pane.cm.t
229 -xscrollcommand [list $w.file_pane.cm.sbx set] \
230 -yscrollcommand [list $w.file_pane.cm.sby set] \
232 $w_cviewer tag conf still_loading \
233 -font font_uiitalic \
235 $w_cviewer tag conf header_key \
237 -background $active_color \
239 $w_cviewer tag conf header_val \
240 -background $active_color \
242 $w_cviewer tag raise sel
243 scrollbar $w.file_pane.cm.sbx \
245 -command [list $w_cviewer xview]
246 scrollbar $w.file_pane.cm.sby \
248 -command [list $w_cviewer yview]
249 pack $w.file_pane.cm.sby -side right -fill y
250 pack $w.file_pane.cm.sbx -side bottom -fill x
251 pack $w_cviewer -expand 1 -fill both
253 set status [::status_bar::new $w.status]
255 menu $w.ctxm -tearoff 0
256 $w.ctxm add command \
257 -label [mc "Copy Commit"] \
258 -command [cb _copycommit]
259 $w.ctxm add command \
260 -label [mc "Do Full Copy Detection"] \
261 -command [cb _fullcopyblame]
263 foreach i $w_columns {
264 for {set g 0} {$g < [llength $group_colors]} {incr g} {
265 $i tag conf color$g -background [lindex $group_colors $g]
268 $i conf -cursor $cursor_ptr
269 $i conf -yscrollcommand [list many2scrollbar \
270 $w_columns yview $w.file_pane.out.sby]
273 [cb _click $i @%x,%y]
276 bind $i <Any-Motion> [cb _show_tooltip $i @%x,%y]
277 bind $i <Any-Enter> [cb _hide_tooltip]
278 bind $i <Any-Leave> [cb _hide_tooltip]
284 tk_popup $w.ctxm %X %Y
286 bind $i <Shift-Tab> "[list focus $w_cviewer];break"
287 bind $i <Tab> "[list focus $w_cviewer];break"
290 foreach i [concat $w_columns $w_cviewer] {
291 bind $i <Key-Up> {catch {%W yview scroll -1 units};break}
292 bind $i <Key-Down> {catch {%W yview scroll 1 units};break}
293 bind $i <Key-Left> {catch {%W xview scroll -1 units};break}
294 bind $i <Key-Right> {catch {%W xview scroll 1 units};break}
295 bind $i <Key-k> {catch {%W yview scroll -1 units};break}
296 bind $i <Key-j> {catch {%W yview scroll 1 units};break}
297 bind $i <Key-h> {catch {%W xview scroll -1 units};break}
298 bind $i <Key-l> {catch {%W xview scroll 1 units};break}
299 bind $i <Control-Key-b> {catch {%W yview scroll -1 pages};break}
300 bind $i <Control-Key-f> {catch {%W yview scroll 1 pages};break}
303 bind $w_cviewer <Shift-Tab> "[list focus $w_file];break"
304 bind $w_cviewer <Tab> "[list focus $w_file];break"
305 bind $w_cviewer <Button-1> [list focus $w_cviewer]
306 bind $w_file <Visibility> [list focus $w_file]
308 grid configure $w.header -sticky ew
309 grid configure $w.file_pane -sticky nsew
310 grid configure $w.status -sticky ew
311 grid columnconfigure $top 0 -weight 1
312 grid rowconfigure $top 0 -weight 0
313 grid rowconfigure $top 1 -weight 1
314 grid rowconfigure $top 2 -weight 0
316 set req_w [winfo reqwidth $top]
317 set req_h [winfo reqheight $top]
318 set scr_h [expr {[winfo screenheight $top] - 100}]
319 if {$req_w < 600} {set req_w 600}
320 if {$req_h < $scr_h} {set req_h $scr_h}
321 set g "${req_w}x${req_h}"
325 set old_height [winfo height $w.file_pane]
326 $w.file_pane sash place 0 \
327 [lindex [$w.file_pane sash coord 0] 0] \
328 [expr {int($old_height * 0.70)}]
329 bind $w.file_pane <Configure> \
330 "if {{$w.file_pane} eq {%W}} {[cb _resize %h]}"
332 wm protocol $top WM_DELETE_WINDOW "destroy $top"
333 bind $top <Destroy> [cb _kill]
339 if {$current_fd ne {}} {
340 kill_file_process $current_fd
341 catch {close $current_fd}
346 method _load {jump} {
347 variable group_colors
351 if {$total_lines != 0 || $current_fd ne {}} {
354 foreach i $w_columns {
355 $i conf -state normal
357 foreach g [$i tag names] {
358 if {[regexp {^g[0-9a-f]{40}$} $g]} {
362 $i conf -state disabled
365 $w_cviewer conf -state normal
366 $w_cviewer delete 0.0 end
367 $w_cviewer conf -state disabled
369 set highlight_line -1
370 set highlight_column {}
371 set highlight_commit {}
375 if {$history eq {}} {
376 $w_back conf -state disabled
378 $w_back conf -state normal
381 # Index 0 is always empty. There is never line 0 as
382 # we use only 1 based lines, as that matches both with
383 # git-blame output and with Tk's text widget.
385 set amov_data [list [list]]
386 set asim_data [list [list]]
388 $status show [mc "Reading %s..." "$commit:[escape_path $path]"]
389 $w_path conf -text [escape_path $path]
391 set fd [open $path r]
392 fconfigure $fd -eofchar {}
394 set fd [git_read cat-file blob "$commit:$path"]
396 fconfigure $fd -blocking 0 -translation lf -encoding binary
397 fileevent $fd readable [cb _read_file $fd $jump]
401 method _history_menu {} {
403 if {[winfo exists $m]} {
409 for {set i [expr {[llength $history] - 1}]
410 } {$i >= 0} {incr i -1} {
411 set e [lindex $history $i]
415 if {[regexp {^[0-9a-f]{40}$} $c]} {
416 set t [string range $c 0 8]...
417 } elseif {$c eq {}} {
418 set t {Working Directory}
422 if {![catch {set summary $header($c,summary)}]} {
424 if {[string length $t] > 70} {
425 set t [string range $t 0 66]...
429 $m add command -label $t -command [cb _goback $i]
431 set X [winfo rootx $w_back]
432 set Y [expr {[winfo rooty $w_back] + [winfo height $w_back]}]
437 set dat [lindex $history $i]
438 set history [lrange $history 0 [expr {$i - 1}]]
439 set commit [lindex $dat 0]
440 set path [lindex $dat 1]
441 _load $this [lrange $dat 2 5]
444 method _read_file {fd jump} {
445 if {$fd ne $current_fd} {
450 foreach i $w_columns {$i conf -state normal}
451 while {[gets $fd line] >= 0} {
452 regsub "\r\$" $line {} line
457 if {$total_lines > 1} {
458 foreach i $w_columns {$i insert end "\n"}
461 $w_line insert end "$total_lines" linenumber
462 $w_file insert end "$line"
465 set ln_wc [expr {[string length $total_lines] + 2}]
466 if {[$w_line cget -width] < $ln_wc} {
467 $w_line conf -width $ln_wc
470 foreach i $w_columns {$i conf -state disabled}
475 # If we don't force Tk to update the widgets *right now*
476 # none of our jump commands will cause a change in the UI.
480 if {[llength $jump] == 1} {
481 set highlight_line [lindex $jump 0]
482 $w_file see "$highlight_line.0"
483 } elseif {[llength $jump] == 4} {
484 set highlight_column [lindex $jump 0]
485 set highlight_line [lindex $jump 1]
486 $w_file xview moveto [lindex $jump 2]
487 $w_file yview moveto [lindex $jump 3]
490 _exec_blame $this $w_asim @asim_data \
492 [mc "Loading copy/move tracking annotations..."]
494 } ifdeleted { catch {close $fd} }
496 method _exec_blame {cur_w cur_d options cur_s} {
497 lappend options --incremental
499 lappend options --contents $path
501 lappend options $commit
503 lappend options -- $path
504 set fd [eval git_read --nice blame $options]
505 fconfigure $fd -blocking 0 -translation lf -encoding binary
506 fileevent $fd readable [cb _read_blame $fd $cur_w $cur_d]
512 [mc "lines annotated"]
515 method _read_blame {fd cur_w cur_d} {
516 upvar #0 $cur_d line_data
517 variable group_colors
519 if {$fd ne $current_fd} {
524 $cur_w conf -state normal
525 while {[gets $fd line] >= 0} {
526 if {[regexp {^([a-z0-9]{40}) (\d+) (\d+) (\d+)$} $line line \
527 cmit original_line final_line line_count]} {
529 set r_orig_line $original_line
530 set r_final_line $final_line
531 set r_line_count $line_count
532 } elseif {[string match {filename *} $line]} {
533 set file [string range $line 9 end]
535 set lno $r_final_line
539 if {[regexp {^0{40}$} $cmit]} {
541 set commit_type curr_commit
542 } elseif {$cmit eq $commit} {
544 set commit_type curr_commit
546 set commit_type prior_commit
547 set commit_abbr [string range $cmit 0 3]
552 catch {set a_name $header($cmit,author)}
553 while {$a_name ne {}} {
554 if {$author_abbr ne {}
555 && [string index $a_name 0] eq {'}} {
556 regsub {^'[^']+'\s+} $a_name {} a_name
558 if {![regexp {^([[:upper:]])} $a_name _a]} break
559 append author_abbr $_a
562 {^[[:upper:]][^\s]*\s+} \
563 $a_name {} a_name ]} break
565 if {$author_abbr eq {}} {
568 set author_abbr [string range $author_abbr 0 3]
575 && $cmit eq [lindex $line_data [expr {$first_lno - 1}] 0]
576 && $file eq [lindex $line_data [expr {$first_lno - 1}] 1]
582 if {$first_lno < $lno} {
583 foreach g [$w_file tag names $first_lno.0] {
584 if {[regexp {^color[0-9]+$} $g]} {
590 set i [lsort [concat \
591 [$w_file tag names "[expr {$first_lno - 1}].0"] \
592 [$w_file tag names "[expr {$lno + $n}].0"] \
594 for {set g 0} {$g < [llength $group_colors]} {incr g} {
595 if {[lsearch -sorted -exact $i color$g] == -1} {
606 set lno_e "$lno.0 lineend + 1c"
607 if {[lindex $line_data $lno] ne {}} {
608 set g [lindex $line_data $lno 0]
609 foreach i $w_columns {
610 $i tag remove g$g $lno.0 $lno_e
613 lset line_data $lno [list $cmit $file $oln]
615 $cur_w delete $lno.0 "$lno.0 lineend"
616 if {$lno == $first_lno} {
617 $cur_w insert $lno.0 $commit_abbr $commit_type
618 } elseif {$lno == [expr {$first_lno + 1}]} {
619 $cur_w insert $lno.0 $author_abbr author_abbr
621 $cur_w insert $lno.0 { |}
624 foreach i $w_columns {
625 if {$cur_w eq $w_amov} {
627 {$g < [llength $group_colors]} \
629 $i tag remove color$g $lno.0 $lno_e
631 $i tag add $color $lno.0 $lno_e
633 $i tag add g$cmit $lno.0 $lno_e
636 if {$highlight_column eq $cur_w} {
637 if {$highlight_line == -1
638 && [lindex [$w_file yview] 0] == 0} {
640 set highlight_line $lno
642 if {$highlight_line == $lno} {
643 _showcommit $this $cur_w $lno
654 $cmit eq [lindex $line_data $lno 0]
655 && $file eq [lindex $line_data $lno 1]
657 $cur_w delete $lno.0 "$lno.0 lineend"
659 if {$lno == $first_lno} {
660 $cur_w insert $lno.0 $commit_abbr $commit_type
661 } elseif {$lno == [expr {$first_lno + 1}]} {
662 $cur_w insert $lno.0 $author_abbr author_abbr
664 $cur_w insert $lno.0 { |}
667 if {$cur_w eq $w_amov} {
668 foreach i $w_columns {
670 {$g < [llength $group_colors]} \
672 $i tag remove color$g $lno.0 $lno_e
674 $i tag add $color $lno.0 $lno_e
681 } elseif {[regexp {^([a-z-]+) (.*)$} $line line key data]} {
682 set header($r_commit,$key) $data
685 $cur_w conf -state disabled
689 if {$cur_w eq $w_asim} {
690 # Switches for original location detection
691 set threshold [get_config gui.copyblamethreshold]
692 set original_options [list "-C$threshold"]
694 if {![is_config_true gui.fastcopyblame]} {
695 # thorough copy search; insert before the threshold
696 set original_options [linsert $original_options 0 -C]
698 if {[git-version >= 1.5.3]} {
699 lappend original_options -w ; # ignore indentation changes
702 _exec_blame $this $w_amov @amov_data \
704 [mc "Loading original location annotations..."]
707 $status stop [mc "Annotation complete."]
710 $status update $blame_lines $total_lines
712 } ifdeleted { catch {close $fd} }
714 method _find_commit_bound {data_list start_idx delta} {
715 upvar #0 $data_list line_data
717 set limit [expr {[llength $line_data] - 1}]
718 set base_commit [lindex $line_data $pos 0]
720 while {$pos > 0 && $pos < $limit} {
721 set new_pos [expr {$pos + $delta}]
722 if {[lindex $line_data $new_pos 0] ne $base_commit} {
732 method _fullcopyblame {} {
733 if {$current_fd ne {}} {
738 -message [mc "Annotation process is already running."]
743 # Switches for original location detection
744 set threshold [get_config gui.copyblamethreshold]
745 set original_options [list -C -C "-C$threshold"]
747 if {[git-version >= 1.5.3]} {
748 lappend original_options -w ; # ignore indentation changes
751 # Find the line range
752 set pos @$::cursorX,$::cursorY
753 set lno [lindex [split [$::cursorW index $pos] .] 0]
754 set min_amov_lno [_find_commit_bound $this @amov_data $lno -1]
755 set max_amov_lno [_find_commit_bound $this @amov_data $lno 1]
756 set min_asim_lno [_find_commit_bound $this @asim_data $lno -1]
757 set max_asim_lno [_find_commit_bound $this @asim_data $lno 1]
759 if {$min_asim_lno < $min_amov_lno} {
760 set min_amov_lno $min_asim_lno
763 if {$max_asim_lno > $max_amov_lno} {
764 set max_amov_lno $max_asim_lno
767 lappend original_options -L "$min_amov_lno,$max_amov_lno"
770 for {set i $min_amov_lno} {$i <= $max_amov_lno} {incr i} {
771 lset amov_data $i [list ]
774 # Start the back-end process
775 _exec_blame $this $w_amov @amov_data \
777 [mc "Running thorough copy detection..."]
780 method _click {cur_w pos} {
781 set lno [lindex [split [$cur_w index $pos] .] 0]
782 _showcommit $this $cur_w $lno
785 method _load_commit {cur_w cur_d pos} {
786 upvar #0 $cur_d line_data
787 set lno [lindex [split [$cur_w index $pos] .] 0]
788 set dat [lindex $line_data $lno]
790 lappend history [list \
794 [lindex [$w_file xview] 0] \
795 [lindex [$w_file yview] 0] \
797 set commit [lindex $dat 0]
798 set path [lindex $dat 1]
799 _load $this [list [lindex $dat 2]]
803 method _showcommit {cur_w lno} {
805 variable active_color
807 if {$highlight_commit ne {}} {
808 foreach i $w_columns {
809 $i tag conf g$highlight_commit -background {}
810 $i tag lower g$highlight_commit
814 if {$cur_w eq $w_asim} {
815 set dat [lindex $asim_data $lno]
816 set highlight_column $w_asim
818 set dat [lindex $amov_data $lno]
819 set highlight_column $w_amov
822 $w_cviewer conf -state normal
823 $w_cviewer delete 0.0 end
827 $w_cviewer insert end [mc "Loading annotation..."] still_loading
829 set cmit [lindex $dat 0]
830 set file [lindex $dat 1]
832 foreach i $w_columns {
833 $i tag conf g$cmit -background $active_color
840 catch {set author_name $header($cmit,author)}
841 catch {set author_email $header($cmit,author-mail)}
842 catch {set author_time [format_date $header($cmit,author-time)]}
844 set committer_name {}
845 set committer_email {}
846 set committer_time {}
847 catch {set committer_name $header($cmit,committer)}
848 catch {set committer_email $header($cmit,committer-mail)}
849 catch {set committer_time [format_date $header($cmit,committer-time)]}
851 if {[catch {set msg $header($cmit,message)}]} {
854 set fd [git_read cat-file commit $cmit]
855 fconfigure $fd -encoding binary -translation lf
856 if {[catch {set enc $repo_config(i18n.commitencoding)}]} {
859 while {[gets $fd line] > 0} {
860 if {[string match {encoding *} $line]} {
861 set enc [string tolower [string range $line 9 end]]
867 set enc [tcl_encoding $enc]
869 set msg [encoding convertfrom $enc $msg]
870 set author_name [encoding convertfrom $enc $author_name]
871 set committer_name [encoding convertfrom $enc $committer_name]
872 set header($cmit,author) $author_name
873 set header($cmit,committer) $committer_name
874 set header($cmit,summary) \
875 [encoding convertfrom $enc $header($cmit,summary)]
877 set msg [string trim $msg]
879 set header($cmit,message) $msg
882 $w_cviewer insert end "commit $cmit\n" header_key
883 $w_cviewer insert end [strcat [mc "Author:"] "\t"] header_key
884 $w_cviewer insert end "$author_name $author_email" header_val
885 $w_cviewer insert end " $author_time\n" header_val
887 $w_cviewer insert end [strcat [mc "Committer:"] "\t"] header_key
888 $w_cviewer insert end "$committer_name $committer_email" header_val
889 $w_cviewer insert end " $committer_time\n" header_val
891 if {$file ne $path} {
892 $w_cviewer insert end [strcat [mc "Original File:"] "\t"] header_key
893 $w_cviewer insert end "[escape_path $file]\n" header_val
896 $w_cviewer insert end "\n$msg"
898 $w_cviewer conf -state disabled
900 set highlight_line $lno
901 set highlight_commit $cmit
903 if {[lsearch -exact $tooltip_commit $highlight_commit] != -1} {
908 method _copycommit {} {
909 set pos @$::cursorX,$::cursorY
910 set lno [lindex [split [$::cursorW index $pos] .] 0]
911 set dat [lindex $amov_data $lno]
921 method _show_tooltip {cur_w pos} {
922 if {$tooltip_wm ne {}} {
923 _open_tooltip $this $cur_w
924 } elseif {$tooltip_timer eq {}} {
925 set tooltip_timer [after 1000 [cb _open_tooltip $cur_w]]
929 method _open_tooltip {cur_w} {
931 set pos_x [winfo pointerx $cur_w]
932 set pos_y [winfo pointery $cur_w]
933 if {[winfo containing $pos_x $pos_y] ne $cur_w} {
938 if {$tooltip_wm ne "$cur_w.tooltip"} {
941 set tooltip_wm [toplevel $cur_w.tooltip -borderwidth 1]
942 wm overrideredirect $tooltip_wm 1
943 wm transient $tooltip_wm [winfo toplevel $cur_w]
944 set tooltip_t $tooltip_wm.label
947 -highlightthickness 0 \
951 -background lightyellow \
953 $tooltip_t tag conf section_header -font font_uibold
956 $tooltip_t conf -state normal
957 $tooltip_t delete 0.0 end
960 set pos @[join [list \
961 [expr {$pos_x - [winfo rootx $cur_w]}] \
962 [expr {$pos_y - [winfo rooty $cur_w]}]] ,]
963 set lno [lindex [split [$cur_w index $pos] .] 0]
964 if {$cur_w eq $w_amov} {
965 set dat [lindex $amov_data $lno]
968 set dat [lindex $asim_data $lno]
969 set org [lindex $amov_data $lno]
977 set cmit [lindex $dat 0]
978 set tooltip_commit [list $cmit]
983 catch {set author_name $header($cmit,author)}
984 catch {set summary $header($cmit,summary)}
985 catch {set author_time [format_date $header($cmit,author-time)]}
987 $tooltip_t insert end "commit $cmit\n"
988 $tooltip_t insert end "$author_name $author_time\n"
989 $tooltip_t insert end "$summary"
991 if {$org ne {} && [lindex $org 0] ne $cmit} {
992 set save [$tooltip_t get 0.0 end]
993 $tooltip_t delete 0.0 end
995 set cmit [lindex $org 0]
996 set file [lindex $org 1]
997 lappend tooltip_commit $cmit
1002 catch {set author_name $header($cmit,author)}
1003 catch {set summary $header($cmit,summary)}
1004 catch {set author_time [format_date $header($cmit,author-time)]}
1006 $tooltip_t insert end [strcat [mc "Originally By:"] "\n"] section_header
1007 $tooltip_t insert end "commit $cmit\n"
1008 $tooltip_t insert end "$author_name $author_time\n"
1009 $tooltip_t insert end "$summary\n"
1011 if {$file ne $path} {
1012 $tooltip_t insert end [strcat [mc "In File:"] " "] section_header
1013 $tooltip_t insert end "$file\n"
1016 $tooltip_t insert end "\n"
1017 $tooltip_t insert end [strcat [mc "Copied Or Moved Here By:"] "\n"] section_header
1018 $tooltip_t insert end $save
1021 $tooltip_t conf -state disabled
1022 _position_tooltip $this
1025 method _position_tooltip {} {
1026 set max_h [lindex [split [$tooltip_t index end] .] 0]
1028 for {set i 1} {$i <= $max_h} {incr i} {
1029 set c [lindex [split [$tooltip_t index "$i.0 lineend"] .] 1]
1030 if {$c > $max_w} {set max_w $c}
1032 $tooltip_t conf -width $max_w -height $max_h
1034 set req_w [winfo reqwidth $tooltip_t]
1035 set req_h [winfo reqheight $tooltip_t]
1036 set pos_x [expr {[winfo pointerx .] + 5}]
1037 set pos_y [expr {[winfo pointery .] + 10}]
1039 set g "${req_w}x${req_h}"
1040 if {$pos_x >= 0} {append g +}
1042 if {$pos_y >= 0} {append g +}
1045 wm geometry $tooltip_wm $g
1049 method _hide_tooltip {} {
1050 if {$tooltip_wm ne {}} {
1053 set tooltip_commit {}
1055 if {$tooltip_timer ne {}} {
1056 after cancel $tooltip_timer
1057 set tooltip_timer {}
1061 method _resize {new_height} {
1062 set diff [expr {$new_height - $old_height}]
1063 if {$diff == 0} return
1065 set my [expr {[winfo height $w.file_pane] - 25}]
1066 set o [$w.file_pane sash coord 0]
1067 set ox [lindex $o 0]
1068 set oy [expr {[lindex $o 1] + $diff}]
1069 if {$oy < 0} {set oy 0}
1070 if {$oy > $my} {set oy $my}
1071 $w.file_pane sash place 0 $ox $oy
1073 set old_height $new_height