Eskil

Check-in [90e6e5e17a]
Login

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

Overview
Comment:GUI for preprocess shortcuts
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 90e6e5e17a7e8cfbcb466c41bde0a6c6385aac6de2184e03fedc4a62f48d6fa6
User & Date: peter 2018-06-08 20:45:37
Context
2018-06-08
21:22
Update tutorial to match GUI changes. check-in: 623bcc4d80 user: peter tags: trunk
20:45
GUI for preprocess shortcuts check-in: 90e6e5e17a user: peter tags: trunk
2018-06-05
15:51
Working on shortcuts for preprocess dialog. check-in: 544eded01c user: peter tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/preprocess.tcl.

87
88
89
90
91
92
93

94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
...
227
228
229
230
231
232
233
234

235
236


























237
238
239
240
241
242
243
244
245
246
247
248
249
250

251
252
253
254
255
256
257

    set result {}
    for {set t 1} {[info exists ::eskil($top,prefregexp$t)]} {incr t} {
        set RE $::eskil($top,prefregexp$t)
        set Sub $::eskil($top,prefregsub$t)
        set l $::eskil($top,prefregleft$t)
        set r $::eskil($top,prefregright$t)

        switch $::eskil($top,prefregtype$t) {
            Subst {
                lappend result $RE $Sub Subst
            }
            Prefix {
                lappend result $RE "" Prefix
            }
            default {
                set side ""
                if {$l && !$r} { set side left }
                if {!$l && $r} { set side right }
                if {!$l && !$r} { continue }

                if {$RE eq ""} continue

                if {[catch {regsub -all -- $RE $exa $Sub _} err]} {
                    return
                }
                lappend result $RE $Sub $side
            }
        }
    }
................................................................................
        set ::eskil($top,prefregright$t) 1
    }
    # Override type if given
    if {$type ne ""} {
        set ::eskil($top,prefregtype$t) $type
    }

    # TBD Subst and Prefix types GUIs


    set w [ttk::frame $parent.fr$t -borderwidth 2 -relief groove -padding 3]


























    ttk::label $w.l1 -text "Regexp:" -anchor "w"
    ttk::entryX $w.e1 -textvariable ::eskil($top,prefregexp$t) -width 60
    ttk::label $w.l2 -text "Subst:" -anchor "w"
    ttk::entryX $w.e2 -textvariable ::eskil($top,prefregsub$t)
    ttk::checkbutton $w.cb1 -text "Left"  -variable ::eskil($top,prefregleft$t)
    ttk::checkbutton $w.cb2 -text "Right" -variable ::eskil($top,prefregright$t)
    addBalloon $w.cb1 "Apply to left file"
    addBalloon $w.cb2 "Apply to right file"

    grid $w.l1 $w.e1 $w.cb1 -sticky we -padx 3 -pady 3
    grid $w.l2 $w.e2 $w.cb2 -sticky we -padx 3 -pady 3
    grid columnconfigure $w 1 -weight 1

    pack $w -side "top" -fill x -padx 3 -pady 3


    trace add variable ::eskil($top,prefregexp$t) write \
            [list EditPrefRegsubUpdate $top]
    trace add variable ::eskil($top,prefregsub$t) write \
            [list EditPrefRegsubUpdate $top]
    trace add variable ::eskil($top,prefregleft$t) write \
            [list EditPrefRegsubUpdate $top]







>













<
<







 







|
>

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

|
|
|
|
<
>







87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107


108
109
110
111
112
113
114
...
226
227
228
229
230
231
232
233
234
235

236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274

275
276
277
278
279
280
281
282

    set result {}
    for {set t 1} {[info exists ::eskil($top,prefregexp$t)]} {incr t} {
        set RE $::eskil($top,prefregexp$t)
        set Sub $::eskil($top,prefregsub$t)
        set l $::eskil($top,prefregleft$t)
        set r $::eskil($top,prefregright$t)
        if {$RE eq ""} continue
        switch $::eskil($top,prefregtype$t) {
            Subst {
                lappend result $RE $Sub Subst
            }
            Prefix {
                lappend result $RE "" Prefix
            }
            default {
                set side ""
                if {$l && !$r} { set side left }
                if {!$l && $r} { set side right }
                if {!$l && !$r} { continue }



                if {[catch {regsub -all -- $RE $exa $Sub _} err]} {
                    return
                }
                lappend result $RE $Sub $side
            }
        }
    }
................................................................................
        set ::eskil($top,prefregright$t) 1
    }
    # Override type if given
    if {$type ne ""} {
        set ::eskil($top,prefregtype$t) $type
    }

    set w [ttk::frame $parent.fr$t -borderwidth 2 -relief groove -padding 3]
    pack $w -side "top" -fill x -padx 3 -pady 3


    switch $::eskil($top,prefregtype$t) {
        Subst {
            ttk::label $w.l1 -text "Left:" -anchor "w"
            ttk::entryX $w.e1 -textvariable ::eskil($top,prefregexp$t) -width 20
            ttk::label $w.l2 -text "Right:" -anchor "w"
            ttk::entryX $w.e2 -textvariable ::eskil($top,prefregsub$t)
            grid $w.l1 $w.e1 $w.l2 $w.e2 -sticky we -padx 3 -pady 3
            grid columnconfigure $w {0 2} -uniform a
            grid columnconfigure $w {1 3} -weight 1 -uniform b

            addBalloon $w.l1 -fmt {
                Each pattern is applied to its side and substituted
                for a common unique string.
            }
        }
        Prefix {
            ttk::label $w.l1 -text "Prefix:" -anchor "w"
            ttk::entryX $w.e1 -textvariable ::eskil($top,prefregexp$t) -width 20
            grid $w.l1 $w.e1 -sticky we -padx 3 -pady 3
            grid columnconfigure $w 1 -weight 1
            addBalloon $w.l1 -fmt {
                Only one word that start with prefix is valid for line
                comparison.
            }
        }
        default {
            ttk::label $w.l1 -text "Regexp:" -anchor "w"
            ttk::entryX $w.e1 -textvariable ::eskil($top,prefregexp$t) -width 60
            ttk::label $w.l2 -text "Subst:" -anchor "w"
            ttk::entryX $w.e2 -textvariable ::eskil($top,prefregsub$t)
            ttk::checkbutton $w.cb1 -text "Left"  -variable ::eskil($top,prefregleft$t)
            ttk::checkbutton $w.cb2 -text "Right" -variable ::eskil($top,prefregright$t)
            addBalloon $w.cb1 "Apply to left file"
            addBalloon $w.cb2 "Apply to right file"

            grid $w.l1 $w.e1 $w.cb1 -sticky we -padx 3 -pady 3
            grid $w.l2 $w.e2 $w.cb2 -sticky we -padx 3 -pady 3
            grid columnconfigure $w 1 -weight 1
        }

    }

    trace add variable ::eskil($top,prefregexp$t) write \
            [list EditPrefRegsubUpdate $top]
    trace add variable ::eskil($top,prefregsub$t) write \
            [list EditPrefRegsubUpdate $top]
    trace add variable ::eskil($top,prefregleft$t) write \
            [list EditPrefRegsubUpdate $top]