310
bind $w.file_pane <Configure> \
311
"if {{$w.file_pane} eq {%W}} {[cb _resize %h]}"
312
313
- _load $this
313
+ _load $this {}
314
}
315
316
-method _load {} {
316
+method _load {jump} {
317
_hide_tooltip $this
318
319
if {$total_lines != 0 || $current_fd ne {}} {
331
$i conf -state disabled
332
}
333
334
+ $w_cviewer conf -state normal
335
+ $w_cviewer delete 0.0 end
336
+ $w_cviewer conf -state disabled
337
+
338
set highlight_line -1
339
set highlight_column {}
340
set highlight_commit {}
360
} else {
361
$w_back conf -state normal
362
}
359
- lappend history [list $commit $path]
363
364
# Index 0 is always empty. There is never line 0 as
365
# we use only 1 based lines, as that matches both with
377
set fd [open "| $cmd" r]
378
}
379
fconfigure $fd -blocking 0 -translation lf -encoding binary
377
- fileevent $fd readable [cb _read_file $fd]
380
+ fileevent $fd readable [cb _read_file $fd $jump]
381
set current_fd $fd
382
}
383
389
menu $m -tearoff 0
390
}
391
389
- for {set i [expr {[llength $history] - 2}]
392
+ for {set i [expr {[llength $history] - 1}]
393
} {$i >= 0} {incr i -1} {
394
set e [lindex $history $i]
395
set c [lindex $e 0]
409
}
410
}
411
409
- $m add command -label $t -command [cb _goback $i $c $f]
412
+ $m add command -label $t -command [cb _goback $i]
413
}
414
set X [winfo rootx $w_back]
415
set Y [expr {[winfo rooty $w_back] + [winfo height $w_back]}]
416
tk_popup $m $X $Y
417
}
418
416
-method _goback {i c f} {
419
+method _goback {i} {
420
+ set dat [lindex $history $i]
421
set history [lrange $history 0 [expr {$i - 1}]]
418
- set commit $c
419
- set path $f
420
- _load $this
422
+ set commit [lindex $dat 0]
423
+ set path [lindex $dat 1]
424
+ _load $this [lrange $dat 2 5]
425
}
426
423
-method _read_file {fd} {
427
+method _read_file {fd jump} {
428
if {$fd ne $current_fd} {
429
catch {close $fd}
430
return
454
455
if {[eof $fd]} {
456
close $fd
457
+
458
+ # If we don't force Tk to update the widgets *right now*
459
+ # none of our jump commands will cause a change in the UI.
460
+ #
461
+ update
462
+
463
+ if {[llength $jump] == 1} {
464
+ set highlight_line [lindex $jump 0]
465
+ $w_file see "$highlight_line.0"
466
+ } elseif {[llength $jump] == 4} {
467
+ set highlight_column [lindex $jump 0]
468
+ set highlight_line [lindex $jump 1]
469
+ $w_file xview moveto [lindex $jump 2]
470
+ $w_file yview moveto [lindex $jump 3]
471
+ }
472
+
473
_exec_blame $this $w_asim @asim_data [list] {}
474
}
475
} ifdeleted { catch {close $fd} }
522
set file [string range $line 9 end]
523
set n $r_line_count
524
set lno $r_final_line
525
+ set oln $r_orig_line
526
set cmit $r_commit
527
528
if {[regexp {^0{40}$} $cmit]} {
571
$i tag remove g$g $lno.0 $lno_e
572
}
573
}
553
- lset line_data $lno [list $cmit $file]
574
+ lset line_data $lno [list $cmit $file $oln]
575
576
$cur_w delete $lno.0 "$lno.0 lineend"
577
if {$lno == $first_lno} {
599
600
incr n -1
601
incr lno
602
+ incr oln
603
incr blame_lines
604
}
605
663
set lno [lindex [split [$cur_w index $pos] .] 0]
664
set dat [lindex $line_data $lno]
665
if {$dat ne {}} {
666
+ lappend history [list \
667
+ $commit $path \
668
+ $highlight_column \
669
+ $highlight_line \
670
+ [lindex [$w_file xview] 0] \
671
+ [lindex [$w_file yview] 0] \
672
+ ]
673
set commit [lindex $dat 0]
674
set path [lindex $dat 1]
646
- _load $this
675
+ _load $this [list [lindex $dat 2]]
676
}
677
}
678