︙ | | | ︙ | |
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
lappend ::tablelist::cmdOpts cellbodyindex
proc tablelist::cellbodyindexSubCmd {win argList} {
if {[llength $argList] != 1} {
mwutil::wrongNumArgs "$win cellbodyindex cellIndex"
}
synchronize $win
foreach {row col} [cellIndex $win [lindex $argList 0] 1] {}
findTabs $win [expr {$row + 1}] $col $col tabIdx1 tabIdx2
upvar ::tablelist::ns${win}::data data
set cIdx1 [$data(body) index "$tabIdx1 + 1 char"]
set cIdx2 [$data(body) index "$tabIdx2 - 1 char"]
return [list $cIdx1 $cIdx2]
}
if {[catch {package require psballoon}]} {
# Add a dummy if it does not exist.
|
>
>
>
|
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
lappend ::tablelist::cmdOpts cellbodyindex
proc tablelist::cellbodyindexSubCmd {win argList} {
if {[llength $argList] != 1} {
mwutil::wrongNumArgs "$win cellbodyindex cellIndex"
}
synchronize $win
updateKeyToRowMap $win
displayItems $win
foreach {row col} [cellIndex $win [lindex $argList 0] 1] {}
findTabs $win [expr {$row + 1}] $col $col tabIdx1 tabIdx2
upvar ::tablelist::ns${win}::data data
# Get indices for cell contents
set cIdx1 [$data(body) index "$tabIdx1 + 1 char"]
set cIdx2 [$data(body) index "$tabIdx2 - 1 char"]
return [list $cIdx1 $cIdx2]
}
if {[catch {package require psballoon}]} {
# Add a dummy if it does not exist.
|
︙ | | | ︙ | |
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
|
}
# Insert lineno and text
proc insertLine {top n line text {tag {equal}} {linetag {}}} {
if {$::eskil($top,view) eq "table"} {
set RE $::eskil($top,separator)
set words [split $text $RE]
set col 0
set id [$::widgets($top,wTable) insert end {}]
foreach w $words {
$::widgets($top,wTable) cellconfigure $id,$col -text $w
if {$tag ne "equal"} {
lassign [$::widgets($top,wTable) cellbodyindex $id,$col] \
cIdx1 cIdx2
set body [$::widgets($top,wTable) bodypath]
$body tag add new$n "$cIdx1" "$cIdx2 + 1 char"
}
incr col
}
return
}
$::widgets($top,wDiff$n) insert end "$text\n" $tag
if {$linetag ne ""} {
|
>
>
|
<
|
<
|
>
>
|
|
|
<
>
>
|
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
|
}
# Insert lineno and text
proc insertLine {top n line text {tag {equal}} {linetag {}}} {
if {$::eskil($top,view) eq "table"} {
set RE $::eskil($top,separator)
set words [split $text $RE]
set id [$::widgets($top,wTable) insert end $words]
if {$tag ne "equal"} {
set col 0
foreach w $words {
if {$n == 1} {
# TBD TABLE, r is faked here for now
lappend ::eskil($top,tablechanges) \
[list $id,$col $w "" "0 0 1 1"]
} else {
lappend ::eskil($top,tablechanges) \
[list $id,$col "" $w "0 0 1 1"]
}
}
incr col
}
return
}
$::widgets($top,wDiff$n) insert end "$text\n" $tag
if {$linetag ne ""} {
|
︙ | | | ︙ | |
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
|
}
set s1 [expr {$ns1 + 1}]
set s2 [expr {$ns2 + 1}]
}
#puts "RES '$res'"
return $res
}
# Insert one line in each text widget.
# Mark them as changed, and optionally parse them.
proc insertMatchingLines {top line1 line2} {
global doingLine1 doingLine2
if {$::eskil($top,view) eq "table"} {
set opts $::Pref(ignore)
if {$::Pref(nocase)} {lappend opts -nocase}
if {$::Pref(lineparsewords)} {lappend opts -words}
set RE $::eskil($top,separator)
set words1 [split $line1 $RE]
set words2 [split $line2 $RE]
set col 0
set id [$::widgets($top,wTable) insert end {}]
foreach w1 $words1 w2 $words2 {
set r [DiffUtil::diffStrings {*}$opts $w1 $w2]
if {[llength $r] <= 2} {
# Equal
$::widgets($top,wTable) cellconfigure $id,$col -text $w1
} else {
# TBD TABLE, simple display for now
$::widgets($top,wTable) cellconfigure $id,$col -text $w1$w2
lassign [$::widgets($top,wTable) cellbodyindex $id,$col] \
cIdx1 cIdx2
set body [$::widgets($top,wTable) bodypath]
set l1 [string length $w1]
set l2 [expr {$l1 + 1}]
set l3 [expr {$l1 + [string length $w2]}]
$body tag add new1 "$cIdx1" "$cIdx1 + $l1 char"
$body tag add new2 "$cIdx1 + $l1 char" "$cIdx1 + $l3 char"
}
incr col
}
incr doingLine1
incr doingLine2
return
}
# FIXA: fully implement filter
if {$::eskil(filter) != ""} {
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
>
>
<
>
|
<
<
>
>
|
<
<
<
<
<
|
>
>
>
>
>
>
>
|
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
|
}
set s1 [expr {$ns1 + 1}]
set s2 [expr {$ns2 + 1}]
}
#puts "RES '$res'"
return $res
}
# Colour changes within table cells
proc postprocessTable {top} {
#puts "POST!"
# Make sure table is populated
update idletasks
foreach cdata $::eskil($top,tablechanges) {
lassign $cdata cell w1 w2 r
# TBD TABLE, simple display for now
# Re-set the cell text to make sure it is in the body text widget
$::widgets($top,wTable) cellconfigure $cell -text $w1$w2
#puts "Cell $cell"
lassign [$::widgets($top,wTable) cellbodyindex $cell] \
cIdx1 cIdx2
set body [$::widgets($top,wTable) bodypath]
set l1 [string length $w1]
set l2 [expr {$l1 + 1}]
set l3 [expr {$l1 + [string length $w2]}]
$body tag add new1 "$cIdx1" "$cIdx1 + $l1 char"
$body tag add new2 "$cIdx1 + $l1 char" "$cIdx1 + $l3 char"
}
}
# Insert one line in each text widget.
# Mark them as changed, and optionally parse them.
proc insertMatchingLines {top line1 line2} {
global doingLine1 doingLine2
if {$::eskil($top,view) eq "table"} {
set opts $::Pref(ignore)
if {$::Pref(nocase)} {lappend opts -nocase}
if {$::Pref(lineparsewords)} {lappend opts -words}
set RE $::eskil($top,separator)
set words1 [split $line1 $RE]
set words2 [split $line2 $RE]
# Lap 1, make row data
set rs {}
set row {}
foreach w1 $words1 w2 $words2 {
set r [DiffUtil::diffStrings {*}$opts $w1 $w2]
# Store for next lap
lappend rs $r
if {[llength $r] <= 2} {
# Equal
lappend row $w1
} else {
# TBD TABLE, simple display for now
lappend row $w1$w2
}
}
set id [$::widgets($top,wTable) insert end $row]
# Lap 2, collect cell changes
set col -1
foreach w1 $words1 w2 $words2 r $rs {
incr col
# Equal? Skip
if {[llength $r] <= 2} continue
lappend ::eskil($top,tablechanges) [list $id,$col $w1 $w2 $r]
}
incr doingLine1
incr doingLine2
return
}
# FIXA: fully implement filter
if {$::eskil(filter) != ""} {
|
︙ | | | ︙ | |
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
|
# Clear up everything before starting processing
if {$::eskil($top,view) eq "table"} {
set w $::widgets($top,wTable)
# TBD TABLE
$w configure -state normal
#$w delete 1.0 end
} else {
foreach item {wLine1 wDiff1 wLine2 wDiff2 wTb} {
set w $::widgets($top,$item)
$w configure -state normal
$w delete 1.0 end
}
}
|
>
|
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
|
# Clear up everything before starting processing
if {$::eskil($top,view) eq "table"} {
set w $::widgets($top,wTable)
# TBD TABLE
$w configure -state normal
#$w delete 1.0 end
set ::eskil($top,tablechanges) {}
} else {
foreach item {wLine1 wDiff1 wLine2 wDiff2 wTb} {
set w $::widgets($top,$item)
$w configure -state normal
$w delete 1.0 end
}
}
|
︙ | | | ︙ | |
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
|
foreach item {wLine1 wDiff1 wLine2 wDiff2} {
set w $::widgets($top,$item)
set d [expr {int($max) - int([$w index end])}]
for {set t 0} {$t < $d} {incr t} {
$w insert end \n padding
}
}
}
close $ch1
close $ch2
# We can turn off editing in the text windows after everything
# is displayed.
|
>
>
|
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
|
foreach item {wLine1 wDiff1 wLine2 wDiff2} {
set w $::widgets($top,$item)
set d [expr {int($max) - int([$w index end])}]
for {set t 0} {$t < $d} {incr t} {
$w insert end \n padding
}
}
} else {
postprocessTable $top
}
close $ch1
close $ch2
# We can turn off editing in the text windows after everything
# is displayed.
|
︙ | | | ︙ | |
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
|
if {$::eskil($top,view) eq "table"} {
# Single frame for contents
ttk::frame $top.ft -borderwidth 2 -relief sunken
grid $top.l1 $top.le $top.l2 -row 1 -sticky news
grid $top.ft - - -row 2 -sticky news
grid columnconfigure $top "0 2" -weight 1
grid rowconfigure $top $top.ft -weight 1
# TBD TABLE
tablelist::tablelist $top.ft.tab -height 20 -width 80 \
-movablecolumns no -setgrid no -showseparators no \
-fullseparators yes -selectmode none
ttk::scrollbar $top.ft.vsb -orient vertical \
-command "$top.ft.tab yview"
ttk::scrollbar $top.ft.hsb -orient horizontal \
|
|
|
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
|
if {$::eskil($top,view) eq "table"} {
# Single frame for contents
ttk::frame $top.ft -borderwidth 2 -relief sunken
grid $top.l1 $top.le $top.l2 -row 1 -sticky news
grid $top.ft - - -row 2 -sticky news
grid columnconfigure $top "0 2" -weight 1
grid rowconfigure $top $top.ft -weight 1
# TBD TABLE
tablelist::tablelist $top.ft.tab -height 20 -width 80 \
-movablecolumns no -setgrid no -showseparators no \
-fullseparators yes -selectmode none
ttk::scrollbar $top.ft.vsb -orient vertical \
-command "$top.ft.tab yview"
ttk::scrollbar $top.ft.hsb -orient horizontal \
|
︙ | | | ︙ | |