Eskil

Check-in [544eded01c]
Login

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

Overview
Comment:Working on shortcuts for preprocess dialog.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 544eded01c32c9e0e0a0040814adc301671aa4fba8a76ba4f09e0d802894a2e6
User & Date: peter 2018-06-05 15:51:01
Context
2018-06-08
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
2018-05-21
15:45
Handle balloon over labelframe check-in: 2970b5118f user: peter tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Changes.




1
2
3
4
5
6
7



2018-05-14
 Added changeset tool to fourway,

2018-05-13
 Adjustments to fourway UI.

Released 2.8.2
>
>
>







1
2
3
4
5
6
7
8
9
10
2018-06-05
 Working on shortcuts for preprocess dialog.

2018-05-14
 Added changeset tool to fourway,

2018-05-13
 Adjustments to fourway UI.

Released 2.8.2

Changes to src/preprocess.tcl.

20
21
22
23
24
25
26

27
28
29
30
31
32
33

34
35
36













37

38
39
40
41
42
43
44
..
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
..
99
100
101
102
103
104
105

106
107
108
109
110
111
112
113
114
115
116

117
118
119
120
121
122
123
124
















125
126
127
128
129
130
131
...
164
165
166
167
168
169
170
171
172
173
174
175
176
177


178
179
180
181
182







183
184
185
186
187
188
189
...
206
207
208
209
210
211
212
213
214


215








216
217
218
219
220
221
222
223
224
225
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
...
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
283
284
285
286
287
...
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
...
392
393
394
395
396
397
398

399
400
401
402
403
404
405
#
#----------------------------------------------------------------------
#
# The format of the ::Pref(preprocessn) is:
# Flat list of stride 2, (name data)
# Data dict elements: preprocess active save
# Preprocess element is a flat list of stride 3 (RE sub side)

#
# There used to be a ::Pref(preprocess) with a different format, the new
# was named a bit different for compatibilty with saved preferences.

# Return active preprocess items as a flat list with stride 3
proc getActivePreprocess {top} {
    set res {}

    foreach {name data} $::Pref(preprocessn) {
        if {[dict get $data active]} {
            foreach {RE sub side} [dict get $data preprocess] {













                lappend res $RE $sub $side

            }
        }
    }
    return $res
}

# Entry for adding preprocess from command line
................................................................................

    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)








        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 ::TmpPref(preprocess,re,$item) $result
    set ::TmpPref(preprocess,active,$item) 1

    if {$keep} {
        # Apply was pressed, also apply main dialog
................................................................................
    }
    destroy $w

    array unset ::eskil $top,prefregexp*
    array unset ::eskil $top,prefregsub*
    array unset ::eskil $top,prefregleft*
    array unset ::eskil $top,prefregright*

}

# Update the example in the preprocess dialog
proc EditPrefRegsubUpdate {top args} {
    set exal $::eskil($top,prefregexa)
    set exar $::eskil($top,prefregexa)
    set exal2 $::eskil($top,prefregexa2)
    set exar2 $::eskil($top,prefregexa2)
    set ok $::widgets($top,prefRegsubOk)
    set app $::widgets($top,prefRegsubApply)


    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

















        if {$l} {
            if {[catch {regsub -all -- $RE $exal $Sub result} err]} {
                set ::eskil($top,prefregresultl) "$t ERROR: $err"
                $ok configure -state disabled
                $app configure -state disabled
                return
            } else {
................................................................................
    set ::eskil($top,prefregresultl) $exal
    set ::eskil($top,prefregresultr) $exar
    $ok configure -state normal
    $app configure -state normal
}

# Add a new entry in the preprocess dialog
proc AddPrefRegsub {top parent} {
    # Figure out next number to use
    for {set t 1} {[winfo exists $parent.fr$t]} {incr t} {
        #Empty
    }
    # Default values
    if {![info exists ::eskil($top,prefregexp$t)]} {


        set ::eskil($top,prefregexp$t) ""
        set ::eskil($top,prefregsub$t) ""
        set ::eskil($top,prefregleft$t) 1
        set ::eskil($top,prefregright$t) 1
    }







    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)
................................................................................
            [list EditPrefRegsubUpdate $top]
}

# Editor for one item in ::Pref(preprocessn)
proc EditPrefRegsub {top item} {
    set w $top.prefregsub

    ToplevelForce $w "Preferences: Preprocess item"



    ttk::button $w.b -text "Add" -command [list AddPrefRegsub $top $w]









    # Result example part
    if {![info exists ::eskil($top,prefregexa)]} {
        set ::eskil($top,prefregexa) \
                "An example TextString FOR_REGSUB /* Comment */"
        set ::eskil($top,prefregexa2) \
                "An example TextString FOR_REGSUB /* Comment */"
    }
    ttk::labelframe $w.res -text "Preprocessing result" -padding 3
    ttk::label $w.res.l3 -text "Example 1:" -anchor "w"
    ttk::entryX $w.res.e3 -textvariable ::eskil($top,prefregexa) -width 60
    ttk::label $w.res.l4 -text "Result 1:" -anchor "w"

    ttk::label $w.res.e4l -textvariable ::eskil($top,prefregresultl) \
            -anchor "w" -width 10
    ttk::label $w.res.e4r -textvariable ::eskil($top,prefregresultr) \
            -anchor "w" -width 10
    ttk::label $w.res.l5 -text "Example 2:" -anchor "w"
    ttk::entryX $w.res.e5 -textvariable ::eskil($top,prefregexa2)
    ttk::label $w.res.l6 -text "Result 2:" -anchor "w"

    ttk::label $w.res.e6l -textvariable ::eskil($top,prefregresultl2) \
            -anchor "w" -width 10
    ttk::label $w.res.e6r -textvariable ::eskil($top,prefregresultr2) \
            -anchor "w" -width 10

    grid $w.res.l3 $w.res.e3  -sticky we -padx 3 -pady 3
    grid $w.res.l4 $w.res.e4l -sticky we -padx 3 -pady 3
    grid x         $w.res.e4r -sticky we -padx 3 -pady 3
    grid $w.res.l5 $w.res.e5  -sticky we -padx 3 -pady 3
    grid $w.res.l6 $w.res.e6l -sticky we -padx 3 -pady 3
    grid x         $w.res.e6r -sticky we -padx 3 -pady 3
    grid columnconfigure $w.res 1 -weight 1

    # Buttons
    ttk::frame $w.fb -padding 3
    ttk::button $w.fb.b1 -text "Ok"     -command [list EditPrefRegsubOk $top $w $item]
    ttk::button $w.fb.b2 -text "Apply"  -command [list EditPrefRegsubOk $top $w $item 1]
    ttk::button $w.fb.b3 -text "Cancel" -command [list destroy $w]
................................................................................
    set ::widgets($top,prefRegsubApply) $w.fb.b2

    grid $w.fb.b1 x $w.fb.b2 x $w.fb.b3 -sticky we
    grid columnconfigure $w.fb {0 2 4} -uniform a
    grid columnconfigure $w.fb {1 3} -weight 1

    # Top layout
    pack $w.b -side "top" -anchor "w" -padx 3 -pady 3 -ipadx 15
    pack $w.fb $w.res -side bottom -fill x -padx 3 -pady 3

    # Fill in existing or an empty line
    set preprocess $::TmpPref(preprocess,re,$item)

    if {[llength $preprocess] == 0} {
        AddPrefRegsub $top $w
    } else {
        set t 1
        foreach {RE Sub side} $preprocess {
            set ::eskil($top,prefregexp$t) $RE
            set ::eskil($top,prefregsub$t) $Sub
            set ::eskil($top,prefregleft$t) 0
            set ::eskil($top,prefregright$t) 0




            if {$side eq "" || $side eq "left"} {
                set ::eskil($top,prefregleft$t) 1
            }
            if {$side eq "" || $side eq "right"} {
                set ::eskil($top,prefregright$t) 1

            }
            AddPrefRegsub $top $w
            incr t
        }
    }

    trace add variable ::eskil($top,prefregexa) write \
................................................................................
    if {![info exists ::TmpPref(preprocess,name,$r)]} {
        set ::TmpPref(preprocess,name,$r) ""
        set ::TmpPref(preprocess,active,$r) 0
        set ::TmpPref(preprocess,save,$r) 0
        set ::TmpPref(preprocess,re,$r) ""
    }
    ttk::entry $w.fp.ne$r -textvariable ::TmpPref(preprocess,name,$r)
    addBalloon $w.fp.ne$r "Name of preprocess item (optional)"
    ttk::checkbutton $w.fp.cba$r -text "Active" \
            -variable ::TmpPref(preprocess,active,$r)
    addBalloon $w.fp.cba$r "Activate item for this session"
    ttk::checkbutton $w.fp.cbs$r -text "Save" \
            -variable ::TmpPref(preprocess,save,$r)
    addBalloon $w.fp.cbs$r "Save item when preferences are saved"
    ttk::button $w.fp.be$r -text "Edit" \
            -command [list EditPrefRegsub $w $r]
    addBalloon $w.fp.be$r "Edit the associated list of regexps"
    ttk::button $w.fp.bu$r -image $::img(up) \
            -command [list EditPrefPreUp $r]
    addBalloon $w.fp.bu$r "Move item up in list"
    grid $w.fp.ne$r $w.fp.cba$r $w.fp.cbs$r $w.fp.be$r $w.fp.bu$r -sticky we \
            -padx 3 -pady 3
    # Make buttons symmetric
    grid  $w.fp.be$r $w.fp.bu$r -sticky news

    set ::TmpPref(preprocess,n) $r
}
................................................................................
        EditPrefPreprocessAddItem $w
    }

    # Frame for action buttons
    ttk::frame $w.fa -padding 3
    ttk::button $w.fa.b1 -text "Add" \
            -command [list EditPrefPreprocessAddItem $w]


    grid $w.fa.b1 -sticky we
    grid columnconfigure $w.fa {0 2 4} -uniform a
    grid columnconfigure $w.fa {1 3} -weight 1

    
    # Frame for dialog Buttons







>







>



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







 







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

|

|
|
|
|
>
>







 







>











>








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







 







|






>
>





>
>
>
>
>
>
>







 







|

>
>
|
>
>
>
>
>
>
>
>











|
>






|
>





|
|
|
|
|
|







 







|






|







>
>
>
>
|
|
|
|
|
>







 







|


|


|





|







 







>







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
..
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
116
117
118
119
120
121
...
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
...
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
...
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
316
317
...
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
...
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
...
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
#
#----------------------------------------------------------------------
#
# The format of the ::Pref(preprocessn) is:
# Flat list of stride 2, (name data)
# Data dict elements: preprocess active save
# Preprocess element is a flat list of stride 3 (RE sub side)
# If side is a special word, it is a special shortcut format.
#
# There used to be a ::Pref(preprocess) with a different format, the new
# was named a bit different for compatibilty with saved preferences.

# Return active preprocess items as a flat list with stride 3
proc getActivePreprocess {top} {
    set res {}
    set count 0
    foreach {name data} $::Pref(preprocessn) {
        if {[dict get $data active]} {
            foreach {RE sub side} [dict get $data preprocess] {
                if {$side eq "Subst"} {
                    # Translate to Regexps
                    # Unique substitution
                    set pattern __$count[clock clicks -microseconds]__
                    incr count
                    lappend res $RE  $pattern left
                    lappend res $sub $pattern right
                } elseif {$side eq "Prefix"} {
                    # Translate to Regexp
                    set RE2 [string map [list % $RE] {^.*?\m(%\w+).*$}]
                    lappend res $RE2 {\1} ""
                } else {
                    # Generic
                    lappend res $RE $sub $side
                }
            }
        }
    }
    return $res
}

# Entry for adding preprocess from command line
................................................................................

    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 ::TmpPref(preprocess,re,$item) $result
    set ::TmpPref(preprocess,active,$item) 1

    if {$keep} {
        # Apply was pressed, also apply main dialog
................................................................................
    }
    destroy $w

    array unset ::eskil $top,prefregexp*
    array unset ::eskil $top,prefregsub*
    array unset ::eskil $top,prefregleft*
    array unset ::eskil $top,prefregright*
    array unset ::eskil $top,prefregtype*
}

# Update the example in the preprocess dialog
proc EditPrefRegsubUpdate {top args} {
    set exal $::eskil($top,prefregexa)
    set exar $::eskil($top,prefregexa)
    set exal2 $::eskil($top,prefregexa2)
    set exar2 $::eskil($top,prefregexa2)
    set ok $::widgets($top,prefRegsubOk)
    set app $::widgets($top,prefRegsubApply)

    set pp {}
    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 {
                set pattern __$t[clock clicks -microseconds]__
                lappend pp $RE  $pattern 1 0
                lappend pp $Sub $pattern 0 1
            }
            Prefix {
                set RE2 [string map [list % $RE] {^.*?\m(%\w+).*$}]
                lappend pp $RE2 {\1} 1 1
            }
            default {
                lappend pp $RE $Sub $l $r
            }
        }
    }
    foreach {RE Sub l r} $pp {
        if {$l} {
            if {[catch {regsub -all -- $RE $exal $Sub result} err]} {
                set ::eskil($top,prefregresultl) "$t ERROR: $err"
                $ok configure -state disabled
                $app configure -state disabled
                return
            } else {
................................................................................
    set ::eskil($top,prefregresultl) $exal
    set ::eskil($top,prefregresultr) $exar
    $ok configure -state normal
    $app configure -state normal
}

# Add a new entry in the preprocess dialog
proc AddPrefRegsub {top parent {type {}}} {
    # Figure out next number to use
    for {set t 1} {[winfo exists $parent.fr$t]} {incr t} {
        #Empty
    }
    # Default values
    if {![info exists ::eskil($top,prefregexp$t)]} {
        set ::eskil($top,prefregtype$t) Generic
        set ::eskil($top,prefregexp$t) ""
        set ::eskil($top,prefregexp$t) ""
        set ::eskil($top,prefregsub$t) ""
        set ::eskil($top,prefregleft$t) 1
        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)
................................................................................
            [list EditPrefRegsubUpdate $top]
}

# Editor for one item in ::Pref(preprocessn)
proc EditPrefRegsub {top item} {
    set w $top.prefregsub

    ToplevelForce $w "Preferences: Preprocess group"

    # Buttons
    ttk::frame $w.fb1 -padding 3
    ttk::button $w.fb1.b1 -text "Add" -command [list AddPrefRegsub $top $w Generic]
    addBalloon $w.fb1.b1 "Add generic pattern"
    ttk::button $w.fb1.b2 -text "Add Subst" -command [list AddPrefRegsub $top $w Subst]
    addBalloon $w.fb1.b2 "Add using substitution shortcut"
    ttk::button $w.fb1.b3 -text "Add Prefix" -command [list AddPrefRegsub $top $w Prefix]
    addBalloon $w.fb1.b3 "Add using prefix shortcut"
    grid $w.fb1.b1 $w.fb1.b2 $w.fb1.b3 -sticky we -ipadx 5 -padx 3 -pady 3
    grid columnconfigure $w.fb1 all -uniform a
    grid anchor $w.fb1 w

    # Result example part
    if {![info exists ::eskil($top,prefregexa)]} {
        set ::eskil($top,prefregexa) \
                "An example TextString FOR_REGSUB /* Comment */"
        set ::eskil($top,prefregexa2) \
                "An example TextString FOR_REGSUB /* Comment */"
    }
    ttk::labelframe $w.res -text "Preprocessing result" -padding 3
    ttk::label $w.res.l3 -text "Example 1:" -anchor "w"
    ttk::entryX $w.res.e3 -textvariable ::eskil($top,prefregexa) -width 60
    ttk::label $w.res.l4l -text "Result 1 L:" -anchor "w"
    ttk::label $w.res.l4r -text "Result 1 R:" -anchor "w"
    ttk::label $w.res.e4l -textvariable ::eskil($top,prefregresultl) \
            -anchor "w" -width 10
    ttk::label $w.res.e4r -textvariable ::eskil($top,prefregresultr) \
            -anchor "w" -width 10
    ttk::label $w.res.l5 -text "Example 2:" -anchor "w"
    ttk::entryX $w.res.e5 -textvariable ::eskil($top,prefregexa2)
    ttk::label $w.res.l6l -text "Result 2 L:" -anchor "w"
    ttk::label $w.res.l6r -text "Result 2 R:" -anchor "w"
    ttk::label $w.res.e6l -textvariable ::eskil($top,prefregresultl2) \
            -anchor "w" -width 10
    ttk::label $w.res.e6r -textvariable ::eskil($top,prefregresultr2) \
            -anchor "w" -width 10

    grid $w.res.l3  $w.res.e3  -sticky we -padx 3 -pady 3
    grid $w.res.l4l $w.res.e4l -sticky we -padx 3 -pady 3
    grid $w.res.l4r $w.res.e4r -sticky we -padx 3 -pady 3
    grid $w.res.l5  $w.res.e5  -sticky we -padx 3 -pady 3
    grid $w.res.l6l $w.res.e6l -sticky we -padx 3 -pady 3
    grid $w.res.l6r $w.res.e6r -sticky we -padx 3 -pady 3
    grid columnconfigure $w.res 1 -weight 1

    # Buttons
    ttk::frame $w.fb -padding 3
    ttk::button $w.fb.b1 -text "Ok"     -command [list EditPrefRegsubOk $top $w $item]
    ttk::button $w.fb.b2 -text "Apply"  -command [list EditPrefRegsubOk $top $w $item 1]
    ttk::button $w.fb.b3 -text "Cancel" -command [list destroy $w]
................................................................................
    set ::widgets($top,prefRegsubApply) $w.fb.b2

    grid $w.fb.b1 x $w.fb.b2 x $w.fb.b3 -sticky we
    grid columnconfigure $w.fb {0 2 4} -uniform a
    grid columnconfigure $w.fb {1 3} -weight 1

    # Top layout
    pack $w.fb1 -side "top" -fill x -padx 3 -pady 3
    pack $w.fb $w.res -side bottom -fill x -padx 3 -pady 3

    # Fill in existing or an empty line
    set preprocess $::TmpPref(preprocess,re,$item)

    if {[llength $preprocess] == 0} {
        AddPrefRegsub $top $w Generic
    } else {
        set t 1
        foreach {RE Sub side} $preprocess {
            set ::eskil($top,prefregexp$t) $RE
            set ::eskil($top,prefregsub$t) $Sub
            set ::eskil($top,prefregleft$t) 0
            set ::eskil($top,prefregright$t) 0
            set ::eskil($top,prefregtype$t) Generic
            if {$side in {Subst Prefix}} {
                set ::eskil($top,prefregtype$t) $side
            } else {
                if {$side eq "" || $side eq "left"} {
                    set ::eskil($top,prefregleft$t) 1
                }
                if {$side eq "" || $side eq "right"} {
                    set ::eskil($top,prefregright$t) 1
                }
            }
            AddPrefRegsub $top $w
            incr t
        }
    }

    trace add variable ::eskil($top,prefregexa) write \
................................................................................
    if {![info exists ::TmpPref(preprocess,name,$r)]} {
        set ::TmpPref(preprocess,name,$r) ""
        set ::TmpPref(preprocess,active,$r) 0
        set ::TmpPref(preprocess,save,$r) 0
        set ::TmpPref(preprocess,re,$r) ""
    }
    ttk::entry $w.fp.ne$r -textvariable ::TmpPref(preprocess,name,$r)
    addBalloon $w.fp.ne$r "Name of preprocess group (optional)"
    ttk::checkbutton $w.fp.cba$r -text "Active" \
            -variable ::TmpPref(preprocess,active,$r)
    addBalloon $w.fp.cba$r "Activate group for this session"
    ttk::checkbutton $w.fp.cbs$r -text "Save" \
            -variable ::TmpPref(preprocess,save,$r)
    addBalloon $w.fp.cbs$r "Save group when preferences are saved"
    ttk::button $w.fp.be$r -text "Edit" \
            -command [list EditPrefRegsub $w $r]
    addBalloon $w.fp.be$r "Edit the associated list of regexps"
    ttk::button $w.fp.bu$r -image $::img(up) \
            -command [list EditPrefPreUp $r]
    addBalloon $w.fp.bu$r "Move group up in list"
    grid $w.fp.ne$r $w.fp.cba$r $w.fp.cbs$r $w.fp.be$r $w.fp.bu$r -sticky we \
            -padx 3 -pady 3
    # Make buttons symmetric
    grid  $w.fp.be$r $w.fp.bu$r -sticky news

    set ::TmpPref(preprocess,n) $r
}
................................................................................
        EditPrefPreprocessAddItem $w
    }

    # Frame for action buttons
    ttk::frame $w.fa -padding 3
    ttk::button $w.fa.b1 -text "Add" \
            -command [list EditPrefPreprocessAddItem $w]
    addBalloon $w.fa.b1 "Add a preprocess group"

    grid $w.fa.b1 -sticky we
    grid columnconfigure $w.fa {0 2 4} -uniform a
    grid columnconfigure $w.fa {1 3} -weight 1

    
    # Frame for dialog Buttons