Eskil

Check-in [42fcdf1d94]
Login

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

Overview
Comment:Syntax check cleanup
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 42fcdf1d9467e99e3a6580bc8fd23a860ece57c677ab7d8adc7060d670499016
User & Date: peter 2024-10-02 18:25:30.200
Context
2024-10-02
18:50
Moved debug to module check-in: 3d33ff0139 user: peter tags: trunk
18:25
Syntax check cleanup check-in: 42fcdf1d94 user: peter tags: trunk
2024-09-08
21:32
Use tcl9 friendly format for package check-in: 9950d1e608 user: peter tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to Makefile.
130
131
132
133
134
135
136





137
138
139
140
141
142
143
newsrc: eskil.vfs/src/eskil.tcl

src/TAGS: $(SRCFILES)
	etags -o src/TAGS --regex="/proc[ \t]+\([^ \t]+\)/\1/" $(SRCFILES) \
	eskil.vfs/lib/*/*.tcl

setup: links src/TAGS






# Use this to rebuild the docs when command line changes or
# new wiki files are added.
docs:
	echo "<title>Usage</title>" > htdocs/usage.wiki
	echo "" >> htdocs/usage.wiki
	echo "<h1>Command Line Usage</h1>" >> htdocs/usage.wiki







>
>
>
>
>







130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
newsrc: eskil.vfs/src/eskil.tcl

src/TAGS: $(SRCFILES)
	etags -o src/TAGS --regex="/proc[ \t]+\([^ \t]+\)/\1/" $(SRCFILES) \
	eskil.vfs/lib/*/*.tcl

setup: links src/TAGS

# Check modules against local copies
tmcheck:
	@ls -ltr `find . -name '*.tm'` `find /home/peter/mystuff -name '*.tm'`


# Use this to rebuild the docs when command line changes or
# new wiki files are added.
docs:
	echo "<title>Usage</title>" > htdocs/usage.wiki
	echo "" >> htdocs/usage.wiki
	echo "<h1>Command Line Usage</h1>" >> htdocs/usage.wiki
154
155
156
157
158
159
160
161
162

163
164
165
166
167
168
169
# Testing
#----------------------------------------------------------------

spell:
	@cat doc/*.txt | ispell -d british -l | sort -u

CHKFILES = $(SRCFILES) $(wildcard plugins/*.tcl) \
	eskil.vfs/lib/psballoon/psballoon.tcl \
	eskil.vfs/lib/pstools/pstools.tcl

NAGELFARFLAGS = -s syntaxdb.tcl -pkgpicky -filter "*Non constant definition*" -quiet -plugin nfplugin.tcl

# Create a common "header" file for all source files.
eskil_h.syntax: $(SRCFILES) src/eskil.syntax nfplugin.tcl
	@echo Creating syntax header file...
	@$(NAGELFAR) $(NAGELFARFLAGS) -header eskil_h.syntax $(SRCFILES)








|
|
>







159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# Testing
#----------------------------------------------------------------

spell:
	@cat doc/*.txt | ispell -d british -l | sort -u

CHKFILES = $(SRCFILES) $(wildcard plugins/*.tcl) \
	eskil.vfs/lib/psmenu-1.1.tm \
	eskil.vfs/lib/pstools-1.0.tm \
	eskil.vfs/lib/psballoon-1.3.tm
NAGELFARFLAGS = -s syntaxdb.tcl -pkgpicky -filter "*Non constant definition*" -quiet -plugin nfplugin.tcl

# Create a common "header" file for all source files.
eskil_h.syntax: $(SRCFILES) src/eskil.syntax nfplugin.tcl
	@echo Creating syntax header file...
	@$(NAGELFAR) $(NAGELFARFLAGS) -header eskil_h.syntax $(SRCFILES)

Changes to eskil.vfs/lib/psballoon-1.3.tm.
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
    set msg [regsub -all "\n" $msg " "]
    # Remove multiple whitespace
    set msg [regsub -all {\s+} $msg " "]
    set msg [string trim $msg]
    # Any explicitly requested newlines?
    set msg [regsub -all {\\n\s*} $msg "\n"]
    # Any remaining substs like tabs?
    set msg [subst -nocommand -novariable $msg]
    # Further line breaks by length?
    set lines {}
    foreach line [split $msg \n] {
        while {[string length $line] > 80} {
            # There should be no path through this loop that does not
            # shorten $line
            set ix [string last " " $line 80]







|







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
    set msg [regsub -all "\n" $msg " "]
    # Remove multiple whitespace
    set msg [regsub -all {\s+} $msg " "]
    set msg [string trim $msg]
    # Any explicitly requested newlines?
    set msg [regsub -all {\\n\s*} $msg "\n"]
    # Any remaining substs like tabs?
    set msg [subst -nocommands -novariables $msg]
    # Further line breaks by length?
    set lines {}
    foreach line [split $msg \n] {
        while {[string length $line] > 80} {
            # There should be no path through this loop that does not
            # shorten $line
            set ix [string last " " $line 80]
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
    } else {
        if {[string index $msg 0] eq "\["} {
            set msg [subst -novariables -nobackslashes $msg]
        }
        set bWidth [Measure $font $msg]
    }

    if {!$create} return

    # Preferred position of the balloon
    set rootX [expr {[winfo rootx $W] + $itemX}]
    set rootY [expr {[winfo rooty $W] + $itemY + $wHeight + 2}]

    set useframe $balloon(frame,$W)








|







285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
    } else {
        if {[string index $msg 0] eq "\["} {
            set msg [subst -novariables -nobackslashes $msg]
        }
        set bWidth [Measure $font $msg]
    }

    if { ! $create} return

    # Preferred position of the balloon
    set rootX [expr {[winfo rootx $W] + $itemX}]
    set rootY [expr {[winfo rooty $W] + $itemY + $wHeight + 2}]

    set useframe $balloon(frame,$W)

Changes to eskil.vfs/lib/psmenu-1.1.tm.
76
77
78
79
80
81
82



83
84
85
86
87
88
89
    # More calls with more cascades work
    psmenu::psmenu . {
        "&Debug" {
            "Reread &Source" -acc F1 -cmd _rs
        }
    }
}




# Main call for psmenu. Some optional arguments are for internal use.
# Canbe called with an existing menu, but then -top must be given.
proc psmenu::psmenu {top args} {
    set def [lindex $args end]
    set args [lrange $args 0 end-1]








>
>
>







76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
    # More calls with more cascades work
    psmenu::psmenu . {
        "&Debug" {
            "Reread &Source" -acc F1 -cmd _rs
        }
    }
}

##nagelfar syntax psmenu::PopEntry v
##nagelfar syntax tk::AmpMenuArgs x*

# Main call for psmenu. Some optional arguments are for internal use.
# Canbe called with an existing menu, but then -top must be given.
proc psmenu::psmenu {top args} {
    set def [lindex $args end]
    set args [lrange $args 0 end-1]

105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
            set top $opts(-top)
        }
    }

    if {$opts(-recursive)} {
        # Locate a free window name for the menu, for internal call
        while {[winfo exists $m]} {
            if {[regexp {^(.*?)(\d+)$} $m -> prefix index]} {
                incr index
            } else {
                set prefix $m
                set index 0
            }
            set m $prefix$index
        }
    }
    # It might exist for a second user call
    if { ! [winfo exists $m]} {
        # Create
        menu $m -tearoff 0
    }







|
|


|

|







108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
            set top $opts(-top)
        }
    }

    if {$opts(-recursive)} {
        # Locate a free window name for the menu, for internal call
        while {[winfo exists $m]} {
            if {[regexp {^(.*?)(\d+)$} $m -> prefix Index]} {
                incr Index
            } else {
                set prefix $m
                set Index 0
            }
            set m $prefix$Index
        }
    }
    # It might exist for a second user call
    if { ! [winfo exists $m]} {
        # Create
        menu $m -tearoff 0
    }
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
                    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







|







155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
                    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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
        #puts "Label   '$label'"
        #puts "Options '$options'"
        # Figure out type
        if {[string match "-*" $label]} {
            set type separator
            set label ""
        } elseif {[dict exists $options -menu]} {
            set type cascade
        } elseif {[dict exists $options -value]} {
            set type radiobutton
        } elseif {[dict exists $options -var]} {
            set type checkbutton
        } else {
            set type command
        }







|







199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
        #puts "Label   '$label'"
        #puts "Options '$options'"
        # Figure out type
        if {[string match "-*" $label]} {
            set type separator
            set label ""
        } elseif {[dict exists $options -menu]} {
            set type "cascade"
        } elseif {[dict exists $options -value]} {
            set type radiobutton
        } elseif {[dict exists $options -var]} {
            set type checkbutton
        } else {
            set type command
        }
271
272
273
274
275
276
277

278
279
280
281
282
283
284
285
286
                    # Just let through
                    lappend newOptions $opt $val
                }
            }
        }

        if {$variable ne ""} {

            upvar \#$opts(-level) $variable __vv
            if {![info exists __vv]} {
                set __vv $default
            }
        }

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








>

|







274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
                    # Just let through
                    lappend newOptions $opt $val
                }
            }
        }

        if {$variable ne ""} {
            ##nagelfar ignore Non constant level
            upvar \#$opts(-level) $variable __vv
            if { ! [info exists __vv]} {
                set __vv $default
            }
        }

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

Changes to eskil.vfs/lib/pstools-1.0.tm.
1
2
3
4
5
6
7
8
#----------------------------------------------------------------------
#
#  pstools.tcl,
#     a package providing misc facilites
#
#  Copyright (c) 2003, Peter Spjuth  (peter.spjuth@gmail.com)
#
#  Permission is granted to use this code under the same terms as
|







1
2
3
4
5
6
7
8
#---------------------------------------------------------*-tcl-*------
#
#  pstools.tcl,
#     a package providing misc facilites
#
#  Copyright (c) 2003, Peter Spjuth  (peter.spjuth@gmail.com)
#
#  Permission is granted to use this code under the same terms as
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
61

##nagelfar syntax _ipexists l
##nagelfar syntax _ipset    v
##nagelfar syntax _iparray  s v

# Load a preference file
# Args lists the variables allowed to be set by the file


proc pstools::safeLoad {file args} {

    interp create -safe loadinterp
    interp alias {} _ipexists loadinterp info exists
    interp alias {} _ipset    loadinterp set
    interp alias {} _iparray  loadinterp array

    interp invokehidden loadinterp source $file


    foreach arg $args {




        ##nagelfar vartype arg varName
        upvar 1 $arg TheVar
        if {[_iparray exists $arg]} {
            foreach {key val} [_iparray get $arg] {
                if {[info exists TheVar($key)]} {
                    set TheVar($key) $val
                }
            }
        } elseif {[_ipexists $arg]} {
            if {[info exists TheVar]} {
                set TheVar [_ipset $arg]
            }
        }
    }

    interp delete loadinterp
}







>
>









>

>
>
>
>




|




|







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
61
62
63
64
65
66
67
68

##nagelfar syntax _ipexists l
##nagelfar syntax _ipset    v
##nagelfar syntax _iparray  s v

# Load a preference file
# Args lists the variables allowed to be set by the file
# If -existing is given, only existing variables and elements may be set
##nagelfar syntax pstools::safeLoad x o* v*
proc pstools::safeLoad {file args} {

    interp create -safe loadinterp
    interp alias {} _ipexists loadinterp info exists
    interp alias {} _ipset    loadinterp set
    interp alias {} _iparray  loadinterp array

    interp invokehidden loadinterp source $file

    set existing 0
    foreach arg $args {
        if {$arg eq "-existing"} {
            set existing 1
            continue
        }
        ##nagelfar vartype arg varName
        upvar 1 $arg TheVar
        if {[_iparray exists $arg]} {
            foreach {key val} [_iparray get $arg] {
                if { ! $existing || [info exists TheVar($key)]} {
                    set TheVar($key) $val
                }
            }
        } elseif {[_ipexists $arg]} {
            if { ! $existing || [info exists TheVar]} {
                set TheVar [_ipset $arg]
            }
        }
    }

    interp delete loadinterp
}
Changes to src/startup.tcl.
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
    while {[file type $tmplink] eq "link"} {
        set tmplink [file readlink $tmplink]
        set tmplink [file normalize [file join $::eskil(thisDir) $tmplink]]
        set ::eskil(thisDir) [file dirname $tmplink]
    }

    set libDir [file join $::eskil(thisDir) .. lib]
    if {![file isdirectory $libDir]} {
        # Try the local file from devel
        set libDir [file join $::eskil(thisDir) .. eskil.vfs lib]
    }
    ::tcl::tm::path add $libDir

    package require pstools
    namespace import -force pstools::*







|







1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
    while {[file type $tmplink] eq "link"} {
        set tmplink [file readlink $tmplink]
        set tmplink [file normalize [file join $::eskil(thisDir) $tmplink]]
        set ::eskil(thisDir) [file dirname $tmplink]
    }

    set libDir [file join $::eskil(thisDir) .. lib]
    if { ! [file isdirectory $libDir]} {
        # Try the local file from devel
        set libDir [file join $::eskil(thisDir) .. eskil.vfs lib]
    }
    ::tcl::tm::path add $libDir

    package require pstools
    namespace import -force pstools::*