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]}"
332 method _load {jump} {
333 variable group_colors
337 if {$total_lines != 0 || $current_fd ne {}} {
338 if {$current_fd ne {}} {
339 catch {close $current_fd}
343 foreach i $w_columns {
344 $i conf -state normal
346 foreach g [$i tag names] {
347 if {[regexp {^g[0-9a-f]{40}$} $g]} {
351 $i conf -state disabled
354 $w_cviewer conf -state normal
355 $w_cviewer delete 0.0 end
356 $w_cviewer conf -state disabled
358 set highlight_line -1
359 set highlight_column {}
360 set highlight_commit {}
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 $status show [mc "Reading %s..." "$commit:[escape_path $path]"]
378 $w_path conf -text [escape_path $path]
380 set fd [open $path r]
381 fconfigure $fd -eofchar {}
383 set fd [git_read cat-file blob "$commit:$path"]
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 [mc "Loading copy/move tracking annotations..."]
483 } ifdeleted { catch {close $fd} }
485 method _exec_blame {cur_w cur_d options cur_s} {
486 lappend options --incremental
488 lappend options --contents $path
490 lappend options $commit
492 lappend options -- $path
493 set fd [eval git_read --nice blame $options]
494 fconfigure $fd -blocking 0 -translation lf -encoding binary
495 fileevent $fd readable [cb _read_blame $fd $cur_w $cur_d]
501 [mc "lines annotated"]
504 method _read_blame {fd cur_w cur_d} {
505 upvar #0 $cur_d line_data
506 variable group_colors
508 if {$fd ne $current_fd} {
513 $cur_w conf -state normal
514 while {[gets $fd line] >= 0} {
515 if {[regexp {^([a-z0-9]{40}) (\d+) (\d+) (\d+)$} $line line \
516 cmit original_line final_line line_count]} {
518 set r_orig_line $original_line
519 set r_final_line $final_line
520 set r_line_count $line_count
521 } elseif {[string match {filename *} $line]} {
522 set file [string range $line 9 end]
524 set lno $r_final_line
528 if {[regexp {^0{40}$} $cmit]} {
530 set commit_type curr_commit
531 } elseif {$cmit eq $commit} {
533 set commit_type curr_commit
535 set commit_type prior_commit
536 set commit_abbr [string range $cmit 0 3]
541 catch {set a_name $header($cmit,author)}
542 while {$a_name ne {}} {
543 if {$author_abbr ne {}
544 && [string index $a_name 0] eq {'}} {
545 regsub {^'[^']+'\s+} $a_name {} a_name
547 if {![regexp {^([[:upper:]])} $a_name _a]} break
548 append author_abbr $_a
551 {^[[:upper:]][^\s]*\s+} \
552 $a_name {} a_name ]} break
554 if {$author_abbr eq {}} {
557 set author_abbr [string range $author_abbr 0 3]
564 && $cmit eq [lindex $line_data [expr {$first_lno - 1}] 0]
565 && $file eq [lindex $line_data [expr {$first_lno - 1}] 1]
571 if {$first_lno < $lno} {
572 foreach g [$w_file tag names $first_lno.0] {
573 if {[regexp {^color[0-9]+$} $g]} {
579 set i [lsort [concat \
580 [$w_file tag names "[expr {$first_lno - 1}].0"] \
581 [$w_file tag names "[expr {$lno + $n}].0"] \
583 for {set g 0} {$g < [llength $group_colors]} {incr g} {
584 if {[lsearch -sorted -exact $i color$g] == -1} {
595 set lno_e "$lno.0 lineend + 1c"
596 if {[lindex $line_data $lno] ne {}} {
597 set g [lindex $line_data $lno 0]
598 foreach i $w_columns {
599 $i tag remove g$g $lno.0 $lno_e
602 lset line_data $lno [list $cmit $file $oln]
604 $cur_w delete $lno.0 "$lno.0 lineend"
605 if {$lno == $first_lno} {
606 $cur_w insert $lno.0 $commit_abbr $commit_type
607 } elseif {$lno == [expr {$first_lno + 1}]} {
608 $cur_w insert $lno.0 $author_abbr author_abbr
610 $cur_w insert $lno.0 { |}
613 foreach i $w_columns {
614 if {$cur_w eq $w_amov} {
616 {$g < [llength $group_colors]} \
618 $i tag remove color$g $lno.0 $lno_e
620 $i tag add $color $lno.0 $lno_e
622 $i tag add g$cmit $lno.0 $lno_e
625 if {$highlight_column eq $cur_w} {
626 if {$highlight_line == -1
627 && [lindex [$w_file yview] 0] == 0} {
629 set highlight_line $lno
631 if {$highlight_line == $lno} {
632 _showcommit $this $cur_w $lno
643 $cmit eq [lindex $line_data $lno 0]
644 && $file eq [lindex $line_data $lno 1]
646 $cur_w delete $lno.0 "$lno.0 lineend"
648 if {$lno == $first_lno} {
649 $cur_w insert $lno.0 $commit_abbr $commit_type
650 } elseif {$lno == [expr {$first_lno + 1}]} {
651 $cur_w insert $lno.0 $author_abbr author_abbr
653 $cur_w insert $lno.0 { |}
656 if {$cur_w eq $w_amov} {
657 foreach i $w_columns {
659 {$g < [llength $group_colors]} \
661 $i tag remove color$g $lno.0 $lno_e
663 $i tag add $color $lno.0 $lno_e
670 } elseif {[regexp {^([a-z-]+) (.*)$} $line line key data]} {
671 set header($r_commit,$key) $data
674 $cur_w conf -state disabled
678 if {$cur_w eq $w_asim} {
679 # Switches for original location detection
680 set threshold [get_config gui.copyblamethreshold]
681 set original_options [list "-C$threshold"]
683 if {![is_config_true gui.fastcopyblame]} {
684 # thorough copy search; insert before the threshold
685 set original_options [linsert $original_options 0 -C]
687 if {[git-version >= 1.5.3]} {
688 lappend original_options -w ; # ignore indentation changes
691 _exec_blame $this $w_amov @amov_data \
693 [mc "Loading original location annotations..."]
696 $status stop [mc "Annotation complete."]
699 $status update $blame_lines $total_lines
701 } ifdeleted { catch {close $fd} }
703 method _click {cur_w pos} {
704 set lno [lindex [split [$cur_w index $pos] .] 0]
705 _showcommit $this $cur_w $lno
708 method _load_commit {cur_w cur_d pos} {
709 upvar #0 $cur_d line_data
710 set lno [lindex [split [$cur_w index $pos] .] 0]
711 set dat [lindex $line_data $lno]
713 lappend history [list \
717 [lindex [$w_file xview] 0] \
718 [lindex [$w_file yview] 0] \
720 set commit [lindex $dat 0]
721 set path [lindex $dat 1]
722 _load $this [list [lindex $dat 2]]
726 method _showcommit {cur_w lno} {
728 variable active_color
730 if {$highlight_commit ne {}} {
731 foreach i $w_columns {
732 $i tag conf g$highlight_commit -background {}
733 $i tag lower g$highlight_commit
737 if {$cur_w eq $w_asim} {
738 set dat [lindex $asim_data $lno]
739 set highlight_column $w_asim
741 set dat [lindex $amov_data $lno]
742 set highlight_column $w_amov
745 $w_cviewer conf -state normal
746 $w_cviewer delete 0.0 end
750 $w_cviewer insert end [mc "Loading annotation..."] still_loading
752 set cmit [lindex $dat 0]
753 set file [lindex $dat 1]
755 foreach i $w_columns {
756 $i tag conf g$cmit -background $active_color
763 catch {set author_name $header($cmit,author)}
764 catch {set author_email $header($cmit,author-mail)}
765 catch {set author_time [format_date $header($cmit,author-time)]}
767 set committer_name {}
768 set committer_email {}
769 set committer_time {}
770 catch {set committer_name $header($cmit,committer)}
771 catch {set committer_email $header($cmit,committer-mail)}
772 catch {set committer_time [format_date $header($cmit,committer-time)]}
774 if {[catch {set msg $header($cmit,message)}]} {
777 set fd [git_read cat-file commit $cmit]
778 fconfigure $fd -encoding binary -translation lf
779 if {[catch {set enc $repo_config(i18n.commitencoding)}]} {
782 while {[gets $fd line] > 0} {
783 if {[string match {encoding *} $line]} {
784 set enc [string tolower [string range $line 9 end]]
790 set enc [tcl_encoding $enc]
792 set msg [encoding convertfrom $enc $msg]
793 set author_name [encoding convertfrom $enc $author_name]
794 set committer_name [encoding convertfrom $enc $committer_name]
795 set header($cmit,author) $author_name
796 set header($cmit,committer) $committer_name
797 set header($cmit,summary) \
798 [encoding convertfrom $enc $header($cmit,summary)]
800 set msg [string trim $msg]
802 set header($cmit,message) $msg
805 $w_cviewer insert end "commit $cmit\n" header_key
806 $w_cviewer insert end [strcat [mc "Author:"] "\t"] header_key
807 $w_cviewer insert end "$author_name $author_email" header_val
808 $w_cviewer insert end " $author_time\n" header_val
810 $w_cviewer insert end [strcat [mc "Committer:"] "\t"] header_key
811 $w_cviewer insert end "$committer_name $committer_email" header_val
812 $w_cviewer insert end " $committer_time\n" header_val
814 if {$file ne $path} {
815 $w_cviewer insert end [strcat [mc "Original File:"] "\t"] header_key
816 $w_cviewer insert end "[escape_path $file]\n" header_val
819 $w_cviewer insert end "\n$msg"
821 $w_cviewer conf -state disabled
823 set highlight_line $lno
824 set highlight_commit $cmit
826 if {[lsearch -exact $tooltip_commit $highlight_commit] != -1} {
831 method _copycommit {} {
832 set pos @$::cursorX,$::cursorY
833 set lno [lindex [split [$::cursorW index $pos] .] 0]
834 set dat [lindex $amov_data $lno]
844 method _show_tooltip {cur_w pos} {
845 if {$tooltip_wm ne {}} {
846 _open_tooltip $this $cur_w
847 } elseif {$tooltip_timer eq {}} {
848 set tooltip_timer [after 1000 [cb _open_tooltip $cur_w]]
852 method _open_tooltip {cur_w} {
854 set pos_x [winfo pointerx $cur_w]
855 set pos_y [winfo pointery $cur_w]
856 if {[winfo containing $pos_x $pos_y] ne $cur_w} {
861 if {$tooltip_wm ne "$cur_w.tooltip"} {
864 set tooltip_wm [toplevel $cur_w.tooltip -borderwidth 1]
865 wm overrideredirect $tooltip_wm 1
866 wm transient $tooltip_wm [winfo toplevel $cur_w]
867 set tooltip_t $tooltip_wm.label
870 -highlightthickness 0 \
874 -background lightyellow \
876 $tooltip_t tag conf section_header -font font_uibold
879 $tooltip_t conf -state normal
880 $tooltip_t delete 0.0 end
883 set pos @[join [list \
884 [expr {$pos_x - [winfo rootx $cur_w]}] \
885 [expr {$pos_y - [winfo rooty $cur_w]}]] ,]
886 set lno [lindex [split [$cur_w index $pos] .] 0]
887 if {$cur_w eq $w_amov} {
888 set dat [lindex $amov_data $lno]
891 set dat [lindex $asim_data $lno]
892 set org [lindex $amov_data $lno]
900 set cmit [lindex $dat 0]
901 set tooltip_commit [list $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 "commit $cmit\n"
911 $tooltip_t insert end "$author_name $author_time\n"
912 $tooltip_t insert end "$summary"
914 if {$org ne {} && [lindex $org 0] ne $cmit} {
915 set save [$tooltip_t get 0.0 end]
916 $tooltip_t delete 0.0 end
918 set cmit [lindex $org 0]
919 set file [lindex $org 1]
920 lappend tooltip_commit $cmit
925 catch {set author_name $header($cmit,author)}
926 catch {set summary $header($cmit,summary)}
927 catch {set author_time [format_date $header($cmit,author-time)]}
929 $tooltip_t insert end [strcat [mc "Originally By:"] "\n"] section_header
930 $tooltip_t insert end "commit $cmit\n"
931 $tooltip_t insert end "$author_name $author_time\n"
932 $tooltip_t insert end "$summary\n"
934 if {$file ne $path} {
935 $tooltip_t insert end [strcat [mc "In File:"] " "] section_header
936 $tooltip_t insert end "$file\n"
939 $tooltip_t insert end "\n"
940 $tooltip_t insert end [strcat [mc "Copied Or Moved Here By:"] "\n"] section_header
941 $tooltip_t insert end $save
944 $tooltip_t conf -state disabled
945 _position_tooltip $this
948 method _position_tooltip {} {
949 set max_h [lindex [split [$tooltip_t index end] .] 0]
951 for {set i 1} {$i <= $max_h} {incr i} {
952 set c [lindex [split [$tooltip_t index "$i.0 lineend"] .] 1]
953 if {$c > $max_w} {set max_w $c}
955 $tooltip_t conf -width $max_w -height $max_h
957 set req_w [winfo reqwidth $tooltip_t]
958 set req_h [winfo reqheight $tooltip_t]
959 set pos_x [expr {[winfo pointerx .] + 5}]
960 set pos_y [expr {[winfo pointery .] + 10}]
962 set g "${req_w}x${req_h}"
963 if {$pos_x >= 0} {append g +}
965 if {$pos_y >= 0} {append g +}
968 wm geometry $tooltip_wm $g
972 method _hide_tooltip {} {
973 if {$tooltip_wm ne {}} {
976 set tooltip_commit {}
978 if {$tooltip_timer ne {}} {
979 after cancel $tooltip_timer
984 method _resize {new_height} {
985 set diff [expr {$new_height - $old_height}]
986 if {$diff == 0} return
988 set my [expr {[winfo height $w.file_pane] - 25}]
989 set o [$w.file_pane sash coord 0]
991 set oy [expr {[lindex $o 1] + $diff}]
992 if {$oy < 0} {set oy 0}
993 if {$oy > $my} {set oy $my}
994 $w.file_pane sash place 0 $ox $oy
996 set old_height $new_height