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
]
260 foreach i
$w_columns {
261 for {set g
0} {$g < [llength $group_colors]} {incr g
} {
262 $i tag conf color
$g -background [lindex $group_colors $g]
265 $i conf
-cursor $cursor_ptr
266 $i conf
-yscrollcommand [list many2scrollbar
\
267 $w_columns yview
$w.file_pane.out.sby
]
270 [cb _click $i @%x,%y]
273 bind $i <Any-Motion
> [cb _show_tooltip
$i @%x
,%y
]
274 bind $i <Any-Enter
> [cb _hide_tooltip
]
275 bind $i <Any-Leave
> [cb _hide_tooltip
]
281 tk_popup $w.ctxm %X %Y
283 bind $i <Shift-Tab
> "[list focus $w_cviewer];break"
284 bind $i <Tab
> "[list focus $w_cviewer];break"
287 foreach i
[concat $w_columns $w_cviewer] {
288 bind $i <Key-Up
> {catch {%W yview scroll
-1 units
};break}
289 bind $i <Key-Down
> {catch {%W yview scroll
1 units
};break}
290 bind $i <Key-Left
> {catch {%W xview scroll
-1 units
};break}
291 bind $i <Key-Right
> {catch {%W xview scroll
1 units
};break}
292 bind $i <Key-k
> {catch {%W yview scroll
-1 units
};break}
293 bind $i <Key-j
> {catch {%W yview scroll
1 units
};break}
294 bind $i <Key-h
> {catch {%W xview scroll
-1 units
};break}
295 bind $i <Key-l
> {catch {%W xview scroll
1 units
};break}
296 bind $i <Control-Key-b
> {catch {%W yview scroll
-1 pages
};break}
297 bind $i <Control-Key-f
> {catch {%W yview scroll
1 pages
};break}
300 bind $w_cviewer <Shift-Tab
> "[list focus $w_file];break"
301 bind $w_cviewer <Tab
> "[list focus $w_file];break"
302 bind $w_cviewer <Button-1
> [list focus $w_cviewer]
303 bind $w_file <Visibility
> [list focus $w_file]
305 grid configure
$w.header
-sticky ew
306 grid configure
$w.file_pane
-sticky nsew
307 grid configure
$w.status
-sticky ew
308 grid columnconfigure
$top 0 -weight 1
309 grid rowconfigure
$top 0 -weight 0
310 grid rowconfigure
$top 1 -weight 1
311 grid rowconfigure
$top 2 -weight 0
313 set req_w
[winfo reqwidth
$top]
314 set req_h
[winfo reqheight
$top]
315 set scr_h
[expr {[winfo screenheight
$top] - 100}]
316 if {$req_w < 600} {set req_w
600}
317 if {$req_h < $scr_h} {set req_h
$scr_h}
318 set g
"${req_w}x${req_h}"
322 set old_height
[winfo height
$w.file_pane
]
323 $w.file_pane sash
place 0 \
324 [lindex [$w.file_pane sash coord
0] 0] \
325 [expr {int
($old_height * 0.70)}]
326 bind $w.file_pane
<Configure
> \
327 "if {{$w.file_pane} eq {%W}} {[cb _resize %h]}"
329 wm protocol
$top WM_DELETE_WINDOW
"destroy $top"
330 bind $top <Destroy
> [cb _kill
]
336 if {$current_fd ne
{}} {
337 kill_file_process
$current_fd
338 catch {close $current_fd}
343 method _load
{jump
} {
344 variable group_colors
348 if {$total_lines != 0 ||
$current_fd ne
{}} {
351 foreach i
$w_columns {
352 $i conf
-state normal
354 foreach g
[$i tag names
] {
355 if {[regexp {^g
[0-9a-f
]{40}$} $g]} {
359 $i conf
-state disabled
362 $w_cviewer conf
-state normal
363 $w_cviewer delete
0.0 end
364 $w_cviewer conf
-state disabled
366 set highlight_line
-1
367 set highlight_column
{}
368 set highlight_commit
{}
372 if {$history eq
{}} {
373 $w_back conf
-state disabled
375 $w_back conf
-state normal
378 # Index 0 is always empty. There is never line 0 as
379 # we use only 1 based lines, as that matches both with
380 # git-blame output and with Tk's text widget.
382 set amov_data
[list [list]]
383 set asim_data
[list [list]]
385 $status show
[mc
"Reading %s..." "$commit:[escape_path $path]"]
386 $w_path conf
-text [escape_path
$path]
388 set fd
[open $path r
]
389 fconfigure $fd -eofchar {}
391 set fd
[git_read cat-file blob
"$commit:$path"]
393 fconfigure $fd -blocking 0 -translation lf
-encoding binary
394 fileevent $fd readable
[cb _read_file
$fd $jump]
398 method _history_menu
{} {
400 if {[winfo exists
$m]} {
406 for {set i
[expr {[llength $history] - 1}]
407 } {$i >= 0} {incr i
-1} {
408 set e
[lindex $history $i]
412 if {[regexp {^
[0-9a-f
]{40}$} $c]} {
413 set t
[string range
$c 0 8]...
414 } elseif
{$c eq
{}} {
415 set t
{Working Directory
}
419 if {![catch {set summary
$header($c,summary
)}]} {
421 if {[string length
$t] > 70} {
422 set t
[string range
$t 0 66]...
426 $m add command
-label $t -command [cb _goback
$i]
428 set X
[winfo rootx
$w_back]
429 set Y
[expr {[winfo rooty
$w_back] + [winfo height
$w_back]}]
434 set dat
[lindex $history $i]
435 set history [lrange $history 0 [expr {$i - 1}]]
436 set commit
[lindex $dat 0]
437 set path
[lindex $dat 1]
438 _load
$this [lrange $dat 2 5]
441 method _read_file
{fd jump
} {
442 if {$fd ne
$current_fd} {
447 foreach i
$w_columns {$i conf
-state normal
}
448 while {[gets $fd line
] >= 0} {
449 regsub "\r\$" $line {} line
454 if {$total_lines > 1} {
455 foreach i
$w_columns {$i insert end
"\n"}
458 $w_line insert end
"$total_lines" linenumber
459 $w_file insert end
"$line"
462 set ln_wc
[expr {[string length
$total_lines] + 2}]
463 if {[$w_line cget
-width] < $ln_wc} {
464 $w_line conf
-width $ln_wc
467 foreach i
$w_columns {$i conf
-state disabled
}
472 # If we don't force Tk to update the widgets *right now*
473 # none of our jump commands will cause a change in the UI.
477 if {[llength $jump] == 1} {
478 set highlight_line
[lindex $jump 0]
479 $w_file see
"$highlight_line.0"
480 } elseif
{[llength $jump] == 4} {
481 set highlight_column
[lindex $jump 0]
482 set highlight_line
[lindex $jump 1]
483 $w_file xview moveto
[lindex $jump 2]
484 $w_file yview moveto
[lindex $jump 3]
487 _exec_blame
$this $w_asim @asim_data
\
489 [mc
"Loading copy/move tracking annotations..."]
491 } ifdeleted
{ catch {close $fd} }
493 method _exec_blame
{cur_w cur_d
options cur_s
} {
494 lappend options --incremental
496 lappend options --contents $path
498 lappend options $commit
500 lappend options -- $path
501 set fd
[eval git_read
--nice blame
$options]
502 fconfigure $fd -blocking 0 -translation lf
-encoding binary
503 fileevent $fd readable
[cb _read_blame
$fd $cur_w $cur_d]
509 [mc
"lines annotated"]
512 method _read_blame
{fd cur_w cur_d
} {
513 upvar #0 $cur_d line_data
514 variable group_colors
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 # Switches for original location detection
688 set threshold
[get_config gui.copyblamethreshold
]
689 set original_options
[list "-C$threshold"]
691 if {![is_config_true gui.fastcopyblame
]} {
692 # thorough copy search; insert before the threshold
693 set original_options
[linsert $original_options 0 -C]
695 if {[git-version
>= 1.5.3]} {
696 lappend original_options
-w ; # ignore indentation changes
699 _exec_blame
$this $w_amov @amov_data
\
701 [mc
"Loading original location annotations..."]
704 $status stop
[mc
"Annotation complete."]
707 $status update $blame_lines $total_lines
709 } ifdeleted
{ catch {close $fd} }
711 method _click
{cur_w pos
} {
712 set lno
[lindex [split [$cur_w index
$pos] .
] 0]
713 _showcommit
$this $cur_w $lno
716 method _load_commit
{cur_w cur_d pos
} {
717 upvar #0 $cur_d line_data
718 set lno
[lindex [split [$cur_w index
$pos] .
] 0]
719 set dat
[lindex $line_data $lno]
721 lappend history [list \
725 [lindex [$w_file xview
] 0] \
726 [lindex [$w_file yview
] 0] \
728 set commit
[lindex $dat 0]
729 set path
[lindex $dat 1]
730 _load
$this [list [lindex $dat 2]]
734 method _showcommit
{cur_w lno
} {
736 variable active_color
738 if {$highlight_commit ne
{}} {
739 foreach i
$w_columns {
740 $i tag conf g
$highlight_commit -background {}
741 $i tag
lower g
$highlight_commit
745 if {$cur_w eq
$w_asim} {
746 set dat
[lindex $asim_data $lno]
747 set highlight_column
$w_asim
749 set dat
[lindex $amov_data $lno]
750 set highlight_column
$w_amov
753 $w_cviewer conf
-state normal
754 $w_cviewer delete
0.0 end
758 $w_cviewer insert end
[mc
"Loading annotation..."] still_loading
760 set cmit
[lindex $dat 0]
761 set file [lindex $dat 1]
763 foreach i
$w_columns {
764 $i tag conf g
$cmit -background $active_color
771 catch {set author_name
$header($cmit,author
)}
772 catch {set author_email
$header($cmit,author-mail
)}
773 catch {set author_time
[format_date
$header($cmit,author-time
)]}
775 set committer_name
{}
776 set committer_email
{}
777 set committer_time
{}
778 catch {set committer_name
$header($cmit,committer
)}
779 catch {set committer_email
$header($cmit,committer-mail
)}
780 catch {set committer_time
[format_date
$header($cmit,committer-time
)]}
782 if {[catch {set msg
$header($cmit,message)}]} {
785 set fd
[git_read cat-file commit
$cmit]
786 fconfigure $fd -encoding binary -translation lf
787 if {[catch {set enc
$repo_config(i18n.commitencoding
)}]} {
790 while {[gets $fd line
] > 0} {
791 if {[string match
{encoding *} $line]} {
792 set enc
[string tolower
[string range
$line 9 end
]]
798 set enc
[tcl_encoding
$enc]
800 set msg
[encoding convertfrom
$enc $msg]
801 set author_name
[encoding convertfrom
$enc $author_name]
802 set committer_name
[encoding convertfrom
$enc $committer_name]
803 set header
($cmit,author
) $author_name
804 set header
($cmit,committer
) $committer_name
805 set header
($cmit,summary
) \
806 [encoding convertfrom
$enc $header($cmit,summary
)]
808 set msg
[string trim
$msg]
810 set header
($cmit,message) $msg
813 $w_cviewer insert end
"commit $cmit\n" header_key
814 $w_cviewer insert end
[strcat
[mc
"Author:"] "\t"] header_key
815 $w_cviewer insert end
"$author_name $author_email" header_val
816 $w_cviewer insert end
" $author_time\n" header_val
818 $w_cviewer insert end
[strcat
[mc
"Committer:"] "\t"] header_key
819 $w_cviewer insert end
"$committer_name $committer_email" header_val
820 $w_cviewer insert end
" $committer_time\n" header_val
822 if {$file ne
$path} {
823 $w_cviewer insert end
[strcat
[mc
"Original File:"] "\t"] header_key
824 $w_cviewer insert end
"[escape_path $file]\n" header_val
827 $w_cviewer insert end
"\n$msg"
829 $w_cviewer conf
-state disabled
831 set highlight_line
$lno
832 set highlight_commit
$cmit
834 if {[lsearch -exact $tooltip_commit $highlight_commit] != -1} {
839 method _copycommit
{} {
840 set pos
@$::cursorX,$::cursorY
841 set lno
[lindex [split [$::cursorW index
$pos] .
] 0]
842 set dat
[lindex $amov_data $lno]
852 method _show_tooltip
{cur_w pos
} {
853 if {$tooltip_wm ne
{}} {
854 _open_tooltip
$this $cur_w
855 } elseif
{$tooltip_timer eq
{}} {
856 set tooltip_timer
[after 1000 [cb _open_tooltip
$cur_w]]
860 method _open_tooltip
{cur_w
} {
862 set pos_x
[winfo pointerx
$cur_w]
863 set pos_y
[winfo pointery
$cur_w]
864 if {[winfo containing
$pos_x $pos_y] ne
$cur_w} {
869 if {$tooltip_wm ne
"$cur_w.tooltip"} {
872 set tooltip_wm
[toplevel $cur_w.tooltip
-borderwidth 1]
873 wm overrideredirect
$tooltip_wm 1
874 wm transient
$tooltip_wm [winfo toplevel $cur_w]
875 set tooltip_t
$tooltip_wm.
label
878 -highlightthickness 0 \
882 -background lightyellow
\
884 $tooltip_t tag conf section_header
-font font_uibold
887 $tooltip_t conf
-state normal
888 $tooltip_t delete
0.0 end
891 set pos
@[join [list \
892 [expr {$pos_x - [winfo rootx
$cur_w]}] \
893 [expr {$pos_y - [winfo rooty
$cur_w]}]] ,]
894 set lno
[lindex [split [$cur_w index
$pos] .
] 0]
895 if {$cur_w eq
$w_amov} {
896 set dat
[lindex $amov_data $lno]
899 set dat
[lindex $asim_data $lno]
900 set org
[lindex $amov_data $lno]
908 set cmit
[lindex $dat 0]
909 set tooltip_commit
[list $cmit]
914 catch {set author_name
$header($cmit,author
)}
915 catch {set summary
$header($cmit,summary
)}
916 catch {set author_time
[format_date
$header($cmit,author-time
)]}
918 $tooltip_t insert end
"commit $cmit\n"
919 $tooltip_t insert end
"$author_name $author_time\n"
920 $tooltip_t insert end
"$summary"
922 if {$org ne
{} && [lindex $org 0] ne
$cmit} {
923 set save
[$tooltip_t get
0.0 end
]
924 $tooltip_t delete
0.0 end
926 set cmit
[lindex $org 0]
927 set file [lindex $org 1]
928 lappend tooltip_commit
$cmit
933 catch {set author_name
$header($cmit,author
)}
934 catch {set summary
$header($cmit,summary
)}
935 catch {set author_time
[format_date
$header($cmit,author-time
)]}
937 $tooltip_t insert end
[strcat
[mc
"Originally By:"] "\n"] section_header
938 $tooltip_t insert end
"commit $cmit\n"
939 $tooltip_t insert end
"$author_name $author_time\n"
940 $tooltip_t insert end
"$summary\n"
942 if {$file ne
$path} {
943 $tooltip_t insert end
[strcat
[mc
"In File:"] " "] section_header
944 $tooltip_t insert end
"$file\n"
947 $tooltip_t insert end
"\n"
948 $tooltip_t insert end
[strcat
[mc
"Copied Or Moved Here By:"] "\n"] section_header
949 $tooltip_t insert end
$save
952 $tooltip_t conf
-state disabled
953 _position_tooltip
$this
956 method _position_tooltip
{} {
957 set max_h
[lindex [split [$tooltip_t index end
] .
] 0]
959 for {set i
1} {$i <= $max_h} {incr i
} {
960 set c
[lindex [split [$tooltip_t index
"$i.0 lineend"] .
] 1]
961 if {$c > $max_w} {set max_w
$c}
963 $tooltip_t conf
-width $max_w -height $max_h
965 set req_w
[winfo reqwidth
$tooltip_t]
966 set req_h
[winfo reqheight
$tooltip_t]
967 set pos_x
[expr {[winfo pointerx .
] + 5}]
968 set pos_y
[expr {[winfo pointery .
] + 10}]
970 set g
"${req_w}x${req_h}"
971 if {$pos_x >= 0} {append g
+}
973 if {$pos_y >= 0} {append g
+}
976 wm geometry
$tooltip_wm $g
980 method _hide_tooltip
{} {
981 if {$tooltip_wm ne
{}} {
984 set tooltip_commit
{}
986 if {$tooltip_timer ne
{}} {
987 after cancel
$tooltip_timer
992 method _resize
{new_height
} {
993 set diff
[expr {$new_height - $old_height}]
994 if {$diff == 0} return
996 set my
[expr {[winfo height
$w.file_pane
] - 25}]
997 set o
[$w.file_pane sash coord
0]
999 set oy
[expr {[lindex $o 1] + $diff}]
1000 if {$oy < 0} {set oy
0}
1001 if {$oy > $my} {set oy
$my}
1002 $w.file_pane sash
place 0 $ox $oy
1004 set old_height
$new_height