|
|
|
|
|
|
|
|
|
namespace eval ::tkdnd { |
|
|
|
if {[info exists ::TKDND_DEBUG_LEVEL]} { |
|
variable _debug_level $::TKDND_DEBUG_LEVEL |
|
} elseif {[info exists ::env(TKDND_DEBUG_LEVEL)]} { |
|
variable _debug_level $::env(TKDND_DEBUG_LEVEL) |
|
} else { |
|
variable _debug_level 0 |
|
} |
|
|
|
|
|
|
|
|
|
proc debug_enabled { {level {}} } { |
|
variable _debug_level |
|
if {$level != {}} { |
|
if {[string is integer -strict $level]} { |
|
set _debug_level $level |
|
} elseif {[string is true $level]} { |
|
set _debug_level 1 |
|
} |
|
} |
|
return $_debug_level |
|
} |
|
|
|
|
|
|
|
|
|
proc source { filename { encoding utf-8 } } { |
|
variable _package_dir |
|
|
|
set dbg_lvl [debug_enabled] |
|
if {$dbg_lvl} { |
|
puts "tkdnd::source (debug level $dbg_lvl) $filename" |
|
set fd [open $filename r] |
|
fconfigure $fd -encoding $encoding |
|
set script [read $fd] |
|
close $fd |
|
set map {} |
|
for {set lvl 0} {$lvl <= $dbg_lvl} {incr lvl} { |
|
lappend map "#DBG$lvl " {} |
|
} |
|
lappend map {#DBG } {} |
|
set script [string map $map $script] |
|
return [eval $script] |
|
} |
|
::source -encoding $encoding $filename |
|
} |
|
|
|
} |
|
|
|
package ifneeded tkdnd 2.9.3 \ |
|
"tkdnd::source \{$dir/tkdnd.tcl\} ; \ |
|
tkdnd::initialise \{$dir\} libtkdnd2.9.3.dylib tkdnd" |
|
|
|
package ifneeded tkdnd::utils 2.9.3 \ |
|
"tkdnd::source \{$dir/tkdnd_utils.tcl\} ; \ |
|
package provide tkdnd::utils 2.9.3" |
|
|