Eskil

Check-in [7ec7dbb565]
Login

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

Overview
Comment:Handle when table cells are cut off. Added -maxwidth to limit table column width.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7ec7dbb5650fade75d1a02bdfb2196d5fb1a49db
User & Date: peter 2015-06-03 23:28:37.267
Context
2015-07-02
07:48
Printing followed by redo diff closed Eskil. Fixed this. check-in: 4400d4437f user: peter tags: trunk
2015-06-03
23:28
Handle when table cells are cut off. Added -maxwidth to limit table column width. check-in: 7ec7dbb565 user: peter tags: trunk
22:22
Added doc for table check-in: 445a0958f0 user: peter tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/eskil.tcl.
473
474
475
476
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

# This is called from the table view whenever a cell is drawn.
# Add color as needed.
proc tblModeColorCallback {win w key row col tabIdx1 tabIdx2 inStripe selected} {
    set cellX $key,$col
    set top [winfo toplevel $win]
    if {![dict exists $::eskil($top,tablechanges) $cellX]} {

        return
    }
    set cinfo [dict get $::eskil($top,tablechanges) $cellX]
    set w1 [dict get $cinfo w1]
    set w2 [dict get $cinfo w2]

    #set xxx [$w get $tabIdx1 $tabIdx2]
    #if {$xxx eq ""} return

    #puts "COLOR UPDATE W $win K $key R $row C $col TB1 $tabIdx1 TB2 $tabIdx2"
    #puts "   [string length $xxx] '$xxx'"
    #puts "   CHANGEME"




    set l1 [string length $w1]
    set l2 [expr {$l1 + 1}]

    set l3 [expr {$l1 + [string length $w2]}]

    $w tag add new1 "$tabIdx1"            "$tabIdx1 + $l1 char"
    $w tag add new2 "$tabIdx1 + $l1 char" "$tabIdx1 + $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








>






<
<
<



>
>
>
>

|
>
|
>
|
|
>
>
>
>
>
>
>







473
474
475
476
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

# This is called from the table view whenever a cell is drawn.
# Add color as needed.
proc tblModeColorCallback {win w key row col tabIdx1 tabIdx2 inStripe selected} {
    set cellX $key,$col
    set top [winfo toplevel $win]
    if {![dict exists $::eskil($top,tablechanges) $cellX]} {
        # No changes, nothing to do here
        return
    }
    set cinfo [dict get $::eskil($top,tablechanges) $cellX]
    set w1 [dict get $cinfo w1]
    set w2 [dict get $cinfo w2]




    #puts "COLOR UPDATE W $win K $key R $row C $col TB1 $tabIdx1 TB2 $tabIdx2"
    #puts "   [string length $xxx] '$xxx'"
    #puts "   CHANGEME"

    # Currently the displayed string is just $w1$w2
    # The table might have cut of display of a cell so make sure to stay
    # within the boundaries.
    set l1 [string length $w1]
    set mid "$tabIdx1 + $l1 char"
    if {[$w compare $mid >= $tabIdx2]} {
        set mid $tabIdx2
    }
    $w tag add new1 $tabIdx1 $mid
    $w tag add new2 $mid     $tabIdx2

    # Get the displayed string
    set xxx [$w get $tabIdx1 $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

521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
            } 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
            dict set ::eskil($top,tablechanges) $id,$col w1 $w1 
            dict set ::eskil($top,tablechanges) $id,$col w2 $w2







|







532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
            } 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
1696
1697
1698
1699
1700
1701
1702


1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724








1725
1726
1727
1728
1729
1730
1731
        # Look for table header line
        set i [lindex $diffres 0]
        lassign $i line1 n1 line2 n2
        if {$line1 == 1 || $line2 == 1} {
            # Hide header line of widget TBD TABLE
            #$::widgets($top,wTable) configure 
            # Set up columns??


        } else {
            # First lines are equal, treat them as header
            # Consume table header line
            gets $ch1 line1
            incr doingLine1
            gets $ch2 line
            incr doingLine2
            if {$::eskil($top,separator) eq ""} {
                # Autodetect separator
                # Any tab?
                if {[regsub -all "\t" $line1 "\t" _] >= 2} {
                    set ::eskil($top,separator) "\t"
                } elseif {[regsub -all "," $line1 "," _] >= 2} {
                    set ::eskil($top,separator) ","
                } 
            }
            set headings [split $line1 $::eskil($top,separator)]
            set col {}
            foreach heading $headings {
                lappend col 0 $heading
            }
            $::widgets($top,wTable) configure -columns $col








        }
    }

    # If there is a range, skip lines up to the range
    if {[llength $range] != 0} {
        disallowEdit $top
        lassign $range start1 end1 start2 end2







>
>

















|

|

|
>
>
>
>
>
>
>
>







1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
        # Look for table header line
        set i [lindex $diffres 0]
        lassign $i line1 n1 line2 n2
        if {$line1 == 1 || $line2 == 1} {
            # Hide header line of widget TBD TABLE
            #$::widgets($top,wTable) configure 
            # Set up columns??
            $::widgets($top,wTable) configure \
                    -columns "0 Table 0 without 0 header 0 not 0 implemented 0 yet"
        } else {
            # First lines are equal, treat them as header
            # Consume table header line
            gets $ch1 line1
            incr doingLine1
            gets $ch2 line
            incr doingLine2
            if {$::eskil($top,separator) eq ""} {
                # Autodetect separator
                # Any tab?
                if {[regsub -all "\t" $line1 "\t" _] >= 2} {
                    set ::eskil($top,separator) "\t"
                } elseif {[regsub -all "," $line1 "," _] >= 2} {
                    set ::eskil($top,separator) ","
                } 
            }
            set headings [split $line1 $::eskil($top,separator)]
            set columns {}
            foreach heading $headings {
                lappend columns 0 $heading
            }
            $::widgets($top,wTable) configure -columns $columns
            if {$::eskil($top,maxwidth) > 0} {
                set col -1
                foreach {_ _} $columns {
                    incr col
                    $::widgets($top,wTable) columnconfigure $col \
                            -maxwidth $::eskil($top,maxwidth)
                }
            }
        }
    }

    # If there is a range, skip lines up to the range
    if {[llength $range] != 0} {
        disallowEdit $top
        lassign $range start1 end1 start2 end2
3060
3061
3062
3063
3064
3065
3066

3067
3068
3069
3070
3071
3072
3073
    set ::eskil($top,view) ""
    set ::eskil($top,printFile) ""
    set ::eskil($top,mergeFile) ""
    set ::eskil($top,ancestorFile) ""
    set ::eskil($top,separator) ""
    set ::eskil($top,conflictFile) ""
    set ::eskil($top,limitlines) 0

    set ::eskil($top,plugin) ""

    # Copy the collected options from command line
    foreach {item val} $::eskil(defaultopts) {
        set ::eskil($top,$item) $val
    }
}







>







3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
    set ::eskil($top,view) ""
    set ::eskil($top,printFile) ""
    set ::eskil($top,mergeFile) ""
    set ::eskil($top,ancestorFile) ""
    set ::eskil($top,separator) ""
    set ::eskil($top,conflictFile) ""
    set ::eskil($top,limitlines) 0
    set ::eskil($top,maxwidth) 0
    set ::eskil($top,plugin) ""

    # Copy the collected options from command line
    foreach {item val} $::eskil(defaultopts) {
        set ::eskil($top,$item) $val
    }
}
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427


3428
3429
3430
3431
3432
3433
3434
        # 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 \
                -colorizecommand tblModeColorCallback
        ttk::scrollbar $top.ft.vsb -orient vertical \
                -command "$top.ft.tab yview"
        ttk::scrollbar $top.ft.hsb -orient horizontal \
                -command "$top.ft.tab xview"
        $top.ft.tab configure -yscrollcommand "$top.ft.vsb set" \
                -xscrollcommand "$top.ft.hsb set"
        set body [$top.ft.tab bodypath]
        $body tag configure new1 -foreground $::Pref(colornew1) \
                -background $::Pref(bgnew1)
        $body tag configure new2 -foreground $::Pref(colornew2) \
                -background $::Pref(bgnew2)



        set bg [ttk::style configure . -background]
        set map [createMap $top $bg]
        
        grid $top.ft.tab $top.ft.vsb $map -sticky news
        grid $top.ft.hsb x           x    -sticky news
        grid columnconfigure $top.ft 0 -weight 1







|














>
>







3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
        # 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 25 -width 100 \
                -movablecolumns no -setgrid no -showseparators no \
                -fullseparators yes -selectmode none \
                -colorizecommand tblModeColorCallback
        ttk::scrollbar $top.ft.vsb -orient vertical \
                -command "$top.ft.tab yview"
        ttk::scrollbar $top.ft.hsb -orient horizontal \
                -command "$top.ft.tab xview"
        $top.ft.tab configure -yscrollcommand "$top.ft.vsb set" \
                -xscrollcommand "$top.ft.hsb set"
        set body [$top.ft.tab bodypath]
        $body tag configure new1 -foreground $::Pref(colornew1) \
                -background $::Pref(bgnew1)
        $body tag configure new2 -foreground $::Pref(colornew2) \
                -background $::Pref(bgnew2)
        $body tag configure change -foreground $::Pref(colorchange) \
                -background $::Pref(bgchange)

        set bg [ttk::style configure . -background]
        set map [createMap $top $bg]
        
        grid $top.ft.tab $top.ft.vsb $map -sticky news
        grid $top.ft.hsb x           x    -sticky news
        grid columnconfigure $top.ft 0 -weight 1
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
        -clip -patch -browse -conflict -print -noempty -pivot
        -printHeaderSize -printCharsPerLine -printPaper
        -printColorChange -printColorOld -printColorNew
        -printFont -sep
        -server -o -a -fine -r -context -cvs -svn -review
        -foreach -preprocess -preprocessleft -preprocessright
        -close -nonewline -plugin -plugininfo -pluginallow
        -plugindump -pluginlist -nocdiff -table
    }

    # If the first option is "--query", use it to ask about options.
    if {$::eskil(argc) == 2 && [lindex $::eskil(argv) 0] == "--query"} {
        set arg [lindex $::eskil(argv) 1]
        if {[lsearch -exact $allOpts $arg] < 0} {
            set match [lsearch -glob -all -inline $allOpts $arg*]







|







4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
        -clip -patch -browse -conflict -print -noempty -pivot
        -printHeaderSize -printCharsPerLine -printPaper
        -printColorChange -printColorOld -printColorNew
        -printFont -sep
        -server -o -a -fine -r -context -cvs -svn -review
        -foreach -preprocess -preprocessleft -preprocessright
        -close -nonewline -plugin -plugininfo -pluginallow
        -plugindump -pluginlist -nocdiff -table -maxwidth
    }

    # If the first option is "--query", use it to ask about options.
    if {$::eskil(argc) == 2 && [lindex $::eskil(argv) 0] == "--query"} {
        set arg [lindex $::eskil(argv) 1]
        if {[lsearch -exact $allOpts $arg] < 0} {
            set match [lsearch -glob -all -inline $allOpts $arg*]
4258
4259
4260
4261
4262
4263
4264


4265
4266
4267
4268
4269
4270
4271
                ValidatePdfColor $arg -printColorNew
                set ::Pref(printColorNew2) $arg
            } elseif {$nextArg eq "revision"} {
                set opts(doptrev$revNo) $arg
                incr revNo
            } elseif {$nextArg eq "limitlines"} {
                set opts(limitlines) $arg


            } elseif {$nextArg eq "context"} {
                set ::Pref(context) $arg
            } elseif {$nextArg eq "pivot"} {
                if {$arg >= 1} {
                    set ::Pref(pivot) $arg
                }
            } elseif {$nextArg eq "prefix"} {







>
>







4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
                ValidatePdfColor $arg -printColorNew
                set ::Pref(printColorNew2) $arg
            } elseif {$nextArg eq "revision"} {
                set opts(doptrev$revNo) $arg
                incr revNo
            } elseif {$nextArg eq "limitlines"} {
                set opts(limitlines) $arg
            } elseif {$nextArg eq "maxwidth"} {
                set opts(maxwidth) $arg
            } elseif {$nextArg eq "context"} {
                set ::Pref(context) $arg
            } elseif {$nextArg eq "pivot"} {
                if {$arg >= 1} {
                    set ::Pref(pivot) $arg
                }
            } elseif {$nextArg eq "prefix"} {
4367
4368
4369
4370
4371
4372
4373


4374
4375
4376
4377
4378
4379
4380
            set ::Pref(lineparsewords) 1
        } elseif {$arg eq "-2nd"} { # Deprecated
            #set ::Pref(extralineparse) 1
        } elseif {$arg eq "-no2nd"} { # Deprecated
            #set ::Pref(extralineparse) 0
        } elseif {$arg eq "-limit"} {
            set nextArg limitlines


        } elseif {$arg eq "-nodiff"} {
            set noautodiff 1
        } elseif {$arg eq "-nocdiff"} {
            set nocdiff 1
        } elseif {$arg eq "-dir"} {
            set dodir 1
        } elseif {$arg eq "-clip"} {







>
>







4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
            set ::Pref(lineparsewords) 1
        } elseif {$arg eq "-2nd"} { # Deprecated
            #set ::Pref(extralineparse) 1
        } elseif {$arg eq "-no2nd"} { # Deprecated
            #set ::Pref(extralineparse) 0
        } elseif {$arg eq "-limit"} {
            set nextArg limitlines
        } elseif {$arg eq "-maxwidth"} {
            set nextArg maxwidth
        } elseif {$arg eq "-nodiff"} {
            set noautodiff 1
        } elseif {$arg eq "-nocdiff"} {
            set nocdiff 1
        } elseif {$arg eq "-dir"} {
            set dodir 1
        } elseif {$arg eq "-clip"} {