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
; # text variable bound to status bar
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 "[appname] ([reponame]): File Viewer"
79 frame $w.header
-background gold
80 label $w.header.commit_l
\
85 set w_back
$w.header.commit_b
87 -image ::blame::img_back_arrow \
92 -activebackground gold
93 bind $w_back <Button-1
> "
94 if {\[$w_back cget -state\] eq {normal}} {
98 label $w.header.commit
\
99 -textvariable @commit
\
103 label $w.header.path_l
\
108 set w_path
$w.header.path
113 pack $w.header.commit_l
-side left
114 pack $w_back -side left
115 pack $w.header.commit
-side left
116 pack $w_path -fill x
-side right
117 pack $w.header.path_l
-side right
119 panedwindow $w.file_pane
-orient vertical
120 frame $w.file_pane.out
121 frame $w.file_pane.cm
122 $w.file_pane add
$w.file_pane.out
\
127 $w.file_pane add
$w.file_pane.cm
\
133 set w_line
$w.file_pane.out.linenumber_t
136 -highlightthickness 0 \
138 -background white
-borderwidth 0 \
144 $w_line tag conf linenumber
-justify right
-rmargin 5
146 set w_amov
$w.file_pane.out.amove_t
149 -highlightthickness 0 \
151 -background white
-borderwidth 0 \
157 $w_amov tag conf author_abbr
-justify right
-rmargin 5
158 $w_amov tag conf curr_commit
159 $w_amov tag conf prior_commit
-foreground blue
-underline 1
160 $w_amov tag
bind prior_commit
\
162 "[cb _load_commit $w_amov @amov_data @%x,%y];break"
164 set w_asim
$w.file_pane.out.asimple_t
167 -highlightthickness 0 \
169 -background white
-borderwidth 0 \
175 $w_asim tag conf author_abbr
-justify right
176 $w_asim tag conf curr_commit
177 $w_asim tag conf prior_commit
-foreground blue
-underline 1
178 $w_asim tag
bind prior_commit
\
180 "[cb _load_commit $w_asim @asim_data @%x,%y];break"
182 set w_file
$w.file_pane.out.file_t
185 -highlightthickness 0 \
187 -background white
-borderwidth 0 \
192 -xscrollcommand [list $w.file_pane.out.sbx
set] \
195 set w_columns
[list $w_amov $w_asim $w_line $w_file]
197 scrollbar $w.file_pane.out.sbx
\
199 -command [list $w_file xview
]
200 scrollbar $w.file_pane.out.sby
\
202 -command [list scrollbar2many
$w_columns yview
]
203 eval grid $w_columns $w.file_pane.out.sby
-sticky nsew
205 $w.file_pane.out.sbx
\
206 -column [expr {[llength $w_columns] - 1}] \
208 grid columnconfigure
\
210 [expr {[llength $w_columns] - 1}] \
212 grid rowconfigure
$w.file_pane.out
0 -weight 1
214 set w_cviewer
$w.file_pane.cm.t
216 -background white
-borderwidth 0 \
221 -xscrollcommand [list $w.file_pane.cm.sbx
set] \
222 -yscrollcommand [list $w.file_pane.cm.sby
set] \
224 $w_cviewer tag conf still_loading
\
225 -font font_uiitalic
\
227 $w_cviewer tag conf header_key
\
229 -background $active_color \
231 $w_cviewer tag conf header_val
\
232 -background $active_color \
234 $w_cviewer tag
raise sel
235 scrollbar $w.file_pane.cm.sbx
\
237 -command [list $w_cviewer xview
]
238 scrollbar $w.file_pane.cm.sby
\
240 -command [list $w_cviewer yview
]
241 pack $w.file_pane.cm.sby
-side right
-fill y
242 pack $w.file_pane.cm.sbx
-side bottom
-fill x
243 pack $w_cviewer -expand 1 -fill both
249 -textvariable @status
\
252 pack $w.status.l
-side left
254 menu $w.ctxm
-tearoff 0
255 $w.ctxm add command
\
256 -label "Copy Commit" \
257 -command [cb _copycommit
]
259 foreach i
$w_columns {
260 for {set g
0} {$g < [llength $group_colors]} {incr g
} {
261 $i tag conf color
$g -background [lindex $group_colors $g]
264 $i conf
-cursor $cursor_ptr
265 $i conf
-yscrollcommand [list many2scrollbar
\
266 $w_columns yview
$w.file_pane.out.sby
]
269 [cb _click $i @%x,%y]
272 bind $i <Any-Motion
> [cb _show_tooltip
$i @%x
,%y
]
273 bind $i <Any-Enter
> [cb _hide_tooltip
]
274 bind $i <Any-Leave
> [cb _hide_tooltip
]
280 tk_popup $w.ctxm %X %Y
282 bind $i <Shift-Tab
> "[list focus $w_cviewer];break"
283 bind $i <Tab
> "[list focus $w_cviewer];break"
286 foreach i
[concat $w_columns $w_cviewer] {
287 bind $i <Key-Up
> {catch {%W yview scroll
-1 units
};break}
288 bind $i <Key-Down
> {catch {%W yview scroll
1 units
};break}
289 bind $i <Key-Left
> {catch {%W xview scroll
-1 units
};break}
290 bind $i <Key-Right
> {catch {%W xview scroll
1 units
};break}
291 bind $i <Key-k
> {catch {%W yview scroll
-1 units
};break}
292 bind $i <Key-j
> {catch {%W yview scroll
1 units
};break}
293 bind $i <Key-h
> {catch {%W xview scroll
-1 units
};break}
294 bind $i <Key-l
> {catch {%W xview scroll
1 units
};break}
295 bind $i <Control-Key-b
> {catch {%W yview scroll
-1 pages
};break}
296 bind $i <Control-Key-f
> {catch {%W yview scroll
1 pages
};break}
299 bind $w_cviewer <Shift-Tab
> "[list focus $w_file];break"
300 bind $w_cviewer <Tab
> "[list focus $w_file];break"
301 bind $w_cviewer <Button-1
> [list focus $w_cviewer]
302 bind $w_file <Visibility
> [list focus $w_file]
304 grid configure
$w.header
-sticky ew
305 grid configure
$w.file_pane
-sticky nsew
306 grid configure
$w.status
-sticky ew
307 grid columnconfigure
$top 0 -weight 1
308 grid rowconfigure
$top 0 -weight 0
309 grid rowconfigure
$top 1 -weight 1
310 grid rowconfigure
$top 2 -weight 0
312 set req_w
[winfo reqwidth
$top]
313 set req_h
[winfo reqheight
$top]
314 set scr_h
[expr {[winfo screenheight
$top] - 100}]
315 if {$req_w < 600} {set req_w
600}
316 if {$req_h < $scr_h} {set req_h
$scr_h}
317 set g
"${req_w}x${req_h}"
321 set old_height
[winfo height
$w.file_pane
]
322 $w.file_pane sash
place 0 \
323 [lindex [$w.file_pane sash coord
0] 0] \
324 [expr {int
($old_height * 0.70)}]
325 bind $w.file_pane
<Configure
> \
326 "if {{$w.file_pane} eq {%W}} {[cb _resize %h]}"
331 method _load
{jump
} {
332 variable group_colors
336 if {$total_lines != 0 ||
$current_fd ne
{}} {
337 if {$current_fd ne
{}} {
338 catch {close $current_fd}
342 foreach i
$w_columns {
343 $i conf
-state normal
345 foreach g
[$i tag names
] {
346 if {[regexp {^g
[0-9a-f
]{40}$} $g]} {
350 $i conf
-state disabled
353 $w_cviewer conf
-state normal
354 $w_cviewer delete
0.0 end
355 $w_cviewer conf
-state disabled
357 set highlight_line
-1
358 set highlight_column
{}
359 set highlight_commit
{}
363 if {[winfo exists
$w.status.c
]} {
364 $w.status.c coords bar
0 0 0 20
368 -height [expr {int
([winfo reqheight
$w.status.l
] * 0.6)}] \
372 $w.status.c create rectangle
0 0 0 20 -tags bar
-fill navy
373 pack $w.status.c
-side right
376 if {$history eq
{}} {
377 $w_back conf
-state disabled
379 $w_back conf
-state normal
382 # Index 0 is always empty. There is never line 0 as
383 # we use only 1 based lines, as that matches both with
384 # git-blame output and with Tk's text widget.
386 set amov_data
[list [list]]
387 set asim_data
[list [list]]
389 set status
"Loading $commit:[escape_path $path]..."
390 $w_path conf
-text [escape_path
$path]
392 set fd
[open $path r
]
394 set cmd
[list git cat-file blob
"$commit:$path"]
395 set fd
[open "| $cmd" r
]
397 fconfigure $fd -blocking 0 -translation lf
-encoding binary
398 fileevent $fd readable
[cb _read_file
$fd $jump]
402 method _history_menu
{} {
404 if {[winfo exists
$m]} {
410 for {set i
[expr {[llength $history] - 1}]
411 } {$i >= 0} {incr i
-1} {
412 set e
[lindex $history $i]
416 if {[regexp {^
[0-9a-f
]{40}$} $c]} {
417 set t
[string range
$c 0 8]...
418 } elseif
{$c eq
{}} {
419 set t
{Working Directory
}
423 if {![catch {set summary
$header($c,summary
)}]} {
425 if {[string length
$t] > 70} {
426 set t
[string range
$t 0 66]...
430 $m add command
-label $t -command [cb _goback
$i]
432 set X
[winfo rootx
$w_back]
433 set Y
[expr {[winfo rooty
$w_back] + [winfo height
$w_back]}]
438 set dat
[lindex $history $i]
439 set history [lrange $history 0 [expr {$i - 1}]]
440 set commit
[lindex $dat 0]
441 set path
[lindex $dat 1]
442 _load
$this [lrange $dat 2 5]
445 method _read_file
{fd jump
} {
446 if {$fd ne
$current_fd} {
451 foreach i
$w_columns {$i conf
-state normal
}
452 while {[gets $fd line
] >= 0} {
453 regsub "\r\$" $line {} line
458 if {$total_lines > 1} {
459 foreach i
$w_columns {$i insert end
"\n"}
462 $w_line insert end
"$total_lines" linenumber
463 $w_file insert end
"$line"
466 set ln_wc
[expr {[string length
$total_lines] + 2}]
467 if {[$w_line cget
-width] < $ln_wc} {
468 $w_line conf
-width $ln_wc
471 foreach i
$w_columns {$i conf
-state disabled
}
476 # If we don't force Tk to update the widgets *right now*
477 # none of our jump commands will cause a change in the UI.
481 if {[llength $jump] == 1} {
482 set highlight_line
[lindex $jump 0]
483 $w_file see
"$highlight_line.0"
484 } elseif
{[llength $jump] == 4} {
485 set highlight_column
[lindex $jump 0]
486 set highlight_line
[lindex $jump 1]
487 $w_file xview moveto
[lindex $jump 2]
488 $w_file yview moveto
[lindex $jump 3]
491 _exec_blame
$this $w_asim @asim_data
\
493 { copy
/move tracking
}
495 } ifdeleted
{ catch {close $fd} }
497 method _exec_blame
{cur_w cur_d
options cur_s
} {
499 if {![is_Windows
] ||
[is_Cygwin
]} {
502 lappend cmd git blame
503 set cmd
[concat $cmd $options]
504 lappend cmd
--incremental
506 lappend cmd
--contents $path
511 set fd
[open "| $cmd" r
]
512 fconfigure $fd -blocking 0 -translation lf
-encoding binary
513 fileevent $fd readable
[cb _read_blame
$fd $cur_w $cur_d $cur_s]
519 method _read_blame
{fd cur_w cur_d cur_s
} {
520 upvar #0 $cur_d line_data
521 variable group_colors
522 variable original_options
524 if {$fd ne
$current_fd} {
529 $cur_w conf
-state normal
530 while {[gets $fd line
] >= 0} {
531 if {[regexp {^
([a-z0-9
]{40}) (\d
+) (\d
+) (\d
+)$} $line line
\
532 cmit original_line final_line line_count
]} {
534 set r_orig_line
$original_line
535 set r_final_line
$final_line
536 set r_line_count
$line_count
537 } elseif
{[string match
{filename *} $line]} {
538 set file [string range
$line 9 end
]
540 set lno
$r_final_line
544 if {[regexp {^
0{40}$} $cmit]} {
546 set commit_type curr_commit
547 } elseif
{$cmit eq
$commit} {
549 set commit_type curr_commit
551 set commit_type prior_commit
552 set commit_abbr
[string range
$cmit 0 3]
557 catch {set a_name
$header($cmit,author
)}
558 while {$a_name ne
{}} {
559 if {$author_abbr ne
{}
560 && [string index
$a_name 0] eq
{'
}} {
561 regsub {^'
[^'
]+'
\s
+} $a_name {} a_name
563 if {![regexp {^
([[:upper
:]])} $a_name _a
]} break
564 append author_abbr
$_a
567 {^
[[:upper
:]][^
\s
]*\s
+} \
568 $a_name {} a_name
]} break
570 if {$author_abbr eq
{}} {
573 set author_abbr
[string range
$author_abbr 0 3]
580 && $cmit eq
[lindex $line_data [expr {$first_lno - 1}] 0]
581 && $file eq
[lindex $line_data [expr {$first_lno - 1}] 1]
587 if {$first_lno < $lno} {
588 foreach g
[$w_file tag names
$first_lno.0] {
589 if {[regexp {^color
[0-9]+$} $g]} {
595 set i
[lsort [concat \
596 [$w_file tag names
"[expr {$first_lno - 1}].0"] \
597 [$w_file tag names
"[expr {$lno + $n}].0"] \
599 for {set g
0} {$g < [llength $group_colors]} {incr g
} {
600 if {[lsearch -sorted -exact $i color
$g] == -1} {
611 set lno_e
"$lno.0 lineend + 1c"
612 if {[lindex $line_data $lno] ne
{}} {
613 set g
[lindex $line_data $lno 0]
614 foreach i
$w_columns {
615 $i tag remove g
$g $lno.0 $lno_e
618 lset line_data
$lno [list $cmit $file $oln]
620 $cur_w delete
$lno.0 "$lno.0 lineend"
621 if {$lno == $first_lno} {
622 $cur_w insert
$lno.0 $commit_abbr $commit_type
623 } elseif
{$lno == [expr {$first_lno + 1}]} {
624 $cur_w insert
$lno.0 $author_abbr author_abbr
626 $cur_w insert
$lno.0 { |
}
629 foreach i
$w_columns {
630 if {$cur_w eq
$w_amov} {
632 {$g < [llength $group_colors]} \
634 $i tag remove color
$g $lno.0 $lno_e
636 $i tag add
$color $lno.0 $lno_e
638 $i tag add g
$cmit $lno.0 $lno_e
641 if {$highlight_column eq
$cur_w} {
642 if {$highlight_line == -1
643 && [lindex [$w_file yview
] 0] == 0} {
645 set highlight_line
$lno
647 if {$highlight_line == $lno} {
648 _showcommit
$this $cur_w $lno
659 $cmit eq
[lindex $line_data $lno 0]
660 && $file eq
[lindex $line_data $lno 1]
662 $cur_w delete
$lno.0 "$lno.0 lineend"
664 if {$lno == $first_lno} {
665 $cur_w insert
$lno.0 $commit_abbr $commit_type
666 } elseif
{$lno == [expr {$first_lno + 1}]} {
667 $cur_w insert
$lno.0 $author_abbr author_abbr
669 $cur_w insert
$lno.0 { |
}
672 if {$cur_w eq
$w_amov} {
673 foreach i
$w_columns {
675 {$g < [llength $group_colors]} \
677 $i tag remove color
$g $lno.0 $lno_e
679 $i tag add
$color $lno.0 $lno_e
686 } elseif
{[regexp {^
([a-z-
]+) (.
*)$} $line line key data
]} {
687 set header
($r_commit,$key) $data
690 $cur_w conf
-state disabled
694 if {$cur_w eq
$w_asim} {
695 _exec_blame
$this $w_amov @amov_data
\
700 set status
{Annotation complete.
}
706 } ifdeleted
{ catch {close $fd} }
708 method _status
{cur_s
} {
709 set have
$blame_lines
710 set total
$total_lines
712 if {$total} {set pdone
[expr {100 * $have / $total}]}
715 "Loading%s annotations... %i of %i lines annotated (%2i%%)" \
716 $cur_s $have $total $pdone]
717 $w.status.c coords bar
0 0 $pdone 20
720 method _click
{cur_w pos
} {
721 set lno
[lindex [split [$cur_w index
$pos] .
] 0]
722 _showcommit
$this $cur_w $lno
725 method _load_commit
{cur_w cur_d pos
} {
726 upvar #0 $cur_d line_data
727 set lno
[lindex [split [$cur_w index
$pos] .
] 0]
728 set dat
[lindex $line_data $lno]
730 lappend history [list \
734 [lindex [$w_file xview
] 0] \
735 [lindex [$w_file yview
] 0] \
737 set commit
[lindex $dat 0]
738 set path
[lindex $dat 1]
739 _load
$this [list [lindex $dat 2]]
743 method _showcommit
{cur_w lno
} {
745 variable active_color
747 if {$highlight_commit ne
{}} {
748 foreach i
$w_columns {
749 $i tag conf g
$highlight_commit -background {}
750 $i tag
lower g
$highlight_commit
754 if {$cur_w eq
$w_asim} {
755 set dat
[lindex $asim_data $lno]
756 set highlight_column
$w_asim
758 set dat
[lindex $amov_data $lno]
759 set highlight_column
$w_amov
762 $w_cviewer conf
-state normal
763 $w_cviewer delete
0.0 end
767 $w_cviewer insert end
"Loading annotation..." still_loading
769 set cmit
[lindex $dat 0]
770 set file [lindex $dat 1]
772 foreach i
$w_columns {
773 $i tag conf g
$cmit -background $active_color
780 catch {set author_name
$header($cmit,author
)}
781 catch {set author_email
$header($cmit,author-mail
)}
782 catch {set author_time
[clock format \
783 $header($cmit,author-time
) \
784 -format {%Y-
%m-
%d
%H
:%M
:%S
}
787 set committer_name
{}
788 set committer_email
{}
789 set committer_time
{}
790 catch {set committer_name
$header($cmit,committer
)}
791 catch {set committer_email
$header($cmit,committer-mail
)}
792 catch {set committer_time
[clock format \
793 $header($cmit,committer-time
) \
794 -format {%Y-
%m-
%d
%H
:%M
:%S
}
797 if {[catch {set msg
$header($cmit,message)}]} {
800 set fd
[open "| git cat-file commit $cmit" r
]
801 fconfigure $fd -encoding binary -translation lf
802 if {[catch {set enc
$repo_config(i18n.commitencoding
)}]} {
805 while {[gets $fd line
] > 0} {
806 if {[string match
{encoding *} $line]} {
807 set enc
[string tolower
[string range
$line 9 end
]]
810 set msg
[encoding convertfrom
$enc [read $fd]]
811 set msg
[string trim
$msg]
814 set author_name
[encoding convertfrom
$enc $author_name]
815 set committer_name
[encoding convertfrom
$enc $committer_name]
817 set header
($cmit,author
) $author_name
818 set header
($cmit,committer
) $committer_name
820 set header
($cmit,message) $msg
823 $w_cviewer insert end
"commit $cmit\n" header_key
824 $w_cviewer insert end
"Author:\t" header_key
825 $w_cviewer insert end
"$author_name $author_email" header_val
826 $w_cviewer insert end
" $author_time\n" header_val
828 $w_cviewer insert end
"Committer:\t" header_key
829 $w_cviewer insert end
"$committer_name $committer_email" header_val
830 $w_cviewer insert end
" $committer_time\n" header_val
832 if {$file ne
$path} {
833 $w_cviewer insert end
"Original File:\t" header_key
834 $w_cviewer insert end
"[escape_path $file]\n" header_val
837 $w_cviewer insert end
"\n$msg"
839 $w_cviewer conf
-state disabled
841 set highlight_line
$lno
842 set highlight_commit
$cmit
844 if {[lsearch -exact $tooltip_commit $highlight_commit] != -1} {
849 method _copycommit
{} {
850 set pos
@$::cursorX,$::cursorY
851 set lno
[lindex [split [$::cursorW index
$pos] .
] 0]
852 set dat
[lindex $amov_data $lno]
862 method _show_tooltip
{cur_w pos
} {
863 if {$tooltip_wm ne
{}} {
864 _open_tooltip
$this $cur_w
865 } elseif
{$tooltip_timer eq
{}} {
866 set tooltip_timer
[after 1000 [cb _open_tooltip
$cur_w]]
870 method _open_tooltip
{cur_w
} {
872 set pos_x
[winfo pointerx
$cur_w]
873 set pos_y
[winfo pointery
$cur_w]
874 if {[winfo containing
$pos_x $pos_y] ne
$cur_w} {
879 if {$tooltip_wm ne
"$cur_w.tooltip"} {
882 set tooltip_wm
[toplevel $cur_w.tooltip
-borderwidth 1]
883 wm overrideredirect
$tooltip_wm 1
884 wm transient
$tooltip_wm [winfo toplevel $cur_w]
885 set tooltip_t
$tooltip_wm.
label
888 -highlightthickness 0 \
892 -background lightyellow
\
894 $tooltip_t tag conf section_header
-font font_uibold
897 $tooltip_t conf
-state normal
898 $tooltip_t delete
0.0 end
901 set pos
@[join [list \
902 [expr {$pos_x - [winfo rootx
$cur_w]}] \
903 [expr {$pos_y - [winfo rooty
$cur_w]}]] ,]
904 set lno
[lindex [split [$cur_w index
$pos] .
] 0]
905 if {$cur_w eq
$w_amov} {
906 set dat
[lindex $amov_data $lno]
909 set dat
[lindex $asim_data $lno]
910 set org
[lindex $amov_data $lno]
913 set cmit
[lindex $dat 0]
914 set tooltip_commit
[list $cmit]
919 catch {set author_name
$header($cmit,author
)}
920 catch {set summary
$header($cmit,summary
)}
921 catch {set author_time
[clock format \
922 $header($cmit,author-time
) \
923 -format {%Y-
%m-
%d
%H
:%M
:%S
}
926 $tooltip_t insert end
"commit $cmit\n"
927 $tooltip_t insert end
"$author_name $author_time\n"
928 $tooltip_t insert end
"$summary"
930 if {$org ne
{} && [lindex $org 0] ne
$cmit} {
931 set save
[$tooltip_t get
0.0 end
]
932 $tooltip_t delete
0.0 end
934 set cmit
[lindex $org 0]
935 set file [lindex $org 1]
936 lappend tooltip_commit
$cmit
941 catch {set author_name
$header($cmit,author
)}
942 catch {set summary
$header($cmit,summary
)}
943 catch {set author_time
[clock format \
944 $header($cmit,author-time
) \
945 -format {%Y-
%m-
%d
%H
:%M
:%S
}
948 $tooltip_t insert end
"Originally By:\n" section_header
949 $tooltip_t insert end
"commit $cmit\n"
950 $tooltip_t insert end
"$author_name $author_time\n"
951 $tooltip_t insert end
"$summary\n"
953 if {$file ne
$path} {
954 $tooltip_t insert end
"In File: " section_header
955 $tooltip_t insert end
"$file\n"
958 $tooltip_t insert end
"\n"
959 $tooltip_t insert end
"Copied Or Moved Here By:\n" section_header
960 $tooltip_t insert end
$save
963 $tooltip_t conf
-state disabled
964 _position_tooltip
$this
967 method _position_tooltip
{} {
968 set max_h
[lindex [split [$tooltip_t index end
] .
] 0]
970 for {set i
1} {$i <= $max_h} {incr i
} {
971 set c
[lindex [split [$tooltip_t index
"$i.0 lineend"] .
] 1]
972 if {$c > $max_w} {set max_w
$c}
974 $tooltip_t conf
-width $max_w -height $max_h
976 set req_w
[winfo reqwidth
$tooltip_t]
977 set req_h
[winfo reqheight
$tooltip_t]
978 set pos_x
[expr {[winfo pointerx .
] + 5}]
979 set pos_y
[expr {[winfo pointery .
] + 10}]
981 set g
"${req_w}x${req_h}"
982 if {$pos_x >= 0} {append g
+}
984 if {$pos_y >= 0} {append g
+}
987 wm geometry
$tooltip_wm $g
991 method _hide_tooltip
{} {
992 if {$tooltip_wm ne
{}} {
995 set tooltip_commit
{}
997 if {$tooltip_timer ne
{}} {
998 after cancel
$tooltip_timer
1003 method _resize
{new_height
} {
1004 set diff
[expr {$new_height - $old_height}]
1005 if {$diff == 0} return
1007 set my
[expr {[winfo height
$w.file_pane
] - 25}]
1008 set o
[$w.file_pane sash coord
0]
1009 set ox
[lindex $o 0]
1010 set oy
[expr {[lindex $o 1] + $diff}]
1011 if {$oy < 0} {set oy
0}
1012 if {$oy > $my} {set oy
$my}
1013 $w.file_pane sash
place 0 $ox $oy
1015 set old_height
$new_height