Eskil

Check-in [afd4e79405]
Login

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

Overview
Comment:Adjusted preprocess dialog
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: afd4e79405dec521b767ea34aa344a90d31f89cd
User & Date: peter 2017-02-09 22:52:22.307
Context
2017-03-16
13:50
Comment check-in: 62cd4fd2c4 user: peter tags: trunk
2017-02-09
22:52
Adjusted preprocess dialog check-in: afd4e79405 user: peter tags: trunk
22:43
Fixed resourcing for debug check-in: 328325a47e user: peter tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/preprocess.tcl.
51
52
53
54
55
56
57



58
59
60
61
62
63
64
}

# Get the value used when saving preferences
proc getPreprocessSave {} {
    set res {}
    foreach {name data} $::Pref(preprocessn) {
        if {[dict get $data save]} {



            lappend res $name $data
        }
    }
    return $res
}

# This is called when Ok or Apply is pressed.







>
>
>







51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
}

# Get the value used when saving preferences
proc getPreprocessSave {} {
    set res {}
    foreach {name data} $::Pref(preprocessn) {
        if {[dict get $data save]} {
            # Always save with active 0 for now.
            # A user can edit the save file to have it by default.
            dict set data active 0
            lappend res $name $data
        }
    }
    return $res
}

# This is called when Ok or Apply is pressed.
309
310
311
312
313
314
315















316
317
318
319
320
321
322
323
324
325
326

327
328

329
330

331
332




333
334


335
336
337
338
339
340
341

# Create a toplevel, even if it exists
proc ToplevelForce {w title} {
    destroy $w
    ttk::toplevel $w -padx 3 -pady 3
    wm title $w $title
}
















proc EditPrefPreprocessAddItem {w} {
    set r $::TmpPref(preprocess,n)
    incr r
    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)

    ttk::checkbutton $w.fp.cba$r -text "Active" \
            -variable ::TmpPref(preprocess,active,$r)

    ttk::checkbutton $w.fp.cbs$r -text "Save" \
            -variable ::TmpPref(preprocess,save,$r)

    ttk::button $w.fp.be$r -text "Edit" \
            -command [list EditPrefRegsub $w $r]




    grid $w.fp.ne$r $w.fp.cba$r $w.fp.cbs$r $w.fp.be$r -sticky we \
            -padx 3 -pady 3



    set ::TmpPref(preprocess,n) $r
}

proc EditPrefPreprocess {top} {
    set w $top.prefpreprocess








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











>


>


>


>
>
>
>
|

>
>







312
313
314
315
316
317
318
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
358
359
360
361
362
363
364
365
366
367
368

# Create a toplevel, even if it exists
proc ToplevelForce {w title} {
    destroy $w
    ttk::toplevel $w -padx 3 -pady 3
    wm title $w $title
}

# Move an item one step up
proc EditPrefPreUp {r} {
    puts EditPrefPreUp$r
    # Sanity check
    if {$r <= 1 || $r > $::TmpPref(preprocess,n)} {
        return
    }
    set p [expr {$r - 1}]
    foreach item {name active save re} {
        set tmp $::TmpPref(preprocess,$item,$r)
        set ::TmpPref(preprocess,$item,$r) $::TmpPref(preprocess,$item,$p)
        set ::TmpPref(preprocess,$item,$p) $tmp
    }
}

proc EditPrefPreprocessAddItem {w} {
    set r $::TmpPref(preprocess,n)
    incr r
    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
}

proc EditPrefPreprocess {top} {
    set w $top.prefpreprocess

355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379

380
381
382
383
384
385
386
    set ::TmpPref(preprocess,n) 0
    set nItems $r

    ToplevelForce $w "Preferences: Preprocess"

    # Frame for List of preprocessing
    ttk::frame $w.fp -padding 3

    # Heading labels for columns
    ttk::label $w.fp.hl1 -text "Name"
    addBalloon $w.fp.hl1 "Name of preprocess item"
    ttk::label $w.fp.hl2 -text "Active"
    addBalloon $w.fp.hl2 "Is item active for this session?"
    ttk::label $w.fp.hl3 -text "Saved"
    addBalloon $w.fp.hl3 "Is item saved with preferences?"

    grid $w.fp.hl1 $w.fp.hl2 $w.fp.hl3 -sticky we -padx 3 -pady 3
    
    for {set r 1} {$r <= $nItems} {incr 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







|
<
<
<
<
<
<
<
<
<







|
>







382
383
384
385
386
387
388
389









390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
    set ::TmpPref(preprocess,n) 0
    set nItems $r

    ToplevelForce $w "Preferences: Preprocess"

    # Frame for List of preprocessing
    ttk::frame $w.fp -padding 3
    grid columnconfigure $w.fp 0 -weight 1









    
    for {set r 1} {$r <= $nItems} {incr 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