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 # 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 "[appname] ([reponame]): File Viewer"
72 frame $w.header
-background gold
73 label $w.header.commit_l
\
78 set w_back
$w.header.commit_b
80 -image ::blame::img_back_arrow \
85 -activebackground gold
86 bind $w_back <Button-1
> "
87 if {\[$w_back cget -state\] eq {normal}} {
91 label $w.header.commit
\
92 -textvariable @commit
\
96 label $w.header.path_l
\
101 set w_path
$w.header.path
106 pack $w.header.commit_l
-side left
107 pack $w_back -side left
108 pack $w.header.commit
-side left
109 pack $w_path -fill x
-side right
110 pack $w.header.path_l
-side right
112 panedwindow $w.file_pane
-orient vertical
113 frame $w.file_pane.out
114 frame $w.file_pane.cm
115 $w.file_pane add
$w.file_pane.out
\
120 $w.file_pane add
$w.file_pane.cm
\
126 set w_line
$w.file_pane.out.linenumber_t
129 -highlightthickness 0 \
131 -background white
-borderwidth 0 \
137 $w_line tag conf linenumber
-justify right
-rmargin 5
139 set w_amov
$w.file_pane.out.amove_t
142 -highlightthickness 0 \
144 -background white
-borderwidth 0 \
150 $w_amov tag conf author_abbr
-justify right
-rmargin 5
151 $w_amov tag conf curr_commit
152 $w_amov tag conf prior_commit
-foreground blue
-underline 1
153 $w_amov tag
bind prior_commit
\
155 "[cb _load_commit $w_amov @amov_data @%x,%y];break"
157 set w_asim
$w.file_pane.out.asimple_t
160 -highlightthickness 0 \
162 -background white
-borderwidth 0 \
168 $w_asim tag conf author_abbr
-justify right
169 $w_asim tag conf curr_commit
170 $w_asim tag conf prior_commit
-foreground blue
-underline 1
171 $w_asim tag
bind prior_commit
\
173 "[cb _load_commit $w_asim @asim_data @%x,%y];break"
175 set w_file
$w.file_pane.out.file_t
178 -highlightthickness 0 \
180 -background white
-borderwidth 0 \
185 -xscrollcommand [list $w.file_pane.out.sbx
set] \
188 set w_columns
[list $w_amov $w_asim $w_line $w_file]
190 scrollbar $w.file_pane.out.sbx
\
192 -command [list $w_file xview
]
193 scrollbar $w.file_pane.out.sby
\
195 -command [list scrollbar2many
$w_columns yview
]
196 eval grid $w_columns $w.file_pane.out.sby
-sticky nsew
198 $w.file_pane.out.sbx
\
199 -column [expr {[llength $w_columns] - 1}] \
201 grid columnconfigure
\
203 [expr {[llength $w_columns] - 1}] \
205 grid rowconfigure
$w.file_pane.out
0 -weight 1
207 set w_cviewer
$w.file_pane.cm.t
209 -background white
-borderwidth 0 \
214 -xscrollcommand [list $w.file_pane.cm.sbx
set] \
215 -yscrollcommand [list $w.file_pane.cm.sby
set] \
217 $w_cviewer tag conf still_loading
\
218 -font font_uiitalic
\
220 $w_cviewer tag conf header_key
\
222 -background $active_color \
224 $w_cviewer tag conf header_val
\
225 -background $active_color \
227 $w_cviewer tag
raise sel
228 scrollbar $w.file_pane.cm.sbx
\
230 -command [list $w_cviewer xview
]
231 scrollbar $w.file_pane.cm.sby
\
233 -command [list $w_cviewer yview
]
234 pack $w.file_pane.cm.sby
-side right
-fill y
235 pack $w.file_pane.cm.sbx
-side bottom
-fill x
236 pack $w_cviewer -expand 1 -fill both
242 -textvariable @status
\
245 pack $w.status.l
-side left
247 menu $w.ctxm
-tearoff 0
248 $w.ctxm add command
\
249 -label "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
277 foreach i
[concat $w_columns $w_cviewer] {
278 bind $i <Key-Up
> {catch {%W yview scroll
-1 units
};break}
279 bind $i <Key-Down
> {catch {%W yview scroll
1 units
};break}
280 bind $i <Key-Left
> {catch {%W xview scroll
-1 units
};break}
281 bind $i <Key-Right
> {catch {%W xview scroll
1 units
};break}
282 bind $i <Key-k
> {catch {%W yview scroll
-1 units
};break}
283 bind $i <Key-j
> {catch {%W yview scroll
1 units
};break}
284 bind $i <Key-h
> {catch {%W xview scroll
-1 units
};break}
285 bind $i <Key-l
> {catch {%W xview scroll
1 units
};break}
286 bind $i <Control-Key-b
> {catch {%W yview scroll
-1 pages
};break}
287 bind $i <Control-Key-f
> {catch {%W yview scroll
1 pages
};break}
290 bind $w_cviewer <Button-1
> [list focus $w_cviewer]
291 bind $top <Visibility
> [list focus $top]
293 grid configure
$w.header
-sticky ew
294 grid configure
$w.file_pane
-sticky nsew
295 grid configure
$w.status
-sticky ew
296 grid columnconfigure
$top 0 -weight 1
297 grid rowconfigure
$top 0 -weight 0
298 grid rowconfigure
$top 1 -weight 1
299 grid rowconfigure
$top 2 -weight 0
301 set req_w
[winfo reqwidth
$top]
302 set req_h
[winfo reqheight
$top]
303 if {$req_w < 600} {set req_w
600}
304 if {$req_h < 400} {set req_h
400}
305 set g
"${req_w}x${req_h}"
309 set old_height
[winfo height
$w.file_pane
]
310 $w.file_pane sash
place 0 \
311 [lindex [$w.file_pane sash coord
0] 0] \
312 [expr {int
($old_height * 0.70)}]
313 bind $w.file_pane
<Configure
> \
314 "if {{$w.file_pane} eq {%W}} {[cb _resize %h]}"
319 method _load
{jump
} {
320 variable group_colors
324 if {$total_lines != 0 ||
$current_fd ne
{}} {
325 if {$current_fd ne
{}} {
326 catch {close $current_fd}
330 foreach i
$w_columns {
331 $i conf
-state normal
333 foreach g
[$i tag names
] {
334 if {[regexp {^g
[0-9a-f
]{40}$} $g]} {
338 $i conf
-state disabled
341 $w_cviewer conf
-state normal
342 $w_cviewer delete
0.0 end
343 $w_cviewer conf
-state disabled
345 set highlight_line
-1
346 set highlight_column
{}
347 set highlight_commit
{}
351 if {[winfo exists
$w.status.c
]} {
352 $w.status.c coords bar
0 0 0 20
356 -height [expr {int
([winfo reqheight
$w.status.l
] * 0.6)}] \
360 $w.status.c create rectangle
0 0 0 20 -tags bar
-fill navy
361 pack $w.status.c
-side right
364 if {$history eq
{}} {
365 $w_back conf
-state disabled
367 $w_back conf
-state normal
370 # Index 0 is always empty. There is never line 0 as
371 # we use only 1 based lines, as that matches both with
372 # git-blame output and with Tk's text widget.
374 set amov_data
[list [list]]
375 set asim_data
[list [list]]
377 set status
"Loading $commit:[escape_path $path]..."
378 $w_path conf
-text [escape_path
$path]
380 set fd
[open $path r
]
382 set cmd
[list git cat-file blob
"$commit:$path"]
383 set fd
[open "| $cmd" r
]
385 fconfigure $fd -blocking 0 -translation lf
-encoding binary
386 fileevent $fd readable
[cb _read_file
$fd $jump]
390 method _history_menu
{} {
392 if {[winfo exists
$m]} {
398 for {set i
[expr {[llength $history] - 1}]
399 } {$i >= 0} {incr i
-1} {
400 set e
[lindex $history $i]
404 if {[regexp {^
[0-9a-f
]{40}$} $c]} {
405 set t
[string range
$c 0 8]...
406 } elseif
{$c eq
{}} {
407 set t
{Working Directory
}
411 if {![catch {set summary
$header($c,summary
)}]} {
413 if {[string length
$t] > 70} {
414 set t
[string range
$t 0 66]...
418 $m add command
-label $t -command [cb _goback
$i]
420 set X
[winfo rootx
$w_back]
421 set Y
[expr {[winfo rooty
$w_back] + [winfo height
$w_back]}]
426 set dat
[lindex $history $i]
427 set history [lrange $history 0 [expr {$i - 1}]]
428 set commit
[lindex $dat 0]
429 set path
[lindex $dat 1]
430 _load
$this [lrange $dat 2 5]
433 method _read_file
{fd jump
} {
434 if {$fd ne
$current_fd} {
439 foreach i
$w_columns {$i conf
-state normal
}
440 while {[gets $fd line
] >= 0} {
441 regsub "\r\$" $line {} line
446 if {$total_lines > 1} {
447 foreach i
$w_columns {$i insert end
"\n"}
450 $w_line insert end
"$total_lines" linenumber
451 $w_file insert end
"$line"
454 set ln_wc
[expr {[string length
$total_lines] + 2}]
455 if {[$w_line cget
-width] < $ln_wc} {
456 $w_line conf
-width $ln_wc
459 foreach i
$w_columns {$i conf
-state disabled
}
464 # If we don't force Tk to update the widgets *right now*
465 # none of our jump commands will cause a change in the UI.
469 if {[llength $jump] == 1} {
470 set highlight_line
[lindex $jump 0]
471 $w_file see
"$highlight_line.0"
472 } elseif
{[llength $jump] == 4} {
473 set highlight_column
[lindex $jump 0]
474 set highlight_line
[lindex $jump 1]
475 $w_file xview moveto
[lindex $jump 2]
476 $w_file yview moveto
[lindex $jump 3]
479 _exec_blame
$this $w_asim @asim_data
\
481 { copy
/move tracking
}
483 } ifdeleted
{ catch {close $fd} }
485 method _exec_blame
{cur_w cur_d
options cur_s
} {
486 set cmd
[list nice git blame
]
487 set cmd
[concat $cmd $options]
488 lappend cmd
--incremental
490 lappend cmd
--contents $path
495 set fd
[open "| $cmd" r
]
496 fconfigure $fd -blocking 0 -translation lf
-encoding binary
497 fileevent $fd readable
[cb _read_blame
$fd $cur_w $cur_d $cur_s]
503 method _read_blame
{fd cur_w cur_d cur_s
} {
504 upvar #0 $cur_d line_data
505 variable group_colors
507 if {$fd ne
$current_fd} {
512 $cur_w conf
-state normal
513 while {[gets $fd line
] >= 0} {
514 if {[regexp {^
([a-z0-9
]{40}) (\d
+) (\d
+) (\d
+)$} $line line
\
515 cmit original_line final_line line_count
]} {
517 set r_orig_line
$original_line
518 set r_final_line
$final_line
519 set r_line_count
$line_count
520 } elseif
{[string match
{filename *} $line]} {
521 set file [string range
$line 9 end
]
523 set lno
$r_final_line
527 if {[regexp {^
0{40}$} $cmit]} {
529 set commit_type curr_commit
530 } elseif
{$cmit eq
$commit} {
532 set commit_type curr_commit
534 set commit_type prior_commit
535 set commit_abbr
[string range
$cmit 0 3]
540 catch {set a_name
$header($cmit,author
)}
541 while {$a_name ne
{}} {
542 if {![regexp {^
([[:upper
:]])} $a_name _a
]} break
543 append author_abbr
$_a
546 {^
[[:upper
:]][^
\s
]*\s
+} \
547 $a_name {} a_name
]} break
549 if {$author_abbr eq
{}} {
552 set author_abbr
[string range
$author_abbr 0 3]
559 && $cmit eq
[lindex $line_data [expr {$first_lno - 1}] 0]
560 && $file eq
[lindex $line_data [expr {$first_lno - 1}] 1]
566 if {$first_lno < $lno} {
567 foreach g
[$w_file tag names
$first_lno.0] {
568 if {[regexp {^color
[0-9]+$} $g]} {
574 set i
[lsort [concat \
575 [$w_file tag names
"[expr {$first_lno - 1}].0"] \
576 [$w_file tag names
"[expr {$lno + $n}].0"] \
578 for {set g
0} {$g < [llength $group_colors]} {incr g
} {
579 if {[lsearch -sorted -exact $i color
$g] == -1} {
590 set lno_e
"$lno.0 lineend + 1c"
591 if {[lindex $line_data $lno] ne
{}} {
592 set g
[lindex $line_data $lno 0]
593 foreach i
$w_columns {
594 $i tag remove g
$g $lno.0 $lno_e
597 lset line_data
$lno [list $cmit $file $oln]
599 $cur_w delete
$lno.0 "$lno.0 lineend"
600 if {$lno == $first_lno} {
601 $cur_w insert
$lno.0 $commit_abbr $commit_type
602 } elseif
{$lno == [expr {$first_lno + 1}]} {
603 $cur_w insert
$lno.0 $author_abbr author_abbr
605 $cur_w insert
$lno.0 { |
}
608 foreach i
$w_columns {
609 if {$cur_w eq
$w_amov} {
611 {$g < [llength $group_colors]} \
613 $i tag remove color
$g $lno.0 $lno_e
615 $i tag add
$color $lno.0 $lno_e
617 $i tag add g
$cmit $lno.0 $lno_e
620 if {$highlight_column eq
$cur_w} {
621 if {$highlight_line == -1
622 && [lindex [$w_file yview
] 0] == 0} {
624 set highlight_line
$lno
626 if {$highlight_line == $lno} {
627 _showcommit
$this $cur_w $lno
638 $cmit eq
[lindex $line_data $lno 0]
639 && $file eq
[lindex $line_data $lno 1]
641 $cur_w delete
$lno.0 "$lno.0 lineend"
643 if {$lno == $first_lno} {
644 $cur_w insert
$lno.0 $commit_abbr $commit_type
645 } elseif
{$lno == [expr {$first_lno + 1}]} {
646 $cur_w insert
$lno.0 $author_abbr author_abbr
648 $cur_w insert
$lno.0 { |
}
651 if {$cur_w eq
$w_amov} {
652 foreach i
$w_columns {
654 {$g < [llength $group_colors]} \
656 $i tag remove color
$g $lno.0 $lno_e
658 $i tag add
$color $lno.0 $lno_e
665 } elseif
{[regexp {^
([a-z-
]+) (.
*)$} $line line key data
]} {
666 set header
($r_commit,$key) $data
669 $cur_w conf
-state disabled
673 if {$cur_w eq
$w_asim} {
674 _exec_blame
$this $w_amov @amov_data
\
679 set status
{Annotation complete.
}
685 } ifdeleted
{ catch {close $fd} }
687 method _status
{cur_s
} {
688 set have
$blame_lines
689 set total
$total_lines
691 if {$total} {set pdone
[expr {100 * $have / $total}]}
694 "Loading%s annotations... %i of %i lines annotated (%2i%%)" \
695 $cur_s $have $total $pdone]
696 $w.status.c coords bar
0 0 $pdone 20
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
"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
[clock format \
762 $header($cmit,author-time
) \
763 -format {%Y-
%m-
%d
%H
:%M
:%S
}
766 set committer_name
{}
767 set committer_email
{}
768 set committer_time
{}
769 catch {set committer_name
$header($cmit,committer
)}
770 catch {set committer_email
$header($cmit,committer-mail
)}
771 catch {set committer_time
[clock format \
772 $header($cmit,committer-time
) \
773 -format {%Y-
%m-
%d
%H
:%M
:%S
}
776 if {[catch {set msg
$header($cmit,message)}]} {
779 set fd
[open "| git cat-file commit $cmit" r
]
780 fconfigure $fd -encoding binary -translation lf
781 if {[catch {set enc
$repo_config(i18n.commitencoding
)}]} {
784 while {[gets $fd line
] > 0} {
785 if {[string match
{encoding *} $line]} {
786 set enc
[string tolower
[string range
$line 9 end
]]
789 set msg
[encoding convertfrom
$enc [read $fd]]
790 set msg
[string trim
$msg]
793 set author_name
[encoding convertfrom
$enc $author_name]
794 set committer_name
[encoding convertfrom
$enc $committer_name]
796 set header
($cmit,author
) $author_name
797 set header
($cmit,committer
) $committer_name
799 set header
($cmit,message) $msg
802 $w_cviewer insert end
"commit $cmit\n" header_key
803 $w_cviewer insert end
"Author:\t" header_key
804 $w_cviewer insert end
"$author_name $author_email" header_val
805 $w_cviewer insert end
" $author_time\n" header_val
807 $w_cviewer insert end
"Committer:\t" header_key
808 $w_cviewer insert end
"$committer_name $committer_email" header_val
809 $w_cviewer insert end
" $committer_time\n" header_val
811 if {$file ne
$path} {
812 $w_cviewer insert end
"Original File:\t" header_key
813 $w_cviewer insert end
"[escape_path $file]\n" header_val
816 $w_cviewer insert end
"\n$msg"
818 $w_cviewer conf
-state disabled
820 set highlight_line
$lno
821 set highlight_commit
$cmit
823 if {[lsearch -exact $tooltip_commit $highlight_commit] != -1} {
828 method _copycommit
{} {
829 set pos
@$::cursorX,$::cursorY
830 set lno
[lindex [split [$::cursorW index
$pos] .
] 0]
831 set dat
[lindex $amov_data $lno]
841 method _show_tooltip
{cur_w pos
} {
842 if {$tooltip_wm ne
{}} {
843 _open_tooltip
$this $cur_w
844 } elseif
{$tooltip_timer eq
{}} {
845 set tooltip_timer
[after 1000 [cb _open_tooltip
$cur_w]]
849 method _open_tooltip
{cur_w
} {
851 set pos_x
[winfo pointerx
$cur_w]
852 set pos_y
[winfo pointery
$cur_w]
853 if {[winfo containing
$pos_x $pos_y] ne
$cur_w} {
858 if {$tooltip_wm ne
"$cur_w.tooltip"} {
861 set tooltip_wm
[toplevel $cur_w.tooltip
-borderwidth 1]
862 wm overrideredirect
$tooltip_wm 1
863 wm transient
$tooltip_wm [winfo toplevel $cur_w]
864 set tooltip_t
$tooltip_wm.
label
867 -highlightthickness 0 \
871 -background lightyellow
\
873 $tooltip_t tag conf section_header
-font font_uibold
876 $tooltip_t conf
-state normal
877 $tooltip_t delete
0.0 end
880 set pos
@[join [list \
881 [expr {$pos_x - [winfo rootx
$cur_w]}] \
882 [expr {$pos_y - [winfo rooty
$cur_w]}]] ,]
883 set lno
[lindex [split [$cur_w index
$pos] .
] 0]
884 if {$cur_w eq
$w_amov} {
885 set dat
[lindex $amov_data $lno]
888 set dat
[lindex $asim_data $lno]
889 set org
[lindex $amov_data $lno]
892 set cmit
[lindex $dat 0]
893 set tooltip_commit
[list $cmit]
898 catch {set author_name
$header($cmit,author
)}
899 catch {set summary
$header($cmit,summary
)}
900 catch {set author_time
[clock format \
901 $header($cmit,author-time
) \
902 -format {%Y-
%m-
%d
%H
:%M
:%S
}
905 $tooltip_t insert end
"commit $cmit\n"
906 $tooltip_t insert end
"$author_name $author_time\n"
907 $tooltip_t insert end
"$summary"
909 if {$org ne
{} && [lindex $org 0] ne
$cmit} {
910 set save
[$tooltip_t get
0.0 end
]
911 $tooltip_t delete
0.0 end
913 set cmit
[lindex $org 0]
914 set file [lindex $org 1]
915 lappend tooltip_commit
$cmit
920 catch {set author_name
$header($cmit,author
)}
921 catch {set summary
$header($cmit,summary
)}
922 catch {set author_time
[clock format \
923 $header($cmit,author-time
) \
924 -format {%Y-
%m-
%d
%H
:%M
:%S
}
927 $tooltip_t insert end
"Originally By:\n" section_header
928 $tooltip_t insert end
"commit $cmit\n"
929 $tooltip_t insert end
"$author_name $author_time\n"
930 $tooltip_t insert end
"$summary\n"
932 if {$file ne
$path} {
933 $tooltip_t insert end
"In File: " section_header
934 $tooltip_t insert end
"$file\n"
937 $tooltip_t insert end
"\n"
938 $tooltip_t insert end
"Copied Or Moved Here By:\n" section_header
939 $tooltip_t insert end
$save
942 $tooltip_t conf
-state disabled
943 _position_tooltip
$this
946 method _position_tooltip
{} {
947 set max_h
[lindex [split [$tooltip_t index end
] .
] 0]
949 for {set i
1} {$i <= $max_h} {incr i
} {
950 set c
[lindex [split [$tooltip_t index
"$i.0 lineend"] .
] 1]
951 if {$c > $max_w} {set max_w
$c}
953 $tooltip_t conf
-width $max_w -height $max_h
955 set req_w
[winfo reqwidth
$tooltip_t]
956 set req_h
[winfo reqheight
$tooltip_t]
957 set pos_x
[expr {[winfo pointerx .
] + 5}]
958 set pos_y
[expr {[winfo pointery .
] + 10}]
960 set g
"${req_w}x${req_h}"
961 if {$pos_x >= 0} {append g
+}
963 if {$pos_y >= 0} {append g
+}
966 wm geometry
$tooltip_wm $g
970 method _hide_tooltip
{} {
971 if {$tooltip_wm ne
{}} {
974 set tooltip_commit
{}
976 if {$tooltip_timer ne
{}} {
977 after cancel
$tooltip_timer
982 method _resize
{new_height
} {
983 set diff
[expr {$new_height - $old_height}]
984 if {$diff == 0} return
986 set my
[expr {[winfo height
$w.file_pane
] - 25}]
987 set o
[$w.file_pane sash coord
0]
989 set oy
[expr {[lindex $o 1] + $diff}]
990 if {$oy < 0} {set oy
0}
991 if {$oy > $my} {set oy
$my}
992 $w.file_pane sash
place 0 $ox $oy
994 set old_height
$new_height