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:"] \
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
245 set status
[::status_bar::new $w.status
]
247 menu $w.ctxm
-tearoff 0
248 $w.ctxm add command
\
249 -label [mc
"Copy Commit"] \
250 -command [cb _copycommit
]
252 foreach i
$w_columns {
253 for {set g
0} {$g < [llength $group_colors]} {incr g
} {
254 $i tag conf color
$g -background [lindex $group_colors $g]
257 $i conf
-cursor $cursor_ptr
258 $i conf
-yscrollcommand [list many2scrollbar
\
259 $w_columns yview
$w.file_pane.out.sby
]
262 [cb _click $i @%x,%y]
265 bind $i <Any-Motion
> [cb _show_tooltip
$i @%x
,%y
]
266 bind $i <Any-Enter
> [cb _hide_tooltip
]
267 bind $i <Any-Leave
> [cb _hide_tooltip
]
273 tk_popup $w.ctxm %X %Y
275 bind $i <Shift-Tab
> "[list focus $w_cviewer];break"
276 bind $i <Tab
> "[list focus $w_cviewer];break"
279 foreach i
[concat $w_columns $w_cviewer] {
280 bind $i <Key-Up
> {catch {%W yview scroll
-1 units
};break}
281 bind $i <Key-Down
> {catch {%W yview scroll
1 units
};break}
282 bind $i <Key-Left
> {catch {%W xview scroll
-1 units
};break}
283 bind $i <Key-Right
> {catch {%W xview scroll
1 units
};break}
284 bind $i <Key-k
> {catch {%W yview scroll
-1 units
};break}
285 bind $i <Key-j
> {catch {%W yview scroll
1 units
};break}
286 bind $i <Key-h
> {catch {%W xview scroll
-1 units
};break}
287 bind $i <Key-l
> {catch {%W xview scroll
1 units
};break}
288 bind $i <Control-Key-b
> {catch {%W yview scroll
-1 pages
};break}
289 bind $i <Control-Key-f
> {catch {%W yview scroll
1 pages
};break}
292 bind $w_cviewer <Shift-Tab
> "[list focus $w_file];break"
293 bind $w_cviewer <Tab
> "[list focus $w_file];break"
294 bind $w_cviewer <Button-1
> [list focus $w_cviewer]
295 bind $w_file <Visibility
> [list focus $w_file]
297 grid configure
$w.header
-sticky ew
298 grid configure
$w.file_pane
-sticky nsew
299 grid configure
$w.status
-sticky ew
300 grid columnconfigure
$top 0 -weight 1
301 grid rowconfigure
$top 0 -weight 0
302 grid rowconfigure
$top 1 -weight 1
303 grid rowconfigure
$top 2 -weight 0
305 set req_w
[winfo reqwidth
$top]
306 set req_h
[winfo reqheight
$top]
307 set scr_h
[expr {[winfo screenheight
$top] - 100}]
308 if {$req_w < 600} {set req_w
600}
309 if {$req_h < $scr_h} {set req_h
$scr_h}
310 set g
"${req_w}x${req_h}"
314 set old_height
[winfo height
$w.file_pane
]
315 $w.file_pane sash
place 0 \
316 [lindex [$w.file_pane sash coord
0] 0] \
317 [expr {int
($old_height * 0.70)}]
318 bind $w.file_pane
<Configure
> \
319 "if {{$w.file_pane} eq {%W}} {[cb _resize %h]}"
324 method _load
{jump
} {
325 variable group_colors
329 if {$total_lines != 0 ||
$current_fd ne
{}} {
330 if {$current_fd ne
{}} {
331 catch {close $current_fd}
335 foreach i
$w_columns {
336 $i conf
-state normal
338 foreach g
[$i tag names
] {
339 if {[regexp {^g
[0-9a-f
]{40}$} $g]} {
343 $i conf
-state disabled
346 $w_cviewer conf
-state normal
347 $w_cviewer delete
0.0 end
348 $w_cviewer conf
-state disabled
350 set highlight_line
-1
351 set highlight_column
{}
352 set highlight_commit
{}
356 if {$history eq
{}} {
357 $w_back conf
-state disabled
359 $w_back conf
-state normal
362 # Index 0 is always empty. There is never line 0 as
363 # we use only 1 based lines, as that matches both with
364 # git-blame output and with Tk's text widget.
366 set amov_data
[list [list]]
367 set asim_data
[list [list]]
369 $status show
[mc
"Reading %s..." "$commit:[escape_path $path]"]
370 $w_path conf
-text [escape_path
$path]
372 set fd
[open $path r
]
373 fconfigure $fd -eofchar {}
375 set fd
[git_read cat-file blob
"$commit:$path"]
377 fconfigure $fd -blocking 0 -translation lf
-encoding binary
378 fileevent $fd readable
[cb _read_file
$fd $jump]
382 method _history_menu
{} {
384 if {[winfo exists
$m]} {
390 for {set i
[expr {[llength $history] - 1}]
391 } {$i >= 0} {incr i
-1} {
392 set e
[lindex $history $i]
396 if {[regexp {^
[0-9a-f
]{40}$} $c]} {
397 set t
[string range
$c 0 8]...
398 } elseif
{$c eq
{}} {
399 set t
{Working Directory
}
403 if {![catch {set summary
$header($c,summary
)}]} {
405 if {[string length
$t] > 70} {
406 set t
[string range
$t 0 66]...
410 $m add command
-label $t -command [cb _goback
$i]
412 set X
[winfo rootx
$w_back]
413 set Y
[expr {[winfo rooty
$w_back] + [winfo height
$w_back]}]
418 set dat
[lindex $history $i]
419 set history [lrange $history 0 [expr {$i - 1}]]
420 set commit
[lindex $dat 0]
421 set path
[lindex $dat 1]
422 _load
$this [lrange $dat 2 5]
425 method _read_file
{fd jump
} {
426 if {$fd ne
$current_fd} {
431 foreach i
$w_columns {$i conf
-state normal
}
432 while {[gets $fd line
] >= 0} {
433 regsub "\r\$" $line {} line
438 if {$total_lines > 1} {
439 foreach i
$w_columns {$i insert end
"\n"}
442 $w_line insert end
"$total_lines" linenumber
443 $w_file insert end
"$line"
446 set ln_wc
[expr {[string length
$total_lines] + 2}]
447 if {[$w_line cget
-width] < $ln_wc} {
448 $w_line conf
-width $ln_wc
451 foreach i
$w_columns {$i conf
-state disabled
}
456 # If we don't force Tk to update the widgets *right now*
457 # none of our jump commands will cause a change in the UI.
461 if {[llength $jump] == 1} {
462 set highlight_line
[lindex $jump 0]
463 $w_file see
"$highlight_line.0"
464 } elseif
{[llength $jump] == 4} {
465 set highlight_column
[lindex $jump 0]
466 set highlight_line
[lindex $jump 1]
467 $w_file xview moveto
[lindex $jump 2]
468 $w_file yview moveto
[lindex $jump 3]
471 _exec_blame
$this $w_asim @asim_data
\
473 [mc
"Loading copy/move tracking annotations..."]
475 } ifdeleted
{ catch {close $fd} }
477 method _exec_blame
{cur_w cur_d
options cur_s
} {
478 lappend options --incremental
480 lappend options --contents $path
482 lappend options $commit
484 lappend options -- $path
485 set fd
[eval git_read
--nice blame
$options]
486 fconfigure $fd -blocking 0 -translation lf
-encoding binary
487 fileevent $fd readable
[cb _read_blame
$fd $cur_w $cur_d]
493 [mc
"lines annotated"]
496 method _read_blame
{fd cur_w cur_d
} {
497 upvar #0 $cur_d line_data
498 variable group_colors
499 variable original_options
501 if {$fd ne
$current_fd} {
506 $cur_w conf
-state normal
507 while {[gets $fd line
] >= 0} {
508 if {[regexp {^
([a-z0-9
]{40}) (\d
+) (\d
+) (\d
+)$} $line line
\
509 cmit original_line final_line line_count
]} {
511 set r_orig_line
$original_line
512 set r_final_line
$final_line
513 set r_line_count
$line_count
514 } elseif
{[string match
{filename *} $line]} {
515 set file [string range
$line 9 end
]
517 set lno
$r_final_line
521 if {[regexp {^
0{40}$} $cmit]} {
523 set commit_type curr_commit
524 } elseif
{$cmit eq
$commit} {
526 set commit_type curr_commit
528 set commit_type prior_commit
529 set commit_abbr
[string range
$cmit 0 3]
534 catch {set a_name
$header($cmit,author
)}
535 while {$a_name ne
{}} {
536 if {$author_abbr ne
{}
537 && [string index
$a_name 0] eq
{'
}} {
538 regsub {^'
[^'
]+'
\s
+} $a_name {} a_name
540 if {![regexp {^
([[:upper
:]])} $a_name _a
]} break
541 append author_abbr
$_a
544 {^
[[:upper
:]][^
\s
]*\s
+} \
545 $a_name {} a_name
]} break
547 if {$author_abbr eq
{}} {
550 set author_abbr
[string range
$author_abbr 0 3]
557 && $cmit eq
[lindex $line_data [expr {$first_lno - 1}] 0]
558 && $file eq
[lindex $line_data [expr {$first_lno - 1}] 1]
564 if {$first_lno < $lno} {
565 foreach g
[$w_file tag names
$first_lno.0] {
566 if {[regexp {^color
[0-9]+$} $g]} {
572 set i
[lsort [concat \
573 [$w_file tag names
"[expr {$first_lno - 1}].0"] \
574 [$w_file tag names
"[expr {$lno + $n}].0"] \
576 for {set g
0} {$g < [llength $group_colors]} {incr g
} {
577 if {[lsearch -sorted -exact $i color
$g] == -1} {
588 set lno_e
"$lno.0 lineend + 1c"
589 if {[lindex $line_data $lno] ne
{}} {
590 set g
[lindex $line_data $lno 0]
591 foreach i
$w_columns {
592 $i tag remove g
$g $lno.0 $lno_e
595 lset line_data
$lno [list $cmit $file $oln]
597 $cur_w delete
$lno.0 "$lno.0 lineend"
598 if {$lno == $first_lno} {
599 $cur_w insert
$lno.0 $commit_abbr $commit_type
600 } elseif
{$lno == [expr {$first_lno + 1}]} {
601 $cur_w insert
$lno.0 $author_abbr author_abbr
603 $cur_w insert
$lno.0 { |
}
606 foreach i
$w_columns {
607 if {$cur_w eq
$w_amov} {
609 {$g < [llength $group_colors]} \
611 $i tag remove color
$g $lno.0 $lno_e
613 $i tag add
$color $lno.0 $lno_e
615 $i tag add g
$cmit $lno.0 $lno_e
618 if {$highlight_column eq
$cur_w} {
619 if {$highlight_line == -1
620 && [lindex [$w_file yview
] 0] == 0} {
622 set highlight_line
$lno
624 if {$highlight_line == $lno} {
625 _showcommit
$this $cur_w $lno
636 $cmit eq
[lindex $line_data $lno 0]
637 && $file eq
[lindex $line_data $lno 1]
639 $cur_w delete
$lno.0 "$lno.0 lineend"
641 if {$lno == $first_lno} {
642 $cur_w insert
$lno.0 $commit_abbr $commit_type
643 } elseif
{$lno == [expr {$first_lno + 1}]} {
644 $cur_w insert
$lno.0 $author_abbr author_abbr
646 $cur_w insert
$lno.0 { |
}
649 if {$cur_w eq
$w_amov} {
650 foreach i
$w_columns {
652 {$g < [llength $group_colors]} \
654 $i tag remove color
$g $lno.0 $lno_e
656 $i tag add
$color $lno.0 $lno_e
663 } elseif
{[regexp {^
([a-z-
]+) (.
*)$} $line line key data
]} {
664 set header
($r_commit,$key) $data
667 $cur_w conf
-state disabled
671 if {$cur_w eq
$w_asim} {
672 _exec_blame
$this $w_amov @amov_data
\
674 [mc
"Loading original location annotations..."]
677 $status stop
[mc
"Annotation complete."]
680 $status update $blame_lines $total_lines
682 } ifdeleted
{ catch {close $fd} }
684 method _click
{cur_w pos
} {
685 set lno
[lindex [split [$cur_w index
$pos] .
] 0]
686 _showcommit
$this $cur_w $lno
689 method _load_commit
{cur_w cur_d pos
} {
690 upvar #0 $cur_d line_data
691 set lno
[lindex [split [$cur_w index
$pos] .
] 0]
692 set dat
[lindex $line_data $lno]
694 lappend history [list \
698 [lindex [$w_file xview
] 0] \
699 [lindex [$w_file yview
] 0] \
701 set commit
[lindex $dat 0]
702 set path
[lindex $dat 1]
703 _load
$this [list [lindex $dat 2]]
707 method _showcommit
{cur_w lno
} {
709 variable active_color
711 if {$highlight_commit ne
{}} {
712 foreach i
$w_columns {
713 $i tag conf g
$highlight_commit -background {}
714 $i tag
lower g
$highlight_commit
718 if {$cur_w eq
$w_asim} {
719 set dat
[lindex $asim_data $lno]
720 set highlight_column
$w_asim
722 set dat
[lindex $amov_data $lno]
723 set highlight_column
$w_amov
726 $w_cviewer conf
-state normal
727 $w_cviewer delete
0.0 end
731 $w_cviewer insert end
[mc
"Loading annotation..."] still_loading
733 set cmit
[lindex $dat 0]
734 set file [lindex $dat 1]
736 foreach i
$w_columns {
737 $i tag conf g
$cmit -background $active_color
744 catch {set author_name
$header($cmit,author
)}
745 catch {set author_email
$header($cmit,author-mail
)}
746 catch {set author_time
[format_date
$header($cmit,author-time
)]}
748 set committer_name
{}
749 set committer_email
{}
750 set committer_time
{}
751 catch {set committer_name
$header($cmit,committer
)}
752 catch {set committer_email
$header($cmit,committer-mail
)}
753 catch {set committer_time
[format_date
$header($cmit,committer-time
)]}
755 if {[catch {set msg
$header($cmit,message)}]} {
758 set fd
[git_read cat-file commit
$cmit]
759 fconfigure $fd -encoding binary -translation lf
760 if {[catch {set enc
$repo_config(i18n.commitencoding
)}]} {
763 while {[gets $fd line
] > 0} {
764 if {[string match
{encoding *} $line]} {
765 set enc
[string tolower
[string range
$line 9 end
]]
771 set enc
[tcl_encoding
$enc]
773 set msg
[encoding convertfrom
$enc $msg]
774 set author_name
[encoding convertfrom
$enc $author_name]
775 set committer_name
[encoding convertfrom
$enc $committer_name]
776 set header
($cmit,author
) $author_name
777 set header
($cmit,committer
) $committer_name
778 set header
($cmit,summary
) \
779 [encoding convertfrom
$enc $header($cmit,summary
)]
781 set msg
[string trim
$msg]
783 set header
($cmit,message) $msg
786 $w_cviewer insert end
"commit $cmit\n" header_key
787 $w_cviewer insert end
[strcat
[mc
"Author:"] "\t"] header_key
788 $w_cviewer insert end
"$author_name $author_email" header_val
789 $w_cviewer insert end
" $author_time\n" header_val
791 $w_cviewer insert end
[strcat
[mc
"Committer:"] "\t"] header_key
792 $w_cviewer insert end
"$committer_name $committer_email" header_val
793 $w_cviewer insert end
" $committer_time\n" header_val
795 if {$file ne
$path} {
796 $w_cviewer insert end
[strcat
[mc
"Original File:"] "\t"] header_key
797 $w_cviewer insert end
"[escape_path $file]\n" header_val
800 $w_cviewer insert end
"\n$msg"
802 $w_cviewer conf
-state disabled
804 set highlight_line
$lno
805 set highlight_commit
$cmit
807 if {[lsearch -exact $tooltip_commit $highlight_commit] != -1} {
812 method _copycommit
{} {
813 set pos
@$::cursorX,$::cursorY
814 set lno
[lindex [split [$::cursorW index
$pos] .
] 0]
815 set dat
[lindex $amov_data $lno]
825 method _show_tooltip
{cur_w pos
} {
826 if {$tooltip_wm ne
{}} {
827 _open_tooltip
$this $cur_w
828 } elseif
{$tooltip_timer eq
{}} {
829 set tooltip_timer
[after 1000 [cb _open_tooltip
$cur_w]]
833 method _open_tooltip
{cur_w
} {
835 set pos_x
[winfo pointerx
$cur_w]
836 set pos_y
[winfo pointery
$cur_w]
837 if {[winfo containing
$pos_x $pos_y] ne
$cur_w} {
842 if {$tooltip_wm ne
"$cur_w.tooltip"} {
845 set tooltip_wm
[toplevel $cur_w.tooltip
-borderwidth 1]
846 wm overrideredirect
$tooltip_wm 1
847 wm transient
$tooltip_wm [winfo toplevel $cur_w]
848 set tooltip_t
$tooltip_wm.
label
851 -highlightthickness 0 \
855 -background lightyellow
\
857 $tooltip_t tag conf section_header
-font font_uibold
860 $tooltip_t conf
-state normal
861 $tooltip_t delete
0.0 end
864 set pos
@[join [list \
865 [expr {$pos_x - [winfo rootx
$cur_w]}] \
866 [expr {$pos_y - [winfo rooty
$cur_w]}]] ,]
867 set lno
[lindex [split [$cur_w index
$pos] .
] 0]
868 if {$cur_w eq
$w_amov} {
869 set dat
[lindex $amov_data $lno]
872 set dat
[lindex $asim_data $lno]
873 set org
[lindex $amov_data $lno]
881 set cmit
[lindex $dat 0]
882 set tooltip_commit
[list $cmit]
887 catch {set author_name
$header($cmit,author
)}
888 catch {set summary
$header($cmit,summary
)}
889 catch {set author_time
[format_date
$header($cmit,author-time
)]}
891 $tooltip_t insert end
"commit $cmit\n"
892 $tooltip_t insert end
"$author_name $author_time\n"
893 $tooltip_t insert end
"$summary"
895 if {$org ne
{} && [lindex $org 0] ne
$cmit} {
896 set save
[$tooltip_t get
0.0 end
]
897 $tooltip_t delete
0.0 end
899 set cmit
[lindex $org 0]
900 set file [lindex $org 1]
901 lappend tooltip_commit
$cmit
906 catch {set author_name
$header($cmit,author
)}
907 catch {set summary
$header($cmit,summary
)}
908 catch {set author_time
[format_date
$header($cmit,author-time
)]}
910 $tooltip_t insert end
[strcat
[mc
"Originally By:"] "\n"] section_header
911 $tooltip_t insert end
"commit $cmit\n"
912 $tooltip_t insert end
"$author_name $author_time\n"
913 $tooltip_t insert end
"$summary\n"
915 if {$file ne
$path} {
916 $tooltip_t insert end
[strcat
[mc
"In File:"] " "] section_header
917 $tooltip_t insert end
"$file\n"
920 $tooltip_t insert end
"\n"
921 $tooltip_t insert end
[strcat
[mc
"Copied Or Moved Here By:"] "\n"] section_header
922 $tooltip_t insert end
$save
925 $tooltip_t conf
-state disabled
926 _position_tooltip
$this
929 method _position_tooltip
{} {
930 set max_h
[lindex [split [$tooltip_t index end
] .
] 0]
932 for {set i
1} {$i <= $max_h} {incr i
} {
933 set c
[lindex [split [$tooltip_t index
"$i.0 lineend"] .
] 1]
934 if {$c > $max_w} {set max_w
$c}
936 $tooltip_t conf
-width $max_w -height $max_h
938 set req_w
[winfo reqwidth
$tooltip_t]
939 set req_h
[winfo reqheight
$tooltip_t]
940 set pos_x
[expr {[winfo pointerx .
] + 5}]
941 set pos_y
[expr {[winfo pointery .
] + 10}]
943 set g
"${req_w}x${req_h}"
944 if {$pos_x >= 0} {append g
+}
946 if {$pos_y >= 0} {append g
+}
949 wm geometry
$tooltip_wm $g
953 method _hide_tooltip
{} {
954 if {$tooltip_wm ne
{}} {
957 set tooltip_commit
{}
959 if {$tooltip_timer ne
{}} {
960 after cancel
$tooltip_timer
965 method _resize
{new_height
} {
966 set diff
[expr {$new_height - $old_height}]
967 if {$diff == 0} return
969 set my
[expr {[winfo height
$w.file_pane
] - 25}]
970 set o
[$w.file_pane sash coord
0]
972 set oy
[expr {[lindex $o 1] + $diff}]
973 if {$oy < 0} {set oy
0}
974 if {$oy > $my} {set oy
$my}
975 $w.file_pane sash
place 0 $ox $oy
977 set old_height
$new_height