📄 autorun.tcl
字号:
proc tornadoAutoRun@@productSelect {} {
global previewProducts
global previewKeyList
set nProducts [llength $previewProducts]
if {$nProducts < 1} {
# this should never happen
} elseif {$nProducts == 1} {
set product [lindex $previewProducts 0]
regexp {^([^ ]+)[ ]+.+$} $product dummy previewKeyList
} else {
dialogCreate \
-name previewDialog@@ \
-title "Preview Product" \
-width 186 -height 82 \
-init previewDialog@@Init \
-nocontexthelp \
-controls { \
{ button -title "OK" -name IDOK -default \
-callback {
previewDialog@@OnOk previewKeyList
} \
-xpos 7 -ypos 61 -width 50 -height 14 \
}
{ button -title "Cancel" -name IDCANCEL \
-xpos 63 -ypos 61 -width 50 -height 14 \
-callback previewDialog@@OnCancel \
}
{ checklist -name productList \
-xpos 6 -ypos 6 -width 174 -height 53 \
-callback previewDialog@@OnSelection \
-nointegralheight \
}
}
}
# Start the preview, if user didn't cancel
if {$previewKeyList != ""} {
previewPageLayoutPrepare $previewKeyList
}
}
proc previewDialog@@Init {} {
global previewProducts
# Get key/desc tuple for all products, then put desc
# in list
set products ""
foreach vp $previewProducts {
lappend products [list [join [lrange [split $vp] 1 end]] 1]
}
controlValuesSet previewDialog@@.productList $products
# Update the OK button
previewDialog@@OnSelection
}
proc previewDialog@@OnOk {_previewKeyList} {
upvar $_previewKeyList previewKeyList
# Get user's product choice
set productDescriptions ""
foreach item [controlValuesGet previewDialog@@.productList -string] {
if {[lindex $item 1] == 1} {
lappend productDescriptions [lindex $item 0]
}
}
windowClose previewDialog@@
# Map the product descriptions to the keys (directory names)
set keyVals ""
beginWaitCursor
if {![catch {setupUnzip -p [archiveGet] autoRunInfo} info]} {
# Turn contents of autoRunInfo into a list
regsub -all \015 $info "" info
set info [split $info \n]
if {[lindex $info [expr [llength $info] - 1]] == ""} {
set info [lrange $info 0 [expr [llength $info] - 2]]
}
foreach line $info {
foreach productDesc $productDescriptions {
if {![string compare [join [lrange $line 1 end]] \
$productDesc]} {
lappend previewKeyList [lindex $line 0]
break
}
}
}
}
endWaitCursor
# previewKeyList is passed back to tornadoAutoRun@@productSelect
}
proc previewDialog@@OnCancel {} {
global previewKeyList
windowClose previewDialog@@
set previewKeyList ""
}
proc previewDialog@@OnSelection {} {
set bEnable 0
foreach item [controlValuesGet previewDialog@@.productList -string] {
if {[lindex $item 1] == 1} {
set bEnable 1
}
}
if {$bEnable != 0} {
controlEnable previewDialog@@.IDOK 1
} else {
controlEnable previewDialog@@.IDOK 0
}
# Process double-click
if {![string compare [lindex [eventInfoGet previewDialog@@] 0] dblclk]} {
previewDialog@@OnOk
}
}
# Create list of previewable products
# Steps:
# Read autoRunInfo from WIND.000
# For each <directory> item in the first column, search WIND.000 for
# <directory>/*.bmp or <directory>/*.BMP
# Matches indicate a product is previewable
# Use 2nd through last items from autoRunInfo entry as descriptive
# field to be added to listbox
#
proc previewProductsEnumerate {archive} {
set previewDirList ""
set productList ""
set info ""
beginWaitCursor
if {![catch {setupUnzip -p $archive autoRunInfo} info]} {
# Turn contents of autoRunInfo into a list
regsub -all \015 $info "" info
set info [split $info \n]
if {[lindex $info [expr [llength $info] - 1]] == ""} {
set info [lrange $info 0 [expr [llength $info] - 2]]
}
# Search WIND.000 for bitmaps
# Line looks like:
# 63070 01-20-96 14:02 tornado/002.bmp
foreach infoLine $info {
set infoDir [lindex $infoLine 0]
if {![catch {setupUnzip -l $archive "$infoDir/*.*"} bitmaps]} {
set bitmaps [split $bitmaps \n]
set tmpLineList ""
foreach line $bitmaps {
set line [split $line]
set bitmapDir ""
foreach tmpElem $line {
if {![string compare [string tolower [file extension \
$tmpElem]] ".bmp"]} {
regexp {^([^/]+)/([0-9]+\.[bmpBMP]+)$} \
$tmpElem dummy bitmapDir bitmapFile
# We have a match; if it's not aleady in our
# list, add it
if {[lsearch $previewDirList $bitmapDir] == -1} {
lappend previewDirList $bitmapDir
lappend productList $infoLine
}
}
}
}
}
}
}
endWaitCursor
return $productList
}
#
# Return root of image tree based on path of uitclsh.exe,
# terminated by '\'
#
proc CDDriveGet {} {
set remainder [info nameofexecutable]
set drive ""
regsub -all {/} $remainder {\\} remainder
# Check for UNC
set index [string first "\\" $remainder]
if {$index != -1} {
# Parse out UNC segment with '\\' intact
set uncSeg $remainder
set remainder [string range $remainder 2 end]
set index [string first "\\" $remainder]
set drive [string range $uncSeg 0 [expr $index + 2]]
set remainder [string range $remainder [expr $index + 1] end]
}
# Set remainder to a list describing the image root
set remainder [file split $remainder]
set remainder [lrange $remainder 0 [expr [llength $remainder] - 4]]
# String remainder back into a '\' separated path, ending in '\'
foreach elem $remainder {
set drive "$drive$elem\\"
}
return $drive
}
#
# Return fully qualified path to archive (zip) file
#
proc archiveGet {} {
set drive [CDDriveGet]
return [format "%sWIND/WIND.000" $drive]
}
#
# Return path location for -- or to which -- files have been
# extracted. If we can't find TMP or TEMP, create c:/TMP
#
proc tempDirGet {} {
global env
global tempDir
if {$tempDir == ""} {
set envList [array names env]
foreach var $envList {
if {![string compare [string tolower $var] tmp]} {
set tempDir $env($var)
break
} elseif {![string compare [string tolower $var] temp]} {
set tempDir $env($var)
break
}
}
# If we can't find TMP, then create it
if {$tempDir == ""} {
if [file mkdir c:/TMP] {
set env(TMP) c:/TMP
set tempDir c:/TMP
}
}
}
# Must end in '/'
regsub -all {\\} $tempDir / tempDir
if {[string index $tempDir [expr [string length $tempDir] - 1]] != "/"} {
set tempDir "$tempDir/"
}
return $tempDir
}
#
# Return 1 if file exists or was successfully extracted from the archive,
# 0 if file couldn't be extracted
proc previewBitmapGet {bitmapFile archive} {
if {[file exists $bitmapFile]} {
return 1
} elseif {![catch {setupUnzip -d [tempDirGet] $archive $bitmapFile} \
errorMsg]} {
return 1
} else {
return 0
}
}
#
# Returns a list of products that can be previewed,
# with elements of the form: <directoryName> <description>
#
proc previewBitmapsEnumerate {productKey archive} {
set bitmapList ""
beginWaitCursor
if {[catch {setupUnzip -l $archive "$productKey/*.bmp"} bitmaps]} {
if {[catch {setupUnzip -l $archive "$productKey/*.BMP"} bitmaps]} {
set bitmaps ""
}
}
endWaitCursor
if {$bitmaps != ""} {
set bitmaps [split $bitmaps \n]
set tmpLineList ""
foreach line $bitmaps {
set line [split $line]
set bitmapDir ""
foreach tmpElem $line {
if {![string compare [string tolower [file extension \
$tmpElem]] ".bmp"]} {
lappend bitmapList $tmpElem
}
}
}
}
return $bitmapList
}
proc tornadoAutoRun@@previewPageTitleSet {} {
global nPreviewBitmaps
global nthPreviewBitmapShow
global previewProductName
set pos [expr $nthPreviewBitmapShow + 1]
set of $nPreviewBitmaps
windowTitleSet tornadoAutoRun@@ \
"Preview of $previewProductName ($pos of $of)"
}
catch {tornadoAutoRunShow}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -