Eskil

Check-in [cad398ea05]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Restuctured some table code
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: cad398ea05438f2ff9aff15ea1e2e96534bc2c3f
User & Date: peter 2017-01-24 23:32:29.245
Context
2017-01-31
20:36
Make things run clean check-in: 43ff6468af user: peter tags: trunk
2017-01-24
23:32
Restuctured some table code check-in: cad398ea05 user: peter tags: trunk
2017-01-12
00:04
Added -gz flag to compare compressed files. check-in: 1b678887d0 user: peter tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/eskil.tcl.
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137






138
139
140
141
142
143
144
    } else {
        foreach f $::tmpfiles {
            catch {file delete $f}
        }
        set ::tmpfiles {}
    }
}

# 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
                    dict set ::eskil($top,tablechanges) $id,$col w1 $w
                    dict set ::eskil($top,tablechanges) $id,$col w2 ""
                    dict set ::eskil($top,tablechanges) $id,$col r  "0 0 1 1"
                } else {
                    dict set ::eskil($top,tablechanges) $id,$col w1 ""
                    dict set ::eskil($top,tablechanges) $id,$col w2 $w
                    dict set ::eskil($top,tablechanges) $id,$col r  "0 0 1 1"
                }
                incr col
            }
        }






        return
    }
    $::widgets($top,wDiff$n) insert end "$text\n" $tag
    if {$linetag ne ""} {
        append tag " $linetag"
    }
    if {$tag != "equal"} {








|
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>







108
109
110
111
112
113
114
115
116
117

118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
    } else {
        foreach f $::tmpfiles {
            catch {file delete $f}
        }
        set ::tmpfiles {}
    }
}

# insertLine, when in table mode
proc insertLineTable {top n line text {tag equal}} {

    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
                dict set ::eskil($top,tablechanges) $id,$col w1 $w
                dict set ::eskil($top,tablechanges) $id,$col w2 ""
                dict set ::eskil($top,tablechanges) $id,$col r  "0 0 1 1"
            } else {
                dict set ::eskil($top,tablechanges) $id,$col w1 ""
                dict set ::eskil($top,tablechanges) $id,$col w2 $w
                dict set ::eskil($top,tablechanges) $id,$col r  "0 0 1 1"
            }
            incr col
        }
    }
}

# Insert lineno and text
proc insertLine {top n line text {tag {equal}} {linetag {}}} {
    if {$::eskil($top,view) eq "table"} {
        insertLineTable $top $n $line $text $tag
        return
    }
    $::widgets($top,wDiff$n) insert end "$text\n" $tag
    if {$linetag ne ""} {
        append tag " $linetag"
    }
    if {$tag != "equal"} {
259
260
261
262
263
264
265










































266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
    # Get the displayed string
    set xxx [$w get $txIdx1 $tabIdx2]
    if {$xxx ne "$w1$w2"} {
        # Make sure dots are coloured
        $w tag add change "$tabIdx2 - 3c" $tabIdx2
    }
}











































# 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 once we have the row id
        set col -1
        foreach w1 $words1 w2 $words2 r $rs {
            incr col
            # Equal? Skip
            if {[llength $r] <= 2} continue
            dict set ::eskil($top,tablechanges) $id,$col "w1" $w1
            dict set ::eskil($top,tablechanges) $id,$col "w2" $w2
            dict set ::eskil($top,tablechanges) $id,$col "r"  $r
        }

        incr doingLine1
        incr doingLine2
        return
    }

    # FIXA: fully implement filter
    if {$::eskil(filter) != ""} {
        if {[regexp $::eskil(filter) $line1]} {
            insertLine $top 1 $doingLine1 $line1







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<







264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319






















320













321
322
323
324
325
326
327
    # Get the displayed string
    set xxx [$w get $txIdx1 $tabIdx2]
    if {$xxx ne "$w1$w2"} {
        # Make sure dots are coloured
        $w tag add change "$tabIdx2 - 3c" $tabIdx2
    }
}

# insertMatchingLines, when in table mode
proc insertMatchingLinesTable {top line1 line2} {
    global doingLine1 doingLine2

    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 once we have the row id
    set col -1
    foreach w1 $words1 w2 $words2 r $rs {
        incr col
        # Equal? Skip
        if {[llength $r] <= 2} continue
        dict set ::eskil($top,tablechanges) $id,$col "w1" $w1
        dict set ::eskil($top,tablechanges) $id,$col "w2" $w2
        dict set ::eskil($top,tablechanges) $id,$col "r"  $r
    }

    incr doingLine1
    incr doingLine2
}

# 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"} {






















        insertMatchingLinesTable $top $line1 $line2













        return
    }

    # FIXA: fully implement filter
    if {$::eskil(filter) != ""} {
        if {[regexp $::eskil(filter) $line1]} {
            insertLine $top 1 $doingLine1 $line1
596
597
598
599
600
601
602
603
604


605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
            # This is two lines that the block matching considered
            # too different to use line parsing on them.
            # Marked the whole line as deleted/inserted
            set textline1 [lindex $block1 $t1]
            set textline2 [lindex $block2 $t2]
            if {$::eskil($top,view) eq "table"} {
                # Fall back to proc that handles table
                insertMatchingLines $top $textline1 $textline2
            } else {


                $::widgets($top,wLine1) insert end [myFormL $doingLine1] \
                        "hl$::HighLightCount change"
                $::widgets($top,wDiff1) insert end "$textline1\n" new1
                $::widgets($top,wLine2) insert end [myFormL $doingLine2] \
                        "hl$::HighLightCount change"
                $::widgets($top,wDiff2) insert end "$textline2\n" new2
                incr doingLine1
                incr doingLine2
            }
            if {$finegrain} {
                addChange $top 1 change [expr {$line1 + $t1}] 1 \
                        [expr {$line2 + $t2}] 1
                nextHighlight $top
            }
            incr t1
            incr t2
        } elseif {$c eq "d"} {
            set bepa [lindex $block1 $t1]
            if {$::eskil($top,view) eq "table"} {
                insertLine $top 1 $doingLine1 $bepa new1
            } else {
                $::widgets($top,wLine1) insert end [myFormL $doingLine1] \
                        "hl$::HighLightCount change"
                $::widgets($top,wDiff1) insert end "$bepa\n" new1
                emptyLine $top 2
            }
            incr doingLine1
            if {$finegrain} {
                addChange $top 1 new1 [expr {$line1 + $t1}] 1 \
                        [expr {$line2 + $t2}] 0
                nextHighlight $top
            }
            incr t1
        } elseif {$c eq "a"} {
            set bepa [lindex $block2 $t2]
            if {$::eskil($top,view) eq "table"} {
                insertLine $top 2 $doingLine2 $bepa new2
            } else {
                $::widgets($top,wLine2) insert end [myFormL $doingLine2] \
                        "hl$::HighLightCount change"
                $::widgets($top,wDiff2) insert end "$bepa\n" new2
                emptyLine $top 1
            }
            incr doingLine2







|

>
>



















|
















|







608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
            # This is two lines that the block matching considered
            # too different to use line parsing on them.
            # Marked the whole line as deleted/inserted
            set textline1 [lindex $block1 $t1]
            set textline2 [lindex $block2 $t2]
            if {$::eskil($top,view) eq "table"} {
                # Fall back to proc that handles table
                insertMatchingLinesTable $top $textline1 $textline2
            } else {
                # insertLine cannot be used here since lineNo and text tags
                # are different
                $::widgets($top,wLine1) insert end [myFormL $doingLine1] \
                        "hl$::HighLightCount change"
                $::widgets($top,wDiff1) insert end "$textline1\n" new1
                $::widgets($top,wLine2) insert end [myFormL $doingLine2] \
                        "hl$::HighLightCount change"
                $::widgets($top,wDiff2) insert end "$textline2\n" new2
                incr doingLine1
                incr doingLine2
            }
            if {$finegrain} {
                addChange $top 1 change [expr {$line1 + $t1}] 1 \
                        [expr {$line2 + $t2}] 1
                nextHighlight $top
            }
            incr t1
            incr t2
        } elseif {$c eq "d"} {
            set bepa [lindex $block1 $t1]
            if {$::eskil($top,view) eq "table"} {
                insertLineTable $top 1 $doingLine1 $bepa new1
            } else {
                $::widgets($top,wLine1) insert end [myFormL $doingLine1] \
                        "hl$::HighLightCount change"
                $::widgets($top,wDiff1) insert end "$bepa\n" new1
                emptyLine $top 2
            }
            incr doingLine1
            if {$finegrain} {
                addChange $top 1 new1 [expr {$line1 + $t1}] 1 \
                        [expr {$line2 + $t2}] 0
                nextHighlight $top
            }
            incr t1
        } elseif {$c eq "a"} {
            set bepa [lindex $block2 $t2]
            if {$::eskil($top,view) eq "table"} {
                insertLineTable $top 2 $doingLine2 $bepa new2
            } else {
                $::widgets($top,wLine2) insert end [myFormL $doingLine2] \
                        "hl$::HighLightCount change"
                $::widgets($top,wDiff2) insert end "$bepa\n" new2
                emptyLine $top 1
            }
            incr doingLine2
736
737
738
739
740
741
742
743
744

745


746
747
748
749
750
751
752
    }
    set t 0
    while {$doingLine1 < $line1} {
        gets $ch1 apa
        gets $ch2 bepa
        if {$limit < 0 || ($t < $limit && $allowStartFill) || \
                ($line1 - $doingLine1) <= $limit} {
            insertLine $top 1 $doingLine1 $apa
            if {$::eskil($top,view) ne "table"} {

                insertLine $top 2 $doingLine2 $bepa


            }
            addMapLines $top 1
        } elseif {$t == $limit && $allowStartFill} {
            # If zero context is shown, skip the filler to keep display tight.
            if {$limit > 0} {
                emptyLine $top 1 0
                emptyLine $top 2 0







<

>

>
>







750
751
752
753
754
755
756

757
758
759
760
761
762
763
764
765
766
767
768
    }
    set t 0
    while {$doingLine1 < $line1} {
        gets $ch1 apa
        gets $ch2 bepa
        if {$limit < 0 || ($t < $limit && $allowStartFill) || \
                ($line1 - $doingLine1) <= $limit} {

            if {$::eskil($top,view) ne "table"} {
                insertLine $top 1 $doingLine1 $apa
                insertLine $top 2 $doingLine2 $bepa
            } else {
                insertLineTable $top 1 $doingLine1 $apa
            }
            addMapLines $top 1
        } elseif {$t == $limit && $allowStartFill} {
            # If zero context is shown, skip the filler to keep display tight.
            if {$limit > 0} {
                emptyLine $top 1 0
                emptyLine $top 2 0