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 # Switches for original location detection
38 variable original_options
[list -C -C]
39 if {[git-version
>= 1.5.3]} {
40 lappend original_options
-w ; # ignore indentation changes
43 # Current blame data; cleared/reset on each load
45 field commit
; # input commit to blame
46 field path
; # input filename to view in $commit
48 field current_fd
{} ; # background process running
49 field highlight_line
-1 ; # current line selected
50 field highlight_column
{} ; # current commit column selected
51 field highlight_commit
{} ; # sha1 of commit selected
53 field total_lines
0 ; # total length of file
54 field blame_lines
0 ; # number of lines computed
55 field amov_data
; # list of {commit origfile origline}
56 field asim_data
; # list of {commit origfile origline}
58 field r_commit
; # commit currently being parsed
59 field r_orig_line
; # original line number
60 field r_final_line
; # final line number
61 field r_line_count
; # lines in this region
63 field tooltip_wm
{} ; # Current tooltip toplevel, if open
64 field tooltip_t
{} ; # Text widget in $tooltip_wm
65 field tooltip_timer
{} ; # Current timer event for our tooltip
66 field tooltip_commit
{} ; # Commit(s) in tooltip
68 constructor new
{i_commit i_path
} {
77 wm title
$top [append "[appname] ([reponame]): " [mc
"File Viewer"]]
79 frame $w.header
-background gold
80 label $w.header.commit_l
\
81 -text [mc
"Commit:"] \
86 set w_back
$w.header.commit_b
88 -image ::blame::img_back_arrow \
94 -activebackground gold
95 bind $w_back <Button-1
> "
96 if {\[$w_back cget -state\] eq {normal}} {
100 label $w.header.commit
\
101 -textvariable @commit
\
106 label $w.header.path_l
\
112 set w_path
$w.header.path
118 pack $w.header.commit_l
-side left
119 pack $w_back -side left
120 pack $w.header.commit
-side left
121 pack $w_path -fill x
-side right
122 pack $w.header.path_l
-side right
124 panedwindow $w.file_pane
-orient vertical
125 frame $w.file_pane.out
126 frame $w.file_pane.cm
127 $w.file_pane add
$w.file_pane.out
\
132 $w.file_pane add
$w.file_pane.cm
\
138 set w_line
$w.file_pane.out.linenumber_t
141 -highlightthickness 0 \
151 $w_line tag conf linenumber
-justify right
-rmargin 5
153 set w_amov
$w.file_pane.out.amove_t
156 -highlightthickness 0 \
166 $w_amov tag conf author_abbr
-justify right
-rmargin 5
167 $w_amov tag conf curr_commit
168 $w_amov tag conf prior_commit
-foreground blue
-underline 1
169 $w_amov tag
bind prior_commit
\
171 "[cb _load_commit $w_amov @amov_data @%x,%y];break"
173 set w_asim
$w.file_pane.out.asimple_t
176 -highlightthickness 0 \
186 $w_asim tag conf author_abbr
-justify right
187 $w_asim tag conf curr_commit
188 $w_asim tag conf prior_commit
-foreground blue
-underline 1
189 $w_asim tag
bind prior_commit
\
191 "[cb _load_commit $w_asim @asim_data @%x,%y];break"
193 set w_file
$w.file_pane.out.file_t
196 -highlightthickness 0 \
205 -xscrollcommand [list $w.file_pane.out.sbx
set] \
208 set w_columns
[list $w_amov $w_asim $w_line $w_file]
210 scrollbar $w.file_pane.out.sbx
\
212 -command [list $w_file xview
]
213 scrollbar $w.file_pane.out.sby
\
215 -command [list scrollbar2many
$w_columns yview
]
216 eval grid $w_columns $w.file_pane.out.sby
-sticky nsew
218 $w.file_pane.out.sbx
\
219 -column [expr {[llength $w_columns] - 1}] \
221 grid columnconfigure
\
223 [expr {[llength $w_columns] - 1}] \
225 grid rowconfigure
$w.file_pane.out
0 -weight 1
227 set w_cviewer
$w.file_pane.cm.t
236 -xscrollcommand [list $w.file_pane.cm.sbx
set] \
237 -yscrollcommand [list $w.file_pane.cm.sby
set] \
239 $w_cviewer tag conf still_loading
\
240 -font font_uiitalic
\
242 $w_cviewer tag conf header_key
\
244 -background $active_color \
246 $w_cviewer tag conf header_val
\
247 -background $active_color \
249 $w_cviewer tag
raise sel
250 scrollbar $w.file_pane.cm.sbx
\
252 -command [list $w_cviewer xview
]
253 scrollbar $w.file_pane.cm.sby
\
255 -command [list $w_cviewer yview
]
256 pack $w.file_pane.cm.sby
-side right
-fill y
257 pack $w.file_pane.cm.sbx
-side bottom
-fill x
258 pack $w_cviewer -expand 1 -fill both
260 set status
[::status_bar::new $w.status
]
262 menu $w.ctxm
-tearoff 0
263 $w.ctxm add command
\
264 -label [mc
"Copy Commit"] \
265 -command [cb _copycommit
]
267 foreach i
$w_columns {
268 for {set g
0} {$g < [llength $group_colors]} {incr g
} {
269 $i tag conf color
$g -background [lindex $group_colors $g]
272 $i conf
-cursor $cursor_ptr
273 $i conf
-yscrollcommand [list many2scrollbar
\
274 $w_columns yview
$w.file_pane.out.sby
]
277 [cb _click $i @%x,%y]
280 bind $i <Any-Motion
> [cb _show_tooltip
$i @%x
,%y
]
281 bind $i <Any-Enter
> [cb _hide_tooltip
]
282 bind $i <Any-Leave
> [cb _hide_tooltip
]
288 tk_popup $w.ctxm %X %Y
290 bind $i <Shift-Tab
> "[list focus $w_cviewer];break"
291 bind $i <Tab
> "[list focus $w_cviewer];break"
294 foreach i
[concat $w_columns $w_cviewer] {
295 bind $i <Key-Up
> {catch {%W yview scroll
-1 units
};break}
296 bind $i <Key-Down
> {catch {%W yview scroll
1 units
};break}
297 bind $i <Key-Left
> {catch {%W xview scroll
-1 units
};break}
298 bind $i <Key-Right
> {catch {%W xview scroll
1 units
};break}
299 bind $i <Key-k
> {catch {%W yview scroll
-1 units
};break}
300 bind $i <Key-j
> {catch {%W yview scroll
1 units
};break}
301 bind $i <Key-h
> {catch {%W xview scroll
-1 units
};break}
302 bind $i <Key-l
> {catch {%W xview scroll
1 units
};break}
303 bind $i <Control-Key-b
> {catch {%W yview scroll
-1 pages
};break}
304 bind $i <Control-Key-f
> {catch {%W yview scroll
1 pages
};break}
307 bind $w_cviewer <Shift-Tab
> "[list focus $w_file];break"
308 bind $w_cviewer <Tab
> "[list focus $w_file];break"
309 bind $w_cviewer <Button-1
> [list focus $w_cviewer]
310 bind $w_file <Visibility
> [list focus $w_file]
312 grid configure
$w.header
-sticky ew
313 grid configure
$w.file_pane
-sticky nsew
314 grid configure
$w.status
-sticky ew
315 grid columnconfigure
$top 0 -weight 1
316 grid rowconfigure
$top 0 -weight 0
317 grid rowconfigure
$top 1 -weight 1
318 grid rowconfigure
$top 2 -weight 0
320 set req_w
[winfo reqwidth
$top]
321 set req_h
[winfo reqheight
$top]
322 set scr_h
[expr {[winfo screenheight
$top] - 100}]
323 if {$req_w < 600} {set req_w
600}
324 if {$req_h < $scr_h} {set req_h
$scr_h}
325 set g
"${req_w}x${req_h}"
329 set old_height
[winfo height
$w.file_pane
]
330 $w.file_pane sash
place 0 \
331 [lindex [$w.file_pane sash coord
0] 0] \
332 [expr {int
($old_height * 0.70)}]
333 bind $w.file_pane
<Configure
> \
334 "if {{$w.file_pane} eq {%W}} {[cb _resize %h]}"
339 method _load
{jump
} {
340 variable group_colors
344 if {$total_lines != 0 ||
$current_fd ne
{}} {
345 if {$current_fd ne
{}} {
346 catch {close $current_fd}
350 foreach i
$w_columns {
351 $i conf
-state normal
353 foreach g
[$i tag names
] {
354 if {[regexp {^g
[0-9a-f
]{40}$} $g]} {
358 $i conf
-state disabled
361 $w_cviewer conf
-state normal
362 $w_cviewer delete
0.0 end
363 $w_cviewer conf
-state disabled
365 set highlight_line
-1
366 set highlight_column
{}
367 set highlight_commit
{}
371 if {$history eq
{}} {
372 $w_back conf
-state disabled
374 $w_back conf
-state normal
377 # Index 0 is always empty. There is never line 0 as
378 # we use only 1 based lines, as that matches both with
379 # git-blame output and with Tk's text widget.
381 set amov_data
[list [list]]
382 set asim_data
[list [list]]
384 $status show
[mc
"Reading %s..." "$commit:[escape_path $path]"]
385 $w_path conf
-text [escape_path
$path]
387 set fd
[open $path r
]
388 fconfigure $fd -eofchar {}
390 set fd
[git_read cat-file blob
"$commit:$path"]
392 fconfigure $fd -blocking 0 -translation lf
-encoding binary
393 fileevent $fd readable
[cb _read_file
$fd $jump]
397 method _history_menu
{} {
399 if {[winfo exists
$m]} {
405 for {set i
[expr {[llength $history] - 1}]
406 } {$i >= 0} {incr i
-1} {
407 set e
[lindex $history $i]
411 if {[regexp {^
[0-9a-f
]{40}$} $c]} {
412 set t
[string range
$c 0 8]...
413 } elseif
{$c eq
{}} {
414 set t
{Working Directory
}
418 if {![catch {set summary
$header($c,summary
)}]} {
420 if {[string length
$t] > 70} {
421 set t
[string range
$t 0 66]...
425 $m add command
-label $t -command [cb _goback
$i]
427 set X
[winfo rootx
$w_back]
428 set Y
[expr {[winfo rooty
$w_back] + [winfo height
$w_back]}]
433 set dat
[lindex $history $i]
434 set history [lrange $history 0 [expr {$i - 1}]]
435 set commit
[lindex $dat 0]
436 set path
[lindex $dat 1]
437 _load
$this [lrange $dat 2 5]
440 method _read_file
{fd jump
} {
441 if {$fd ne
$current_fd} {
446 foreach i
$w_columns {$i conf
-state normal
}
447 while {[gets $fd line
] >= 0} {
448 regsub "\r\$" $line {} line
453 if {$total_lines > 1} {
454 foreach i
$w_columns {$i insert end
"\n"}
457 $w_line insert end
"$total_lines" linenumber
458 $w_file insert end
"$line"
461 set ln_wc
[expr {[string length
$total_lines] + 2}]
462 if {[$w_line cget
-width] < $ln_wc} {
463 $w_line conf
-width $ln_wc
466 foreach i
$w_columns {$i conf
-state disabled
}
471 # If we don't force Tk to update the widgets *right now*
472 # none of our jump commands will cause a change in the UI.
476 if {[llength $jump] == 1} {
477 set highlight_line
[lindex $jump 0]
478 $w_file see
"$highlight_line.0"
479 } elseif
{[llength $jump] == 4} {
480 set highlight_column
[lindex $jump 0]
481 set highlight_line
[lindex $jump 1]
482 $w_file xview moveto
[lindex $jump 2]
483 $w_file yview moveto
[lindex $jump 3]
486 _exec_blame
$this $w_asim @asim_data
\
488 [mc
"Loading copy/move tracking annotations..."]
490 } ifdeleted
{ catch {close $fd} }
492 method _exec_blame
{cur_w cur_d
options cur_s
} {
493 lappend options --incremental
495 lappend options --contents $path
497 lappend options $commit
499 lappend options -- $path
500 set fd
[eval git_read
--nice blame
$options]
501 fconfigure $fd -blocking 0 -translation lf
-encoding binary
502 fileevent $fd readable
[cb _read_blame
$fd $cur_w $cur_d]
508 [mc
"lines annotated"]
511 method _read_blame
{fd cur_w cur_d
} {
512 upvar #0 $cur_d line_data
513 variable group_colors
514 variable original_options
516 if {$fd ne
$current_fd} {
521 $cur_w conf
-state normal
522 while {[gets $fd line
] >= 0} {
523 if {[regexp {^
([a-z0-9
]{40}) (\d
+) (\d
+) (\d
+)$} $line line
\
524 cmit original_line final_line line_count
]} {
526 set r_orig_line
$original_line
527 set r_final_line
$final_line
528 set r_line_count
$line_count
529 } elseif
{[string match
{filename *} $line]} {
530 set file [string range
$line 9 end
]
532 set lno
$r_final_line
536 if {[regexp {^
0{40}$} $cmit]} {
538 set commit_type curr_commit
539 } elseif
{$cmit eq
$commit} {
541 set commit_type curr_commit
543 set commit_type prior_commit
544 set commit_abbr
[string range
$cmit 0 3]
549 catch {set a_name
$header($cmit,author
)}
550 while {$a_name ne
{}} {
551 if {$author_abbr ne
{}
552 && [string index
$a_name 0] eq
{'
}} {
553 regsub {^'
[^'
]+'
\s
+} $a_name {} a_name
555 if {![regexp {^
([[:upper
:]])} $a_name _a
]} break
556 append author_abbr
$_a
559 {^
[[:upper
:]][^
\s
]*\s
+} \
560 $a_name {} a_name
]} break
562 if {$author_abbr eq
{}} {
565 set author_abbr
[string range
$author_abbr 0 3]
572 && $cmit eq
[lindex $line_data [expr {$first_lno - 1}] 0]
573 && $file eq
[lindex $line_data [expr {$first_lno - 1}] 1]
579 if {$first_lno < $lno} {
580 foreach g
[$w_file tag names
$first_lno.0] {
581 if {[regexp {^color
[0-9]+$} $g]} {
587 set i
[lsort [concat \
588 [$w_file tag names
"[expr {$first_lno - 1}].0"] \
589 [$w_file tag names
"[expr {$lno + $n}].0"] \
591 for {set g
0} {$g < [llength $group_colors]} {incr g
} {
592 if {[lsearch -sorted -exact $i color
$g] == -1} {
603 set lno_e
"$lno.0 lineend + 1c"
604 if {[lindex $line_data $lno] ne
{}} {
605 set g
[lindex $line_data $lno 0]
606 foreach i
$w_columns {
607 $i tag remove g
$g $lno.0 $lno_e
610 lset line_data
$lno [list $cmit $file $oln]
612 $cur_w delete
$lno.0 "$lno.0 lineend"
613 if {$lno == $first_lno} {
614 $cur_w insert
$lno.0 $commit_abbr $commit_type
615 } elseif
{$lno == [expr {$first_lno + 1}]} {
616 $cur_w insert
$lno.0 $author_abbr author_abbr
618 $cur_w insert
$lno.0 { |
}
621 foreach i
$w_columns {
622 if {$cur_w eq
$w_amov} {
624 {$g < [llength $group_colors]} \
626 $i tag remove color
$g $lno.0 $lno_e
628 $i tag add
$color $lno.0 $lno_e
630 $i tag add g
$cmit $lno.0 $lno_e
633 if {$highlight_column eq
$cur_w} {
634 if {$highlight_line == -1
635 && [lindex [$w_file yview
] 0] == 0} {
637 set highlight_line
$lno
639 if {$highlight_line == $lno} {
640 _showcommit
$this $cur_w $lno
651 $cmit eq
[lindex $line_data $lno 0]
652 && $file eq
[lindex $line_data $lno 1]
654 $cur_w delete
$lno.0 "$lno.0 lineend"
656 if {$lno == $first_lno} {
657 $cur_w insert
$lno.0 $commit_abbr $commit_type
658 } elseif
{$lno == [expr {$first_lno + 1}]} {
659 $cur_w insert
$lno.0 $author_abbr author_abbr
661 $cur_w insert
$lno.0 { |
}
664 if {$cur_w eq
$w_amov} {
665 foreach i
$w_columns {
667 {$g < [llength $group_colors]} \
669 $i tag remove color
$g $lno.0 $lno_e
671 $i tag add
$color $lno.0 $lno_e
678 } elseif
{[regexp {^
([a-z-
]+) (.
*)$} $line line key data
]} {
679 set header
($r_commit,$key) $data
682 $cur_w conf
-state disabled
686 if {$cur_w eq
$w_asim} {
687 _exec_blame
$this $w_amov @amov_data
\
689 [mc
"Loading original location annotations..."]
692 $status stop
[mc
"Annotation complete."]
695 $status update $blame_lines $total_lines
697 } ifdeleted
{ catch {close $fd} }
699 method _click
{cur_w pos
} {
700 set lno
[lindex [split [$cur_w index
$pos] .
] 0]
701 _showcommit
$this $cur_w $lno
704 method _load_commit
{cur_w cur_d pos
} {
705 upvar #0 $cur_d line_data
706 set lno
[lindex [split [$cur_w index
$pos] .
] 0]
707 set dat
[lindex $line_data $lno]
709 lappend history [list \
713 [lindex [$w_file xview
] 0] \
714 [lindex [$w_file yview
] 0] \
716 set commit
[lindex $dat 0]
717 set path
[lindex $dat 1]
718 _load
$this [list [lindex $dat 2]]
722 method _showcommit
{cur_w lno
} {
724 variable active_color
726 if {$highlight_commit ne
{}} {
727 foreach i
$w_columns {
728 $i tag conf g
$highlight_commit -background {}
729 $i tag
lower g
$highlight_commit
733 if {$cur_w eq
$w_asim} {
734 set dat
[lindex $asim_data $lno]
735 set highlight_column
$w_asim
737 set dat
[lindex $amov_data $lno]
738 set highlight_column
$w_amov
741 $w_cviewer conf
-state normal
742 $w_cviewer delete
0.0 end
746 $w_cviewer insert end
[mc
"Loading annotation..."] still_loading
748 set cmit
[lindex $dat 0]
749 set file [lindex $dat 1]
751 foreach i
$w_columns {
752 $i tag conf g
$cmit -background $active_color
759 catch {set author_name
$header($cmit,author
)}
760 catch {set author_email
$header($cmit,author-mail
)}
761 catch {set author_time
[format_date
$header($cmit,author-time
)]}
763 set committer_name
{}
764 set committer_email
{}
765 set committer_time
{}
766 catch {set committer_name
$header($cmit,committer
)}
767 catch {set committer_email
$header($cmit,committer-mail
)}
768 catch {set committer_time
[format_date
$header($cmit,committer-time
)]}
770 if {[catch {set msg
$header($cmit,message)}]} {
773 set fd
[git_read cat-file commit
$cmit]
774 fconfigure $fd -encoding binary -translation lf
775 if {[catch {set enc
$repo_config(i18n.commitencoding
)}]} {
778 while {[gets $fd line
] > 0} {
779 if {[string match
{encoding *} $line]} {
780 set enc
[string tolower
[string range
$line 9 end
]]
786 set enc
[tcl_encoding
$enc]
788 set msg
[encoding convertfrom
$enc $msg]
789 set author_name
[encoding convertfrom
$enc $author_name]
790 set committer_name
[encoding convertfrom
$enc $committer_name]
791 set header
($cmit,author
) $author_name
792 set header
($cmit,committer
) $committer_name
793 set header
($cmit,summary
) \
794 [encoding convertfrom
$enc $header($cmit,summary
)]
796 set msg
[string trim
$msg]
798 set header
($cmit,message) $msg
801 $w_cviewer insert end
"commit $cmit\n" header_key
802 $w_cviewer insert end
[strcat
[mc
"Author:"] "\t"] header_key
803 $w_cviewer insert end
"$author_name $author_email" header_val
804 $w_cviewer insert end
" $author_time\n" header_val
806 $w_cviewer insert end
[strcat
[mc
"Committer:"] "\t"] header_key
807 $w_cviewer insert end
"$committer_name $committer_email" header_val
808 $w_cviewer insert end
" $committer_time\n" header_val
810 if {$file ne
$path} {
811 $w_cviewer insert end
[strcat
[mc
"Original File:"] "\t"] header_key
812 $w_cviewer insert end
"[escape_path $file]\n" header_val
815 $w_cviewer insert end
"\n$msg"
817 $w_cviewer conf
-state disabled
819 set highlight_line
$lno
820 set highlight_commit
$cmit
822 if {[lsearch -exact $tooltip_commit $highlight_commit] != -1} {
827 method _copycommit
{} {
828 set pos
@$::cursorX,$::cursorY
829 set lno
[lindex [split [$::cursorW index
$pos] .
] 0]
830 set dat
[lindex $amov_data $lno]
840 method _show_tooltip
{cur_w pos
} {
841 if {$tooltip_wm ne
{}} {
842 _open_tooltip
$this $cur_w
843 } elseif
{$tooltip_timer eq
{}} {
844 set tooltip_timer
[after 1000 [cb _open_tooltip
$cur_w]]
848 method _open_tooltip
{cur_w
} {
850 set pos_x
[winfo pointerx
$cur_w]
851 set pos_y
[winfo pointery
$cur_w]
852 if {[winfo containing
$pos_x $pos_y] ne
$cur_w} {
857 if {$tooltip_wm ne
"$cur_w.tooltip"} {
860 set tooltip_wm
[toplevel $cur_w.tooltip
-borderwidth 1]
861 wm overrideredirect
$tooltip_wm 1
862 wm transient
$tooltip_wm [winfo toplevel $cur_w]
863 set tooltip_t
$tooltip_wm.
label
866 -highlightthickness 0 \
870 -background lightyellow
\
872 $tooltip_t tag conf section_header
-font font_uibold
875 $tooltip_t conf
-state normal
876 $tooltip_t delete
0.0 end
879 set pos
@[join [list \
880 [expr {$pos_x - [winfo rootx
$cur_w]}] \
881 [expr {$pos_y - [winfo rooty
$cur_w]}]] ,]
882 set lno
[lindex [split [$cur_w index
$pos] .
] 0]
883 if {$cur_w eq
$w_amov} {
884 set dat
[lindex $amov_data $lno]
887 set dat
[lindex $asim_data $lno]
888 set org
[lindex $amov_data $lno]
896 set cmit
[lindex $dat 0]
897 set tooltip_commit
[list $cmit]
902 catch {set author_name
$header($cmit,author
)}
903 catch {set summary
$header($cmit,summary
)}
904 catch {set author_time
[format_date
$header($cmit,author-time
)]}
906 $tooltip_t insert end
"commit $cmit\n"
907 $tooltip_t insert end
"$author_name $author_time\n"
908 $tooltip_t insert end
"$summary"
910 if {$org ne
{} && [lindex $org 0] ne
$cmit} {
911 set save
[$tooltip_t get
0.0 end
]
912 $tooltip_t delete
0.0 end
914 set cmit
[lindex $org 0]
915 set file [lindex $org 1]
916 lappend tooltip_commit
$cmit
921 catch {set author_name
$header($cmit,author
)}
922 catch {set summary
$header($cmit,summary
)}
923 catch {set author_time
[format_date
$header($cmit,author-time
)]}
925 $tooltip_t insert end
[strcat
[mc
"Originally By:"] "\n"] section_header
926 $tooltip_t insert end
"commit $cmit\n"
927 $tooltip_t insert end
"$author_name $author_time\n"
928 $tooltip_t insert end
"$summary\n"
930 if {$file ne
$path} {
931 $tooltip_t insert end
[strcat
[mc
"In File:"] " "] section_header
932 $tooltip_t insert end
"$file\n"
935 $tooltip_t insert end
"\n"
936 $tooltip_t insert end
[strcat
[mc
"Copied Or Moved Here By:"] "\n"] section_header
937 $tooltip_t insert end
$save
940 $tooltip_t conf
-state disabled
941 _position_tooltip
$this
944 method _position_tooltip
{} {
945 set max_h
[lindex [split [$tooltip_t index end
] .
] 0]
947 for {set i
1} {$i <= $max_h} {incr i
} {
948 set c
[lindex [split [$tooltip_t index
"$i.0 lineend"] .
] 1]
949 if {$c > $max_w} {set max_w
$c}
951 $tooltip_t conf
-width $max_w -height $max_h
953 set req_w
[winfo reqwidth
$tooltip_t]
954 set req_h
[winfo reqheight
$tooltip_t]
955 set pos_x
[expr {[winfo pointerx .
] + 5}]
956 set pos_y
[expr {[winfo pointery .
] + 10}]
958 set g
"${req_w}x${req_h}"
959 if {$pos_x >= 0} {append g
+}
961 if {$pos_y >= 0} {append g
+}
964 wm geometry
$tooltip_wm $g
968 method _hide_tooltip
{} {
969 if {$tooltip_wm ne
{}} {
972 set tooltip_commit
{}
974 if {$tooltip_timer ne
{}} {
975 after cancel
$tooltip_timer
980 method _resize
{new_height
} {
981 set diff
[expr {$new_height - $old_height}]
982 if {$diff == 0} return
984 set my
[expr {[winfo height
$w.file_pane
] - 25}]
985 set o
[$w.file_pane sash coord
0]
987 set oy
[expr {[lindex $o 1] + $diff}]
988 if {$oy < 0} {set oy
0}
989 if {$oy > $my} {set oy
$my}
990 $w.file_pane sash
place 0 $ox $oy
992 set old_height
$new_height