Eskil

Check-in [f983dcb004]
Login

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

Overview
Comment:Started working on a edit buttons shown between diffs.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f983dcb0046e084f10f2d2e1e6f7f11721ad5ca6
User & Date: peter 2015-04-09 22:03:18.576
Context
2015-04-12
21:40
Started on table view check-in: 6a189c234c user: peter tags: trunk
2015-04-09
22:03
Started working on a edit buttons shown between diffs. check-in: f983dcb004 user: peter tags: trunk
2015-03-31
21:17
Moved download to main menu check-in: e368b1bdca user: peter tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to Changes.



1
2
3
4
5
6
7



2015-03-18
 Allow plugins to yield if Eskil is run in Tcl 8.6 or newer.
 Added swap plugin to exemplify this.

2015-03-18
 Added command line flag "-pluginallow" to allow a plugin to run in a standard
 interpreter instead of a safe one.
>
>
>







1
2
3
4
5
6
7
8
9
10
2015-04-09
 Started working on a edit buttons shown between diffs.

2015-03-18
 Allow plugins to yield if Eskil is run in Tcl 8.6 or newer.
 Added swap plugin to exemplify this.

2015-03-18
 Added command line flag "-pluginallow" to allow a plugin to run in a standard
 interpreter instead of a safe one.
Changes to src/eskil.tcl.
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455

1456
1457
1458
1459
1460
1461
1462
        enableRedo $top
    }

    busyCursor $top
    resetEdit $top

    # Clear up everything before starting processing
    foreach item {wLine1 wDiff1 wLine2 wDiff2} {
        set w $::widgets($top,$item)
        $w configure -state normal
        $w delete 1.0 end
    }
    clearMap $top
    set ::HighLightCount 0
    highLightChange $top -1
    # Display a star during diff execution, to know when the internal
    # processing starts, and when the label is "valid".
    set ::widgets($top,eqLabel) "*"

    wm title $top "Eskil:"
    update idletasks

    if {$::eskil($top,mode) eq "patch"} {
        disallowEdit $top
        displayPatch $top
        drawMap $top -1

        foreach item {wLine1 wLine2} {
            set w $::widgets($top,$item)
            $w configure -state disabled
        }
        update idletasks
        wm title $top "Eskil: [file tail $::eskil($top,patchFile)]"
        $::widgets($top,wLine2) see 1.0







|


















>







1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
        enableRedo $top
    }

    busyCursor $top
    resetEdit $top

    # Clear up everything before starting processing
    foreach item {wLine1 wDiff1 wLine2 wDiff2 wTb} {
        set w $::widgets($top,$item)
        $w configure -state normal
        $w delete 1.0 end
    }
    clearMap $top
    set ::HighLightCount 0
    highLightChange $top -1
    # Display a star during diff execution, to know when the internal
    # processing starts, and when the label is "valid".
    set ::widgets($top,eqLabel) "*"

    wm title $top "Eskil:"
    update idletasks

    if {$::eskil($top,mode) eq "patch"} {
        disallowEdit $top
        displayPatch $top
        drawMap $top -1
        #drawEditButtons $top
        foreach item {wLine1 wLine2} {
            set w $::widgets($top,$item)
            $w configure -state disabled
        }
        update idletasks
        wm title $top "Eskil: [file tail $::eskil($top,patchFile)]"
        $::widgets($top,wLine2) see 1.0
1620
1621
1622
1623
1624
1625
1626

1627
1628
1629
1630
1631
1632
1633
1634
                $::widgets($top,wLine2) tag add align \
                        "$i linestart" "$i lineend"
            }
        }
    }

    drawMap $top -1

    foreach item {wLine1 wLine2} {
        set w $::widgets($top,$item)
        $w configure -state disabled
    }
    update idletasks
    $::widgets($top,wLine2) see 1.0
    normalCursor $top
    showDiff $top 0







>
|







1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
                $::widgets($top,wLine2) tag add align \
                        "$i linestart" "$i lineend"
            }
        }
    }

    drawMap $top -1
    #drawEditButtons $top
    foreach item {wLine1 wLine2 wTb} {
        set w $::widgets($top,$item)
        $w configure -state disabled
    }
    update idletasks
    $::widgets($top,wLine2) see 1.0
    normalCursor $top
    showDiff $top 0
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
# Returns 1 if nothing was added.
proc editMenu {m top n hl x y} {

    if {![mayEdit $top $n]} {return 1}

    # Only copy when in a change block
    if {$hl ne ""} {
        set o [expr {3 - $n}]
        set editOther [mayEdit $top $o]

        set w $::widgets($top,wLine$n)
        set wo $::widgets($top,wLine$o)

        # Get the row that was clicked
        set index [$w index @$x,$y]







|







1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
# Returns 1 if nothing was added.
proc editMenu {m top n hl x y} {

    if {![mayEdit $top $n]} {return 1}

    # Only copy when in a change block
    if {$hl ne ""} {
        set o [expr {3 - $n}] ;# switch 1 <-> 2
        set editOther [mayEdit $top $o]

        set w $::widgets($top,wLine$n)
        set wo $::widgets($top,wLine$o)

        # Get the row that was clicked
        set index [$w index @$x,$y]
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
    toplevel $top
    eskilRegisterToplevel $top

    wm title $top "Eskil:"
    wm protocol $top WM_DELETE_WINDOW [list cleanupAndExit $top]

    ttk::frame $top.f
    grid $top.f -row 0 -columnspan 4 -sticky nws
    lappend ::widgets(toolbars) $top.f
    if {!$::Pref(toolbar)} {
        grid remove $top.f
    }

    menu $top.m
    $top configure -menu $top.m







|







2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
    toplevel $top
    eskilRegisterToplevel $top

    wm title $top "Eskil:"
    wm protocol $top WM_DELETE_WINDOW [list cleanupAndExit $top]

    ttk::frame $top.f
    grid $top.f -row 0 -columnspan 5 -sticky nws
    lappend ::widgets(toolbars) $top.f
    if {!$::Pref(toolbar)} {
        grid remove $top.f
    }

    menu $top.m
    $top configure -menu $top.m
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
    pack $top.ft2.tl -side left -fill y
    pack $top.ft2.f -side left -fill y
    pack $top.ft2.tt -side right -fill both -expand 1
    ttk::scrollbar $top.sbx2 -orient horizontal \
            -command [list $top.ft2.tt xview]
    set ::widgets($top,wLine2) $top.ft2.tl
    set ::widgets($top,wDiff2) $top.ft2.tt
    commonYScroll $top.sby $top.ft1.tl $top.ft1.tt $top.ft2.tl $top.ft2.tt

    # Set up a tag for incremental search bindings
    if {[info procs textSearch::enableSearch] != ""} {
        textSearch::enableSearch $top.ft1.tt -label ::widgets($top,isearchLabel)
        textSearch::enableSearch $top.ft2.tt -label ::widgets($top,isearchLabel)
    }








|







3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
    pack $top.ft2.tl -side left -fill y
    pack $top.ft2.f -side left -fill y
    pack $top.ft2.tt -side right -fill both -expand 1
    ttk::scrollbar $top.sbx2 -orient horizontal \
            -command [list $top.ft2.tt xview]
    set ::widgets($top,wLine2) $top.ft2.tl
    set ::widgets($top,wDiff2) $top.ft2.tt
    #commonYScroll $top.sby $top.ft1.tl $top.ft1.tt $top.ft2.tl $top.ft2.tt

    # Set up a tag for incremental search bindings
    if {[info procs textSearch::enableSearch] != ""} {
        textSearch::enableSearch $top.ft1.tt -label ::widgets($top,isearchLabel)
        textSearch::enableSearch $top.ft2.tt -label ::widgets($top,isearchLabel)
    }

3248
3249
3250
3251
3252
3253
3254

3255








3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278

3279
3280


3281
3282
3283
3284
3285
3286
3287
    addBalloon $top.le "* means external diff is running.\n= means files do\
            not differ.\n! means a large block is being processed.\nBlank\
            means files differ."
    # FIXA: verify that this label is ok after Tile migration
    ttk::label $top.ls -width 1 \
            -textvariable ::widgets($top,isearchLabel)
    addBalloon $top.ls "Incremental search indicator"

    set map [createMap $top]









    applyColor
    foreach w [list $top.ft1.tt $top.ft2.tt] {
        # The last change in a row is underlined
        $w tag configure last -underline 1
        # Each file in a patch view starts with a block of this type
        $w tag configure patch -background gray
        # Make sure selection is visible
        $w tag raise sel
        bind $w <ButtonPress-3> "zoomRow %W %X %Y %x %y"
        bind $w <ButtonRelease-3> "unzoomRow %W"
    }
    foreach w [list $top.ft1.tl $top.ft2.tl] {
        $w tag configure align -underline 1
        bind $w <ButtonPress-3> "rowPopup %W %X %Y %x %y"
    }
    SetupAlignDrag $top $top.ft1.tl $top.ft2.tl

    grid $top.l1   $top.le -        $top.l2   -row 1 -sticky news
    grid $top.ft1  $map    $top.sby $top.ft2  -row 2 -sticky news
    grid $top.sbx1 $top.ls -        $top.sbx2 -row 3 -sticky news
    grid columnconfigure $top {0 3} -weight 1
    grid rowconfigure $top 2 -weight 1

    grid $map -pady [expr {[winfo reqwidth $top.sby] - 2}]
    grid $top.ls -sticky ""



    # Allow scrolling from keys at toplevel
    bind $top <Key-Up>    [list scrollText $top yview scroll -1 u]
    bind $top <Key-k>     [list scrollText $top yview scroll -1 u]
    bind $top <Key-Down>  [list scrollText $top yview scroll  1 u]
    bind $top <Key-j>     [list scrollText $top yview scroll  1 u]
    bind $top <Key-Prior> [list scrollText $top yview scroll -1 pa]







>
|
>
>
>
>
>
>
>
>


















|
|
|
|
|
>


>
>







3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
    addBalloon $top.le "* means external diff is running.\n= means files do\
            not differ.\n! means a large block is being processed.\nBlank\
            means files differ."
    # FIXA: verify that this label is ok after Tile migration
    ttk::label $top.ls -width 1 \
            -textvariable ::widgets($top,isearchLabel)
    addBalloon $top.ls "Incremental search indicator"
    set bg [ttk::style configure . -background]
    set map [createMap $top $bg]

    # Edit buttons widget
    set ::widgets($top,wTb) $top.tb
    text $top.tb -width 4 -wrap none -background $bg \
            -font myfont -borderwidth 0 -padx 0 -highlightthickness 0 \
            -takefocus 0
    commonYScroll $top.sby $top.ft1.tl $top.ft1.tt $top.ft2.tl $top.ft2.tt \
            $top.tb

    applyColor
    foreach w [list $top.ft1.tt $top.ft2.tt] {
        # The last change in a row is underlined
        $w tag configure last -underline 1
        # Each file in a patch view starts with a block of this type
        $w tag configure patch -background gray
        # Make sure selection is visible
        $w tag raise sel
        bind $w <ButtonPress-3> "zoomRow %W %X %Y %x %y"
        bind $w <ButtonRelease-3> "unzoomRow %W"
    }
    foreach w [list $top.ft1.tl $top.ft2.tl] {
        $w tag configure align -underline 1
        bind $w <ButtonPress-3> "rowPopup %W %X %Y %x %y"
    }
    SetupAlignDrag $top $top.ft1.tl $top.ft2.tl

    grid $top.l1   $top.le -    -        $top.l2   -row 1 -sticky news
    grid $top.ft1  $top.tb $map $top.sby $top.ft2  -row 2 -sticky news
    grid $top.sbx1 $top.ls -    -        $top.sbx2 -row 3 -sticky news
    grid columnconfigure $top "$top.ft1 $top.ft2" -weight 1
    grid rowconfigure $top $top.ft1 -weight 1
    grid $top.tb -pady 2
    grid $map -pady [expr {[winfo reqwidth $top.sby] - 2}]
    grid $top.ls -sticky ""

    grid remove $top.tb ;# Hide until done

    # Allow scrolling from keys at toplevel
    bind $top <Key-Up>    [list scrollText $top yview scroll -1 u]
    bind $top <Key-k>     [list scrollText $top yview scroll -1 u]
    bind $top <Key-Down>  [list scrollText $top yview scroll  1 u]
    bind $top <Key-j>     [list scrollText $top yview scroll  1 u]
    bind $top <Key-Prior> [list scrollText $top yview scroll -1 pa]
Changes to src/map.tcl.
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
#  Boston, MA 02111-1307, USA.
#
#----------------------------------------------------------------------
# $Revision$
#----------------------------------------------------------------------

proc createMap {top} {
    set w $top.c_map
    if {$::Pref(wideMap)} {
        set width 20
    } else {
        set width 6
    }
    canvas $w -width $width -borderwidth 0 -selectborderwidth 0 \
            -highlightthickness 0 -height 10
    set map [image create photo map$top]

    $w create image 0 0 -anchor nw -image $map
    bind $w <Destroy>   [list image delete $map]
    bind $w <Configure> [list drawMap $top %h]
    bind $w <Button-2>  [list ThumbMap $top %y]








|







|







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
#  Boston, MA 02111-1307, USA.
#
#----------------------------------------------------------------------
# $Revision$
#----------------------------------------------------------------------

proc createMap {top bg} {
    set w $top.c_map
    if {$::Pref(wideMap)} {
        set width 20
    } else {
        set width 6
    }
    canvas $w -width $width -borderwidth 0 -selectborderwidth 0 \
            -highlightthickness 0 -height 10 -background $bg
    set map [image create photo map$top]

    $w create image 0 0 -anchor nw -image $map
    bind $w <Destroy>   [list image delete $map]
    bind $w <Configure> [list drawMap $top %h]
    bind $w <Button-2>  [list ThumbMap $top %y]

60
61
62
63
64
65
66

































67
68
69
70
71
72
73
    }
    incr ::eskil($top,mapMax) $n
}

proc addMapLines {top n} {
    incr ::eskil($top,mapMax) $n
}


































proc drawMap {top newh} {
    set oldh [map$top cget -height]
    if {$oldh == $newh} return

    map$top blank
    if {![info exists ::eskil($top,changes)] || \







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







60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
    }
    incr ::eskil($top,mapMax) $n
}

proc addMapLines {top n} {
    incr ::eskil($top,mapMax) $n
}

# Use the assembled information for the map to draw edit buttons
proc drawEditButtons {top} {
    $::widgets($top,wTb) delete 1.0 end
    set l 0
    foreach change $::eskil($top,changes) {
	lassign $change start length type line1 n1 line2 n2
        set pre [expr {($length - 1) / 2}]
        while {$l < ($start + $pre)} {
            incr l
            $::widgets($top,wTb) insert end \n
        }
        incr l
        $::widgets($top,wTb) image create end -image $::img(left) \
                -pady -2 -padx 1 -name li$l
        $::widgets($top,wTb) image create end -image $::img(right) \
                -pady -2 -name ri$l
        $::widgets($top,wTb) tag add lt$l li$l
        $::widgets($top,wTb) tag add rt$l ri$l
        # Make visible for now
        $::widgets($top,wTb) tag configure lt$l -background pink
        $::widgets($top,wTb) tag configure rt$l -background lightgreen
        $::widgets($top,wTb) insert end \n
        while {$l < ($start+ $length)} {
            incr l
            $::widgets($top,wTb) insert end \n
        }
    }
    while {$l < $::eskil($top,mapMax)} {
        incr l
        $::widgets($top,wTb) insert end \n
    }
}

proc drawMap {top newh} {
    set oldh [map$top cget -height]
    if {$oldh == $newh} return

    map$top blank
    if {![info exists ::eskil($top,changes)] || \