Eskil

Check-in [bafe8468f1]
Login

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

Overview
Comment:PsMenu can store entry reconfig info. Subst on any value.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: bafe8468f1ef5b0400302d7394729fd6351a130cf1997c4175ab5f9c6938db87
User & Date: peter 2024-09-08 14:10:10.360
Context
2024-09-08
20:52
Rebuilt main menus to psmenu. Changed psmenu to use options. Removed experiemental filter from debug. check-in: 6bf27462d4 user: peter tags: trunk
14:10
PsMenu can store entry reconfig info. Subst on any value. check-in: bafe8468f1 user: peter tags: trunk
12:48
Improved window browser with menu items. Cleaner exit. check-in: 6a713b1c5a user: peter tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to eskil.vfs/lib/psmenu-1.0.tm.
28
29
30
31
32
33
34

35
36
37
38
39
40
41
    # Thus \-newline are not strictly necessary.
    # For compactness, options are kept short
    # -ul  for -underline
    #          "&File"-syntax supported for label
    # -var for -variable
    #          Variable is initialised if not existing
    #          If used with cascade, store menu widget in var

    # -cmd for -command
    #          command part is put through "subst"
    # -acc for -accelerator
    #          Will bind <Key-acc> to command unless -accelerator
    # -def for default value of -var
    #          checkbuttons default to default 0
    #          radiobuttons default to first value seen







>







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
    # Thus \-newline are not strictly necessary.
    # For compactness, options are kept short
    # -ul  for -underline
    #          "&File"-syntax supported for label
    # -var for -variable
    #          Variable is initialised if not existing
    #          If used with cascade, store menu widget in var
    # -cfgvar  Store entryconfigure command in var
    # -cmd for -command
    #          command part is put through "subst"
    # -acc for -accelerator
    #          Will bind <Key-acc> to command unless -accelerator
    # -def for default value of -var
    #          checkbuttons default to default 0
    #          radiobuttons default to first value seen
132
133
134
135
136
137
138

139
140
141
142
143
144
145
146
                    incr t 2
                    set value [lindex $body $t]
                } else {
                    set value $label
                }
                lappend radioDef $label -value $value {*}$options
            }


            # Prepend
            set def [list {*}$radioDef {*}$def]
            # TBD FIXA
            continue
        }

        # Conditionals







>
|







133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
                    incr t 2
                    set value [lindex $body $t]
                } else {
                    set value $label
                }
                lappend radioDef $label -value $value {*}$options
            }
            #puts "RADIO '$radioDef'"
            
            # Prepend
            set def [list {*}$radioDef {*}$def]
            # TBD FIXA
            continue
        }

        # Conditionals
193
194
195
196
197
198
199

200
201

202
203
204
205
206
207
208
209
210
211
212
213



214
215
216
217
218
219
220
221
222
        if {$label ne ""} {
            lappend newOptions -label $label
        }
        set doBind ""
        set command ""
        set value ""
        set variable ""

        set default 0
        foreach {opt val} $options {

            switch -- $opt {
                -ul - -underline {
                    lappend newOptions -underline $val
                }
                -var - -variable {
                    if {$type eq "cascade"} {
                        set variable $val
                    } else {
                        set variable $val
                        lappend newOptions -variable $val
                    }
                }



                -cmd - -command {
                    set val [uplevel \#$Level [list subst $val]]
                    set command $val
                    lappend newOptions -command $val
                }
                -acc {
                    lappend newOptions -accelerator $val
                    set doBind $val
                }







>


>












>
>
>

<







195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221

222
223
224
225
226
227
228
        if {$label ne ""} {
            lappend newOptions -label $label
        }
        set doBind ""
        set command ""
        set value ""
        set variable ""
        set cfgvar ""
        set default 0
        foreach {opt val} $options {
            set val [uplevel \#$Level [list subst $val]]
            switch -- $opt {
                -ul - -underline {
                    lappend newOptions -underline $val
                }
                -var - -variable {
                    if {$type eq "cascade"} {
                        set variable $val
                    } else {
                        set variable $val
                        lappend newOptions -variable $val
                    }
                }
                -cfgvar {
                    set cfgvar $val
                }
                -cmd - -command {

                    set command $val
                    lappend newOptions -command $val
                }
                -acc {
                    lappend newOptions -accelerator $val
                    set doBind $val
                }
255
256
257
258
259
260
261






262
263
264



265
266
267
268
269
270
271
            if {![info exists __vv]} {
                set __vv $default
            }
        }

        # TK helper to handle & in label
        ::tk::AmpMenuArgs $m add $type {*}$newOptions







        if {$doBind ne ""} {
            if {[regexp {^(.*)-(.*)$} $doBind -> pre post]} {



                set doBind $pre-Key-$post
            } else {
                set doBind Key-$doBind
            }
            #puts "Binding '$doBind' '$command'"
            bind $Toplevel <$doBind> $command
        }







>
>
>
>
>
>



>
>
>







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
            if {![info exists __vv]} {
                set __vv $default
            }
        }

        # TK helper to handle & in label
        ::tk::AmpMenuArgs $m add $type {*}$newOptions

        if {$cfgvar ne ""} {
            set ix [$m index end]
            set tmp [list $m entryconfigure $ix]
            uplevel \#$Level [list set $cfgvar $tmp]
        }

        if {$doBind ne ""} {
            if {[regexp {^(.*)-(.*)$} $doBind -> pre post]} {
                if {$pre eq "Ctrl"} {
                    set pre "Control"
                }
                set doBind $pre-Key-$post
            } else {
                set doBind Key-$doBind
            }
            #puts "Binding '$doBind' '$command'"
            bind $Toplevel <$doBind> $command
        }