summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2008-01-07 14:17:43 +0000
committermurphy <murphy@rubychan.de>2008-01-07 14:17:43 +0000
commitbbbbc70a0b2efcd03bbcaf4e08ac139e7969e608 (patch)
tree8eb543ee3633ebedd3746b5557c77df0e8612a2a /etc
parenta08d41bb16104ad52ecf612c81f75f531af87d25 (diff)
downloadcoderay-bbbbc70a0b2efcd03bbcaf4e08ac139e7969e608.tar.gz
Added etc/todo (scanner drafts) and two TextMate project files.
Diffstat (limited to 'etc')
-rw-r--r--etc/check-diffs.rb27
-rw-r--r--etc/coderay-lib.tmproj127
-rw-r--r--etc/coderay.tmproj108
-rw-r--r--etc/todo/example.applescript12997
-rw-r--r--etc/todo/example.lua8289
-rw-r--r--etc/todo/example.lua.zipbin0 -> 48755 bytes
-rw-r--r--etc/todo/latex.rb44
-rw-r--r--etc/todo/scanners.zipbin0 -> 18380 bytes
-rw-r--r--etc/todo/scanners/applescript-sebastian.rb219
-rw-r--r--etc/todo/scanners/avrasm.rb153
-rw-r--r--etc/todo/scanners/css.rb170
-rw-r--r--etc/todo/scanners/javascript.rb199
-rw-r--r--etc/todo/scanners/lisp.rb102
-rw-r--r--etc/todo/scanners/paste-333 (DIFF).rb88
-rw-r--r--etc/todo/scanners/paste-693 (IO).rb134
-rw-r--r--etc/todo/scanners/php.rb282
-rw-r--r--etc/todo/scanners/sql.rb138
-rw-r--r--etc/todo/scanners/vhdl.rb132
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/_darcs/checkpoints/index.html11
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/_darcs/index.html17
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/_darcs/index.html@C=D;O=A17
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/_darcs/index.html@C=M;O=A17
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/_darcs/index.html@C=N;O=D17
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/_darcs/index.html@C=S;O=A17
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/_darcs/inventories/index.html11
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/_darcs/inventory17
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/_darcs/patches/index.html18
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/_darcs/prefs/index.html16
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/_darcs/pristine/index.html13
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/index.html14
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/index.html@C=D;O=A14
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/index.html@C=D;O=D14
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/index.html@C=M;O=A14
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/index.html@C=M;O=D14
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/index.html@C=N;O=A14
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/index.html@C=N;O=D14
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/index.html@C=S;O=A14
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/index.html@C=S;O=D14
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/index.html12
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/index.html@C=D;O=A12
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/index.html@C=M;O=A12
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/index.html@C=N;O=D12
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/index.html@C=S;O=A12
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/latex.rb79
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html13
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=D;O=A13
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=D;O=D13
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=M;O=A13
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=M;O=D13
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=N;O=A13
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=N;O=D13
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=S;O=A13
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=S;O=D13
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/index.html13
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/index.html@C=D;O=A13
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/index.html@C=M;O=A13
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/index.html@C=N;O=D13
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/index.html@C=S;O=A13
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/javascript.rb199
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/javascript/index.html12
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/index.html12
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=D;O=A12
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=D;O=D12
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=M;O=A12
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=M;O=D12
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=N;O=A12
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=N;O=D12
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=S;O=A12
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=S;O=D12
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/test/index.html13
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/test/index.html@C=D;O=A13
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/test/index.html@C=M;O=A13
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/test/index.html@C=N;O=D13
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/test/index.html@C=S;O=A13
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/test/test_javascript_scanner.rb104
-rwxr-xr-xetc/todo/www.demiurgo.org/darcs/coderay/test/test_latex_encoder.rb103
76 files changed, 24418 insertions, 0 deletions
diff --git a/etc/check-diffs.rb b/etc/check-diffs.rb
new file mode 100644
index 0000000..8bc66ca
--- /dev/null
+++ b/etc/check-diffs.rb
@@ -0,0 +1,27 @@
+DIFF_PART = /
+^ ([\d,]+c[\d,]+) \n # change
+( (?: < .* \n )+ ) # old
+---\n
+( (?: > .* \n )+ ) # new
+/x
+
+class String
+ def undiff!
+ gsub!(/^./, '')
+ end
+end
+
+for diff in Dir['*.debug.diff']
+ puts diff
+ diff = File.read diff
+ diff.scan(/#{DIFF_PART}|(.+)/o) do |change, old, new, error|
+ raise error if error
+ old.undiff!
+ new.undiff!
+
+ new.gsub!('inline_delimiter', 'delimiter')
+ unless new == old
+ raise "\n>>>\n#{new}\n<<<#{old}\n"
+ end
+ end
+end \ No newline at end of file
diff --git a/etc/coderay-lib.tmproj b/etc/coderay-lib.tmproj
new file mode 100644
index 0000000..1801248
--- /dev/null
+++ b/etc/coderay-lib.tmproj
@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>documents</key>
+ <array>
+ <dict>
+ <key>expanded</key>
+ <true/>
+ <key>name</key>
+ <string>lib</string>
+ <key>regexFolderFilter</key>
+ <string>!.*/(\.[^/]*|CVS|_darcs|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
+ <key>sourceDirectory</key>
+ <string>../lib</string>
+ </dict>
+ <dict>
+ <key>name</key>
+ <string>bin</string>
+ <key>regexFolderFilter</key>
+ <string>!.*/(\.[^/]*|CVS|_darcs|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
+ <key>sourceDirectory</key>
+ <string>../bin</string>
+ </dict>
+ <dict>
+ <key>filename</key>
+ <string>../FOLDERS</string>
+ </dict>
+ <dict>
+ <key>filename</key>
+ <string>../ftp.yaml</string>
+ </dict>
+ <dict>
+ <key>name</key>
+ <string>gem_server</string>
+ <key>regexFolderFilter</key>
+ <string>!.*/(\.[^/]*|CVS|_darcs|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
+ <key>sourceDirectory</key>
+ <string>../gem_server</string>
+ </dict>
+ <dict>
+ <key>filename</key>
+ <string>../IDEA</string>
+ </dict>
+ <dict>
+ <key>filename</key>
+ <string>../LICENSE</string>
+ </dict>
+ <dict>
+ <key>name</key>
+ <string>pkg</string>
+ <key>regexFolderFilter</key>
+ <string>!.*/(\.[^/]*|CVS|_darcs|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
+ <key>sourceDirectory</key>
+ <string>../pkg</string>
+ </dict>
+ <dict>
+ <key>name</key>
+ <string>rake_helpers</string>
+ <key>regexFolderFilter</key>
+ <string>!.*/(\.[^/]*|CVS|_darcs|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
+ <key>sourceDirectory</key>
+ <string>../rake_helpers</string>
+ </dict>
+ <dict>
+ <key>name</key>
+ <string>rake_tasks</string>
+ <key>regexFolderFilter</key>
+ <string>!.*/(\.[^/]*|CVS|_darcs|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
+ <key>sourceDirectory</key>
+ <string>../rake_tasks</string>
+ </dict>
+ <dict>
+ <key>filename</key>
+ <string>../Rakefile</string>
+ <key>lastUsed</key>
+ <date>2006-10-31T02:10:52Z</date>
+ <key>selected</key>
+ <true/>
+ </dict>
+ <dict>
+ <key>filename</key>
+ <string>../README</string>
+ </dict>
+ <dict>
+ <key>filename</key>
+ <string>../ROADMAP</string>
+ </dict>
+ <dict>
+ <key>filename</key>
+ <string>../TODO</string>
+ </dict>
+ <dict>
+ <key>name</key>
+ <string>functional</string>
+ <key>regexFolderFilter</key>
+ <string>!.*/(\.[^/]*|CVS|_darcs|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
+ <key>sourceDirectory</key>
+ <string>../test/functional</string>
+ </dict>
+ <dict>
+ <key>filename</key>
+ <string>../test/scanners/coderay_suite.rb</string>
+ <key>lastUsed</key>
+ <date>2006-10-31T02:10:48Z</date>
+ </dict>
+ <dict>
+ <key>filename</key>
+ <string>../test/scanners/suite.rb</string>
+ <key>lastUsed</key>
+ <date>2006-10-31T01:56:15Z</date>
+ </dict>
+ <dict>
+ <key>filename</key>
+ <string>../bench/bench.rb</string>
+ </dict>
+ </array>
+ <key>fileHierarchyDrawerWidth</key>
+ <integer>200</integer>
+ <key>metaData</key>
+ <dict/>
+ <key>showFileHierarchyDrawer</key>
+ <true/>
+ <key>windowFrame</key>
+ <string>{{6, 14}, {643, 764}}</string>
+</dict>
+</plist>
diff --git a/etc/coderay.tmproj b/etc/coderay.tmproj
new file mode 100644
index 0000000..ed8791c
--- /dev/null
+++ b/etc/coderay.tmproj
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>currentDocument</key>
+ <string>../rake_tasks/gem.rake</string>
+ <key>documents</key>
+ <array>
+ <dict>
+ <key>expanded</key>
+ <true/>
+ <key>name</key>
+ <string>coderay</string>
+ <key>regexFolderFilter</key>
+ <string>!.*/(\.[^/]*|CVS|_darcs|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
+ <key>sourceDirectory</key>
+ <string>..</string>
+ </dict>
+ </array>
+ <key>fileHierarchyDrawerWidth</key>
+ <integer>312</integer>
+ <key>metaData</key>
+ <dict>
+ <key>../lib/coderay/scanners/ruby.rb</key>
+ <dict>
+ <key>caret</key>
+ <dict>
+ <key>column</key>
+ <integer>50</integer>
+ <key>line</key>
+ <integer>11</integer>
+ </dict>
+ <key>firstVisibleColumn</key>
+ <integer>0</integer>
+ <key>firstVisibleLine</key>
+ <integer>0</integer>
+ </dict>
+ <key>../lib/coderay/scanners/ruby/patterns.rb</key>
+ <dict>
+ <key>caret</key>
+ <dict>
+ <key>column</key>
+ <integer>43</integer>
+ <key>line</key>
+ <integer>18</integer>
+ </dict>
+ <key>firstVisibleColumn</key>
+ <integer>0</integer>
+ <key>firstVisibleLine</key>
+ <integer>0</integer>
+ </dict>
+ <key>../rake_tasks/gem.rake</key>
+ <dict>
+ <key>caret</key>
+ <dict>
+ <key>column</key>
+ <integer>44</integer>
+ <key>line</key>
+ <integer>89</integer>
+ </dict>
+ <key>firstVisibleColumn</key>
+ <integer>0</integer>
+ <key>firstVisibleLine</key>
+ <integer>77</integer>
+ </dict>
+ <key>../test/scanners/coderay_suite.rb</key>
+ <dict>
+ <key>caret</key>
+ <dict>
+ <key>column</key>
+ <integer>29</integer>
+ <key>line</key>
+ <integer>316</integer>
+ </dict>
+ <key>firstVisibleColumn</key>
+ <integer>0</integer>
+ <key>firstVisibleLine</key>
+ <integer>305</integer>
+ </dict>
+ <key>../test/scanners/ruby/regexp.in.rb</key>
+ <dict>
+ <key>caret</key>
+ <dict>
+ <key>column</key>
+ <integer>51</integer>
+ <key>line</key>
+ <integer>4</integer>
+ </dict>
+ <key>firstVisibleColumn</key>
+ <integer>0</integer>
+ <key>firstVisibleLine</key>
+ <integer>0</integer>
+ </dict>
+ </dict>
+ <key>openDocuments</key>
+ <array>
+ <string>../lib/coderay/scanners/ruby.rb</string>
+ <string>../test/scanners/coderay_suite.rb</string>
+ <string>../test/scanners/ruby/regexp.in.rb</string>
+ <string>../rake_tasks/gem.rake</string>
+ <string>../lib/coderay/scanners/ruby/patterns.rb</string>
+ </array>
+ <key>showFileHierarchyDrawer</key>
+ <true/>
+ <key>windowFrame</key>
+ <string>{{1, 4}, {952, 774}}</string>
+</dict>
+</plist>
diff --git a/etc/todo/example.applescript b/etc/todo/example.applescript
new file mode 100644
index 0000000..8153e0d
--- /dev/null
+++ b/etc/todo/example.applescript
@@ -0,0 +1,12997 @@
+(**
+ * filename: MailNotification.applescript
+ * created : Tue Feb 11 14:24:40 2003
+ * LastEditDate Was "Mon Jun 30 11:25:23 2003"
+ *
+ *)
+
+(* recipientAddress is a list of Addresses to send to
+ * messageSubject is the subject of the spam message
+ * messageBody is the body of the spam message
+ *)
+on sendemail(emailer, vcardPath, recipientAddress, messageSubject, messageBody)
+
+ (* Part that does all of the work, this works for Mail *)
+ if (emailer is equal to "com.apple.mail") then
+ tell application "Mail"
+ -- Properties can be specified in a record when creating the message or
+ -- afterwards by setting individual property values.
+ set newMessage to make new outgoing message with properties {subject:messageSubject, content:messageBody}
+ tell newMessage
+ -- Default is false. Determines whether the compose window will
+ -- show on the screen or whether it will happen in the background.
+ set visible to false
+
+ repeat with emailAddress in recipientAddress
+ make new bcc recipient at end of bcc recipients with properties {address:emailAddress}
+ end repeat
+ tell content
+ -- Position must be specified for attachments
+ make new attachment with properties {file name:vcardPath} at after the last paragraph
+ end tell
+ end tell
+ -- send the message
+ send newMessage
+ end tell
+ else
+ if (emailer is equal to "com.microsoft.entourage") then
+ (* lots of stuff for entourage here *)
+ end if
+ end if
+end sendemail
+
+-- sendemail("com.apple.mail", "/tmp/foo.vcf", "dude@apple.com", "messageSubject", "messageBody")
+(**
+ * filename: SharingInvite.applescript
+ *
+ *)
+
+(* recipientAddress is a list of Addresses to send to
+ * messageSubject is the subject of the invite message
+ * messageBody is the body of the invite message
+ *)
+on sendemail(emailer, recipientAddress, messageSubject, messageBody)
+
+ (* Part that does all of the work, this works for Mail *)
+ if (emailer is equal to "com.apple.mail") then
+ tell application "Mail"
+ -- Properties can be specified in a record when creating the message or
+ -- afterwards by setting individual property values.
+ set newMessage to make new outgoing message with properties {subject:messageSubject, content:messageBody}
+ tell newMessage
+ -- Default is false. Determines whether the compose window will
+ -- show on the screen or whether it will happen in the background.
+ set visible to true
+
+ repeat with emailAddress in recipientAddress
+ make new bcc recipient at end of bcc recipients with properties {address:emailAddress}
+ end repeat
+ end tell
+ -- send the message
+ -- send newMessage
+ end tell
+ else
+ if (emailer is equal to "com.microsoft.entourage") then
+ (* lots of stuff for entourage here *)
+ end if
+ end if
+end sendemail
+
+-- sendemail("com.apple.mail", "dude@apple.com", "messageSubject", "messageBody")
+beep
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Wil je Big Bang " & game_name & " voor Mac OS X spelen? (Laat het me weten als je het spel niet hebt en ik stuur het je met een klik op de muis.)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Wanneer je klaar bent om te spelen, open je mijn spelsleutel die je meteen van mij zult ontvangen."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Laten we Big Bang " & game_name & " voor Mac OS X spelen. Ik denk niet dat je het spel hebt, dus daarom stuur ik het je hierbij!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Laat het me weten wanneer je klaar bent om te spelen, dan nodig ik je uit voor een spel."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Want to play Big Bang " & game_name & " for Mac OS X? (If you don't have it, let me know and I can send it with one click!)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "When you're ready to play, simply open my game key which I'm sending to you next."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Let's play Big Bang " & game_name & " for Mac OS X. I don't think you have it, so, here it is!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "When you're ready to play, let me know and I'll invite you to a game."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+(* The calling application will define the following variables for you: * * oldPath - A Mac OS 9 styled full path name to the attachment file * unixPath - A Unix-styled full path name * theRecipients - A comma-separated list of email addresses to send to * theSubject - String which contained the subject * theBody - String which contains the body of the email *) tell application "Eudora" set newMessage to make new message at end of mailbox "Out" tell newMessage set subject to theSubject set body to theBody & return & return set field "to" to theRecipients attach to newMessage documents {oldPath as alias} end tell activate return true end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Une partie de Big Bang " & game_name & " pour Mac OS X ? (Si tu n'as pas ce jeu, dis-le moi et je te l'envoie d'un simple clic !)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Pour jouer, il suffit d'ouvrir le fichier que je vais t'envoyer."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Faisons une partie de Big Bang " & game_name & " pour Mac OS X. Comme tu n'as pas ce jeu, je te l'envoie !" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Dis-moi quand tu veux jouer et je t'inviterai pour une partie."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Willst Du Big Bang " & game_name & " auf einem Mac OS X spielen? (Wenn Du das Spiel nicht besitzt, gib mir Bescheid. Ich kann es mit einem Klick senden.)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Wenn Du spielbereit bist, verwende einfach meinen Spieleschluessel, den ich Dir gleich sende."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Lass uns Big Bang " & game_name & " for Mac OS X spielen. Ich glaube, dass Du es nicht hast. Hier ist es." as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Wenn Du spielbereit bist, gebe mir Bescheid, und ich lade Dich zu einem Spiel ein."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Vuoi giocare a Big Bang " & game_name & " per Mac OS X? (Se non ce l'hai, fammelo sapere e te lo mando in un clic!)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Quando sei pronto per giocare, apri la chiave della partita che ti mando."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Giochiamo a Big Bang " & game_name & " per Mac OS X. Non mi sembra che tu ce l'abbia, quindi te lo mando!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Quando sei pronto per giocare, fammelo sapere."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Want to play Big Bang " & game_name & " for Mac OS X? (If you don't have it, let me know and I can send it with one click!)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "When you're ready to play, simply open my game key which I'm sending to you next."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Let's play Big Bang " & game_name & " for Mac OS X. I don't think you have it, so, here it is!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "When you're ready to play, let me know and I'll invite you to a game."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+(* The calling application will define the following variables for you: * * oldPath - A Mac OS 9 styled full path name to the attachment file * unixPath - A Unix-styled full path name * theRecipients - A comma-separated list of email addresses to send to * theSubject - String which contained the subject * theBody - String which contains the body of the email *) tell application "Mail" activate set this_message to make new compose message at beginning of every compose message with properties {subject:theSubject,content:theBody} tell this_message set content to return & return & content make new recipient at end of recipients with properties {display name:theRecipients} tell content make new text attachment with properties {file name:unixPath} at before the first word of the first paragraph end tell end tell set content of this_message to the content of this_message make new message editor at beginning of message editors set compose message of message editor 1 to this_message return true end tell
+(* The calling application will define the following variables for you:
+ *
+ * oldPath - A Mac OS 9 styled full path name to the attachment file
+ * unixPath - A Unix-styled full path name
+ * theRecipients - A comma-separated list of email addresses to send to
+ * theSubject - String which contained the subject
+ * theBody - String which contains the body of the email
+ *)
+
+set theBody to the clipboard as Unicode text
+
+tell application "Mail"
+
+ set newMessage to make new outgoing message with properties {subject:theSubject, content:return}
+ tell newMessage
+ set visible to true
+ make new to recipient at end of to recipients with properties {name:theRecipients}
+ tell content
+ make new attachment with properties {file name:unixPath} at after the last paragraph
+ make new text at after the last paragraph with data (return & return & theBody)
+ end tell
+ end tell
+
+ activate
+
+ return true
+end tell
+(* The calling application will define the following variables for you:
+ *
+ * oldPath - A Mac OS 9 styled full path name to the attachment file
+ * unixPath - A Unix-styled full path name
+ * theRecipients - A comma-separated list of email addresses to send to
+ * theSubject - String which contained the subject
+ * theBody - String which contains the body of the email
+ *)
+
+tell application "Microsoft Entourage"
+
+ set newMessage to make new draft window with properties {recipient:theRecipients, subject:theSubject, content:theBody & return & return}
+ tell newMessage
+ make new file with properties {name:oldPath}
+ end tell
+
+ activate
+
+ return true
+end tell
+(* The calling application will define the following variables for you:
+ *
+ * oldPath - A Mac OS 9 styled full path name to the attachment file
+ * unixPath - A Unix-styled full path name
+ * theRecipients - A comma-separated list of email addresses to send to
+ * theSubject - String which contained the subject
+ * theBody - String which contains the body of the email
+ *)
+
+tell application "Outlook Express"
+ set newMessage to make new draft window with properties {recipient:theRecipients, subject:theSubject, content:theBody & return & return}
+ tell newMessage
+ make new file with properties {name:oldPath}
+ end tell
+
+ activate
+
+ return true
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Quieres jugar a Big Bang " & game_name & " para Mac OS X? Si no lo tienes, te lo hago llegar con un simple clic." as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Para empezar a jugar, abre el archivo de llave de partida que te paso."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Juguemos a Big Bang " & game_name & " para Mac OS X. Creo que no lo tienes. Te lo paso." as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Cuando quieras jugar me lo dices y te invito a una partida."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Wil je Big Bang " & game_name & " voor Mac OS X spelen? (Laat het me weten als je het spel niet hebt en ik stuur het je met een klik op de muis.)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Wanneer je klaar bent om te spelen, open je mijn spelsleutel die je meteen van mij zult ontvangen."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Laten we Big Bang " & game_name & " voor Mac OS X spelen. Ik denk niet dat je het spel hebt, dus daarom stuur ik het je hierbij!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Laat het me weten wanneer je klaar bent om te spelen, dan nodig ik je uit voor een spel."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Want to play Big Bang " & game_name & " for Mac OS X? (If you don't have it, let me know and I can send it with one click!)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "When you're ready to play, simply open my game key which I'm sending to you next."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Let's play Big Bang " & game_name & " for Mac OS X. I don't think you have it, so, here it is!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "When you're ready to play, let me know and I'll invite you to a game."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+(* The calling application will define the following variables for you: * * oldPath - A Mac OS 9 styled full path name to the attachment file * unixPath - A Unix-styled full path name * theRecipients - A comma-separated list of email addresses to send to * theSubject - String which contained the subject * theBody - String which contains the body of the email *) tell application "Eudora" set newMessage to make new message at end of mailbox "Out" tell newMessage set subject to theSubject set body to theBody & return & return set field "to" to theRecipients attach to newMessage documents {oldPath as alias} end tell activate return true end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Une partie de Big Bang " & game_name & " pour Mac OS X ? (Si tu n'as pas ce jeu, dis-le moi et je te l'envoie d'un simple clic !)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Pour jouer, il suffit d'ouvrir le fichier que je vais t'envoyer."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Faisons une partie de Big Bang " & game_name & " pour Mac OS X. Comme tu n'as pas ce jeu, je te l'envoie !" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Dis-moi quand tu veux jouer et je t'inviterai pour une partie."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Willst Du Big Bang " & game_name & " auf einem Mac OS X spielen? (Wenn Du das Spiel nicht besitzt, gib mir Bescheid. Ich kann es mit einem Klick senden.)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Wenn Du spielbereit bist, verwende einfach meinen Spieleschluessel, den ich Dir gleich sende."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Lass uns Big Bang " & game_name & " for Mac OS X spielen. Ich glaube, dass Du es nicht hast. Hier ist es." as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Wenn Du spielbereit bist, gebe mir Bescheid, und ich lade Dich zu einem Spiel ein."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Vuoi giocare a Big Bang " & game_name & " per Mac OS X? (Se non ce l'hai, fammelo sapere e te lo mando in un clic!)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Quando sei pronto per giocare, apri la chiave della partita che ti mando."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Giochiamo a Big Bang " & game_name & " per Mac OS X. Non mi sembra che tu ce l'abbia, quindi te lo mando!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Quando sei pronto per giocare, fammelo sapere."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Want to play Big Bang " & game_name & " for Mac OS X? (If you don't have it, let me know and I can send it with one click!)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "When you're ready to play, simply open my game key which I'm sending to you next."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Let's play Big Bang " & game_name & " for Mac OS X. I don't think you have it, so, here it is!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "When you're ready to play, let me know and I'll invite you to a game."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+(* The calling application will define the following variables for you: * * oldPath - A Mac OS 9 styled full path name to the attachment file * unixPath - A Unix-styled full path name * theRecipients - A comma-separated list of email addresses to send to * theSubject - String which contained the subject * theBody - String which contains the body of the email *) tell application "Mail" activate set this_message to make new compose message at beginning of every compose message with properties {subject:theSubject,content:theBody} tell this_message set content to return & return & content make new recipient at end of recipients with properties {display name:theRecipients} tell content make new text attachment with properties {file name:unixPath} at before the first word of the first paragraph end tell end tell set content of this_message to the content of this_message make new message editor at beginning of message editors set compose message of message editor 1 to this_message return true end tell
+(* The calling application will define the following variables for you:
+ *
+ * oldPath - A Mac OS 9 styled full path name to the attachment file
+ * unixPath - A Unix-styled full path name
+ * theRecipients - A comma-separated list of email addresses to send to
+ * theSubject - String which contained the subject
+ * theBody - String which contains the body of the email
+ *)
+
+set theBody to the clipboard as Unicode text
+
+tell application "Mail"
+
+ set newMessage to make new outgoing message with properties {subject:theSubject, content:return}
+ tell newMessage
+ set visible to true
+ make new to recipient at end of to recipients with properties {name:theRecipients}
+ tell content
+ make new attachment with properties {file name:unixPath} at after the last paragraph
+ make new text at after the last paragraph with data (return & return & theBody)
+ end tell
+ end tell
+
+ activate
+
+ return true
+end tell
+(* The calling application will define the following variables for you:
+ *
+ * oldPath - A Mac OS 9 styled full path name to the attachment file
+ * unixPath - A Unix-styled full path name
+ * theRecipients - A comma-separated list of email addresses to send to
+ * theSubject - String which contained the subject
+ * theBody - String which contains the body of the email
+ *)
+
+tell application "Microsoft Entourage"
+
+ set newMessage to make new draft window with properties {recipient:theRecipients, subject:theSubject, content:theBody & return & return}
+ tell newMessage
+ make new file with properties {name:oldPath}
+ end tell
+
+ activate
+
+ return true
+end tell
+(* The calling application will define the following variables for you:
+ *
+ * oldPath - A Mac OS 9 styled full path name to the attachment file
+ * unixPath - A Unix-styled full path name
+ * theRecipients - A comma-separated list of email addresses to send to
+ * theSubject - String which contained the subject
+ * theBody - String which contains the body of the email
+ *)
+
+tell application "Outlook Express"
+ set newMessage to make new draft window with properties {recipient:theRecipients, subject:theSubject, content:theBody & return & return}
+ tell newMessage
+ make new file with properties {name:oldPath}
+ end tell
+
+ activate
+
+ return true
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Quieres jugar a Big Bang " & game_name & " para Mac OS X? Si no lo tienes, te lo hago llegar con un simple clic." as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Para empezar a jugar, abre el archivo de llave de partida que te paso."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Juguemos a Big Bang " & game_name & " para Mac OS X. Creo que no lo tienes. Te lo paso." as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Cuando quieras jugar me lo dices y te invito a una partida."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Wil je Big Bang " & game_name & " voor Mac OS X spelen? (Laat het me weten als je het spel niet hebt en ik stuur het je met een klik op de muis.)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Wanneer je klaar bent om te spelen, open je mijn spelsleutel die je meteen van mij zult ontvangen."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Laten we Big Bang " & game_name & " voor Mac OS X spelen. Ik denk niet dat je het spel hebt, dus daarom stuur ik het je hierbij!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Laat het me weten wanneer je klaar bent om te spelen, dan nodig ik je uit voor een spel."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Want to play Big Bang " & game_name & " for Mac OS X? (If you don't have it, let me know and I can send it with one click!)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "When you're ready to play, simply open my game key which I'm sending to you next."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Let's play Big Bang " & game_name & " for Mac OS X. I don't think you have it, so, here it is!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "When you're ready to play, let me know and I'll invite you to a game."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+(* The calling application will define the following variables for you: * * oldPath - A Mac OS 9 styled full path name to the attachment file * unixPath - A Unix-styled full path name * theRecipients - A comma-separated list of email addresses to send to * theSubject - String which contained the subject * theBody - String which contains the body of the email *) tell application "Eudora" set newMessage to make new message at end of mailbox "Out" tell newMessage set subject to theSubject set body to theBody & return & return set field "to" to theRecipients attach to newMessage documents {oldPath as alias} end tell activate return true end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Une partie de Big Bang " & game_name & " pour Mac OS X ? (Si tu n'as pas ce jeu, dis-le moi et je te l'envoie d'un simple clic !)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Pour jouer, il suffit d'ouvrir le fichier que je vais t'envoyer."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Faisons une partie de Big Bang " & game_name & " pour Mac OS X. Comme tu n'as pas ce jeu, je te l'envoie !" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Dis-moi quand tu veux jouer et je t'inviterai pour une partie."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Willst Du Big Bang " & game_name & " auf einem Mac OS X spielen? (Wenn Du das Spiel nicht besitzt, gib mir Bescheid. Ich kann es mit einem Klick senden.)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Wenn Du spielbereit bist, verwende einfach meinen Spieleschluessel, den ich Dir gleich sende."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Lass uns Big Bang " & game_name & " for Mac OS X spielen. Ich glaube, dass Du es nicht hast. Hier ist es." as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Wenn Du spielbereit bist, gebe mir Bescheid, und ich lade Dich zu einem Spiel ein."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Vuoi giocare a Big Bang " & game_name & " per Mac OS X? (Se non ce l'hai, fammelo sapere e te lo mando in un clic!)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Quando sei pronto per giocare, apri la chiave della partita che ti mando."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Giochiamo a Big Bang " & game_name & " per Mac OS X. Non mi sembra che tu ce l'abbia, quindi te lo mando!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Quando sei pronto per giocare, fammelo sapere."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Want to play Big Bang " & game_name & " for Mac OS X? (If you don't have it, let me know and I can send it with one click!)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "When you're ready to play, simply open my game key which I'm sending to you next."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Let's play Big Bang " & game_name & " for Mac OS X. I don't think you have it, so, here it is!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "When you're ready to play, let me know and I'll invite you to a game."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+(* The calling application will define the following variables for you: * * oldPath - A Mac OS 9 styled full path name to the attachment file * unixPath - A Unix-styled full path name * theRecipients - A comma-separated list of email addresses to send to * theSubject - String which contained the subject * theBody - String which contains the body of the email *) tell application "Mail" activate set this_message to make new compose message at beginning of every compose message with properties {subject:theSubject,content:theBody} tell this_message set content to return & return & content make new recipient at end of recipients with properties {display name:theRecipients} tell content make new text attachment with properties {file name:unixPath} at before the first word of the first paragraph end tell end tell set content of this_message to the content of this_message make new message editor at beginning of message editors set compose message of message editor 1 to this_message return true end tell
+(* The calling application will define the following variables for you:
+ *
+ * oldPath - A Mac OS 9 styled full path name to the attachment file
+ * unixPath - A Unix-styled full path name
+ * theRecipients - A comma-separated list of email addresses to send to
+ * theSubject - String which contained the subject
+ * theBody - String which contains the body of the email
+ *)
+
+set theBody to the clipboard as Unicode text
+
+tell application "Mail"
+
+ set newMessage to make new outgoing message with properties {subject:theSubject, content:return}
+ tell newMessage
+ set visible to true
+ make new to recipient at end of to recipients with properties {name:theRecipients}
+ tell content
+ make new attachment with properties {file name:unixPath} at after the last paragraph
+ make new text at after the last paragraph with data (return & return & theBody)
+ end tell
+ end tell
+
+ activate
+
+ return true
+end tell
+(* The calling application will define the following variables for you:
+ *
+ * oldPath - A Mac OS 9 styled full path name to the attachment file
+ * unixPath - A Unix-styled full path name
+ * theRecipients - A comma-separated list of email addresses to send to
+ * theSubject - String which contained the subject
+ * theBody - String which contains the body of the email
+ *)
+
+tell application "Microsoft Entourage"
+
+ set newMessage to make new draft window with properties {recipient:theRecipients, subject:theSubject, content:theBody & return & return}
+ tell newMessage
+ make new file with properties {name:oldPath}
+ end tell
+
+ activate
+
+ return true
+end tell
+(* The calling application will define the following variables for you:
+ *
+ * oldPath - A Mac OS 9 styled full path name to the attachment file
+ * unixPath - A Unix-styled full path name
+ * theRecipients - A comma-separated list of email addresses to send to
+ * theSubject - String which contained the subject
+ * theBody - String which contains the body of the email
+ *)
+
+tell application "Outlook Express"
+ set newMessage to make new draft window with properties {recipient:theRecipients, subject:theSubject, content:theBody & return & return}
+ tell newMessage
+ make new file with properties {name:oldPath}
+ end tell
+
+ activate
+
+ return true
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Quieres jugar a Big Bang " & game_name & " para Mac OS X? Si no lo tienes, te lo hago llegar con un simple clic." as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Para empezar a jugar, abre el archivo de llave de partida que te paso."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Juguemos a Big Bang " & game_name & " para Mac OS X. Creo que no lo tienes. Te lo paso." as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Cuando quieras jugar me lo dices y te invito a una partida."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Wil je Big Bang " & game_name & " voor Mac OS X spelen? (Laat het me weten als je het spel niet hebt en ik stuur het je met een klik op de muis.)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Wanneer je klaar bent om te spelen, open je mijn spelsleutel die je meteen van mij zult ontvangen."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Laten we Big Bang " & game_name & " voor Mac OS X spelen. Ik denk niet dat je het spel hebt, dus daarom stuur ik het je hierbij!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Laat het me weten wanneer je klaar bent om te spelen, dan nodig ik je uit voor een spel."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Want to play Big Bang " & game_name & " for Mac OS X? (If you don't have it, let me know and I can send it with one click!)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "When you're ready to play, simply open my game key which I'm sending to you next."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Let's play Big Bang " & game_name & " for Mac OS X. I don't think you have it, so, here it is!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "When you're ready to play, let me know and I'll invite you to a game."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+(* The calling application will define the following variables for you: * * oldPath - A Mac OS 9 styled full path name to the attachment file * unixPath - A Unix-styled full path name * theRecipients - A comma-separated list of email addresses to send to * theSubject - String which contained the subject * theBody - String which contains the body of the email *) tell application "Eudora" set newMessage to make new message at end of mailbox "Out" tell newMessage set subject to theSubject set body to theBody & return & return set field "to" to theRecipients attach to newMessage documents {oldPath as alias} end tell activate return true end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Une partie de Big Bang " & game_name & " pour Mac OS X ? (Si tu n'as pas ce jeu, dis-le moi et je te l'envoie d'un simple clic !)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Pour jouer, il suffit d'ouvrir le fichier que je vais t'envoyer."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Faisons une partie de Big Bang " & game_name & " pour Mac OS X. Comme tu n'as pas ce jeu, je te l'envoie !" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Dis-moi quand tu veux jouer et je t'inviterai pour une partie."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Willst Du Big Bang " & game_name & " auf einem Mac OS X spielen? (Wenn Du das Spiel nicht besitzt, gib mir Bescheid. Ich kann es mit einem Klick senden.)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Wenn Du spielbereit bist, verwende einfach meinen Spieleschluessel, den ich Dir gleich sende."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Lass uns Big Bang " & game_name & " for Mac OS X spielen. Ich glaube, dass Du es nicht hast. Hier ist es." as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Wenn Du spielbereit bist, gebe mir Bescheid, und ich lade Dich zu einem Spiel ein."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Vuoi giocare a Big Bang " & game_name & " per Mac OS X? (Se non ce l'hai, fammelo sapere e te lo mando in un clic!)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Quando sei pronto per giocare, apri la chiave della partita che ti mando."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Giochiamo a Big Bang " & game_name & " per Mac OS X. Non mi sembra che tu ce l'abbia, quindi te lo mando!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Quando sei pronto per giocare, fammelo sapere."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Want to play Big Bang " & game_name & " for Mac OS X? (If you don't have it, let me know and I can send it with one click!)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "When you're ready to play, simply open my game key which I'm sending to you next."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Let's play Big Bang " & game_name & " for Mac OS X. I don't think you have it, so, here it is!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "When you're ready to play, let me know and I'll invite you to a game."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+(* The calling application will define the following variables for you: * * oldPath - A Mac OS 9 styled full path name to the attachment file * unixPath - A Unix-styled full path name * theRecipients - A comma-separated list of email addresses to send to * theSubject - String which contained the subject * theBody - String which contains the body of the email *) tell application "Mail" activate set this_message to make new compose message at beginning of every compose message with properties {subject:theSubject,content:theBody} tell this_message set content to return & return & content make new recipient at end of recipients with properties {display name:theRecipients} tell content make new text attachment with properties {file name:unixPath} at before the first word of the first paragraph end tell end tell set content of this_message to the content of this_message make new message editor at beginning of message editors set compose message of message editor 1 to this_message return true end tell
+(* The calling application will define the following variables for you:
+ *
+ * oldPath - A Mac OS 9 styled full path name to the attachment file
+ * unixPath - A Unix-styled full path name
+ * theRecipients - A comma-separated list of email addresses to send to
+ * theSubject - String which contained the subject
+ * theBody - String which contains the body of the email
+ *)
+
+set theBody to the clipboard as Unicode text
+
+tell application "Mail"
+
+ set newMessage to make new outgoing message with properties {subject:theSubject, content:return}
+ tell newMessage
+ set visible to true
+ make new to recipient at end of to recipients with properties {name:theRecipients}
+ tell content
+ make new attachment with properties {file name:unixPath} at after the last paragraph
+ make new text at after the last paragraph with data (return & return & theBody)
+ end tell
+ end tell
+
+ activate
+
+ return true
+end tell
+(* The calling application will define the following variables for you:
+ *
+ * oldPath - A Mac OS 9 styled full path name to the attachment file
+ * unixPath - A Unix-styled full path name
+ * theRecipients - A comma-separated list of email addresses to send to
+ * theSubject - String which contained the subject
+ * theBody - String which contains the body of the email
+ *)
+
+tell application "Microsoft Entourage"
+
+ set newMessage to make new draft window with properties {recipient:theRecipients, subject:theSubject, content:theBody & return & return}
+ tell newMessage
+ make new file with properties {name:oldPath}
+ end tell
+
+ activate
+
+ return true
+end tell
+(* The calling application will define the following variables for you:
+ *
+ * oldPath - A Mac OS 9 styled full path name to the attachment file
+ * unixPath - A Unix-styled full path name
+ * theRecipients - A comma-separated list of email addresses to send to
+ * theSubject - String which contained the subject
+ * theBody - String which contains the body of the email
+ *)
+
+tell application "Outlook Express"
+ set newMessage to make new draft window with properties {recipient:theRecipients, subject:theSubject, content:theBody & return & return}
+ tell newMessage
+ make new file with properties {name:oldPath}
+ end tell
+
+ activate
+
+ return true
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Quieres jugar a Big Bang " & game_name & " para Mac OS X? Si no lo tienes, te lo hago llegar con un simple clic." as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Para empezar a jugar, abre el archivo de llave de partida que te paso."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Juguemos a Big Bang " & game_name & " para Mac OS X. Creo que no lo tienes. Te lo paso." as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Cuando quieras jugar me lo dices y te invito a una partida."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Wil je Big Bang " & game_name & " voor Mac OS X spelen? (Laat het me weten als je het spel niet hebt en ik stuur het je met een klik op de muis.)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Wanneer je klaar bent om te spelen, open je mijn spelsleutel die je meteen van mij zult ontvangen."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Laten we Big Bang " & game_name & " voor Mac OS X spelen. Ik denk niet dat je het spel hebt, dus daarom stuur ik het je hierbij!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Laat het me weten wanneer je klaar bent om te spelen, dan nodig ik je uit voor een spel."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Want to play Big Bang " & game_name & " for Mac OS X? (If you don't have it, let me know and I can send it with one click!)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "When you're ready to play, simply open my game key which I'm sending to you next."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Let's play Big Bang " & game_name & " for Mac OS X. I don't think you have it, so, here it is!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "When you're ready to play, let me know and I'll invite you to a game."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+(* The calling application will define the following variables for you: * * oldPath - A Mac OS 9 styled full path name to the attachment file * unixPath - A Unix-styled full path name * theRecipients - A comma-separated list of email addresses to send to * theSubject - String which contained the subject * theBody - String which contains the body of the email *) tell application "Eudora" set newMessage to make new message at end of mailbox "Out" tell newMessage set subject to theSubject set body to theBody & return & return set field "to" to theRecipients attach to newMessage documents {oldPath as alias} end tell activate return true end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Une partie de Big Bang " & game_name & " pour Mac OS X ? (Si tu n'as pas ce jeu, dis-le moi et je te l'envoie d'un simple clic !)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Pour jouer, il suffit d'ouvrir le fichier que je vais t'envoyer."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Faisons une partie de Big Bang " & game_name & " pour Mac OS X. Comme tu n'as pas ce jeu, je te l'envoie !" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Dis-moi quand tu veux jouer et je t'inviterai pour une partie."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Willst Du Big Bang " & game_name & " auf einem Mac OS X spielen? (Wenn Du das Spiel nicht besitzt, gib mir Bescheid. Ich kann es mit einem Klick senden.)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Wenn Du spielbereit bist, verwende einfach meinen Spieleschluessel, den ich Dir gleich sende."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Lass uns Big Bang " & game_name & " for Mac OS X spielen. Ich glaube, dass Du es nicht hast. Hier ist es." as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Wenn Du spielbereit bist, gebe mir Bescheid, und ich lade Dich zu einem Spiel ein."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Vuoi giocare a Big Bang " & game_name & " per Mac OS X? (Se non ce l'hai, fammelo sapere e te lo mando in un clic!)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Quando sei pronto per giocare, apri la chiave della partita che ti mando."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Giochiamo a Big Bang " & game_name & " per Mac OS X. Non mi sembra che tu ce l'abbia, quindi te lo mando!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Quando sei pronto per giocare, fammelo sapere."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Want to play Big Bang " & game_name & " for Mac OS X? (If you don't have it, let me know and I can send it with one click!)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "When you're ready to play, simply open my game key which I'm sending to you next."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Let's play Big Bang " & game_name & " for Mac OS X. I don't think you have it, so, here it is!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "When you're ready to play, let me know and I'll invite you to a game."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+(* The calling application will define the following variables for you: * * oldPath - A Mac OS 9 styled full path name to the attachment file * unixPath - A Unix-styled full path name * theRecipients - A comma-separated list of email addresses to send to * theSubject - String which contained the subject * theBody - String which contains the body of the email *) tell application "Mail" activate set this_message to make new compose message at beginning of every compose message with properties {subject:theSubject,content:theBody} tell this_message set content to return & return & content make new recipient at end of recipients with properties {display name:theRecipients} tell content make new text attachment with properties {file name:unixPath} at before the first word of the first paragraph end tell end tell set content of this_message to the content of this_message make new message editor at beginning of message editors set compose message of message editor 1 to this_message return true end tell
+(* The calling application will define the following variables for you:
+ *
+ * oldPath - A Mac OS 9 styled full path name to the attachment file
+ * unixPath - A Unix-styled full path name
+ * theRecipients - A comma-separated list of email addresses to send to
+ * theSubject - String which contained the subject
+ * theBody - String which contains the body of the email
+ *)
+
+set theBody to the clipboard as Unicode text
+
+tell application "Mail"
+
+ set newMessage to make new outgoing message with properties {subject:theSubject, content:return}
+ tell newMessage
+ set visible to true
+ make new to recipient at end of to recipients with properties {name:theRecipients}
+ tell content
+ make new attachment with properties {file name:unixPath} at after the last paragraph
+ make new text at after the last paragraph with data (return & return & theBody)
+ end tell
+ end tell
+
+ activate
+
+ return true
+end tell
+(* The calling application will define the following variables for you:
+ *
+ * oldPath - A Mac OS 9 styled full path name to the attachment file
+ * unixPath - A Unix-styled full path name
+ * theRecipients - A comma-separated list of email addresses to send to
+ * theSubject - String which contained the subject
+ * theBody - String which contains the body of the email
+ *)
+
+tell application "Microsoft Entourage"
+
+ set newMessage to make new draft window with properties {recipient:theRecipients, subject:theSubject, content:theBody & return & return}
+ tell newMessage
+ make new file with properties {name:oldPath}
+ end tell
+
+ activate
+
+ return true
+end tell
+(* The calling application will define the following variables for you:
+ *
+ * oldPath - A Mac OS 9 styled full path name to the attachment file
+ * unixPath - A Unix-styled full path name
+ * theRecipients - A comma-separated list of email addresses to send to
+ * theSubject - String which contained the subject
+ * theBody - String which contains the body of the email
+ *)
+
+tell application "Outlook Express"
+ set newMessage to make new draft window with properties {recipient:theRecipients, subject:theSubject, content:theBody & return & return}
+ tell newMessage
+ make new file with properties {name:oldPath}
+ end tell
+
+ activate
+
+ return true
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Quieres jugar a Big Bang " & game_name & " para Mac OS X? Si no lo tienes, te lo hago llegar con un simple clic." as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Para empezar a jugar, abre el archivo de llave de partida que te paso."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Juguemos a Big Bang " & game_name & " para Mac OS X. Creo que no lo tienes. Te lo paso." as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Cuando quieras jugar me lo dices y te invito a una partida."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Wil je Big Bang " & game_name & " voor Mac OS X spelen? (Laat het me weten als je het spel niet hebt en ik stuur het je met een klik op de muis.)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Wanneer je klaar bent om te spelen, open je mijn spelsleutel die je meteen van mij zult ontvangen."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Laten we Big Bang " & game_name & " voor Mac OS X spelen. Ik denk niet dat je het spel hebt, dus daarom stuur ik het je hierbij!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Laat het me weten wanneer je klaar bent om te spelen, dan nodig ik je uit voor een spel."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Want to play Big Bang " & game_name & " for Mac OS X? (If you don't have it, let me know and I can send it with one click!)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "When you're ready to play, simply open my game key which I'm sending to you next."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Let's play Big Bang " & game_name & " for Mac OS X. I don't think you have it, so, here it is!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "When you're ready to play, let me know and I'll invite you to a game."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+(* The calling application will define the following variables for you: * * oldPath - A Mac OS 9 styled full path name to the attachment file * unixPath - A Unix-styled full path name * theRecipients - A comma-separated list of email addresses to send to * theSubject - String which contained the subject * theBody - String which contains the body of the email *) tell application "Eudora" set newMessage to make new message at end of mailbox "Out" tell newMessage set subject to theSubject set body to theBody & return & return set field "to" to theRecipients attach to newMessage documents {oldPath as alias} end tell activate return true end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Une partie de Big Bang " & game_name & " pour Mac OS X ? (Si tu n'as pas ce jeu, dis-le moi et je te l'envoie d'un simple clic !)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Pour jouer, il suffit d'ouvrir le fichier que je vais t'envoyer."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Faisons une partie de Big Bang " & game_name & " pour Mac OS X. Comme tu n'as pas ce jeu, je te l'envoie !" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Dis-moi quand tu veux jouer et je t'inviterai pour une partie."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Willst Du Big Bang " & game_name & " auf einem Mac OS X spielen? (Wenn Du das Spiel nicht besitzt, gib mir Bescheid. Ich kann es mit einem Klick senden.)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Wenn Du spielbereit bist, verwende einfach meinen Spieleschluessel, den ich Dir gleich sende."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Lass uns Big Bang " & game_name & " for Mac OS X spielen. Ich glaube, dass Du es nicht hast. Hier ist es." as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Wenn Du spielbereit bist, gebe mir Bescheid, und ich lade Dich zu einem Spiel ein."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Vuoi giocare a Big Bang " & game_name & " per Mac OS X? (Se non ce l'hai, fammelo sapere e te lo mando in un clic!)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Quando sei pronto per giocare, apri la chiave della partita che ti mando."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Giochiamo a Big Bang " & game_name & " per Mac OS X. Non mi sembra che tu ce l'abbia, quindi te lo mando!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Quando sei pronto per giocare, fammelo sapere."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Want to play Big Bang " & game_name & " for Mac OS X? (If you don't have it, let me know and I can send it with one click!)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "When you're ready to play, simply open my game key which I'm sending to you next."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Let's play Big Bang " & game_name & " for Mac OS X. I don't think you have it, so, here it is!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "When you're ready to play, let me know and I'll invite you to a game."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+(* The calling application will define the following variables for you: * * oldPath - A Mac OS 9 styled full path name to the attachment file * unixPath - A Unix-styled full path name * theRecipients - A comma-separated list of email addresses to send to * theSubject - String which contained the subject * theBody - String which contains the body of the email *) tell application "Mail" activate set this_message to make new compose message at beginning of every compose message with properties {subject:theSubject,content:theBody} tell this_message set content to return & return & content make new recipient at end of recipients with properties {display name:theRecipients} tell content make new text attachment with properties {file name:unixPath} at before the first word of the first paragraph end tell end tell set content of this_message to the content of this_message make new message editor at beginning of message editors set compose message of message editor 1 to this_message return true end tell
+(* The calling application will define the following variables for you:
+ *
+ * oldPath - A Mac OS 9 styled full path name to the attachment file
+ * unixPath - A Unix-styled full path name
+ * theRecipients - A comma-separated list of email addresses to send to
+ * theSubject - String which contained the subject
+ * theBody - String which contains the body of the email
+ *)
+
+set theBody to the clipboard as Unicode text
+
+tell application "Mail"
+
+ set newMessage to make new outgoing message with properties {subject:theSubject, content:return}
+ tell newMessage
+ set visible to true
+ make new to recipient at end of to recipients with properties {name:theRecipients}
+ tell content
+ make new attachment with properties {file name:unixPath} at after the last paragraph
+ make new text at after the last paragraph with data (return & return & theBody)
+ end tell
+ end tell
+
+ activate
+
+ return true
+end tell
+(* The calling application will define the following variables for you:
+ *
+ * oldPath - A Mac OS 9 styled full path name to the attachment file
+ * unixPath - A Unix-styled full path name
+ * theRecipients - A comma-separated list of email addresses to send to
+ * theSubject - String which contained the subject
+ * theBody - String which contains the body of the email
+ *)
+
+tell application "Microsoft Entourage"
+
+ set newMessage to make new draft window with properties {recipient:theRecipients, subject:theSubject, content:theBody & return & return}
+ tell newMessage
+ make new file with properties {name:oldPath}
+ end tell
+
+ activate
+
+ return true
+end tell
+(* The calling application will define the following variables for you:
+ *
+ * oldPath - A Mac OS 9 styled full path name to the attachment file
+ * unixPath - A Unix-styled full path name
+ * theRecipients - A comma-separated list of email addresses to send to
+ * theSubject - String which contained the subject
+ * theBody - String which contains the body of the email
+ *)
+
+tell application "Outlook Express"
+ set newMessage to make new draft window with properties {recipient:theRecipients, subject:theSubject, content:theBody & return & return}
+ tell newMessage
+ make new file with properties {name:oldPath}
+ end tell
+
+ activate
+
+ return true
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Quieres jugar a Big Bang " & game_name & " para Mac OS X? Si no lo tienes, te lo hago llegar con un simple clic." as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Para empezar a jugar, abre el archivo de llave de partida que te paso."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Juguemos a Big Bang " & game_name & " para Mac OS X. Creo que no lo tienes. Te lo paso." as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Cuando quieras jugar me lo dices y te invito a una partida."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Wil je Big Bang " & game_name & " voor Mac OS X spelen? (Laat het me weten als je het spel niet hebt en ik stuur het je met een klik op de muis.)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Wanneer je klaar bent om te spelen, open je mijn spelsleutel die je meteen van mij zult ontvangen."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Laten we Big Bang " & game_name & " voor Mac OS X spelen. Ik denk niet dat je het spel hebt, dus daarom stuur ik het je hierbij!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Laat het me weten wanneer je klaar bent om te spelen, dan nodig ik je uit voor een spel."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Want to play Big Bang " & game_name & " for Mac OS X? (If you don't have it, let me know and I can send it with one click!)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "When you're ready to play, simply open my game key which I'm sending to you next."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Let's play Big Bang " & game_name & " for Mac OS X. I don't think you have it, so, here it is!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "When you're ready to play, let me know and I'll invite you to a game."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+(* The calling application will define the following variables for you: * * oldPath - A Mac OS 9 styled full path name to the attachment file * unixPath - A Unix-styled full path name * theRecipients - A comma-separated list of email addresses to send to * theSubject - String which contained the subject * theBody - String which contains the body of the email *) tell application "Eudora" set newMessage to make new message at end of mailbox "Out" tell newMessage set subject to theSubject set body to theBody & return & return set field "to" to theRecipients attach to newMessage documents {oldPath as alias} end tell activate return true end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Une partie de Big Bang " & game_name & " pour Mac OS X ? (Si tu n'as pas ce jeu, dis-le moi et je te l'envoie d'un simple clic !)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Pour jouer, il suffit d'ouvrir le fichier que je vais t'envoyer."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Faisons une partie de Big Bang " & game_name & " pour Mac OS X. Comme tu n'as pas ce jeu, je te l'envoie !" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Dis-moi quand tu veux jouer et je t'inviterai pour une partie."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Willst Du Big Bang " & game_name & " auf einem Mac OS X spielen? (Wenn Du das Spiel nicht besitzt, gib mir Bescheid. Ich kann es mit einem Klick senden.)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Wenn Du spielbereit bist, verwende einfach meinen Spieleschluessel, den ich Dir gleich sende."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Lass uns Big Bang " & game_name & " for Mac OS X spielen. Ich glaube, dass Du es nicht hast. Hier ist es." as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Wenn Du spielbereit bist, gebe mir Bescheid, und ich lade Dich zu einem Spiel ein."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Vuoi giocare a Big Bang " & game_name & " per Mac OS X? (Se non ce l'hai, fammelo sapere e te lo mando in un clic!)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Quando sei pronto per giocare, apri la chiave della partita che ti mando."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Giochiamo a Big Bang " & game_name & " per Mac OS X. Non mi sembra che tu ce l'abbia, quindi te lo mando!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Quando sei pronto per giocare, fammelo sapere."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Want to play Big Bang " & game_name & " for Mac OS X? (If you don't have it, let me know and I can send it with one click!)" as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "When you're ready to play, simply open my game key which I'm sending to you next."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Let's play Big Bang " & game_name & " for Mac OS X. I don't think you have it, so, here it is!" as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "When you're ready to play, let me know and I'll invite you to a game."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+(* The calling application will define the following variables for you: * * oldPath - A Mac OS 9 styled full path name to the attachment file * unixPath - A Unix-styled full path name * theRecipients - A comma-separated list of email addresses to send to * theSubject - String which contained the subject * theBody - String which contains the body of the email *) tell application "Mail" activate set this_message to make new compose message at beginning of every compose message with properties {subject:theSubject,content:theBody} tell this_message set content to return & return & content make new recipient at end of recipients with properties {display name:theRecipients} tell content make new text attachment with properties {file name:unixPath} at before the first word of the first paragraph end tell end tell set content of this_message to the content of this_message make new message editor at beginning of message editors set compose message of message editor 1 to this_message return true end tell
+(* The calling application will define the following variables for you:
+ *
+ * oldPath - A Mac OS 9 styled full path name to the attachment file
+ * unixPath - A Unix-styled full path name
+ * theRecipients - A comma-separated list of email addresses to send to
+ * theSubject - String which contained the subject
+ * theBody - String which contains the body of the email
+ *)
+
+set theBody to the clipboard as Unicode text
+
+tell application "Mail"
+
+ set newMessage to make new outgoing message with properties {subject:theSubject, content:return}
+ tell newMessage
+ set visible to true
+ make new to recipient at end of to recipients with properties {name:theRecipients}
+ tell content
+ make new attachment with properties {file name:unixPath} at after the last paragraph
+ make new text at after the last paragraph with data (return & return & theBody)
+ end tell
+ end tell
+
+ activate
+
+ return true
+end tell
+(* The calling application will define the following variables for you:
+ *
+ * oldPath - A Mac OS 9 styled full path name to the attachment file
+ * unixPath - A Unix-styled full path name
+ * theRecipients - A comma-separated list of email addresses to send to
+ * theSubject - String which contained the subject
+ * theBody - String which contains the body of the email
+ *)
+
+tell application "Microsoft Entourage"
+
+ set newMessage to make new draft window with properties {recipient:theRecipients, subject:theSubject, content:theBody & return & return}
+ tell newMessage
+ make new file with properties {name:oldPath}
+ end tell
+
+ activate
+
+ return true
+end tell
+(* The calling application will define the following variables for you:
+ *
+ * oldPath - A Mac OS 9 styled full path name to the attachment file
+ * unixPath - A Unix-styled full path name
+ * theRecipients - A comma-separated list of email addresses to send to
+ * theSubject - String which contained the subject
+ * theBody - String which contains the body of the email
+ *)
+
+tell application "Outlook Express"
+ set newMessage to make new draft window with properties {recipient:theRecipients, subject:theSubject, content:theBody & return & return}
+ tell newMessage
+ make new file with properties {name:oldPath}
+ end tell
+
+ activate
+
+ return true
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Quieres jugar a Big Bang " & game_name & " para Mac OS X? Si no lo tienes, te lo hago llegar con un simple clic." as string)
+
+ set chat_message to chat_message & chat_string
+
+ set chat_message to chat_message & "Para empezar a jugar, abre el archivo de llave de partida que te paso."
+
+ repeat with j from 1 to the number of services
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+ end repeat
+
+ return false
+end tell
+tell application "iChat"
+
+ activate
+
+ set chat_message to {}
+
+ set chat_string to ("Juguemos a Big Bang " & game_name & " para Mac OS X. Creo que no lo tienes. Te lo paso." as string)
+
+
+ set chat_message to chat_message & chat_string
+ set chat_message to chat_message & "Cuando quieras jugar me lo dices y te invito a una partida."
+
+ repeat with j from 1 to the number of services
+
+ repeat with i from 1 to the number of accounts of item j of services
+
+ if (id of item i of accounts of item j of services as string) is equal to target_id then
+
+ set user_status to status of item i of accounts of item j of services
+ set user_idle to idle time of item i of accounts of item j of services
+
+ if user_status is available and user_idle is 0 then
+
+ repeat with k from 1 to the number of items of chat_message
+ send item k of chat_message to item i of accounts of item j of services
+ end repeat
+
+ --send ("Big Bang " & game_name & "" as string) to item i of accounts of item j of services
+
+ set frontmost to true
+
+ return true
+
+ end if
+ end if
+
+ end repeat
+
+ end repeat
+
+ return false
+end tell
+
+-- First we initialize a few variables
+-- TODO remove the unused ones
+set myEvList to {}
+set myTaskList to {}
+set theTextList to ""
+set theError to 0
+set theImfile to ""
+set theDocRef to 0
+set theImFileName to ""
+set gEntourageWasRunning to true
+set gMinimunPBar to 0.005
+set gProgression to 0
+set gNTasks to 0
+set gNEvents to 0
+
+-- Creating a new calendar in iCal
+
+tell application "iCal"
+ activate
+ make new calendar with properties {title:"Entourage"}
+ delay (0.5)
+end tell
+
+-- Getting the events from Entourage (not there is no way to choose which Entourage in this one)
+try
+ if (theError of me is equal to 0) then
+ tell application "Microsoft Entourage"
+ --log "Entourage import, start getting events " & (current date)
+ activate
+
+ set myEEvents to get every event
+ set my gNEvents to count (myEEvents)
+ set myTasks to tasks where its completed is equal to false
+ set my gNTasks to count (myTasks)
+
+ if my gNTasks is not equal to 0 then
+ set entIncrement to (round ((count myEEvents) / 40) rounding up)
+ else
+ set entIncrement to (round ((count myEEvents) / 80) rounding up)
+ end if
+ set progEntIdx to 0
+
+ repeat with aEEvent in myEEvents
+ set tmpVal to {}
+ -- append raw properties to the list as list of records have their own syntax
+ set tmpVal to tmpVal & (get subject of aEEvent as Unicode text)
+
+ set begDate to (get start time of aEEvent)
+ set endDate to (get end time of aEEvent)
+ set addFlag to (get all day event of aEEvent)
+ if addFlag is equal to false then
+ if (endDate - begDate) > 24 * hours then
+ set addFlag to true
+ set time of begDate to 0
+ set time of endDate to 0
+ set dday to day of endDate
+ set day of endDate to dday + 1
+ end if
+ end if
+ set tmpVal to tmpVal & addFlag
+ set tmpVal to tmpVal & begDate
+ set tmpVal to tmpVal & endDate
+
+ set tmpVal to tmpVal & (get recurring of aEEvent)
+ set tmpVal to tmpVal & (get recurrence of aEEvent)
+ set tmpVal to tmpVal & (get location of aEEvent as Unicode text)
+ set tmpVal to tmpVal & (get content of aEEvent as Unicode text)
+ set (myEvList of me) to (myEvList of me) & tmpVal
+ set progEntIdx to progEntIdx + 1
+ if progEntIdx is equal to entIncrement then
+ set progEntIdx to 0
+ end if
+ end repeat
+
+ --log "Entourage import, start getting tasks " & (current date)
+ if (my gNTasks) is not equal to 0 then
+ --if count task is not equal to 0 then
+ set my gProgression to 0.3
+ set entIncrement to (round ((my gNTasks) / 40) rounding up)
+
+ set progEntIdx to 0
+
+ repeat with aTask in myTasks
+ set tmpVal to {}
+ set tmpVal to tmpVal & (get the name of aTask as Unicode text)
+ set tmpVal to tmpVal & (get the due date of aTask)
+ set tmpPri to the priority of aTask
+ if tmpPri is equal to highest then
+ set tmpVal to tmpVal & 1
+ else if tmpPri is equal to high then
+ set tmpVal to tmpVal & 4
+ else if tmpPri is equal to low then
+ set tmpVal to tmpVal & 7
+ else if tmpPri is equal to lowest then
+ set tmpVal to tmpVal & 7
+ else
+ set tmpVal to tmpVal & 0
+ end if
+ set tmpVal to tmpVal & (get content of aTask as Unicode text)
+
+ set (myTaskList of me) to (myTaskList of me) & tmpVal
+ set progEntIdx to progEntIdx + 1
+
+ if progEntIdx is equal to entIncrement then
+ set progEntIdx to 0
+ end if
+ end repeat
+ end if
+ end tell
+ end if
+
+ --correct the recurrences
+ set parsidx to 0
+ repeat my gNEvents times
+ set entRule to (item (parsidx + 6) of (myEvList of me))
+ if (entRule) is not equal to "" then
+ set offUntil to offset of "UNTIL=" in entRule
+ if offUntil is not equal to 0 then
+ set icalRule to text 1 through (offUntil + 5) of entRule
+ set remainText to (text (offUntil + 6) through (length of (entRule)) of entRule)
+ set endPos to offset of ";" in remainText
+ set untilDateStr to (text 1 through (endPos - 1) of remainText) as string
+ set untilYear to (items 1 through 4 of untilDateStr) as string
+ set untilMonth to (items 5 through 6 of untilDateStr) as string
+ set untilDay to (items 7 through 8 of untilDateStr) as string
+
+ set untilDate to current date
+ set day of untilDate to untilDay
+ set year of untilDate to untilYear
+
+ if untilMonth is equal to "01" then
+ set month of untilDate to January
+ else if untilMonth is equal to "02" then
+ set month of untilDate to February
+ else if untilMonth is equal to "03" then
+ set month of untilDate to March
+ else if untilMonth is equal to "04" then
+ set month of untilDate to April
+ else if untilMonth is equal to "05" then
+ set month of untilDate to May
+ else if untilMonth is equal to "06" then
+ set month of untilDate to June
+ else if untilMonth is equal to "07" then
+ set month of untilDate to July
+ else if untilMonth is equal to "08" then
+ set month of untilDate to August
+ else if untilMonth is equal to "09" then
+ set month of untilDate to September
+ else if untilMonth is equal to "10" then
+ set month of untilDate to October
+ else if untilMonth is equal to "11" then
+ set month of untilDate to November
+ else if untilMonth is equal to "12" then
+ set month of untilDate to December
+ end if
+
+ set newUntilDate to untilDate + 1 * days
+ set newUntiDateStr to ((year of newUntilDate) as string)
+ if (month of newUntilDate) as string is equal to "January" then
+ set newUntiDateStr to newUntiDateStr & "01"
+ else if (month of newUntilDate) as string is equal to "February" then
+ set newUntiDateStr to newUntiDateStr & "02"
+ else if (month of newUntilDate) as string is equal to "March" then
+ set newUntiDateStr to newUntiDateStr & "03"
+ else if (month of newUntilDate) as string is equal to "April" then
+ set newUntiDateStr to newUntiDateStr & "04"
+ else if (month of newUntilDate) as string is equal to "May" then
+ set newUntiDateStr to newUntiDateStr & "05"
+ else if (month of newUntilDate) as string is equal to "June" then
+ set newUntiDateStr to newUntiDateStr & "06"
+ else if (month of newUntilDate) as string is equal to "July" then
+ set newUntiDateStr to newUntiDateStr & "07"
+ else if (month of newUntilDate) as string is equal to "August" then
+ set newUntiDateStr to newUntiDateStr & "08"
+ else if (month of newUntilDate) as string is equal to "September" then
+ set newUntiDateStr to newUntiDateStr & "09"
+ else if (month of newUntilDate) as string is equal to "October" then
+ set newUntiDateStr to newUntiDateStr & "10"
+ else if (month of newUntilDate) as string is equal to "November" then
+ set newUntiDateStr to newUntiDateStr & "11"
+ else if (month of newUntilDate) as string is equal to "December" then
+ set newUntiDateStr to newUntiDateStr & "12"
+ end if
+
+ if day of newUntilDate < 10 then
+ set newUntiDateStr to newUntiDateStr & "0" & day of newUntilDate
+ else
+ set newUntiDateStr to newUntiDateStr & day of newUntilDate
+ end if
+ set icalRule to icalRule & newUntiDateStr & (items 9 through (length of untilDateStr) of untilDateStr) as string
+ set icalRule to icalRule & (text endPos through (length of (remainText)) of remainText)
+ set (item (parsidx + 6) of (myEvList of me)) to icalRule
+ end if
+ end if
+ set parsidx to parsidx + 8
+ end repeat
+ -- put the events in iCal
+
+ tell application "iCal"
+ set my gProgression to 0.5
+ set progression to my gProgression
+ activate
+ log "Entourage import, storing events in iCal " & (current date)
+ set parsidx to 0
+ set numEvents to (count (myEvList of me)) / 8
+
+ if my gNTasks is not equal to 0 then
+ set entIncrement to (round ((my gNEvents) / 50) rounding up)
+ else
+ set entIncrement to (round ((my gNEvents) / 100) rounding up)
+ end if
+
+ set progEntIdx to 0
+
+ repeat numEvents times
+ set evtSummary to (item (parsidx + 1) of (myEvList of me)) as Unicode text
+ set evtStartDate to item (parsidx + 3) of (myEvList of me)
+ set evtLocation to (item (parsidx + 7) of (myEvList of me))
+ set evtNotes to (item (parsidx + 8) of (myEvList of me))
+ set isAD to (item (parsidx + 2) of (myEvList of me)) as boolean
+
+ if isAD is equal to true then
+ set evtADD to true
+ set evtEndDate to item (parsidx + 4) of (myEvList of me)
+ if ((item (parsidx + 5) of (myEvList of me)) is equal to true) then
+ set evtRecRule to (item (parsidx + 6) of (myEvList of me))
+ --my translateReccurenceRule
+ set myNewADEvent to make new event at the end of events of last calendar
+ tell myNewADEvent
+ set summary to evtSummary
+ set start date to evtStartDate
+ set end date to evtEndDate - 1
+ set allday event to true
+ set recurrence to evtRecRule
+ set description to evtNotes
+ set location to evtLocation
+ end tell
+ else
+ set myNewADEvent to make new event at the end of events of last calendar
+ tell myNewADEvent
+ set summary to evtSummary
+ set start date to evtStartDate
+ set end date to evtEndDate - 1
+ set allday event to true
+ set description to evtNotes
+ set location to evtLocation
+ end tell
+ end if
+ else
+ set evtEndDate to item (parsidx + 4) of (myEvList of me)
+ if ((item (parsidx + 5) of (myEvList of me)) is equal to true) then
+ set evtRecRule to (item (parsidx + 6) of (myEvList of me))
+ -- my translateReccurenceRule
+ make new event with properties {summary:evtSummary, start date:evtStartDate, end date:evtEndDate, recurrence:evtRecRule, location:evtLocation, description:evtNotes} at the end of events of last calendar
+ else
+ make new event with properties {summary:evtSummary, start date:evtStartDate, end date:evtEndDate, location:evtLocation, description:evtNotes} at the end of events of last calendar
+ end if
+ end if
+
+
+ set parsidx to parsidx + 8
+ set progEntIdx to progEntIdx + 1
+
+ if progEntIdx is equal to entIncrement then
+ set progEntIdx to 0
+ set my gProgression to ((my gProgression) + gMinimunPBar)
+ set progression to my gProgression
+ end if
+ end repeat
+ -- log "Entourage import : end of events" & (current date)
+ if my gNTasks is not equal to 0 then
+ set my gProgression to 0.75
+ set progression to my gProgression
+ set parsjdx to 0
+ set entIncrement to (round ((my gNTasks) / 50) rounding up)
+ set progEntIdx to 0
+ repeat my gNTasks times
+ set tdSummary to (item (parsjdx + 1) of (myTaskList of me)) as Unicode text
+ -- set tdPriority to no priority -- (item (parsjdx + 3) of (myTaskList of me)) as integer
+ set msPriority to (item (parsjdx + 3) of (myTaskList of me)) as integer
+ set tdContent to (item (parsjdx + 4) of (myTaskList of me)) as Unicode text
+ if msPriority is equal to 1 then
+ set tdPriority to high priority
+ else if msPriority is equal to 4 then
+ set tdPriority to medium priority
+ else if msPriority is equal to 7 then
+ set tdPriority to low priority
+ else if msPriority is equal to 0 then
+ set tdPriority to no priority
+ end if
+ set tdDueDate to item (parsjdx + 2) of (myTaskList of me)
+ set yearPosDueDate to year of tdDueDate
+ --Entourage marks ToDo with no due date to 1904
+ if yearPosDueDate is not equal to 1904 then
+ make new todo with properties {summary:tdSummary, priority:tdPriority, due date:tdDueDate, description:tdContent} at the end of todos of last calendar
+ else
+ make new todo with properties {summary:tdSummary, priority:tdPriority, description:tdContent} at the end of todos of last calendar
+ end if
+ set parsjdx to parsjdx + 4
+ set progEntIdx to progEntIdx + 1
+
+ if progEntIdx is equal to entIncrement then
+ set progEntIdx to 0
+ set my gProgression to ((my gProgression) + gMinimunPBar)
+ set progression to my gProgression
+ end if
+ end repeat
+ end if
+ set progression to 1
+ delay 0.9
+ end tell
+on error errorMessageVariable
+ log errorMessageVariable
+ if errorMessageVariable is equal to "Cancel Operation" then
+ tell application "iCal"
+ log "Operation cancelled"
+ end tell
+ end if
+end try
+
+--tell application "iCal"
+-- dismiss progress
+--end tell
+
+-- reput Entourage to its initial state
+--if (gEntourageWasRunning of me) is equal to false then
+tell application "Microsoft Entourage" to quit
+--end if
+
+on translateReccurenceRule(entRule)
+ set icalRule to entRule
+
+ set offUntil to offset of "UNTIL=" in entRule
+ if offUntil is not equal to 0 then
+ set icalRule to text 1 through (offUntil + 5) of entRule
+ set remainText to (text (offUntil + 6) through (length of (entRule)) of entRule)
+ set endPos to offset of ";" in remainText
+ set untilDateStr to (text 1 through (endPos - 1) of remainText) as string
+ log untilDateStr
+ set untilYear to (items 1 through 4 of untilDateStr) as string
+ set untilMonth to (items 5 through 6 of untilDateStr) as string
+ set untilDay to (items 7 through 8 of untilDateStr) as string
+ set untilDate to date (untilMonth & "/" & untilDay & "/ " & untilYear)
+ set newUntilDate to untilDate + 1 * days
+ set newUntiDateStr to ((year of newUntilDate) as string)
+ if (month of newUntilDate) as string is equal to "January" then
+ set newUntiDateStr to newUntiDateStr & "01"
+ else if (month of newUntilDate) as string is equal to "February" then
+ set newUntiDateStr to newUntiDateStr & "02"
+ else if (month of newUntilDate) as string is equal to "March" then
+ set newUntiDateStr to newUntiDateStr & "03"
+ else if (month of newUntilDate) as string is equal to "April" then
+ set newUntiDateStr to newUntiDateStr & "04"
+ else if (month of newUntilDate) as string is equal to "May" then
+ set newUntiDateStr to newUntiDateStr & "05"
+ else if (month of newUntilDate) as string is equal to "June" then
+ set newUntiDateStr to newUntiDateStr & "06"
+ else if (month of newUntilDate) as string is equal to "July" then
+ set newUntiDateStr to newUntiDateStr & "07"
+ else if (month of newUntilDate) as string is equal to "August" then
+ set newUntiDateStr to newUntiDateStr & "08"
+ else if (month of newUntilDate) as string is equal to "September" then
+ set newUntiDateStr to newUntiDateStr & "09"
+ else if (month of newUntilDate) as string is equal to "October" then
+ set newUntiDateStr to newUntiDateStr & "10"
+ else if (month of newUntilDate) as string is equal to "November" then
+ set newUntiDateStr to newUntiDateStr & "11"
+ else if (month of newUntilDate) as string is equal to "December" then
+ set newUntiDateStr to newUntiDateStr & "12"
+ end if
+
+ if day of newUntilDate < 10 then
+ set newUntiDateStr to newUntiDateStr & "0" & day of newUntilDate
+ else
+ set newUntiDateStr to newUntiDateStr & day of newUntilDate
+ end if
+ set icalRule to icalRule & newUntiDateStr & (items 9 through (length of untilDateStr) of untilDateStr) as string
+ set icalRule to icalRule & (text endPos through (length of (remainText)) of remainText)
+ end if
+
+ return icalRule
+end translateReccurenceRule
+
+on getValueForCalRecRule(aRecRule, aRuleName)
+ set ruleOffset to offset of aRuleName in aRecRule
+ if ruleOffset is not equal to 0 then
+ if (character (ruleOffset + (count of aRuleName)) of aRecRule) is equal to "=" then
+ set remainStr to text (ruleOffset + (count of aRuleName) + 1) through (count of aRecRule) of aRecRule
+ set endPos to offset of ";" in remainStr
+ set result to text 1 through (endPos - 1) of remainStr
+ return result
+ else
+ return ""
+ end if
+ else
+ return ""
+ end if
+end getValueForCalRecRule
+
+-- Mail.applescript
+-- iCal
+
+on show_mail_sbrs(subjectLine, messageText, myrecipients)
+ tell application "Mail"
+ set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:subjectLine, content:messageText})
+ repeat with i from (count of myrecipients) to 1 by -1
+ tell mymail to make new to recipient at beginning of to recipients with properties {address:(item i of myrecipients)}
+ end repeat
+ set visible of mymail to true
+ activate
+ end tell
+end show_mail_sbrs
+
+on show_mail_sbr(subjectLine, messageText, myrecipient)
+ tell application "Mail"
+ set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:subjectLine, content:messageText})
+ tell mymail to make new to recipient at beginning of to recipients with properties {address:myrecipient}
+ set visible of mymail to true
+ activate
+ end tell
+end show_mail_sbr
+
+on send_mail_sb(subjectLine, messageText)
+ tell application "Mail"
+ set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:subjectLine, content:messageText})
+ set visible of mymail to true
+ activate
+ end tell
+end send_mail_sb
+
+on send_mail_sbr(subjectLine, messageText, myrecipient)
+ tell application "Mail"
+ set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:subjectLine, content:messageText})
+ tell mymail to make new to recipient at beginning of to recipients with properties {address:myrecipient}
+ send mymail
+ end tell
+end send_mail_sbr
+
+on send_mail_sbrp(subjectLine, messageText, myrecipient, invitationPath)
+ set pfile to POSIX file invitationPath
+ set myfile to pfile as alias
+ tell application "Mail"
+ set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:subjectLine, content:messageText})
+ tell mymail to make new to recipient at beginning of to recipients with properties {address:myrecipient}
+ tell mymail
+ tell content
+ make new attachment with properties {file name:myfile} at after the last word of the the last paragraph
+ end tell
+ end tell
+ send mymail
+ end tell
+end send_mail_sbrp
+
+on send_mail_sbp(subjectLine, messageText, invitationPath)
+ set pfile to POSIX file invitationPath
+ set myfile to pfile as alias
+ tell application "Mail"
+ set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:subjectLine, content:messageText})
+ tell mymail
+ tell content
+ make new attachment with properties {file name:myfile} at after the last word of the the last paragraph
+ end tell
+ end tell
+ set visible of mymail to true
+ activate
+ end tell
+end send_mail_sbp
+
+tell application "Mail" activate set mysubject to $1 set mybody to $2 set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:mysubject, content:mybody}) set visible of mymail to true end tell
+tell application "Mail" set mysubject to $1 set mybody to $2 set myrecipient to $3 set mymail to (make new outgoing message at the beginning of outgoing messages with properties { subject:mysubject, content:mybody}) tell mymail to make new to recipient at beginning of to recipients with properties {name:myrecipient} send mymail end tell
+tell application "Mail" set mysubject to $1 set mybody to $2 set myrecipient to $3 set pfile to $4 set myfile to pfile as alias set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:mysubject, content:mybody}) tell mymail to make new to recipient at beginning of to recipients with properties {name:myrecipient} tell mymail tell content make new attachment with properties {file name:myfile} at after the last word of the the last paragraph end tell end tell send mymail end tell
+-- Mail.applescript
+-- iCal
+
+on show_mail_sbrs(subjectLine, messageText, myrecipients)
+ tell application "Mail"
+ set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:subjectLine, content:messageText})
+ repeat with i from (count of myrecipients) to 1 by -1
+ tell mymail to make new to recipient at beginning of to recipients with properties {address:(item i of myrecipients)}
+ end repeat
+ set visible of mymail to true
+ activate
+ end tell
+end show_mail_sbrs
+
+on show_mail_sbr(subjectLine, messageText, myrecipient)
+ tell application "Mail"
+ set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:subjectLine, content:messageText})
+ tell mymail to make new to recipient at beginning of to recipients with properties {address:myrecipient}
+ set visible of mymail to true
+ activate
+ end tell
+end show_mail_sbr
+
+on send_mail_sb(subjectLine, messageText)
+ tell application "Mail"
+ set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:subjectLine, content:messageText})
+ set visible of mymail to true
+ activate
+ end tell
+end send_mail_sb
+
+on send_mail_sbr(subjectLine, messageText, myrecipient)
+ tell application "Mail"
+ set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:subjectLine, content:messageText})
+ tell mymail to make new to recipient at beginning of to recipients with properties {address:myrecipient}
+ send mymail
+ end tell
+end send_mail_sbr
+
+on send_mail_sbrp(subjectLine, messageText, myrecipient, invitationPath)
+ set pfile to POSIX file invitationPath
+ set myfile to pfile as alias
+ tell application "Mail"
+ set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:subjectLine, content:messageText})
+ tell mymail to make new to recipient at beginning of to recipients with properties {address:myrecipient}
+ tell mymail
+ tell content
+ make new attachment with properties {file name:myfile} at after the last word of the the last paragraph
+ end tell
+ end tell
+ send mymail
+ end tell
+end send_mail_sbrp
+
+on send_mail_sbp(subjectLine, messageText, invitationPath)
+ set pfile to POSIX file invitationPath
+ set myfile to pfile as alias
+ tell application "Mail"
+ set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:subjectLine, content:messageText})
+ tell mymail
+ tell content
+ make new attachment with properties {file name:myfile} at after the last word of the the last paragraph
+ end tell
+ end tell
+ set visible of mymail to true
+ activate
+ end tell
+end send_mail_sbp
+
+tell application "Mail" activate set mysubject to $1 set mybody to $2 set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:mysubject, content:mybody}) set visible of mymail to true end tell
+tell application "Mail" set mysubject to $1 set mybody to $2 set myrecipient to $3 set mymail to (make new outgoing message at the beginning of outgoing messages with properties { subject:mysubject, content:mybody}) tell mymail to make new to recipient at beginning of to recipients with properties {name:myrecipient} send mymail end tell
+tell application "Mail" set mysubject to $1 set mybody to $2 set myrecipient to $3 set pfile to $4 set myfile to pfile as alias set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:mysubject, content:mybody}) tell mymail to make new to recipient at beginning of to recipients with properties {name:myrecipient} tell mymail tell content make new attachment with properties {file name:myfile} at after the last word of the the last paragraph end tell end tell send mymail end tell
+on activate_iterm(shellCommand)
+ tell application "iTerm"
+ make new terminal
+ tell the first terminal
+ activate current session
+ launch session "Default Session"
+ tell the last session
+ write text shellCommand
+ end tell
+ end tell
+ activate
+ end tell
+end activate_iterm
+on activate_terminal(shellCommand)
+ tell application "Finder"
+ if exists process "Terminal" then
+ tell application "Terminal"
+ activate
+ do script shellCommand
+ end tell
+ else
+ tell application "Terminal"
+ activate
+ do script shellCommand in window 0
+ end tell
+ end if
+ end tell
+end activate_terminal
+tell application "Mail"
+ set composeWindow to make new outgoing message with properties {subject:"SelfTest message", content:"This is a test message for SelfTest.", visible:true}
+ close composeWindow without saving
+end tell
+-- dynamicCall publish("[[QTExpNameOut]]")
+
+on publish(attachedFilePath)
+ tell application "Mail"
+ set new_message to make new outgoing message
+ tell new_message
+ set visible to true
+ make new to recipient at end of to recipients
+ tell content
+ make new attachment with properties {file name:attachedFilePath} at after the last paragraph
+ end tell
+ end tell
+ activate
+ end tell
+end publish
+-- ${TM_NEW_FILE_BASENAME}.applescript
+--
+-- Created by ${TM_USERNAME} on ${TM_DATE}.
+-- Copyright (c) ${TM_YEAR} ${TM_ORGANIZATION_NAME}. All rights reserved.
+--
+
+on open dropped_items
+
+ -- do something useful
+
+end open
+-- ${TM_NEW_FILE_BASENAME}.applescript
+--
+-- Created by ${TM_USERNAME} on ${TM_DATE}.
+-- Copyright (c) ${TM_YEAR} ${TM_ORGANIZATION_NAME}. All rights reserved.
+--
+
+on adding folder items to this_folder after receiving added_items
+
+ -- do something useful
+
+end adding folder items to
+
+
+
+on removing folder items from this_folder after losing removed_items
+
+ -- do something useful
+
+end removing folder items from
+
+
+
+on opening folder this_folder
+
+ -- do something useful
+
+end opening folder
+
+
+
+on moving folder window for this_folder from original_bounds
+
+ -- do something useful
+
+end moving folder window for
+
+
+
+on closing folder window for this_folder
+
+ -- do something useful
+
+end closing folder window for
+-- ${TM_NEW_FILE_BASENAME}.applescript
+--
+-- Created by ${TM_USERNAME} on ${TM_DATE}.
+-- Copyright (c) ${TM_YEAR} ${TM_ORGANIZATION_NAME}. All rights reserved.
+--
+-- Place in ~/Library/Application Support/Quicksilver/Actions/
+--
+
+using terms from application "Quicksilver"
+ on process text the_text
+
+ -- do something useful
+
+ end process text
+end using terms from
+-- ${TM_NEW_FILE_BASENAME}.applescript
+--
+-- Created by ${TM_USERNAME} on ${TM_DATE}.
+-- Copyright (c) ${TM_YEAR} ${TM_ORGANIZATION_NAME}. All rights reserved.
+--
+
+on run
+
+ -- do something useful
+
+end run
+-- ${TM_NEW_FILE_BASENAME}.applescript
+--
+-- Created by ${TM_USERNAME} on ${TM_DATE}.
+-- Copyright (c) ${TM_YEAR} ${TM_ORGANIZATION_NAME}. All rights reserved.
+--
+
+on run argv
+
+ -- do something useful
+
+end run
+-----------------------------------------------------------------------------
+-- Name: docs/mac/M5build.applescript
+-- Purpose: Automatic build of projects with CodeWarrior 5
+-- Author: Gilles Depeyrot
+-- Modified by:
+-- Created: 06.10.2001
+-- RCS-ID: $Id: M5build.applescript,v 1.3 2001/12/02 20:02:17 GD Exp $
+-- Copyright: (c) 2001 Gilles Depeyrot
+-- Licence: wxWindows licence
+-----------------------------------------------------------------------------
+--
+-- This AppleScript automatically recurses through the selected folder looking for
+-- and building CodeWarrior projects.
+-- To use this script, simply open it with the 'Script Editor' and run it.
+--
+
+--
+-- Suffix used to recognize CodeWarrior project files
+--
+property gProjectSuffix : "M5.mcp"
+
+--
+-- Values used to create the log file
+--
+property gEol : "
+"
+property gSeparator : "-------------------------------------------------------------------------------" & gEol
+
+--
+-- Project and build success count
+--
+set theProjectCount to 0
+set theProjectSuccessCount to 0
+
+--
+-- Default log file name
+--
+set theDate to (day of (current date)) & "/" & GetMonthIndex(current date) & "/" & (year of (current date))
+set theLogFileName to "build-" & theDate & ".log"
+
+--
+-- Ask the user to select the wxWindows samples folder
+--
+set theFolder to choose folder with prompt "Select the folder in which to build the projects"
+
+--
+-- Ask the user to choose the build log file
+--
+set theLogFile to choose file name with prompt "Save the build log file" default name theLogFileName
+
+--
+-- Open the log file to record the build log
+--
+set theLogFileRef to open for access theLogFile with write permission
+
+--
+-- Write log file header
+--
+write gSeparator starting at 0 to theLogFileRef
+write "Build log" & gEol to theLogFileRef
+write gSeparator to theLogFileRef
+write "start on " & ((current date) as string) & gEol to theLogFileRef
+write gSeparator to theLogFileRef
+write "building projects in '" & (theFolder as string) & "'" & gEol to theLogFileRef
+write gSeparator to theLogFileRef
+
+--
+-- Build or Rebuild targets?
+--
+set theText to "Build or rebuild projects?"
+set theBuild to button returned of (display dialog theText buttons {"Cancel", "Build", "Rebuild"} default button "Rebuild" with icon note)
+if theBuild is not equal to "Cancel" then
+ --
+ -- Build which targets?
+ --
+ set theText to theBuild & " Classic or Carbon targets?"
+ set theType to button returned of (display dialog theText buttons {"Cancel", "Classic", "Carbon"} default button "Carbon" with icon note)
+ if theType is not equal to "Cancel" then
+ --
+ -- Build Debug or Release targets?
+ --
+ set theText to theBuild & " " & theType & " Debug or " & theType & " Release targets?"
+ set theOption to button returned of (display dialog theText buttons {"Cancel", "Release", "Debug"} default button "Debug" with icon note)
+ if theOption is not equal to "Cancel" then
+ set theTarget to theType & " " & theOption
+
+ write "building project targets '" & theTarget & "'" & gEol to theLogFileRef
+ write gSeparator to theLogFileRef
+
+ BuildProjects(theLogFileRef, theFolder, theTarget, theBuild is equal to "Rebuild")
+
+ end if
+ end if
+end if
+
+--
+-- Write log file footer
+--
+write "successful build of " & theProjectSuccessCount & " projects out of " & theProjectCount & gEol to theLogFileRef
+write gSeparator to theLogFileRef
+write "end on " & ((current date) as string) & gEol to theLogFileRef
+write gSeparator to theLogFileRef
+--
+-- Close the log file
+--
+close access theLogFileRef
+
+--
+-- BuildProjects
+--
+on BuildProjects(inLogFileRef, inFolder, inTarget, inRebuild)
+ global theProjectCount, theProjectSuccessCount
+
+ tell application "Finder" to update inFolder
+
+ try
+ tell application "Finder" to set theProject to ((the first file of inFolder whose name ends with gProjectSuffix) as string)
+ on error
+ set theProject to ""
+ end try
+
+ if theProject is not "" then
+ set theProjectCount to theProjectCount + 1
+
+ write "building project '" & theProject & "'" & gEol to inLogFileRef
+
+ tell application "CodeWarrior IDE 4.0.4"
+ --
+ -- Open the project in CodeWarrior
+ --
+ open theProject
+ --
+ -- Change to the requested target
+ --
+ Set Current Target inTarget
+ --
+ -- Remove object code if rebuild requested
+ --
+ if inRebuild then
+ Remove Binaries
+ end if
+ --
+ -- Build/Rebuild the selected target
+ --
+ set theBuildInfo to Make Project with ExternalEditor
+ --
+ -- Close the project
+ --
+ Close Project
+ end tell
+ --
+ -- Report errors to build log file
+ --
+ write gEol to inLogFileRef
+ ReportBuildInfo(inLogFileRef, theBuildInfo)
+ write gSeparator to inLogFileRef
+ end if
+
+ tell application "Finder" to set theSubFolders to every folder of inFolder whose name does not end with " Data"
+ repeat with theFolder in theSubFolders
+ BuildProjects(inLogFileRef, theFolder, inTarget, inRebuild)
+ end repeat
+
+end BuildProjects
+
+--
+-- ReportBuildInfo
+--
+on ReportBuildInfo(inLogFileRef, inBuildInfo)
+ global theProjectCount, theProjectSuccessCount
+
+ set theErrorCount to 0
+ set theWarningCount to 0
+
+ repeat with theInfo in inBuildInfo
+ tell application "CodeWarrior IDE 4.0.4"
+ set theKind to ((messageKind of theInfo) as string)
+
+ tell me to write "*** " & theKind & " *** " & message of theInfo & gEol to inLogFileRef
+ try
+ set theFile to ((file of theInfo) as string)
+ on error
+ set theFile to ""
+ end try
+ if theFile is not "" then
+ tell me to write theFile & " line " & lineNumber of theInfo & gEol to inLogFileRef
+ end if
+ tell me to write gEol to inLogFileRef
+ end tell
+
+ if MessageKindIsError(theKind) then
+ set theErrorCount to theErrorCount + 1
+ else
+ set theWarningCount to theWarningCount + 1
+ end if
+ end repeat
+
+ if theErrorCount is 0 then
+ set theProjectSuccessCount to theProjectSuccessCount + 1
+ write "build succeeded with " & theWarningCount & " warning(s)" & gEol to inLogFileRef
+ else
+ write "build failed with " & theErrorCount & " error(s) and " & theWarningCount & " warning(s)" & gEol to inLogFileRef
+ end if
+end ReportBuildInfo
+
+--
+-- MessageKindIsError
+--
+on MessageKindIsError(inKind)
+ if inKind is "compiler error" or inKind is "linker error" or inKind is "generic error" then
+ return true
+ else
+ return false
+ end if
+end MessageKindIsError
+
+--
+-- GetMonthIndex
+--
+on GetMonthIndex(inDate)
+ set theMonth to the month of inDate
+ set theMonthList to {January, February, March, April, May, June, July, August, September, October, November, December}
+ repeat with i from 1 to the number of items in theMonthList
+ if theMonth is item i of theMonthList then
+ return i
+ end if
+ end repeat
+end GetMonthIndex
+-----------------------------------------------------------------------------
+-- Name: docs/mac/M5mcp2xml.applescript
+-- Purpose: Automatic export of CodeWarrior 5 projects to XML files
+-- Author: Gilles Depeyrot
+-- Modified by:
+-- Created: 28.11.2001
+-- RCS-ID: $Id: M5mcp2xml.applescript,v 1.2 2001/12/02 20:02:17 GD Exp $
+-- Copyright: (c) 2001 Gilles Depeyrot
+-- Licence: wxWindows licence
+-----------------------------------------------------------------------------
+--
+-- This AppleScript automatically recurses through the selected folder looking for
+-- and exporting CodeWarrior projects to xml files.
+-- To use this script, simply open it with the 'Script Editor' and run it.
+--
+
+--
+-- Suffix used to recognize CodeWarrior project files
+--
+property gProjectSuffix : "M5.mcp"
+
+--
+-- Project and build success count
+--
+set theProjectCount to 0
+set theProjectSuccessCount to 0
+
+--
+-- Ask the user to select the wxWindows samples folder
+--
+set theFolder to choose folder with prompt "Select the wxWindows folder"
+
+ExportProjects(theFolder)
+
+tell me to display dialog "Exported " & theProjectSuccessCount & " projects out of " & theProjectCount
+
+--
+-- ExportProjects
+--
+on ExportProjects(inFolder)
+ global theProjectCount, theProjectSuccessCount
+
+ tell application "Finder" to update inFolder
+
+ try
+ tell application "Finder" to set theProject to ((the first file of inFolder whose name ends with gProjectSuffix) as string)
+ on error
+ set theProject to ""
+ end try
+
+ if theProject is not "" then
+ set theProjectCount to theProjectCount + 1
+
+ -- save the current text delimiters
+ set theDelimiters to my text item delimiters
+
+ -- replace the ".mcp" extension with ".xml"
+ set my text item delimiters to "."
+ set theList to (every text item of theProject)
+ set theList to (items 1 thru -2 of theList)
+ set theExport to (theList as string) & ".xml"
+
+ -- restore the text delimiters
+ set my text item delimiters to theDelimiters
+
+ tell application "CodeWarrior IDE 4.0.4"
+ --
+ -- Open the project in CodeWarrior
+ --
+ open theProject
+ --
+ -- Export the selected project
+ --
+ try
+ export project document 1 in theExport
+ set theProjectSuccessCount to theProjectSuccessCount + 1
+ on error number errnum
+ tell me to display dialog "Error " & errnum & " exporting " & theExport
+ end try
+ --
+ -- Close the project
+ --
+ Close Project
+ end tell
+ end if
+
+ tell application "Finder" to set theSubFolders to every folder of inFolder whose name does not end with " Data"
+ repeat with theFolder in theSubFolders
+ ExportProjects(theFolder)
+ end repeat
+
+end ExportProjects
+-----------------------------------------------------------------------------
+-- Name: docs/mac/M5xml2mcp.applescript
+-- Purpose: Automatic import of CodeWarrior 5 xml files to projects
+-- Author: Gilles Depeyrot
+-- Modified by:
+-- Created: 30.11.2001
+-- RCS-ID: $Id: M5xml2mcp.applescript,v 1.2 2001/12/02 20:02:17 GD Exp $
+-- Copyright: (c) 2001 Gilles Depeyrot
+-- Licence: wxWindows licence
+-----------------------------------------------------------------------------
+--
+-- This AppleScript automatically recurses through the selected folder looking for
+-- and importing CodeWarrior xml files to projects
+-- To use this script, simply open it with the 'Script Editor' and run it.
+--
+
+--
+-- Suffix used to recognize CodeWarrior xml files
+--
+property gXmlSuffix : "M5.xml"
+
+--
+-- Project and build success count
+--
+set theXmlCount to 0
+set theXmlSuccessCount to 0
+
+--
+-- Ask the user to select the wxWindows samples folder
+--
+set theFolder to choose folder with prompt "Select the wxWindows folder"
+
+ImportProjects(theFolder)
+
+tell me to display dialog "Imported " & theXmlSuccessCount & " xml files out of " & theXmlCount buttons {"OK"}
+
+--
+-- ImportProjects
+--
+on ImportProjects(inFolder)
+ global theXmlCount, theXmlSuccessCount
+
+ tell application "Finder" to update inFolder
+
+ try
+ tell application "Finder" to set theXml to ((the first file of inFolder whose name ends with gXmlSuffix) as string)
+ on error
+ set theXml to ""
+ end try
+
+ if theXml is not "" then
+ set theXmlCount to theXmlCount + 1
+
+ -- save the current text delimiters
+ set theDelimiters to my text item delimiters
+
+ -- replace the ".xml" extension with ".mcp"
+ set my text item delimiters to "."
+ set theList to (every text item of theXml)
+ set theList to (items 1 thru -2 of theList)
+ set theImport to (theList as string) & ".mcp"
+
+ -- restore the text delimiters
+ set my text item delimiters to theDelimiters
+
+ tell application "CodeWarrior IDE 4.0.4"
+ --
+ -- Import the selected xml file
+ --
+ try
+ make new project document as theImport with data theXml
+ set theXmlSuccessCount to theXmlSuccessCount + 1
+ --
+ -- Close the project
+ --
+ Close Project
+ on error number errnum
+ tell me to display dialog "Error " & errnum & " importing " & theXml & " to " & theImport
+ end try
+ end tell
+ end if
+
+ tell application "Finder" to set theSubFolders to every folder of inFolder whose name does not end with " Data"
+ repeat with theFolder in theSubFolders
+ ImportProjects(theFolder)
+ end repeat
+
+end ImportProjects
+-----------------------------------------------------------------------------
+-- Name: docs/mac/M8mcp2xml.applescript
+-- Purpose: Automatic export of CodeWarrior 8 projects to XML files
+-- Author: Gilles Depeyrot
+-- Modified by: Stefan Csomor for M8
+-- Created: 28.11.2001
+-- RCS-ID: $Id: M8mcp2xml.applescript,v 1.1 2003/01/16 06:44:49 SC Exp $
+-- Copyright: (c) 2001 Gilles Depeyrot
+-- Licence: wxWindows licence
+-----------------------------------------------------------------------------
+--
+-- This AppleScript automatically recurses through the selected folder looking for
+-- and exporting CodeWarrior projects to xml files.
+-- To use this script, simply open it with the 'Script Editor' and run it.
+--
+
+--
+-- Suffix used to recognize CodeWarrior project files
+--
+property gProjectSuffix : "M8.mcp"
+
+--
+-- Project and build success count
+--
+set theProjectCount to 0
+set theProjectSuccessCount to 0
+
+--
+-- Ask the user to select the wxWindows samples folder
+--
+set theFolder to choose folder with prompt "Select the wxWindows folder"
+
+ExportProjects(theFolder)
+
+tell me to display dialog "Exported " & theProjectSuccessCount & " projects out of " & theProjectCount
+
+--
+-- ExportProjects
+--
+on ExportProjects(inFolder)
+ global theProjectCount, theProjectSuccessCount
+
+ tell application "Finder" to update inFolder
+
+ try
+ tell application "Finder" to set theProject to ((the first file of inFolder whose name ends with gProjectSuffix) as string)
+ on error
+ set theProject to ""
+ end try
+
+ if theProject is not "" then
+ set theProjectCount to theProjectCount + 1
+
+ -- save the current text delimiters
+ set theDelimiters to my text item delimiters
+
+ -- replace the ".mcp" extension with ".xml"
+ set my text item delimiters to "."
+ set theList to (every text item of theProject)
+ set theList to (items 1 thru -2 of theList)
+ set theExport to (theList as string) & ".xml"
+
+ -- restore the text delimiters
+ set my text item delimiters to theDelimiters
+
+ tell application "CodeWarrior IDE"
+ --
+ -- Open the project in CodeWarrior
+ --
+ open theProject
+ --
+ -- Export the selected project
+ --
+ try
+ export project document 1 to theExport
+ set theProjectSuccessCount to theProjectSuccessCount + 1
+ on error number errnum
+ tell me to display dialog "Error " & errnum & " exporting " & theExport
+ end try
+ --
+ -- Close the project
+ --
+ Close Project
+ end tell
+ end if
+
+ tell application "Finder" to set theSubFolders to every folder of inFolder whose name does not end with " Data"
+ repeat with theFolder in theSubFolders
+ ExportProjects(theFolder)
+ end repeat
+
+end ExportProjects
+-----------------------------------------------------------------------------
+-- Name: docs/mac/M8xml2mcp.applescript
+-- Purpose: Automatic import of CodeWarrior 8 xml files to projects
+-- Author: Gilles Depeyrot
+-- Modified by: Stefan Csomor
+-- Created: 30.11.2001
+-- RCS-ID: $Id: M8xml2mcp.applescript,v 1.2 2004/04/28 22:03:15 DS Exp $
+-- Copyright: (c) 2001 Gilles Depeyrot
+-- Licence: wxWindows licence
+-----------------------------------------------------------------------------
+--
+-- This AppleScript automatically recurses through the selected folder looking for
+-- and importing CodeWarrior xml files to projects
+-- To use this script, simply open it with the 'Script Editor' and run it.
+--
+
+--
+-- Suffix used to recognize CodeWarrior xml files
+--
+property gXmlSuffix : "M8.xml"
+
+--
+-- Project and build success count
+--
+set theXmlCount to 0
+set theXmlSuccessCount to 0
+
+--
+-- Ask the user to select the wxWindows samples folder
+--
+set theFolder to choose folder with prompt "Select the wxWindows folder"
+
+ImportProjects(theFolder)
+
+tell me to display dialog "Imported " & theXmlSuccessCount & " xml files out of " & theXmlCount buttons {"OK"}
+
+--
+-- ImportProjects
+--
+on ImportProjects(inFolder)
+ global theXmlCount, theXmlSuccessCount
+
+ tell application "Finder" to update inFolder
+
+ tell application "Finder" to set theXmlList to (every file of inFolder whose name ends with gXmlSuffix)
+
+ repeat with theXml in theXmlList
+ set theXml to theXml as string
+ set theXmlCount to theXmlCount + 1
+
+ -- save the current text delimiters
+ set theDelimiters to my text item delimiters
+
+ -- replace the ".xml" extension with ".mcp"
+ set my text item delimiters to "."
+ set theList to (every text item of theXml)
+ set theList to (items 1 thru -2 of theList)
+ set theImport to (theList as string) & ".mcp"
+
+ -- restore the text delimiters
+ set my text item delimiters to theDelimiters
+
+ tell application "CodeWarrior IDE"
+ --
+ -- Import the selected xml file
+ --
+ try
+ make new project document as theImport with data theXml
+ set theXmlSuccessCount to theXmlSuccessCount + 1
+ --
+ -- Close the project
+ --
+ Close Project
+ on error number errnum
+ tell me to display dialog "Error " & errnum & " importing " & theXml & " to " & theImport
+ end try
+ end tell
+ end repeat
+
+ tell application "Finder" to set theSubFolders to every folder of inFolder whose name does not end with " Data"
+ repeat with theFolder in theSubFolders
+ ImportProjects(theFolder)
+ end repeat
+
+end ImportProjects
+---------------------------------------------------------------------------------
+-- Name: docs/mac/SetXMLCreator.applescript
+-- Purpose: Sets the creator types of the XML files
+-- Author: Ryan Wilcox
+-- Modified by:
+-- Created: 2004-03-30
+-- RCS-ID: $Id: SetXMLCreator.applescript,v 1.2 2004/03/30 10:26:17 JS Exp $
+-- Copyright: (c) 2004 Ryan Wilcox
+-- Licence: wxWindows licence
+--
+-- Press the run button and select the file you need (or, alternatively, save the
+-- script as an application drag-and-drop the files on top of it).
+---------------------------------------------------------------------------------
+
+on run
+ set myFile to choose file
+ open ({myFile})
+end run
+
+
+on open (fileList)
+
+ repeat with each in fileList
+
+ tell application "Finder"
+ if name of each contains "M5" or name of each contains "M7" or name of each contains "M8" then
+ set creator type of each to "CWIE"
+ set file type of each to "TEXT"
+
+ log "set"
+ end if
+
+ end tell
+ end repeat
+end open
+
+(* Application.applescript *)
+
+(* This example employs many UI features in Cocoa, such as a 'drawer' and 'panels' as well as using the 'do shell script' to provide a UI frontend to the 'gnutar' shell tool to build tar archives. It also demonstrates how to design an application that is a droplet as well. You can also fine an example of how to use the 'user-defaults' class. *)
+
+(* The structure of this script is as follows:
+ Properties Properties needed for the application.
+ Event Handlers Handlers that are called by actions in the UI.
+ Handlers Handlers that are called within the script.
+*)
+
+(* ==== Properties ==== *)
+
+-- Settings
+property openWindowOnLaunch : true
+property showProgress : true
+property compressArchive : true
+property preserveIDs : true
+property followLinks : false
+property verboseMode : false
+property defaultLocation : ""
+
+-- Others
+property windowOpened : false
+property progressPanel : missing value
+property fileNames : {}
+property filesDataSource : missing value
+
+
+(* ==== Event Handlers ==== *)
+
+-- This event handler is called as early in the process of launching an application as is possible. The handler is a good place to register our settings as well as read in the current set of settings.
+--
+on will finish launching theObject
+ set windowOpened to false
+
+ registerSettings()
+ readSettings()
+end will finish launching
+
+-- This event handler is the last handler called in the process of launching an application. If the handler is called and a window hasn't been shown yet (via the 'open' event handler) then we need to show the main window here (as well was opening the settings drawer).
+--
+on launched theObject
+ if windowOpened is false then
+ showWindow()
+ showSettings()
+ end if
+end launched
+
+-- This event handler is called when the object that is associated with it is loaded from its nib file. It's a good place to do any one-time initialization, which in this case is to create the data source for the table view.
+--
+on awake from nib theObject
+ -- Create the data source for the table view
+ set filesDataSource to make new data source at end of data sources with properties {name:"files"}
+
+ -- Create the "files" data column
+ make new data column at end of data columns of filesDataSource with properties {name:"files"}
+
+ -- Assign the data source to the table view
+ set data source of theObject to filesDataSource
+
+ -- Register for the "file names" drag types
+ tell theObject to register drag types {"file names", "color"}
+end awake from nib
+
+-- This event handler is called (in this example) when the user drags any finder items over the table view.
+--
+on drop theObject drag info dragInfo
+ -- Get the list of data types on the pasteboard
+ set dataTypes to types of pasteboard of dragInfo
+
+ -- We are only interested in either "file names" or "color" data types
+ if "file names" is in dataTypes then
+ -- Initialize the list of files to an empty list
+ set theFiles to {}
+
+ -- We want the data as a list of file names, so set the preferred type to "file names"
+ set preferred type of pasteboard of dragInfo to "file names"
+
+ -- Get the list of files from the pasteboard
+ set theFiles to contents of pasteboard of dragInfo
+
+ -- Make sure we have at least one item
+ if (count of theFiles) > 0 then
+ -- Turn off the updating of the views
+ set update views of filesDataSource to false
+
+ -- For every item in the list, make a new data row and set it's contents
+ repeat with theItem in theFiles
+ set theDataRow to make new data row at end of data rows of filesDataSource
+ set contents of data cell "files" of theDataRow to quoted form of theItem
+ set fileNames to fileNames & {quoted form of theItem}
+ end repeat
+
+ -- Turn back on the updating of the views
+ set update views of filesDataSource to true
+ end if
+ end if
+
+ -- Set the preferred type back to the default
+ set preferred type of pasteboard of dragInfo to ""
+
+ return true
+end drop
+
+-- This event handler is called when you drag any file/folder items in the Finder onto the application icon (either in the Finder or in the Dock). It can be called as many times as the user drags items onto the application icon, therefore the main process here is to append the list of names the existing list of names. Then we conditionally open the window, make the archive (displaying a progress bar if requested) and then if a window hasn't been opened we simply quit.
+--
+on open names
+ -- Append the list of names to our current list
+ repeat with i from 1 to count of names
+ set fileNames to fileNames & {quoted form of (POSIX path of (item i of names))}
+ end repeat
+
+ -- Show the window if requested
+ if openWindowOnLaunch then
+ -- Of course, only show if it hasn't already been opened
+ if not windowOpened then
+ showWindow()
+ end if
+ end if
+
+ -- If the main window wasn't opened then go ahead and process the list of files, making an archive with a determined name.
+ if not windowOpened then
+ set windowOpened to true
+
+ -- Get the generated archive name
+ set archiveFileName to getArchiveFileName()
+
+ -- Show the progress panel if requested
+ if showProgress then
+ showProgressPanel(false, archiveFileName)
+ end if
+
+ -- Make the archive
+ set theResult to makeArchive(archiveFileName)
+
+ -- If we are in verbose mode, then show the results in the log window
+ if verboseMode then
+ set contents of text view "log" of scroll view "log" of window "log" to theResult
+ show window "log"
+ end if
+
+ -- Hide the progress panel (if shown)
+ if showProgress then
+ hideProgressPanel(false)
+ end if
+
+ -- Go ahead and quit, as we are done. (This might need some rethinking, as it probably isn't the right thing to do if for instance the log window is shown, with the verbose mode on.
+ quit
+ else if openWindowOnLaunch then
+ -- Turn off the updating of the views
+ set update views of filesDataSource to false
+
+ -- Add the files to the data source
+ repeat with i from 1 to count of names
+ set theDataRow to make new data row at end of data rows of filesDataSource
+ set contents of data cell "files" of theDataRow to quoted form of (POSIX path of (item i of names))
+ end repeat
+
+ -- Turn back on the updating of the views
+ set update views of filesDataSource to true
+ end if
+end open
+
+-- This handler is the last handler to be called before the application quits. It's a good place to the get current settings from the setting drawer and write them out (but only if the window has been opened).
+--
+on will quit theObject
+ if windowOpened then
+ getSettingsFromUI()
+ writeSettings()
+ end if
+end will quit
+
+-- This event handler is called when a UI object is clicked (any object that is linked to this handler in Interface Builder that is...).
+--
+on clicked theObject
+ if name of theObject is "make" then
+ -- Make sure that we have at least one item to make into an archive.
+ if (count of fileNames) is greater than 0 then
+ -- Get the current settings in the UI from the settings drawer.
+ getSettingsFromUI()
+
+ -- Determine a good default name based on the first file item, and then ask for the archive name.
+ set defaultName to last word of (item 1 of fileNames as string) & ".tar"
+ if compressArchive then set defaultName to defaultName & ".gz"
+
+ -- Setup the 'save panel'
+ tell save panel
+ set title to "Save Archive As"
+ set prompt to "Make"
+ set treat packages as directories to false
+ end tell
+
+ -- Display the save panel as a sheet (we will do the processing in the 'on panel ended' handler)
+ display save panel in directory defaultLocation with file name defaultName attached to window of theObject
+ else
+ -- Alert the user that they need to have at least one file item.
+ display alert "Missing Files/Folders" as critical message "You must add files or folders by dragging them on to the application icon in order to make an archive." attached to window "main"
+ end if
+ else if name of theObject is "settings" then
+ -- This simply toggles the state of the 'settings' button, showing/hiding the settings drawer as needed.
+ tell window "main"
+ set currentState to state of drawer "settings"
+
+ if currentState is drawer closed then
+ my showSettings()
+ else if currentState is drawer opened then
+ my hideSettings()
+ end if
+
+ end tell
+ else if name of theObject is "choose" then
+ -- Choose the default location (folder) in which to store the archive when the application is used as a droplet (without the main window begin shown.)
+ chooseDefaultLocation()
+ end if
+end clicked
+
+-- This event handler is called when the save panel (which was shown as a sheet) has been concluded.
+--
+on panel ended theObject with result withResult
+ if theObject is the open panel then
+ if withResult is 1 then
+ set theLocation to item 1 of (path names of open panel as list)
+ set contents of text field "default location" of drawer "settings" of window "main" to theLocation as string
+ end if
+ else if theObject is the save panel and withResult is 1 then
+ -- We need to hide the panel as we might be putting up a progress panel next
+ set visible of save panel to false
+
+ -- Show the progress panel (if requested).
+ if showProgress then
+ showProgressPanel(true, path name of save panel)
+ end if
+
+ -- The main point of this entire application. Make the archive (which expects everything to be a POSIX path.
+ set theResult to makeArchive(path name of save panel)
+
+ -- If requested, show the results of the make in the log window
+ if verboseMode then
+ set contents of text view "log" of scroll view "log" of window "log" to theResult
+ show window "log"
+ end if
+
+ -- Hide the progres panel (if shown)
+ if showProgress then
+ hideProgressPanel(true)
+ end if
+ end if
+end panel ended
+
+
+(* ==== Handlers ==== *)
+
+-- This is the bread and butter of the application. It simply creates the command to be issued to 'do shell script' and returns the result.
+--
+on makeArchive(archiveName)
+ -- The 'gnutar' command in it's basic strucure.
+ set scriptCommand to "gnutar " & getOptionsString() & " -f " & archiveName
+
+ -- Add each of the file items to the command.
+ repeat with fileName in fileNames
+ set scriptCommand to scriptCommand & space & fileName
+ end repeat
+
+ -- Tell the shell to do it's thing.
+ return do shell script scriptCommand
+end makeArchive
+
+-- Returns the various options chosen by the user in a simple string beginning with the required '-c' which is used to tell 'gnutar' to create a new archive. You can do a 'man gnutar' to see all of the options in a terminal window.
+--
+on getOptionsString()
+ set optionsString to "-c"
+
+ if compressArchive then
+ set optionsString to optionsString & "z"
+ end if
+ if preserveIDs then
+ set optionsString to optionsString & "p"
+ end if
+ if followLinks then
+ set optionsString to optionsString & "h"
+ end if
+ if verboseMode then
+ set optionsString to optionsString & "v"
+ end if
+
+ return optionsString
+end getOptionsString
+
+-- Returns a self determined archive name based on the first item in the file item list.
+--
+on getArchiveFileName()
+ set archiveFileName to ""
+
+ -- Prepend the file name with the default location
+ if defaultLocation is not equal to "" then
+ set archiveFileName to defaultLocation
+ if archiveFileName does not end with "/" then
+ set archiveFileName to archiveFileName & "/"
+ end if
+ end if
+
+ -- Append the last word of the first item plus a '.tar' or '.tar.gz' (which is the normal extension for tar files.
+ set archiveFileName to archiveFileName & last word of (item 1 of fileNames as string) & ".tar"
+ if compressArchive then set archiveFileName to archiveFileName & ".gz"
+
+ return archiveFileName
+end getArchiveFileName
+
+-- Loads the progress panel (if needed) and then displays it.
+--
+on showProgressPanel(attachedToWindow, archiveFileName)
+ -- Only load the progress panel once.
+ if progressPanel is missing value then
+ load nib "ProgressPanel"
+ set progressPanel to window "progress"
+ end if
+
+ -- Set the status item in the progress panel
+ set content of text field "status" of progressPanel to "Making Archive: " & (call method "lastPathComponent" of archiveFileName)
+
+ -- Display the progress panel appropriately.
+ if attachedToWindow then
+ display panel progressPanel attached to window "main"
+ else
+ show progressPanel
+ end if
+
+ -- Start spinning the progress bar.
+ tell progressPanel
+ set uses threaded animation of progress indicator "progress" to true
+ tell progress indicator "progress" to start
+ end tell
+end showProgressPanel
+
+-- Hides the progress panel.
+--
+on hideProgressPanel(attachedToWindow)
+ if attachedToWindow then
+ tell progress indicator "progress" of progressPanel to stop
+ close panel progressPanel
+ else
+ hide progressPanel
+ end if
+
+ -- Set the status item in the progress panel
+ set content of text field "status" of progressPanel to ""
+end hideProgressPanel
+
+-- Shows the main window, doing any necessary setup of the drawer as necessary.
+--
+on showWindow()
+ tell window "main"
+ tell drawer "settings"
+ -- Initialize some settings to appropriate values for the settings drawer. These will set the current, min and max contents size to be the same, which will have the effect of keeping the settings drawer size appropriate to it's contents. (In other words it can't grow or shrink.)
+ set leading offset to 20
+ set trailing offset to 20
+ set content size to {436, 136}
+ set minimum content size to {436, 136}
+ set maximum content size to {436, 136}
+
+ -- Set the UI settings
+ my setSettingsInUI()
+ end tell
+
+ set visible to true
+ end tell
+
+ set windowOpened to true
+end showWindow
+
+-- Shows the current list of file names as a list of strings in the text view of the main window.
+--
+on updateFileNamesInUI()
+ tell window "main"
+ set AppleScript's text item delimiters to return
+ set contents of text view "files" of scroll view "files" to fileNames as string
+ set AppleScript's text item delimiters to ""
+ end tell
+end updateFileNamesInUI
+
+-- Prompts the user to select a default location for new archives.
+--
+on chooseDefaultLocation()
+ -- Setup the open panel properties
+ tell open panel
+ set can choose directories to true
+ set can choose files to false
+ set prompt to "Choose"
+ end tell
+
+ display open panel attached to window "main"
+end chooseDefaultLocation
+
+-- Show's the settings drawer, also adjusting the title of the 'settings' button.
+--
+on showSettings()
+ tell window "main"
+ tell drawer "settings" to open drawer on bottom edge
+ set title of button "settings" to "Hide Settings"
+ end tell
+end showSettings
+
+-- Hide's the settings drawer, also adjusting the title of the 'settings' button.
+--
+on hideSettings()
+ tell window "main"
+ tell drawer "settings" to close drawer
+ set title of button "settings" to "Show Settings"
+ end tell
+end hideSettings
+
+-- Sets the settings properties based on the states of the various UI items in the settings drawer.
+--
+on getSettingsFromUI()
+ tell drawer "settings" of window "main"
+ set defaultLocation to contents of text field "default location"
+ set openWindowOnLaunch to (state of button "open window") as boolean
+ set showProgress to (state of button "show progress") as boolean
+ set compressArchive to (state of button "compress archive") as boolean
+ set preserveIDs to (state of button "preserve ids") as boolean
+ set followLinks to (state of button "follow links") as boolean
+ set verboseMode to (state of button "verbose mode") as boolean
+ end tell
+end getSettingsFromUI
+
+-- Sets the state of the UI elements int he settings drawer based upon the settings properties.
+--
+on setSettingsInUI()
+ tell drawer "settings" of window "main"
+ set contents of text field "default location" to defaultLocation
+ set state of button "open window" to openWindowOnLaunch
+ set state of button "show progress" to showProgress
+ set state of button "compress archive" to compressArchive
+ set state of button "preserve ids" to preserveIDs
+ set state of button "follow links" to followLinks
+ set state of button "verbose mode" to verboseMode
+ end tell
+end setSettingsInUI
+
+-- Registers the settings (application preferences) with the 'user defaults'.
+--
+on registerSettings()
+ tell user defaults
+ -- Add all of the new defalt entries
+ make new default entry at end of default entries with properties {name:"openWindowOnLaunch", contents:openWindowOnLaunch}
+ make new default entry at end of default entries with properties {name:"showProgress", contents:showProgress}
+ make new default entry at end of default entries with properties {name:"compressArchive", contents:compressArchive}
+ make new default entry at end of default entries with properties {name:"preserveIDs", contents:preserveIDs}
+ make new default entry at end of default entries with properties {name:"followLinks", contents:followLinks}
+ make new default entry at end of default entries with properties {name:"verboseMode", contents:verboseMode}
+ make new default entry at end of default entries with properties {name:"defaultLocation", contents:defaultLocation}
+
+ -- Now we need to register the new entries in the user defaults
+ register
+ end tell
+end registerSettings
+
+-- Reads the settings (application preferences) from the 'user defaults'.
+--
+on readSettings()
+ tell user defaults
+ set openWindowOnLaunch to contents of default entry "openWindowOnLaunch" as boolean
+ set showProgress to contents of default entry "showProgress" as boolean
+ set compressArchive to contents of default entry "compressArchive" as boolean
+ set preserveIDs to contents of default entry "preserveIDs" as boolean
+ set followLinks to contents of default entry "followLinks" as boolean
+ set verboseMode to contents of default entry "verboseMode" as boolean
+ set defaultLocation to contents of default entry "defaultLocation"
+ end tell
+end readSettings
+
+-- Writes the settings (application preferences) to the 'user defaults'.
+--
+on writeSettings()
+ tell user defaults
+ set contents of default entry "openWindowOnLaunch" to openWindowOnLaunch
+ set contents of default entry "showProgress" to showProgress
+ set contents of default entry "compressArchive" to compressArchive
+ set contents of default entry "preserveIDs" to preserveIDs
+ set contents of default entry "followLinks" to followLinks
+ set contents of default entry "verboseMode" to verboseMode
+ set contents of default entry "defaultLocation" to defaultLocation
+ end tell
+end writeSettings
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Assistant.applescript *)
+
+(* This application is to present one possible implementation of an 'Assistant'. The strategy that is used is to use a tab view and use seperate tab view items to represent an information panel. The tab view is set without a border or visible tabs. This gives the appearance of a panel full of UI elements to being switched in and out. The design also supports the ability to easily add, remove or change the order of info panels. One thing of note is that and that is incorporated in this strategy is that UI elements of tab view items that are not the current tab view item are not accessible. The way a tab view works is by adding and removing the tab view item's view in and out of the view hierarchy. Since AppleScript needs to be able to walk that view hierarchy to get access to the UI elements in the sub views. Thus, the properties of each info panel is updated before the tab view item is switched out. *)
+
+(* The structure of this script is as follows:
+ Properties Properties needed for the application.
+ Script Objects Model/Controller objects that are specific to each info panel.
+ Event Handlers Handlers that are called by actions in the UI.
+ Handlers Handlers that interact with the script objects and as well as the UI.
+*)
+
+
+(* ==== Properties === *)
+
+property infoPanels : {}
+property currentInfoPanelIndex : 1
+property statusImages : {}
+
+
+(* ==== Script Objects ==== *)
+
+-- This is the parent script object that represents an info panel. It has default implementations of all of the handlers that is used throughout this application.
+--
+script InfoPanel
+ -- This handler is called when the contents of the UI elements need to be prepared
+ on prepareValues(theWindow)
+ -- Scripts that inherit from this script need to implement this handler
+ end prepareValues
+
+ -- This handler is called when the properties need to be updated from the contents of the UI elements
+ on updateValues(theWindow)
+ -- Scripts that inherit from this script need to implement this handler
+ end updateValues
+
+ -- This handler is called to allow an info panel to validate it's values, returning false if the data isn't valid (or is missing)
+ on validateValues(theWindow)
+ -- Scripts that inherit from this script need to implement this handler
+ return true
+ end validateValues
+
+ -- This handler is called when a summary of the property values is needed.
+ on summarizeValues()
+ -- Scripts that inherit from this script need to implement this handler
+ end summarizeValues
+
+ -- This handler will set the focus on the UI element that has a problem and then presents an alert.
+ on postValidationAlert(theMessage, theTextField, theWindow)
+ -- Move to the field that is missing it's information
+ set first responder of theWindow to theTextField
+
+ -- Display the alert
+ display alert "Missing Information" as critical message theMessage attached to theWindow
+ end postValidationAlert
+end script
+
+
+-- This script represents the reporter info panel that contains the personal information about the person reporting the problem.
+--
+script ReporterInfoPanel
+ property parent : InfoPanel
+ property infoPanelName : "reporter"
+ property infoPanelInstruction : "Please enter your personal information."
+
+ property company : ""
+ property name : ""
+ property address : ""
+ property city : ""
+ property zip : ""
+ property state : ""
+ property email : ""
+
+ -- This handler is called when the properties need to be updated from the contents of the UI elements
+ --
+ on updateValues(theWindow)
+ tell view of tab view item infoPanelName of tab view "info panels" of box "border" of theWindow
+ set my company to contents of text field "company"
+ set my name to contents of text field "name"
+ set my address to contents of text field "address"
+ set my city to contents of text field "city"
+ set my state to contents of text field "state"
+ set my zip to contents of text field "zip"
+ set my email to contents of text field "email"
+ end tell
+ end updateValues
+
+ -- This handler is called to allow an info panel to validate it's values, returning false if the data isn't valid (or is missing)
+ --
+ on validateValues(theWindow)
+ set isValid to true
+
+ -- We need to have at least the name and email
+ if name is "" then
+ postValidationAlert("You must enter a name.", text field "name" of view of tab view item infoPanelName of tab view "info panels" of box "border" of theWindow, theWindow)
+ set isValid to false
+ else if email is "" then
+ postValidationAlert("You must enter an e-mail address.", text field "email" of view of tab view item infoPanelName of tab view "info panels" of box "border" of theWindow, theWindow)
+ set isValid to false
+ end if
+
+ return isValid
+ end validateValues
+
+ -- This handler is called when a summary of the property values is needed.
+ --
+ on summarizeValues()
+ set theSummary to company & return
+ set theSummary to theSummary & name & return
+ set theSummary to theSummary & address & return
+ set theSummary to theSummary & city & ", " & state & " " & zip & return
+ set theSummary to theSummary & email & return
+ return theSummary
+ end summarizeValues
+end script
+
+
+-- This script represents the problem info panel that contains the information about the problem itself.
+--
+script ProblemInfoPanel
+ property parent : InfoPanel
+ property infoPanelName : "problem"
+ property infoPanelInstruction : "Please describe your problem."
+
+ property product : ""
+ property version : ""
+ property severity : ""
+ property reproducible : ""
+ property description : ""
+
+ -- This handler is called when the properties need to be updated from the contents of the UI elements
+ --
+ on updateValues(theWindow)
+ tell view of tab view item infoPanelName of tab view "info panels" of box "border" of theWindow
+ set my product to contents of text field "product"
+ set my version to contents of text field "version"
+ set my severity to title of current cell of matrix "severity"
+ set my reproducible to title of current menu item of popup button "reproducible"
+ set my description to contents of text view "description" of scroll view "scroll"
+ end tell
+ end updateValues
+
+ -- This handler is called to allow an info panel to validate it's values, returning false if the data isn't valid (or is missing)
+ --
+ on validateValues(theWindow)
+ set isValid to true
+
+ -- We need to have at the very least the product info, version info and description info
+ if product is "" then
+ postValidationAlert("You must enter a product name.", text field "product" of view of tab view item infoPanelName of tab view "info panels" of box "border" of theWindow, theWindow)
+ set isValid to false
+ else if version is "" then
+ postValidationAlert("You must enter the version of the product.", text field "version" of view of tab view item infoPanelName of tab view "info panels" of box "border" of theWindow, theWindow)
+ set isValid to false
+ else if description is "" then
+ postValidationAlert("You must enter a description of the problem.", text field "description" of view of tab view item infoPanelName of tab view "info panels" of box "border" of theWindow, theWindow)
+ set isValid to false
+ end if
+
+ return isValid
+ end validateValues
+
+ -- This handler is called when a summary of the property values is needed.
+ --
+ on summarizeValues()
+ set theSummary to "Product: " & tab & product & " version " & version & return
+ set theSummary to theSummary & "Severity: " & tab & severity & return
+ set theSummary to theSummary & "Reproducible: " & tab & reproducible & return
+ set theSummary to theSummary & "Description: " & return
+ set theSummary to theSummary & description & return
+ return theSummary
+ end summarizeValues
+
+end script
+
+
+-- This script represents the comments info panel that contains the comments from the reporter.
+--
+script CommentsInfoPanel
+ property parent : InfoPanel
+ property infoPanelName : "comments"
+ property infoPanelInstruction : "Please enter any comments."
+
+ property comments : ""
+
+ -- This handler is called when the properties need to be updated from the contents of the UI elements
+ --
+ on updateValues(theWindow)
+ tell view of tab view item infoPanelName of tab view "info panels" of box "border" of theWindow
+ set my comments to contents of text view "comments" of scroll view "scroll"
+ end tell
+ end updateValues
+
+ -- This handler is called when a summary of the property values is needed.
+ --
+ on summarizeValues()
+ set theSummary to "Comments: " & return
+ set theSummary to theSummary & comments & return
+ return theSummary
+ end summarizeValues
+end script
+
+
+-- This script represents the review info panel, that allows the reporter a chance to see a summary of all of the information before it will be sent.
+--
+script ReviewInfoPanel
+ property parent : InfoPanel
+ property infoPanelName : "review"
+ property infoPanelInstruction : "Please review before sending."
+
+ property reviewSummary : ""
+
+ -- This handler is called when the contents of the UI elements need to be prepared
+ --
+ on prepareValues(theWindow)
+ set theSummary to summarizeValues()
+ tell view of tab view item "review" of tab view "info panels" of box "border" of theWindow
+ set contents of text view "review" of scroll view "scroll" to theSummary
+ end tell
+ end prepareValues
+
+ -- This handler is called when the properties need to be updated from the contents of the UI elements
+ --
+ on updateValues(theWindow)
+ tell view of tab view item infoPanelName of tab view "info panels" of box "border" of theWindow
+ set my reviewSummary to contents of text view "review" of scroll view "scroll"
+ end tell
+ end updateValues
+
+ -- This handler is called when a summary of the property values is needed.
+ --
+ on summarizeValues()
+ set theSummary to ""
+
+ -- Since this is the review info panel, we'll get the summary from all of the other info panels and put them together
+ repeat with n from 1 to ((count of infoPanels) - 1)
+ set theSummary to theSummary & summarizeValues() of item n of infoPanels & return
+ end repeat
+
+ return theSummary
+ end summarizeValues
+end script
+
+
+(* ==== Event Handlers ==== *)
+
+-- This event handler is called when the application is finished launching. It's a good place to to any initialization before showing the main window.
+--
+
+on launched theObject
+ -- Load the images
+ set statusImages to {(load image "DotBlue"), (load image "DotGray")}
+
+ -- Setup the info panel list. The order of the panels is established here. You can easily change the order that they are presented by changing their order here in this list. The only other thing you need to keep synchronized is the status text items in the left hand portion of the window.
+ set infoPanels to {ReporterInfoPanel, ProblemInfoPanel, CommentsInfoPanel, ReviewInfoPanel}
+
+ -- Switch to the first info panel
+ switchToFirstInfoPanel(window "main")
+
+ set visible of window "main" to true
+end launched
+
+
+-- This event handler is called when a button is clicked, in this case the 'go back' or 'continue' buttons.
+--
+on clicked theObject
+ if name of theObject is "continue" then
+ if currentInfoPanelIndex is equal to (count of infoPanels) then
+ -- On the last panel, the button has changed to 'Send' so send the gathered information
+ sendInformation(window of theObject)
+ else
+ -- Switch to the next info panel
+ switchToNextInfoPanel(window of theObject)
+ end if
+ else if name of theObject is "back" then
+ -- Switch to the previous info panel
+ switchToPreviousInfoPanel(window of theObject)
+ end if
+end clicked
+
+
+-- This event handler is called when the tab view is about to switch tab items. You can control the result by returning 'true' to allow the selection to happen, or 'false' to cancel it. Here we will collect the information from each panel and then validate the information and make our decision based upon the validation as to whether or not we will allow the selection to change.
+--
+on should select tab view item theObject tab view item tabViewItem
+ set isValid to true
+
+ -- We only want to update and validate if the window is visible
+ if window of theObject is visible then
+ -- Update the current info panel with the contents of the UI
+ updateCurrentInfoPanel(window of theObject)
+
+ -- Validate the current info panel to see if we should move on
+ set isValid to validateCurrentInfoPanel(window of theObject)
+ end if
+
+ -- Return the validity status (true if it's ok to select the tab, false if it's not)
+ return isValid
+end should select tab view item
+
+
+-- This event handler is called when the current tab view item has been changed.
+--
+on selected tab view item theObject tab view item tabViewItem
+ -- We will give the new info panel a chance to prepare it's data values
+ prepareValues(window of theObject) of infoPanelWithName(name of tabViewItem)
+end selected tab view item
+
+
+(* ==== Handlers ==== *)
+
+-- This handler will attempt to switch to the indicated info panel and change the UI to reflect that change.
+--
+on switchToInfoPanel(theIndex, theWindow)
+ tell theWindow
+ set theInfoPanelName to infoPanelName of item theIndex of infoPanels
+ set theInfoPanelInstruction to infoPanelInstruction of item theIndex of infoPanels
+
+ -- Attempt to switch to the indicated tab view item
+ tell tab view "info panels" of box "border"
+ set current tab view item to tab view item theInfoPanelName
+
+ -- The tab may not change due to validation checking, so make sure we have changed
+ if name of current tab view item is not equal to theInfoPanelName then
+ return
+ end if
+ end tell
+
+ -- Update the current index
+ set currentInfoPanelIndex to theIndex
+
+ -- Update the instructions
+ tell box "instructions"
+ set contents of text field "instructions" to theInfoPanelInstruction
+ end tell
+
+ -- Update the 'back' button.
+ if theIndex is 1 then
+ -- Hide it on the first panel.
+ set visible of button "back" to false
+ else
+ -- Show it on all others
+ set visible of button "back" to true
+ end if
+
+ -- Update the 'continue' button.
+ if theIndex is (count of infoPanels) then
+ -- Set the title to 'Send' if we are on the last panel.
+ set title of button "continue" to "Send"
+ else
+ -- Otherwise set it to 'Continue'
+ set title of button "continue" to "Continue"
+ end if
+
+ -- Update the status images
+ repeat with index from 1 to count of infoPanels
+ -- Get the name of the info panel
+ set infoPanelName to infoPanelName of item index of infoPanels
+
+ -- We will be setting the status image to blue for any info panels up to the current index, otherwise we'll set it to gray
+ if index ² currentInfoPanelIndex then
+ set image of image view infoPanelName to item 1 of statusImages
+ else
+ set image of image view infoPanelName to item 2 of statusImages
+ end if
+ end repeat
+ end tell
+end switchToInfoPanel
+
+
+-- Switches to the the first info panel (called upon startup of the application)
+--
+on switchToFirstInfoPanel(theWindow)
+ -- Switch to the first item in the info panels list
+ switchToInfoPanel(1, theWindow)
+end switchToFirstInfoPanel
+
+
+-- Switches to the the next info panel if available
+--
+on switchToNextInfoPanel(theWindow)
+ -- Make sure that we aren't already on the last panel
+ if currentInfoPanelIndex is less than (count of infoPanels) then
+ switchToInfoPanel(currentInfoPanelIndex + 1, theWindow)
+ end if
+end switchToNextInfoPanel
+
+
+-- Switches to the the previous info panel if available
+--
+on switchToPreviousInfoPanel(theWindow)
+ -- Make sure that we aren't already on the first panel
+ if currentInfoPanelIndex is greater than 1 then
+ switchToInfoPanel(currentInfoPanelIndex - 1, theWindow)
+ end if
+end switchToPreviousInfoPanel
+
+
+-- This handler will tell the current info panel to set it's properties values from the UI objects in it's panel
+--
+on updateCurrentInfoPanel(theWindow)
+ tell item currentInfoPanelIndex of infoPanels to updateValues(theWindow)
+end updateCurrentInfoPanel
+
+
+-- This handler will validate the current info panel, to ensure that the required data is present and valid
+--
+on validateCurrentInfoPanel(theWindow)
+ return validateValues(theWindow) of item currentInfoPanelIndex of infoPanels
+end validateCurrentInfoPanel
+
+
+-- This event handler handles sending the gathered information to (wherever)
+--
+on sendInformation(theWindow)
+ -- Get the summary information from the the Review info panel
+ set theInformation to reviewSummary of ReviewInfoPanel
+
+ -- Send this information
+ -- *** This is left blank as it is implementation dependent and is left as an exercise ***
+end sendInformation
+
+
+-- This is a utility handler that is called to return the info panel with the given name
+--
+on infoPanelWithName(theName)
+ set theInfoPanel to null
+
+ repeat with thePanel in infoPanels
+ if infoPanelName of thePanel is equal to theName then
+ set theInfoPanel to thePanel
+ exit repeat
+ end if
+ end repeat
+
+ return theInfoPanel
+end infoPanelWithName
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Application.applescript *)
+
+(* This example demonstrates how to script a browser object. The main parts of the script are the "number of browser rows" event handler which needs to return number of rows in the browser for the given column, and the "will display browser cell" event handler that will be called for every item in the browser. *)
+
+(* ==== Properties ==== *)
+
+property diskNames : {}
+
+
+(* ==== Event Handlers ==== *)
+
+-- Initialize various items here
+--
+on launched theObject
+ tell application "Finder"
+ set diskNames to name of every disk as list
+ end tell
+
+ set path separator of browser "browser" of window "main" to ":"
+
+ tell browser "browser" of window "main" to update
+end launched
+
+-- Return the number of rows for the given column
+--
+on number of browser rows theObject in column theColumn
+ set rowCount to 0
+
+ if (count of diskNames) > 0 then
+ if theColumn is 1 then
+ set rowCount to count of diskNames
+ else
+ tell browser "browser" of window "main"
+ set thePath to path for column theColumn - 1
+ end tell
+
+ tell application "Finder"
+ set rowCount to count of items of item thePath
+ end tell
+ end if
+ end if
+
+ return rowCount
+end number of browser rows
+
+-- This is called whenever a cell in the browser needs to be displayed.
+--
+on will display browser cell theObject row theRow browser cell theCell in column theColumn
+ if theColumn > 1 then
+ tell browser "browser" of window "main"
+ set thePath to path for column theColumn
+ end tell
+ end if
+
+ tell application "Finder"
+ if theColumn is 1 then
+ set cellContents to displayed name of disk (item theRow of diskNames as string)
+ set isLeaf to false
+ else
+ set theItem to item theRow of item thePath
+
+ if class of theItem is folder or class of theItem is disk then
+ set isLeaf to false
+ else
+ set isLeaf to true
+ end if
+
+ set cellContents to (displayed name of theItem as string)
+ end if
+ end tell
+
+ set string value of theCell to cellContents
+ set leaf of theCell to isLeaf
+
+end will display browser cell
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Tool Helper.applescript *)
+
+(* This example will help to find shell commands and then provide a window containing the man page for that command. You choose how to search by choosing from several choices in a popup button: "begins with", "contains", "ends with" and "is". The strategy employed is to get a list of all of the command names at starup and then search through that list when requested, displaying the results of the ones found. *)
+
+
+(* ==== Properties ==== *)
+
+property commandsDataSource : missing value
+property commandNames : {}
+property manPageWindow : missing value
+
+
+(* ==== Event Handlers ==== *)
+
+-- The "will finish launching" event handler is the first event handler called in the startup sequence and is a good place to do any type of initialization work that doesn't require any UI. For this example we will get a list of all of the command names.
+--
+on will finish launching theObject
+ -- The quickest method of getting a list of all of the command names appears to be to get the information using "ls" in a "do shell script". We want to get a list of all of the commands from the following locations: /bin, /usr/bin, /usr/sbin. We can do this by concating the commands together with the ";" character and then piping ("|") the results through the "sort" shell command passing it the "-u" option which eliminates any duplicates. We then take the result from the do shell command (which will be a string with return characters between each item) and convert it to a list of strings.
+ set commandNames to every paragraph of (do shell script "ls /usr/bin ; ls /usr/sbin ; ls /bin | sort -u")
+end will finish launching
+
+
+-- The "awake from nib" event handler is called when the object is loaded from a nib file. It's a good place to initialize one or more items.
+--
+on awake from nib theObject
+ if name of theObject is "main" then
+ -- When the window is loaded, be sure to hide the status items
+ hideStatus(theObject)
+ else if name of theObject is "man page" then
+ -- If the man page window is being loaded then set a reference to it
+ set manPageWindow to theObject
+ else if name of theObject is "commands" then
+ -- Create the data source
+ set commandsDataSource to make new data source at end of data sources with properties {name:"commands"}
+
+ -- Create the data columns
+ make new data column at end of data columns of commandsDataSource with properties {name:"command"}
+ make new data column at end of data columns of commandsDataSource with properties {name:"description"}
+
+ -- Assign the data source to the table view
+ set data source of theObject to commandsDataSource
+ end if
+end awake from nib
+
+
+-- The "launched" is one of the last event handlers that is called in the startup sequence. In this case we want to show our main window.
+--
+on launched theObject
+ show window "main"
+end launched
+
+
+-- The "clicked" event handler is called (in this example) when the "Find" button is clicked. We then initiate our find process.
+--
+on clicked theObject
+ if name of theObject is "find" then
+ findCommands(window of theObject)
+ end if
+end clicked
+
+
+on double clicked theObject
+ if name of theObject is "commands" then
+ -- Show and update the message items in the main window
+ showStatus(window of theObject)
+ updateStatusMessage(window of theObject, "Getting the man page...")
+
+ -- Get the clicked row of the table view
+ set theRow to clicked row of theObject
+ set theDataRow to data row theRow of data source of theObject
+
+ -- Get the name of the command
+ set theCommandName to contents of data cell "command" of theDataRow
+
+ -- See if the window is already open
+ set theWindow to findWindowWithTitle(theCommandName)
+ if theWindow is not missing value then
+ -- Just bring it to the front
+ show theWindow
+ else
+ -- Load a new instance of the man page window and show it
+ load nib "ManPage"
+ set title of manPageWindow to theCommandName
+
+ -- Get the man page for the command, cleaning it up in the process
+ set theResult to do shell script "man " & theCommandName & " | perl -pe 's/.\\x08//g'"
+
+ -- Put the results into the text view of our man page window
+ set contents of text view "man page" of scroll view "man page" of manPageWindow to theResult
+
+ -- Show the window
+ show manPageWindow
+ end if
+
+ -- Hide the status items
+ hideStatus(window of theObject)
+ end if
+end double clicked
+
+
+-- The "action" event handler is called (in this example) when a menu item is chosen from the popup button. We then initiate our find process.
+--
+on action theObject
+ if name of theObject is "how" then
+ findCommands(window of theObject)
+ end if
+end action
+
+
+(* ==== Handlers ==== *)
+
+-- This handler is called to find any commands that meet the criteria specified in the UI (how and what). It also is responsible for providing any feedback during the find, such as showing, updating and hiding the status items in the window.
+--
+on findCommands(theWindow)
+ -- Show the the status items
+ showStatus(theWindow)
+ updateStatusMessage(theWindow, "Finding commands...")
+
+ -- Find the commands with what coming from the text field, and how coming from the popup button
+ set theCommands to commandsWithName(contents of text field "name" of theWindow, title of popup button "how" of theWindow)
+
+ -- Turn off the updating of the table view while we load the data source
+ set update views of commandsDataSource to false
+
+ -- Delete any existing items in the data source
+ delete every data row of commandsDataSource
+
+ -- Make sure that we actually found at least one command
+ if (count of theCommands) > 0 then
+ -- Update the status message
+ updateStatusMessage(theWindow, "Adding commands...")
+
+ -- Add the list of commands to the data source using the "append" command
+ append commandsDataSource with theCommands
+ end if
+
+ -- Turn back on the updating of the table view
+ set update views of commandsDataSource to true
+
+ -- Hide the status items
+ hideStatus(theWindow)
+end findCommands
+
+
+-- This handler is used to look through our list of command names, returning a list of found commands, which also includes getting and returning the description of the command
+--
+on commandsWithName(whatToFind, howToFind)
+ -- Set our result to a known good value, in this case an empty list will do just fine
+ set theCommands to {}
+
+ -- Make sure that we have a value to find for
+ if (count of whatToFind) > 0 then
+ -- Set our found names list to an empty list
+ set foundCommandNames to {}
+
+ -- Based on the "howToFind" repeat through each of the command names in our commandNames list finding the appropriate items and adding it to the foundCommandNames list
+ if howToFind is "begins with" then
+ repeat with i in commandNames
+ if i begins with whatToFind then
+ copy i to end of foundCommandNames
+ end if
+ end repeat
+ else if howToFind is "contains" then
+ repeat with i in commandNames
+ if i contains whatToFind then
+ copy i to end of foundCommandNames
+ end if
+ end repeat
+ else if howToFind is "ends with" then
+ repeat with i in commandNames
+ if i ends with whatToFind then
+ copy i to end of foundCommandNames
+ end if
+ end repeat
+ else if howToFind is "is" then
+ repeat with i in commandNames
+ if (i as string) is equal to whatToFind then
+ copy i to end of foundCommandNames
+ end if
+ end repeat
+ end if
+
+ -- Make sure that we found at least one command name
+ if (count of foundCommandNames) > 0 then
+ -- Iterate through each of the found names
+ repeat with i in foundCommandNames
+ try
+ set theDescription to ""
+
+ -- We will use the "whatis" shell command to get the description of
+ set theResult to do shell script ("whatis " & (i as string))
+
+ -- Unfortunately, the result will look something like "more(1), page(1) - file perusal filter for crt viewing". We only want to get portion of the text following the " - " characters. This can be done using the following bit of script.
+ set dashoffset to offset of " - " in theResult
+ set firstReturn to offset of return in theResult
+ set theDescription to characters (dashoffset + 2) through (firstReturn - 1) of theResult as string
+
+ -- Add the command name and description as a list the end of our command list
+ copy {i, theDescription} to end of theCommands
+ end try
+ end repeat
+ end if
+ end if
+
+ -- Return our result
+ return theCommands
+end commandsWithName
+
+
+(* ==== Status Handlers ==== *)
+
+-- This handler will show the various status items in the window, along with starting the animation of the progress indicator
+--
+on showStatus(theWindow)
+ tell theWindow
+ set visible of progress indicator "progress" to true
+ set visible of text field "status" to true
+ set uses threaded animation of progress indicator "progress" to true
+ start progress indicator "progress"
+ end tell
+end showStatus
+
+
+-- This handler will hide all of the status items in the window, including stopping the animation of the progress indicator
+--
+on hideStatus(theWindow)
+ tell theWindow
+ set visible of progress indicator "progress" to false
+ set visible of text field "status" to false
+ stop progress indicator "progress"
+ end tell
+end hideStatus
+
+
+-- This handler will update the status message in the status items of the window
+--
+on updateStatusMessage(theWindow, theMessage)
+ set contents of text field "status" of theWindow to theMessage
+end updateStatusMessage
+
+
+(* ==== Utility Handlers ==== *)
+
+-- This is a utility handler that will simply find the window with the specified title.
+--
+on findWindowWithTitle(theTitle)
+ set theWindow to missing value
+
+ set theWindows to every window whose title is theTitle
+ if (count of theWindows) > 0 then
+ set theWindow to item 1 of theWindows
+ end if
+
+ return theWindow
+end findWindowWithTitle
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Coordinate System.applescript *)
+
+(* This is an example of how to use the new coordinate system support. *)
+
+(* ===== Event Handlers ===== *)
+
+on launched theObject
+ show window "main"
+end launched
+
+-- This event handler is attached to the window and will be called when it is loaded. It is a good time to update the display in the window to show the current coordinates.
+--
+on awake from nib theObject
+ updateDisplay(theObject)
+end awake from nib
+
+-- This event handler is called when the button in our document window is clicked. It will test the various settings of the coordinate system by moving the window and then by moving the button.
+--
+on clicked theObject
+ set theWindow to window of theObject
+ set testObject to theWindow
+
+ -- Test the Cocoa coordinate system on a window. This system uses {x, y, width, height}, with the origin of a window or view in the lower left corner being 0, 0
+ set coordinate system to Cocoa coordinate system
+ set testBounds to bounds of testObject
+ set testPosition to position of testObject
+ set bounds of testObject to {50, 50, 500, 500}
+ delay 1
+ set position of testObject to {150, 150}
+ updateDisplay(theWindow)
+ delay 1
+
+ -- Test the old (classic) coordinate system on a window. This system uses {left, bottom, right, top}, with the origin of a window or view in the bottom left corner being 0, 0
+ set coordinate system to classic coordinate system
+ set testBounds to bounds of testObject
+ set testPosition to position of testObject
+ set bounds of testObject to {50, 50, 500, 500}
+ delay 1
+ set position of testObject to {150, 150}
+ updateDisplay(theWindow)
+ delay 1
+
+ -- Test the AppleScript coordinate system on a window. This system uses {left, top, right, bottom}, with the origin of a window or view in the top left corner being 0, 0
+ set coordinate system to AppleScript coordinate system
+ set testBounds to bounds of testObject
+ set testPosition to position of testObject
+ set bounds of testObject to {50, 50, 500, 500}
+ delay 1
+ set position of testObject to {150, 150}
+ updateDisplay(theWindow)
+ delay 1
+
+ set testObject to theObject
+
+ -- Test the Cocoa coordinate system on our button. This system uses {x, y, width, height}, with the origin of a window or view in the lower left corner being 0, 0
+ set coordinate system to Cocoa coordinate system
+ set testBounds to bounds of testObject
+ set testPosition to position of testObject
+ set bounds of testObject to {0, 0, 82, 30}
+ delay 1
+ set position of testObject to {10, 10}
+ updateDisplay(theWindow)
+ delay 1
+
+ -- Test the old (classic) coordinate system on our button. This system uses {left, bottom, right, top}, with the origin of a window or view in the bottom left corner being 0, 0
+ set coordinate system to classic coordinate system
+ set testBounds to bounds of testObject
+ set testPosition to position of testObject
+ set bounds of testObject to {0, 0, 82, 30}
+ delay 1
+ set position of testObject to {10, 10}
+ updateDisplay(theWindow)
+ delay 1
+
+ -- Test the AppleScript coordinate system on our button. This system uses {left, top, right, bottom}, with the origin of a window or view in the top left corner being 0, 0
+ set coordinate system to AppleScript coordinate system
+ set testBounds to bounds of testObject
+ set testPosition to position of testObject
+ set bounds of testObject to {0, 0, 82, 30}
+ delay 1
+ set position of testObject to {10, 10}
+ updateDisplay(theWindow)
+end clicked
+
+-- This event handler is called when the coordinate system popup button is changed. It will change the coordinate system and update the display.
+--
+on action theObject
+ set popupChoice to content of theObject
+
+ if popupChoice is 0 then
+ set coordinate system to Cocoa coordinate system
+ else if popupChoice is 1 then
+ set coordinate system to classic coordinate system
+ else if popupChoice is 2 then
+ set coordinate system to AppleScript coordinate system
+ end if
+
+ updateDisplay(window of theObject)
+end action
+
+-- This event handler is called when the window moves. It will update the display to show the current coordinates.
+--
+on moved theObject
+ updateDisplay(theObject)
+end moved
+
+-- This event handler is called when the window resizes. It will update the display to show the current coordinates.
+--
+on resized theObject
+ updateDisplay(theObject)
+end resized
+
+(* ===== Handlers ===== *)
+
+-- This handler is used to get the coordinates of the window and button and display a description in the window.
+--
+on updateDisplay(theWindow)
+ set theButton to button "button" of theWindow
+
+ set windowBounds to bounds of theWindow
+ set windowPosition to position of theWindow
+ set buttonBounds to bounds of theButton
+ set buttonPosition to position of theButton
+
+ if coordinate system is Cocoa coordinate system then
+ set coordinateSystemDescription to 0
+ set windowBoundsDescription to "{x: " & item 1 of windowBounds & ", y: " & item 2 of windowBounds & ", w: " & item 3 of windowBounds & ", h: " & item 4 of windowBounds & "}"
+ set windowPositionDescription to "{x: " & item 1 of windowPosition & ", y: " & item 2 of windowPosition & "}"
+ set buttonBoundsDescription to "{x: " & item 1 of buttonBounds & ", y: " & item 2 of buttonBounds & ", w: " & item 3 of buttonBounds & ", h: " & item 4 of buttonBounds & "}"
+ set buttonPositionDescription to "{x: " & item 1 of buttonPosition & ", y: " & item 2 of buttonPosition & "}"
+ else if coordinate system is classic coordinate system then
+ set coordinateSystemDescription to 1
+ set windowBoundsDescription to "{l: " & item 1 of windowBounds & ", b: " & item 2 of windowBounds & ", r: " & item 3 of windowBounds & ", t: " & item 4 of windowBounds & "}"
+ set windowPositionDescription to "{l: " & item 1 of windowPosition & ", b: " & item 2 of windowPosition & "}"
+ set buttonBoundsDescription to "{l: " & item 1 of buttonBounds & ", b: " & item 2 of buttonBounds & ", r: " & item 3 of buttonBounds & ", t: " & item 4 of buttonBounds & "}"
+ set buttonPositionDescription to "{l: " & item 1 of buttonPosition & ", b: " & item 2 of buttonPosition & "}"
+ else if coordinate system is AppleScript coordinate system then
+ set coordinateSystemDescription to 2
+ set windowBoundsDescription to "{l: " & item 1 of windowBounds & ", t: " & item 2 of windowBounds & ", r: " & item 3 of windowBounds & ", b: " & item 4 of windowBounds & "}"
+ set windowPositionDescription to "{l: " & item 1 of windowPosition & ", t: " & item 2 of windowPosition & "}"
+ set buttonBoundsDescription to "{l: " & item 1 of buttonBounds & ", t: " & item 2 of buttonBounds & ", r: " & item 3 of buttonBounds & ", b: " & item 4 of buttonBounds & "}"
+ set buttonPositionDescription to "{l: " & item 1 of buttonPosition & ", t: " & item 2 of buttonPosition & "}"
+ end if
+
+ tell theWindow
+ set content of popup button "coordinate system" to coordinateSystemDescription
+ set content of text field "window bounds" to windowBoundsDescription
+ set content of text field "window position" to windowPositionDescription
+ set content of text field "button bounds" to buttonBoundsDescription
+ set content of text field "button position" to buttonPositionDescription
+ end tell
+end updateDisplay
+
+(* © Copyright 2005 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Coundown Timer.applescript *)
+
+(* This is a simple example the demonstrates how to idle event to do a countdown timer. When the application is launched it will display the countdown window with a sheet asking for the amount of time for the countdown, after which the countdown begins and when the specified time has elapsed, it displays an alert. *)
+
+(* ===== Properties ===== *)
+
+property countdown : false
+property currentDate : 0
+property startDate : 0
+property endDate : 0
+
+
+(* ===== Event Handlers ===== *)
+
+on launched theObject
+ -- Show the window
+ set visible of window "main" to true
+
+ -- Display an alert (as a sheet) asking for the amount of time in the HH:MM:SS format
+ display dialog "Enter the amount of time for the countdown timer:" default answer "00:00:05" attached to window "main"
+end launched
+
+on dialog ended theObject with reply withReply
+ -- See if the "OK" button has been clicked
+ if button returned of withReply is "OK" then
+ -- Save the current date for display purposes
+ set currentDate to date (text returned of withReply)
+
+ -- Save the start date
+ set startDate to current date
+
+ -- And determine the end date (start date + the countdown timer)
+ set endDate to startDate + (time of currentDate)
+
+ -- Update the contents of the text field
+ set contents of text field "display" of window "main" to currentDate
+
+ -- And let the processing in the idle event handler begin
+ set countdown to true
+ end if
+end dialog ended
+
+on idle theObject
+ -- See if we are ready to start counting down
+ if countdown then
+ -- If the required amount of time has elapsed then display our dialog
+ if (current date) is greater than endDate then
+ set countdown to false
+ display alert "Time's Up!"
+ else
+ -- Otherwise determine how much time has elapsed (for display purposes)
+ set elapsedTime to (current date) - startDate
+
+ -- Update the display
+ set contents of text field "display" of window "main" to currentDate - elapsedTime
+ end if
+ end if
+
+ -- We want to update the idle event every second, so we return 1
+ return 1
+end idle
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Application.applescript *)
+
+(* This is a very simple example that illustrates getting and setting the contents of text fields. It is a simple currency converter based on a '(rate * amount) = value' formula. It also uses 'formatters' for the text fields to align and set the number formatting (this is done in Interface Builder by dragging a formatter onto the text field). *)
+
+(* ==== Event Handlers ==== *)
+
+on clicked theObject
+ tell window of theObject
+ try
+ set theRate to contents of text field "rate"
+ set theAmount to contents of text field "amount" as number
+
+ set contents of text field "total" to theRate * theAmount
+ on error
+ set contents of text field "total" to 0
+ end try
+ end tell
+end clicked
+
+on should quit after last window closed theObject
+ return true
+end should quit after last window closed
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Currency Converter.applescript *)
+
+(* This is an enhanced version of Currency Converter that utilizes SOAP services to enable getting the current exchange rate. *)
+
+
+(* ==== Event Handlers ==== *)
+
+-- The "action" event handler is called when the user choosing a country from the popup button. We will call the "getRate" event handler to use a SOAP service to get the rate.
+--
+on action theObject
+ set contents of text field "rate" of window of theObject to getRate(title of theObject as string)
+end action
+
+
+-- The "clicked" event handler is called when the user clicks on the "Convert" button. This will do a simple calculatin of "rate * dollars" and put the result in the "total" field.
+--
+on clicked theObject
+ tell window of theObject
+ set theRate to contents of text field "rate" as real
+ set theDollars to contents of text field "dollars" as real
+ set contents of text field "total" to theRate * theDollars
+ end tell
+end clicked
+
+
+-- The "awake from nib" event handler is called the popup button is loaded form the nib. In this example we will use this opportunity to get the rate (based on the default selection of the popup button).
+--
+on awake from nib theObject
+ set contents of text field "rate" of window of theObject to getRate(title of theObject)
+end awake from nib
+
+
+(* ==== Handlers ==== *)
+
+-- This handler is called to get the current exchange rate for the given country. It does this by using the "call soap" command to communicate with a SOAP web service.
+--
+on getRate(forCountry)
+ -- Initialize the result to a known value
+ set theRate to 1.0
+
+ -- We always convert from the US
+ set fromCountry to "USA"
+
+ -- Talk to the soap service
+ tell application "http://services.xmethods.net:80/soap"
+ -- Call the "getRate" method of the soap service returning the current rate
+ set theRate to call soap {method name:"getRate", method namespace uri:"urn:xmethods-CurrencyExchange", parameters:{country1:fromCountry, country2:forCountry}, SOAPAction:""}
+ end tell
+
+ -- Return the result
+ return theRate
+end getRate
+
+-- This is a utility handler to get the given unicode text as plain text (not styled text)
+--
+on getPlainText(fromUnicodeString)
+ set styledText to fromUnicodeString as string
+ set styledRecord to styledText as record
+ return Çclass ktxtÈ of styledRecord
+end getPlainText
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Daily Dilbert.applescript *)
+
+(* This is a simple example of how to load an image given a URL from a web service. It utilizes a couple of shell commands (date, curl) to accomplish this. *)
+
+
+(* ==== Event Handlers ==== *)
+
+-- The "awake from nib" event handler is called when the object is loaded from its nib file. In this case it will be the image view. The script will get the image from the web service and then set that image into the image view. Then the window will be resized appropriately.
+--
+on awake from nib theObject
+ -- We need to have the date in the format "mm/dd/yy" which is actually easier to get from the "date" shell command.
+ set theDate to do shell script "date +%m/%d/%y"
+
+ -- Get the Dilbert image based on the date
+ set theImage to getDilbertImageForDate(theDate)
+ set image of theObject to theImage
+
+ -- Resize the window
+ set the size of (window of theObject) to call method "size" of object theImage
+
+ -- Show the window
+ show window of theObject
+end awake from nib
+
+
+(* ==== Handlers ==== *)
+
+-- This handler will return the image for the given date. It does this by getting the URL for the image from a web service.
+--
+on getDilbertImageForDate(theDate)
+ set theImage to missing value
+ set theImage to loadImageAtURL(DailyDilbertImagePath(theDate))
+ return theImage
+end getDilbertImageForDate
+
+
+-- With the given URL, this handler will download the image using the "curl" shell tool. It then will load the image using the "load image" command.
+--
+on loadImageAtURL(theURL)
+ set theImage to missing value
+
+ -- Get the last component of the URL. Here we'll use the "lastPathComponent" method of NSString.
+ set theImagePath to "/tmp/" & (call method "lastPathComponent" of object theURL)
+
+ -- Download the image using "curl"
+ do shell script ("curl -o " & theImagePath & " " & theURL)
+
+ -- Load the image
+ set theImage to load image theImagePath
+
+ return theImage
+end loadImageAtURL
+
+
+(* ==== Web Services Handlers ==== *)
+
+-- This handler will return the URL that points to the Dilbert image for the given date.
+--
+on DailyDilbertImagePath(forDate)
+ tell application "http://www.esynaps.com/WebServices/DailyDiblert.asmx"
+ set mname to "DailyDilbertImagePath"
+ set soapact to "http://tempuri.org/DailyDilbertImagePath"
+ set namespace to "http://tempuri.org/"
+ set params to {}
+ set params to params & {|parameters|:forDate}
+ return call soap {method name:mname, parameters:params, SOAPAction:soapact, method namespace uri:namespace}
+ end tell
+end DailyDilbertImagePath
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Debug Test.applescript *)
+
+(* The purpose of this example is to illustrate the debugging of AppleScript. Many of the properties and values are there mainly to test the debugger in it's ability to show and set the various values. It also illustrates the ability to interact with the UI while in the processing of executing a script. *)
+
+(* ==== Properties ==== *)
+
+property keepRunning : true
+property prop1 : "Test property 1"
+property prop2 : "Test property 2"
+property prop3 : 0
+
+
+(* ==== Event Handlers ==== *)
+
+-- Here we handle the click on the "Start/Stop" button, toggling between states as necessary.
+--
+on clicked theObject
+ if title of theObject is "Start" then
+ set keepRunning to true
+ set title of theObject to "Stop"
+ set theResult to 2
+ runforever()
+ else if title of theObject is "Stop" then
+ set title of theObject to "Start"
+ set keepRunning to false
+ end if
+end clicked
+
+-- This handler is called after the window is loaded, but before it is displayed.
+--
+on will open theObject
+ set prop3 to 10
+end will open
+
+-- This event handler is called just before the window is closed. If you want to stop the window from being closed, you can use the "should close" event handler and return false.
+--
+on will close theObject
+ set keepRunning to false
+end will close
+
+
+(* ==== Handlers ==== *)
+
+-- This is a handler that is called to do a repeat loop until the keepRunning variable gets changed to false. It also animates the barber pole and set the value of the text field.
+--
+on runforever()
+ set numberTest to 1
+ set stringTest to "testing"
+
+ runonce()
+
+ repeat while keepRunning
+ tell progress indicator "Barber Pole" of window "Main" to animate
+ set prop3 to prop3 + 1
+ set numberTest to numberTest + 1
+
+ set contents of text field "counter" of window "Main" to numberTest as string
+ end repeat
+end runforever
+
+on runonce()
+ set prop3 to prop3 + 1
+ set prop3 to prop3 + 1
+ set prop3 to prop3 + 1
+ set prop3 to prop3 + 1
+
+ runonceagain()
+end runonce
+
+on runonceagain()
+ set prop3 to prop3 + 1
+ set prop3 to prop3 + 1
+ set prop3 to prop3 + 1
+ set prop3 to prop3 + 1
+
+ runlasttime()
+end runonceagain
+
+on runlasttime()
+ set prop3 to prop3 + 1
+end runlasttime
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Display Alert.applescript *)
+
+(* This example demonstrates the "display alert" command. It can be used in place of "display dialog" when you need to alert the user to some condition. The icon is determined by the "as" type. *)
+
+(* ==== Event Handlers ==== *)
+
+-- This event handler is called when the "Display Alert" button is clicked, which when clicked the various parameter values pulled from the text fields to be sent to "display alert".
+--
+on clicked theObject
+ -- Get the various parameter values
+ tell window "main"
+ set dialogText to contents of text field "text"
+ set dialogMessage to contents of text field "message"
+ set defaultButtonTitle to contents of text field "default button"
+ set alternateButtonTitle to contents of text field "alternate button"
+ set otherButtonTitle to contents of text field "other button"
+ end tell
+
+ -- Set the "as" type to be either warning, informational or critical based on the setting in the radio group.
+ set dialogType to warning
+ if current row of matrix "type" of window "main" is 2 then
+ set dialogType to informational
+ else if current row of matrix "type" of window "main" is 3 then
+ set dialogType to critical
+ end if
+
+ -- If the "as sheet" button is checked then use the "attached to" optional parameter, in which the "alert ended" event handler will be called when the sheet is dismissed.
+ if state of button "as sheet" of window "main" is 1 then
+ display alert dialogText as dialogType message dialogMessage default button defaultButtonTitle alternate button alternateButtonTitle other button otherButtonTitle attached to window "main"
+ else
+ -- Otherwise handle it much like "display dialog"
+ set theReply to display alert dialogText as dialogType message dialogMessage default button defaultButtonTitle alternate button alternateButtonTitle other button otherButtonTitle
+ set contents of text field "button returned" of window "main" to button returned of theReply
+ end if
+end clicked
+
+-- This event handler is called if the "attached to" parameter is used. It is called when the dialog has been dismissed. It simply sets the text field to be the button that was pressed to dismiss the dialog.
+--
+on alert ended theObject with reply theReply
+ set contents of text field "button returned" of window "main" to button returned of theReply
+end alert ended
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Display Dialog.applescript *)
+
+(* This example will demonstrate the various ways of using the "display dialog" command. The dialog can be displayed as a dialog, or attached to a window as sheet. *)
+
+(* ==== Event Handlers ==== *)
+
+-- This event handler is called when the "Display Dialog" button is clicked. It gets the various settings from the UI elements and passes them to "display dialog" as parameters.
+--
+on clicked theObject
+ -- Initialize all the parameter values that will be passed to display dialog
+ tell window "main"
+ set dialogText to contents of text field "text"
+ set dialogDefaultAnswer to contents of text field "default answer"
+ set dialogButton1 to contents of text field "button 1"
+
+ set dialogButton2 to contents of text field "button 2"
+ set dialogButton3 to contents of text field "button 3"
+ set dialogDefaultButton to contents of text field "default button"
+ set dialogIcon to contents of text field "icon"
+ set dialogGivingUpAfter to contents of text field "giving up" as number
+ end tell
+
+ -- If we want to have the display dialog presented as a sheet, then we need add the optional parameter "attached to" passing it a window object
+ if state of button "as sheet" of window "main" is equal to 1 then
+ if dialogDefaultAnswer is "" then
+ display dialog dialogText buttons {dialogButton1, dialogButton2, dialogButton3} default button dialogDefaultButton giving up after dialogGivingUpAfter with icon dialogIcon attached to window "main"
+ else
+ display dialog dialogText default answer dialogDefaultAnswer buttons {dialogButton1, dialogButton2, dialogButton3} default button dialogDefaultButton giving up after dialogGivingUpAfter with icon dialogIcon attached to window "main"
+ end if
+ else
+ -- Otherwise we do it the standard way
+ try
+ if dialogDefaultAnswer is "" then
+ set theReply to display dialog dialogText buttons {dialogButton1, dialogButton2, dialogButton3} default button dialogDefaultButton giving up after dialogGivingUpAfter with icon dialogIcon
+ else
+ set theReply to display dialog dialogText default answer dialogDefaultAnswer buttons {dialogButton1, dialogButton2, dialogButton3} default button dialogDefaultButton giving up after dialogGivingUpAfter with icon dialogIcon
+ end if
+
+ -- Set the values returned from the dialog reply
+ set contents of text field "text returned" of window "main" to text returned of theReply
+ set contents of text field "button returned" of window "main" to button returned of theReply
+ set state of button "gave up" of window "main" to gave up of theReply
+ on error
+ -- The user pressed the "Cancel" button, so display that as the result. We can't use the "theReply" value because it wasn't returned from the "display dialog" call, because of the cancel.
+ set contents of text field "button returned" of window "main" to "Cancel"
+ end try
+ end if
+end clicked
+
+-- This handler gets called when the display dialog dialog if finished if it was called with the "attached to" optional parameter.
+on dialog ended theObject with reply theReply
+ -- Set the values returned in "theReply"
+ set contents of text field "text returned" of window "main" to text returned of theReply
+ set contents of text field "button returned" of window "main" to button returned of theReply
+ set state of button "gave up" of window "main" to gave up of theReply
+end dialog ended
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Settings.applescript *)
+
+(* ==== Event Handlers ==== *)
+
+on clicked theObject
+ if name of theObject is "cancel" then
+ close panel (window of theObject)
+ else if name of theObject is "change" then
+ close panel (window of theObject) with result 1
+ end if
+end clicked
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Window.applescript *)
+
+(* This script demonstrates the "display panel" command which allows you to create your own dialogs and have them displayed either as a dialog or attached to a window as a sheet. *)
+
+(* ==== Properties ==== *)
+
+property panelWIndow : missing value
+
+(* ==== Event Handlers ==== *)
+
+on clicked theObject
+ set theName to contents of text field "name" of window "main"
+ set theType to contents of text field "type" of window "main"
+
+ -- Load the panel. We do this by loading the nib that contains the panel window, and then setting our property to the loaded window. Only do this once, as every time the nib is loaded, it will create new copies of all of the top level objects in the nib.
+ if panelWIndow is equal to missing value then
+ load nib "SettingsPanel"
+ set panelWIndow to window "settings"
+ end if
+
+ -- Set the state of the items in the panel
+ tell panelWIndow
+ set contents of text field "name" to theName
+ if theType is "Button" then
+ set current row of matrix "type" to 1
+ else if theType is "Popup Button" then
+ set current row of matrix "type" to 2
+ else if theType is "Radio" then
+ set current row of matrix "type" to 3
+ else if theType is "Switch" then
+ set current row of matrix "type" to 4
+ end if
+ end tell
+
+ -- Display the panel
+ if state of button "as sheet" of window "main" is 1 then
+ display panel panelWIndow attached to window "main"
+ else
+ if (display panel panelWIndow) is 1 then
+ local theName
+ local theType
+
+ tell panelWIndow
+ set theName to contents of text field "name"
+ set selectedRow to current row of matrix "type"
+
+ if selectedRow is 1 then
+ set theType to "Button"
+ else if selectedRow is 2 then
+ set theType to "Popup Button"
+ else if selectedRow is 3 then
+ set theType to "Radio"
+ else if selectedRow is 4 then
+ set theType to "Switch"
+ end if
+ end tell
+
+ set contents of text field "name" of window "main" to theName
+ set contents of text field "type" of window "main" to theType
+ end if
+ end if
+
+end clicked
+
+on panel ended thePanel with result theResult
+ if theResult is 1 then
+ local theName
+ local theType
+
+ tell thePanel
+ set theName to contents of text field "name"
+ set selectedRow to current row of matrix "type"
+
+ if selectedRow is 1 then
+ set theType to "Button"
+ else if selectedRow is 2 then
+ set theType to "Popup Button"
+ else if selectedRow is 3 then
+ set theType to "Radio"
+ else if selectedRow is 4 then
+ set theType to "Switch"
+ end if
+ end tell
+
+ set contents of text field "name" of window "main" to theName
+ set contents of text field "type" of window "main" to theType
+ end if
+end panel ended
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Button.applescript *)
+
+(* This script is used to register the appropriate drag types for the "button" object and then responds to a drop on it. *)
+
+(* ==== Event Handlers ==== *)
+
+-- The "awake from nib" event handler is a good place to register the drag types that this object can respond to.
+--
+on awake from nib theObject
+ -- Enable the dropping of the appropriate types by registering them.
+ tell theObject to register drag types {"string", "rich text", "file names"}
+end awake from nib
+
+-- The "drop" event handler is called when the appropriate type of data is dropped onto the object. All of the pertinent information about the drop is contained in the "dragInfo" object.
+--
+on drop theObject drag info dragInfo
+ -- Make sure that we have the "string" data type
+ if "string" is in types of pasteboard of dragInfo then
+ -- Set the title of the button to the contents of the pasteboard
+ set title of theObject to contents of pasteboard of dragInfo
+ end if
+
+ return true
+end drop
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Drag and Drop.applescript *)
+
+(* This script is the main script of the application, although in this case it does very little. It responds to the "Color Chooser" button by displaying the "color panel". *)
+
+(* ==== Event Handlers ==== *)
+
+-- The "clicked" event handler is called when the user clicks on the "Color Chooser" button.
+--
+on clicked theObject
+ -- We simply want to the show the "color panel" so that the user can drag a color from it.
+ show the color panel
+end clicked
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Image View.applescript *)
+
+(* This script is used to register the appropriate drag types for the "image view" object and then responds to a drop on it. *)
+
+(* ==== Event Handlers ==== *)
+
+-- The "awake from nib" event handler is a good place to register the drag types that this object can respond to.
+--
+on awake from nib theObject
+ -- Enable the dropping of the appropriate types by registering them.
+ tell theObject to register drag types {"image", "pict image", "file names", "color"}
+end awake from nib
+
+-- The "drop" event handler is called when the appropriate type of data is dropped onto the object. All of the pertinent information about the drop is contained in the "dragInfo" object.
+--
+on drop theObject drag info dragInfo
+ -- Get a list of the data types on the pasteboard
+ set dataTypes to types of pasteboard of dragInfo
+
+ -- Currently, we are only interested if there are "files names" on the pasteboard
+ if "file names" is in dataTypes then
+ -- This is a mechanism to tell the pasteboard which type of data we want when we access the "contents" of the pasteboard.
+ set preferred type of pasteboard of dragInfo to "file names"
+
+ -- Get the list of files dropped on the object form the pasteboard
+ set thePaths to contents of pasteboard of dragInfo
+
+ -- Load the image at the location of the first item
+ set theImage to load image (item 1 of thePaths)
+
+ -- Set the image into the image view
+ set image of theObject to theImage
+
+ -- Make sure to delete the image we loaded otherwise it will never be removed from memory.
+ delete theImage
+
+ -- Set the preferred type back to the default
+ set preferred type of pasteboard of dragInfo to ""
+ end if
+
+ return true
+end drop
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Table.applescript *)
+
+(* This script is used to register the appropriate drag types for the "table view" object and then responds to a drop on it. *)
+
+(* ==== Event Handlers ==== *)
+
+-- The "awake from nib" event handler is a good place to register the drag types that this object can respond to.
+--
+on awake from nib theObject
+ -- Create the data source for the table view
+ set theDataSource to make new data source at end of data sources with properties {name:"files"}
+
+ -- Create the "files" data column
+ make new data column at end of data columns of theDataSource with properties {name:"files"}
+
+ -- Assign the data source to the table view
+ set data source of theObject to theDataSource
+
+ -- Register for the "color" and "file names" drag types
+ tell theObject to register drag types {"file names", "color"}
+end awake from nib
+
+-- The "drop" event handler is called when the appropriate type of data is dropped onto the object. All of the pertinent information about the drop is contained in the "dragInfo" object.
+--
+on drop theObject drag info dragInfo
+ -- Get the list of data types on the pasteboard
+ set dataTypes to types of pasteboard of dragInfo
+
+ -- We are only interested in either "file names" or "color" data types
+ if "file names" is in dataTypes then
+ -- Initialize the list of files to an empty list
+ set theFiles to {}
+
+ -- We want the data as a list of file names, so set the preferred type to "file names"
+ set preferred type of pasteboard of dragInfo to "file names"
+
+ -- Get the list of files from the pasteboard
+ set theFiles to contents of pasteboard of dragInfo
+
+ -- Make sure we have at least one item
+ if (count of theFiles) > 0 then
+ --- Get the data source from the table view
+ set theDataSource to data source of theObject
+
+ -- Turn off the updating of the views
+ set update views of theDataSource to false
+
+ -- Delete all of the data rows in the data source
+ delete every data row of theDataSource
+
+ -- For every item in the list, make a new data row and set it's contents
+ repeat with theItem in theFiles
+ set theDataRow to make new data row at end of data rows of theDataSource
+ set contents of data cell "files" of theDataRow to theItem
+ end repeat
+
+ -- Turn back on the updating of the views
+ set update views of theDataSource to true
+ end if
+ else if "color" is in dataTypes then
+ -- We want the data as a color, so set the preferred type
+ set preferred type of pasteboard of dragInfo to "color"
+
+ -- Set the background color of the table view to the color on the pasteboard
+ set background color of theObject to contents of pasteboard of dragInfo
+
+ -- We need to update the table view (redraw it).
+ update theObject
+ end if
+
+ -- Set the preferred type back to the default
+ set preferred type of pasteboard of dragInfo to ""
+
+ return true
+end drop
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+
+(* ==== Event Handlers ==== *)
+
+-- The "awake from nib" event handler is a good place to register the drag types that this object can respond to.
+--
+on awake from nib theObject
+ -- We will register for the following types (altough this example only responds to the "string" type).
+ tell theObject to register drag types {"string", "rich text", "file names"}
+end awake from nib
+
+on conclude drop theObject drag info dragInfo
+ (* We need to have this handler do nothing to keep the text field from doing it's own drop. This is true for text view's as well. If you want to let the text field or text view do the actual drop you can remove the "conclude drop" event handler and then not do anything in the "drop" event handler. *)
+end conclude drop
+
+-- The "drop" event handler is called when the appropriate type of data is dropped onto the object. All of the pertinent information about the drop is contained in the "dragInfo" object.
+--
+on drop theObject drag info dragInfo
+ -- We are only interested in the "string" data type
+ if "string" is in types of pasteboard of dragInfo then
+ -- Set the contents of the text field to the contents of the pasteboard
+ set string value of theObject to contents of pasteboard of dragInfo
+ end if
+
+ return true
+end drop
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Application.applescript *)
+
+(* ==== Properties ==== *)
+
+property endRace : false
+property finishLine : 627
+property betAmount : 5
+property holdingsAmount : 1000
+
+global carOneOrgbounds, carTwoOrgbounds, carThreeOrgbounds, carFourOrgbounds, carFiveOrgbounds, pickedCar, winner, raceSpeedval
+
+
+(* ==== Handlers ==== *)
+
+on resetRace()
+ set the title of button "Car 1" of window "Drag Race" to "Car 1"
+ set the title of button "Car 2" of window "Drag Race" to "Car 2"
+ set the title of button "Car 3" of window "Drag Race" to "Car 3"
+ set the title of button "Car 4" of window "Drag Race" to "Car 4"
+ set the title of button "Car 5" of window "Drag Race" to "Car 5"
+ set the enabled of button "Start Race" of window "Drag Race" to false
+ set the bounds of button "Car 1" of window "Drag Race" to carOneOrgbounds
+ set the bounds of button "Car 2" of window "Drag Race" to carTwoOrgbounds
+ set the bounds of button "Car 3" of window "Drag Race" to carThreeOrgbounds
+ set the bounds of button "Car 4" of window "Drag Race" to carFourOrgbounds
+ set the bounds of button "Car 5" of window "Drag Race" to carFiveOrgbounds
+end resetRace
+
+
+on moveCar1()
+ tell window "Drag Race"
+ set carOneOrgPos to the bounds of button "Car 1"
+ set stepVal to random number from 1 to raceSpeedval
+ set bounds of button "Car 1" to {((item 1 of carOneOrgPos) + stepVal), item 2 of carOneOrgbounds, ((item 3 of carOneOrgPos) + stepVal), item 4 of carOneOrgbounds}
+
+ set carOneOrgPos to the bounds of button "Car 1"
+ if item 3 of carOneOrgPos > 630 then
+ set winner to "Car 1"
+ set endRace to true
+ set the enabled of button "Start Race" to false
+ if pickedCar = "Car 1" then
+ set the contents of text field "results" to "Car 1, you won!"
+ tell progress indicator "ProgressBar" to stop
+ set visible of progress indicator "ProgressBar" to false
+ set contents of text field "holdings" to (betAmount + holdingsAmount)
+ else
+ set the contents of text field "results" to winner & " won, you lost!"
+ tell progress indicator "ProgressBar" to stop
+ set visible of progress indicator "ProgressBar" to false
+ set contents of text field "holdings" to (holdingsAmount - betAmount)
+ end if
+ end if
+ end tell
+end moveCar1
+
+on moveCar2()
+ tell window "Drag Race"
+ set cartwoOrgPos to the bounds of button "Car 2"
+ set stepVal to random number from 1 to raceSpeedval
+ set bounds of button "Car 2" to {((item 1 of cartwoOrgPos) + stepVal), item 2 of carTwoOrgbounds, ((item 3 of cartwoOrgPos) + stepVal), item 4 of carTwoOrgbounds}
+
+ set cartwoOrgPos to the bounds of button "Car 2"
+ if item 3 of cartwoOrgPos > finishLine then
+ set winner to "Car 2"
+ set endRace to true
+ set the enabled of button "Start Race" to false
+ if pickedCar = "Car 2" then
+ set the contents of text field "results" to "Car 2, you won!"
+ tell progress indicator "ProgressBar" to stop
+ set visible of progress indicator "ProgressBar" to false
+ set contents of text field "holdings" to (betAmount + holdingsAmount)
+ else
+ set the contents of text field "results" to winner & " won, you lost!"
+ tell progress indicator "ProgressBar" to stop
+ set visible of progress indicator "ProgressBar" to false
+ set contents of text field "holdings" to (holdingsAmount - betAmount)
+ end if
+ end if
+ end tell
+end moveCar2
+
+on moveCar3()
+ tell window "Drag Race"
+ set carThreeOrgPos to the bounds of button "Car 3"
+ set stepVal to random number from 1 to raceSpeedval
+ set bounds of button "Car 3" to {((item 1 of carThreeOrgPos) + stepVal), item 2 of carThreeOrgbounds, ((item 3 of carThreeOrgPos) + stepVal), item 4 of carThreeOrgbounds}
+ set carThreeOrgPos to the bounds of button "Car 3"
+ if item 3 of carThreeOrgPos > finishLine then
+ set winner to "Car 3"
+ set endRace to true
+ set the enabled of button "Start Race" to false
+ if pickedCar = "Car 3" then
+ set the contents of text field "results" to "Car 3, you won!"
+ tell progress indicator "ProgressBar" to stop
+ set visible of progress indicator "ProgressBar" to false
+ set contents of text field "holdings" to (betAmount + holdingsAmount)
+ else
+ set the contents of text field "results" to winner & " won, you lost!"
+ tell progress indicator "ProgressBar" to stop
+ set visible of progress indicator "ProgressBar" to false
+ set contents of text field "holdings" to (holdingsAmount - betAmount)
+ end if
+ end if
+ end tell
+end moveCar3
+
+on moveCar4()
+ tell window "Drag Race"
+ set carFourOrgPos to the bounds of button "Car 4"
+ set stepVal to random number from 1 to raceSpeedval
+ set bounds of button "Car 4" to {((item 1 of carFourOrgPos) + stepVal), item 2 of carFourOrgbounds, ((item 3 of carFourOrgPos) + stepVal), item 4 of carFourOrgbounds}
+ set carFourOrgPos to the bounds of button "Car 4"
+ if item 3 of carFourOrgPos > finishLine then
+ set winner to "Car 4"
+ set endRace to true
+ set the enabled of button "Start Race" to false
+ if pickedCar = "Car 4" then
+ set the contents of text field "results" to "Car 4, you won!"
+ tell progress indicator "ProgressBar" to stop
+ set visible of progress indicator "ProgressBar" to false
+ set contents of text field "holdings" to (betAmount + holdingsAmount)
+ else
+ set the contents of text field "results" to winner & " won, you lost!"
+ tell progress indicator "ProgressBar" to stop
+ set visible of progress indicator "ProgressBar" to false
+ set contents of text field "holdings" to (holdingsAmount - betAmount)
+ end if
+ end if
+ end tell
+end moveCar4
+
+on moveCar5()
+ tell window "Drag Race"
+ set carFiveOrgPos to the bounds of button "Car 5"
+ set stepVal to random number from 1 to raceSpeedval
+ set bounds of button "Car 5" to {((item 1 of carFiveOrgPos) + stepVal), item 2 of carFiveOrgbounds, ((item 3 of carFiveOrgPos) + stepVal), item 4 of carFiveOrgbounds}
+ set carFiveOrgPos to the bounds of button "Car 5"
+ if item 3 of carFiveOrgPos > finishLine then
+ set winner to "Car 5"
+ set endRace to true
+ set the enabled of button "Start Race" to false
+ if pickedCar = "Car 5" then
+ set the contents of text field "results" to "Car 5, you won!"
+ tell progress indicator "ProgressBar" to stop
+ set visible of progress indicator "ProgressBar" to false
+ set contents of text field "holdings" to (betAmount + holdingsAmount)
+ else
+ set the contents of text field "results" to winner & " won, you lost!"
+ tell progress indicator "ProgressBar" to stop
+ set visible of progress indicator "ProgressBar" to false
+ set contents of text field "holdings" to (holdingsAmount - betAmount)
+ end if
+ end if
+ end tell
+end moveCar5
+
+
+(* ==== Event Handlers ==== *)
+
+on will open theObject
+ set visible of progress indicator "ProgressBar" of window "Drag Race" to false
+ set betAmount to contents of text field "bet" of window "Drag Race"
+ set holdingsAmount to contents of text field "holdings" of window "Drag Race"
+ set raceSpeedval to contents of slider "RaceSpeed" of window "Drag Race" as integer
+ set carOneOrgbounds to the bounds of button "Car 1" of window "Drag Race"
+ set carTwoOrgbounds to the bounds of button "Car 2" of window "Drag Race"
+ set carThreeOrgbounds to the bounds of button "Car 3" of window "Drag Race"
+ set carFourOrgbounds to the bounds of button "Car 4" of window "Drag Race"
+ set carFiveOrgbounds to the bounds of button "Car 5" of window "Drag Race"
+ set the contents of text field "results" of window "Drag Race" to "Pick a car!"
+ set the enabled of button "Start Race" of window "Drag Race" to false
+ set the enabled of button "Reset" of window "Drag Race" to false
+end will open
+
+
+on clicked theObject
+
+ if title of theObject = "Car 1" then
+ resetRace()
+ set the title of button "Car 1" of window "Drag Race" to "Car 1 ¥"
+ set contents of text field "results" of window "Drag Race" to "You picked car 1"
+ set pickedCar to "Car 1"
+ set the enabled of button "Start Race" of window "Drag Race" to true
+ set the enabled of button "Reset" of window "Drag Race" to true
+ else if title of theObject = "Car 2" then
+ resetRace()
+ set the title of button "Car 2" of window "Drag Race" to "Car 2 ¥"
+ set contents of text field "results" of window "Drag Race" to "You picked car 2"
+ set pickedCar to "Car 2"
+ set the enabled of button "Start Race" of window "Drag Race" to true
+ set the enabled of button "Reset" of window "Drag Race" to true
+ else if title of theObject = "Car 3" then
+ resetRace()
+ set the title of button "Car 3" of window "Drag Race" to "Car 3 ¥"
+ set contents of text field "results" of window "Drag Race" to "You picked car 3"
+ set pickedCar to "Car 3"
+ set the enabled of button "Start Race" of window "Drag Race" to true
+ set the enabled of button "Reset" of window "Drag Race" to true
+ else if title of theObject = "Car 4" then
+ resetRace()
+ set the title of button "Car 4" of window "Drag Race" to "Car 4 ¥"
+ set contents of text field "results" of window "Drag Race" to "You picked car 4"
+ set pickedCar to "Car 4"
+ set the enabled of button "Start Race" of window "Drag Race" to true
+ set the enabled of button "Reset" of window "Drag Race" to true
+ else if title of theObject = "Car 5" then
+ resetRace()
+ set the title of button "Car 5" of window "Drag Race" to "Car 5 ¥"
+ set contents of text field "results" of window "Drag Race" to "You picked car 5"
+ set pickedCar to "Car 5"
+ set the enabled of button "Start Race" of window "Drag Race" to true
+ set the enabled of button "Reset" of window "Drag Race" to true
+ else if title of theObject = "Reset" then
+ set endRace to true
+ tell progress indicator "ProgressBar" of window "Drag Race" to stop
+ resetRace()
+ set the contents of text field "results" of window "Drag Race" to "Pick a car!"
+ end if
+
+ if contents of text field "results" of window "Drag Race" ­ "Pick a car!" then
+ if title of theObject = "Start Race" then
+ set endRace to false
+ set betAmount to contents of text field "bet" of window "Drag Race"
+ set holdingsAmount to contents of text field "holdings" of window "Drag Race"
+ set visible of progress indicator "ProgressBar" of window "Drag Race" to true
+ tell progress indicator "ProgressBar" of window "Drag Race" to start
+ repeat while endRace = false
+ moveCar1()
+ moveCar2()
+ moveCar3()
+ moveCar4()
+ moveCar5()
+ end repeat
+ end if
+ end if
+end clicked
+
+on action theObject
+ set raceSpeedval to contents of slider "RaceSpeed" of window "Drag Race" as integer
+end action
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Application.applescript *)
+
+(* This is an example that demonstrates how to show and hide a drawer, as well as change all of the various settings of a drawer, including the leading/trailing offsets and the various content sizes. *)
+
+(* ==== Event Handlers ==== *)
+
+-- This event handler is called when any of the attached UI elements are clicked. One thing of note in the handling of clicking on stepper objects: you need to update the value of the text fields based on the value of the stepper in order to keep them in sync.
+--
+on clicked theObject
+ tell window "main"
+ if theObject is equal to button "drawer" then
+ set currentState to state of drawer "drawer"
+ set openOnSide to current row of matrix "open on"
+
+ -- Show/Hide the drawer as appropriate as well as updating the state text fields.
+ if currentState is equal to drawer closed or currentState is equal to drawer closing then
+ if openOnSide is equal to 1 then
+ tell drawer "drawer" to open drawer on left edge
+ else if openOnSide is equal to 2 then
+ tell drawer "drawer" to open drawer on top edge
+ else if openOnSide is equal to 3 then
+ tell drawer "drawer" to open drawer on right edge
+ else if openOnSide is equal to 4 then
+ tell drawer "drawer" to open drawer on bottom edge
+ end if
+ set title of button "drawer" to "Close Drawer"
+ set contents of text field "drawer state" to "Opened"
+ else if currentState is equal to drawer opened or currentState is equal to drawer opening then
+ tell drawer "drawer" to close drawer
+ set title of button "drawer" to "Open Drawer"
+ set contents of text field "drawer state" to "Closed"
+ end if
+ else if theObject is equal to stepper "leading offset" then
+ set theValue to (contents of stepper "leading offset") as integer
+ set leading offset of drawer "drawer" to theValue
+ set contents of text field "leading offset" to theValue
+ else if theObject is equal to stepper "trailing offset" then
+ set theValue to (contents of stepper "trailing offset") as integer
+ set trailing offset of drawer "drawer" to theValue
+ set contents of text field "trailing offset" to theValue
+ else if theObject is equal to stepper "content width" then
+ set theValue to (contents of stepper "content width") as integer
+ set contentSize to content size of drawer "drawer"
+ set item 1 of contentSize to theValue
+ set content size of drawer "drawer" to contentSize
+ set contents of text field "content width" to theValue
+ else if theObject is equal to stepper "content height" then
+ set theValue to (contents of stepper "content height") as integer
+ set contentSize to content size of drawer "drawer"
+ set item 2 of contentSize to theValue
+ set content size of drawer "drawer" to contentSize
+ set contents of text field "content height" to theValue
+ else if theObject is equal to stepper "minimum width" then
+ set theValue to (contents of stepper "minimum width") as integer
+ set minimumSize to minimum content size of drawer "drawer"
+ set item 1 of minimumSize to theValue
+ set minimum content size of drawer "drawer" to minimumSize
+ set contents of text field "minimum width" to theValue
+ else if theObject is equal to stepper "minimum height" then
+ set theValue to (contents of stepper "minimum height") as integer
+ set minimumSize to minimum content size of drawer "drawer"
+ set item 2 of minimumSize to theValue
+ set minimum content size of drawer "drawer" to minimumSize
+ set contents of text field "minimum height" to theValue
+ else if theObject is equal to stepper "maximum width" then
+ set theValue to (contents of stepper "maximum width") as integer
+ set maximumSize to maximum content size of drawer "drawer"
+ set item 1 of maximumSize to theValue
+ set maximum content size of drawer "drawer" to maximumSize
+ set contents of text field "maximum width" to theValue
+ else if theObject is equal to stepper "maximum height" then
+ set theValue to (contents of stepper "maximum height") as integer
+ set maximumSize to maximum content size of drawer "drawer"
+ set item 2 of maximumSize to theValue
+ set maximum content size of drawer "drawer" to maximumSize
+ set contents of text field "maximum height" to theValue
+ end if
+ end tell
+end clicked
+
+-- This event handler is called when the text value of the attached text fields are changed. One thing of note in the handling of text fields with stepper objects: you need to update the value of the stepper based on the value of the text field in order to keep them in sync.
+--
+on action theObject
+ set textValue to contents of theObject
+
+ tell window "main"
+ if theObject is equal to text field "leading offset" then
+ set leading offset of drawer "drawer" to textValue
+ set contents of stepper "leading offset" to textValue
+ else if theObject is equal to text field "trailing offset" then
+ set trailing offset of drawer "drawer" to textValue
+ set contents of stepper "trailing offset" to textValue
+ else if theObject is equal to text field "content width" then
+ set theValue to (contents of text field "content width") as integer
+ set contentSize to content size of drawer "drawer"
+ set item 1 of contentSize to theValue
+ set content size of drawer "drawer" to contentSize
+ set contents of stepper "content width" to theValue
+ else if theObject is equal to text field "content height" then
+ set theValue to (contents of text field "content height") as integer
+ set contentSize to content size of drawer "drawer"
+ set item 2 of contentSize to theValue
+ set content size of drawer "drawer" to contentSize
+ set contents of stepper "content height" to theValue
+ else if theObject is equal to text field "minimum width" then
+ set theValue to (contents of text field "minimum width") as integer
+ set minimumSize to minimum content size of drawer "drawer"
+ set item 1 of minimumSize to theValue
+ set minimum content size of drawer "drawer" to minimumSize
+ set contents of stepper "minimum width" to theValue
+ else if theObject is equal to text field "minimum height" then
+ set theValue to (contents of text field "minimum height") as integer
+ set minimumSize to minimum content size of drawer "drawer"
+ set item 2 of minimumSize to theValue
+ set minimum content size of drawer "drawer" to minimumSize
+ set contents of stepper "minimum height" to theValue
+ else if theObject is equal to text field "maximum width" then
+ set theValue to (contents of text field "maximum width") as integer
+ set maximumSize to maximum content size of drawer "drawer"
+ set item 1 of maximumSize to theValue
+ set maximum content size of drawer "drawer" to maximumSize
+ set contents of stepper "maximum width" to theValue
+ else if theObject is equal to text field "maximum height" then
+ set theValue to (contents of text field "maximum height") as integer
+ set maximumSize to maximum content size of drawer "drawer"
+ set item 2 of maximumSize to theValue
+ set maximum content size of drawer "drawer" to maximumSize
+ set contents of stepper "maximum height" to theValue
+ end if
+ end tell
+end action
+
+-- This event handler is called when the attached window is loaded from the nib file. It's a good place to set up the values of all of the UI elements based on the current drawer settings.
+--
+on awake from nib theObject
+ tell theObject
+ set openOnEdge to edge of drawer "drawer"
+ set preferredEdge to preferred edge of drawer "drawer"
+
+ -- Set the drawer up with some initial values.
+ set leading offset of drawer "drawer" to 20
+ set trailing offset of drawer "drawer" to 20
+
+ -- Update the UI to match the settings of the drawer.
+ if state of drawer "drawer" is drawer closed then
+ set contents of text field "drawer state" to "Closed"
+ else if state of drawer "drawer" is drawer opened then
+ set contents of text field "drawer state" to "Opened"
+ end if
+
+ if openOnEdge is left edge then
+ set current row of matrix "open on" to 1
+ else if openOnEdge is top edge then
+ set current row of matrix "open on" to 2
+ else if openOnEdge is right edge then
+ set current row of matrix "open on" to 3
+ else if openOnEdge is bottom edge then
+ set current row of matrix "open on" to 4
+ end if
+
+ if preferredEdge is left edge then
+ set current row of matrix "prefer on" to 1
+ else if preferredEdge is top edge then
+ set current row of matrix "prefer on" to 2
+ else if preferredEdge is right edge then
+ set current row of matrix "prefer on" to 3
+ else if preferredEdge is bottom edge then
+ set current row of matrix "prefer on" to 4
+ end if
+
+ set leadingValue to leading offset of drawer "drawer"
+ set trailingValue to trailing offset of drawer "drawer"
+ set contentSize to content size of drawer "drawer"
+ set minimumContentSize to minimum content size of drawer "drawer"
+ set maximumContentSize to maximum content size of drawer "drawer"
+
+ set contents of text field "leading offset" to leadingValue
+ set contents of stepper "leading offset" to leadingValue
+ set contents of text field "trailing offset" to trailingValue
+ set contents of stepper "trailing offset" to trailingValue
+ set contents of text field "content width" to item 1 of contentSize
+ set contents of stepper "content width" to item 1 of contentSize
+ set contents of text field "content height" to item 2 of contentSize
+ set contents of stepper "content height" to item 2 of contentSize
+ set contents of text field "minimum width" to item 1 of minimumContentSize
+ set contents of stepper "minimum width" to item 1 of minimumContentSize
+ set contents of text field "minimum height" to item 2 of minimumContentSize
+ set contents of stepper "minimum height" to item 2 of minimumContentSize
+ set contents of text field "maximum width" to item 1 of maximumContentSize
+ set contents of stepper "maximum width" to item 1 of maximumContentSize
+ set contents of text field "maximum height" to item 2 of maximumContentSize
+ set contents of stepper "maximum height" to item 2 of maximumContentSize
+ end tell
+end awake from nib
+
+on launched theObject
+ show window "main"
+end launched
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Content Controller.applescript *)
+
+(* ==== Event Handlers ==== *)
+
+on clicked theObject
+ set contents of text field "Date Field" of drawer "Drawer" of window "Main" to (current date) as text
+end clicked
+
+on should open theObject
+ set contents of text field "Date Field" of drawer "Drawer" of window "Main" to "should open"
+ return false
+end should open
+
+on should close theObject
+ set contents of text field "Date Field" of drawer "Drawer" of window "Main" to "should close"
+ return true
+end should close
+
+on will open theObject
+ set contents of text field "Date Field" of drawer "Drawer" of window "Main" to "will open"
+end will open
+
+on will resize theObject proposed size proposedSize
+ log proposedSize as string
+ set contents of text field "Date Field" of drawer "Drawer" of window "Main" to "will resize"
+end will resize
+
+on will close theObject
+ set contents of text field "Date Field" of drawer "Drawer" of window "Main" to "will close"
+end will close
+
+on opened theObject
+ set contents of text field "Date Field" of drawer "Drawer" of window "Main" to "opened"
+end opened
+
+on closed theObject
+ set contents of text field "Date Field" of drawer "Drawer" of window "Main" to "closed"
+end closed
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Application.applescript *)
+
+(* This example simply loads an image with a given name that is contained in the project and set's it as the image of the image view. *)
+
+(* ==== Event Handlers ==== *)
+
+on awake from nib theObject
+ set image of image view "image" of window "main" to load image "AboutBox"
+end awake from nib
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Mail Search.applescript *)
+
+(* ==== Globals ==== *)
+
+global controllers
+
+
+(* ==== Properties ==== *)
+
+property windowCount : 0
+property statusPanelNibLoaded : false
+
+
+(* ==== Event Handlers ==== *)
+
+on clicked theObject
+ set theController to controllerForWindow(window of theObject)
+ if theController is not equal to null then
+ tell theController to find()
+ end if
+end clicked
+
+on double clicked theObject
+ set theController to controllerForWindow(window of theObject)
+ if theController is not equal to null then
+ tell theController to openMessages()
+ end if
+end double clicked
+
+on action theObject
+ set theController to controllerForWindow(window of theObject)
+ if theController is not equal to null then
+ tell theController to find()
+ end if
+end action
+
+on will open theObject
+ set theController to makeController(theObject)
+ if theController is not equal to null then
+ addController(theController)
+ tell theController to initialize()
+ end if
+end will open
+
+on opened theObject
+ set theController to controllerForWindow(theObject)
+ if theController is not equal to null then
+ tell theController to loadMailboxes()
+ end if
+end opened
+
+on will finish launching theObject
+ set controllers to {}
+end will finish launching
+
+
+(* ==== Controller Handlers ==== *)
+
+on makeController(forWindow)
+ script
+ property theWindow : forWindow
+ property theStatusPanel : null
+ property foundMessages : {}
+ property mailboxesLoaded : false
+
+ -- Handlers
+
+ on initialize()
+ -- Add a column to the mailboxes data source
+ tell scroll view "mailboxes" of split view 1 of theWindow
+ make new data column at the end of the data columns of data source of outline view "mailboxes" with properties {name:"mailboxes"}
+ end tell
+
+ -- Add the columns to the messages data source
+ tell scroll view "messages" of split view 1 of theWindow
+ make new data column at the end of the data columns of data source of table view "messages" with properties {name:"from"}
+ make new data column at the end of the data columns of data source of table view "messages" with properties {name:"subject"}
+ make new data column at the end of the data columns of data source of table view "messages" with properties {name:"mailbox"}
+ end tell
+
+ set windowCount to windowCount + 1
+ end initialize
+
+ on loadMailboxes()
+ if not mailboxesLoaded then
+ -- Open the status panel
+ set theStatusPanel to makeStatusPanel(theWindow)
+ tell theStatusPanel to openPanel("Looking for Mailboxes...")
+
+ -- Add the mailboxes
+ addMailboxes()
+
+ -- Close the status panel
+ tell theStatusPanel to closePanel()
+
+ set mailboxesLoaded to true
+ end if
+ end loadMailboxes
+
+ on find()
+ -- Get what and where to find
+ set whatToFind to contents of text field "what" of theWindow
+ set whereToFind to title of current menu item of popup button "where" of theWindow
+
+ -- Make sure that we have something to find
+ if (count of whatToFind) is greater than 0 then
+ -- Clear any previously found messages
+ clearMessages()
+
+ -- Setup a status panel
+ set theStatusPanel to makeStatusPanel(theWindow)
+ tell theStatusPanel to openPanel("Determining the number of messages...")
+
+ try
+ -- Determine the mailboxes to search
+ set mailboxesToSearch to selectedMailboxes()
+
+ -- Determine the total number of messages to search
+ set totalCount of theStatusPanel to countMessages(mailboxesToSearch)
+
+ -- Adjust the status panel
+ tell theStatusPanel to adjustPanel()
+
+ -- Find the messages
+ set foundMessages to findMessages(mailboxesToSearch, whereToFind, whatToFind)
+
+ -- Change the status panel
+ tell theStatusPanel to changePanel("Adding found messages...")
+
+ -- Add the found messages to the result table
+ addMessages(foundMessages)
+
+ -- Close the status panel
+ tell theStatusPanel to closePanel()
+ on error errorText
+ tell theStatusPanel to closePanel()
+ display alert "AppleScript Error" as critical attached to theWindow message errorText
+ end try
+ else
+ display alert "Missing Value" as critical attached to theWindow message "You need to enter a value to search for."
+ end if
+ end find
+
+ on addMailbox(accountItem, accountName, mailboxIndex, mailboxName)
+ -- Add a new item
+ set mailboxItem to make new data item at the end of the data items of accountItem
+ set name of data cell 1 of mailboxItem to "mailboxes"
+ set contents of data cell 1 of mailboxItem to mailboxName
+ set associated object of mailboxItem to mailboxIndex
+ end addMailbox
+
+ on addAccount(a, accountIndex, accountName)
+ -- Add a new item
+ set accountItem to make new data item at the end of the data items of data source of outline view "mailboxes" of scroll view "mailboxes" of split view 1 of theWindow
+ set name of data cell 1 of accountItem to "mailboxes"
+ set contents of data cell 1 of accountItem to accountName
+ set associated object of accountItem to accountIndex
+
+ -- Add the mail boxes
+ tell application "Mail"
+ set mailboxIndex to 0
+ repeat with m in (get mailboxes of a)
+ try
+ set mailboxIndex to mailboxIndex + 1
+ my addMailbox(accountItem, accountName, mailboxIndex, name of m)
+ end try
+ end repeat
+ end tell
+ end addAccount
+
+ on addMailboxes()
+ tell application "Mail"
+ set accountIndex to 0
+ repeat with a in (get accounts whose enabled is not equal to false)
+ try
+ set accountIndex to accountIndex + 1
+ my addAccount(a, accountIndex, name of a)
+ end try
+ end repeat
+ end tell
+ end addMailboxes
+
+ on mailboxesForIndex(mailboxIndex)
+ -- Initiialize the result
+ set theMailboxes to {}
+
+ set theIndex to 0
+ set theAccountIndex to 0
+
+ -- Determine if the selected item is an account or a mailbox
+ tell outline view "mailboxes" of scroll view "mailboxes" of split view 1 of theWindow
+ set theItem to item for row mailboxIndex
+ set theName to contents of data cell 1 of theItem
+ set theIndex to associated object of theItem
+ if has parent data item of theItem then
+ set theAccountIndex to the associated object of the parent data item of theItem
+ end if
+ end tell
+
+ tell application "Mail"
+ if theAccountIndex > 0 then
+ set theMailboxes to {mailbox theIndex of account theAccountIndex}
+ else
+ set theMailboxes to theMailboxes & every mailbox of account theIndex
+ end if
+ end tell
+
+ -- Return the result
+ return theMailboxes
+ end mailboxesForIndex
+
+ on selectedMailboxes()
+ -- Initialize the result
+ set mailboxesSelected to {}
+
+ -- Get the currently selected mailboxes in the outline view
+ set mailboxIndicies to selected rows of outline view "mailboxes" of scroll view "mailboxes" of split view 1 of theWindow
+
+ -- Get the actual mailboxes from Mail
+ tell application "Mail"
+ if (count of mailboxIndicies) is equal to 0 then
+ repeat with a in (get accounts)
+ set mailboxesSelected to mailboxesSelected & every mailbox of a
+ end repeat
+ else
+ repeat with i in mailboxIndicies
+ set mailboxesSelected to mailboxesSelected & my mailboxesForIndex(i)
+ end repeat
+ end if
+ end tell
+
+ -- Return the result
+ return mailboxesSelected
+ end selectedMailboxes
+
+ on addMessage(messageFrom, messageSubject, messageMailbox)
+ -- Add a new row
+ set theRow to make new data row at the end of the data rows of data source of table view "messages" of scroll view "messages" of split view 1 of theWindow
+
+ -- Add "From" cell
+ set name of data cell 1 of theRow to "from"
+ set contents of data cell 1 of theRow to messageFrom
+
+ -- Add "Subject" cell
+ set name of data cell 2 of theRow to "subject"
+ set contents of data cell 2 of theRow to messageSubject
+
+ -- Add "Mailbox" cell
+ set name of data cell 3 of theRow to "mailbox"
+ set contents of data cell 3 of theRow to messageMailbox
+
+ -- set the associated object of theRow to m
+ end addMessage
+
+ on addMessages(foundMessages)
+ set update views of data source of table view "messages" of scroll view "messages" of split view 1 of theWindow to false
+
+ tell application "Mail"
+ repeat with m in foundMessages
+ try
+ set messageMailbox to name of account 1 of mailbox of m & "/" & name of mailbox of m
+ my addMessage(sender of m, subject of m, messageMailbox)
+ end try
+ end repeat
+ end tell
+
+ set update views of data source of table view "messages" of scroll view "messages" of split view 1 of theWindow to true
+ end addMessages
+
+ on findMessages(mailboxesToSearch, whereToFind, whatToFind)
+ -- Initialize the result
+ set messagesFound to {}
+
+ tell application "Mail"
+ -- Search through each of the mail boxes
+ repeat with b in (get mailboxesToSearch)
+ try
+ -- Search through each of the messages of the mail box
+ repeat with m in (get messages of b)
+ try
+ if whereToFind is equal to "Subject" then
+ if whatToFind is in the subject of m then
+ copy m to end of messagesFound
+ end if
+ else if whereToFind is equal to "From" then
+ if whatToFind is in sender of m then
+ copy m to end of messagesFound
+ end if
+ else if whereToFind is equal to "To" then
+ set foundRecipient to false
+
+ -- Recipients
+ repeat with r in (get recipients of m)
+ if whatToFind is in address of r or whatToFind is in name of r then
+ set foundRecipient to true
+ end if
+ end repeat
+
+ -- To Recipients
+ if not foundRecipient then
+ repeat with r in (get to recipients of m)
+ if whatToFind is in address of r or whatToFind is in name of r then
+ set foundRecipient to true
+ end if
+ end repeat
+ end if
+
+ -- cc Recipients
+ if not foundRecipient then
+ repeat with r in (get cc recipients of m)
+ if whatToFind is in address of r or whatToFind is in name of r then
+ set foundRecipient to true
+ end if
+ end repeat
+ end if
+
+ -- bcc Recipients
+ if not foundRecipient then
+ repeat with r in (get bcc recipients of m)
+ if whatToFind is in address of r or whatToFind is in name of r then
+ set foundRecipient to true
+ end if
+ end repeat
+ end if
+
+ if foundRecipient then
+ copy m to end of messagesFound
+ end if
+ else if whereToFind is equal to "Contents" then
+ if whatToFind is in the content of m then
+ copy m to end of messagesFound
+ end if
+ end if
+
+ -- Update the status panel
+ tell theStatusPanel to incrementPanel()
+ end try
+ end repeat
+ end try
+ end repeat
+ end tell
+
+ -- Return the result
+ return messagesFound
+ end findMessages
+
+ on clearMessages()
+ tell scroll view "messages" of split view 1 of theWindow
+ tell data source of table view "messages" to delete every data row
+ end tell
+ end clearMessages
+
+ on countMessages(mailboxesToSearch)
+ set messageCount to 0
+
+ tell application "Mail"
+ repeat with b in (get mailboxesToSearch)
+ try
+ set messageCount to messageCount + (count of every message of b)
+ end try
+ end repeat
+ end tell
+
+ return messageCount
+ end countMessages
+
+ on openMessages()
+ -- Since Mail.app currently can't open a selected message then we will just open it in our own window
+ openMessageWindow()
+ end openMessages
+
+ on openMessageWindow()
+ set clickedRow to clicked row of table view "messages" of scroll view "messages" of split view 1 of theWindow
+ if clickedRow is greater than or equal to 0 then
+ set theAccount to ""
+ set theMailbox to ""
+ set theSubject to ""
+ set theDateReceived to ""
+ set theContents to ""
+ set theSender to ""
+ set theRecipients to ""
+ set theCCRecipients to ""
+ set theReplyTo to ""
+
+ tell application "Mail"
+ set theMessage to item clickedRow of foundMessages
+
+ set theAccount to name of account of mailbox of theMessage
+ set theMailbox to name of mailbox of theMessage
+ set theSubject to subject of theMessage
+ -- set theDateReceived to date received of theMessage
+ set theContents to content of theMessage
+ set theSender to sender of theMessage
+ set theRecipients to address of every recipient of theMessage
+ set theCCRecipients to address of every cc recipient of theMessage
+ set theReplyTo to reply to of theMessage
+ end tell
+
+ set messageWindow to makeMessageWindow()
+ tell messageWindow
+ set messageContents to "Account: " & theAccount & return
+ set messageContents to messageContents & "Mailbox: " & theMailbox & return
+ if length of theSender > 0 then
+ set messageContents to messageContents & "From: " & theSender & return
+ end if
+ if length of theDateReceived as string > 0 then
+ set messageContents to messageContents & "Date: " & (theDateReceived as string) & return
+ end if
+ if length of theRecipients > 0 then
+ set messageContents to messageContents & "To: " & theRecipients & return
+ end if
+ if length of theCCRecipients > 0 then
+ set messageContents to messageContents & "Cc: " & theCCRecipients & return
+ end if
+ if length of theSubject > 0 then
+ set messageContents to messageContents & "Subject: " & theSubject & return
+ end if
+ if length of theReplyTo > 0 then
+ set messageContents to messageContents & "Reply-To: " & theReplyTo & return & return
+ end if
+ set messageContents to messageContents & theContents
+ set contents of text view "message" of scroll view "message" to messageContents
+ set title to theSubject
+ set visible to true
+ end tell
+ end if
+ end openMessageWindow
+ end script
+end makeController
+
+on addController(theController)
+ set controllers to controllers & {theController}
+end addController
+
+
+on controllerForWindow(aWindow)
+ repeat with c in controllers
+ if theWindow of c is equal to aWindow then
+ set theController to c
+ end if
+ end repeat
+ return theController
+end controllerForWindow
+
+
+(* ==== Message Window Handlers ==== *)
+
+on makeMessageWindow()
+ load nib "Message"
+ set windowCount to windowCount + 1
+ set windowName to "message " & windowCount
+ set name of window "message" to windowName
+ return window windowName
+end makeMessageWindow
+
+
+(* ==== Status Panel Handlers ==== *)
+
+on makeStatusPanel(forWindow)
+ script
+ property theWindow : forWindow
+ property initialized : false
+ property totalCount : 0
+ property currentCount : 0
+
+ -- Handlers
+ on openPanel(statusMessage)
+ if initialized is false then
+ if not statusPanelNibLoaded then
+ load nib "StatusPanel"
+ set statusPanelNibLoaded to true
+ end if
+ tell window "status"
+ set indeterminate of progress indicator "progress" to true
+ tell progress indicator "progress" to start
+ set contents of text field "statusMessage" to statusMessage
+ end tell
+ set initialized to true
+ end if
+ display panel window "status" attached to theWindow
+ end openPanel
+
+ on changePanel(statusMessage)
+ tell window "status"
+ set indeterminate of progress indicator "progress" to true
+ tell progress indicator "progress" to start
+ set contents of text field "statusMessage" to statusMessage
+ end tell
+ end changePanel
+
+ on adjustPanel()
+ tell progress indicator "progress" of window "status"
+ set indeterminate to false
+ set minimum value to currentCount
+ set maximum value to totalCount
+ set contents to 0
+ end tell
+ incrementPanel()
+ end adjustPanel
+
+ on incrementPanel()
+ set currentCount to currentCount + 1
+ if currentCount ² totalCount then
+ tell window "status"
+ tell progress indicator "progress" to increment by 1
+ set contents of text field "statusMessage" to "Message " & currentCount & " of " & totalCount
+ end tell
+ end if
+ end incrementPanel
+
+ on closePanel()
+ close panel window "status"
+ end closePanel
+ end script
+end makeStatusPanel
+
+
+(* © Copyright 2005 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+-- AppleScript.applescript
+
+(* ==== Event Handlers ==== *)
+
+-- This event handler is called when the "AppleScript" button is clicked.
+--
+on clicked theObject
+ tell window of theObject
+ -- Simply put "AppleScript" into the text field
+ set the contents of the text field "applescript" to "AppleScript"
+ end tell
+end clicked
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+-- C++.applescript
+
+(* ==== Event Handlers ==== *)
+
+-- This event handler is called when the "C++" button is clicked.
+--
+on clicked theObject
+ tell window of theObject
+ -- Call the Objective-C method "nameForCPlusPlusLanguage" defined in "Multi-Language.h"
+ -- It will in turn call a method of the CPlusPlusLanguage class defined in "C++.h"
+ set contents of text field "c++" to call method "nameForCPlusPlusLanguage"
+ end tell
+end clicked
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+-- C.applescript
+
+(* ==== Event Handlers ==== *)
+
+-- This event handler is called when the "C" button is clicked.
+--
+on clicked theObject
+ tell window of theObject
+ -- Call the Objective-C method "nameForCLanguage" defined in "Multi-Language.h"
+ -- It in turn, will call a function defined in "C.h"
+ set contents of text field "c" to call method "nameForCLanguage"
+ end tell
+end clicked
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+-- Java.applescript
+
+(* ==== Event Handlers ==== *)
+
+-- This event handler is called when either the "Java" or "Direct Java" button is clicked. If the "Java" button is clicked it will call into the Objective-C method and use the Java Bridging mechanism to call a Java method of a Java class. If the "Direct Java" button is clicked it will use 'call method''s ability to call a static method of a Java class directly.
+--
+on clicked theObject
+ tell window of theObject
+ if name of theObject is "java" then
+ -- Call the Objective-C method "nameForJavaLanguage" defined in "Multi-Language.h"
+ -- It will in turn call a method of the JavaLanguage class defined in "JavaLanguage.java"
+ set contents of text field "java" to call method "nameForJavaLanguage"
+ else if name of theObject is "direct java" then
+ -- Call the static "languageName" method of the "JavaLanguage" class which is defined in "JavaLanguage.java"
+ set contents of text field "direct java" to call method "languageName" of class "JavaLanguage"
+ end if
+ end tell
+end clicked
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+-- Application.applescript
+
+(* ==== Event Handlers ==== *)
+
+-- This event handler is called when the "Use All" button is clicked.
+--
+on clicked theObject
+ tell window of theObject
+ -- Execute the 'nameOfAllLanguages' Objective-C method in "Multi-Language.mm" and then append "AppleScript" to the result and put it in the text field
+ set contents of text field "use all" to ((call method "nameOfAllLanguages") & ", AppleScript")
+ end tell
+end clicked
+
+-- This event handler is called when the "Clear All" menu item in the edit menu is chosen. It will set the contents of all of the text fields to empty strings.
+--
+on choose menu item theObject
+ tell window "main"
+ set contents of text field "applescript" to ""
+ set contents of text field "objective-c" to ""
+ set contents of text field "c" to ""
+ set contents of text field "c++" to ""
+ set contents of text field "java" to ""
+ set contents of text field "direct java" to ""
+ set contents of text field "use all" to ""
+ end tell
+end choose menu item
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+-- Objective-C.applescript
+
+(* ==== Event Handlers ==== *)
+
+-- This event handler is called when the "Objective-C" button is clicked.
+--
+on clicked theObject
+ tell window of theObject
+ -- Call the Objective-C method "nameForObjCLanguage" defined in "Multi-Language.h"
+ -- It will in turn call a method of the ObjCLanugage class defined in "Objective-C.h"
+ set contents of text field "objective-c" to call method "nameForObjCLanguage"
+ end tell
+end clicked
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(*Open Panel.applescript *)
+
+(* This example demonstrates how to use the 'open-panel' class, either as a modal panel or as a panel attached to a window. The 'open panel' is a property of the application object. *)
+
+(* ==== Event Handlers ==== *)
+
+-- This event handler is called when the "Display Open Panel" button is clicked, which when clicked the various parameter values pulled from the text fields to be sent to "display".
+--
+on clicked theObject
+ -- Get the values from the UI
+ tell window of theObject
+ set theTitle to contents of text field "title"
+ set thePrompt to contents of text field "prompt"
+ set theFileTypes to contents of text field "file types"
+ set theDirectory to contents of text field "directory"
+ set theFileName to contents of text field "file name"
+ set treatPackages to contents of button "treat packages" as boolean
+ set canChooseDirectories to contents of button "choose directories" as boolean
+ set canChooseFiles to contents of button "choose files" as boolean
+ set allowsMultiple to contents of button "multiple selection" as boolean
+ set asSheet to contents of button "sheet" as boolean
+
+ -- Convert the comma separated list of file type to an actual list
+ set AppleScript's text item delimiters to ", "
+ set theFileTypes to text items of theFileTypes
+ set AppleScript's text item delimiters to ""
+ end tell
+
+ -- Setup the properties in the 'open panel'
+ tell open panel
+ set title to theTitle
+ set prompt to thePrompt
+ set treat packages as directories to treatPackages
+ set can choose directories to canChooseDirectories
+ set can choose files to canChooseFiles
+ set allows multiple selection to allowsMultiple
+ end tell
+
+ -- Determine which way to display the panel
+ if asSheet then
+ -- Display the panel as sheet (in which case the result will happen in 'on panel ended').
+ -- One thing to note is that the script will not stop processing until the panel is presented but continues on. You must use the 'on panel ended' event handler to get notified when the panel has finished.
+ -- The 'in directory' and 'with file name' parameters are optional.
+ if (count of theFileTypes) is 0 then
+ display open panel in directory theDirectory with file name theFileName attached to window of theObject
+ else
+ display open panel in directory theDirectory with file name theFileName for file types theFileTypes attached to window of theObject
+ end if
+ else
+ -- Display the panel.
+ -- Unlike the 'attached to' variant, the script does stop processing until the panel is finished.
+ -- The 'in directory' and 'with file name' parameters are optional
+ if (count of theFileTypes) is 0 then
+ set theResult to display open panel in directory theDirectory with file name theFileName for file types theFileTypes
+ else
+ set theResult to display open panel in directory theDirectory with file name theFileName
+ end if
+
+ if theResult is 1 then
+ -- Convert the list into a list of strings separated by return characters that we can put in the 'path names' text view
+ -- For some unknown (as of yet) you must coerce the 'path names' to a list (even though it is defined as list).
+ set the pathNames to (path names of open panel as list)
+ set AppleScript's text item delimiters to return
+ set the pathNames to pathNames as string
+ set AppleScript's text item delimiters to ""
+
+ set contents of text view "path names" of scroll view "path names" of window "main" to pathNames
+ else
+ set contents of text view "path names" of scroll view "path names" of window "main" to ""
+ end if
+ end if
+end clicked
+
+-- This event handler is called when the panel presented with the 'display attached to' command is finished.
+--
+on panel ended theObject with result withResult
+ if withResult is 1 then
+ -- Convert the list into a list of strings separated by return characters that we can put in the 'path names' text view
+ -- For some unknown (as of yet) you must coerce the 'path names' to a list (even though it is defined as list).
+ set the pathNames to (path names of open panel as list)
+ set AppleScript's text item delimiters to return
+ set the pathNames to pathNames as string
+ set AppleScript's text item delimiters to ""
+
+ set contents of text view "path names" of scroll view "path names" of window "main" to pathNames
+ else
+ set contents of text view "path names" of scroll view "path names" of window "main" to ""
+ end if
+end panel ended
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Application.applescript *)
+
+(* This example illustrates how to script an outline view. *)
+
+(* ==== Properties ==== *)
+
+property diskNames : {}
+
+
+(* ==== Event Handlers ==== *)
+
+on launched theObject
+ try
+ tell application "Finder"
+ set diskNames to name of every disk
+ end tell
+ end try
+ tell outline view "outline" of scroll view "scroll" of window "main" to update
+end launched
+
+on number of items theObject outline item theItem
+ set itemCount to 0
+ try
+ tell application "Finder"
+ if (count of diskNames) > 0 then
+ if theItem is 0 then
+ set itemCount to count of diskNames
+ else
+ set itemCount to count of items of (get item theItem)
+ end if
+ end if
+ end tell
+ end try
+ return itemCount
+end number of items
+
+on child of item theObject outline item theItem child theChild
+ set childItem to ""
+ try
+ tell application "Finder"
+ if theItem is 0 then
+ set childItem to disk (get item theChild of diskNames as string) as string
+ else
+ set childItem to item theChild of (get item theItem) as string
+ end if
+ end tell
+ end try
+ return childItem
+end child of item
+
+on item expandable theObject outline item theItem
+ set isExpandable to false
+ try
+ if theItem is 0 then
+ if (count of diskNames) is greater than 1 then
+ set isExpandable to true
+ end if
+ else
+ tell application "Finder"
+ if (count of items of (get item theItem)) is greater than 1 then
+ set isExpandable to true
+ end if
+ end tell
+ end if
+ end try
+ return isExpandable
+end item expandable
+
+on item value theObject outline item theItem table column theColumn
+ set itemValue to ""
+ try
+ if the identifier of theColumn is "name" then
+ tell application "Finder"
+ set itemValue to displayed name of (get item theItem) as string
+ end tell
+ else if the identifier of theColumn is "date" then
+ tell application "Finder"
+ set itemValue to modification date of (get item theItem) as string
+ end tell
+ else if the identifier of theColumn is "kind" then
+ tell application "Finder"
+ set itemValue to kind of (get item theItem) as string
+ end tell
+ end if
+ end try
+ return itemValue
+end item value
+
+on will open theObject
+ try
+ tell application "Finder"
+ set diskNames to name of every disk
+ end tell
+ end try
+ tell outline view "outline" of scroll view "scroll" of window "main" to update
+end will open
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Outline Reorder.applescript *)
+
+(* This example populates an outline view using the "content" property and then uses the "allows reordering" property of the table and outline views to enable the automatic support of drag and drop to roerder items.
+*)
+
+
+(* ===== Event Handlers ===== *)
+
+-- This event handler is attached to the table view and is a good place to setup our data source.
+--
+on awake from nib theObject
+ -- Setup the data source, data items and data cells simply by setting the "content" property of the table view.
+ set content of theObject to {{completed:false, task:"Things to do", |items|:{{completed:true, task:"Work on outline example", |items|:{{completed:true, task:"Make it plain and simple"}, {completed:true, task:"Put it all in an \"on launched'\" event handler"}}}, {completed:true, task:"Put it in my iDisk when done"}}}}
+end awake from nib
+
+-- This event handler is called when the user clicks on the check box.
+--
+on clicked theObject
+ set allows reordering of outline view "outline" of scroll view "scroll" of window of theObject to state of theObject
+end clicked
+
+
+(* © Copyright 2005 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Document.applescript *)
+
+(* This is a very simple example of how to write a document based plain text editor. It takes advantage of the lower level handlers for document handling, namely "read from file" and "write to file". It does this so that it can read text documents created by other applications. The two higher level handlers "data representation" and "load data representation" allow you to return and set any type of data, but then it will only be readable by your application, as it utilizes Cocoa's NSData object to store and retrieve your data. *)
+
+(* ==== Event Handlers ==== *)
+
+-- The "read from file" handler is called when the document needs to the data to be read from disk. "theObject" is the document object, "pathName" contains the POSIX style path of the file to read and "ofType" contains the type of document to read (which by default this value will be "DocumentType" as set up in the documents section of the target editor for document based Studio applications).
+--
+on read from file theObject path name pathName of type ofType
+ -- Open the file so that we can read it in
+ set theFile to open for access (pathName as POSIX file)
+
+ -- Read the data in
+ set theData to read theFile as string
+
+ -- Close the file
+ close access theFile
+
+ -- Put the data that we read into the text view of our document
+ set contents of text view "editor" of scroll view "editor" of window of theObject to theData
+
+ -- We need to return true (if everything went well) or false (if something failed). For the purposes of this example we'll signal that everything went well.
+ return true
+end read from file
+
+
+-- The "write to file" handler is called when the document needs to be saved to disk. "theObject" is the document object, "pathName" contains the POSIX style path of the file to write and "ofType" contains the type of document to read (which by default this value will be "DocumentType" as set up in the documents section of the target editor for document based Studio applications).
+--
+on write to file theObject path name pathName of type ofType
+ -- Get the data from the text view of the document
+ set theData to contents of text view "editor" of scroll view "editor" of window of theObject
+
+ -- Open the file for writing
+ set theFile to open for access (pathName as POSIX file) with write permission
+
+ -- Write the data
+ write theData to theFile as string
+
+ -- Close the file
+ close access theFile
+
+ -- We need to return true (if everything went well) or false (if something failed). For the purposes of this example we'll signal that everything went well.
+ return true
+end write to file
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(*Save Panel.applescript *)
+
+(* This example demonstrates how to use the 'save-panel' class, either as a modal panel or as a panel attached to a window. The 'save panel' is a property of the application object. *)
+
+(* ==== Event Handlers ==== *)
+
+-- This event handler is called when the "Display Save Panel" button is clicked, which when clicked the various parameter values pulled from the text fields to be sent to "display".
+--
+on clicked theObject
+ -- Get the values from the UI
+ tell window of theObject
+ set theTitle to contents of text field "title"
+ set thePrompt to contents of text field "prompt"
+ set theFileType to contents of text field "file type"
+ set theDirectory to contents of text field "directory"
+ set theFileName to contents of text field "file name"
+ set treatPackages to contents of button "treat packages" as boolean
+ set asSheet to contents of button "sheet" as boolean
+ end tell
+
+ -- Setup the properties in the 'save panel'
+ tell save panel
+ set title to theTitle
+ set prompt to thePrompt
+ set required file type to theFileType
+ set treat packages as directories to treatPackages
+ end tell
+
+ -- Determine which way to display the panel
+ if asSheet then
+ -- Display the panel as sheet (in which case the result will happen in 'on panel ended').
+ -- One thing to note is that the script will not stop processing until the panel is presented but continues on. You must use the 'on panel ended' event handler to get notified when the panel has finished.
+ -- The 'in directory' and 'with file name' parameters are optional.
+ display save panel in directory theDirectory with file name theFileName attached to window of theObject
+ else
+ -- Display the panel.
+ -- Unlike the 'attached to' variant, the script does stop processing until the panel is finished.
+ -- The 'in directory' and 'with file name' parameters are optional
+ set theResult to display save panel in directory theDirectory with file name theFileName
+ if theResult is 1 then
+ set contents of text field "path name" of window "main" to path name of save panel
+ else
+ set contents of text field "path name" of window "main" to ""
+ end if
+ end if
+end clicked
+
+-- This event handler is called when the panel presented with the 'display attached to' command is finished.
+--
+on panel ended theObject with result withResult
+ if withResult is 1 then
+ set contents of text field "path name" of window "main" to path name of save panel
+ else
+ set contents of text field "path name" of window "main" to ""
+ end if
+end panel ended
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Simple Outline.applescript *)
+
+(* This is a very simple example of how to populate an outline view using a data source. It will create a data source with data items representing the following outline:
+
+ - Things to do
+ - Work on outline example
+ - Make it plain and simple
+ - Put it all in a "on launched" event handler
+ - Put it in my iDisk when done
+
+ It has been enhanced to add drag and drop support and uses the new "content" property.
+*)
+
+
+(* ===== Event Handlers ===== *)
+
+-- This event handler is attached to the table view in our nib. It is a good place to set the contents of the table view and to setup any drag types that we might desire.
+--
+on awake from nib theObject
+ -- Create the data source, data items and data cells by simply setting the "content" property of the outline view
+ set content of theObject to {{completed:"--", task:"Things to do", |items|:{{completed:"Yes", task:"Work on outline example", |items|:{{completed:"Yes", task:"Make it plain and simple"}, {completed:"Yes", task:"Put it all in an \"on launched'\" event handler"}}}, {completed:"Yes", task:"Put it in my iDisk when done"}}}}
+
+ tell theObject to register drag types {"items", "file names"}
+end awake from nib
+
+-- The launched handler is generally the last event handler to be called in the launch sequence. It's a good place for us to show our window.
+--
+on launched theObject
+ show window "main"
+end launched
+
+-- This event handler is called whenever the user is done editing a cell in the outline view.
+--
+on change item value theObject table column tableColumn outline item outlineItem value theValue
+ return "maybe"
+end change item value
+
+-- This event handler is called that the beginning of a drag operation in our outline view
+--
+on prepare outline drag theObject drag items dragItems pasteboard thePasteboard
+ -- We are about to start a drag from within our outline view, so set the preferred type of the pasteboard to be "items" and then set the content of the pasteboard to be the items being dragged
+ set preferred type of thePasteboard to "items"
+ set content of thePasteboard to dragItems
+
+ -- Since it isn't convenient to get items on to the pasteboard, we just save the list of dragged items to be used later
+ set dragged items of theObject to dragItems
+
+ return true
+end prepare outline drag
+
+-- This event handler is called while the drag and drop operation is ongoing. We can decide whether or not we want to accept the drop, or where to allow the drop.
+--
+on prepare outline drop theObject data item dataItem drag info dragInfo child index childIndex
+ -- By default we will set the drag operation to not be a drag operation
+ set dragOperation to no drag operation
+
+ -- Get the list of data types on the pasteboard
+ set dataTypes to types of pasteboard of dragInfo
+
+ -- Set the type of drag operation based on the drop operation and the state of the option key
+ if "items" is in dataTypes then
+ if option key down of event 1 then
+ set dragOperation to copy drag operation
+ else
+ set dragOperation to move drag operation
+ end if
+ else if "file names" is in dataTypes then
+ set dragOperation to copy drag operation
+ end if
+
+ -- Return the desired drag operation
+ return dragOperation
+end prepare outline drop
+
+-- This event handler is called when the drop happens.
+--
+on accept outline drop theObject data item dataItem drag info dragInfo child index childIndex
+ -- Get the list of data types on the pasteboard
+ set dataTypes to types of pasteboard of dragInfo
+ set dataSource to data source of theObject
+
+ -- Turn off the updating of the views
+ set update views of dataSource to false
+
+ -- Set up the target data item (where we'll be placing the dropped items)
+ if dataItem is missing value or childIndex = 0 or childIndex > (count of data items of dataItem) then
+ set targetDataItem to missing value
+ else
+ set targetDataItem to data item childIndex of dataItem
+ end if
+
+ -- See if we are receiving our "items" in the drop
+ if "items" is in dataTypes then
+ -- We'll just use the list of dragged items we saved earlier, as it is easier than getting them from the pasteboard
+ set draggedItems to dragged items of theObject
+
+ -- Now move or duplicate the data items based on the option key
+ if option key down of event 1 then
+ repeat with i in draggedItems
+ if dataItem is not missing value then
+ if childIndex = 0 or childIndex > (count of data items of dataItem) then
+ duplicate i to end of data items of dataItem
+ else
+ duplicate i to before dataItem
+ end if
+ else
+ duplicate i to end of data items of dataSource
+ end if
+ end repeat
+ else
+ repeat with i in draggedItems
+ if dataItem is not missing value then
+ if childIndex = 0 or childIndex > (count of data items of dataItem) then
+ move i to end of data items of dataItem
+ else
+ move i to before dataItem
+ end if
+ else
+ move i to end of data items of dataSource
+ end if
+ end repeat
+ end if
+ else if "file names" is in dataTypes then
+ -- Initialize the list of files to an empty list
+ set theFiles to {}
+
+ -- We want the data as a list of file names, so set the preferred type to "file names"
+ set preferred type of pasteboard of dragInfo to "file names"
+
+ -- Get the list of files from the pasteboard
+ set theFiles to contents of pasteboard of dragInfo
+
+ -- Make sure we have at least one item
+ if (count of theFiles) > 0 then
+ repeat with theItem in theFiles
+ if targetDataItem is not missing value then
+ set dataItem to make new data item at before targetDataItem
+ else
+ set dataItem to make new data item at end of data items of dataSource
+ end if
+
+ set contents of data cell "task" of dataItem to theItem
+ end repeat
+ end if
+ end if
+
+ -- Turn back on the updating of the views
+ set update views of dataSource to true
+
+ -- Make sure to return true, otherwise the drop will be cancelled.
+ return true
+end accept outline drop
+
+
+(* © Copyright 2005 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Application.applescript *)
+
+(* ==== Event Handlers ==== *)
+
+on action theObject
+ set theResult to do shell script (contents of text field "input" of window "main" as string)
+ set the contents of text view "output" of scroll view "output" of window "main" to theResult
+ set needs display of text view "output" of scroll view "output" of window "main" to true
+end action
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Simple Table.applescript *)
+
+(* This is a very simple example of how to populate a table view using the "content" property. It also demonstrates how to add drag and drop support to allow both reordering and accepting external drops.
+*)
+
+
+(* ===== Event Handlers ===== *)
+
+-- This event handler is attached to the table view in our nib. It is a good place to set the contents of the table view and to setup any drag types that we might desire.
+--
+on awake from nib theObject
+ -- Create the data source, data rows and data cells by simply setting the "content" property of the table view
+ set content of theObject to {{"Work on outline example", "Yes"}, {"Make it plain and simple", "Yes"}, {"Put it all in an \"on launched\" event handler", "Yes"}, {"Put it in my iDisk when done", "Yes"}}
+
+ -- Register for the "rows" and "file names" drag types
+ tell theObject to register drag types {"rows", "file names"}
+end awake from nib
+
+-- The launched handler is generally the last event handler to be called in the launch sequence. It's a good place for us to show our window.
+--
+on launched theObject
+ show window "main"
+end launched
+
+-- This event handler is called whenever the user double clicks, edits and then leaves a cell in the table.
+--
+on change cell value theObject table column tableColumn row theRow value theValue
+ return theValue
+end change cell value
+
+-- This event handler is called that the beginning of a drag operation in our table view
+--
+on prepare table drag theObject drag rows dragRows pasteboard thePasteboard
+ -- We are about to start a drag from within our table view, so set the preferred type of the pasteboard to be "rows" and then set the content of the pasteboard to be the rows being dragged
+ set preferred type of thePasteboard to "rows"
+ set content of thePasteboard to dragRows
+
+ -- We need to return true here so that the drag will continue
+ return true
+end prepare table drag
+
+-- This event handler is called while the drag and drop operation is ongoing. We can decide whether or not we want to accept the drop, or where to allow the drop.
+--
+on prepare table drop theObject drag info dragInfo row theRow drop operation dropOperation
+ -- By default we will set the drag operation to not be a drag operation
+ set dragOperation to no drag operation
+
+ -- Get the list of data types on the pasteboard
+ set dataTypes to types of pasteboard of dragInfo
+
+ -- Set the type of drag operation based on the drop operation and the state of the option key
+ if "rows" is in dataTypes then
+ if dropOperation is 1 then
+ if option key down of event 1 then
+ set dragOperation to copy drag operation
+ else
+ set dragOperation to move drag operation
+ end if
+ end if
+ else if "file names" is in dataTypes then
+ if dropOperation is 1 then
+ set dragOperation to copy drag operation
+ end if
+ end if
+
+ -- Return the desired drag operation
+ return dragOperation
+end prepare table drop
+
+-- This event handler is called when the drop happens.
+--
+on accept table drop theObject drag info dragInfo row theRow drop operation dropOperation
+ -- Get the list of data types on the pasteboard
+ set dataTypes to types of pasteboard of dragInfo
+ set dataSource to data source of theObject
+
+ -- Turn off the updating of the views
+ set update views of dataSource to false
+
+ -- Set up the target data row (where we'll be placing the dropped items)
+ if theRow ² (count of data rows of dataSource) then
+ set targetDataRow to data row theRow of dataSource
+ else
+ set targetDataRow to missing value
+ end if
+
+ -- See if we are accepting our own "rows" (reorder)
+ if "rows" is in dataTypes then
+ -- Get the list of row numbers
+ set preferred type of pasteboard of dragInfo to "rows"
+ set rowNumbers to contents of pasteboard of dragInfo
+
+ -- We'll make a temporary list of the dragged data rows
+ set dataRows to {}
+ repeat with i in rowNumbers
+ copy data row i of dataSource to end of dataRows
+ end repeat
+
+ -- Now move or duplicate the data rows based on the option key
+ if option key down of event 1 then
+ repeat with i in dataRows
+ if targetDataRow is not missing value then
+ duplicate i to before targetDataRow
+ else
+ duplicate i to end of data rows of dataSource
+ end if
+ end repeat
+ else
+ repeat with i in dataRows
+ if targetDataRow is not missing value then
+ move i to before targetDataRow
+ else
+ move i to end of data rows of dataSource
+ end if
+ end repeat
+ end if
+ else if "file names" is in dataTypes then
+ -- Initialize the list of files to an empty list
+ set theFiles to {}
+
+ -- We want the data as a list of file names, so set the preferred type to "file names"
+ set preferred type of pasteboard of dragInfo to "file names"
+
+ -- Get the list of files from the pasteboard
+ set theFiles to contents of pasteboard of dragInfo
+
+ -- Make sure we have at least one item
+ if (count of theFiles) > 0 then
+ repeat with theItem in theFiles
+ if targetDataRow is not missing value then
+ set dataRow to make new data row at before targetDataRow
+ else
+ set dataRow to make new data row at end of data rows of dataSource
+ end if
+
+ set contents of data cell "task" of dataRow to theItem
+ end repeat
+
+ end if
+ end if
+
+ -- Turn back on the updating of the views
+ set update views of dataSource to true
+
+ -- Make sure to return true, otherwise the drop will be cancelled.
+ return true
+end accept table drop
+
+
+(* © Copyright 2005 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Document.applescript *)
+
+(* This is a simple example of how to add a toolbar to a window. It also demonstrates how to respond to the user clicking on a toolbar item and how to enable or disable toolbar items.
+*)
+
+
+(* ===== Event Handlers ===== *)
+
+-- These two event handlers are used to save and load the data for a document. For the purposes of this example, we will not be using them.
+--
+on data representation theObject of type ofType
+ (*Return the data that is to be stored in your document here.*)
+end data representation
+
+on load data representation theObject of type ofType with data withData
+ (* The withData contains the data that was stored in your document that you provided in the "data representation" event handler. Return "true" if this was successful, or false if not.*)
+ return true
+end load data representation
+
+
+-- This event handler is attached to the table view in our nib. It is a good place to set the contents of the table view and to setup any drag types that we might desire.
+--
+on awake from nib theObject
+ -- Make the new toolbar, giving it a unique identifier
+ set documentToolbar to make new toolbar at end with properties {name:"document toolbar", identifier:"document toolbar identifier", allows customization:true, auto sizes cells:true, display mode:default display mode, size mode:default size mode}
+
+ -- Setup the allowed and default identifiers.
+ set allowed identifiers of documentToolbar to {"compile item identifier", "run item identifier", "stop item identifier", "print item identifier", "customize toolbar item identifer", "flexible space item identifer", "space item identifier", "separator item identifier"}
+ set default identifiers of documentToolbar to {"compile item identifier", "run item identifier", "stop item identifier"}
+
+ --set selectable identifiers of documentToolbar to {}
+
+ -- Create the toolbar items, adding them to the toolbar.
+ make new toolbar item at end of toolbar items of documentToolbar with properties {identifier:"compile item identifier", name:"compile item", label:"Compile", palette label:"Compile", tool tip:"Compile", image name:"CompileScript"}
+ make new toolbar item at end of toolbar items of documentToolbar with properties {identifier:"run item identifier", name:"run item", label:"Run", palette label:"Run", tool tip:"Run", image name:"RunScript"}
+ make new toolbar item at end of toolbar items of documentToolbar with properties {identifier:"stop item identifier", name:"stop item", label:"Stop", palette label:"Stop", tool tip:"Stop", image name:"StopScript"}
+
+ -- Assign our toolbar to the window
+ set toolbar of theObject to documentToolbar
+end awake from nib
+
+-- This event handler is called when the user clicks on one of the toolbar items
+--
+on clicked toolbar item theObject
+ if identifier of theObject is "compile item identifier" then
+ display dialog "It's time to compile" attached to the front window
+ end if
+end clicked toolbar item
+
+-- This event handler is called whenever the state of the toolbar items needs to be changed.
+--
+on update toolbar item theObject
+ -- We return true in order to enable the toolbar item, otherwise we would return false
+ return true
+end update toolbar item
+
+
+(* © Copyright 2005 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Simple Toolbar.applescript *)
+
+(* This is a simple example of how to add a toolbar to a window. It also demonstrates how to respond to the user clicking on a toolbar item and how to enable or disable toolbar items.
+*)
+
+
+(* © Copyright 2005 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Application.applescript *)
+
+(* ==== Properties ==== *)
+
+global soapresult, readFile
+property SOAPEndpointURLParm : ""
+property SOAPActionPram : ""
+property MethodNamespaceURLPram : ""
+property MethodNamesPram : ""
+property ParametersPram : {}
+property ParametersPramRec : {}
+
+
+(* ==== Event Handlers ==== *)
+
+on clicked theObject
+ set ButtonTitle to title of theObject
+ if ButtonTitle = "Run" then
+ set enabled of button "stop" of window "SOAPtalk" to true
+ tell progress indicator "barberpole" of window "SOAPtalk" to start
+ set the contents of text view "results" of scroll view 1 of window "SOAPtalk" to ""
+ updateProperties()
+ soapCallHandler()
+ else if ButtonTitle = "Reset" then
+ display dialog "Reset field?" buttons {"Cancel", "All", "Results"} default button "Results" --with icon stop --attached to window "SOAPtalk"
+ set eraseresultswindbutton to text of button returned of result
+ if eraseresultswindbutton = "Results" then
+ set the contents of text view "results" of scroll view 1 of window "SOAPtalk" to ""
+ else if eraseresultswindbutton = "All" then
+ restFields()
+ end if
+ else if ButtonTitle = "" then
+ open location "http://www.xmethods.com"
+ else if ButtonTitle = "stop" then
+ tell progress indicator "barberpole" of window "SOAPtalk" to stop
+ set enabled of button "stop" of window "SOAPtalk" to false
+ end if
+end clicked
+
+on changed theObject
+ (*Add your script here.*)
+end changed
+
+on choose menu item theObject --menu item theItem
+ set menuItemTitle to title of theObject as string
+ if menuItemTitle = "Open..." then
+ set SOAPReadFile to choose file with prompt "Please select a previously saved SOAPTalk file"
+ set xRef to open for access SOAPReadFile
+ set readFile to read xRef as list
+ close access xRef
+ updateFieldsFromFile()
+ end if
+ if menuItemTitle = "Save" then
+ try
+ updateProperties()
+ set resultsfield to contents of text view "results" of scroll view 1 of window "SOAPtalk"
+ set writeRecord to {SOAPEndpointURL:SOAPEndpointURLParm, SOAPAction:SOAPActionPram, MethodNamespaceURL:MethodNamespaceURLPram, MethodNames:MethodNamesPram, parameters:ParametersPram, soapresult:resultsfield}
+ set saveFile to choose file name with prompt "Save File to" default name "SOAPTalk"
+
+ set fileRef to open for access saveFile with write permission
+ write writeRecord to fileRef as list
+ close access fileRef
+ on error errMsg
+ try
+ get fileRef
+ close access fileRef
+ display dialog errMsg
+ end try
+ end try
+ end if
+end choose menu item
+
+
+(* ==== Handlers ==== *)
+
+on updateProperties()
+ tell window "SOAPTalk"
+ set SOAPEndpointURLParm to contents of text field "SOAPEndpointURL" --as application
+ set SOAPActionPram to contents of text field "SOAPAction"
+ set MethodNamespaceURLPram to contents of text field "MethodNamespaceURL"
+ set MethodNamesPram to contents of text field "MethodNames"
+ set ParametersPram to contents of text field "Parameters"
+ set ParametersPramRec to run script ParametersPram -- convert string record into list record
+ set soapresult to ""
+ end tell
+end updateProperties
+
+on updateFieldsFromFile()
+ tell window "SOAPTalk"
+ set contents of text field "SOAPEndpointURL" to SOAPEndpointURL of item 1 of readFile
+ set contents of text field "SOAPAction" to SOAPAction of item 1 of readFile
+ set contents of text field "MethodNamespaceURL" to MethodNamespaceURL of item 1 of readFile
+ set contents of text field "MethodNames" to MethodNames of item 1 of readFile
+ set contents of text field "Parameters" to parameters of item 1 of readFile
+ end tell
+end updateFieldsFromFile
+
+on restFields()
+ tell window "SOAPTalk"
+ set contents of text field "SOAPEndpointURL" to ""
+ set contents of text field "SOAPAction" to ""
+ set contents of text field "MethodNamespaceURL" to ""
+ set contents of text field "MethodNames" to ""
+ set contents of text field "Parameters" to ""
+ set the contents of text view "results" of scroll view 1 to ""
+ end tell
+end restFields
+
+on soapCallHandler()
+ try
+ using terms from application "http://www.apple.com"
+ tell application (SOAPEndpointURLParm as string)
+ set soapresult to call soap {method name:my getPlainText(MethodNamesPram), method namespace uri:my getPlainText(MethodNamespaceURLPram), parameters:ParametersPramRec, SOAPAction:my getPlainText(SOAPActionPram)}
+ end tell
+ end using terms from
+
+ on error errMsg number errNum
+ set the contents of text view "results" of scroll view 1 of window "SOAPtalk" to errMsg & " " & errNum & return & "Are you connected to the Internet?"
+ tell progress indicator "barberpole" of window "SOAPtalk" to stop
+ set enabled of button "stop" of window "SOAPtalk" to false
+ end try
+
+ set the contents of text view "results" of scroll view 1 of window "SOAPtalk" to soapresult as string
+ tell progress indicator "barberpole" of window "SOAPtalk" to stop
+ set enabled of button "stop" of window "SOAPtalk" to false
+end soapCallHandler
+
+on getPlainText(fromUnicodeString)
+ set styledText to fromUnicodeString as string
+ set styledRecord to styledText as record
+ return Çclass ktxtÈ of styledRecord
+end getPlainText
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(*Application.applescript *)
+
+(* This script is used to exercise two (currently) workarounds. The first is to work around the bug in "load image" in that it won't open files outside of the project. The second is to enable "user defaults", which is Cocoa's method of reading/writing preferences for an application. *)
+
+(* ==== Event Handlers ==== *)
+
+-- This event handler is called when the "Open.." menu item is chosen.
+--
+on choose menu item theObject
+ -- Choose the image to be used in the image view
+ set thePath to choose file with prompt "Select an Image"
+
+ -- Call the workaround, making sure that path we pass is a posix path
+ set theImage to call method "loadImage:" with parameter (POSIX path of thePath)
+
+ -- Set the image of the image view to the one we loaded
+ set image of image view "image" of window "main" to theImage
+end choose menu item
+
+-- This event handler is called when the application is about done launching. We initialize the preferences and
+on will finish launching theObject
+ -- Initialize the user defaults (only happens if the prefs don't exist)
+ call method "registerDefaultObjects:forKeys:" with parameters {{"Text", 1, 0, 1, 1, {false, true}}, {"text", "number", "popup", "slider", "radio", "switches"}}
+end will finish launching
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(*Event Support.applescript *)
+
+(* This script is used to demonstrate how to access some of the properties of the 'event' class that is missing (not implemented) from AppleScript Studio 1.0. The properties that aren't working that are demonstrate here are: characters, command key down, control key down, option key down and shift key down. *)
+
+on keyboard up theObject event theEvent
+ tell window of theObject
+ -- characters
+ set contents of text field "characters" to (call method "characters" of object theEvent) as string
+
+ -- unmodified characters
+ set contents of text field "unmodified characters" to (call method "charactersIgnoringModifiers" of object theEvent) as string
+
+ -- command key down
+ set state of button "command" to call method "isCommandKeyDownForEvent:" with parameter theEvent
+
+ -- control key down
+ set state of button "control" to call method "isControlKeyDownForEvent:" with parameter theEvent
+
+ -- option key down
+ set state of button "option" to call method "isOptionKeyDownForEvent:" with parameter theEvent
+
+ -- shift key down
+ set state of button "shift" to call method "isShiftKeyDownForEvent:" with parameter theEvent
+ end tell
+end keyboard up
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(*Localized String.applescript *)
+
+(* This script is used to demonstrate a way to load a localized string from a '.strings' file. The Objective-C method that has been adde to this project is "localizedStringForKey:fromTable:" which takes two parameters. The first is the key in the .strings file (this is the string on the left hand side of the strings entry. The second is the name of the table (which is simply the name of the .strings file). Look in the "Localized.strings" file to see an example of the format for .strings file. *)
+
+(* ==== Event Handlers ==== *)
+
+on clicked theObject
+ tell window of theObject
+ if name of theObject is "open" then
+ set contents of text field "output" to (call method "localizedStringForKey:fromTable:" with parameters {"OPEN_KEY", "Localized"})
+ else if name of theObject is "close" then
+ set contents of text field "output" to (call method "localizedStringForKey:fromTable:" with parameters {"CLOSE_KEY", "Localized"})
+ end if
+ end tell
+end clicked
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+
+(* Preferences.applescript *)
+
+(* This script shows an example of using the workaround for reading and writing user defaults. You can use a number, string, or array for objects to be stored in the defaults. *)
+
+(* ==== Properties ==== *)
+
+property preferencesWindow : null
+
+
+(* ==== Event Handlers ==== *)
+
+-- This event handler is called when the "preferences" menu item is chosen.
+--
+on choose menu item theObject
+ -- Only load the preferences nib once
+ if preferencesWindow is equal to null then
+ load nib "Preferences"
+ set preferencesWindow to window "preferences"
+ end if
+
+ -- Load in the preferences
+ loadPreferences(preferencesWindow)
+
+ -- Show the preferences window
+ set visible of preferencesWindow to true
+end choose menu item
+
+
+-- This event handler is called when either the "cancel" or "done" buttons are clicked.
+--
+on clicked theObject
+ if name of theObject is "done" then
+ -- Save out the preferences
+ storePreferences(preferencesWindow)
+ end if
+
+ -- Hide the preferences window
+ set visible of preferencesWindow to false
+end clicked
+
+
+(* ==== Handlers ==== *)
+
+-- This handler will read the preferences from the "Support.plist" in the ~/Library/Preferences directory and then sets those values in the UI elements.
+--
+on loadPreferences(theWindow)
+ -- Read in the preferences
+ set theText to call method "defaultObjectForKey:" with parameter "text"
+ set theNumber to call method "defaultObjectForKey:" with parameter "number"
+ set thePopup to call method "defaultObjectForKey:" with parameter "popup"
+ set theSlider to call method "defaultObjectForKey:" with parameter "slider"
+ set theRadio to call method "defaultObjectForKey:" with parameter "radio"
+ set theSwitches to call method "defaultObjectForKey:" with parameter "switches"
+
+ -- Set the contents of the UI elements
+ tell theWindow
+ set contents of text field "text" to theText
+ set contents of text field "number" to theNumber
+ set contents of popup button "popup" to thePopup
+ set contents of slider "slider" to theSlider
+ set current row of matrix "radio" to theRadio
+ set contents of button "show" to item 1 of theSwitches
+ set contents of button "hide" to item 2 of theSwitches
+ end tell
+end loadPreferences
+
+-- This handler will get the values from the UI elements and store those values in the preferences file.
+--
+on storePreferences(theWindow)
+ -- Get the contents of the UI elements
+ tell theWindow
+ set theText to contents of text field "text"
+ set theNumber to contents of text field "number"
+ set thePopup to contents of popup button "popup"
+ set theSlider to contents of slider "slider"
+ set theRadio to current row of matrix "radio"
+ set theSwitches to {contents of button "show", contents of button "hide"}
+ end tell
+
+ -- Write out the preferences
+ call method "setDefaultObject:forKey:" with parameters {theText, "text"}
+ call method "setDefaultObject:forKey:" with parameters {theNumber, "number"}
+ call method "setDefaultObject:forKey:" with parameters {thePopup, "popup"}
+ call method "setDefaultObject:forKey:" with parameters {theSlider, "slider"}
+ call method "setDefaultObject:forKey:" with parameters {theRadio, "radio"}
+ call method "setDefaultObject:forKey:" with parameters {theSwitches, "switches"}
+end storePreferences
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* WithDataSource.applescript *)
+
+(* This script is used to demonstrate the scripting of a table view using a data source that is connected to the table view in Interface Builder. Basically the data source has columns added in the "will open" event handler, the "data rows" are added/updated/removed as need from the data source. *)
+
+(* ==== Properties ==== *)
+
+property contactsDataSource : null
+
+
+(* ==== Event Handlers ==== *)
+
+on clicked theObject
+ if name of theObject is equal to "add" then
+ -- Add a new contact
+ set theRow to make new data row at the end of the data rows of contactsDataSource
+ getContactInfo(window of theObject, theRow)
+
+ -- Clear out the contact information
+ clearContactInfo(window of theObject)
+ else if name of theObject is "update" then
+ set tableView to table view "contacts" of scroll view "contacts" of window of theObject
+ set selectedDataRows to selected data rows of tableView
+ if (count of selectedDataRows) > 0 then
+ -- Update the contact
+ getContactInfo(window of theObject, item 1 of selectedDataRows)
+
+ -- Tell the table view to update it's values
+ tell tableView to update
+ end if
+ else if name of theObject is "remove" then
+ set tableView to table view "contacts" of scroll view "contacts" of window of theObject
+ set selectedDataRows to selected data rows of tableView
+ if (count of selectedDataRows) > 0 then
+ tell window of theObject
+ -- Remove the contact form the data source
+ delete (item 1 of selectedDataRows)
+
+ -- Clear out the contact information
+ my clearContactInfo(window of theObject)
+ end tell
+ end if
+ end if
+end clicked
+
+on will open theObject
+ -- Set up the contactDataSource so that the rest will be simpler
+ set contactsDataSource to data source of table view "contacts" of scroll view "contacts" of theObject
+
+ -- Here we will add the data columns to the data source of the contacts table view
+ tell contactsDataSource
+ make new data column at the end of the data columns with properties {name:"name"}
+ make new data column at the end of the data columns with properties {name:"address"}
+ make new data column at the end of the data columns with properties {name:"city"}
+ make new data column at the end of the data columns with properties {name:"state"}
+ make new data column at the end of the data columns with properties {name:"zip"}
+ end tell
+end will open
+
+on selection changed theObject
+ if name of theObject is "contacts" then
+ set theWindow to window of theObject
+
+ -- Set the contact index to the current row, so that we can use it to update the right contact later
+ set selectedDataRows to selected data rows of theObject
+
+ if (count of selectedDataRows) = 0 then
+ -- There wasn't any selected so clear the contact information
+ my clearContactInfo(theWindow)
+
+ -- Disable the "Update" and "Remove" buttons
+ set enabled of button "update" of theWindow to false
+ set enabled of button "remove" of theWindow to false
+ else
+ -- A contact was selected, so show the contact information
+ my setContactInfo(theWindow, item 1 of selectedDataRows)
+
+ -- Enable the "Update" and "Remove" buttons
+ set enabled of button "update" of theWindow to true
+ set enabled of button "remove" of theWindow to true
+ end if
+ end if
+end selection changed
+
+
+(* ==== Contact Handlers ==== *)
+
+-- Empty all of the text fields
+--
+on clearContactInfo(theWindow)
+ tell theWindow
+ set contents of text field "name" to ""
+ set contents of text field "address" to ""
+ set contents of text field "city" to ""
+ set contents of text field "state" to ""
+ set contents of text field "zip" to ""
+ set first responder to text field "name"
+ end tell
+end clearContactInfo
+
+-- Get the values from the text fields and set the cells in the the data row
+--
+on getContactInfo(theWindow, theRow)
+ tell theWindow
+ set contents of data cell "name" of theRow to contents of text field "name"
+ set contents of data cell "address" of theRow to contents of text field "address"
+ set contents of data cell "city" of theRow to contents of text field "city"
+ set contents of data cell "state" of theRow to contents of text field "state"
+ set contents of data cell "zip" of theRow to contents of text field "zip"
+ end tell
+end getContactInfo
+
+-- Set the text fields with the values from the contact
+--
+on setContactInfo(theWindow, theRow)
+ tell theWindow
+ set contents of text field "name" to contents of data cell "name" of theRow
+ set contents of text field "address" to contents of data cell "address" of theRow
+ set contents of text field "city" to contents of data cell "city" of theRow
+ set contents of text field "state" to contents of data cell "state" of theRow
+ set contents of text field "zip" to contents of data cell "zip" of theRow
+ end tell
+end setContactInfo
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* WithoutDataSource.applescript *)
+
+(* This script is used to demonstrate the scripting of a table view without using a data source. The important part of supplying the table with information is in the "cell value" and "number of rows" event handlers. The table will query the script asking it for the number of rows, and then for every row of every column the "number of rows" event handler will be called, returning the contents of the cell for the table to display. *)
+
+(* ==== Properties ==== *)
+
+property contacts : {}
+property contactIndex : 0
+
+
+(* ==== Event Handlers ==== *)
+
+on clicked theObject
+ if name of theObject is "add" then
+ -- Add a new contact
+ tell window of theObject
+ -- Create a contact record from the values in the text fields and add it to the list of contacts
+ set contacts to contacts & {my getContactInfo(window of theObject)}
+
+ -- Tell the table view to update it's values
+ tell table view "contacts" of scroll view "contacts" to update
+
+ -- Clear out the contact information
+ my clearContactInfo(window of theObject)
+ end tell
+
+ else if name of theObject is "update" then
+ -- Update the contact
+ tell window of theObject
+ -- Update the contact information
+ set item contactIndex of contacts to my getContactInfo(window of theObject)
+
+ -- Tell the table view to update it's values
+ tell table view "contacts" of scroll view "contacts" to update
+ end tell
+ else if name of theObject is "remove" then
+ -- Remove the contact
+ if contactIndex > 0 and contactIndex ² (count of contacts) then
+ tell window of theObject
+ -- Remove the contact form the list
+ set contacts to my deleteItemInList(contactIndex, contacts)
+
+ -- Tell the table view to update it's values
+ tell table view "contacts" of scroll view "contacts" to update
+
+ -- Clear out the contact information
+ my clearContactInfo(window of theObject)
+ end tell
+ end if
+ end if
+end clicked
+
+-- Return the value of the specified column for the given row
+--
+on cell value theObject row theRow table column theColumn
+ -- Set the value to an empty string for now
+ set theValue to ""
+
+ -- Make sure that we aren't being asked for a row that is greater than the number of contacts
+ if (count of contacts) ³ theRow then
+ set theContact to item theRow of contacts
+
+ -- Get the identifier of the column so that we can determine which field of the record to return
+ set theID to identifier of theColumn
+ if the theID is "name" then
+ set theValue to name of theContact
+ else if theID is "address" then
+ set theValue to address of theContact
+ else if theID is "city" then
+ set theValue to city of theContact
+ else if theID is "state" then
+ set theValue to state of theContact
+ else if theID is "zip" then
+ set theValue to zip of theContact
+ end if
+ end if
+
+ -- Now return the value that we set
+ return theValue
+end cell value
+
+-- Return the number of contacts
+--
+on number of rows theObject
+ return count of contacts
+end number of rows
+
+on selection changed theObject
+ if name of theObject is "contacts" then
+ set theWindow to window of theObject
+
+ -- Set the contact index to the current row, so that we can use it to update the right contact later
+ set contactIndex to selected row of theObject
+
+ if contactIndex = 0 then
+ -- There wasn't any selected so clear the contact information
+ my clearContactInfo(theWindow)
+
+ -- Disable the "Update" and "Remove" buttons
+ set enabled of button "update" of theWindow to false
+ set enabled of button "remove" of theWindow to false
+ else
+ -- A contact was selected, so show the contact information
+ my setContactInfo(theWindow, item contactIndex of contacts)
+
+ -- Enable the "Update" and "Remove" buttons
+ set enabled of button "update" of theWindow to true
+ set enabled of button "remove" of theWindow to true
+ end if
+ end if
+end selection changed
+
+
+(* ==== Contact Handlers ==== *)
+
+-- Empty all of the text fields
+--
+on clearContactInfo(theWindow)
+ tell theWindow
+ set contents of text field "name" to ""
+ set contents of text field "address" to ""
+ set contents of text field "city" to ""
+ set contents of text field "state" to ""
+ set contents of text field "zip" to ""
+ set first responder to text field "name"
+ end tell
+end clearContactInfo
+
+-- Get the values from the text fields and return a contact record
+--
+on getContactInfo(theWindow)
+ tell theWindow
+ return {name:contents of text field "name", address:contents of text field "address", city:contents of text field "city", state:contents of text field "state", zip:contents of text field "zip"}
+ end tell
+end getContactInfo
+
+-- Set the text fields with the values from the contact
+--
+on setContactInfo(theWindow, theContact)
+ tell theWindow
+ set contents of text field "name" to name of theContact
+ set contents of text field "address" to address of theContact
+ set contents of text field "city" to city of theContact
+ set contents of text field "state" to state of theContact
+ set contents of text field "zip" to zip of theContact
+ end tell
+end setContactInfo
+
+(* ==== Utilities ==== *)
+
+on deleteItemInList(x, theList)
+ set x to (x as number)
+ if x < 1 then return theList
+ set numItems to count of items in theList
+ if numItems is 1 then return {}
+ if x > numItems then return theList
+ if x = 1 then
+ set newList to (items 2 thru -1 of theList)
+ else if x = numItems then
+ set newList to (items 1 thru -2 of theList)
+ else
+ set newList to (items 1 thru (x - 1) of theList) & (items (x + 1) thru -1 of theList)
+ end if
+ return newList
+end deleteItemInList
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Table Reorder.applescript *)
+
+(* This example populates a table view using the "content" property and then uses the "allows reordering" property of the table and outline views to enable the automatic support of drag and drop to reorder data rows.
+*)
+
+
+(* ===== Event Handlers ===== *)
+
+-- This event handler is attached to the table view and is a good place to setup our data source.
+--
+on awake from nib theObject
+ -- Setup the data source, data rows and data cells simply by setting the "content" property of the table view.
+ set content of theObject to {{|property|:"Zoomed", include:true}, {|property|:"Miniaturized", include:true}, {|property|:"Floating", include:false}, {|property|:"Modal", include:false}, {|property|:"Visible", include:true}, {|property|:"Closeable", include:true}, {|property|:"Resizable", include:true}, {|property|:"Zoomable", include:true}, {|property|:"Titled", include:true}}
+end awake from nib
+
+-- This event handler is called when the user clicks on the check box.
+--
+on clicked theObject
+ set allows reordering of table view "table" of scroll view "scroll" of window of theObject to state of theObject
+end clicked
+
+
+(* © Copyright 2005 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Table Sort.applescript *)
+
+(* This example demonstrates how easy it is to add sorting to your tables. In the example, you can click on different columns to sort on that column. Clicking more than once in the same column changes the sort order of that column. *)
+
+(* ==== Properties ==== *)
+
+property tableData : {{|name|:"Bart Simpson", city:"Springfield", zip:"19542", age:12}, {|name|:"Ally McBiel", city:"Chicago", zip:"91544", age:28}, {|name|:"Joan of Ark", city:"Paris", zip:"53255", age:36}, {|name|:"King Tut", city:"Egypt", zip:"00245", age:45}, {|name|:"James Taylor", city:"Atlanta", zip:"21769", age:42}}
+
+
+(* ==== Event Handlers ==== *)
+
+-- The "awake from nib" event handler is attached to the table view. It will be called when the table view is loaded from the nib. It's a good place to create our data source and set up the data columns.
+--
+on awake from nib theObject
+ -- Create the data source
+ set theDataSource to make new data source at end of data sources with properties {name:"names"}
+
+ -- Create each of the data columns, including the sort information for each column
+ make new data column at end of data columns of theDataSource with properties {name:"name", sort order:ascending, sort type:alphabetical, sort case sensitivity:case sensitive}
+ make new data column at end of data columns of theDataSource with properties {name:"city", sort order:ascending, sort type:alphabetical, sort case sensitivity:case sensitive}
+ make new data column at end of data columns of theDataSource with properties {name:"zip", sort order:ascending, sort type:alphabetical, sort case sensitivity:case sensitive}
+ make new data column at end of data columns of theDataSource with properties {name:"age", sort order:ascending, sort type:numerical, sort case sensitivity:case sensitive}
+
+ -- Make this a sorted data source
+ set sorted of theDataSource to true
+
+ -- Set the "name" data column as the sort column
+ set sort column of theDataSource to data column "name" of theDataSource
+
+ -- Set the data source of the table view to the new data source
+ set data source of theObject to theDataSource
+
+ -- Add the table data (using the new "append" command)
+ append theDataSource with tableData
+end awake from nib
+
+
+-- The "launched" event handler is attached to the application object ("File's Owner of MainMenu.nib"). It is called towards the end of the startup sequence.
+--
+on launched theObject
+ -- Show the main window
+ show window "main"
+end launched
+
+
+-- The "column clicked" event handler is called when the user clicks on a table column in the table view. We will use this handler to change the sort column of the data source as well as the sort order.
+--
+on column clicked theObject table column tableColumn
+ -- Get the data source of the table view
+ set theDataSource to data source of theObject
+
+ -- Get the identifier of the clicked table column
+ set theColumnIdentifier to identifier of tableColumn
+
+ -- Get the current sort column of the data source
+ set theSortColumn to sort column of theDataSource
+
+ -- If the current sort column is not the same as the clicked column then switch the sort column
+ if (name of theSortColumn) is not equal to theColumnIdentifier then
+ set the sort column of theDataSource to data column theColumnIdentifier of theDataSource
+ else
+ -- Otherwise change the sort order
+ if sort order of theSortColumn is ascending then
+ set sort order of theSortColumn to descending
+ else
+ set sort order of theSortColumn to ascending
+ end if
+ end if
+
+ -- We need to update the table view (so it will be redrawn)
+ update theObject
+end column clicked
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Application.applescript *)
+
+(* ==== Event Handlers ==== *)
+
+on will open theObject
+ set movie of movie view "movie" of window "main" to load movie "jumps"
+end will open
+
+on choose menu item theMenuItem
+ tell window "main"
+ set theCommand to tag of theMenuItem
+
+ if theCommand is equal to 1001 then
+ set moviePath to choose file
+ set movie file of movie view "movie" to moviePath
+ else if theCommand is equal to 1002 then
+ tell movie view "movie" to play
+ else if theCommand is equal to 1003 then
+ tell movie view "movie" to stop
+ else if theCommand is equal to 1004 then
+ tell movie view "movie" to step forward
+ else if theCommand is equal to 1005 then
+ tell movie view "movie" to step back
+ else if theCommand is equal to 1006 then
+ tell movie view "movie" to go to beginning frame
+ else if theCommand is equal to 1007 then
+ tell movie view "movie" to go to end frame
+ else if theCommand is equal to 1008 then
+ tell movie view "movie" to go to poster frame
+ else if theCommand is equal to 1009 then
+ set loop mode of movie view "movie" to normal playback
+ else if theCommand is equal to 1010 then
+ set loop mode of movie view "movie" to looping playback
+ else if theCommand is equal to 1011 then
+ set loop mode of movie view "movie" to looping back and forth playback
+ end if
+ end tell
+end choose menu item
+
+on update menu item theMenuItem
+ tell window "main"
+ local enableItem
+ set enableItem to 1
+
+ set theCommand to tag of theMenuItem
+ set thePlayBack to loop mode of movie view "movie"
+
+ if theCommand is equal to 1002 then
+ if playing of movie view "movie" is true then set enableItem to 0
+ else if theCommand is equal to 1003 then
+ if playing of movie view "movie" is false then set enableItem to 0
+ else if theCommand ³ 1009 and theCommand ² 1011 then
+ set theState to 0
+
+ if thePlayBack is equal to normal playback and theCommand is equal to 1009 then set theState to 1
+ if thePlayBack is equal to looping playback and theCommand is equal to 1010 then set theState to 1
+ if thePlayBack is equal to looping back and forth playback and theCommand is equal to 1011 then set theState to 1
+
+ set state of theMenuItem to theState
+ end if
+ end tell
+
+ return enableItem
+end update menu item
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Document.applescript *)
+
+(* This is a good example of several different features of AppleScript Studio. The main one is to demonstrate how to write a document bases application using the higher level handlers "data representation" and "load data representation" (as opposed to the lower level handlers "write to file" and "read from file". It also demonstrates how to work with a table view (including support for sorting). Menu Item handling is also included in this example. *)
+
+(* ==== Event Handlers ==== *)
+
+-- The "awake from nib" handler is called (in this example) when the table view is loaded from the "Documents.nib" nib file. This is a good place to create a new data source and data columns and set various properties of said items.
+--
+on awake from nib theObject
+ if name of theObject is "tasks" then
+ -- Create the data source for our "tasks" table view
+ set theDataSource to make new data source at end of data sources with properties {name:"tasks"}
+
+ -- Create the data columns, "priority", "task" and "status". We also set the sort properties of each of the data columns, including the sort order, the type of data in each column and what type of sensitivity to use.
+ make new data column at end of data columns of theDataSource with properties {name:"priority", sort order:ascending, sort type:numerical, sort case sensitivity:case sensitive}
+ make new data column at end of data columns of theDataSource with properties {name:"task", sort order:ascending, sort type:alphabetical, sort case sensitivity:case sensitive}
+ make new data column at end of data columns of theDataSource with properties {name:"status", sort order:ascending, sort type:alphabetical, sort case sensitivity:case sensitive}
+
+ -- Set the data source as sorted
+ set sorted of theDataSource to true
+
+ -- Set the "priority" data column as the sort column
+ set sort column of theDataSource to data column "priority" of theDataSource
+
+ -- Finally, assign the data source of the table view to our data source
+ set data source of theObject to theDataSource
+ end if
+end awake from nib
+
+
+-- The "action" event handler is called whenever the user chooses a menu in the popup buttons or presses (in this example) the enter key in the text field.
+--
+on action theObject
+ -- Set some local variables to various objects in the UI
+ set theWindow to window of theObject
+ set theTableView to table view "tasks" of scroll view "tasks" of theWindow
+ set theDataSource to data source of theTableView
+
+ -- The behavior from here will be determined by whether or not an task in the table view is selected
+ if (count of selected rows of theTableView) is 0 then
+ -- Since nothing is selected we will create a new task (but only if the enter key is pressed in the "task" text field)
+ if name of theObject is "task" then
+ -- Make a new data row
+ set theTask to make new data row at end of data rows of theDataSource
+
+ -- Populate the task using values in the UI
+ setTaskValuesWithUIValues(theTask, theWindow)
+
+ -- Now set the UI to default values
+ setDefaultUIValues(theWindow)
+
+ -- Make the "task" text field the object with the focus so that it will be ready for typing
+ set first responder of theWindow to text field "task" of theWindow
+ end if
+ else
+ -- Get the selected task from the table view
+ set theTask to selected data row of theTableView
+
+ -- See which object was touched
+ if name of theObject is "priority" then
+ set contents of data cell "priority" of theTask to title of theObject
+ else if name of theObject is "task" then
+ set contents of data cell "task" of theTask to content of theObject
+ else if name of theObject is "status" then
+ set contents of data cell "status" of theTask to title of theObject
+ end if
+ end if
+end action
+
+
+(* ==== Document Event Handlers ==== *)
+
+-- The "data representation" event handler is called when the document needs to be saved. It is the responsiblity of the handler to return the data that is to be saved. This can be nearly any AppleScript object, whether it be a string, a list, a record, etc. In this case we are going to return a record that contains the list of tasks, the name of the current sort column and the sort order of the current sort column.
+--
+on data representation theObject of type ofType
+ -- Set some local variables to various objects in the UI
+ set theWindow to window 1 of theObject
+ set theDataSource to data source of table view "tasks" of scroll view "tasks" of theWindow
+ set theTasks to contents of every data cell of every data row of theDataSource
+ set theSortColumn to sort column of theDataSource
+
+ -- Create our record containing the list of tasks (just a list of lists), the name of the sort column and the sort order.
+ set theData to {tasks:theTasks, sortColumnName:name of theSortColumn, sortColumnOrder:sort order of theSortColumn}
+
+ return theData
+end data representation
+
+
+-- The "load data representation" event handler is called when the document is being loaded. The data that you provided in the "data representation" event handler is passed to you in the "theData" parameter.
+--
+on load data representation theObject of type ofType with data theData
+ -- Set some local variables to various objects in the UI
+ set theWindow to window 1 of theObject
+ set theDataSource to data source of table view "tasks" of scroll view "tasks" of theWindow
+
+ -- Restore the sort column and sort order of the data source based on the information saved
+ set sort column of theDataSource to data column (sortColumnName of theData) of theDataSource
+ set sort order of sort column of theDataSource to (sortColumnOrder of theData)
+
+ -- Use the "append" verb to quickly populate the data source with the list of tasks
+ append the theDataSource with (tasks of theData)
+
+ -- We return true, signaling that everything worked correctly. If you return "false" then the document will fail to load and an alert will be presented.
+ return true
+end load data representation
+
+
+(* ==== Data View Event Handlers ==== *)
+
+-- The "selection changing" event handler is called whenever the selection in the table view is changing. We will use this to update the values in the UI based on the selection.
+--
+on selection changing theObject
+ if name of theObject is "tasks" then
+ -- If there is a selection then we'll update the UI, otherwise we set the UI to default values
+ if (count of selected rows of theObject) > 0 then
+ -- Get the selected data row of the table view
+ set theTask to selected data row of theObject
+
+ -- Update the UI using the selected task
+ setUIValuesWithTaskValues(window of theObject, theTask)
+ else
+ -- Set the UI to default values
+ setDefaultUIValues(window of theObject)
+ end if
+ end if
+end selection changing
+
+
+-- The "selection changing" event handler is called whenever the selection in the table view is changing. We will use this to update the values in the UI based on the selection.
+--
+on selection changed theObject
+ if name of theObject is "tasks" then
+ -- If there is a selection then we'll update the UI, otherwise we set the UI to default values
+ if (count of selected rows of theObject) > 0 then
+ -- Get the selected data row of the table view
+ set theTask to selected data row of theObject
+
+ -- Update the UI using the selected task
+ setUIValuesWithTaskValues(window of theObject, theTask)
+ else
+ -- Set the UI to default values
+ setDefaultUIValues(window of theObject)
+ end if
+ end if
+end selection changed
+
+
+-- The "column clicked" event handler is called whenever the user clickes on a column in the table view. We will change the sort state based on the column clicked. This event handler can be used as is in most applications when utilizing the sort support built into data sources.
+--
+on column clicked theObject table column tableColumn
+ -- Get the data source of the table view
+ set theDataSource to data source of theObject
+
+ -- Get the name of the clicked table column
+ set theColumnName to name of tableColumn
+
+ -- Get the current sort column of the data source
+ set theSortColumn to sort column of theDataSource
+
+ -- If the current sort column is not the same as the clicked column then switch the sort column
+ if (name of theSortColumn) is not equal to theColumnName then
+ set the sort column of theDataSource to data column theColumnName of theDataSource
+ else
+ -- Otherwise change the sort order
+ if sort order of theSortColumn is ascending then
+ set sort order of theSortColumn to descending
+ else
+ set sort order of theSortColumn to ascending
+ end if
+ end if
+
+ -- We need to update the table view (so it will be redrawn)
+ update theObject
+end column clicked
+
+
+(* ==== Menu Item Event Handlers ==== *)
+
+-- The "choose menu item" is called (in this example) whenever the user chooses one of the "New Task, Duplicate Task, and Delete Task" menu items.
+--
+on choose menu item theObject
+ -- Set some local variables to various objects in the UI
+ set theWindow to front window
+ set theTableView to table view "tasks" of scroll view "tasks" of theWindow
+ set theDataSource to data source of theTableView
+
+ if name of theObject is "new" then
+ -- New Task
+ set theTask to make new data row at end of data rows of theDataSource
+
+ -- Set the UI to default values
+ setDefaultTaskValues(theTask)
+
+ -- Select the newly added task
+ set selected data row of theTableView to theTask
+
+ -- Make the "task" text field the object with the focus so that it will be ready for typing
+ set first responder of theWindow to text field "task" of theWindow
+ else if name of theObject is "duplicate" then
+ -- Duplicate Task (only if there is a task selected in the table view)
+ if (count of selected data rows of theTableView) > 0 then
+ -- Get the selected task
+ set theTask to selected data row of theTableView
+
+ -- Make a new task and copy the values from the selected one to the new one. (There is a bug in the copy of a data row such that you can't simply say "copy theTask to end of data rows of theDataSource").
+ set newTask to make new data row at end of data rows of theDataSource
+ set contents of data cell "priority" of newTask to contents of data cell "priority" of theTask
+ set contents of data cell "task" of newTask to contents of data cell "task" of theTask
+ set contents of data cell "status" of newTask to contents of data cell "status" of theTask
+ end if
+ else if name of theObject is "delete" then
+ -- Delete Task
+ if (count of selected data rows of theTableView) > 0 then
+ -- Get the selected task
+ set theTask to selected data row of theTableView
+
+ -- Delete it
+ delete theTask
+ end if
+ end if
+end choose menu item
+
+
+-- The "update menu item" is called whenever the status of any the "Task" menu items need to be updated (for instance when the user clicks on the "Edit" menu where these menu items are).
+--
+on update menu item theObject
+ -- By default we will enable each of these items
+ if front window exists then
+ set shouldEnable to true
+
+ -- Set some local variables to various objects in the UI
+ set theWindow to front window
+ set theTableView to table view "tasks" of scroll view "tasks" of theWindow
+ set theDataSource to data source of theTableView
+
+ if name of theObject is "duplicate" then
+ -- If there isn't a task selected disable the "Duplicate Task" menu item
+ if (count of selected data rows of theTableView) is 0 then
+ set shouldEnable to false
+ end if
+ else if name of theObject is "delete" then
+ -- If there isn't a task selected disable the "Delete Task" menu item
+ if (count of selected data rows of theTableView) is 0 then
+ set shouldEnable to false
+ end if
+ end if
+ else
+ set shouldEnable to false
+ end if
+
+ -- Return out enable state
+ return shouldEnable
+end update menu item
+
+
+(* ==== Handlers ==== *)
+
+-- This handler will set the default values of a new task
+--
+on setDefaultTaskValues(theTask)
+ set contents of data cell "priority" of theTask to "3"
+ set contents of data cell "task" of theTask to ""
+ set contents of data cell "status" of theTask to "Not Started"
+end setDefaultTaskValues
+
+-- This handler will set the default values of UI
+--
+on setDefaultUIValues(theWindow)
+ tell theWindow
+ set title of popup button "priority" to "3"
+ set contents of text field "task" to ""
+ set title of popup button "status" to "Not Started"
+ end tell
+end setDefaultUIValues
+
+-- This handler will set the values of the given task using the values in the UI
+--
+on setTaskValuesWithUIValues(theTask, theWindow)
+ set contents of data cell "priority" of theTask to title of popup button "priority" of theWindow
+ set contents of data cell "task" of theTask to contents of text field "task" of theWindow
+ set contents of data cell "status" of theTask to title of popup button "status" of theWindow
+end setTaskValuesWithUIValues
+
+-- This handler will set the values of the UI using the given task
+--
+on setUIValuesWithTaskValues(theWindow, theTask)
+ set title of popup button "priority" of theWindow to contents of data cell "priority" of theTask
+ set contents of text field "task" of theWindow to contents of data cell "task" of theTask
+ set title of popup button "status" of theWindow to contents of data cell "status" of theTask
+end setUIValuesWithTaskValues
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Application.applescript *)
+
+(* ==== Globals ==== *)
+
+global converterLib
+global logLib
+global LogController
+global Converter
+global LengthConverter
+global WeightConverter
+global LiquidVolumeConverter
+global VolumeConverter
+global AreaConverter
+global TemperatureConverter
+
+
+(* ==== Properties ==== *)
+
+property currentConverter : 0
+property scriptsLoaded : false
+
+
+(* ==== Event Handlers ==== *)
+
+on clicked theObject
+ tell window "Main"
+ if theObject is equal to button "Convert" of box 1 then
+ my convert()
+ else if the theObject is equal to button "Drawer" then
+ if state of drawer "Log" is drawer closed then
+ tell drawer "Log" to open drawer on bottom edge
+ else
+ tell drawer "Log" to close drawer
+ end if
+ else if the theObject is equal to button "Clear" of box 1 of drawer "Log" then
+ tell LogController to clearLog()
+ else if the theObject is equal to button "Save As" of box 1 of drawer "Log" then
+ set logFile to choose file name with prompt "Save Log As" default name "Conversion Results.txt"
+ tell LogController to saveLogInFile(logFile)
+ end if
+ end tell
+end clicked
+
+on choose menu item theObject
+ tell window "Main"
+ if theObject is equal to popup button "Type" of box 1 then
+ set currentConverter to my getConverterForType(title of popup button "Type" of box 1)
+ tell currentConverter to updateUnitTypes()
+ else
+ my convert()
+ end if
+ end tell
+end choose menu item
+
+on action theObject
+ if theObject is equal to text field "Value" of box 1 of window "Main" then
+ my convert()
+ end if
+end action
+
+on launched theObject
+ my loadScripts()
+ tell LogController to initialize()
+ set currentConverter to my getConverterForType(title of popup button "Type" of box 1 of window "Main")
+
+ set visible of window "Main" to true
+end launched
+
+
+(* ==== Handlers ==== *)
+
+on convert()
+ if contents of text field "Value" of box 1 of window "Main" is equal to "" then
+ display alert "You must enter a value to convert." as critical attached to window "Main"
+ else
+ tell currentConverter to convert()
+ end if
+end convert
+
+on getConverterForType(typeName)
+ if typeName is equal to "length" then
+ return LengthConverter
+ else if typeName is equal to "weight and mass" then
+ return WeightConverter
+ else if typeName is equal to "liquid volume" then
+ return LiquidVolumeConverter
+ else if typeName is equal to "volume" then
+ return VolumeConverter
+ else if typeName is equal to "area" then
+ return AreaConverter
+ else if typeName is equal to "temperature" then
+ return TemperatureConverter
+ else
+ return Converter
+ end if
+end getConverterForType
+
+on pathToScripts()
+ set appPath to (path to me from user domain) as text
+ return (appPath & "Contents:Resources:Scripts:") as text
+end pathToScripts
+
+on loadScript(scriptName)
+ return load script file (my pathToScripts() & scriptName & ".scpt")
+end loadScript
+
+on loadScripts()
+ set logLib to my loadScript("Log Controller")
+ set converterLib to my loadScript("Converter")
+
+ set LogController to LogController of logLib
+ set Converter to Converter of converterLib
+ set LengthConverter to LengthConverter of converterLib
+ set WeightConverter to WeightConverter of converterLib
+ set LiquidVolumeConverter to LiquidVolumeConverter of converterLib
+ set VolumeConverter to VolumeConverter of converterLib
+ set AreaConverter to AreaConverter of converterLib
+ set TemperatureConverter to TemperatureConverter of converterLib
+end loadScripts
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Converter.applescript *)
+
+(* ==== Globals ==== *)
+
+global LogController
+
+
+(* ==== Scripts ==== *)
+
+script Converter
+ property measureType : ""
+ property fromMeasure : ""
+ property toMeasure : ""
+ property fromUnits : 0
+ property resultUnits : 0
+ property unitTypes : {}
+
+ on initializeUnitTypes()
+ end initializeUnitTypes
+
+ on convert()
+ tell box 1 of window "Main"
+ set measureType to title of popup button "Type"
+ set fromMeasure to title of popup button "From"
+ set toMeasure to title of popup button "To"
+ set fromUnits to contents of text field "Value" as real
+ set resultUnits to 0
+ end tell
+ end convert
+
+ on updateUnitTypes()
+ tell box 1 of window "Main"
+ -- Delete all of the menu items from the popups
+ delete every menu item of menu of popup button "From"
+ delete every menu item of menu of popup button "To"
+
+ -- Add each of the unit types as menu items to both of the popups
+ repeat with i in my unitTypes
+ make new menu item at the end of menu items of menu of popup button "From" with properties {title:i, enabled:true}
+ make new menu item at the end of menu items of menu of popup button "To" with properties {title:i, enabled:true}
+ end repeat
+ end tell
+ end updateUnitTypes
+
+ on updateObject(theObject)
+ end updateObject
+
+ on updateResult(theResult)
+ set contents of text field "Result" of box 1 of window "Main" to (theResult as text)
+ tell LogController to addResultToLog((fromUnits as text) & " " & fromMeasure & " equals " & (theResult as text) & " " & toMeasure)
+ end updateResult
+end script
+
+script LengthConverter
+ property parent : Converter
+ property unitTypes : {"kilometers", "meters", "centimeters", "miles", "yards", "feet", "inches"}
+
+ on convert()
+ continue convert()
+
+ if my fromMeasure = "kilometers" then
+ set my resultUnits to my fromUnits as kilometers
+ else if my fromMeasure = "meters" then
+ set my resultUnits to my fromUnits as meters
+ else if my fromMeasure = "centimeters" then
+ set my resultUnits to my fromUnits as centimeters
+ else if my fromMeasure = "miles" then
+ set my resultUnits to my fromUnits as miles
+ else if my fromMeasure = "yards" then
+ set my resultUnits to my fromUnits as yards
+ else if my fromMeasure = "feet" then
+ set my resultUnits to my fromUnits as feet
+ else if my fromMeasure = "inches" then
+ set my resultUnits to my fromUnits as inches
+ end if
+
+ if my toMeasure = "kilometers" then
+ set my resultUnits to my resultUnits as kilometers
+ else if my toMeasure = "meters" then
+ set my resultUnits to my resultUnits as meters
+ else if my toMeasure = "centimeters" then
+ set my resultUnits to my resultUnits as centimeters
+ else if my toMeasure = "miles" then
+ set my resultUnits to my resultUnits as miles
+ else if my toMeasure = "yards" then
+ set my resultUnits to my resultUnits as yards
+ else if my toMeasure = "feet" then
+ set my resultUnits to my resultUnits as feet
+ else if my toMeasure = "inches" then
+ set my resultUnits to my resultUnits as inches
+ end if
+
+ my updateResult(my resultUnits)
+ end convert
+end script
+
+script WeightConverter
+ property parent : Converter
+ property unitTypes : {"kilograms", "grams", "pounds", "ounces"}
+
+ on convert()
+ continue convert()
+
+ if my fromMeasure = "kilograms" then
+ set my resultUnits to my fromUnits as kilograms
+ else if my fromMeasure = "grams" then
+ set my resultUnits to my fromUnits as grams
+ else if my fromMeasure = "pounds" then
+ set my resultUnits to my fromUnits as pounds
+ else if my fromMeasure = "ounces" then
+ set my resultUnits to my fromUnits as ounces
+ end if
+
+ if my toMeasure = "kilograms" then
+ set my resultUnits to my resultUnits as kilograms
+ else if my toMeasure = "grams" then
+ set my resultUnits to my resultUnits as grams
+ else if my toMeasure = "pounds" then
+ set my resultUnits to my resultUnits as pounds
+ else if my toMeasure = "ounces" then
+ set my resultUnits to my resultUnits as ounces
+ end if
+
+ my updateResult(my resultUnits)
+ end convert
+end script
+
+script LiquidVolumeConverter
+ property parent : Converter
+ property unitTypes : {"liters", "gallons", "quarts"}
+
+ on convert()
+ continue convert()
+
+ if my fromMeasure = "liters" then
+ set my resultUnits to my fromUnits as liters
+ else if my fromMeasure = "gallons" then
+ set my resultUnits to my fromUnits as gallons
+ else if my fromMeasure = "quarts" then
+ set my resultUnits to my fromUnits as quarts
+ end if
+
+ if my toMeasure = "liters" then
+ set my resultUnits to my resultUnits as liters
+ else if my toMeasure = "gallons" then
+ set my resultUnits to my resultUnits as gallons
+ else if my toMeasure = "quarts" then
+ set my resultUnits to my resultUnits as quarts
+ end if
+
+ my updateResult(my resultUnits)
+ end convert
+end script
+
+script VolumeConverter
+ property parent : Converter
+ property unitTypes : {"cubic centimeters", "cubic meters", "cubic inches", "cubic feet", "cubic yards"}
+
+ on convert()
+ continue convert()
+
+ if my fromMeasure = "cubic centimeters" then
+ set my resultUnits to my fromUnits as cubic centimeters
+ else if my fromMeasure = "cubic meters" then
+ set my resultUnits to my fromUnits as cubic meters
+ else if my fromMeasure = "cubic inches" then
+ set my resultUnits to my fromUnits as cubic inches
+ else if my fromMeasure = "cubic feet" then
+ set my resultUnits to my fromUnits as cubic feet
+ else if my fromMeasure = "cubic yards" then
+ set my resultUnits to my fromUnits as cubic yards
+ end if
+
+ if my toMeasure = "cubic centimeters" then
+ set my resultUnits to my resultUnits as cubic centimeters
+ else if my toMeasure = "cubic meters" then
+ set my resultUnits to my resultUnits as cubic meters
+ else if my toMeasure = "cubic inches" then
+ set my resultUnits to my resultUnits as cubic inches
+ else if my toMeasure = "cubic feet" then
+ set my resultUnits to my resultUnits as cubic feet
+ else if my toMeasure = "cubic yards" then
+ set my resultUnits to my resultUnits as cubic yards
+ end if
+
+ my updateResult(my resultUnits)
+ end convert
+end script
+
+script AreaConverter
+ property parent : Converter
+ property unitTypes : {"square meters", "square kilometers", "square feet", "square yards", "square miles"}
+
+ on convert()
+ continue convert()
+
+ if my fromMeasure = "square meters" then
+ set my resultUnits to my fromUnits as square meters
+ else if my fromMeasure = "square kilometers" then
+ set my resultUnits to my fromUnits as square kilometers
+ else if my fromMeasure = "square feet" then
+ set my resultUnits to my fromUnits as square feet
+ else if my fromMeasure = "square yards" then
+ set my resultUnits to my fromUnits as square yards
+ else if my fromMeasure = "square miles" then
+ set my resultUnits to my fromUnits as square miles
+ else if my fromMeasure = "feet" then
+ set my resultUnits to my fromUnits as feet
+ else if my fromMeasure = "inches" then
+ set my resultUnits to my fromUnits as inches
+ end if
+
+ if my toMeasure = "square meters" then
+ set my resultUnits to my resultUnits as square meters
+ else if my toMeasure = "square kilometers" then
+ set my resultUnits to my resultUnits as square kilometers
+ else if my toMeasure = "square feet" then
+ set my resultUnits to my resultUnits as square feet
+ else if my toMeasure = "square yards" then
+ set my resultUnits to my resultUnits as square yards
+ else if my toMeasure = "square miles" then
+ set my resultUnits to my resultUnits as square miles
+ end if
+
+ my updateResult(my resultUnits)
+ end convert
+end script
+
+script TemperatureConverter
+ property parent : Converter
+ property unitTypes : {"degrees Fahrenheit", "degrees Celsius", "degrees Kelvin"}
+
+ on convert()
+ continue convert()
+
+ if my fromMeasure = "degrees Fahrenheit" then
+ set my resultUnits to my fromUnits as degrees Fahrenheit
+ else if my fromMeasure = "degrees Celsius" then
+ set my resultUnits to my fromUnits as degrees Celsius
+ else if my fromMeasure = "degrees Kelvin" then
+ set my resultUnits to my fromUnits as degrees Kelvin
+ end if
+
+ if my toMeasure = "degrees Fahrenheit" then
+ set my resultUnits to my resultUnits as degrees Fahrenheit
+ else if my toMeasure = "degrees Celsius" then
+ set my resultUnits to my resultUnits as degrees Celsius
+ else if my toMeasure = "degrees Kelvin" then
+ set my resultUnits to my resultUnits as degrees Kelvin
+ end if
+
+ my updateResult(my resultUnits)
+ end convert
+end script
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Log Controller.applescript *)
+
+(* ==== Scripts ==== *)
+
+script LogController
+ property initialized : false
+
+ on initialize()
+ if initialized is equal to false then
+ set leading offset of drawer "Log" of window "Main" to 20
+ set trailing offset of drawer "Log" of window "Main" to 20
+ set initialized to true
+ end if
+
+ my clearLog()
+ end initialize
+
+ on addResultToLog(theResult)
+ tell scroll view 1 of drawer "Log" of window "Main"
+ set prevResult to contents of text view "Log"
+ if prevResult is equal to return or prevResult is equal to "" then
+ set contents of text view "Log" to theResult
+ else
+ set contents of text view "Log" to prevResult & return & theResult
+ end if
+ end tell
+ end addResultToLog
+
+ on clearLog()
+ set contents of text view "Log" of scroll view 1 of drawer "Log" of window "Main" to ""
+ end clearLog
+
+ on saveLogInFile(logFile)
+ open for access logFile with write permission
+ set logText to contents of text view "Log" of scroll view 1 of drawer "Log" of window "Main" as string
+ write logText to logFile
+ close access logFile
+ end saveLogInFile
+
+end script
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* Service Detail.applescript *)
+
+(* This script is used to handle events in the "Service Detail" window. *)
+
+(* ==== Event Handlers ==== *)
+
+-- The "clicked" event handler is called whenever the user clicks on the buttons in the detail window.
+--
+on clicked theObject
+ if name of theObject is "mail" then
+ -- Use the "open location" command to send an email
+ set theServiceName to contents of text field "name" of window of theObject
+ set theEmailAddress to contents of text field "email" of window of theObject
+
+ open location "mailto: " & theEmailAddress
+ else if name of theObject is "info site" then
+ -- Open the information site for this service
+ set theURL to contents of text field "info url" of window of theObject
+ open location theURL
+ else if name of theObject is "wsdl site" then
+ -- Open the WSDL for this service
+ set theURL to contents of text field "wsdl url" of window of theObject
+ open location theURL
+ end if
+end clicked
+
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+(* XMethods Service Finder.applescript *)
+
+(* This is an example that demonstrates how to use Web Services. It utilizes a service from XMethods.org that provides information about all of the services available at their site. It also demonstrates how to create and use data sources for a table view. *)
+
+(* The strategy used in this script is to populate the "services" list with all of the services avialable (which is also used to populate the "all services" data source. Then whenever a "find" is requested, the "found services" list is filled out the listing found in the "services" list, and then a new temporary data source is created, using the "found services" list to populate it. That data source is then set as the current data source of the table. If the user deletes the search text field, then the data rows of the "found services" data source are removed and the "all services" data source is set to be the current data source of the table view. In essence, it's just a matter of switching in and out the "all services" and "found services" data sources according to the actions of the user. *)
+
+(* ==== Properties ==== *)
+
+property services : {}
+property foundServices : {}
+property servicesTableView : missing value
+property detailWindow : missing value
+
+
+(* ==== Event Handlers ==== *)
+
+-- The "launched" event handler is called near the end of the launch sequence. This is a good place to show our main window.
+--
+on launched theObject
+ show window "main"
+end launched
+
+
+-- The "idle" event handler is called on a periodic basis. For our purposes, we are using it to do the initial work of getting all of the services. This is done so that the window will have already been opened and made the active window.
+--
+on idle theObject
+ -- Only do this once (hopefully)
+ if (count of services) is 0 then
+ -- Show the status items in the main window with a message
+ showStatus(window "main")
+ updateStatusMessage(window "main", "Getting Services...")
+
+ -- Get the services from the xmethods server
+ set services to getServices()
+
+ -- Update the status message
+ updateStatusMessage(window "main", "Adding Services...")
+
+ -- Add the services to our data source
+ addServicesToDataSource(services, data source "all services")
+
+ -- Hide the status items
+ hideStatus(window "main")
+ end if
+
+ return 6000
+end idle
+
+
+-- The "awake from nib" event handler is called whenever the object attached to this handler is loaded from a nib. It's a great place to do any initialization for a particular object, as it's not necessary to locate the object within it's hierarchy.
+--
+on awake from nib theObject
+ if name of theObject is "services" then
+ -- Save a reference to the table view
+ set servicesTableView to theObject
+
+ -- Create a data source that will always contain all of the services, and one that will contain the currently found service
+ makeDataSourceWithColumns("all services", {"publisherid", "name", "shortdescription", "id"})
+ makeDataSourceWithColumns("found services", {"publisherid", "name", "shortdescription", "id"})
+
+ -- Use the "all services" data source at first
+ set data source of servicesTableView to data source "all services"
+ else if name of theObject is "detail" then
+ -- Save a reference to the new detail window
+ set detailWindow to theObject
+ end if
+end awake from nib
+
+
+-- The "double clicked" event handler is called when someone double clicks on the table view.
+--
+on double clicked theObject
+ if name of theObject is "services" then
+ -- Show and update the message items in the main window
+ showStatus(window of theObject)
+ updateStatusMessage(window of theObject, "Getting Service Details...")
+
+ -- Get the clicked row of the table view
+ set theDataRow to clicked data row of theObject
+
+ -- Get the name and id of the selected service
+ set theServiceID to contents of data cell "id" of theDataRow
+ set theServiceName to contents of data cell "name" of theDataRow
+
+ -- See if the listing is already open
+ set theWindow to findWindowWithTitle(theServiceName)
+ if theWindow is not missing value then
+ -- Just bring it to the front
+ show theWindow
+ else
+ -- Load a new instance of the detail window and show it
+ load nib "ServiceDetail"
+ set title of detailWindow to theServiceName
+
+ -- Load the service detail and update it in the window
+ set theServiceDetail to getServiceDetailWithID(theServiceID as string)
+ updateServiceDetailInWindow(theServiceDetail, detailWindow)
+
+ -- Show the window
+ show detailWindow
+ end if
+
+ -- Hide the status items
+ hideStatus(window of theObject)
+ end if
+end double clicked
+
+
+-- The "action" event handler is called when someone chooses a menu item from the popup button. In this case the script will just cause another "find" to happen.
+--
+on action theObject
+ find(window of theObject)
+end action
+
+on column clicked theObject table column tableColumn
+ -- Get the data source of the table view
+ set theDataSource to data source of theObject
+
+ -- Get the identifier of the clicked table column
+ set theColumnIdentifier to identifier of tableColumn
+
+ -- Get the current sort column of the data source
+ try
+ set theSortColumn to sort column of theDataSource
+
+ -- If the current sort column is not the same as the clicked column then switch the sort column
+ if (name of theSortColumn) is not equal to theColumnIdentifier then
+ set the sort column of theDataSource to data column theColumnIdentifier of theDataSource
+ else
+ -- Otherwise change the sort order
+ if sort order of theSortColumn is ascending then
+ set sort order of theSortColumn to descending
+ else
+ set sort order of theSortColumn to ascending
+ end if
+ end if
+ on error
+ set sort column of theDataSource to data column theColumnIdentifier of theDataSource
+ end try
+
+ -- We need to update the table view (so it will be redrawn)
+ update theObject
+end column clicked
+
+
+(* ==== Handlers ==== *)
+
+-- This handler will show the status items in the main window. It also starts the animation of the progress indicator.
+--
+on showStatus(theWindow)
+ tell theWindow
+ -- Show the text field and progress indicator
+ set visible of text field "status" to true
+ set visible of progress indicator "progress" to true
+
+ -- Make sure it's using threaded animation and start it
+ set uses threaded animation of progress indicator "progress" to true
+ start progress indicator "progress"
+ end tell
+end showStatus
+
+
+-- This handler will hide the status items in the main window. It also stops the animation of the progress indicator.
+--
+on hideStatus(theWindow)
+ tell theWindow
+ -- Hide the text field and progress indicator
+ set visible of text field "status" to false
+ set visible of progress indicator "progress" to false
+
+ -- Stop the progress indicator
+ stop progress indicator "progress"
+ end tell
+end hideStatus
+
+
+-- This handler will update the contents of the status message.
+--
+on updateStatusMessage(theWindow, theMessage)
+ set contents of text field "status" of theWindow to theMessage
+end updateStatusMessage
+
+
+-- The "find" handler is used to query the data source based on the state of where, how, and what to find.
+--
+on find(theWindow)
+ -- Show and update the status items in the window
+ showStatus(theWindow)
+ updateStatusMessage(theWindow, "Finding Services...")
+
+ -- Get the where, how, and what to find form the UI
+ tell theWindow
+ set findWhere to title of popup button "where"
+ set findHow to title of popup button "how"
+ set findWhat to contents of text field "what"
+ end tell
+
+ -- If there isn't anything specified in the "what", then switch in the "all services" data source
+ if findWhat is "" then
+ set data source of servicesTableView to data source "all services"
+ update servicesTableView
+ else
+ -- Otherwise, find the matching services
+ set foundServices to findServices(findWhere, findHow, findWhat)
+
+ -- Turn off the updating of the table view while we manipulate the data source
+ set update views of data source "found services" to false
+
+ -- Delete all of the data rows in the data source
+ delete every data row of data source "found services"
+
+ -- Make sure that we have at least one found web service and then add the services to the data source
+ if (count of foundServices) > 0 then
+ addServicesToDataSource(foundServices, data source "found services")
+ end if
+
+ -- Switch in the "found services" data source into the table view
+ set data source of servicesTableView to data source "found services"
+
+ -- Turn back on the updating of the table view
+ set update views of data source "found services" to true
+ end if
+
+ -- Hide the status items
+ hideStatus(theWindow)
+end find
+
+
+-- This is a utility handler that will create a new data source with the given name and columns names.
+--
+on makeDataSourceWithColumns(theName, theColumnNames)
+ -- Make the data source
+ make new data source at the end of the data sources with properties {name:theName}
+
+ -- Add the data columns
+ repeat with columnName in theColumnNames
+ make new data column at the end of the data columns of data source theName with properties {name:columnName, sort order:ascending, sort type:alphabetical, sort case sensitivity:case insensitive}
+ end repeat
+
+ -- Set the first column to be the sort column
+ set sort column of data source theName to data column (item 1 of theColumnNames) of data source theName
+
+ -- Make the data source sorted
+ set sorted of data source theName to true
+
+end makeDataSourceWithColumns
+
+
+-- This handler adds the records to the data source using the "append" command.
+--
+on addServicesToDataSource(theServices, theDataSource)
+ -- Turn off updating the associated table view
+ set update views of theDataSource to false
+
+ -- Add the records to the data source
+ append theDataSource with theServices
+
+ -- Turn the updating of the table view back on
+ set update views of theDataSource to true
+end addServicesToDataSource
+
+
+-- This is handler will do the actual searching of the "services" list based on the where, how and what parameters.
+--
+on findServices(findWhere, findHow, findWhat)
+ -- Set the result to an empty list
+ set theServices to {}
+
+ -- Determine which field of the record to search based on "where"
+ if findWhere is "Publisher" then
+ repeat with service in services
+ set theValue to publisherid of service
+ if findHow is "begins with" and theValue begins with findWhat then
+ copy service to the end of theServices
+ else if findHow is "contains" and theValue contains findWhat then
+ copy service to the end of theServices
+ else if findHow is "ends with" and theValue ends with findWhat then
+ copy service to the end of theServices
+ else if findHow is "is" and theValue is findWhat then
+ copy service to the end of theServices
+ end if
+ end repeat
+ else if findWhere is "Service Name" then
+ repeat with service in services
+ set theValue to |name| of service
+ if findHow is "begins with" and theValue begins with findWhat then
+ copy service to the end of theServices
+ else if findHow is "contains" and theValue contains findWhat then
+ copy service to the end of theServices
+ else if findHow is "ends with" and theValue ends with findWhat then
+ copy service to the end of theServices
+ else if findHow is "is" and theValue is findWhat then
+ copy service to the end of theServices
+ end if
+ end repeat
+ else if findWhere is "Description" then
+ repeat with service in services
+ set theValue to shortdescription of service
+ if findHow is "begins with" and theValue begins with findWhat then
+ copy service to the end of theServices
+ else if findHow is "contains" and theValue contains findWhat then
+ copy service to the end of theServices
+ else if findHow is "ends with" and theValue ends with findWhat then
+ copy service to the end of theServices
+ else if findHow is "is" and theValue is findWhat then
+ copy service to the end of theServices
+ end if
+ end repeat
+ end if
+
+ -- Return the services that were found
+ return theServices
+end findServices
+
+
+-- This handler is called when the user has double clicked on one of the services in the table view. It will update the UI elements in the specified detail window with the given service detail record.
+--
+on updateServiceDetailInWindow(theServiceDetail, theWindow)
+ tell theWindow
+ -- Update the contents of each of the text fields with the corresponding fields from the detail record.
+ set contents of text field "name" to |name| of theServiceDetail
+ set contents of text field "description" to shortdescription of theServiceDetail
+ set contents of text field "publisher" to publisherid of theServiceDetail
+ set contents of text field "email" to email of theServiceDetail
+ --set contents of text field "info url" to infourl of theServiceDetail
+ set contents of text field "wsdl url" to wsdlurl of theServiceDetail
+
+ -- Check to see if we actually have a "note" field.
+ if notes of theServiceDetail is not "<<nil not supported>>" then
+ set contents of text view "notes" of scroll view "notes" to notes of theServiceDetail
+ end if
+ end tell
+end updateServiceDetailInWindow
+
+
+(* ==== Web Services Handlers ==== *)
+
+-- The "getServices" handler is used to get a list of records that describes all of the services available from XMethods.org.
+--
+on getServices()
+ -- Set the result to an empty list
+ set theServices to {}
+
+ -- Get the list of services from the server
+ try
+ tell application "http://www.xmethods.net/interfaces/query"
+ set theServices to call soap {method name:"getAllServiceSummaries", method namespace uri:"http://www.xmethods.net/interfaces/query", parameters:{}, SOAPAction:""}
+ end tell
+ end try
+
+ -- Return the list of services
+ return theServices
+end getServices
+
+
+-- The "getServiceDetailWithID" handler will return a record that contains the details about the service with the specified ID.
+--
+on getServiceDetailWithID(theServiceID)
+ -- Set the result to a known value
+ set theDetail to missing value
+
+ -- We need to convert the supplied service id as plain text (as it is given as unicode text). This is a workaround for a known bug in the "call soap" command, as it can not except unicode or styled text at this time.
+ set theServiceID to getPlainText(theServiceID)
+
+ -- Get the detailed info from the server.
+ try
+ tell application "http://www.xmethods.net/interfaces/query"
+ set theDetail to call soap {method name:"getServiceDetail", method namespace uri:"http://www.xmethods.net/interfaces/query", parameters:{|id|:theServiceID}, SOAPAction:""}
+ end tell
+ end try
+
+ -- Return the requested detail information
+ return theDetail
+end getServiceDetailWithID
+
+
+(* ==== Utility Handlers ==== *)
+
+-- This is a utility handler that will simply find the window with the specified title.
+--
+on findWindowWithTitle(theTitle)
+ set theWindow to missing value
+
+ set theWindows to every window whose title is theTitle
+ if (count of theWindows) > 0 then
+ set theWindow to item 1 of theWindows
+ end if
+
+ return theWindow
+end findWindowWithTitle
+
+-- This is a workaround that will convert the given unicode text into plain text (not styled text)
+--
+on getPlainText(fromUnicodeString)
+ set styledText to fromUnicodeString as string
+ set styledRecord to styledText as record
+ return Çclass ktxtÈ of styledRecord
+end getPlainText
+
+(* © Copyright 2004 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+-- main.applescript
+-- Get Process Information
+
+on run {input, parameters}
+
+ if input is in {{}, {""}, ""} or |ignoresInput| of parameters is true then -- ignoresInput is the value of the type setting in the action's title bar
+ -- if input is empty or being ignored then get process from popup button selection
+ set processNameVal to (|processName| of parameters) as Unicode text
+ else
+ -- if input is not empty then use input as process name
+ if class of input is list then
+ set processNameVal to item 1 of input
+ if processNameVal is in {{}, ""} then
+ set processNameVal to (|processName| of parameters) as Unicode text
+ end if
+ else
+ set processNameVal to input
+ end if
+ end if
+
+ set ReturnAppleScriptRecordVal to (|ReturnAppleScriptRecord| of parameters)
+
+ if ReturnAppleScriptRecordVal = 1 then
+ (*
+ Since this is a compiled script, we use the 'run script' command to load in System Events' AppleScript terminology.
+ Otherwise the resulting AppleScript record will appear in chevron syntax (four byte character codes) in the View Results action.
+ *)
+ set theScript to "tell application \"System Events\" to properties of process \"" & processNameVal & "\""
+ set processInfo to run script theScript
+ else
+ tell application "System Events"
+ set processInfo to properties of process processNameVal
+ end tell
+ set counter to count of processInfo
+ -- Get localized strings for properties labels
+ set accepts_high_level_events to localized_string("accepts high level events")
+ set accepts_remote_events to localized_string("accepts remote events")
+ set background_only to localized_string("background only")
+ set ClassicVal to localized_string("Classic")
+ set creator_type to localized_string("creator type")
+ set displayed_name to localized_string("displayed name")
+ set fileVal to localized_string("file")
+ set file_type to localized_string("file type")
+ set frontmostVal to localized_string("frontmost")
+ set has_scripting_terminology to localized_string("has scripting terminology")
+ set idVal to localized_string("id")
+ set nameVal to localized_string("name")
+ set partition_space_used to localized_string("partition space used")
+ set total_partition_size to localized_string("total partition size")
+ set unix_id to localized_string("unix id")
+ set visibleVal to localized_string("visible")
+ -- Create text report
+ tell application "System Events"
+ set theTextData to accepts_high_level_events & ":" & tab & accepts high level events of processInfo & return & Â
+ accepts_remote_events & ":" & tab & accepts remote events of processInfo & return & Â
+ background_only & ":" & tab & background only of processInfo & return & Â
+ ClassicVal & ":" & tab & Classic of processInfo & return & Â
+ creator_type & ":" & tab & creator type of processInfo & return & Â
+ displayed_name & ":" & tab & displayed name of processInfo & return & Â
+ fileVal & ":" & tab & file of processInfo & return & Â
+ file_type & ":" & tab & file type of processInfo & return & Â
+ frontmostVal & ":" & tab & frontmost of processInfo & return & Â
+ has_scripting_terminology & ":" & tab & has scripting terminology of processInfo & return & Â
+ idVal & ":" & tab & id of processInfo & return & Â
+ nameVal & ":" & tab & name of processInfo & return & Â
+ partition_space_used & ":" & tab & partition space used of processInfo & return & Â
+ total_partition_size & ":" & tab & total partition size of processInfo & return & Â
+ unix_id & ":" & tab & unix id of processInfo & return & Â
+ visibleVal & ":" & tab & visible of processInfo & return
+ end tell
+ set processInfo to theTextData
+ end if
+ return processInfo
+end run
+
+on localized_string(key_string)
+ return localized string key_string in bundle with identifier "com.apple.AutomatorExamples.GetProcessInformation"
+end localized_string
+
+(* © Copyright 2005 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+
+-- UI.applescript
+-- Get Process Information
+
+property actionview_reference : missing value
+property contentview_reference : missing value
+property action_parameters : missing value
+
+on awake from nib theObject
+ set contentview_reference to theObject
+ set actionview_reference to the super view of contentview_reference
+ set the action_parameters to (call method "parameters" of (call method "action" of the actionview_reference))
+ getProcesses()
+end awake from nib
+
+on parameters updated theObject parameters theParameters
+ set (the title of popup button "processesMenu" of contentview_reference) to |processName| of theParameters as Unicode text
+ set (the state of button "backgroundProcessesButton" of contentview_reference) to |backgroundProcesses| of theParameters as integer
+ set (the state of button "ReturnAppleScriptRecord" of contentview_reference) to |ReturnAppleScriptRecord| of theParameters as integer
+ return theParameters
+end parameters updated
+
+on update parameters theObject parameters theParameters
+ set |processName| of theParameters to (the title of popup button "processesMenu" of contentview_reference) as Unicode text
+ set |backgroundProcesses| of theParameters to (the state of button "backgroundProcessesButton" of contentview_reference)
+ set |ReturnAppleScriptRecord| of theParameters to (the state of button "ReturnAppleScriptRecord" of contentview_reference)
+ return theParameters
+end update parameters
+
+on clicked theObject
+ -- This handler is attached to the check box buttons
+ if name of theObject is "backgroundProcessesButton" then
+ getProcesses()
+ else if name of theObject is "ReturnAppleScriptRecord" then
+ -- There are problems targeting the Automator process when returning a record, so we don't present this process to user
+ set CurrentProcessTitle to (title of popup button "processesMenu" of contentview_reference) --as Unicode text
+ if CurrentProcessTitle contains "Automator" then
+ getProcesses()
+ end if
+ end if
+end clicked
+
+
+on will pop up theObject
+ -- This handler is attached to the popup button
+ tell progress indicator "ProgressIndicator" of contentview_reference to start
+ set CurrentProcessTitle to (title of theObject) --as Unicode text
+ getProcesses()
+ set (title of theObject) to CurrentProcessTitle
+ tell progress indicator "ProgressIndicator" of contentview_reference to stop
+end will pop up
+
+on getProcesses()
+ set |backgroundProcesses| of action_parameters to (the state of button "backgroundProcessesButton" of contentview_reference)
+ set backgroundProcessVal to (|backgroundProcesses| of action_parameters)
+ set ReturnAppleScriptRecordVar to (the state of button "ReturnAppleScriptRecord" of contentview_reference)
+
+ delete every menu item of menu of popup button "processesMenu" of contentview_reference
+ if backgroundProcessVal = 1 then
+ tell application "System Events"
+ set processList to name of every process
+ end tell
+ else
+ tell application "System Events"
+ set processList to name of every process whose background only is false
+ end tell
+ end if
+ repeat with processTitle in processList
+ -- There are problems targeting the Automator process when returning a record, so we don't present this process to user
+ if ReturnAppleScriptRecordVar = 1 then
+ if processTitle does not contain "Automator" then
+ make new menu item at the end of menu items of menu of popup button "processesMenu" of contentview_reference with properties {title:processTitle, enabled:true}
+ end if
+ else
+ make new menu item at the end of menu items of menu of popup button "processesMenu" of contentview_reference with properties {title:processTitle, enabled:true}
+ end if
+ end repeat
+end getProcesses
+
+(* © Copyright 2005 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+-- main.applescript
+-- Quit Application
+
+on run {input, parameters}
+ set the app_path to |appPath| of parameters
+
+ set the target_app to app_path as POSIX file as alias
+ set the target_app to the target_app as Unicode text
+
+ set saving to (saving of parameters)
+ if saving is 0 then
+ tell application target_app to quit saving yes
+ else if saving is 1 then
+ tell application target_app to quit saving no
+ else
+ tell application target_app to quit saving ask
+ end if
+ return input
+end run
+
+(* © Copyright 2005 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (“Appleâ€) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple’s copyrights in this original Apple software (the “Apple Softwareâ€), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+-- main.applescript
+-- Randomizer
+
+on run {input_items, parameters}
+ set the output_items to {}
+ if input_items is not {} then
+ if the class of the input_items is list then
+ set the number_method to (|numberMethod| of parameters) as integer
+ set the number_to_choose to (|numberToChoose| of parameters) as integer
+ if number_method is 1 then
+ set the number_to_choose to my convert_percentage_to_number(number_to_choose, count of the input_items)
+ end if
+ repeat with i from 1 to the number_to_choose
+ set the end of the output_items to some item of the input_items
+ end repeat
+ else
+ set the output_items to the input_items
+ end if
+ end if
+ return output_items
+end run
+
+on convert_percentage_to_number(this_percentage, this_total)
+ return (this_percentage * this_total) div 100
+end convert_percentage_to_number
+
+on localized_string(key_string)
+ return localized string key_string in bundle with identifier "com.apple.AutomatorExamples.Randomizer"
+end localized_string
+
+(* © Copyright 2005 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (ÒAppleÓ) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
+
+In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in this original Apple software (the ÒApple SoftwareÓ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *)
+-- ÇFILENAMEÈ
+-- ÇPROJECTNAMEÈ
+
+-- Created by ÇFULLUSERNAMEÈ on ÇDATEÈ.
+-- Copyright ÇYEARÈ ÇORGANIZATIONNAMEÈ. All rights reserved.
+
+-- CodeWarrior Script Handlers
+-- pbxprojectimporters
+-- Created by Scott Tooker on Mon Mar 17 2003.
+-- Copyright ? 2003 Apple Computer. All rights reserved.
+
+-- This file contains subroutines that are called by PBXCWProjectImporter to assist in the import of a CodeWarrior project.
+
+-- exportCodeWarriorProjectAtPath subroutine
+-- this subroutine opens the project pointed to by posixProjectPath, sets all the targets to use relative paths and then exports the project to an XML file and returns the posix path to the XML export file.
+on exportCodeWarriorProjectAtPath(posixProjectPath)
+ set projectAlias to (POSIX file posixProjectPath) as alias
+ tell application "CodeWarrior IDE"
+ set projectToExport to a reference to document (openProject(projectAlias) of me)
+ -- log projectToExport
+ set theProjectWindow to window of projectToExport
+ select theProjectWindow
+ set projectFileLocation to (location of projectToExport) as alias
+ set originalTarget to current target of projectToExport
+ set originalTargetName to name of originalTarget
+ set listOfTargets to name of every target in projectToExport
+
+ repeat with eachTargetName in listOfTargets
+ Set Current Target eachTargetName
+ set settings to (Get Preferences from panel "Target Settings")
+ set Use Relative Paths of settings to true
+ Set Preferences of panel "Target Settings" to settings
+ end repeat
+
+ Set Current Target originalTargetName
+
+ tell application "Finder"
+ set projectFolder to (the container of projectFileLocation) as alias
+ end tell
+
+ set xmlFileName to (name of projectToExport) & ".xml"
+ set tempXMLFilePath to ((projectFolder as Unicode text) & "tempProjectAsXML.xml")
+
+ set xmlFileReference to a reference to file tempXMLFilePath
+
+ export projectToExport to xmlFileReference
+ end tell
+
+ tell application "Finder"
+ set aliasToXMLFile to tempXMLFilePath as alias
+ set name of aliasToXMLFile to xmlFileName
+ end tell
+
+ return POSIX path of aliasToXMLFile
+end exportCodeWarriorProjectAtPath
+
+-- closeCodeWarriorProjectAtPath subroutine
+-- this subroutine closes the project pointed to by posixProjectPath if it is open
+on closeCodeWarriorProjectAtPath(posixProjectPath)
+ set projectAlias to (POSIX file posixProjectPath) as alias
+
+ tell application "CodeWarrior IDE"
+ set projectToClose to a reference to document (openProject(projectAlias) of me)
+ set theProjectWindow to window of projectToClose
+ close theProjectWindow saving yes
+ end tell
+end closeCodeWarriorProjectAtPath
+
+-- generateInfoPlist subroutine
+-- this subroutine generates the Info.plist from the given .plc file using the given target in the current project and returns the posix path to the Info.plist
+on generateInfoPlist(posixProjectPath, targetName, posixPlcFilePath)
+ set projectAlias to (POSIX file posixProjectPath) as alias
+ set plcFileAlias to (POSIX file posixPlcFilePath) as alias
+
+ tell application "CodeWarrior IDE"
+ set projectOfInterest to a reference to document (openProject(projectAlias) of me)
+ set theProjectWindow to window of projectOfInterest
+ select theProjectWindow
+
+ set originalTarget to current target of projectOfInterest
+ set originalTargetName to name of originalTarget
+
+ Set Current Target targetName
+ compile {plcFileAlias}
+
+ set infoPlistPath to findInfoPlistForTargetInProject(targetName, projectAlias) of me
+
+ Set Current Target originalTargetName
+ return infoPlistPath
+ end tell
+end generateInfoPlist
+
+-- findInfoPlistForTarget subroutine
+-- this subroutine finds the Info.plist for the given target in the current project and returns the posix path
+on findInfoPlistForTargetInProject(cwTargetName, projectAlias)
+
+ tell application "CodeWarrior IDE"
+ Set Current Target cwTargetName
+ -- determine which linker is being used for this target to get the project type
+ set targetSettings to (Get Preferences from panel "Target Settings")
+ set linkerName to Linker of targetSettings
+ set projectType to missing value
+ set productName to missing value
+
+ if (linkerName is "MacOS PPC Linker") then
+ set targetSettings to (Get Preferences from panel "PPC Project")
+ else if (linkerName is "MacOS X PPC Linker") then
+ set targetSettings to (Get Preferences from panel "PPC Mac OS X Project")
+ else if (linkerName is "Mach-O PPC Linker") then
+ set targetSettings to (Get Preferences from panel "PPC Mach-O Target")
+ end if
+
+ set projectType to Project Type of targetSettings
+ set productName to File Name of targetSettings
+
+ set projectTypesThatIgnorePlistOutputPath to {application package, shared library package, framework, kernel extension package}
+
+ set targetSettings to (Get Preferences from panel "Property List")
+ set plistOutputPath to Output Directory of targetSettings
+
+ if projectType is in projectTypesThatIgnorePlistOutputPath then
+ set targetSettings to (Get Preferences from panel "Target Settings")
+ set outputRelativePath to Output Directory Location of targetSettings
+ set pathName to name of outputRelativePath
+ set newPathName to pathName
+
+ if format of outputRelativePath is MacOS Path then
+ set newPathName to (pathName & ":" & productName & ":Contents:Info.plist")
+ else if format of outputRelativePath is Unix Path then
+ set newPathName to (pathName & "/" & productName & "/Contents/Info.plist")
+ end if
+ set (name of outputRelativePath) to newPathName
+ set plistOutputPath to outputRelativePath
+ end if
+
+ set absolutePath to absolutePathForAccessPathInTargetNamedFromProject(plistOutputPath, cwTargetName, projectAlias) of me
+
+ return absolutePath
+ end tell
+end findInfoPlistForTargetInProject
+
+-- absolutePathForAccessPathInTargetNamedFromProject subroutine
+-- this subroutine returns an absolute posix path for the given access path
+on absolutePathForAccessPathInTargetNamedFromProject(accessPath, cwTargetName, projectAlias)
+ set projectPathRoot to projectAlias
+ tell application "Finder"
+ set compilerFolderAlias to container of (application file id "CWIE") as alias
+ set compilerPathRoot to POSIX path of (compilerFolderAlias)
+ set projectFolderAlias to container of (file projectAlias) as alias
+ set projectPathRoot to POSIX path of projectFolderAlias
+ end tell
+
+
+ tell application "CodeWarrior IDE"
+ set relativePath to name of accessPath
+ set pathFormat to format of accessPath
+ set pathRootType to origin of accessPath
+ set pathRootName to missing value
+ if pathRootType is root relative then
+ set pathRootName to root of accessPath
+ end if
+ set absolutePath to missing value
+
+ if pathRootType is absolute then
+ set absolutePath to relativePath
+ else if pathRootType is project relative then
+ if pathFormat is MacOS Path then
+ set macOSProjectPathRoot to projectFolderAlias as Unicode text
+ set absolutePath to (macOSProjectPathRoot & relativePath)
+ else if pathFormat is Unix Path then
+ set absolutePath to (projectPathRoot & relativePath)
+ end if
+ else if pathRootType is shell relative then
+ if pathFormat is MacOS Path then
+ set macOSCompilerPathRoot to compilerFolderAlias as Unicode text
+ set absolutePath to (macOSCompilerPathRoot & relativePath)
+ else if pathFormat is Unix Path then
+ set absolutePath to (compilerPathRoot & relativePath)
+ end if
+ else if pathRootType is root relative then
+ set sourceTreeRoot to pathForSourceTreeNameUsingTargetNamedInProjectAtPath(pathRootName, cwTargetName, projectAlias) of me
+ if pathFormat is MacOS Path then
+ set macOSSourceTreePathRoot to (POSIX file sourceTreeRoot) as Unicode text
+ set absolutePath to (macOSSourceTreePathRoot & relativePath)
+ else if pathFormat is Unix Path then
+ set absolutePath to (sourceTreeRoot & relativePath)
+ end if
+ end if
+
+ if pathFormat is MacOS Path then
+ return POSIX path of (absolutePath as alias)
+ else
+ return absolutePath
+ end if
+ end tell
+end absolutePathForAccessPathInTargetNamedFromProject
+
+-- pathForSourceTreeNameUsingTargetNamedInProjectAtPath subroutine
+-- this subroutine returns the posix path for a given Source Tree name
+-- target source trees are searched first, followed by global source trees
+on pathForSourceTreeNameUsingTargetNamedInProjectAtPath(pathRootName, cwTargetName, projectAlias)
+
+ tell application "CodeWarrior IDE"
+ set cwProject to a reference to document (openProjectAtPath(projectAlias) of me)
+ set originalTarget to current target of cwProject
+ set originalTargetName to name of originalTarget
+
+ Set Current Target cwTargetName
+ set targetSourceTrees to Source Trees of (Get Preferences from panel "Target Source Trees")
+ Set Current Target originalTargetName
+
+ set sourceTreePath to missing value
+ repeat with eachSourceTree in targetSourceTrees
+ if name of eachSourceTree is pathRootName then
+ if format of eachSourceTree is MacOS Path then
+ set sourceTreePath to POSIX path of file (path of eachSourceTree)
+ else
+ set sourceTreePath to (path of eachSourceTree)
+ end if
+ end if
+ end repeat
+
+ if sourceTreePath is missing value then
+ set globalSourceTrees to Source Trees of Global Source Trees
+
+ repeat with eachSourceTree in globalSourceTrees
+ if name of eachSourceTree is pathRootName then
+ if format of eachSourceTree is MacOS Path then
+ set sourceTreePath to POSIX path of file (path of eachSourceTree)
+ else
+ set sourceTreePath to (path of eachSourceTree)
+ end if
+ end if
+ end repeat
+ end if
+
+ return sourceTreePath
+ end tell
+end pathForSourceTreeNameUsingTargetNamedInProjectAtPath
+
+-- fixUpBrokenCodeWarriorPath subroutine
+-- this is needed to get around a bug in the path value that CodeWarrior returns for a target file
+on fixUpBrokenCodeWarriorPath(brokenPath)
+ set slashOffset to offset of "/" in brokenPath
+ set lengthOfPath to count of brokenPath
+ set firstPiece to characters 1 thru (slashOffset - 1) of brokenPath
+ set lastPiece to characters (slashOffset + 1) thru lengthOfPath of brokenPath
+ set fixedPath to firstPiece & ":" & lastPiece as Unicode text
+
+ return fixedPath
+end fixUpBrokenCodeWarriorPath
+
+-- openProject subroutine
+-- this returns the name of the CodeWarrior project that is at the given path
+on openProject(projectAlias)
+ tell application "CodeWarrior IDE"
+ -- log (open projectAlias converting yes)
+ open projectAlias converting yes
+
+ set desiredProjectName to missing value
+ set documentList to every document
+ -- log documentList
+ repeat with eachDocument in documentList
+ if kind of eachDocument is project then
+ if ((location of eachDocument) as alias) is projectAlias then
+ set desiredProjectName to name of eachDocument
+ exit repeat
+ end if
+ end if
+ end repeat
+ -- log desiredProjectName
+ return desiredProjectName
+ end tell
+end openProject
+
+-- getGlobalSourceTrees subroutine
+-- this returns the set of defined app-level source trees
+on getGlobalSourceTrees()
+ tell application "CodeWarrior IDE"
+ get Source Trees of (Get Preferences from panel "Global Source Trees")
+ end tell
+end getGlobalSourceTrees
+
+-- launchCodeWarrior subroutine
+-- this launches CodeWarrior
+on launchCodeWarrior()
+ launch application "CodeWarrior IDE"
+end launchCodeWarrior
+
+-- quitCodeWarrior subroutine
+-- this quits CodeWarrior
+on quitCodeWarrior()
+ quit application "CodeWarrior IDE"
+end quitCodeWarrior
+
+-- Created by Scott Tooker on Mon Apr 21 2003.
+-- Copyright © 2003 Apple Computer. All rights reserved.
+
+-- This file contains subroutines that are called by PBXCWProjectImporter to assist in the import of a CodeWarrior project.
+
+-- isCodeWarriorOpen subroutine
+-- this returns if CodeWarrior is already open
+on isCodeWarriorOpen()
+
+ set codeWarriorOpen to false
+
+ tell application "System Events"
+ set codeWarriorProcesses to processes whose name contains "CodeWarrior"
+ end tell
+
+ if codeWarriorProcesses is not {} then
+ set codeWarriorOpen to true
+ end if
+
+ return codeWarriorOpen
+
+end isCodeWarriorOpen
+-- main.applescript
+-- ÇPROJECTNAMEÈ
+
+-- Created by ÇFULLUSERNAMEÈ on ÇDATEÈ.
+-- Copyright ÇYEARÈ ÇORGANIZATIONNAMEÈ. All rights reserved.
+
+on run {input, parameters}
+
+ return input
+end run
+-- ÇPROJECTNAMEÈ.applescript
+-- ÇPROJECTNAMEÈ
+
+-- Created by ÇFULLUSERNAMEÈ on ÇDATEÈ.
+-- Copyright ÇYEARÈ ÇORGANIZATIONNAMEÈ. All rights reserved.
+-- ÇPROJECTNAMEÈ.applescript
+-- ÇPROJECTNAMEÈ
+
+-- Created by ÇFULLUSERNAMEÈ on ÇDATEÈ.
+-- Copyright ÇYEARÈ ÇORGANIZATIONNAMEÈ. All rights reserved.
+
+-- Document.applescript
+-- ÇPROJECTNAMEÈ
+
+-- Created by ÇFULLUSERNAMEÈ on ÇDATEÈ.
+-- Copyright ÇYEARÈ ÇORGANIZATIONNAMEÈ. All rights reserved.
+
+on data representation theObject of type ofType
+ (*Return the data that is to be stored in your document here.*)
+end data representation
+
+on load data representation theObject of type ofType with data withData
+ (* The withData contains the data that was stored in your document that you provided in the "data representation" event handler. Return "true" if this was successful, or false if not.*)
+ return true
+end load data representation
+-- ÇPROJECTNAMEÈ.applescript
+-- ÇPROJECTNAMEÈ
+
+-- Created by ÇFULLUSERNAMEÈ on ÇDATEÈ.
+-- Copyright ÇYEARÈ ÇORGANIZATIONNAMEÈ. All rights reserved.
+
+on idle
+ (* Add any idle time processing here. *)
+end idle
+
+on open names
+ (* Add your script to process the names here. *)
+
+ -- Remove the following line if you want the application to stay open.
+ quit
+end open
+
+-- ÇPROJECTNAMEÈ.applescript
+-- ÇPROJECTNAMEÈ
+
+-- Created by ÇFULLUSERNAMEÈ on ÇDATEÈ.
+-- Copyright ÇYEARÈ ÇORGANIZATIONNAMEÈ. All rights reserved.
+
+on plugin loaded theBundle
+ (* Add your script here. *)
+end plugin loaded
+-- Refresh Finder.applescript
+-- SCPlugin
+
+-- Created by Jonathan Paisley on 03/12/2006.
+-- Copyright 2006 Jonathan Paisley. All rights reserved.
+
+tell application "Finder"
+ update every item of every window
+end tell
+tell application "System Preferences"
+ activate
+ set current pane to pane "com.apple.preferences.users"
+end tell
+
+tell application "System Events"
+ if UI elements enabled then
+ tell tab group 1 of window "Accounts" of process "System Preferences"
+ click radio button 1
+ delay 2
+ get value of text field 1
+ end tell
+ else
+ tell application "System Preferences"
+ activate
+ set current pane to pane "com.apple.preference.universalaccess"
+ display dialog "UI element scripting is not enabled. Check \"Enable access for assistive devices\""
+ end tell
+ end if
+end tell
+tell application "TextEdit"
+ activate
+end tell
+
+tell application "System Events"
+ if UI elements enabled then
+ tell process "TextEdit"
+ set frontmost to true
+ end tell
+
+ key down option
+ keystroke "e"
+ delay 1
+ key up option
+ keystroke "e"
+ keystroke return
+
+ keystroke "e" using option down
+ delay 1
+ keystroke "e"
+ keystroke return
+
+ key down shift
+ keystroke "p"
+ key up shift
+ keystroke return
+
+ key down option
+ keystroke "p"
+ key up option
+ keystroke return
+
+ key down {shift, option}
+ keystroke "p"
+ key up {shift, option}
+ keystroke return
+
+ keystroke "p" using {shift down, option down}
+ keystroke return
+
+ else
+ tell application "System Preferences"
+ activate
+ set current pane to pane "com.apple.preference.universalaccess"
+ display dialog "UI element scripting is not enabled. Check \"Enable access for assistive devices\""
+ end tell
+ end if
+end tell
+tell application "System Events"
+ get properties
+ get every process
+ if UI elements enabled then
+ tell process "Finder"
+ get every menu bar
+ tell menu bar 1
+ get every menu bar item
+ get every menu of every menu bar item
+ get every menu item of every menu of every menu bar item
+ get every menu of every menu item of every menu of every menu bar item
+ get every menu item of every menu of every menu item of every menu of every menu bar item
+ end tell
+ end tell
+ else
+ tell application "System Preferences"
+ activate
+ set current pane to pane "com.apple.preference.universalaccess"
+ display dialog "UI element scripting is not enabled. Check \"Enable access for assistive devices\""
+ end tell
+ end if
+end tell
+tell application "Finder"
+ activate
+end tell
+
+tell application "System Events"
+ get properties
+ if UI elements enabled then
+ tell process "Finder"
+
+ get every UI element
+
+ tell window 1
+
+ get every button
+ get properties of every button
+ get every UI element of every button
+
+ get every static text
+ get properties of every static text
+ get every UI element of every static text
+
+ get every scroll bar
+ get properties of every scroll bar
+ get every UI element of every scroll bar
+
+ get every UI element Â
+ whose class is not button and class is not static text Â
+ and class is not scroll bar
+ get properties of every UI element Â
+ whose class is not button and class is not static text Â
+ and class is not scroll bar
+
+ end tell
+
+ end tell
+ else
+ tell application "System Preferences"
+ activate
+ set current pane to pane "com.apple.preference.universalaccess"
+ display dialog "UI element scripting is not enabled. Check \"Enable access for assistive devices\""
+ end tell
+ end if
+end tell
+tell application "Finder"
+ activate
+end tell
+
+tell application "System Events"
+ if UI elements enabled then
+ click menu item "Automatic" of menu "Location" of menu item "Location" of menu "Apple" of menu bar 1 of process "Finder"
+ else
+ tell application "System Preferences"
+ activate
+ set current pane to pane "com.apple.preference.universalaccess"
+ display dialog "UI element scripting is not enabled. Check \"Enable access for assistive devices\""
+ end tell
+ end if
+end tell
+tell application "System Preferences"
+ activate
+ set current pane to pane "com.apple.preference.sound"
+end tell
+
+tell application "System Events"
+ if UI elements enabled then
+ tell slider 1 of group 1 of window 1 of process "System Preferences"
+ if value is 0.5 then
+ set value to 0.8
+ else
+ set value to 0.5
+ end if
+ end tell
+ else
+ tell application "System Preferences"
+ activate
+ set current pane to pane "com.apple.preference.universalaccess"
+ display dialog "UI element scripting is not enabled. Check \"Enable access for assistive devices\""
+ end tell
+ end if
+end tell
+(**
+ * filename: MailFile.applescript
+ * created : Tue Feb 11 14:24:40 2003
+ * LastEditDate Was "Fri Oct 22 10:17:12 2004"
+ *
+ *)
+
+on sendfileviaemail(emailer, filenames)
+ (* Part that does all of the work, this works for Mail *)
+ if (emailer is equal to "com.apple.mail") then
+ tell application "Mail"
+ -- Properties can be specified in a record when creating the message or
+ -- afterwards by setting individual property values.
+ set newMessage to make new outgoing message
+ tell newMessage
+ set visible to true
+ tell content
+ -- Position must be specified for attachments
+ repeat with filename in filenames
+ make new attachment with properties {file name:filename} at after the last paragraph
+ end repeat
+ end tell
+ end tell
+ end tell
+ activate
+ else
+ if (emailer is equal to "com.microsoft.entourage") then
+ (* lots of stuff for entourage here *)
+ end if
+ end if
+end sendfileviaemail
+
+-- sendfileviaemail("com.apple.mail", "array of files/tmp/foo.vcf")
diff --git a/etc/todo/example.lua b/etc/todo/example.lua
new file mode 100644
index 0000000..9d9a404
--- /dev/null
+++ b/etc/todo/example.lua
@@ -0,0 +1,8289 @@
+
+-------------------------------------------------------------------------------
+-- Creates a new function, with the name suffixed by "New". This new function
+-- creates a new image, based on a source image, and calls the previous function
+-- with this new image.
+
+local function OneSourceOneDest (funcname, width, height, color_space, data_type)
+ local func = im[funcname]
+ assert(func) -- see if function is really defined
+
+ -- define function with "New" suffix
+ im[funcname.."New"] = function (src_image, ...)
+ -- create destination image
+ local dst_image = im.ImageCreateBased(src_image, width, height, color_space, data_type)
+
+ -- call previous method, repassing all parameters
+ func(src_image, dst_image, unpack(arg))
+ return dst_image
+ end
+end
+
+-------------------------------------------------------------------------------
+-- This function is similar to OneSourceOneDest, but it receives two source
+-- images.
+
+local function TwoSourcesOneDest (funcname, width, height, color_space, data_type)
+ local func = im[funcname]
+
+ -- see if function is really defined
+ assert(func, string.format("undefined function `%s'", funcname))
+
+ -- define function with "New" suffix
+ im[funcname.."New"] = function (src_image1, src_image2, ...)
+ -- create destination image
+ local dst_image = im.ImageCreateBased(src_image1, width, height, color_space, data_type)
+
+ -- call previous method, repassing all parameters
+ func(src_image1, src_image2, dst_image, unpack(arg))
+ return dst_image
+ end
+end
+
+-------------------------------------------------------------------------------
+
+TwoSourcesOneDest("ProcessCrossCorrelation")
+OneSourceOneDest("ProcessAutoCorrelation", nil, nil, nil, im.CFLOAT)
+OneSourceOneDest("ProcessFFT")
+OneSourceOneDest("ProcessIFFT")
+
+-------------------------------------------------------------------------------
+-- Creates a new function, with the name suffixed by "New". This new function
+-- creates a new image, based on a source image, and calls the previous function
+-- with this new image.
+-- We assume here that the functions returns only one parameter or none.
+
+local function OneSourceOneDest (funcname, width, height, color_space, data_type)
+ local func = im[funcname]
+ assert(func) -- see if function is really defined
+
+ -- define function with "New" suffix
+ im[funcname.."New"] = function (src_image, ...)
+ -- create destination image
+ local dst_image = im.ImageCreateBased(src_image, width, height, color_space, data_type)
+
+ -- call previous method, repassing all parameters
+ local ret = func(src_image, dst_image, unpack(arg))
+ if (ret) then
+ return ret, dst_image
+ else
+ return dst_image
+ end
+ end
+end
+
+-------------------------------------------------------------------------------
+-- This function is similar to OneSourceOneDest, but it receives two source
+-- images.
+
+local function TwoSourcesOneDest (funcname, width, height, color_space, data_type)
+ local func = im[funcname]
+
+ -- see if function is really defined
+ assert(func, string.format("undefined function `%s'", funcname))
+
+ -- define function with "New" suffix
+ im[funcname.."New"] = function (src_image1, src_image2, ...)
+ -- create destination image
+ local dst_image = im.ImageCreateBased(src_image1, width, height, color_space, data_type)
+
+ -- call previous method, repassing all parameters
+ local ret = func(src_image1, src_image2, dst_image, unpack(arg))
+ if (ret) then
+ return ret, dst_image
+ else
+ return dst_image
+ end
+ end
+end
+
+-------------------------------------------------------------------------------
+-- This function is similar to OneSourceOneDest, but it receives three source
+-- images.
+
+local function ThreeSourcesOneDest (funcname, width, height, color_space, data_type)
+ local func = im[funcname]
+ assert(func) -- see if function is really defined
+
+ -- define function with "New" suffix
+ im[funcname.."New"] = function (src_image1, src_image2, src_image3, ...)
+ -- create destination image
+ local dst_image = im.ImageCreateBased(src_image1, width, height, color_space, data_type)
+
+ -- call previous method, repassing all parameters
+ local ret = func(src_image1, src_image2, src_image3, dst_image, unpack(arg))
+ if (ret) then
+ return ret, dst_image
+ else
+ return dst_image
+ end
+ end
+end
+
+-------------------------------------------------------------------------------
+-- This function is similar to OneSourceOneDest, but it creates two destiny
+-- images.
+
+local function OneSourceTwoDests (funcname, width, height, color_space, data_type)
+ local func = im[funcname]
+ assert(func) -- see if function is really defined
+
+ -- define function with "New" suffix
+ im[funcname.."New"] = function (src_image, ...)
+ -- create destination image
+ local dst_image1 = im.ImageCreateBased(src_image, width, height, color_space, data_type)
+ local dst_image2 = im.ImageCreateBased(src_image, width, height, color_space, data_type)
+
+ -- call previous method, repassing all parameters
+ local ret = func(src_image, dst_image1, dst_image2, unpack(arg))
+ if (ret) then
+ return ret, dst_image1, dst_image2
+ else
+ return dst_image1, dst_image2
+ end
+ end
+end
+
+-------------------------------------------------------------------------------
+-- This function is similar to OneSourceOneDest, but it creates three destiny
+-- images.
+
+local function OneSourceThreeDests (funcname, width, height, color_space, data_type)
+ local func = im[funcname]
+ assert(func) -- see if function is really defined
+
+ -- define function with "New" suffix
+ im[funcname.."New"] = function (src_image, ...)
+ -- create destination image
+ local dst_image1 = im.ImageCreateBased(src_image, width, height, color_space, data_type)
+ local dst_image2 = im.ImageCreateBased(src_image, width, height, color_space, data_type)
+ local dst_image3 = im.ImageCreateBased(src_image, width, height, color_space, data_type)
+
+ -- call previous method, repassing all parameters
+ local ret = func(src_image, dst_image1, dst_image2, dst_image3, unpack(arg))
+ if (ret) then
+ return ret, dst_image1, dst_image2, dst_image3
+ else
+ return dst_image1, dst_image2, dst_image3
+ end
+ end
+end
+
+-------------------------------------------------------------------------------
+
+local function hough_height(image)
+ local function sqr(x) return x*x end
+ local rmax = math.sqrt(sqr(image:Width()) + sqr(image:Height())) / 2
+ return 2*rmax+1
+end
+
+OneSourceOneDest("AnalyzeFindRegions", nil, nil, nil, im.USHORT)
+OneSourceOneDest("ProcessPerimeterLine")
+OneSourceOneDest("ProcessPrune")
+OneSourceOneDest("ProcessFillHoles")
+OneSourceOneDest("ProcessHoughLines", 180, hough_height, im.GRAY, im.INT)
+OneSourceOneDest("ProcessHoughLinesDraw")
+OneSourceOneDest("ProcessDistanceTransform", nil, nil, nil, im.FLOAT)
+OneSourceOneDest("ProcessRegionalMaximum", nil, nil, im.BINARY, nil)
+
+function im.ProcessReduceNew (src_image, width, height)
+ local dst_image = im.ImageCreateBased(src_image, width, height)
+ return im.ProcessReduce(src_image, dst_image), dst_image
+end
+
+function im.ProcessResizeNew (src_image, width, height)
+ local dst_image = im.ImageCreateBased(src_image, width, height)
+ return im.ProcessResize(src_image, dst_image), dst_image
+end
+
+OneSourceOneDest("ProcessReduceBy4", function (image) return image:Width() / 2 end,
+ function (image) return image:Height() / 2 end)
+
+function im.ProcessCropNew (src_image, xmin, xmax, ymin, ymax)
+ local width = xmax - xmin + 1
+ local height = xmax - ymin + 1
+ local dst_image = im.ImageCreateBased(src_image, width, height)
+ im.ProcessCrop(src_image, dst_image, xmin, ymin)
+ return dst_image
+end
+
+TwoSourcesOneDest("ProcessInsert")
+
+function im.ProcessAddMarginsNew (src_image, xmin, xmax, ymin, ymax)
+ local width = xmax - xmin + 1
+ local height = xmax - ymin + 1
+ local dst_image = im.ImageCreateBased(src_image, width, height)
+ im.ProcessAddMargins(src_image, dst_image, xmin, ymin)
+ return dst_image
+end
+
+function im.ProcessRotateNew (src_image, cos0, sin0, order)
+ local width, height = im.ProcessCalcRotateSize(src_image:Width(), src_image:Height(), cos0, sin0)
+ local dst_image = im.ImageCreateBased(src_image, width, height)
+ return im.ProcessRotate(src_image, dst_image, cos0, sin0, order), dst_image
+end
+
+OneSourceOneDest("ProcessRotateRef")
+OneSourceOneDest("ProcessRotate90", function (image) return image:Height() end, function (image) return image:Width() end)
+OneSourceOneDest("ProcessRotate180")
+OneSourceOneDest("ProcessMirror")
+OneSourceOneDest("ProcessFlip")
+OneSourceOneDest("ProcessRadial")
+OneSourceOneDest("ProcessGrayMorphConvolve")
+OneSourceOneDest("ProcessGrayMorphErode")
+OneSourceOneDest("ProcessGrayMorphDilate")
+OneSourceOneDest("ProcessGrayMorphOpen")
+OneSourceOneDest("ProcessGrayMorphClose")
+OneSourceOneDest("ProcessGrayMorphTopHat")
+OneSourceOneDest("ProcessGrayMorphWell")
+OneSourceOneDest("ProcessGrayMorphGradient")
+OneSourceOneDest("ProcessBinMorphConvolve")
+OneSourceOneDest("ProcessBinMorphErode")
+OneSourceOneDest("ProcessBinMorphDilate")
+OneSourceOneDest("ProcessBinMorphOpen")
+OneSourceOneDest("ProcessBinMorphClose")
+OneSourceOneDest("ProcessBinMorphOutline")
+OneSourceOneDest("ProcessBinMorphThin")
+OneSourceOneDest("ProcessMedianConvolve")
+OneSourceOneDest("ProcessRangeConvolve")
+OneSourceOneDest("ProcessRankClosestConvolve")
+OneSourceOneDest("ProcessRankMaxConvolve")
+OneSourceOneDest("ProcessRankMinConvolve")
+OneSourceOneDest("ProcessConvolve")
+OneSourceOneDest("ProcessConvolveSep")
+OneSourceOneDest("ProcessConvolveRep")
+OneSourceOneDest("ProcessConvolveDual")
+OneSourceOneDest("ProcessCompassConvolve")
+OneSourceOneDest("ProcessMeanConvolve")
+OneSourceOneDest("ProcessGaussianConvolve")
+OneSourceOneDest("ProcessBarlettConvolve")
+OneSourceTwoDests("ProcessInterlaceSplit", nil, function (image) if (image:Height()) then return image:Height() else return image:Height()/2 end end)
+
+function im.ProcessInterlaceSplitNew(src_image)
+ -- create destination image
+ local dst_height1 = src_image:Height()/2
+ if math.mod(src_image:Height(), 2) then
+ dst_height1 = dst_height1 + 1
+ end
+
+ local dst_image1 = im.ImageCreateBased(src_image, nil, dst_height1)
+ local dst_image2 = im.ImageCreateBased(src_image, nil, src_image:Height()/2)
+
+ -- call method, repassing all parameters
+ im.ProcessInterlaceSplit(src_image, dst_image1, dst_image2)
+ return dst_image1, dst_image2
+end
+
+local function int_datatype (image)
+ local data_type = image:DataType()
+ if data_type == im.BYTE or data_type == im.USHORT then
+ data_type = im.INT
+ end
+ return data_type
+end
+
+OneSourceOneDest("ProcessDiffOfGaussianConvolve", nil, nil, nil, int_datatype)
+OneSourceOneDest("ProcessLapOfGaussianConvolve", nil, nil, nil, int_datatype)
+OneSourceOneDest("ProcessSobelConvolve")
+OneSourceOneDest("ProcessSplineEdgeConvolve")
+OneSourceOneDest("ProcessPrewittConvolve")
+OneSourceOneDest("ProcessZeroCrossing")
+OneSourceOneDest("ProcessCanny")
+OneSourceOneDest("ProcessUnArithmeticOp")
+TwoSourcesOneDest("ProcessArithmeticOp")
+
+function im.ProcessArithmeticConstOpNew (src_image, src_const, op)
+ local dst_image = im.ImageCreateBased(src_image)
+ im.ProcessArithmeticConstOp(src_image, src_const, dst_image, op)
+ return dst_image
+end
+
+TwoSourcesOneDest("ProcessBlendConst")
+ThreeSourcesOneDest("ProcessBlend")
+OneSourceTwoDests("ProcessSplitComplex")
+TwoSourcesOneDest("ProcessMergeComplex", nil, nil, nil, im.CFLOAT)
+
+function im.ProcessMultipleMeanNew (src_image_list, dst_image)
+ local dst_image = im.ImageCreateBased(src_image_list[1])
+ im.ProcessMultipleMean(src_image_list, dst_image)
+ return dst_image
+end
+
+function im.ProcessMultipleStdDevNew (src_image_list, mean_image)
+ local dst_image = im.ImageCreateBased(src_image_list[1])
+ im.ProcessMultipleStdDev(src_image_list, mean_image, dst_image)
+ return dst_image
+end
+
+TwoSourcesOneDest("ProcessAutoCovariance")
+OneSourceOneDest("ProcessMultiplyConj")
+OneSourceOneDest("ProcessQuantizeRGBUniform", nil, nil, im.MAP, nil)
+OneSourceOneDest("ProcessQuantizeGrayUniform")
+OneSourceOneDest("ProcessExpandHistogram")
+OneSourceOneDest("ProcessEqualizeHistogram")
+
+function im.ProcessSplitYChromaNew (src_image)
+ local y_image = im.ImageCreateBased(src_image, nil, nil, im.GRAY, im.BYTE)
+ local chroma_image = im.ImageCreateBased(src_image, nil, nil, im.RGB, im.BYTE)
+ im.ProcessSplitYChroma(src_image, y_image, chroma_image)
+ return y_image, chroma_image
+end
+
+OneSourceThreeDests("ProcessSplitHSI", nil, nil, im.GRAY, im.FLOAT)
+ThreeSourcesOneDest("ProcessMergeHSI", nil, nil, im.RGB, im.BYTE)
+
+function im.ProcessSplitComponentsNew (src_image)
+ local depth = src_image:Depth()
+ local dst_images = {}
+ for i = 1, depth do
+ table.insert(dst_images, im.ImageCreateBased(src_image, nil, nil, im.GRAY))
+ end
+ im.ProcessSplitComponents(src_image, dst_images)
+ return unpack(dst_images)
+end
+
+function im.ProcessMergeComponentsNew (src_image_list)
+ local dst_image = im.ImageCreateBased(src_image_list[1], nil, nil, im.RGB)
+ im.ProcessMergeComponents(src_image_list, dst_image)
+ return dst_image
+end
+
+OneSourceOneDest("ProcessNormalizeComponents", nil, nil, nil, im.FLOAT)
+OneSourceOneDest("ProcessReplaceColor")
+TwoSourcesOneDest("ProcessBitwiseOp")
+OneSourceOneDest("ProcessBitwiseNot")
+OneSourceOneDest("ProcessBitMask")
+OneSourceOneDest("ProcessBitPlane")
+OneSourceOneDest("ProcessToneGamut")
+OneSourceOneDest("ProcessUnNormalize", nil, nil, nil, im.BYTE)
+OneSourceOneDest("ProcessDirectConv", nil, nil, nil, im.BYTE)
+OneSourceOneDest("ProcessNegative")
+OneSourceOneDest("ProcessRangeContrastThreshold", nil, nil, im.BINARY, nil)
+OneSourceOneDest("ProcessLocalMaxThreshold", nil, nil, im.BINARY, nil)
+OneSourceOneDest("ProcessThreshold", nil, nil, im.BINARY, nil)
+TwoSourcesOneDest("ProcessThresholdByDiff")
+OneSourceOneDest("ProcessHysteresisThreshold", nil, nil, im.BINARY, nil)
+OneSourceOneDest("ProcessUniformErrThreshold", nil, nil, im.BINARY, nil)
+OneSourceOneDest("ProcessDifusionErrThreshold")
+OneSourceOneDest("ProcessPercentThreshold")
+OneSourceOneDest("ProcessOtsuThreshold")
+OneSourceOneDest("ProcessMinMaxThreshold", nil, nil, im.BINARY, nil)
+OneSourceOneDest("ProcessSliceThreshold", nil, nil, im.BINARY, nil)
+OneSourceOneDest("ProcessPixelate")
+OneSourceOneDest("ProcessPosterize")
+
+----------------------------------------------------
+-- The main porpouse of this file is to build linux gcc makefiles.
+-- Must have Premake version 3 installed.
+-- Original Premake was changed to remove some parameters and add others.
+-- Default parameters:
+-- premake3s --target gnu --os linux
+-- But it can build windows gcc makefiles, and visual studio projects.
+-- premake3s --target gnu --os windows
+-- premake3s --target gnu --os macosx
+-- premake3s --target vs6
+-- premake3s --target vs2002
+-- premake3s --target vs2003
+-- premake3s --target vs2005
+-- In Linux the generated makefiles will not correctly build libraries in 64-bits.
+-- must add "-m64 -fPIC" flags
+----------------------------------------------------
+
+if (not options.target) then
+ options.target = "gnu"
+end
+
+if (not options.os) then
+ if (options.target ~= "gnu") then
+ options.os = "windows"
+ else
+ options.os = "linux"
+ end
+end
+
+function fixPackagePath(package_files)
+ if (options.os ~= "linux") then
+ for i, file in package_files do
+ package_files[i] = "../src/"..file
+ end
+ end
+end
+
+----------------------------------------------------
+
+project.name = "im"
+project.bindir = "../bin"
+project.libdir = "../lib"
+
+if (options.os ~= "linux") then
+ if (options.os == "macosx") then
+ project.path = "../mak.macosx"
+ else
+ project.path = "../mak."..options.target
+ end
+end
+
+----------------------------------------------------
+
+package = newpackage()
+package.name = "im"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ matchfiles("libtiff/*.c"),
+ matchfiles("libjpeg/*.c"),
+ matchfiles("liblzf/*.c"),
+ matchfiles("zlib/*.c"),
+ "libpng/png.c", "libpng/pngget.c", "libpng/pngread.c", "libpng/pngrutil.c", "libpng/pngwtran.c",
+ "libpng/pngerror.c", "libpng/pngmem.c", "libpng/pngrio.c", "libpng/pngset.c", "libpng/pngwio.c",
+ "libpng/pngpread.c", "libpng/pngrtran.c", "libpng/pngtrans.c", "libpng/pngwrite.c", "libpng/pngwutil.c",
+ matchfiles("libexif/canon/*.c"),
+ matchfiles("libexif/olympus/*.c"),
+ matchfiles("libexif/pentax/*.c"),
+ matchfiles("libexif/*.c"),
+ "old_imcolor.c", "old_imresize.c", "tiff_binfile.c", "im_converttype.cpp",
+ "im_attrib.cpp", "im_format.cpp", "im_format_tga.cpp", "im_filebuffer.cpp",
+ "im_bin.cpp", "im_format_all.cpp", "im_format_tiff.cpp", "im_format_raw.cpp",
+ "im_binfile.cpp", "im_format_sgi.cpp", "im_datatype.cpp", "im_format_pcx.cpp",
+ "im_colorhsi.cpp", "im_format_bmp.cpp", "im_image.cpp", "im_rgb2map.cpp",
+ "im_colormode.cpp", "im_format_gif.cpp", "im_lib.cpp", "im_format_pnm.cpp",
+ "im_colorutil.cpp", "im_format_ico.cpp", "im_palette.cpp", "im_format_png.cpp",
+ "im_convertbitmap.cpp", "im_format_led.cpp", "im_counter.cpp", "im_str.cpp",
+ "im_convertcolor.cpp", "im_format_jpeg.cpp", "im_fileraw.cpp", "im_format_krn.cpp",
+ "im_file.cpp", "im_format_ras.cpp", "old_im.cpp", "im_compress.cpp",
+}
+
+package.includepaths = { ".", "../include", "libtiff", "libjpeg", "libexif", "libpng", "zlib" }
+package.defines = { "JPEG_SUPPORT", "ZIP_SUPPORT", "OJPEG_SUPPORT", "PIXARLOG_SUPPORT", "PNG_NO_STDIO", "PNG_TIME_RFC1123_SUPPORTED" }
+
+if (options.os == "windows") then
+ tinsert(package.files, {"im_sysfile_win32.cpp", "im_dib.cpp", "im_dibxbitmap.cpp"})
+
+ if (options.target ~= "gnu") then
+ -- optimize PNG lib for VC
+ tinsert(package.files, "libpng/pngvcrd.c")
+ tinsert(package.defines, "PNG_USE_PNGVCRD")
+ end
+else
+ tinsert(package.files, "im_sysfile_unix.cpp")
+
+ if (options.os == "linux") then
+ --package.buildoptions = { "-W -Wall -ansi -pedantic" }
+
+ -- optimize PNG lib for Linux in x86
+ tinsert(package.files, "libpng/pnggccrd.c")
+ tinsert(package.defines, "PNG_USE_PNGGCCRD")
+ end
+end
+
+fixPackagePath(package.files)
+
+---------------------------------------------------------------------
+
+package = newpackage()
+package.name = "im_process"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ "process/im_arithmetic_bin.cpp", "process/im_morphology_gray.cpp", "process/im_quantize.cpp",
+ "process/im_arithmetic_un.cpp", "process/im_geometric.cpp", "process/im_render.cpp",
+ "process/im_color.cpp", "process/im_histogram.cpp", "process/im_resize.cpp",
+ "process/im_convolve.cpp", "process/im_houghline.cpp", "process/im_statistics.cpp",
+ "process/im_convolve_rank.cpp", "process/im_logic.cpp", "process/im_threshold.cpp",
+ "process/im_effects.cpp", "process/im_morphology_bin.cpp", "process/im_tonegamut.cpp",
+ "process/im_canny.cpp", "process/im_distance.cpp", "process/im_analyze.cpp"
+}
+fixPackagePath(package.files)
+
+package.includepaths = { "../include" }
+
+---------------------------------------------------------------------
+
+package = newpackage()
+package.name = "im_jp2"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ matchfiles("libjasper/base/*.c", "libjasper/jp2/*.c", "libjasper/jpc/*.c"),
+ "jas_binfile.c", "im_format_jp2.cpp"
+}
+fixPackagePath(package.files)
+
+package.includepaths = { "../include", "libjasper" }
+package.defines = { "EXCLUDE_JPG_SUPPORT", "EXCLUDE_MIF_SUPPORT", "EXCLUDE_PNM_SUPPORT",
+ "EXCLUDE_BMP_SUPPORT", "EXCLUDE_PGX_SUPPORT", "EXCLUDE_RAS_SUPPORT",
+ "EXCLUDE_TIFF_SUPPORT", "JAS_GEO_OMIT_PRINTING_CODE" }
+
+tinsert(package.defines, "JAS_TYPES")
+
+if (options.os == "linux") then
+ tinsert(package.defines, "HAVE_UNISTD_H")
+end
+
+---------------------------------------------------------------------
+
+package = newpackage()
+package.name = "imlua3"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ "im_lua3.c"
+}
+fixPackagePath(package.files)
+
+package.includepaths = { "../include", "$(LUA3)/include", "$(CD)/include" }
+
+---------------------------------------------------------------------
+
+package = newpackage()
+package.name = "im_fftw"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ matchfiles("fftw/*.c"),
+ "process/im_fft.cpp"
+}
+fixPackagePath(package.files)
+
+package.includepaths = { "../include", "fftw" }
+package.defines = { "FFTW_ENABLE_FLOAT" }
+
+---------------------------------------------------------------------
+
+package = newpackage()
+package.name = "im_fftw3"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ matchfiles("fftw3/api/*.c"),
+ matchfiles("fftw3/reodft/*.c"),
+ matchfiles("fftw3/kernel/*.c"),
+ matchfiles("fftw3/dft/*.c", "fftw3/dft/codelets/*.c", "fftw3/dft/codelets/inplace/*.c", "fftw3/dft/codelets/standard/*.c"),
+ matchfiles("fftw3/rdft/*.c", "fftw3/rdft/codelets/*.c", "fftw3/rdft/codelets/hc2r/*.c", "fftw3/rdft/codelets/r2hc/*.c", "fftw3/rdft/codelets/r2r/*.c"),
+ "process/im_fft.cpp"
+}
+fixPackagePath(package.files)
+
+package.includepaths = { "../include", "fftw3/kernel", "fftw3/dft", "fftw3/rdft", "fftw3/api",
+ "fftw3/reodft", "fftw3/rdft/codelets", "fftw3/dft/codelets" }
+package.defines = { "USE_FFTW3" }
+
+if (options.os == "windows") then
+ if (options.target == "gnu") then
+ tinsert(package.defines, "HAVE_UINTPTR_T")
+ end
+end
+
+---------------------------------------------------------------------
+
+package = newpackage()
+package.name = "imlua51"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ "lua5/imlua.c", "lua5/imlua_aux.c", "lua5/imlua_convert.c", "lua5/imlua_file.c",
+ "lua5/imlua_image.c", "lua5/imlua_palette.c", "lua5/imlua_util.c"
+}
+fixPackagePath(package.files)
+
+package.includepaths = { "../include", "lua5", "$(LUA51)/include" }
+
+---------------------------------------------------------------------
+
+package = newpackage()
+package.name = "imlua_cd51"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ "lua5/imlua_cd.c"
+}
+fixPackagePath(package.files)
+
+package.includepaths = { "../include", "lua5", "$(LUA51)/include", "$(CD)/include" }
+
+---------------------------------------------------------------------
+
+package = newpackage()
+package.name = "imlua_process51"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ "lua5/imlua_process.c"
+}
+fixPackagePath(package.files)
+
+package.includepaths = { "../include", "lua5", "$(LUA51)/include" }
+
+---------------------------------------------------------------------
+
+package = newpackage()
+package.name = "imlua_capture51"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ "lua5/imlua_capture.c"
+}
+fixPackagePath(package.files)
+
+package.includepaths = { "../include", "lua5", "$(LUA51)/include" }
+
+---------------------------------------------------------------------
+
+package = newpackage()
+package.name = "imlua_fftw51"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ "lua5/imlua_fftw.c"
+}
+fixPackagePath(package.files)
+
+package.includepaths = { "../include", "lua5", "$(LUA51)/include" }
+
+---------------------------------------------------------------------
+----------------------------------------------------
+-- The main porpouse of this file is to build linux gcc makefiles.
+-- Must have Premake version 3 installed.
+-- Original Premake was changed to remove some parameters and add others.
+-- Default parameters:
+-- premake3s --target gnu --os linux
+-- But it can build windows gcc makefiles, and visual studio projects.
+-- premake3s --target gnu --os windows
+-- premake3s --target gnu --os macosx
+-- premake3s --target vs6
+-- premake3s --target vs2002
+-- premake3s --target vs2003
+-- premake3s --target vs2005
+-- In Linux the generated makefiles will not correctly build libraries in 64-bits.
+-- must add "-m64 -fPIC" flags
+----------------------------------------------------
+
+if (not options.target) then
+ options.target = "gnu"
+end
+
+if (not options.os) then
+ if (options.target ~= "gnu") then
+ options.os = "windows"
+ else
+ options.os = "linux"
+ end
+end
+
+function fixPackagePath(package_files)
+ if (options.os ~= "linux") then
+ for i, file in package_files do
+ package_files[i] = "../src/"..file
+ end
+ end
+end
+
+function tremove(t, value)
+ local index = -1
+ function f(i, v)
+ if (v == value) then
+ index = i
+ end
+ end
+ table.foreachi(t, f)
+ if (index ~= -1) then
+ table.remove(t, index)
+ end
+end
+
+----------------------------------------------------
+
+project.name = "iup"
+project.bindir = "../bin"
+project.libdir = "../lib"
+
+if (options.os ~= "linux") then
+ if (options.os == "macosx") then
+ project.path = "../mak.macosx"
+ else
+ project.path = "../mak."..options.target
+ end
+end
+
+----------------------------------------------------
+
+package = newpackage()
+package.name = "iup"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ matchfiles("*.c")
+}
+
+package.includepaths = { ".", "../include" }
+
+if (options.os == "windows") then
+ tinsert(package.files, matchfiles("win/*.c"))
+ tinsert(package.includepaths, {"win"})
+ package.defines = {"_WIN32_WINNT=0x0400"}
+else
+ tinsert(package.files, matchfiles("mot/*.c"))
+ tremove(package.files[2], "mot/ComboBox1.c")
+ tinsert(package.includepaths, {"mot", "/usr/X11R6/include"})
+ package.defines = {"LINUX"}
+end
+
+fixPackagePath(package.files)
+
+----------------------------------------------------
+----------------------------------------------------
+-- The main porpouse of this file is to build linux gcc makefiles.
+-- Must have Premake version 3 installed.
+-- Original Premake was changed to remove some parameters and add others.
+-- Default parameters:
+-- premake3s --target gnu --os linux
+-- But it can build windows gcc makefiles, and visual studio projects.
+-- premake3s --target gnu --os windows
+-- premake3s --target gnu --os macosx
+-- premake3s --target vs6
+-- premake3s --target vs2002
+-- premake3s --target vs2003
+-- premake3s --target vs2005
+-- In Linux the generated makefiles will not correctly build libraries in 64-bits.
+-- must add "-m64 -fPIC" flags
+----------------------------------------------------
+
+if (not options.target) then
+ options.target = "gnu"
+end
+
+if (not options.os) then
+ if (options.target ~= "gnu") then
+ options.os = "windows"
+ else
+ options.os = "linux"
+ end
+end
+
+function fixPackagePath(package_files)
+ if (options.os ~= "linux") then
+ for i, file in package_files do
+ package_files[i] = "../src/"..file
+ end
+ end
+end
+
+----------------------------------------------------
+
+project.name = "iup"
+project.bindir = "../bin"
+project.libdir = "../lib"
+
+if (options.os ~= "linux") then
+ if (options.os == "macosx") then
+ project.path = "../mak.macosx"
+ else
+ project.path = "../mak."..options.target
+ end
+end
+
+----------------------------------------------------
+
+package = newpackage()
+package.name = "iupcontrols"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ matchfiles("*.c"),
+ matchfiles("mask/*.c"),
+ matchfiles("matrix/*.c"),
+ matchfiles("tree/*.c"),
+ matchfiles("color/*.c")
+}
+
+package.includepaths = { ".", "../include", "../src", "$(CD)/include" }
+
+if (options.os == "linux") then
+ package.defines = { "_MOTIF_" }
+ tinsert(package.includepaths, {"/usr/X11R6/include"})
+end
+
+fixPackagePath(package.files)
+
+----------------------------------------------------
+----------------------------------------------------
+-- The main porpouse of this file is to build linux gcc makefiles.
+-- Must have Premake version 3 installed.
+-- Original Premake was changed to remove some parameters and add others.
+-- Default parameters:
+-- premake3s --target gnu --os linux
+-- But it can build windows gcc makefiles, and visual studio projects.
+-- premake3s --target gnu --os windows
+-- premake3s --target gnu --os macosx
+-- premake3s --target vs6
+-- premake3s --target vs2002
+-- premake3s --target vs2003
+-- premake3s --target vs2005
+-- In Linux the generated makefiles will not correctly build libraries in 64-bits.
+-- must add "-m64 -fPIC" flags
+----------------------------------------------------
+
+if (not options.target) then
+ options.target = "gnu"
+end
+
+if (not options.os) then
+ if (options.target ~= "gnu") then
+ options.os = "windows"
+ else
+ options.os = "linux"
+ end
+end
+
+function fixPackagePath(package_files)
+ if (options.os ~= "linux") then
+ for i, file in package_files do
+ package_files[i] = "../src/"..file
+ end
+ end
+end
+
+----------------------------------------------------
+
+project.name = "iup"
+project.bindir = "../bin"
+project.libdir = "../lib"
+
+if (options.os ~= "linux") then
+ if (options.os == "macosx") then
+ project.path = "../mak.macosx"
+ else
+ project.path = "../mak."..options.target
+ end
+end
+
+----------------------------------------------------
+
+package = newpackage()
+package.name = "iupgl"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.includepaths = { ".", "../include" }
+
+if (options.os == "windows") then
+ package.files = { "iupglw.c" }
+else
+ package.files = { "iupglx.c", "GL/GLwMDrawA.c" }
+ tinsert(package.includepaths, {"/usr/X11R6/include"})
+end
+
+fixPackagePath(package.files)
+
+----------------------------------------------------
+----------------------------------------------------
+-- The main porpouse of this file is to build linux gcc makefiles.
+-- Must have Premake version 3 installed.
+-- Original Premake was changed to remove some parameters and add others.
+-- Default parameters:
+-- premake3s --target gnu --os linux
+-- But it can build windows gcc makefiles, and visual studio projects.
+-- premake3s --target gnu --os windows
+-- premake3s --target gnu --os macosx
+-- premake3s --target vs6
+-- premake3s --target vs2002
+-- premake3s --target vs2003
+-- premake3s --target vs2005
+-- In Linux the generated makefiles will not correctly build libraries in 64-bits.
+-- must add "-m64 -fPIC" flags
+----------------------------------------------------
+
+if (not options.target) then
+ options.target = "gnu"
+end
+
+if (not options.os) then
+ if (options.target ~= "gnu") then
+ options.os = "windows"
+ else
+ options.os = "linux"
+ end
+end
+
+function fixPackagePath(package_files)
+ if (options.os ~= "linux") then
+ for i, file in package_files do
+ package_files[i] = "../src/"..file
+ end
+ end
+end
+
+----------------------------------------------------
+
+project.name = "iup"
+project.bindir = "../bin"
+project.libdir = "../lib"
+
+if (options.os ~= "linux") then
+ if (options.os == "macosx") then
+ project.path = "../mak.macosx"
+ else
+ project.path = "../mak."..options.target
+ end
+end
+
+----------------------------------------------------
+
+package = newpackage()
+package.name = "iupim"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.includepaths = { ".", "../include", "$(IM)/include" }
+
+package.files = { "iupim.c" }
+
+fixPackagePath(package.files)
+
+----------------------------------------------------
+----------------------------------------------------
+-- The main porpouse of this file is to build linux gcc makefiles.
+-- Must have Premake version 3 installed.
+-- Original Premake was changed to remove some parameters and add others.
+-- Default parameters:
+-- premake3s --target gnu --os linux
+-- But it can build windows gcc makefiles, and visual studio projects.
+-- premake3s --target gnu --os windows
+-- premake3s --target gnu --os macosx
+-- premake3s --target vs6
+-- premake3s --target vs2002
+-- premake3s --target vs2003
+-- premake3s --target vs2005
+-- In Linux the generated makefiles will not correctly build libraries in 64-bits.
+-- must add "-m64 -fPIC" flags
+----------------------------------------------------
+
+if (not options.target) then
+ options.target = "gnu"
+end
+
+if (not options.os) then
+ if (options.target ~= "gnu") then
+ options.os = "windows"
+ else
+ options.os = "linux"
+ end
+end
+
+function fixPackagePath(package_files)
+ if (options.os ~= "linux") then
+ for i, file in package_files do
+ package_files[i] = "../src/"..file
+ end
+ end
+end
+
+----------------------------------------------------
+
+project.name = "iup"
+project.bindir = "../bin"
+project.libdir = "../lib"
+
+if (options.os ~= "linux") then
+ if (options.os == "macosx") then
+ project.path = "../mak.macosx"
+ else
+ project.path = "../mak."..options.target
+ end
+end
+
+----------------------------------------------------
+
+package = newpackage()
+package.name = "ledc"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "exe"
+
+package.files =
+{
+ "lex.yy.c", "y.tab.c", "main.c"
+}
+
+package.includepaths = { "." }
+
+fixPackagePath(package.files)
+
+----------------------------------------------------
+-- Utilities
+
+function printvars()
+ local n,v = nextvar(nil)
+ print("--printvars Start--")
+ while n ~= nil do
+ print(tostring(n).."="..tostring(v))
+ n,v = nextvar(n)
+ end
+ print("--printvars End--")
+end
+
+function printtable(t)
+ local n,v = next(t, nil)
+ print("--printtable Start--")
+ while n ~= nil do
+ print(tostring(n).."="..tostring(v))
+ n,v = next(t, n)
+ end
+ print("--printtable End--")
+end
+
+function print_version_info()
+ print(_VERSION .. " " .. iup._LUA_COPYRIGHT)
+ if (im) then print(im._VERSION .. " " .. im._COPYRIGHT) end
+ if (cd and cd._VERSION) then print(cd._VERSION .. " " .. cd._COPYRIGHT) end
+ print(iup._VERSION .. " " .. iup._COPYRIGHT)
+ print("")
+ print("IUP Info")
+ print(" System: " .. iup.GetGlobal("SYSTEM"))
+ print(" System Version: " .. iup.GetGlobal("SYSTEMVERSION"))
+ local mot = iup.GetGlobal("MOTIFVERSION")
+ if (mot) then print(" Motif Version: ", mot) end
+ print(" Screen Size: " .. iup.GetGlobal("SCREENSIZE"))
+ print(" Screen Depth: " .. iup.GetGlobal("SCREENDEPTH"))
+ if (iup.GL_VENDOR) then print(" OpenGL Vendor: " .. iup.GL_VENDOR) end
+ if (iup.GL_RENDERER) then print(" OpenGL Renderer: " .. iup.GL_RENDERER) end
+ if (iup.GL_VERSION) then print(" OpenGL Version: " .. iup.GL_VERSION) end
+end
+
+-- IUPLUA Full Application
+
+lastfile = nil -- Last file open
+
+mulCommands = iupmultiline{expand=IUP_YES, size="200x120", font="COURIER_NORMAL_10"}
+poslabel = iuplabel{title="0:0", size="50x"}
+filelabel = iuplabel{title="", size="50x", expand="HORIZONTAL"}
+
+mulCommands.caretcb = function(self, lin, col)
+ poslabel.title = lin..":"..col
+end
+
+butExecute = iupbutton{size="50x15", title = "Execute", action="dostring(mulCommands.value)"}
+butClearCommands = iupbutton{size="50x15", title = "Clear", action = "mulCommands.value = '' filelabel.title = '' lastfile = nil"}
+butLoadFile = iupbutton{size="50x15", title = "Load..."}
+butSaveasFile = iupbutton{size="50x15", title = "Save As..."}
+butSaveFile = iupbutton{size="50x15", title = "Save"}
+
+function butSaveFile:action()
+ if (lastfile == nil) then
+ butSaveasFile:action()
+ else
+ novoarq = openfile (lastfile, "w+")
+ if (novoarq ~= nil) then
+ write (novoarq,mulCommands.value)
+ closefile (novoarq)
+ else
+ error ("Cannot Save file "..filename)
+ end
+ end
+end
+
+function butSaveasFile:action()
+ local filedlg = iupfiledlg{dialogtype = "SAVE", title = "Save File", filter = "*.lua", filterinfo = "Lua files",allownew=yes}
+ IupPopup(filedlg,IUP_LEFT, IUP_LEFT)
+ local status = filedlg.status
+ lastfile = filedlg.value
+ filelabel.title = lastfile
+ IupDestroy(filedlg)
+ if status ~= "-1" then
+ if (lastfile == nil) then
+ error ("Cannot Save file "..lastfile)
+ end
+ local novoarq = openfile (lastfile, "w+")
+ if (novoarq ~= nil) then
+ write (novoarq,mulCommands.value)
+ closefile (novoarq)
+ else
+ error ("Cannot Save file")
+ end
+ end
+end
+
+function butLoadFile:action()
+ local filedlg = iupfiledlg{dialogtype="OPEN", title="Load File", filter="*.lua", filterinfo="Lua Files", allownew="NO"}
+ filedlg:popup(IUP_CENTER, IUP_CENTER)
+ local status = filedlg.status
+ local newfile = filedlg.value
+ IupDestroy(filedlg)
+ if (status == "-1") or (status == "1") then
+ if (status == "1") then
+ error ("Cannot load file "..newfile)
+ end
+ else
+ local fp = openfile (newfile, "r")
+ if (fp == nil) then
+ error ("Cannot load file "..newfile)
+ else
+ mulCommands.value = read (fp,"*a")
+ closefile (fp)
+ lastfile = newfile
+ filelabel.title = lastfile
+ end
+ end
+end
+
+vbxConsole = iupvbox
+{
+ iupframe{iuphbox{iupvbox{butLoadFile, butSaveFile, butSaveasFile, butClearCommands, butExecute; margin="0x0", gap="10"}, iupvbox{filelabel, mulCommands, poslabel; alignment="ARIGHT"}; alignment="ATOP"}; title="Commands"}
+ ;alignment="ACENTER", margin="5x5", gap="5"
+}
+
+-- Main Menu Definition.
+
+mnuMain = iupmenu
+{
+ iupsubmenu
+ {
+ iupmenu
+ {
+ iupitem{title="Exit", action="return IUP_CLOSE"}
+ }; title="File"
+ },
+ iupsubmenu{iupmenu
+ {
+ iup.item{title="Print Version Info...", action=print_version_info},
+ iupitem{title="About...", action="dlgAbout:popup(IUP_CENTER, IUP_CENTER)"}
+ };title="Help"}
+}
+
+-- Main Dialog Definition.
+
+dlgMain = iupdialog{vbxConsole; title="Complete IupLua3 Interpreter", menu=mnuMain, close_cb = "return IUP_CLOSE"}
+
+-- About Dialog Definition.
+
+dlgAbout = iupdialog
+{
+ iupvbox
+ {
+ iuplabel{title="Complete IupLua3 Interpreter"},
+ iupfill{size="5"},
+ iupfill{size="5"},
+ iupframe
+ {
+ iupvbox
+ {
+ iuplabel{title="Tecgraf/PUC-Rio"},
+ iuplabel{title="Mark/Ovídio/Scuri"},
+ iuplabel{title="iup@tecgraf.puc-rio.br"}
+ }
+ },
+ iupfill{size="5"},
+ iupbutton{title="OK", action="return IUP_CLOSE", size="50X20"}
+ ;margin="10x10", alignment="ACENTER"
+ }
+ ;maxbox=IUP_NO, minbox=IUP_NO, resize=IUP_NO, title="About"
+}
+
+-- Displays the Main Dialog
+
+dlgMain:show()
+
+IupMainLoop()
+
+IupDestroy(dlgMain)
+IupDestroy(dlgAbout)
+
+-- #################################################################################
+-- Constants
+-- #################################################################################
+
+
+IUP_ERROR = 1 iup.ERROR = IUP_ERROR
+IUP_NOERROR = 0 iup.NOERROR = IUP_NOERROR
+IUP_OPENED = -1 iup.OPENED = IUP_OPENED
+IUP_INVALID = -1 iup.INVALID = IUP_INVALID
+
+IUP_CENTER = 65535 iup.CENTER = IUP_CENTER
+IUP_LEFT = 65534 iup.LEFT = IUP_LEFT
+IUP_RIGHT = 65533 iup.RIGHT = IUP_RIGHT
+IUP_MOUSEPOS = 65532 iup.MOUSEPOS = IUP_MOUSEPOS
+IUP_CURRENT = 65531 iup.CURRENT = IUP_CURRENT
+IUP_CENTERPARENT = 65530 iup.CENTERPARENT = IUP_CENTERPARENT
+IUP_TOP = IUP_LEFT iup.TOP = IUP_TOP
+IUP_BOTTOM = IUP_RIGHT iup.BOTTOM = IUP_BOTTOM
+IUP_ANYWHERE = IUP_CURRENT iup.ANYWHERE = IUP_ANYWHERE
+
+IUP_BUTTON1 = 49 iup.BUTTON1 = IUP_BUTTON1 -- '1'
+IUP_BUTTON2 = 50 iup.BUTTON2 = IUP_BUTTON2 -- '2'
+IUP_BUTTON3 = 51 iup.BUTTON3 = IUP_BUTTON3 -- '3'
+IUP_BUTTON4 = 52 iup.BUTTON4 = IUP_BUTTON4 -- '4'
+IUP_BUTTON5 = 53 iup.BUTTON5 = IUP_BUTTON5 -- '5'
+
+IUP_IGNORE = -1 iup.IGNORE = IUP_IGNORE
+IUP_DEFAULT = -2 iup.DEFAULT = IUP_DEFAULT
+IUP_CLOSE = -3 iup.CLOSE = IUP_CLOSE
+IUP_CONTINUE = -4 iup.CONTINUE = IUP_CONTINUE
+
+IUP_SBUP = 0 iup.SBUP = IUP_SBUP
+IUP_SBDN = 1 iup.SBDN = IUP_SBDN
+IUP_SBPGUP = 2 iup.SBPGUP = IUP_SBPGUP
+IUP_SBPGDN = 3 iup.SBPGDN = IUP_SBPGDN
+IUP_SBPOSV = 4 iup.SBPOSV = IUP_SBPOSV
+IUP_SBDRAGV = 5 iup.SBDRAGV = IUP_SBDRAGV
+IUP_SBLEFT = 6 iup.SBLEFT = IUP_SBLEFT
+IUP_SBRIGHT = 7 iup.SBRIGHT = IUP_SBRIGHT
+IUP_SBPGLEFT = 8 iup.SBPGLEFT = IUP_SBPGLEFT
+IUP_SBPGRIGHT = 9 iup.SBPGRIGHT = IUP_SBPGRIGHT
+IUP_SBPOSH = 10 iup.SBPOSH = IUP_SBPOSH
+IUP_SBDRAGH = 11 iup.SBDRAGH = IUP_SBDRAGH
+
+IUP_SHOW = 0 iup.SHOW = IUP_SHOW
+IUP_RESTORE = 1 iup.RESTORE = IUP_RESTORE
+IUP_MINIMIZE = 2 iup.MINIMIZE = IUP_MINIMIZE
+IUP_MAXIMIZE = 3 iup.MAXIMIZE = IUP_MAXIMIZE
+IUP_HIDE = 4 iup.HIDE = IUP_HIDE
+
+RED = IupRGB(1, 0, 0) iup.RED = RED
+GREEN = IupRGB(0, 1, 0) iup.GREEN = GREEN
+BLUE = IupRGB(0, 0, 1) iup.BLUE = BLUE
+BLACK = IupRGB(0, 0, 0) iup.BLACK = BLACK
+WHITE = IupRGB(1, 1, 1) iup.WHITE = WHITE
+YELLOW = IupRGB(1, 1, 0) iup.YELLOW = YELLOW
+
+IUP_ON = "ON" iup.ON = IUP_ON
+IUP_OFF = "OFF" iup.OFF = IUP_OFF
+IUP_YES = "YES" iup.YES = IUP_YES
+IUP_NO = "NO" iup.NO = IUP_NO
+IUP_APPEND = "APPEND" iup.APPEND = IUP_APPEND
+IUP_VERTICAL = "VERTICAL" iup.VERTICAL = IUP_VERTICAL
+IUP_HORIZONTAL ="HORIZONTAL" iup.HORIZONTAL =IUP_HORIZONTAL
+
+IUP_ACENTER = "ACENTER" iup.ACENTER = IUP_ACENTER
+IUP_ALEFT = "ALEFT" iup.ALEFT = IUP_ALEFT
+IUP_ARIGHT = "ARIGHT" iup.ARIGHT = IUP_ARIGHT
+IUP_ATOP = "ATOP" iup.ATOP = IUP_ATOP
+IUP_ABOTTOM = "ABOTTOM" iup.ABOTTOM = IUP_ABOTTOM
+
+IUP_NORTH = "NORTH" iup.NORTH = IUP_NORTH
+IUP_SOUTH = "SOUTH" iup.SOUTH = IUP_SOUTH
+IUP_WEST = "WEST" iup.WEST = IUP_WEST
+IUP_EAST = "EAST" iup.EAST = IUP_EAST
+IUP_NE = "NE" iup.NE = IUP_NE
+IUP_SE = "SE" iup.SE = IUP_SE
+IUP_NW = "NW" iup.NW = IUP_NW
+IUP_SW = "SW" iup.SW = IUP_SW
+
+IUP_FULL = "FULL" iup.FULL = IUP_FULL
+IUP_HALF = "HALF" iup.HALF = IUP_HALF
+IUP_THIRD = "THIRD" iup.THIRD = IUP_THIRD
+IUP_QUARTER = "QUARTER" iup.QUARTER = IUP_QUARTER
+IUP_EIGHTH = "EIGHTH" iup.EIGHTH = IUP_EIGHTH
+
+IUP_ARROW = "ARROW" iup.ARROW = IUP_ARROW
+IUP_BUSY = "BUSY" iup.BUSY = IUP_BUSY
+IUP_RESIZE_N = "RESIZE_N" iup.RESIZE_N = IUP_RESIZE_N
+IUP_RESIZE_S = "RESIZE_S" iup.RESIZE_S = IUP_RESIZE_S
+IUP_RESIZE_E = "RESIZE_E" iup.RESIZE_E = IUP_RESIZE_E
+IUP_RESIZE_W = "RESIZE_W" iup.RESIZE_W = IUP_RESIZE_W
+IUP_RESIZE_NE = "RESIZE_NE" iup.RESIZE_NE = IUP_RESIZE_NE
+IUP_RESIZE_NW = "RESIZE_NW" iup.RESIZE_NW = IUP_RESIZE_NW
+IUP_RESIZE_SE = "RESIZE_SE" iup.RESIZE_SE = IUP_RESIZE_SE
+IUP_RESIZE_SW = "RESIZE_SW" iup.RESIZE_SW = IUP_RESIZE_SW
+IUP_MOVE = "MOVE" iup.MOVE = IUP_MOVE
+IUP_HAND = "HAND" iup.HAND = IUP_HAND
+IUP_NONE = "NONE" iup.NONE = IUP_NONE
+IUP_IUP = "IUP" iup.IUP = IUP_IUP
+IUP_CROSS = "CROSS" iup.CROSS = IUP_CROSS
+IUP_PEN = "PEN" iup.PEN = IUP_PEN
+IUP_TEXT = "TEXT" iup.TEXT = IUP_TEXT
+IUP_RESIZE_C = "RESIZE_C" iup.RESIZE_C = IUP_RESIZE_C
+IUP_OPENHAND = "OPENHAND" iup.OPENHAND = IUP_OPENHAND
+
+IUP_HELVETICA_NORMAL_8 = "HELVETICA_NORMAL_8" iup.HELVETICA_NORMAL_8 = IUP_HELVETICA_NORMAL_8
+IUP_HELVETICA_ITALIC_8 = "HELVETICA_ITALIC_8" iup.HELVETICA_ITALIC_8 = IUP_HELVETICA_ITALIC_8
+IUP_HELVETICA_BOLD_8 = "HELVETICA_BOLD_8" iup.HELVETICA_BOLD_8 = IUP_HELVETICA_BOLD_8
+IUP_HELVETICA_NORMAL_10 = "HELVETICA_NORMAL_10" iup.HELVETICA_NORMAL_10 = IUP_HELVETICA_NORMAL_10
+IUP_HELVETICA_ITALIC_10 = "HELVETICA_ITALIC_10" iup.HELVETICA_ITALIC_10 = IUP_HELVETICA_ITALIC_10
+IUP_HELVETICA_BOLD_10 = "HELVETICA_BOLD_10" iup.HELVETICA_BOLD_10 = IUP_HELVETICA_BOLD_10
+IUP_HELVETICA_NORMAL_12 = "HELVETICA_NORMAL_12" iup.HELVETICA_NORMAL_12 = IUP_HELVETICA_NORMAL_12
+IUP_HELVETICA_ITALIC_12 = "HELVETICA_ITALIC_12" iup.HELVETICA_ITALIC_12 = IUP_HELVETICA_ITALIC_12
+IUP_HELVETICA_BOLD_12 = "HELVETICA_BOLD_12" iup.HELVETICA_BOLD_12 = IUP_HELVETICA_BOLD_12
+IUP_HELVETICA_NORMAL_14 = "HELVETICA_NORMAL_14" iup.HELVETICA_NORMAL_14 = IUP_HELVETICA_NORMAL_14
+IUP_HELVETICA_ITALIC_14 = "HELVETICA_ITALIC_14" iup.HELVETICA_ITALIC_14 = IUP_HELVETICA_ITALIC_14
+IUP_HELVETICA_BOLD_14 = "HELVETICA_BOLD_14" iup.HELVETICA_BOLD_14 = IUP_HELVETICA_BOLD_14
+IUP_COURIER_NORMAL_8 = "COURIER_NORMAL_8" iup.COURIER_NORMAL_8 = IUP_COURIER_NORMAL_8
+IUP_COURIER_ITALIC_8 = "COURIER_ITALIC_8" iup.COURIER_ITALIC_8 = IUP_COURIER_ITALIC_8
+IUP_COURIER_BOLD_8 = "COURIER_BOLD_8" iup.COURIER_BOLD_8 = IUP_COURIER_BOLD_8
+IUP_COURIER_NORMAL_10 = "COURIER_NORMAL_10" iup.COURIER_NORMAL_10 = IUP_COURIER_NORMAL_10
+IUP_COURIER_ITALIC_10 = "COURIER_ITALIC_10" iup.COURIER_ITALIC_10 = IUP_COURIER_ITALIC_10
+IUP_COURIER_BOLD_10 = "COURIER_BOLD_10" iup.COURIER_BOLD_10 = IUP_COURIER_BOLD_10
+IUP_COURIER_NORMAL_12 = "COURIER_NORMAL_12" iup.COURIER_NORMAL_12 = IUP_COURIER_NORMAL_12
+IUP_COURIER_ITALIC_12 = "COURIER_ITALIC_12" iup.COURIER_ITALIC_12 = IUP_COURIER_ITALIC_12
+IUP_COURIER_BOLD_12 = "COURIER_BOLD_12" iup.COURIER_BOLD_12 = IUP_COURIER_BOLD_12
+IUP_COURIER_NORMAL_14 = "COURIER_NORMAL_14" iup.COURIER_NORMAL_14 = IUP_COURIER_NORMAL_14
+IUP_COURIER_ITALIC_14 = "COURIER_ITALIC_14" iup.COURIER_ITALIC_14 = IUP_COURIER_ITALIC_14
+IUP_COURIER_BOLD_14 = "COURIER_BOLD_14" iup.COURIER_BOLD_14 = IUP_COURIER_BOLD_14
+IUP_TIMES_NORMAL_8 = "TIMES_NORMAL_8" iup.TIMES_NORMAL_8 = IUP_TIMES_NORMAL_8
+IUP_TIMES_ITALIC_8 = "TIMES_ITALIC_8" iup.TIMES_ITALIC_8 = IUP_TIMES_ITALIC_8
+IUP_TIMES_BOLD_8 = "TIMES_BOLD_8" iup.TIMES_BOLD_8 = IUP_TIMES_BOLD_8
+IUP_TIMES_NORMAL_10 = "TIMES_NORMAL_10" iup.TIMES_NORMAL_10 = IUP_TIMES_NORMAL_10
+IUP_TIMES_ITALIC_10 = "TIMES_ITALIC_10" iup.TIMES_ITALIC_10 = IUP_TIMES_ITALIC_10
+IUP_TIMES_BOLD_10 = "TIMES_BOLD_10" iup.TIMES_BOLD_10 = IUP_TIMES_BOLD_10
+IUP_TIMES_NORMAL_12 = "TIMES_NORMAL_12" iup.TIMES_NORMAL_12 = IUP_TIMES_NORMAL_12
+IUP_TIMES_ITALIC_12 = "TIMES_ITALIC_12" iup.TIMES_ITALIC_12 = IUP_TIMES_ITALIC_12
+IUP_TIMES_BOLD_12 = "TIMES_BOLD_12" iup.TIMES_BOLD_12 = IUP_TIMES_BOLD_12
+IUP_TIMES_NORMAL_14 = "TIMES_NORMAL_14" iup.TIMES_NORMAL_14 = IUP_TIMES_NORMAL_14
+IUP_TIMES_ITALIC_14 = "TIMES_ITALIC_14" iup.TIMES_ITALIC_14 = IUP_TIMES_ITALIC_14
+IUP_TIMES_BOLD_14 = "TIMES_BOLD_14" iup.TIMES_BOLD_14 = IUP_TIMES_BOLD_14
+
+
+
+-- #################################################################################
+-- Private functions
+-- #################################################################################
+
+-- maps Ihandles into Lua objects
+iup_handles = {}
+
+settagmethod(iuplua_tag, "gettable", iup_gettable)
+settagmethod(iuplua_tag, "settable", iup_settable)
+settagmethod (tag({}), "index", iup_index)
+
+function _ALERT(s)
+ local bt = iupbutton{title="Ok", size="60", action="return IUP_CLOSE"}
+ local ml = iupmultiline{expand="YES", readonly="YES", value=s, size="300x150"}
+ local vb = iupvbox{ml, bt; alignment="ACENTER", margin="10x10", gap="10"}
+ local dg = iupdialog{vb; title="Lua Error",defaultesc=bt,defaultenter=bt,startfocus=bt}
+ dg:popup(IUP_CENTER, IUP_CENTER)
+ dg:destroy()
+end
+
+function type_string (o)
+ return type(o) == "string"
+end
+
+function type_number (o)
+ return type(o) == "number"
+end
+
+function type_nil (o)
+ return type(o) == "nil"
+end
+
+function type_function (o)
+ return type(o) == "function"
+end
+
+function type_widget(w)
+ if w then
+ return iup_handles[w]
+ else
+ return nil
+ end
+end
+
+function type_menu (o)
+ return type_widget(o) and (o.parent==IUPMENU)
+end
+
+function type_item (o)
+ return type_widget(o) and (o.parent==IUPITEM or o.parent==IUPSUBMENU or o.parent==IUPSEPARATOR)
+end
+
+function iupCallMethod(name, ...)
+ local handle = arg[1] -- always the handle
+
+ local func = handle[name] -- this is the old name
+ if (not func) then
+ local full_name = strlower(iup_callbacks[name][1])
+ func = handle[full_name] -- check also for the full name
+
+ if (not func) then
+ return
+ end
+ end
+
+ if type_function (func) then
+ return call(func, arg)
+ elseif type_string(func) then
+ local temp = self
+ self = handle
+ local result = dostring(func)
+ self = temp
+ return result
+ else
+ return IUP_ERROR
+ end
+end
+
+function iupSetName (handle)
+ if not type_string(iup_handles[handle].IUP_name) then
+ iup_handles[handle].IUP_name = format("_IUPLUA_NAME(%s)", tostring(handle))
+ IupSetHandle(handle.IUP_name, handle)
+ end
+end
+
+function iupCreateChildrenNames (obj)
+ if obj.parent.parent == COMPOSITION then
+ local i = 1
+ while obj[i] do
+ iupCreateChildrenNames (obj[i])
+ i = i+1
+ end
+ elseif obj.parent == IUPFRAME then
+ iupCreateChildrenNames (obj[1])
+ else
+ iupSetName (obj)
+ end
+end
+
+
+-- #################################################################################
+-- Public Functions
+-- #################################################################################
+
+
+function IupRGB (red, green, blue)
+ return floor(red*255).." "..floor(green*255).." "..floor(blue*255)
+end
+iup.RGB = IupRGB
+
+function IupRegisterHandle(handle, typename)
+ if not iup_handles[handle] then
+ local obj = getglobal("IUP"..strupper(typename))
+ if not obj then
+ obj = WIDGET
+ end
+ iup_handles[handle] = { parent=obj, handle=handle }
+ end
+ return handle
+end
+iup.RegisterHandle = IupRegisterHandle
+
+function IupGetFromC(obj)
+ local handle = IupGetHandle(obj[1])
+ return IupRegisterHandle(handle, IupGetType(handle))
+end
+
+iup.GetFromC = function (name)
+ local handle = IupGetHandle(name)
+ return IupRegisterHandle(handle, IupGetType(handle))
+end
+
+
+-- #################################################################################
+-- Widgets
+-- #################################################################################
+
+
+-- "type" is used to check the type of each parameter in the creation table
+WIDGET = {type = {}}
+
+-- called by the iupxxx functions
+-- obj is a lua table
+function WIDGET:Constructor(obj)
+ -- the parent of the table is the widget class used to create the control
+ obj.parent = self
+
+ -- check the table parameters
+ self:checkParams(obj)
+
+ -- create the IUP control, calling iupCreateXXX
+ obj.handle = self:CreateIUPelement(obj)
+
+ -- set the parameters that are attributes
+ self:setAttributes(obj)
+
+ -- save the table indexed by the handle
+ iup_handles[obj.handle] = obj
+
+ -- the returned value is the handle, not the table
+ return obj.handle
+end
+
+function WIDGET:checkParams (obj)
+ local type = self.type
+ local param, func = next(type, nil)
+ while param do
+ if not func(obj[param]) then
+ error("parameter " .. param .. " has wrong value or is not initialized")
+ end
+ param, func = next(type, param)
+ end
+end
+
+function WIDGET:setAttributes (obj)
+ local temp = {}
+ local f = next(obj, nil)
+ while f do
+ temp[f] = 1
+ f = next(obj, f)
+ end
+ f = next(temp, nil)
+ while f do
+ obj:set (f, obj[f])
+ f = next(temp, f)
+ end
+end
+
+function WIDGET:get(index)
+ if type_string (index) then
+ if (iup_callbacks[index]) then
+ return self[index]
+ else
+ local INDEX = strupper (index)
+ local value = IupGetAttribute (self.handle, INDEX)
+ if value then
+ local handle = IupGetHandle (value)
+ if handle then
+ return handle
+ else
+ return value
+ end
+ end
+ end
+ end
+ return self[index]
+end
+
+function WIDGET:set(index, value)
+ if type_string (index) then
+ local INDEX = strupper (index)
+ local cb = iup_callbacks[index]
+
+ -- workaround for resize attribute in dialog
+ if (index == "resize" and IupGetType(self.handle) == "dialog") then
+ cb = nil
+ end
+
+ if (cb) then
+ local func = cb[2]
+ if (not func) then
+ func = cb[IupGetType(self.handle)]
+ end
+ iupSetCallback(self.handle, cb[1], func, value)
+ self[index] = value
+ return
+ elseif type_string(value) or type_number(value) then
+ IupSetAttribute(self.handle, INDEX, value)
+ return
+ elseif type_nil(value) then
+ local old_value = IupGetAttribute(self.handle, INDEX)
+ if old_value then
+ IupSetAttribute(self.handle, INDEX, value)
+ return
+ end
+ elseif type_widget(value) then
+ iupSetName(value)
+ IupSetAttribute(self.handle, INDEX, value.IUP_name)
+ return
+ end
+ end
+ self[index] = value
+end
+
+function WIDGET:r_destroy()
+ local i = 1
+ local elem = self[i]
+ while elem do
+ if type_widget (elem) and elem.IUP_parent then
+ if elem.IUP_parent == self then
+ elem.IUP_parent = nil
+ elem:r_destroy ()
+ else -- wrong parent
+ error ("Internal table inconsistency")
+ exit()
+ end
+ end
+
+ i = i + 1
+ elem = self[i]
+ end
+ iup_handles[self] = nil
+end
+
+function WIDGET:destroy()
+ self:r_destroy ()
+ IupDestroy (self)
+end
+
+function WIDGET:detach()
+ IupDetach (self)
+ local parent = self.IUP_parent
+ if parent then
+ self.IUP_parent = nil
+ local i = 1
+ while parent[i] do
+ if parent[i] == self then
+ while parent[i+1] do
+ parent[i] = parent[i+1]
+ i = i+1
+ end
+ parent[i] = nil
+ return
+ end
+ i = i+1
+ end
+ end
+end
+
+function WIDGET:append(o)
+ if IupAppend (self, o) then
+ o.IUP_parent = self
+ local i = 1
+ while self[i] do
+ if self[i] == o then
+ return i
+ end
+ i = i+1
+ end
+ iup_handles[self][i] = o
+ return i
+ else
+ return nil
+ end
+end
+
+function WIDGET:map()
+ return IupMap(self)
+end
+
+function WIDGET:hide()
+ return IupHide(self)
+end
+
+
+-- ###############
+IUPTIMER = {parent = WIDGET}
+
+function IUPTIMER:CreateIUPelement (obj)
+ return iupCreateTimer()
+end
+
+function iuptimer(o)
+ return IUPTIMER:Constructor(o)
+end
+iup.timer = iuptimer
+
+
+-- ###############
+IUPDIALOG = {parent = WIDGET, type = {type_widget}}
+
+function IUPDIALOG:CreateIUPelement (obj)
+ local handle = iupCreateDialog(obj[1])
+ obj[1].IUP_parent = handle
+ return handle
+end
+
+function IUPDIALOG:show ()
+ return IupShow(self)
+end
+
+function IUPDIALOG:showxy (x,y)
+ return IupShowXY(self, x, y)
+end
+
+function IUPDIALOG:popup (x, y)
+ return IupPopup (self, x, y)
+end
+
+function iupdialog (o)
+ return IUPDIALOG:Constructor (o)
+end
+iup.dialog = iupdialog
+
+
+-- ###############
+IUPRADIO = {parent = WIDGET, type = {type_widget}}
+
+function IUPRADIO:CreateIUPelement (obj)
+ local handle = iupCreateRadio (obj[1])
+ obj[1].IUP_parent = handle
+ return handle
+end
+
+function iupradio (o)
+ local handle = IUPRADIO:Constructor (o)
+ iupCreateChildrenNames (handle[1])
+ return handle
+end
+iup.radio = iupradio
+
+-- OLD STUFF
+function edntoggles (h)
+ local tmp = {}
+ local i = 1
+ while h[i] do
+ if type_string (h[i]) then
+ tmp[i] = iuptoggle{title = h[i], action = h.action}
+ else
+ error ("option "..i.." must be a string")
+ end
+ i = i + 1
+ end
+
+ if h.value then
+ local j = 1
+ while h[j] and (h[j] ~= h.value) do
+ j = j + 1
+ end
+ if h[j] then
+ tmp.value = tmp[j]
+ end
+ elseif h.nvalue then
+ tmp.value = tmp[h.nvalue]
+ end
+
+ return tmp
+end
+
+-- OLD STUFF
+function edhradio (o)
+ local toggles = edntoggles (o)
+ return iupradio{edhbox (toggles); value = toggles.value}
+end
+
+-- OLD STUFF
+function edvradio (o)
+ local toggles = edntoggles (o)
+ return iupradio{edvbox (toggles); value = toggles.value}
+end
+
+
+-- ###############
+IUPMENU = {parent = WIDGET}
+
+function IUPMENU:checkParams (obj)
+ local i = 1
+ while obj[i] do
+ local o = obj[i]
+ if not type_item (o) then -- not a menu item
+ if type (o) ~= 'table' then
+ error("parameter " .. i .. " is not a table nor a menu item")
+ elseif (o[1] and not type_string (o[1])) then
+ error("parameter " .. i .. " does not have a string title")
+ elseif (o[2] and not type_string (o[2]) and not type_function (o[2])
+ and not type_widget (o[2])) then
+ error("parameter " .. i .. " does not have an action nor a menu")
+ end
+ end
+ i = i + 1
+ end
+end
+
+function IUPMENU:CreateIUPelement (obj)
+ local handle = iupCreateMenu ()
+ local i = 1
+ while obj[i] do
+ local o = obj[i]
+ local elem
+ if type_widget (o) then -- predefined
+ elem = o
+ elseif not o[1] then -- Separator
+ elem = iupseparator {}
+ elseif type_widget (o[2]) then -- SubMenu
+ o.title = o[1]
+ o[1] = o[2]
+ o[2] = nil
+ elem = iupsubmenu(o)
+ else -- Item
+ o.title = o[1]
+ o.action = o[2]
+ o[1] = nil
+ o[2] = nil
+ elem = iupitem(o)
+ end
+ IupAppend (handle, elem)
+ elem.IUP_parent = handle
+ obj[i] = elem
+ i = i + 1
+ end
+ return handle
+end
+
+function iupmenu (o)
+ return IUPMENU:Constructor (o)
+end
+iup.menu = iupmenu
+
+function IUPMENU:popup (x, y)
+ return IupPopup (self, x, y)
+end
+
+
+-- ###############
+COMPOSITION = {parent = WIDGET}
+
+function COMPOSITION:checkParams (obj)
+ local i = 1
+ while obj[i] do
+ if not type_widget (obj[i]) then
+ error("parameter " .. i .. " has wrong value or is not initialized")
+ end
+ i = i + 1
+ end
+end
+
+function COMPOSITION:CreateIUPelement (obj)
+ local handle = self:CreateBoxElement ()
+ local filled = obj.filled
+ local i = 1
+ local n = 0
+ while obj[i] do
+ n = n + 1
+ i = i + 1
+ end
+ i = 1
+
+ if filled == IUP_YES then
+ obj[i+n] = iupfill{}
+ IupAppend (handle, obj[i+n])
+ obj[i+n].IUP_parent = handle
+ end
+
+ while i <= n do
+ IupAppend (handle, obj[i])
+ obj[i].IUP_parent = handle
+ i = i + 1
+ if filled == IUP_YES then
+ obj[i+n] = iupfill{}
+ IupAppend (handle, obj[i+n])
+ obj[i+n].IUP_parent = handle
+ end
+ end
+ return handle
+end
+
+
+-- ###############
+IUPHBOX = {parent = COMPOSITION}
+
+function IUPHBOX:CreateBoxElement ()
+ return iupCreateHbox ()
+end
+
+function iuphbox (o)
+ return IUPHBOX:Constructor (o)
+end
+iup.hbox = iuphbox
+
+-- OLD STUFF
+function edhbox (o)
+ o.filled = IUP_YES
+ return IUPHBOX:Constructor (o)
+end
+
+-- OLD STUFF
+function edfield (f)
+ local l, t
+ if (type_string (f.prompt) or type_number (f.prompt)) then
+ l = iuplabel {title = f.prompt}
+ else
+ error ("parameter prompt has wrong value or is not initialized")
+ end
+ if f.value then
+ t = iuptext {value = f.value}
+ else
+ t = iuptext {value = f.nvalue}
+ end
+ if t and l then
+ return edhbox {l, t}
+ else
+ return nil
+ end
+end
+
+
+-- ###############
+IUPVBOX = {parent = COMPOSITION}
+
+function IUPVBOX:CreateBoxElement ()
+ return iupCreateVbox ()
+end
+
+function iupvbox (o)
+ return IUPVBOX:Constructor (o)
+end
+iup.vbox = iupvbox
+
+-- OLD STUFF
+function edvbox (o)
+ o.filled = IUP_YES
+ return IUPVBOX:Constructor (o)
+end
+
+
+-- ###############
+IUPZBOX = {parent = COMPOSITION}
+
+function IUPZBOX:CreateBoxElement ()
+ return iupCreateZbox ()
+end
+
+function iupzbox (obj)
+ local handle = IUPZBOX:Constructor (obj)
+ local i = 1
+ while obj[i] do
+ iupSetName(handle[i])
+ i = i+1
+ end
+ return handle
+end
+iup.zbox = iupzbox
+
+
+-- ###############
+IUPFILL = {parent = WIDGET}
+
+function IUPFILL:CreateIUPelement (obj)
+ return iupCreateFill ()
+end
+
+function iupfill (o)
+ return IUPFILL:Constructor (o)
+end
+iup.fill = iupfill
+
+
+-- ###############
+IUPBUTTON = {parent = WIDGET, type = {title = type_string}}
+
+function IUPBUTTON:CreateIUPelement (obj)
+ if not obj.title and obj.image then
+ obj.title=''
+ end
+ return iupCreateButton(obj.title)
+end
+
+function iupbutton (o)
+ return IUPBUTTON:Constructor (o)
+end
+iup.button = iupbutton
+
+
+-- ###############
+IUPTEXT = {parent = WIDGET}
+
+function IUPTEXT:CreateIUPelement (obj)
+ return iupCreateText()
+end
+
+function iuptext (o)
+ return IUPTEXT:Constructor (o)
+end
+iup.text = iuptext
+
+
+-- ###############
+IUPMULTILINE = {parent = IUPTEXT}
+
+function IUPMULTILINE:CreateIUPelement (obj)
+ return iupCreateMultiLine()
+end
+
+function iupmultiline (o)
+ return IUPMULTILINE:Constructor (o)
+end
+iup.multiline = iupmultiline
+
+
+-- ###############
+IUPLABEL = {parent = WIDGET, type = {title = type_string}}
+
+function IUPLABEL:CreateIUPelement (obj)
+ if not obj.title and obj.image then
+ obj.title=''
+ end
+ return iupCreateLabel (obj.title)
+end
+
+function iuplabel (o)
+ return IUPLABEL:Constructor (o)
+end
+iup.label = iuplabel
+
+
+-- ###############
+IUPTOGGLE = {parent = IUPBUTTON}
+
+function IUPTOGGLE:CreateIUPelement (obj)
+ return iupCreateToggle (obj.title)
+end
+
+function iuptoggle (o)
+ return IUPTOGGLE:Constructor (o)
+end
+iup.toggle = iuptoggle
+
+
+-- ###############
+IUPITEM = {parent = IUPBUTTON}
+
+function IUPITEM:CreateIUPelement (obj)
+ return iupCreateItem (obj.title)
+end
+
+function iupitem (o)
+ return IUPITEM:Constructor (o)
+end
+iup.item = iupitem
+
+
+-- ###############
+IUPSUBMENU = {parent = WIDGET, type = {type_menu; title = type_string}}
+
+function IUPSUBMENU:CreateIUPelement (obj)
+ local h = iupCreateSubmenu (obj.title, obj[1])
+ obj[1].IUP_parent = h
+ return h
+end
+
+function iupsubmenu (o)
+ return IUPSUBMENU:Constructor (o)
+end
+iup.submenu = iupsubmenu
+
+
+-- ###############
+IUPSEPARATOR = {parent = WIDGET}
+
+function IUPSEPARATOR:CreateIUPelement (obj)
+ return iupCreateSeparator ()
+end
+
+function iupseparator (o)
+ return IUPSEPARATOR:Constructor (o)
+end
+iup.separator = iupseparator
+
+
+-- ###############
+IUPFILEDLG = {parent = WIDGET}
+
+function IUPFILEDLG:popup (x, y)
+ return IupPopup (self, x, y)
+end
+
+function IUPFILEDLG:CreateIUPelement ()
+ return iupCreateFileDlg ()
+end
+
+function iupfiledlg (o)
+ return IUPFILEDLG:Constructor (o)
+end
+iup.filedlg = iupfiledlg
+
+
+-- ###############
+IUPMESSAGEDLG = {parent = WIDGET}
+
+function IUPMESSAGEDLG:popup (x, y)
+ return IupPopup (self, x, y)
+end
+
+function IUPMESSAGEDLG:CreateIUPelement ()
+ return iupCreateMessageDlg ()
+end
+
+function iupmessagedlg (o)
+ return IUPMESSAGEDLG:Constructor (o)
+end
+iup.messagedlg = iupmessagedlg
+
+
+-- ###############
+IUPCOLORDLG = {parent = WIDGET}
+
+function IUPCOLORDLG:popup (x, y)
+ return IupPopup (self, x, y)
+end
+
+function IUPCOLORDLG:CreateIUPelement ()
+ return iupCreateColorDlg ()
+end
+
+function iupcolordlg (o)
+ return IUPCOLORDLG:Constructor (o)
+end
+iup.colordlg = iupcolordlg
+
+
+-- ###############
+IUPFONTDLG = {parent = WIDGET}
+
+function IUPFONTDLG:popup (x, y)
+ return IupPopup (self, x, y)
+end
+
+function IUPFONTDLG:CreateIUPelement ()
+ return iupCreateFontDlg ()
+end
+
+function iupfontdlg (o)
+ return IUPFONTDLG:Constructor (o)
+end
+iup.fontdlg = iupfontdlg
+
+
+-- ###############
+IUPUSER = {parent = WIDGET}
+
+function IUPUSER:CreateIUPelement ()
+ return iupCreateUser ()
+end
+
+function iupuser ()
+ return IUPUSER:Constructor ()
+end
+iup.user = iupuser
+
+
+-- ###############
+IUPFRAME = {parent = WIDGET, type = {type_widget}}
+
+function IUPFRAME:CreateIUPelement (obj)
+ local h = iupCreateFrame (obj[1])
+ obj[1].IUP_parent = h
+ return h
+end
+
+function iupframe (o)
+ return IUPFRAME:Constructor (o)
+end
+iup.frame = iupframe
+
+
+-- ###############
+IUPCANVAS = {parent = WIDGET}
+
+function IUPCANVAS:CreateIUPelement (obj)
+ return iupCreateCanvas ()
+end
+
+function iupcanvas (o)
+ return IUPCANVAS:Constructor (o)
+end
+iup.canvas = iupcanvas
+
+
+-- ###############
+IUPLIST = {parent = WIDGET}
+
+function IUPLIST:CreateIUPelement (obj)
+ return iupCreateList ()
+end
+
+function IUPLIST:get(index)
+ if type (index) == 'number' then
+ return IupGetAttribute (self.handle, ""..index)
+ else
+ return WIDGET.get(self, index)
+ end
+end
+
+function IUPLIST:set (index, value)
+ if type (index) == 'number' then
+ if (type_string (value) or type_number (value)) then
+ return IupSetAttribute (self.handle, ""..index, ""..value)
+ elseif value == nil then
+ return IupSetAttribute (self.handle, ""..index, value)
+ end
+ end
+ return WIDGET.set(self, index, value)
+end
+
+function iuplist (o)
+ return IUPLIST:Constructor (o)
+end
+iup.list = iuplist
+
+
+-- ###############
+IUPIMAGE = {parent = WIDGET}
+
+function IUPIMAGE:checkParams (obj)
+ local i = 1
+ while obj[i] do
+ local j = 1
+ while obj[i][j] do
+ if type (obj[i][j]) ~= 'number' then
+ error ("non-numeric value in image definition")
+ end
+ j = j + 1
+ end
+
+ if obj.width and (j - 1) ~= obj.width then
+ error ("inconsistent image lenght")
+ else
+ obj.width = j - 1
+ end
+
+ i = i + 1
+ end
+
+ obj.height = i - 1
+end
+
+function IUPIMAGE:CreateIUPelement (obj)
+ local handle = iupCreateImage (obj.width, obj.height, obj)
+ if type (obj.colors) == 'table' then
+ local i = 1
+ while obj.colors[i] do
+ IupSetAttribute (handle, i, obj.colors[i])
+ i = i + 1
+ end
+ end
+ return handle
+end
+
+function iupimage (o)
+ return IUPIMAGE:Constructor (o)
+end
+iup.image = iupimage
+
+
+IUPIMAGERGB = {parent = WIDGET}
+
+function IUPIMAGERGB:CreateIUPelement (obj)
+ return iupCreateImageRGB(obj.width, obj.height, obj.pixels)
+end
+
+function iupimagergb (o)
+ return IUPIMAGERGB:Constructor (o)
+end
+iup.imagergb = iupimagergb
+
+
+IUPIMAGERGBA = {parent = WIDGET}
+
+function IUPIMAGERGBA:CreateIUPelement (obj)
+ return iupCreateImageRGBA(obj.width, obj.height, obj.pixels)
+end
+
+function iupimagergba (o)
+ return IUPIMAGERGBA:Constructor (o)
+end
+iup.imagergba = iupimagergba
+
+
+-- #################################################################################
+-- Callbacks
+-- #################################################################################
+
+
+-- global list of callbacks
+-- index is the Lua callback name
+-- each callback contains the full name, and the C callback
+iup_callbacks =
+{
+ action = {"ACTION", nil},
+ actioncb = {"ACTION_CB", nil},
+ getfocus = {"GETFOCUS_CB", iup_getfocus_cb},
+ killfocus = {"KILLFOCUS_CB", iup_killfocus_cb},
+ focus = {"FOCUS_CB", iup_focus_cb},
+ k_any = {"K_ANY", iup_k_any},
+ help = {"HELP_CB", iup_help_cb},
+ caretcb = {"CARET_CB", iup_caret_cb},
+ keypress = {"KEYPRESS_CB", iup_keypress_cb},
+ scroll = {"SCROLL_CB", iup_scroll_cb},
+ trayclick = {"TRAYCLICK_CB", iup_trayclick_cb},
+ close = {"CLOSE_CB", iup_close_cb},
+ open = {"OPEN_CB", iup_open_cb},
+ showcb = {"SHOW_CB", iup_show_cb},
+ mapcb = {"MAP_CB", iup_map_cb},
+ dropfiles = {"DROPFILES_CB", iup_dropfiles_cb},
+ menuclose = {"MENUCLOSE_CB", iup_menuclose_cb},
+ highlight = {"HIGHLIGHT_CB", iup_highlight_cb},
+ wom = {"WOM_CB", iup_wom_cb},
+ wheel = {"WHEEL_CB", iup_wheel_cb},
+ button = {"BUTTON_CB", iup_button_cb},
+ resize = {"RESIZE_CB", iup_resize_cb},
+ motion = {"MOTION_CB", iup_motion_cb},
+ enterwindow = {"ENTERWINDOW_CB", iup_enterwindow_cb},
+ leavewindow = {"LEAVEWINDOW_CB", iup_leavewindow_cb},
+ edit = {"EDIT_CB", iup_edit_cb},
+ multiselect = {"MULTISELECT_CB", iup_multiselect_cb},
+ filecb = {"FILE_CB", iup_file_cb},
+ mdiactivatecb = {"MDIACTIVATE_CB", iup_mdiactivate_cb},
+}
+
+iup_callbacks.action.toggle = iup_action_toggle
+iup_callbacks.action.multiline = iup_action_text
+iup_callbacks.action.text = iup_action_text
+iup_callbacks.action.button = iup_action_button
+iup_callbacks.action.list = iup_action_list
+iup_callbacks.action.item = iup_action_button
+iup_callbacks.action.canvas = iup_action_canvas
+
+-- must set here because it is also used elsewhere with a different signature
+iup_callbacks.actioncb.timer = iup_action_timer
+
+-- aliases for the full names
+iup_callbacks.action_cb = iup_callbacks.actioncb
+iup_callbacks.getfocus_cb = iup_callbacks.getfocus
+iup_callbacks.killfocus_cb = iup_callbacks.killfocus
+iup_callbacks.focus_cb = iup_callbacks.focus
+iup_callbacks.k_any = iup_callbacks.k_any
+iup_callbacks.help_cb = iup_callbacks.help
+iup_callbacks.caret_cb = iup_callbacks.caretcb
+iup_callbacks.keypress_cb = iup_callbacks.keypress
+iup_callbacks.scroll_cb = iup_callbacks.scroll
+iup_callbacks.trayclick_cb = iup_callbacks.trayclick
+iup_callbacks.close_cb = iup_callbacks.close
+iup_callbacks.open_cb = iup_callbacks.open
+iup_callbacks.show_cb = iup_callbacks.showcb
+iup_callbacks.map_cb = iup_callbacks.mapcb
+iup_callbacks.dropfiles_cb = iup_callbacks.dropfiles
+iup_callbacks.menuclose_cb = iup_callbacks.menuclose
+iup_callbacks.highlight_cb = iup_callbacks.highlight
+iup_callbacks.wom_cb = iup_callbacks.wom
+iup_callbacks.wheel_cb = iup_callbacks.wheel
+iup_callbacks.button_cb = iup_callbacks.button
+iup_callbacks.resize_cb = iup_callbacks.resize
+iup_callbacks.motion_cb = iup_callbacks.motion
+iup_callbacks.enterwindow_cb = iup_callbacks.enterwindow
+iup_callbacks.leavewindow_cb = iup_callbacks.leavewindow
+iup_callbacks.edit_cb = iup_callbacks.edit
+iup_callbacks.multiselect_cb = iup_callbacks.multiselect
+iup_callbacks.mdiactivate_cb = iup_callbacks.mdiactivatecb
+iup_callbacks.file_cb = iup_callbacks.filecb
+IUPCOLORBROWSER = {parent = WIDGET}
+
+function IUPCOLORBROWSER:CreateIUPelement(obj)
+ return iupCreateColorBrowser(obj)
+end
+
+function iupcolorbrowser (o)
+ return IUPCOLORBROWSER:Constructor (o)
+end
+iup.colorbrowser = iupcolorbrowser
+
+
+iup_callbacks.drag = {"DRAG_CB", iup_colorbrowser_drag_cb}
+iup_callbacks.change = {"CHANGE_CB", iup_colorbrowser_change_cb}
+
+iup_callbacks.drag_cb = iup_callbacks.drag
+iup_callbacks.change_cb = iup_callbacks.change
+IUPCELLS = {parent = WIDGET}
+
+function IUPCELLS:CreateIUPelement( obj )
+ return iupCreateCells()
+end
+
+function IUPCELLS:redraw()
+ self.repaint = IUP_YES
+end
+
+function iupcells(o)
+ return IUPCELLS:Constructor(o)
+end
+iup.cells = iupcells
+
+
+-- iup_callbacks.draw_cb = iup_callbacks.draw = {"DRAW_CB", iup_mat_draw_cb} -- same callback at IupMatrix
+
+iup_callbacks.mouseclick = {"MOUSECLICK_CB", iup_cells_mouseclick_cb}
+iup_callbacks.mousemotion = {"MOUSEMOTION_CB", iup_cells_mousemotion_cb}
+iup_callbacks.scrolling = {"SCROLLING_CB", iup_cells_scrolling_cb}
+iup_callbacks.width = {"WIDTH_CB", iup_cells_width_cb}
+iup_callbacks.height = {"HEIGHT_CB", iup_cells_height_cb}
+iup_callbacks.nlines = {"NLINES_CB", iup_cells_nlines_cb}
+iup_callbacks.ncols = {"NCOLS_CB", iup_cells_ncols_cb}
+iup_callbacks.hspan = {"HSPAN_CB", iup_cells_hspan_cb}
+iup_callbacks.vspan = {"VSPAN_CB", iup_cells_vspan_cb}
+
+iup_callbacks.mouseclick_cb = iup_callbacks.mouseclick
+iup_callbacks.mousemotion_cb = iup_callbacks.mousemotion
+iup_callbacks.scrolling_cb = iup_callbacks.scrolling
+iup_callbacks.width_cb = iup_callbacks.width
+iup_callbacks.height_cb = iup_callbacks.height
+iup_callbacks.nlines_cb = iup_callbacks.nlines
+iup_callbacks.ncols_cb = iup_callbacks.ncols
+iup_callbacks.hspan_cb = iup_callbacks.hspan
+iup_callbacks.vspan_cb = iup_callbacks.vspan
+IUPCOLORBAR = {parent = WIDGET}
+
+function IUPCOLORBAR:CreateIUPelement(obj)
+ return iupCreateColorbar(obj)
+end
+
+function iupcolorbar (o)
+ return IUPCOLORBAR:Constructor (o)
+end
+iup.colorbar = iupcolorbar
+
+
+iup_callbacks.cellcb = {"CELL_CB", iup_colorbar_cell_cb}
+iup_callbacks.selectcb = {"SELECT_CB", iup_colorbar_select_cb}
+iup_callbacks.switchcb = {"SWITCH_CB", iup_colorbar_switch_cb}
+iup_callbacks.extendedcb = {"EXTENDED_CB", iup_colorbar_extended_cb}
+
+iup_callbacks.cell_cb = iup_callbacks.cellcb
+iup_callbacks.select_cb = iup_callbacks.selectcb
+iup_callbacks.switch_cb = iup_callbacks.switchcb
+iup_callbacks.extended_cb = iup_callbacks.extendedcb
+IUPDIAL = {parent = WIDGET}
+
+function IUPDIAL:CreateIUPelement (obj)
+ return iupCreateDial (obj[1])
+end
+
+function iupdial (o)
+ return IUPDIAL:Constructor (o)
+end
+iup.dial = iupdial
+
+iup_callbacks.mousemove.dial = iup_val_mousemove_cb -- same callback at IupVal
+
+-- iup_callbacks.buttonpress = {"BUTTON_PRESS_CB", iup_val_button_press_cb} -- same callback at IupVal
+-- iup_callbacks.buttonrelease = {"BUTTON_RELEASE_CB", iup_val_button_release_cb} -- same callback at IupVal
+IUPGAUGE = {parent = WIDGET}
+
+function IUPGAUGE:CreateIUPelement (obj)
+ return iupCreateGauge ()
+end
+
+function iupgauge (o)
+ return IUPGAUGE:Constructor (o)
+end
+iup.gauge = iupgauge
+IUPMATRIX = {parent = WIDGET}
+
+function IUPMATRIX:CreateIUPelement (obj)
+ return iupCreateMatrix ()
+end
+
+function IUPMATRIX:setcell(l,c,val)
+ IupSetAttribute(self,l..":"..c,val)
+end
+
+function IUPMATRIX:getcell(l,c,val)
+ return IupGetAttribute(self,l..":"..c)
+end
+
+function iupmatrix (o)
+ return IUPMATRIX:Constructor (o)
+end
+iup.matrix = iupmatrix
+
+
+iup_callbacks.actioncb.matrix = iup_mat_action_cb
+iup_callbacks.mousemove.matrix = iup_mat_mousemove_cb
+
+iup_callbacks.edition = {"EDITION_CB", iup_mat_edition_cb}
+iup_callbacks.drop = {"DROP_CB", iup_mat_drop_cb}
+iup_callbacks.dropselect = {"DROPSELECT_CB", iup_mat_dropselect_cb}
+iup_callbacks.enteritem = {"ENTERITEM_CB", iup_mat_enteritem_cb}
+iup_callbacks.leaveitem = {"LEAVEITEM_CB", iup_mat_leaveitem_cb}
+iup_callbacks.click = {"CLICK_CB", iup_mat_click_cb}
+iup_callbacks.scrolltop = {"SCROLLTOP_CB", iup_mat_scrolltop_cb}
+iup_callbacks.valuecb = {"VALUE_CB", iup_mat_value_cb}
+iup_callbacks.draw = {"DRAW_CB", iup_mat_draw_cb}
+iup_callbacks.dropcheck = {"DROPCHECK_CB", iup_mat_dropcheck_cb}
+iup_callbacks.fgcolorcb = {"FGCOLOR_CB", iup_mat_fgcolor_cb}
+iup_callbacks.bgcolorcb = {"BGCOLOR_CB", iup_mat_bgcolor_cb}
+iup_callbacks.value_edit = {"VALUE_EDIT_CB", iup_mat_value_edit_cb}
+iup_callbacks.markedit_cb = {"MARKEDIT_CB", iup_mat_markedit_cb}
+iup_callbacks.mark_cb = {"MARK_CB", iup_mat_mark_cb}
+iup_callbacks.mouse_cb = {"MOUSE_CB", iup_mat_mouse_cb}
+
+iup_callbacks.edition_cb = iup_callbacks.edition
+iup_callbacks.drop_cb = iup_callbacks.drop
+iup_callbacks.dropselect_cb = iup_callbacks.dropselect
+iup_callbacks.enteritem_cb = iup_callbacks.enteritem
+iup_callbacks.leaveitem_cb = iup_callbacks.leaveitem
+iup_callbacks.click_cb = iup_callbacks.click
+iup_callbacks.scrolltop_cb = iup_callbacks.scrolltop
+iup_callbacks.value_cb = iup_callbacks.valuecb
+iup_callbacks.draw_cb = iup_callbacks.draw
+iup_callbacks.dropcheck_cb = iup_callbacks.dropcheck
+iup_callbacks.fgcolor_cb = iup_callbacks.fgcolorcb
+iup_callbacks.bgcolor_cb = iup_callbacks.bgcolorcb
+iup_callbacks.value_edit_cb = iup_callbacks.value_edit
+IUPPPLOT = {parent = WIDGET}
+
+function IUPPPLOT:CreateIUPelement (obj)
+ return iupCreatePPlot ()
+end
+
+function iuppplot (o)
+ return IUPPPLOT:Constructor (o)
+end
+iup.pplot = iuppplot
+
+iup_callbacks.edit_cb.pplot = iup_pplot_edit_cb
+
+iup_callbacks.editbegin_cb = {"EDITBEGIN_CB", iup_pplot_editbegin_cb}
+iup_callbacks.editend_cb = {"EDITEND_CB", iup_pplot_editend_cb}
+iup_callbacks.select_cb = {"SELECT_CB", iup_pplot_select_cb}
+iup_callbacks.selectbegin_cb = {"SELECTBEGIN_CB", iup_pplot_selectbegin_cb}
+iup_callbacks.selectend_cb = {"SELECTEND_CB", iup_pplot_selectend_cb}
+iup_callbacks.delete_cb = {"DELETE_CB", iup_pplot_delete_cb}
+iup_callbacks.deletebegin_cb = {"DELETEBEGIN_CB", iup_pplot_deletebegin_cb}
+iup_callbacks.deleteend_cb = {"DELETEEND_CB", iup_pplot_deleteend_cb}
+iup_callbacks.predraw_cb = {"PREDRAW_CB", iup_pplot_predraw_cb}
+iup_callbacks.postdraw_cb = {"POSTDRAW_CB", iup_pplot_postdraw_cb}
+IUPSBOX = {parent = WIDGET}
+
+function IUPSBOX:CreateIUPelement (obj)
+ return iupCreateSbox(obj[1])
+end
+
+function iupsbox (o)
+ return IUPSBOX:Constructor (o)
+end
+iup.sbox = iupsbox
+IUPSPIN = {parent = WIDGET}
+
+function IUPSPIN:CreateIUPelement (obj)
+ return iupCreateSpin ()
+end
+
+function iupspin (o)
+ return IUPSPIN:Constructor (o)
+end
+iup.spin = iupspin
+
+IUPSPINBOX = {parent = WIDGET}
+
+function IUPSPINBOX:CreateIUPelement (obj)
+ return iupCreateSpinbox (obj[1])
+end
+
+function iupspinbox (o)
+ return IUPSPINBOX:Constructor (o)
+end
+iup.spinbox = iupspinbox
+
+iup_callbacks.spincb = {"SPIN_CB", iup_spin_cb}
+iup_callbacks.spin_cb = iup_callbacks.spincb
+IUPTABS = {parent = WIDGET}
+
+function IUPTABS:CreateIUPelement (obj)
+ return iupCreateTabs (obj, getn(obj))
+end
+
+function iuptabs (o)
+ return IUPTABS:Constructor (o)
+end
+iup.tabs = iuptabs
+
+iup_callbacks.tabchange = {"TABCHANGE_CB", iup_tabchange_cb}
+iup_callbacks.tabchange_cb = iup_callbacks.tabchangeIUPTREE = {parent = WIDGET}
+IUPTREEREFERENCETABLE = {} -- Used in C, see luatree.c
+
+function IUPTREE:CreateIUPelement (obj)
+ return iupCreateTree ()
+end
+
+function iuptree (o)
+ return IUPTREE:Constructor (o)
+end
+iup.tree = iuptree
+
+function TreeSetValueRec(handle, t, id)
+
+ if t == nil then return end
+
+ local cont = getn(t)
+
+ while cont >= 0 do
+ if type (t[cont]) == "table" then
+ if t[cont].branchname ~= nil then
+ IupSetAttribute(handle, "ADDBRANCH"..id, t[cont].branchname)
+ else
+ IupSetAttribute(handle, "ADDBRANCH"..id, "")
+ end
+ TreeSetValueRec(handle, t[cont], id+1)
+ else
+ if t[cont] then
+ IupSetAttribute(handle, "ADDLEAF"..id, t[cont])
+ end
+ end
+ cont = cont - 1
+ end
+end
+
+function TreeSetValue(handle, t)
+ if type(t) ~= "table" then
+ IupMessage("TreeLua Error", "Incorrect arguments to function TreeSetValue")
+ return
+ end
+ if t.branchname ~= nil then
+ IupSetAttribute(handle, "NAME", t.branchname)
+ end
+ TreeSetValueRec(handle, t, 0)
+end
+iup.TreeSetValue = TreeSetValue
+
+iup_callbacks.selection = {"SELECTION_CB", iup_tree_selection_cb}
+iup_callbacks.multiselection = {"MULTISELECTION_CB", iup_tree_multiselection_cb}
+iup_callbacks.branchopen = {"BRANCHOPEN_CB", iup_tree_branchopen_cb}
+iup_callbacks.branchclose = {"BRANCHCLOSE_CB", iup_tree_branchclose_cb}
+iup_callbacks.executeleaf = {"EXECUTELEAF_CB", iup_tree_executeleaf_cb}
+iup_callbacks.renamenode = {"RENAMENODE_CB", iup_tree_renamenode_cb}
+iup_callbacks.renamecb = {"RENAME_CB", iup_tree_renamecb_cb}
+iup_callbacks.showrenamecb = {"SHOWRENAME_CB", iup_tree_showrenamecb_cb}
+iup_callbacks.rightclick = {"RIGHTCLICK_CB", iup_tree_rightclick_cb}
+iup_callbacks.dragdrop = {"DRAGDROP_CB", iup_tree_dragdrop_cb}
+
+iup_callbacks.selection_cb = iup_callbacks.selection
+iup_callbacks.multiselection_cb = iup_callbacks.multiselection
+iup_callbacks.branchopen_cb = iup_callbacks.branchopen
+iup_callbacks.branchclose_cb = iup_callbacks.branchclose
+iup_callbacks.executeleaf_cb = iup_callbacks.executeleaf
+iup_callbacks.renamenode_cb = iup_callbacks.renamenode
+iup_callbacks.rename_cb = iup_callbacks.renamecb
+iup_callbacks.showrename_cb = iup_callbacks.showrenamecb
+iup_callbacks.rightclick_cb = iup_callbacks.rightclick
+iup_callbacks.dragdrop_cb = iup_callbacks.dragdrop
+IUPVAL = {parent = WIDGET}
+
+function IUPVAL:CreateIUPelement (obj)
+ return iupCreateVal (obj[1])
+end
+
+function iupval (o)
+ return IUPVAL:Constructor (o)
+end
+iup.val = iupval
+
+
+-- must set here because it is also used elsewhere with a different signature
+iup_callbacks.mousemove = {"MOUSEMOVE_CB", nil}
+iup_callbacks.mousemove_cb = iup_callbacks.mousemove
+iup_callbacks.mousemove.val = iup_val_mousemove_cb
+
+iup_callbacks.buttonpress = {"BUTTON_PRESS_CB", iup_val_button_press_cb}
+iup_callbacks.buttonrelease = {"BUTTON_RELEASE_CB", iup_val_button_release_cb}
+
+iup_callbacks.button_press_cb = iup_callbacks.buttonpress
+iup_callbacks.button_release_cb = iup_callbacks.buttonrelease
+----------------------------------------------------
+-- The main porpouse of this file is to build linux gcc makefiles.
+-- Must have Premake version 3 installed.
+-- Original Premake was changed to remove some parameters and add others.
+-- Default parameters:
+-- premake3s --target gnu --os linux
+-- But it can build windows gcc makefiles, and visual studio projects.
+-- premake3s --target gnu --os windows
+-- premake3s --target gnu --os macosx
+-- premake3s --target vs6
+-- premake3s --target vs2002
+-- premake3s --target vs2003
+-- premake3s --target vs2005
+-- In Linux the generated makefiles will not correctly build libraries in 64-bits.
+-- must add "-m64 -fPIC" flags
+----------------------------------------------------
+
+if (not options.target) then
+ options.target = "gnu"
+end
+
+if (not options.os) then
+ if (options.target ~= "gnu") then
+ options.os = "windows"
+ else
+ options.os = "linux"
+ end
+end
+
+function fixPackagePath(package_files)
+ if (options.os ~= "linux") then
+ for i, file in package_files do
+ package_files[i] = "../src/"..file
+ end
+ end
+end
+
+----------------------------------------------------
+
+project.name = "iup"
+project.bindir = "../bin"
+project.libdir = "../lib"
+
+if (options.os ~= "linux") then
+ if (options.os == "macosx") then
+ project.path = "../mak.macosx"
+ else
+ project.path = "../mak."..options.target
+ end
+end
+
+----------------------------------------------------
+
+package = newpackage()
+package.name = "iuplua3"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ "iuplua.c", "iuplua_api.c", "iuplua_widgets.c"
+}
+fixPackagePath(package.files)
+
+package.includepaths = { "../include", "../src", "$(LUA3)/include" }
+package.defines = {"IUPLUA_USELOH"}
+
+-- SRCLUA = iuplua.lua
+
+---------------------------------------------------------------------
+
+package = newpackage()
+package.name = "iupluacontrols3"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ "luaval.c", "luadial.c", "luagauge.c", "luagc.c", "luacbox.c", "luacells.c",
+ "luacb.c", "luatabs.c", "luamask.c", "luacontrols.c", "luagetparam.c",
+ "luamatrix.c", "luatree.c", "luasbox.c", "luaspin.c", "luacolorbar.c"
+}
+fixPackagePath(package.files)
+
+-- SRCLUA = luaval.lua luadial.lua luagauge.lua luacb.lua luatabs.lua luamatrix.lua luatree.lua luasbox.lua luaspin.lua luacells.lua
+
+package.includepaths = { "../include", "$(CD)/include", "$(LUA3)/include" }
+package.defines = {"IUPLUA_USELOH"}
+
+---------------------------------------------------------------------
+
+package = newpackage()
+package.name = "iuplua_pplot3"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ "luapplot.c"
+}
+fixPackagePath(package.files)
+
+-- SRCLUA = luapplot.lua
+
+package.includepaths = { "../include", "$(CD)/include", "$(LUA3)/include" }
+package.defines = {"IUPLUA_USELOH"}
+
+---------------------------------------------------------------------
+
+package = newpackage()
+package.name = "iupluagl3"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ "luaglcanvas.c"
+}
+fixPackagePath(package.files)
+
+package.includepaths = { "../include", "$(LUA3)/include" }
+
+---------------------------------------------------------------------
+
+package = newpackage()
+package.name = "iupluaim3"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ "luaim.c"
+}
+fixPackagePath(package.files)
+
+package.includepaths = { "../include", "$(LUA3)/include" }
+
+---------------------------------------------------------------------
+
+package = newpackage()
+package.name = "iuplua3exe"
+package.target = "iuplua3"
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "exe"
+package.linkflags = { "static-runtime" }
+
+package.files =
+{
+ "iupluaexe.c"
+}
+fixPackagePath(package.files)
+
+-- SRCLUA = console.lua
+
+package.includepaths = { "../include", "$(LUA3)/include", "$(CD)/include", "$(IM)/include" }
+package.defines = {"IUPLUA_USELOH"}
+package.links = { "imlua3", "cdluaiup3", "cdlua3",
+ "iupluagl3", "iupluaim3", "iupluacontrols3", "iuplua3",
+ "lualib", "lua",
+ "iupgl", "iupim", "iupcontrols",
+ "cdiup", "cd", "iup", "im" }
+package.libpaths = { "../lib", "$(IM)/lib", "$(CD)/lib", "$(LUA3)/lib" }
+
+if (options.os == "windows") then
+ tinsert(package.links, { "comctl32", "ole32", "opengl32", "glu32", "glaux" })
+else
+ tinsert(package.links, { "GLU", "GL", "Xm", "Xpm", "Xmu", "Xt", "Xext", "X11", "m" })
+ tinsert(package.libpaths, { "/usr/X11R6/lib" })
+end
+
+---------------------------------------------------------------------
+------------------------------------------------------------------------------
+-- Button class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "button",
+ parent = WIDGET,
+ creation = "S-",
+ callback = {
+ action = "",
+ }
+}
+
+function ctrl.createElement(class, arg)
+ return Button(arg.title)
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- Canvas class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "canvas",
+ parent = WIDGET,
+ creation = "-",
+ callback = {
+ action = "ff",
+ button_cb = "nnnns",
+ enterwindow_cb = "",
+ leavewindow_cb = "",
+ motion_cb = "nns",
+ resize_cb = "nn",
+ scroll_cb = "nff",
+ keypress_cb = "nn",
+ wom_cb = "n",
+ wheel_cb = "fnns",
+ mdiactivate_cb = "",
+ focus_cb = "n",
+ }
+}
+
+function ctrl.createElement(class, arg)
+ return Canvas()
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- Cbox class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "cbox",
+ parent = WIDGET,
+ creation = "v",
+ callback = {},
+ include = "iupcbox.h",
+ funcname = "Cboxv",
+ createfunc = [[
+static int Cboxv(lua_State *L)
+{
+ Ihandle **hlist = iuplua_checkihandle_array(L, 1);
+ Ihandle *h = IupCboxv(hlist);
+ iuplua_plugstate(L, h);
+ iuplua_pushihandle_raw(L, h);
+ free(hlist);
+ return 1;
+}
+ ]],
+}
+
+function ctrl.createElement(class, arg)
+ return Cboxv(arg)
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- Cells class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "cells",
+ parent = WIDGET,
+ creation = "",
+ callback = {
+ mouseclick_cb = "nnnnnns",
+ mousemotion_cb = "nnnns",
+ scrolling_cb = "nn",
+-- draw_cb = "nnnnnnn", -- already registered by the matrix
+ width_cb = "n",
+ height_cb = "n",
+ nlines_cb = "",
+ ncols_cb = "",
+ hspan_cb = "nn",
+ vspan_cb = "nn",
+ },
+ include = "iupcells.h"
+}
+
+function ctrl.redraw(handle)
+ handle.repaint = "YES"
+end
+
+function ctrl.createElement(class, arg)
+ return Cells()
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- Colorbar class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "colorbar",
+ parent = WIDGET,
+ creation = "",
+ callback = {
+ select_cb = "nn",
+ cell_cb = {"n", ret = "s"},
+ switch_cb = "nn",
+ extended_cb = "n",
+ },
+ funcname = "Colorbar",
+ include = "iupcolorbar.h",
+}
+
+function ctrl.createElement(class, arg)
+ return Colorbar(arg.action)
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- ColorBrowser class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "colorbrowser",
+ parent = WIDGET,
+ creation = "",
+ callback = {
+ drag_cb = "ccc",
+ change_cb = "ccc",
+ },
+ funcname = "ColorBrowser",
+ include = "iupcb.h",
+}
+
+function ctrl.createElement(class, arg)
+ return ColorBrowser(arg.action)
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- ColorDlg class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "colordlg",
+ parent = WIDGET,
+ creation = "",
+ funcname = "ColorDlg",
+ callback = {}
+}
+
+function ctrl.popup(handle, x, y)
+ Popup(handle,x,y)
+end
+
+function ctrl.destroy(handle)
+ return Destroy(handle)
+end
+
+function ctrl.createElement(class, arg)
+ return ColorDlg()
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+
+-- Utilities
+iupluacmd = {}
+
+function iupluacmd.printtable(t)
+ local n,v = next(t, nil)
+ print("--printtable Start--")
+ while n ~= nil do
+ print(tostring(n).."="..tostring(v))
+ n,v = next(t, n)
+ end
+ print("--printtable End--")
+end
+
+function iupluacmd.print_version_info()
+ print(_VERSION .. " " .. _COPYRIGHT)
+ if (im) then print("IM " .. im._VERSION .. " " .. im._COPYRIGHT) end
+ if (cd) then print("CD " .. cd._VERSION .. " " .. cd._COPYRIGHT) end
+ print("IUP " .. iup._VERSION .. " " .. iup._COPYRIGHT)
+ print("")
+ print("IUP Info")
+ print(" System: " .. iup.GetGlobal("SYSTEM"))
+ print(" System Version: " .. iup.GetGlobal("SYSTEMVERSION"))
+ local mot = iup.GetGlobal("MOTIFVERSION")
+ if (mot) then print(" Motif Version: ", mot) end
+ print(" Screen Size: " .. iup.GetGlobal("SCREENSIZE"))
+ print(" Screen Depth: " .. iup.GetGlobal("SCREENDEPTH"))
+ if (iup.GL_VENDOR) then print(" OpenGL Vendor: " .. iup.GL_VENDOR) end
+ if (iup.GL_RENDERER) then print(" OpenGL Renderer: " .. iup.GL_RENDERER) end
+ if (iup.GL_VERSION) then print(" OpenGL Version: " .. iup.GL_VERSION) end
+end
+
+-- IUPLUA Full Application
+
+iupluacmd.lastfilename = nil -- Last file open
+iupluacmd.mlCode = iup.multiline{expand="YES", size="200x120", font="COURIER_NORMAL_10"}
+iupluacmd.lblPosition = iup.label{title="0:0", size="50x"}
+iupluacmd.lblFileName = iup.label{title="", size="50x", expand="HORIZONTAL"}
+
+function iupluacmd.mlCode:caret_cb(lin, col)
+ iupluacmd.lblPosition.title = lin..":"..col
+end
+
+iupluacmd.butExecute = iup.button{size="50x15", title="Execute",
+ action="iup.dostring(iupluacmd.mlCode.value)"}
+iupluacmd.butClearCommands = iup.button{size="50x15", title="Clear",
+ action="iupluacmd.mlCode.value='' iupluacmd.lblFileName.title = '' iupluacmd.lastfilename = nil"}
+iupluacmd.butLoadFile = iup.button{size="50x15", title="Load..."}
+iupluacmd.butSaveasFile = iup.button{size="50x15", title="Save As..."}
+iupluacmd.butSaveFile = iup.button{size="50x15", title="Save"}
+
+iupluacmd.butSaveFile.action = function()
+ if (iupluacmd.lastfilename == nil) then
+ iupluacmd.butSaveasFile:action()
+ else
+ newfile = io.open(iupluacmd.lastfilename, "w+")
+ if (newfile ~= nil) then
+ newfile:write(iupluacmd.mlCode.value)
+ newfile:close()
+ else
+ error ("Cannot Save file "..filename)
+ end
+ end
+end
+
+iupluacmd.butSaveasFile.action = function()
+ local fd = iup.filedlg{dialogtype="SAVE", title="Save File",
+ filter="*.lua", filterinfo="Lua files",allownew=yes}
+ fd:popup(iup.LEFT, iup.LEFT)
+ local status = fd.status
+ iupluacmd.lastfilename = fd.value
+ iupluacmd.lblFileName.title = iupluacmd.lastfilename
+ fd:destroy()
+ if status ~= "-1" then
+ if (iupluacmd.lastfilename == nil) then
+ error ("Cannot Save file "..filename)
+ end
+ local newfile=io.open(iupluacmd.lastfilename, "w+")
+ if (newfile ~= nil) then
+ newfile:write(iupluacmd.mlCode.value)
+ newfile:close(newfile)
+ else
+ error ("Cannot Save file")
+ end
+ end
+end
+
+iupluacmd.butLoadFile.action = function ()
+ local fd=iup.filedlg{dialogtype="OPEN", title="Load File",
+ filter="*.lua", filterinfo="Lua Files", allownew="NO"}
+ fd:popup(iup.CENTER, iup.CENTER)
+ local status = fd.status
+ local filename = fd.value
+ fd:destroy()
+ if (status == "-1") or (status == "1") then
+ if (status == "1") then
+ error ("Cannot load file "..filename)
+ end
+ else
+ local newfile = io.open (filename, "r")
+ if (newfile == nil) then
+ error ("Cannot load file "..filename)
+ else
+ iupluacmd.mlCode.value=newfile:read("*a")
+ newfile:close (newfile)
+ iupluacmd.lastfilename = filename
+ iupluacmd.lblFileName.title = iupluacmd.lastfilename
+ end
+ end
+end
+
+iupluacmd.vbxConsole = iup.vbox
+{
+ iup.frame{iup.hbox{iup.vbox{iupluacmd.butLoadFile,
+ iupluacmd.butSaveFile,
+ iupluacmd.butSaveasFile,
+ iupluacmd.butClearCommands,
+ iupluacmd.butExecute;
+ margin="0x0", gap="10"},
+ iup.vbox{iupluacmd.lblFileName,
+ iupluacmd.mlCode,
+ iupluacmd.lblPosition;
+ alignment = "ARIGHT"};
+ alignment="ATOP"}; title="Commands"}
+ ;alignment="ACENTER", margin="5x5", gap="5"
+}
+
+-- Main Menu Definition.
+
+iupluacmd.mnuMain = iup.menu
+{
+ iup.submenu
+ {
+ iup.menu
+ {
+ iup.item{title="Exit", action="return iup.CLOSE"}
+ }; title="File"
+ },
+ iup.submenu{iup.menu
+ {
+ iup.item{title="Print Version Info...", action=iupluacmd.print_version_info},
+ iup.item{title="About...", action="iupluacmd.dlgAbout:popup(iup.CENTER, iup.CENTER)"}
+ };title="Help"}
+}
+
+-- Main Dialog Definition.
+
+iupluacmd.dlgMain = iup.dialog{iupluacmd.vbxConsole;
+ title="IupLua Console",
+ menu=iupluacmd.mnuMain,
+ defaultenter=iupluacmd.butExecute,
+ close_cb = "return iup.CLOSE"}
+
+-- About Dialog Definition.
+
+iupluacmd.dlgAbout = iup.dialog
+{
+ iup.vbox
+ {
+ iup.label{title="IupLua5 Console"},
+ iup.fill{size="5"},
+ iup.fill{size="5"},
+ iup.frame
+ {
+ iup.vbox
+ {
+ iup.label{title="Tecgraf/PUC-Rio"},
+ iup.label{title="iup@tecgraf.puc-rio.br"}
+ }
+ },
+ iup.fill{size="5"},
+ iup.button{title="OK", action="return iup.CLOSE", size="50X20"}
+ ;margin="10x10", alignment="ACENTER"
+ }
+ ;maxbox="NO", minbox="NO", resize="NO", title="About"
+}
+
+-- Displays the Main Dialog
+
+iupluacmd.dlgMain:show()
+iup.SetFocus(iupluacmd.mlCode)
+
+iup.MainLoop()
+
+iupluacmd.dlgMain:destroy()
+iupluacmd.dlgAbout:destroy()
+----------------------------------------------------------------------------
+-- Callback return values
+----------------------------------------------------------------------------
+IGNORE = -1
+DEFAULT = -2
+CLOSE = -3
+CONTINUE = -4
+
+----------------------------------------------------------------------------
+-- IupPopup e IupShowXY
+----------------------------------------------------------------------------
+CENTER = 65535
+LEFT = 65534
+RIGHT = 65533
+MOUSEPOS = 65532
+CURRENT = 65531
+CENTERPARENT = 65530
+TOP = LEFT
+BOTTOM = RIGHT
+ANYWHERE = CURRENT
+
+----------------------------------------------------------------------------
+-- Scrollbar
+----------------------------------------------------------------------------
+SBUP = 0
+SBDN = 1
+SBPGUP = 2
+SBPGDN = 3
+SBPOSV = 4
+SBDRAGV = 5
+SBLEFT = 6
+SBRIGHT = 7
+SBPGLEFT = 8
+SBPGRIGHT = 9
+SBPOSH = 10
+SBDRAGH = 11
+
+----------------------------------------------------------------------------
+-- SHOW_CB
+----------------------------------------------------------------------------
+SHOW = 0
+RESTORE = 1
+MINIMIZE = 2
+MAXIMIZE = 3
+HIDE = 4
+
+----------------------------------------------------------------------------
+-- BUTTON_CB
+----------------------------------------------------------------------------
+BUTTON1 = string.byte('1')
+BUTTON2 = string.byte('2')
+BUTTON3 = string.byte('3')
+BUTTON4 = string.byte('4')
+BUTTON5 = string.byte('5')
+
+----------------------------------------------------------------------------
+-- IupOpen
+----------------------------------------------------------------------------
+ERROR = 1
+NOERROR = 0
+OPENED = -1
+INVALID = -1
+------------------------------------------------------------------------------
+-- Template to create control classes for IupLua5
+-- The Lua module is used by the "generator.lua" to build a C module,
+-- and loaded during iuplua_open to initialize the control.
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "mycontrol", -- name of the control, used in the control creation: iup.mycontrol{}
+ -- also used for the generated C module
+ parent = WIDGET, -- used to define a few methods used fro creation and set attribute
+ creation = "nn", -- the creation parameters in Lua
+ -- "n" = int
+ -- "d" = double
+ -- "s" = char*
+ -- "S" = optional char*, can be nil
+ -- "i" = Ihandle*
+ -- "-" = NULL, no parameters in Lua, but a NULL parameter in C
+ -- "a" = char* array in a table
+ -- "t" = int array in a table
+ -- "v" = Ihandle* array in a table
+
+ funcname = "myControl", -- [optional] name of the function used in C
+ -- default is ctrl.nick with first letter uppercase
+
+ callback = { -- partial list of callbacks
+ -- only the callbacks that are not already defined by other controls needs to be defined
+ action = "ff",
+ button_cb = "nnnns",
+ enterwindow_cb = "",
+ leavewindow_cb = "",
+ motion_cb = "nns",
+ resize_cb = "nn",
+ scroll_cb = "nff",
+ keypress_cb = "nn",
+ wom_cb = "n",
+ wheel_cb = "fnns",
+ mdiactivate_cb = "",
+ focus_cb = "n",
+ value_cb = {"nn", ret = "s"}, -- ret is return type, default is n ("int")
+
+ -- the following types can be used for callback parameters:
+ -- n = "int",
+ -- s = "char *",
+ -- i = "Ihandle *",
+ -- c = "unsigned char ",
+ -- d = "double",
+ -- f = "float",
+ -- v = "Ihandle **",
+ --
+ -- Other parameters must be implemented in C using the extrafuncs module
+
+ -- IMPORTANT: callbacks with the same name in different controls
+ -- are assumed to have the same parameters, that's why they are defined only once
+ -- When callbacks conflict using the same name, but different parameters
+ -- generator.lua must be edited to include the callback in the list of conflicting callbacks
+ -- "action" is a common callback that conflicts
+ -- In the callback list, just declare the callback with the parameters used in that control.
+ }
+
+ include = "iupmycontrol.h", -- [optional] header to be included, it is where the creation function is declared.
+ extrafuncs = 1, -- [optional] additional module in C called by the initialization function
+
+ createfunc = [[ -- [optional] creation function in C,
+ -- used if creation parameters needs some interpretation in C
+ -- not to be used together with funcname
+#include<stdlib.h>
+static int myControl (lua_State * L)
+{
+ xxxx;
+ yyyy;
+ return 1;
+}
+]]
+
+ extracode = [[ -- [optional] extra fucntions to be defined in C.
+int luaopen_iupluamycontrol51(lua_State* L)
+{
+ return iupmycontrollua_open(L);
+}
+]]
+
+}
+
+-- must be defined so the WIDGET constructor can call it
+function ctrl.createElement(class, arg)
+ return myControl()
+end
+
+-- here you can add some custom methods to the class
+function ctrl.popup(handle, x, y)
+ Popup(handle,x,y)
+end
+
+iupRegisterWidget(ctrl) -- will make iup.mycontrol available
+iupSetClass(ctrl, "iup widget") -- register the class in the registry
+------------------------------------------------------------------------------
+-- Dial class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "dial",
+ parent = WIDGET,
+ creation = "s",
+ callback = {
+ mousemove_cb = "d", -- already registered by the val, but has a name conflict
+-- button_press_cb = "d", -- already registered by the val
+-- button_release_cb = "d", -- already registered by the val
+ },
+ include = "iupdial.h",
+}
+
+function ctrl.createElement(class, arg)
+ return Dial(arg[1])
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- Dialog class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "dialog",
+ parent = WIDGET,
+ creation = "i",
+ callback = {
+ map_cb = "",
+ close_cb = "",
+ show_cb = "n",
+ trayclick_cb = "nnn",
+ dropfiles_cb = "snnn",
+ }
+}
+
+function ctrl.createElement(class, arg)
+ return Dialog(arg[1])
+end
+
+function ctrl.popup(handle, x, y)
+ Popup(handle,x,y)
+end
+
+function ctrl.showxy(handle, x, y)
+ return ShowXY(handle, x, y)
+end
+
+function ctrl.destroy(handle)
+ return Destroy(handle)
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- FileDlg class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "filedlg",
+ parent = WIDGET,
+ creation = "",
+ callback = {
+ file_cb = "ss",
+ },
+ funcname = "FileDlg"
+}
+
+function ctrl.popup(handle, x, y)
+ Popup(handle,x,y)
+end
+
+function ctrl.destroy(handle)
+ return Destroy(handle)
+end
+
+function ctrl.createElement(class, arg)
+ return FileDlg()
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+
+------------------------------------------------------------------------------
+-- Fill class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "fill",
+ parent = WIDGET,
+ creation = "",
+ callback = {}
+}
+
+function ctrl.createElement(class, arg)
+ return Fill()
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- FontDlg class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "fontdlg",
+ parent = WIDGET,
+ creation = "",
+ funcname = "FontDlg",
+ callback = {}
+}
+
+function ctrl.popup(handle, x, y)
+ Popup(handle,x,y)
+end
+
+function ctrl.destroy(handle)
+ return Destroy(handle)
+end
+
+function ctrl.createElement(class, arg)
+ return FontDlg()
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+
+------------------------------------------------------------------------------
+-- Frame class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "frame",
+ parent = WIDGET,
+ creation = "i",
+ callback = {}
+}
+
+function ctrl.createElement(class, arg)
+ return Frame(arg[1])
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- Gauge class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "gauge",
+ parent = WIDGET,
+ creation = "",
+ callback = {},
+ include = "iupgauge.h",
+}
+
+function ctrl.createElement(class, arg)
+ return Gauge(arg.action)
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+
+function dofile(f)
+ pcall(loadfile(f))
+end
+
+-- compatibility functions (with iuplua.lua)
+function iupSetClass(ctrl, name)
+ element = ctrl
+end
+
+-- dummy functions
+iupluaNewClass = function() end
+iupSetMethod = iupluaNewClass
+iupRegisterWidget = iupluaNewClass
+
+c_types = {
+ n = "int",
+ s = "char *",
+ i = "Ihandle *",
+ c = "unsigned char ",
+ d = "double",
+ f = "float",
+ v = "Ihandle **",
+}
+
+-- Adjust the callbacks table
+function adjustcallbacktable(c)
+ d = {}
+ for i,j in pairs(c) do
+ if type(j) == "string" then
+ d[i] = { j, "IUP_".. string.upper(i)}
+ elseif type(j) == "table" then
+ d[i] = j
+ else
+ print("ERROR IN CALLBACK TABLE FORMAT")
+ end
+ end
+ return d
+end
+
+
+function header(o,i)
+ io.write [[
+/******************************************************************************
+ * Automatically generated file (iuplua5). Please don't change anything. *
+ *****************************************************************************/
+
+#include <stdlib.h>
+
+#include <lua.h>
+#include <lauxlib.h>
+
+#include <iup.h>
+#include <iuplua.h>
+]]
+ if i then io.write("#include <",i,">\n") end
+ io.write('#include "il.h"\n\n\n')
+end
+
+function firstupper(name)
+ return string.upper(string.sub(name,1,1)) .. string.sub(name,2,-1)
+end
+
+function write_creation(o, t)
+ local aux = {n = 1}
+ local u = firstupper(o)
+ local v = t.creation
+ local c = t.callback
+ if t.funcname then
+ u = t.funcname
+ end
+ io.write ("static int ",u,"(lua_State *L)\n")
+ io.write ("{\n")
+ if t.rettype == nil then io.write(" Ihandle *ih = Iup",u,"(")
+ elseif t.rettype == "n" then io.write(" int n = (Iup",u,"(")
+ elseif t.rettype == "s" then io.write(" char *s = (Iup",u,"(")
+ end
+ local max = string.len(v)
+ string.gsub(v, "(.)", function(p)
+ if p == "n" then io.write("luaL_checkint(L, ",aux.n,")")
+ elseif p == "d" then io.write("luaL_number(L, ",aux.n,")")
+ elseif p == "s" then io.write("(char *) luaL_checkstring(L, ",aux.n,")")
+ elseif p == "S" then io.write("(char *) luaL_optstring(L, ",aux.n,', NULL)')
+ elseif p == "i" then io.write("iuplua_checkihandle(L, ",aux.n,")")
+ elseif p == "-" then io.write("NULL")
+ elseif p == "a" then io.write("iuplua_checkstring_array(L, ",aux.n,")")
+ elseif p == "t" then io.write("iuplua_checkint_array(L, ",aux.n,")")
+ elseif p == "v" then io.write("iuplua_checkihandle_array(L, ",aux.n,")")
+ else io.write("FORMAT '", p, "' NOT SUPPORTED\n")
+ end
+ if aux.n < max then io.write(", ") end
+ aux.n = aux.n + 1
+ end)
+ io.write(");\n")
+
+ io.write(" iuplua_plugstate(L, ih);\n")
+ io.write(" iuplua_pushihandle_raw(L, ih);\n")
+ io.write(" return 1;\n")
+ io.write("}\n\n")
+end
+
+function write_callbacks(o, c)
+ local aux = { }
+ for i,v in pairs(c) do
+ local s = v[1]
+ local max = string.len(s)
+ aux.n = 0
+ io.write("static ")
+ if v.ret ~= nil then
+ if v.ret == "s" then
+ io.write("char * ")
+ end
+ else
+ io.write("int ")
+ end
+ io.write(o, "_", i, "(Ihandle *self")
+ if max > 0 then io.write(", ") end
+ string.gsub(s, "(.)", function(p)
+ io.write(c_types[p], " p", aux.n)
+ aux.n = aux.n + 1
+ if aux.n < max then io.write(", ") end
+ end)
+ io.write(")\n{\n")
+ io.write(' lua_State *L = iuplua_call_start(self, "', i, '");')
+ aux.n = 0
+ string.gsub(s, "(.)", function(p)
+ if p == "n" or p == "f" or p == "d" or p == "c" then
+ io.write("\n lua_pushnumber(L, p"..aux.n..");")
+ elseif p == "s" then
+ io.write("\n lua_pushstring(L, p"..aux.n..");")
+ elseif p == "i" then
+ io.write("\n iuplua_pushihandle(L, p"..aux.n..");")
+ else
+ io.write("\n ERROR !! ")
+ end
+ aux.n = aux.n + 1
+ end)
+ if v.ret ~= nil and v.ret == "s" then
+ io.write("\n return iuplua_call_rs(L, " .. max .. ");")
+ else
+ io.write("\n return iuplua_call(L, " .. max .. ");")
+ end
+ io.write("\n}\n\n")
+ end
+end
+
+function write_initialization(o,t)
+ local aux= {n=1}
+ local c = t.callback
+ local u = firstupper(o)
+ if t.extrafuncs then
+ io.write('void iuplua_', o,'funcs_open(lua_State *L);\n\n')
+ end
+ if t.openfuncname then
+ io.write("void ", t.openfuncname, "(lua_State * L)\n")
+ else
+ io.write("int iup", o,"lua_open(lua_State * L)\n")
+ end
+ io.write("{\n")
+ io.write(" iuplua_register(L, ")
+ if t.funcname then
+ u = t.funcname
+ end
+ io.write(u, ', "', u,'");\n\n')
+
+ for i,v in pairs(c) do
+ local type = "NULL"
+ if i == "action" or
+ i == "action_cb" or
+ i == "edit_cb" or
+ i == "mousemove_cb" then
+ type = '"'..string.lower(o)..'"'
+ end
+ io.write(' iuplua_register_cb(L, "',string.upper(i),'", (lua_CFunction)',o,'_',i,', ',type,');\n')
+ first = 0
+ end
+ io.write('\n')
+
+ if t.extrafuncs then
+ io.write(' iuplua_', o,'funcs_open(L);\n\n')
+ end
+ io.write('#ifdef IUPLUA_USELOH\n')
+ io.write('#ifdef TEC_BIGENDIAN\n')
+ io.write('#ifdef TEC_64\n')
+ io.write('#include "', o,'_be64.loh"\n')
+ io.write('#else\n')
+ io.write('#include "', o,'_be32.loh"\n')
+ io.write('#endif\n')
+ io.write('#else\n')
+ io.write('#ifdef TEC_64\n')
+ io.write('#ifdef WIN64\n')
+ io.write('#include "', o,'_le64w.loh"\n')
+ io.write('#else\n')
+ io.write('#include "', o,'_le64.loh"\n')
+ io.write('#endif\n')
+ io.write('#else\n')
+ io.write('#include "', o,'.loh"\n')
+ io.write('#endif\n')
+ io.write('#endif\n')
+ io.write('#else\n')
+ io.write(' iuplua_dofile(L, "', o,'.lua");\n')
+ io.write('#endif\n\n')
+ io.write(' return 0;\n')
+ io.write("}\n\n")
+end
+
+dofile(arg[1])
+element.callback = adjustcallbacktable(element.callback)
+
+io.output(element.nick..".c")
+header(element.nick, element.include)
+write_callbacks(element.nick, element.callback)
+if element.createfunc == nil then
+ write_creation(element.nick, element)
+else
+ io.write(element.createfunc)
+end
+write_initialization(element.nick, element)
+if element.extracode then
+ io.write(element.extracode)
+end
+------------------------------------------------------------------------------
+-- GLCanvas class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "glcanvas",
+ parent = WIDGET,
+ creation = "-",
+ funcname = "GLCanvas",
+ include = "iupgl.h",
+ callback = {
+ action = "nn",
+ },
+ extrafuncs = 1,
+ extracode = [[
+int iupgllua_open(lua_State * L)
+{
+ if (iuplua_opencall_internal(L))
+ IupGLCanvasOpen();
+
+ iuplua_changeEnv(L);
+ iupglcanvaslua_open(L);
+ iuplua_returnEnv(L);
+ return 0;
+}
+
+/* obligatory to use require"iupluagl" */
+int luaopen_iupluagl(lua_State* L)
+{
+ return iupgllua_open(L);
+}
+
+/* obligatory to use require"iupluagl51" */
+int luaopen_iupluagl51(lua_State* L)
+{
+ return iupgllua_open(L);
+}
+
+]]
+}
+
+function ctrl.createElement(class, arg)
+ return GLCanvas()
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- HBox class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "hbox",
+ parent = BOX,
+ creation = "-",
+ callback = {}
+}
+
+function ctrl.append(handle, elem)
+ Append(handle, elem)
+end
+
+function ctrl.createElement(class, arg)
+ return Hbox()
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- Image class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "image",
+ parent = WIDGET,
+ creation = "nns", -- fake definition
+ callback = {},
+ createfunc = [[
+#include<stdlib.h>
+static int Image (lua_State * L)
+{
+ int w, h, i, j;
+ char *img;
+ Ihandle *image;
+
+ h = luaL_getn(L, 1);
+ lua_pushnumber(L, 1);
+ lua_gettable(L, 1);
+ w = luaL_getn(L, -1);
+ lua_pop(L, 1);
+
+ img = (char *) malloc (h*w);
+
+ for (i=1; i<=h; i++)
+ {
+ lua_pushnumber(L, i);
+ lua_gettable(L, 1);
+ for (j=1; j<=w; j++)
+ {
+ int idx = (i-1)*w+(j-1);
+ lua_pushnumber(L, j);
+ lua_gettable(L, -2);
+ img[idx] = (char)lua_tonumber(L, -1);
+ lua_pop(L, 1);
+ }
+ lua_pop(L, 1);
+ }
+
+ image = IupImage(w,h,img);
+ free(img);
+
+ w = luaL_getn(L, 2);
+
+ for(i=1; i<=w; i++)
+ {
+ lua_pushnumber(L,i);
+ lua_pushnumber(L,i);
+ lua_gettable(L, 2);
+ IupStoreAttribute(image, (char *) lua_tostring(L,-2), (char *) lua_tostring(L,-1));
+ lua_pop(L, 2);
+ }
+
+ iuplua_plugstate(L, image);
+ iuplua_pushihandle_raw(L, image);
+ return 1;
+}
+
+]]
+}
+
+function ctrl.createElement(class, arg)
+ return Image(arg, arg.colors)
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- ImageRGB class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "imagergb",
+ parent = WIDGET,
+ creation = "nns", -- fake definition
+ funcname = "ImageRGB",
+ callback = {},
+ createfunc = [[
+static int ImageRGB(lua_State *L)
+{
+ int w = luaL_checkint(L, 1);
+ int h = luaL_checkint(L, 2);
+ unsigned char *pixels = iuplua_checkuchar_array(L, 3, w*h*3);
+ Ihandle *ih = IupImageRGB(w, h, pixels);
+ iuplua_plugstate(L, ih);
+ iuplua_pushihandle_raw(L, ih);
+ free(pixels);
+ return 1;
+}
+
+]]
+}
+
+function ctrl.createElement(class, arg)
+ return ImageRGB(arg.width, arg.height, arg.pixels)
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- ImageRGBA class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "imagergba",
+ parent = WIDGET,
+ creation = "nns", -- fake definition
+ funcname = "ImageRGBA",
+ callback = {},
+ createfunc = [[
+static int ImageRGBA(lua_State *L)
+{
+ int w = luaL_checkint(L, 1);
+ int h = luaL_checkint(L, 2);
+ unsigned char *pixels = iuplua_checkuchar_array(L, 3, w*h*4);
+ Ihandle *ih = IupImageRGBA(w, h, pixels);
+ iuplua_plugstate(L, ih);
+ iuplua_pushihandle_raw(L, ih);
+ free(pixels);
+ return 1;
+}
+
+]]
+}
+
+function ctrl.createElement(class, arg)
+ return ImageRGBA(arg.width, arg.height, arg.pixels)
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- Item class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "item",
+ parent = WIDGET,
+ creation = "S-",
+ callback = {
+ action = "",
+ highlight_cb = "",
+ }
+}
+
+function ctrl.createElement(class, arg)
+ return Item(arg.title)
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+-- This file is executed with the "iup" table already as the globalindex
+
+------------------------------------------------------------------------------
+-- Callback handler
+------------------------------------------------------------------------------
+
+callbacks = {}
+
+function iupCallMethod(name, ...)
+ local handle = arg[1] -- always the handle
+ local func = handle[name]
+ if (not func) then
+ return
+ end
+
+ if type(func) == "function" then
+ return func(unpack(arg))
+ elseif type(func) == "string" then
+ local temp = self
+ self = handle
+ local result = iup.dostring(func)
+ self = temp
+ return result
+ else
+ return iup.ERROR
+ end
+end
+
+function RegisterCallback(name, func, type)
+ if not callbacks[name] then callbacks[name] = {} end
+ local cb = callbacks[name]
+ if type then
+ cb[type] = func
+ else
+ cb[1] = func
+ end
+end
+
+------------------------------------------------------------------------------
+-- Meta Methods
+------------------------------------------------------------------------------
+
+
+local widget_gettable = function(object, index)
+ local p = object
+ local v
+ while 1 do
+ v = rawget(p, index)
+ if v then return v end
+ p = rawget(p, "parent")
+ if not p then return nil end
+ end
+end
+
+iupNewClass("iup widget")
+iupSetMethod("iup widget", "__index", widget_gettable)
+
+
+local ihandle_gettable = function(handle, index)
+ local INDEX = string.upper(index)
+ if (callbacks[INDEX]) then
+ local object = iupGetWidget(handle)
+ if (not object or type(object)~="table") then error("invalid iup handle") end
+ return object[index]
+ else
+ local value = GetAttribute(handle, INDEX)
+ if (not value) then
+ local object = iupGetWidget(handle)
+ if (not object or type(object)~="table") then error("invalid iup handle") end
+ return object[index]
+ elseif type(value)== "number" or type(value) == "string" then
+ local ih = GetHandle(value)
+ if ih then return ih
+ else return value end
+ else
+ return value
+ end
+ end
+end
+
+local ihandle_settable = function(handle, index, value)
+ local ti = type(index)
+ local tv = type(value)
+ local object = iupGetWidget(handle)
+ if (not object or type(object)~="table") then error("invalid iup handle") end
+ if ti == "number" or ti == "string" then -- check if a valid C name
+ local INDEX = string.upper(index)
+ local cb = callbacks[INDEX]
+ if (cb) then -- if a callback name
+ local func = cb[1]
+ if (not func) then
+ func = cb[GetType(handle)]
+ end
+ iupSetCallback(handle, INDEX, func, value) -- register the pre-defined C callback
+ object[index] = value -- store also in Lua
+ elseif iupGetClass(value) == "iup handle" then -- if a iup handle
+ local name = ihandle_setname(value)
+ StoreAttribute(handle, INDEX, name)
+ object[index] = nil -- if there was something in Lua remove it
+ elseif tv == "string" or tv == "number" or tv == "nil" then -- if a common value
+ StoreAttribute(handle, INDEX, value)
+ object[index] = nil -- if there was somthing in Lua remove it
+ else
+ object[index] = value -- store also in Lua
+ end
+ else
+ object[index] = value -- store also in Lua
+ end
+end
+
+iupNewClass("iup handle")
+iupSetMethod("iup handle", "__index", ihandle_gettable)
+iupSetMethod("iup handle", "__newindex", ihandle_settable)
+iupSetMethod("iup handle", "__tostring", ihandle_tostring)
+iupSetMethod("iup handle", "__eq", ihandle_compare) -- implemented in C
+
+
+------------------------------------------------------------------------------
+-- Utilities
+------------------------------------------------------------------------------
+
+function ihandle_setname(v) -- used also by radio and zbox
+ local name = GetName(v)
+ if not name then
+ local autoname = string.format("_IUPLUA_NAME(%s)", tostring(v))
+ SetHandle(autoname, v)
+ return autoname
+ end
+ return name
+end
+
+function iupRegisterWidget(ctrl) -- called by all the controls initialization functions
+ iup[ctrl.nick] = function(arg)
+ return ctrl:constructor(arg)
+ end
+end
+
+function RegisterHandle(handle, typename)
+
+ iupSetClass(handle, "iup handle")
+
+ local object = iupGetWidget(handle)
+ if not object then
+
+ local class = iup[string.upper(typename)]
+ if not class then
+ class = WIDGET
+ end
+
+ local object = { parent=class, handle=handle }
+ iupSetClass(object, "iup widget")
+ iupSetWidget(handle, object)
+ end
+
+ return handle
+end
+
+------------------------------------------------------------------------------
+-- Widget class (top class)
+------------------------------------------------------------------------------
+
+WIDGET = {
+ callback = {}
+}
+
+function WIDGET.show(object)
+ Show(object.handle)
+end
+
+function WIDGET.hide(object)
+ Hide(object.handle)
+end
+
+function WIDGET.map(object)
+ Map(object.handle)
+end
+
+function WIDGET.constructor(class, arg)
+ local handle = class:createElement(arg)
+ local object = {
+ parent = class,
+ handle = handle
+ }
+ iupSetClass(handle, "iup handle")
+ iupSetClass(object, "iup widget")
+ iupSetWidget(handle, object)
+ object:setAttributes(arg)
+ return handle
+end
+
+function WIDGET.setAttributes(object, arg)
+ local handle = object.handle
+ for i,v in pairs(arg) do
+ if type(i) == "number" and iupGetClass(v) == "iup handle" then
+ -- We should not set this or other elements (such as iuptext)
+ -- will erroneosly inherit it
+ rawset(object, i, v)
+ else
+ -- this will call settable metamethod
+ handle[i] = v
+ end
+ end
+end
+
+-- all the objects in the hierarchy must be "iup widget"
+-- Must repeat this call for every new widget
+iupSetClass(WIDGET, "iup widget")
+
+
+------------------------------------------------------------------------------
+-- Box class (inherits from WIDGET)
+------------------------------------------------------------------------------
+
+BOX = {
+ parent = WIDGET
+}
+
+function BOX.setAttributes(object, arg)
+ local handle = rawget(object, "handle")
+ local n = table.getn(arg)
+ for i = 1, n do
+ if iupGetClass(arg[i]) == "iup handle" then
+ Append(handle, arg[i])
+ end
+ end
+ WIDGET.setAttributes(object, arg)
+end
+
+iupSetClass(BOX, "iup widget")
+
+
+------------------------------------------------------------------------------
+-- Compatibility functions.
+------------------------------------------------------------------------------
+
+error_message_popup = nil
+
+function _ERRORMESSAGE(err)
+ if (error_message_popup) then
+ error_message_popup.value = err
+ else
+ local bt = button{title="Ok", size="60", action="error_message_popup = nil; return iup.CLOSE"}
+ local ml = multiline{expand="YES", readonly="YES", value=err, size="300x150"}
+ local vb = vbox{ml, bt; alignment="ACENTER", margin="10x10", gap="10"}
+ local dg = dialog{vb; title="Error Message",defaultesc=bt,defaultenter=bt,startfocus=bt}
+ error_message_popup = ml
+ dg:popup(CENTER, CENTER)
+ dg:destroy()
+ error_message_popup = nil
+ end
+end
+
+pack = function (...) return arg end
+
+function protectedcall_(f, err)
+ if not f then
+ _ERRORMESSAGE(err)
+ return
+ end
+ local ret = pack(pcall(f))
+ if not ret[1] then
+ _ERRORMESSAGE(ret[2])
+ return
+ else
+ table.remove(ret, 1)
+ return unpack(ret)
+ end
+end
+
+function dostring(s) return protectedcall_(loadstring(s)) end
+function dofile(f) return protectedcall_(loadfile(f)) end
+
+function RGB(r, g, b)
+ return string.format("%d %d %d", 255*r, 255*g, 255*b)
+end
+------------------------------------------------------------------------------
+-- Label class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "label",
+ parent = WIDGET,
+ creation = "S",
+ callback = {}
+}
+
+function ctrl.createElement(class, arg)
+ return Label(arg.title)
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- List class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "list",
+ parent = WIDGET,
+ creation = "-",
+ callback = {
+ action = "snn",
+ multiselect_cb = "s",
+ edit_cb = "ns",
+ }
+}
+
+function ctrl.createElement(class, arg)
+ return List()
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- Matrix class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "matrix",
+ parent = WIDGET,
+ creation = "-",
+ callback = {
+ action_cb = "nnnns",
+ click_cb = "nns",
+ release_cb = "nns",
+ drop_cb = "inn",
+ dropcheck_cb = "nn",
+ draw_cb = "nnnnnnn", -- fake definitions to be replaced by matrixfuncs module
+ dropselect_cb = "nnisnn",
+ edition_cb = "nnn",
+ enteritem_cb = "nn",
+ leaveitem_cb = "nn",
+ mousemove_cb = "nn",
+ scrolltop_cb = "nn",
+ fgcolor_cb = "nn", -- fake definitions to be replaced by matrixfuncs module
+ bgcolor_cb = "nn",
+ value_cb = {"nn", ret = "s"}, -- ret is return type
+ value_edit_cb = "nns",
+ mark_cb = "nn",
+ markedit_cb = "nnn",
+ },
+ include = "iupmatrix.h",
+ extrafuncs = 1,
+}
+
+function ctrl.createElement(class, arg)
+ return Matrix(arg.action)
+end
+
+function ctrl.setcell(handle, l, c, val)
+ SetAttribute(handle,l..":"..c,val)
+end
+
+function ctrl.getcell(handle, l, c)
+ return GetAttribute(handle,l..":"..c)
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- Menu class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "menu",
+ parent = BOX,
+ creation = "-",
+ callback = {
+ open_cb = "",
+ menuclose_cb = "",
+ }
+}
+
+function ctrl.popup(handle, x, y)
+ Popup(handle, x, y)
+end
+
+function ctrl.append(handle, elem)
+ Append(handle, elem)
+end
+
+function ctrl.createElement(class, arg)
+ local n = table.getn(arg)
+ for i=1,n do
+ if type(arg[i]) == "table" then
+ itemarg = {}
+ for u,v in pairs(arg[i]) do
+ if type(u) ~= "number" then
+ itemarg[u] = v
+ end
+ end
+ if type(arg[i][1]) == "string" and (type(arg[i][2]) == "function" or type(arg[i][2]) == "string") then
+ itemarg.title = arg[i][1]
+ itemarg.action = arg[i][2]
+ arg[i] = item(itemarg)
+ elseif type(arg[i][1]) == "string" and type(arg[i][2]) == "userdata" then
+ itemarg[1] = arg[i][2]
+ itemarg.title = arg[i][1]
+ arg[i] = submenu(itemarg)
+ end
+ end
+ end
+ return Menu()
+end
+
+function ctrl.showxy(handle, x, y)
+ return ShowXY(handle, x, y)
+end
+
+function ctrl.destroy(handle)
+ return Destroy(handle)
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- MessageDlg class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "messagedlg",
+ parent = WIDGET,
+ creation = "",
+ funcname = "MessageDlg",
+ callback = {}
+}
+
+function ctrl.popup(handle, x, y)
+ Popup(handle,x,y)
+end
+
+function ctrl.destroy(handle)
+ return Destroy(handle)
+end
+
+function ctrl.createElement(class, arg)
+ return MessageDlg()
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+
+------------------------------------------------------------------------------
+-- Multiline class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "multiline",
+ parent = WIDGET,
+ creation = "-",
+ callback = {
+ action = "ns",
+ },
+ funcname = "MultiLine",
+}
+
+function ctrl.createElement(class, arg)
+ return MultiLine()
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- OleControl class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "olecontrol",
+ parent = WIDGET,
+ creation = "s",
+ funcname = "OleControl",
+ callback = {},
+ include = "iupole.h",
+ extracode = [[
+int iupolelua_open(lua_State* L)
+{
+ if (iuplua_opencall_internal(L))
+ IupOleControlOpen();
+
+ iuplua_changeEnv(L);
+ iupolecontrollua_open(L);
+ iuplua_returnEnv(L);
+ return 0;
+}
+
+/* obligatory to use require"iupluaole" */
+int luaopen_iupluaole(lua_State* L)
+{
+ return iupolelua_open(L);
+}
+
+/* obligatory to use require"iupluaole51" */
+int luaopen_iupluaole51(lua_State* L)
+{
+ return iupolelua_open(L);
+}
+
+]]
+}
+
+function ctrl.createElement(class, arg)
+ local ctl = OleControl(arg[1])
+
+ -- if luacom is loaded, use it to access methods and properties
+ -- of the control
+ if luacom then
+ local punk = ctl.iunknown
+ if punk then
+ ctl.com = luacom.MakeLuaCOM(luacom.MakeIUnknown(punk))
+ end
+ end
+
+ return ctl
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- PPlot class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "pplot",
+ parent = WIDGET,
+ creation = "",
+ funcname = "PPlot",
+ callback = {
+ select_cb = "nnffn",
+ selectbegin_cb = "",
+ selectend_cb = "",
+ predraw_cb = "n", -- fake definitions to be replaced by pplotfuncs module
+ postdraw_cb = "n", -- fake definitions to be replaced by pplotfuncs module
+ edit_cb = "nnffff", -- fake definitions to be replaced by pplotfuncs module
+ editbegin_cb = "",
+ editend_cb = "",
+ delete_cb = "nnff",
+ deletebegin_cb = "",
+ deleteend_cb = "",
+ },
+ include = "iup_pplot.h",
+ extrafuncs = 1,
+}
+
+function ctrl.createElement(class, arg)
+ return PPlot(arg.action)
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+----------------------------------------------------
+-- The main porpouse of this file is to build linux gcc makefiles.
+-- Must have Premake version 3 installed.
+-- Original Premake was changed to remove some parameters and add others.
+-- Default parameters:
+-- premake3s --target gnu --os linux
+-- But it can build windows gcc makefiles, and visual studio projects.
+-- premake3s --target gnu --os windows
+-- premake3s --target gnu --os macosx
+-- premake3s --target vs6
+-- premake3s --target vs2002
+-- premake3s --target vs2003
+-- premake3s --target vs2005
+-- In Linux the generated makefiles will not correctly build libraries in 64-bits.
+-- must add "-m64 -fPIC" flags
+----------------------------------------------------
+
+if (not options.target) then
+ options.target = "gnu"
+end
+
+if (not options.os) then
+ if (options.target ~= "gnu") then
+ options.os = "windows"
+ else
+ options.os = "linux"
+ end
+end
+
+function fixPackagePath(package_files)
+ if (options.os ~= "linux") then
+ for i, file in package_files do
+ package_files[i] = "../src/"..file
+ end
+ end
+end
+
+if (options.os ~= "linux") then
+ if (options.os == "macosx") then
+ project.path = "../mak.macosx"
+ else
+ project.path = "../mak."..options.target
+ end
+end
+
+----------------------------------------------------
+
+project.name = "iup"
+project.bindir = "../bin"
+project.libdir = "../lib"
+
+----------------------------------------------------
+
+package = newpackage()
+package.name = "iuplua51"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ "iuplua.c", "scanf.c", "iuplua_api.c", "fontdlg.c",
+ "button.c", "canvas.c", "dialog.c", "messagedlg.c",
+ "filedlg.c", "fill.c", "frame.c", "hbox.c",
+ "item.c", "image.c", "label.c", "menu.c", "multiline.c",
+ "list.c", "separator.c", "radio.c", "colordlg.c",
+ "submenu.c", "text.c", "toggle.c", "vbox.c", "zbox.c", "timer.c"
+}
+fixPackagePath(package.files)
+
+package.includepaths = { "../include", "../src", "$(LUA51)/include" }
+package.defines = {"IUPLUA_USELOH"}
+
+--SRCLUA = iuplua.lua constants.lua $(CTRLUA)
+--GC = $(addsuffix .c, $(basename $(CTRLUA)))
+--$(GC) : %.c : %.lua %.loh generator.lua
+-- lua5 generator.lua $<
+
+---------------------------------------------------------------------
+
+package = newpackage()
+package.name = "iupluacontrols51"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ "val.c", "dial.c", "gauge.c", "gc.c", "cbox.c", "cells.c", "getparam.c",
+ "colorbrowser.c", "tabs.c", "mask.c", "colorbar.c",
+ "matrix.c", "tree.c", "sbox.c", "spin.c", "spinbox.c",
+ "controls.c", "mask.c", "treefuncs.c", "matrixfuncs.c"
+}
+fixPackagePath(package.files)
+
+package.includepaths = { "../include", "$(CD)/include", "$(LUA51)/include" }
+package.defines = {"IUPLUA_USELOH"}
+
+--SRCLUA = val.lua dial.lua gauge.lua colorbrowser.lua tabs.lua sbox.lua matrix.lua tree.lua spin.lua spinbox.lua
+
+---------------------------------------------------------------------
+
+package = newpackage()
+package.name = "iuplua_pplot51"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ "pplot.c", "pplotfuncs.c"
+}
+fixPackagePath(package.files)
+
+package.includepaths = { "../include", "$(CD)/include", "$(LUA51)/include" }
+package.defines = {"IUPLUA_USELOH"}
+
+--SRCLUA = pplot.lua
+
+---------------------------------------------------------------------
+
+package = newpackage()
+package.name = "iupluagl51"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ "glcanvas.c", "glcanvasfuncs.c"
+}
+fixPackagePath(package.files)
+
+-- SRCLUA = glcanvas.lua
+
+package.includepaths = { "../include", "$(LUA51)/include" }
+package.defines = {"IUPLUA_USELOH"}
+
+---------------------------------------------------------------------
+
+package = newpackage()
+package.name = "iupluaim51"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.files =
+{
+ "iupluaim.c"
+}
+fixPackagePath(package.files)
+
+package.includepaths = { "../include", "$(LUA51)/include" }
+
+---------------------------------------------------------------------
+
+package = newpackage()
+package.name = "iuplua51exe"
+package.target = "iuplua51"
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "exe"
+package.linkflags = { "static-runtime" }
+
+package.files =
+{
+ "iupluaexe51.c"
+}
+fixPackagePath(package.files)
+
+-- SRCLUA = console.lua
+
+package.includepaths = { "../include", "$(LUA51)/include", "$(CD)/include", "$(IM)/include" }
+
+package.links = { "imlua_process51", "im_process", "imlua_cd51", "imlua51",
+ "cdluaiup51", "cdlua51",
+ "iupluagl51", "iupluaim51", "iuplua_pplot51.lib", "iupluacontrols51", "iuplua51",
+ "lua5.1",
+ "iupgl", "iupim", "iup_pplot.lib", "iupcontrols",
+ "cdiup", "cd", "iup", "im" }
+package.libpaths = { "../lib", "$(IM)/lib", "$(CD)/lib", "$(LUA51)/lib", }
+
+if (options.os == "windows") then
+ tinsert(package.links, { "cdgdiplus", "gdiplus", "comctl32", "opengl32", "glu32", "glaux" })
+else
+ tinsert(package.links, { "GLU", "GL", "Xm", "Xpm", "Xmu", "Xt", "Xext", "X11", "m" })
+ tinsert(package.libpaths, { "/usr/X11R6/lib" })
+end
+
+---------------------------------------------------------------------
+------------------------------------------------------------------------------
+-- Radio class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "radio",
+ parent = WIDGET,
+ creation = "i",
+ callback = {}
+}
+
+function ctrl.CreateChildrenNames(obj)
+ if obj then
+ if obj.parent.parent == BOX then
+ local i = 1
+ while obj[i] do
+ ctrl.CreateChildrenNames (obj[i])
+ i = i+1
+ end
+ elseif obj.parent == IUPFRAME then
+ ctrl.CreateChildrenNames (obj[1])
+ else
+ ihandle_setname(obj)
+ end
+ end
+end
+
+function ctrl.createElement(class, arg)
+ ctrl.CreateChildrenNames(arg[1])
+ return Radio(arg[1])
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- Sbox class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "sbox",
+ parent = WIDGET,
+ creation = "i",
+ callback = {},
+ include="iupsbox.h"
+}
+
+function ctrl.createElement(class, arg)
+ return Sbox(arg[1])
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- Separator class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "separator",
+ parent = WIDGET,
+ creation = "",
+ callback = {}
+}
+
+function ctrl.createElement(class, arg)
+ return Separator()
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- Spin class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "spin",
+ parent = WIDGET,
+ creation = "",
+ callback = {
+ spin_cb = "n",
+ },
+ include = "iupspin.h",
+}
+
+function ctrl.createElement(class, arg)
+ return Spin(arg.action)
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- SpinBox class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "spinbox",
+ parent = WIDGET,
+ creation = "i",
+ callback = {
+ spin_cb = "n",
+ },
+ include = "iupspin.h",
+}
+
+function ctrl.createElement(class, arg)
+ return Spinbox(arg[1])
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- Submenu class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "submenu",
+ parent = WIDGET,
+ creation = "Si",
+ callback = {
+-- open_cb = "", -- already registered by the menu
+-- menuclose_cb = "", -- already registered by the menu
+ }
+}
+
+function ctrl.createElement(class, arg)
+ return Submenu(arg.title, arg[1])
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- Tabs class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "tabs",
+ parent = WIDGET,
+ creation = "v",
+ callback = {
+ tabchange_cb = "ii",
+ },
+ include = "iuptabs.h",
+ funcname = "Tabsv",
+ createfunc = [[
+static int Tabsv(lua_State *L)
+{
+ Ihandle **hlist = iuplua_checkihandle_array(L, 1);
+ Ihandle *h = IupTabsv(hlist);
+ iuplua_plugstate(L, h);
+ iuplua_pushihandle_raw(L, h);
+ free(hlist);
+ return 1;
+}
+
+]],
+}
+
+function ctrl.createElement(class, arg)
+ return Tabsv(arg)
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- Text class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "text",
+ parent = WIDGET,
+ creation = "-",
+ callback = {
+ action = "ns",
+ caret_cb = "nn",
+ }
+}
+
+function ctrl.createElement(class, arg)
+ return Text()
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- Timer class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "timer",
+ parent = WIDGET,
+ creation = "",
+ callback = {
+ action_cb = "",
+ },
+}
+
+function ctrl.createElement(class, arg)
+ return Timer()
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- Toggle class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "toggle",
+ parent = WIDGET,
+ creation = "S-",
+ callback = {
+ action = "n",
+ }
+}
+
+function ctrl.createElement(class, arg)
+ return Toggle(arg.title)
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- Tree class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "tree",
+ parent = WIDGET,
+ creation = "",
+ callback = {
+ selection_cb = "nn",
+ multiselection_cb = "nn", -- fake definition to be replaced by treefuncs module
+ branchopen_cb = "n",
+ branchclose_cb = "n",
+ executeleaf_cb = "n",
+ renamenode_cb = "ns",
+ rename_cb = "ns",
+ showrename_cb = "n",
+ rightclick_cb = "n",
+ dragdrop_cb = "nnnn",
+ },
+ include = "iuptree.h",
+ extrafuncs = 1,
+}
+
+function TreeSetValueRec(handle, t, id)
+ if t == nil then return end
+ local cont = table.getn(t)
+ while cont >= 0 do
+ if type (t[cont]) == "table" then
+ if t[cont].branchname ~= nil then
+ SetAttribute(handle, "ADDBRANCH"..id, t[cont].branchname)
+ TreeSetValueRec(handle, t[cont], id+1)
+ end
+ else
+ if t[cont] then
+ SetAttribute(handle, "ADDLEAF"..id, t[cont])
+ end
+ end
+ cont = cont - 1
+ end
+end
+
+function TreeSetValue(handle, t)
+ if t.branchname ~= nil then
+ SetAttribute(handle, "NAME", t.branchname)
+ end
+ TreeSetValueRec(handle, t, 0)
+end
+
+function ctrl.createElement(class, arg)
+ return Tree()
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- Val class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "val",
+ parent = WIDGET,
+ creation = "s",
+ callback = {
+ mousemove_cb = "d",
+ button_press_cb = "d",
+ button_release_cb = "d",
+ },
+ include = "iupval.h",
+}
+
+function ctrl.createElement(class, arg)
+ return Val(arg[1])
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- VBox class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "vbox",
+ parent = BOX,
+ creation = "-",
+ callback = {}
+}
+
+function ctrl.append (handle, elem)
+ Append(handle, elem)
+end
+
+function ctrl.createElement(class, arg)
+ return Vbox()
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+------------------------------------------------------------------------------
+-- ZBox class
+------------------------------------------------------------------------------
+local ctrl = {
+ nick = "zbox",
+ parent = BOX,
+ creation = "-",
+ callback = {}
+}
+
+function ctrl.append (handle, elem)
+ ihandle_setname(elem)
+ Append(handle, elem)
+end
+
+function ctrl.SetChildrenNames(obj)
+ if obj then
+ local i = 1
+ while obj[i] do
+ ihandle_setname(obj[i])
+ i = i+1
+ end
+ end
+end
+
+function ctrl.createElement(class, arg)
+ ctrl.SetChildrenNames(arg)
+ return Zbox()
+end
+
+iupRegisterWidget(ctrl)
+iupSetClass(ctrl, "iup widget")
+----------------------------------------------------
+-- The main porpouse of this file is to build linux gcc makefiles.
+-- Must have Premake version 3 installed.
+-- Original Premake was changed to remove some parameters and add others.
+-- Default parameters:
+-- premake3s --target gnu --os linux
+-- But it can build windows gcc makefiles, and visual studio projects.
+-- premake3s --target gnu --os windows
+-- premake3s --target gnu --os macosx
+-- premake3s --target vs6
+-- premake3s --target vs2002
+-- premake3s --target vs2003
+-- premake3s --target vs2005
+-- In Linux the generated makefiles will not correctly build libraries in 64-bits.
+-- must add "-m64 -fPIC" flags
+----------------------------------------------------
+
+if (not options.target) then
+ options.target = "gnu"
+end
+
+if (not options.os) then
+ if (options.target ~= "gnu") then
+ options.os = "windows"
+ else
+ options.os = "linux"
+ end
+end
+
+function fixPackagePath(package_files)
+ if (options.os ~= "linux") then
+ for i, file in package_files do
+ package_files[i] = "../src/"..file
+ end
+ end
+end
+
+----------------------------------------------------
+
+project.name = "iup"
+project.bindir = "../bin"
+project.libdir = "../lib"
+
+if (options.os ~= "linux") then
+ if (options.os == "macosx") then
+ project.path = "../mak.macosx"
+ else
+ project.path = "../mak."..options.target
+ end
+end
+
+----------------------------------------------------
+
+package = newpackage()
+package.name = "iup_pplot"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "lib"
+package.buildflags = { "static-runtime" }
+
+package.includepaths = { ".", "../include" }
+
+package.files = { "iup_pplot.cpp", "PPlot.cpp", "PPlotInteraction.cpp" }
+fixPackagePath(package.files)
+
+----------------------------------------------------
+----------------------------------------------------
+-- The main porpouse of this file is to build linux gcc makefiles.
+-- Must have Premake version 3 installed.
+-- Original Premake was changed to remove some parameters and add others.
+-- Default parameters:
+-- premake3s --target gnu --os linux
+-- But it can build windows gcc makefiles, and visual studio projects.
+-- premake3s --target gnu --os windows
+-- premake3s --target gnu --os macosx
+-- premake3s --target vs6
+-- premake3s --target vs2002
+-- premake3s --target vs2003
+-- premake3s --target vs2005
+-- In Linux the generated makefiles will not correctly build libraries in 64-bits.
+-- must add "-m64 -fPIC" flags
+----------------------------------------------------
+
+if (not options.target) then
+ options.target = "gnu"
+end
+
+if (not options.os) then
+ if (options.target ~= "gnu") then
+ options.os = "windows"
+ else
+ options.os = "linux"
+ end
+end
+
+function fixPackagePath(package_files)
+ if (options.os ~= "linux") then
+ for i, file in package_files do
+ package_files[i] = "../src/"..file
+ end
+ end
+end
+
+----------------------------------------------------
+
+project.name = "iup"
+project.bindir = "../bin"
+project.libdir = "../lib"
+
+if (options.os ~= "linux") then
+ if (options.os == "macosx") then
+ project.path = "../mak.macosx"
+ else
+ project.path = "../mak."..options.target
+ end
+end
+
+----------------------------------------------------
+
+package = newpackage()
+package.name = "iupview"
+package.target = package.name
+package.objdir = "../obj/"..package.name
+package.language = "c++"
+package.kind = "winexe"
+package.linkflags = { "static-runtime" }
+
+package.files =
+{
+ "iupview.c"
+}
+fixPackagePath(package.files)
+
+package.includepaths = { ".", "../include", "$(CD)/include" }
+package.links = { "iupgl", "iupim", "iupimglib", "iupcontrols", "cdiup", "cd", "iup", "im" }
+package.libpaths = { "../lib", "$(IM)/lib", "$(CD)/lib" }
+
+if (options.os == "windows") then
+ tinsert(package.links, { "comctl32", "opengl32", "glu32", "glaux" })
+else
+ tinsert(package.links, { "GLU", "GL", "Xm", "Xpm", "Xmu", "Xt", "Xext", "X11", "m" })
+ tinsert(package.libpaths, { "/usr/X11R6/lib" })
+end
+
+----------------------------------------------------
+
+l = iup.label{title="1", size="200x"}
+
+function idle_cb()
+ local v = tonumber(l.title) + 1
+ l.title = v
+ if v == 10000 then
+ iup.SetIdle(nil)
+ end
+ return iup.DEFAULT
+end
+
+dlg = iup.dialog{l; title = "Idle Test"}
+
+dlg:showxy(iup.CENTER, iup.CENTER)
+
+-- Registers idle callback
+iup.SetIdle(idle_cb)
+
+-- Creates a IupColorBrowser control and updates, through
+-- callbacks, the values of texts representing the R, G and B
+-- components of the selected color.
+
+text_red = iup.text{}
+text_green = iup.text{}
+text_blue = iup.text{}
+
+cb = iup.colorbrowser{}
+
+function update(r, g, b)
+ text_red.value = r
+ text_green.value = g
+ text_blue.value = b
+end
+
+function cb:drag_cb(r, g ,b)
+ update(r,g,b)
+end
+
+function cb:change_cb(r, g ,b)
+ update(r,g,b)
+end
+
+vbox = iup.vbox {
+ iup.fill {},
+ text_red,
+ iup.fill {},
+ text_green,
+ iup.fill {},
+ text_blue,
+ iup.fill {}
+ }
+
+dlg = iup.dialog{iup.hbox {cb, iup.fill{}, vbox}; title = "ColorBrowser"}
+dlg:showxy(iup.CENTER, iup.CENTER)
+--IupDial Example in IupLua
+
+lbl_h = iup.label{title = "0", alignment = "ACENTER", size = "100x10"}
+lbl_v = iup.label{title = "0", alignment = "ACENTER", size = "100x10"}
+lbl_c = iup.label{title = "0", alignment = "ACENTER", size = "100x10"}
+
+dial_v = iup.dial{"VERTICAL"; size="100x100"}
+dial_h = iup.dial{"HORIZONTAL"; density=0.3}
+
+function dial_v:mousemove_cb(a)
+ lbl_v.title = a
+ return iup.DEFAULT
+end
+
+function dial_v:button_press_cb(a)
+ lbl_v.bgcolor = "255 0 0"
+ return iup.DEFAULT
+end
+
+function dial_v:button_release_cb(a)
+ lbl_v.bgcolor = nil
+ return iup.DEFAULT
+end
+
+function dial_h:mousemove_cb(a)
+ lbl_h.title = a
+ return iup.DEFAULT
+end
+
+function dial_h:button_press_cb(a)
+ lbl_h.bgcolor = "255 0 0"
+ return iup.DEFAULT
+end
+
+function dial_h:button_release_cb(a)
+ lbl_h.bgcolor = nil
+ return iup.DEFAULT
+end
+
+dlg = iup.dialog
+{
+ iup.hbox
+ {
+ iup.fill{},
+ iup.vbox
+ {
+ iup.fill{},
+ iup.frame
+ {
+ iup.vbox
+ {
+ iup.hbox
+ {
+ iup.fill{},
+ dial_v,
+ iup.fill{}
+ } ,
+ iup.hbox
+ {
+ iup.fill{},
+ lbl_v,
+ iup.fill{}
+ }
+ }
+ },
+ iup.fill{},
+ iup.frame
+ {
+ iup.vbox
+ {
+ iup.hbox
+ {
+ iup.fill{},
+ dial_h,
+ iup.fill{}
+ } ,
+ iup.hbox
+ {
+ iup.fill{},
+ lbl_h,
+ iup.fill{}
+ } ,
+ }
+ },
+ iup.fill{},
+ },
+ iup.fill{}
+ }; title="IupDial"
+}
+
+dlg:showxy(iup.CENTER,iup.CENTER)
+
+
+function idle_cb()
+ local value = gauge.value
+ value = value + 0.0001;
+ if value > 1.0 then
+ value = 0.0
+ end
+ gauge.value = value
+ return iup.DEFAULT
+end
+
+gauge = iup.gauge{}
+gauge.size = "QUARTERxEIGHTH"
+gauge.show_text = "YES"
+
+dlg = iup.dialog{gauge; title = "IupGauge"}
+
+-- Registers idle callback
+iup.SetIdle(idle_cb)
+
+dlg:showxy(iup.CENTER, iup.CENTER)
+--
+-- IupGetColor Example in IupLua
+--
+-- Creates a predefined color selection dialog which returns the
+-- selected color in the RGB format.
+--
+
+r, g, b = iup.GetColor(100, 100, 255, 255, 255)
+if (r) then
+ print("r="..r.." g="..g.." b="..b)
+end
+-- IupGetParam Example in IupLua
+-- Shows a dialog with all possible fields.
+
+iup.SetLanguage("ENGLISH")
+
+function param_action(dialog, param_index)
+ if (param_index == -1) then
+ print("OK")
+ elseif (param_index == -2) then
+ print("Map")
+ elseif (param_index == -3) then
+ print("Cancel")
+ else
+ local param = iup.GetParamParam(dialog, param_index)
+ print("PARAM"..param_index.." = "..param.value)
+ end
+ return 1
+end
+
+-- set initial values
+pboolean = 1
+pinteger = 3456
+preal = 3.543
+pinteger2 = 192
+preal2 = 0.5
+pangle = 90
+pstring = "string text"
+plist = 2
+pstring2 = "second text\nsecond line"
+
+ret, pboolean, pinteger, preal, pinteger2, preal2, pangle, pstring, plist, pstring2 =
+ iup.GetParam("Title", param_action,
+ "Boolean: %b\n"..
+ "Integer: %i\n"..
+ "Real 1: %r\n"..
+ "Sep1 %t\n"..
+ "Integer: %i[0,255]\n"..
+ "Real 2: %r[-1.5,1.5]\n"..
+ "Sep2 %t\n"..
+ "Angle: %a[0,360]\n"..
+ "String: %s\n"..
+ "List: %l|item1|item2|item3|\n"..
+ "Sep3 %t\n"..
+ "Multiline: %m\n",
+ pboolean, pinteger, preal, pinteger2, preal2, pangle, pstring, plist, pstring2)
+if (ret == 0) then
+ return
+end
+
+iup.Message("IupGetParam",
+ "Boolean Value: "..pboolean.."\n"..
+ "Integer: "..pinteger.."\n"..
+ "Real 1: "..preal.."\n"..
+ "Integer: "..pinteger2.."\n"..
+ "Real 2: "..preal2.."\n"..
+ "Angle: "..pangle.."\n"..
+ "String: "..pstring.."\n"..
+ "List Index: "..plist.."\n"..
+ "String: "..pstring2)
+-- Example IupGLCanvas in Lua
+-- Creates a OpenGL canvas and draws a line in it.
+-- This example uses gllua binding of OpenGL to Lua.
+
+cv = iup.glcanvas{buffer="DOUBLE", rastersize = "300x300"}
+
+function cv:action(x, y)
+ iup.GLMakeCurrent(self)
+ --glClearColor(1.0, 1.0, 1.0, 1.0)
+ --glClear(GL_COLOR_BUFFER_BIT)
+ --glClear(GL_DEPTH_BUFFER_BIT)
+ --glMatrixMode( GL_PROJECTION )
+ --glViewport(0, 0, 300, 300)
+ --glLoadIdentity()
+ --glBegin( GL_LINES )
+ --glColor(1.0, 0.0, 0.0)
+ --glVertex(0.0, 0.0)
+ --glVertex(10.0, 10.0)
+ --glEnd()
+ iup.GLSwapBuffers(self)
+ return iup.DEFAULT
+end
+
+dg = iup.dialog{cv; title="IupGLCanvas Example"}
+
+function cv:k_any(c)
+ if c == iup.K_q then
+ return iup.CLOSE
+ else
+ return iup.DEFAULT
+ end
+end
+
+
+dg:show()
+
+canvas = iup.glcanvas{buffer="DOUBLE", rastersize = "640x480"}
+
+function canvas:resize_cb(width, height)
+ iup.GLMakeCurrent(self)
+
+ gl.Viewport(0, 0, width, height)
+
+ gl.MatrixMode('PROJECTION')
+ gl.LoadIdentity()
+
+ gl.MatrixMode('MODELVIEW')
+ gl.LoadIdentity()
+
+end
+
+function canvas:action()
+ iup.GLMakeCurrent(self)
+
+ gl.MatrixMode("PROJECTION")
+ gl.LoadIdentity()
+ gl.Ortho(0, 1, 1, 0, -1.0, 1.0)
+ gl.MatrixMode("MODELVIEW")
+ gl.LoadIdentity()
+ gl.PushMatrix()
+ gl.Translate(0.25,0.5, 0)
+ gl.Scale(0.2, 0.2, 1)
+
+ gl.BlendFunc("SRC_ALPHA", "ONE_MINUS_SRC_ALPHA")
+
+ gl.ClearColor(0,0,0,1)
+ gl.Clear("DEPTH_BUFFER_BIT,COLOR_BUFFER_BIT")
+ gl.Enable("BLEND")
+
+ -- draw rectangle
+ gl.Color( {1, 1, 0, 0.8} )
+ gl.Rect(-1,-1,1,1)
+
+ --------------------------------------------------------
+ -- Create List That Draws the Circle
+ --------------------------------------------------------
+
+ planet = 1
+ orbit = 2
+ pi =
+
+ gl.NewList(planet, "COMPILE")
+ gl.Begin("POLYGON")
+ for i=0, 100 do
+ cosine = math.cos(i * 2 * math.pi/100.0)
+ sine = math.sin(i * 2 * math.pi/100.0)
+ gl.Vertex(cosine,sine)
+ end
+ gl.End()
+ gl.EndList()
+
+ gl.NewList(orbit, "COMPILE")
+ gl.Begin("LINE_LOOP")
+ for i=0, 100 do
+ cosine = math.cos(i * 2 * math.pi/100.0)
+ sine = math.sin(i * 2 * math.pi/100.0)
+ gl.Vertex(cosine, sine)
+ end
+ gl.End()
+ gl.EndList()
+
+ --------------------------------------------------------
+
+ gl.Color( {0, 0.5, 0, 0.8} )
+ gl.CallList(planet)
+
+ gl.Color( {0, 0, 0, 1} )
+ lists = { orbit }
+ gl.CallLists(lists)
+
+ gl.EnableClientState ("VERTEX_ARRAY")
+
+ vertices = { {-3^(1/2)/2, 1/2}, {3^(1/2)/2, 1/2}, {0, -1}, {-3^(1/2)/2, -1/2}, {3^(1/2)/2, -1/2}, {0, 1} }
+
+ gl.VertexPointer (vertices)
+
+ -- draw first triangle
+ gl.Color( {0, 0, 1, 0.5} )
+
+ gl.Begin("TRIANGLES")
+ gl.ArrayElement (0)
+ gl.ArrayElement (1)
+ gl.ArrayElement (2)
+ gl.End()
+
+ -- draw second triangle
+ gl.Color( {1, 0, 0, 0.5} )
+ gl.VertexPointer (vertices)
+ gl.DrawArrays("TRIANGLES", 3, 3)
+
+ -- draw triangles outline
+ gl.Color(1,1,1,1)
+ elements = { 0, 1, 2} gl.DrawElements("LINE_LOOP", elements)
+ elements = { 3, 4, 5} gl.DrawElements("LINE_LOOP", elements)
+
+ gl.DisableClientState ("VERTEX_ARRAY")
+
+ gl.PopMatrix()
+ gl.Translate(0.75,0.5, 0)
+ gl.Scale(0.2, 0.2, 1)
+
+ ----------------------------------------------------------------------------
+
+ gl.BlendFunc("SRC_ALPHA", "ONE_MINUS_SRC_ALPHA")
+
+ -- draw rectangle
+ gl.Color( {1, 1, 0, 0.8} )
+
+ gl.Begin("QUADS")
+ gl.Vertex(-1,-1)
+ gl.Vertex( 1,-1)
+ gl.Vertex( 1, 1)
+ gl.Vertex(-1, 1)
+ gl.End()
+ -------------------------------
+ gl.Color( {0, 0.5, 0, 0.8} )
+ gl.Begin("POLYGON")
+ for i=0, 100 do
+ cosine = math.cos(i * 2 * math.pi/100.0)
+ sine = math.sin(i * 2 * math.pi/100.0)
+ gl.Vertex(cosine,sine)
+ end
+ gl.End()
+
+ gl.Color( {0, 0, 0, 1} )
+ gl.Begin("LINE_LOOP")
+ for i=0, 100 do
+ cosine = math.cos(i * 2 * math.pi/100.0)
+ sine = math.sin(i * 2 * math.pi/100.0)
+ gl.Vertex(cosine, sine)
+ end
+ gl.End()
+
+ -- draw first triangle
+ gl.Color( {0, 0, 1, 0.5} )
+ gl.Begin("TRIANGLES")
+ gl.Vertex (vertices[1])
+ gl.Vertex (vertices[2])
+ gl.Vertex (vertices[3])
+ gl.End()
+ -- draw second triangle
+ gl.Color( {1, 0, 0, 0.5} )
+ gl.Begin("TRIANGLES")
+ gl.Vertex (vertices[4])
+ gl.Vertex (vertices[5])
+ gl.Vertex (vertices[6])
+ gl.End()
+ -- draw triangles outline
+ gl.Color(1,1,1,1)
+ gl.Begin("LINE_LOOP")
+ gl.Vertex (vertices[1])
+ gl.Vertex (vertices[2])
+ gl.Vertex (vertices[3])
+ gl.End()
+ gl.Begin("LINE_LOOP")
+ gl.Vertex (vertices[4])
+ gl.Vertex (vertices[5])
+ gl.Vertex (vertices[6])
+ gl.End()
+
+ iup.GLSwapBuffers(self)
+ gl.Flush()
+
+end
+
+dialog = iup.dialog{canvas; title="Lua GL Test Application"}
+dialog:show()
+-- IupMask Example in Lua
+-- Creates an IupText that accepts only numbers.
+
+txt = iup.text{}
+iup.maskSet(txt, "/d*", 0, 1) ;
+dg = iup.dialog{txt}
+dg:show()mat= iup.matrix{numlin=3, numcol=3}
+mat:setcell(1,1,"Only numbers")
+iup.maskMatSet(mat, "/d*", 0, 1, 1, 1) ;
+dg = iup.dialog{mat}
+dg:show()
+
+mat = iup.matrix {numcol=5, numlin=3,numcol_visible=5, numlin_visible=3, widthdef=34}
+mat.resizematrix = "YES"
+mat:setcell(0,0,"Inflation")
+mat:setcell(1,0,"Medicine")
+mat:setcell(2,0,"Food")
+mat:setcell(3,0,"Energy")
+mat:setcell(0,1,"January 2000")
+mat:setcell(0,2,"February 2000")
+mat:setcell(1,1,"5.6")
+mat:setcell(2,1,"2.2")
+mat:setcell(3,1,"7.2")
+mat:setcell(1,2,"4.6")
+mat:setcell(2,2,"1.3")
+mat:setcell(3,2,"1.4")
+dlg = iup.dialog{iup.vbox{mat; margin="10x10"}}
+dlg:showxy(iup.CENTER, iup.CENTER)
+matrix = iup.matrix
+{
+ numlin=3,
+ numcol=3,
+ numcol_visible=3,
+ height0=10,
+ widthdef=30,
+ scrollbar="VERTICAL",
+}
+
+data = {
+ {"1:1", "1:2", "1:3"},
+ {"2:1", "2:2", "2:3"},
+ {"3:1", "3:2", "3:3"},
+ }
+
+function matrix:value_cb(l, c)
+ if l == 0 or c == 0 then
+ return "title"
+ end
+ return data[l][c]
+end
+
+function matrix:value_edit_cb(l, c, newvalue)
+ data[l][c] = newvalue
+end
+
+dlg=iup.dialog{matrix; title="IupMatrix in Callback Mode" }
+dlg:show()
+
+bt = iup.button{title="Test"}
+bt.expand = "YES"
+box = iup.sbox{bt}
+box.direction = "SOUTH"
+box.color = "0 0 255"
+
+ml = iup.multiline{}
+ml.expand = "YES"
+vbox = iup.vbox{box, ml}
+
+lb = iup.label{title="Label"}
+lb.expand = "YES"
+dg = iup.dialog{iup.hbox{vbox, lb}}
+dg:show()
+--IupSpeech Example in Lua
+
+label = iuplabel{title="Possible commands are defined in xml1.xml"}
+text = iuptext {size="200"}
+
+function reco(self, msg)
+ text.value = msg
+end
+
+sk = iupspeech{action=reco, grammar="xml1.xml", say="xml1 loaded"}
+
+dg = iupdialog{iupvbox{label, text}; title = "IupSpeech Test"}
+dg:show()
+-- Creates boxes
+vboxA = iup.vbox{iup.label{title="TABS AAA"}, iup.button{title="AAA"}}
+vboxB = iup.vbox{iup.label{title="TABS BBB"}, iup.button{title="BBB"}}
+
+-- Sets titles of the vboxes
+vboxA.tabtitle = "AAAAAA"
+vboxB.tabtitle = "BBBBBB"
+
+-- Creates tabs
+tabs = iup.tabs{vboxA, vboxB}
+
+-- Creates dialog
+dlg = iup.dialog{tabs; title="Test IupTabs", size="200x80"}
+
+-- Shows dialog in the center of the screen
+dlg:showxy(iup.CENTER, iup.CENTER)-- IupTree Example in IupLua
+-- Creates a tree with some branches and leaves.
+-- Two callbacks are registered: one deletes marked nodes when the Del key
+-- is pressed, and the other, called when the right mouse button is pressed,
+-- opens a menu with options.
+
+tree = iup.tree{}
+
+-- Creates rename dialog
+ok = iup.button{title = "OK",size="EIGHTH"}
+cancel = iup.button{title = "Cancel",size="EIGHTH"}
+
+text = iup.text{border="YES",expand="YES"}
+dlg_rename = iup.dialog{iup.vbox{text,iup.hbox{ok,cancel}};
+ defaultenter=ok,
+ defaultesc=cancel,
+ title="Enter node's name",
+ size="QUARTER",
+ startfocus=text}
+
+-- Creates menu displayed when the right mouse button is pressed
+addleaf = iup.item {title = "Add Leaf"}
+addbranch = iup.item {title = "Add Branch"}
+renamenode = iup.item {title = "Rename Node"}
+menu = iup.menu{addleaf, addbranch, renamenode}
+
+-- Callback of the right mouse button click
+function tree:rightclick_cb(id)
+ tree.value = id
+ menu:popup(iup.MOUSEPOS,iup.MOUSEPOS)
+ return iup.DEFAULT
+end
+
+-- Callback called when a node will be renamed
+function tree:renamenode_cb(id)
+ text.value = tree.name
+
+ dlg_rename:popup(iup.CENTER, iup.CENTER)
+ iup.SetFocus(tree)
+
+ return iup.DEFAULT
+end
+
+-- Callback called when the rename operation is cancelled
+function cancel:action()
+ return iup.CLOSE
+end
+
+-- Callback called when the rename operation is confirmed
+function ok:action()
+ tree.name = text.value
+
+ return iup.CLOSE
+end
+
+function tree:k_any(c)
+ if c == 339 then tree.delnode = "MARKED" end
+ return iup.DEFAULT
+end
+
+-- Callback called when a leaf is added
+function addleaf:action()
+ tree.addleaf = ""
+ tree.redraw = "YES"
+ return iup.DEFAULT
+end
+
+-- Callback called when a branch is added
+function addbranch:action()
+ tree.addbranch = ""
+ tree.redraw = "YES"
+ return iup.DEFAULT
+end
+
+-- Callback called when a branch will be renamed
+function renamenode:action()
+ tree:renamenode_cb(tree.value)
+ tree.redraw = "YES"
+ return iup.DEFAULT
+end
+
+function init_tree_atributes()
+ tree.font = "COURIER_NORMAL_10"
+ tree.name = "Figures"
+ tree.addbranch = "3D"
+ tree.addbranch = "2D"
+ tree.addbranch1 = "parallelogram"
+ tree.addleaf2 = "diamond"
+ tree.addleaf2 = "square"
+ tree.addbranch1 = "triangle"
+ tree.addleaf2 = "scalenus"
+ tree.addleaf2 = "isoceles"
+ tree.value = "6"
+ tree.ctrl = "YES"
+ tree.shift = "YES"
+ tree.addexpanded = "NO"
+ tree.redraw = "YES"
+end
+
+dlg = iup.dialog{tree; title = "IupTree", size = "QUARTERxTHIRD"}
+dlg:showxy(iup.CENTER,iup.CENTER)
+init_tree_atributes()--IupTree Example in IupLua
+--Creates a tree with some branches and leaves. Uses a Lua Table to define the IupTree structure.
+
+tree = iup.tree{}
+dlg = iup.dialog{tree ; title = "TableTree result", size = "200x200"}
+dlg:showxy(iup.CENTER,iup.CENTER)
+
+t = {
+ {
+ "Horse",
+ "Whale";
+ branchname = "Mammals"
+ },
+ {
+ "Shrimp",
+ "Lobster";
+ branchname = "Crustaceans"
+ };
+ branchname = "Animals"
+}
+iup.TreeSetValue(tree, t)
+
+tree.redraw = "YES"
+-- IupTree Example in IupLua
+-- Creates a tree with some branches and leaves.
+-- Two callbacks are registered: one deletes marked nodes when the Del key
+-- is pressed, and the other, called when the right mouse button is pressed,
+-- opens a menu with options.
+
+
+tree = iup.tree{}
+
+
+function tree:showrename_cb(id)
+ print("SHOWRENAME")
+ return iup.DEFAULT
+end
+-- Callback called when a node will be renamed
+function tree:renamenode_cb(id)
+ print("RENAMENODE")
+ return iup.DEFAULT
+end
+
+
+function tree:k_any(c)
+ if c == 316 then tree.delnode = "MARKED" end
+ return iup.DEFAULT
+end
+
+
+function init_tree_atributes()
+ tree.font = "COURIER_NORMAL_10"
+ tree.name = "Figures"
+ tree.addbranch = "3D"
+ tree.addbranch = "2D"
+ tree.addbranch1 = "parallelogram"
+ tree.addleaf2 = "diamond"
+ tree.addleaf2 = "square"
+ tree.addbranch1 = "triangle"
+ tree.addleaf2 = "scalenus"
+ tree.addleaf2 = "isoceles"
+ tree.value = "6"
+ tree.ctrl = "YES"
+ tree.shift = "YES"
+ tree.addexpanded = "NO"
+ tree.redraw = "YES"
+ tree.showrename = "NO"
+end
+
+
+dlg = iup.dialog{tree; title = "IupTree", size = "QUARTERxTHIRD"}
+dlg:showxy(iup.CENTER,iup.CENTER)
+init_tree_atributes()-- IupVal Example in IupLua
+-- Creates two Valuator controls, exemplifying the two possible types.
+-- When manipulating the Valuator, the label's value changes.
+
+if not string then
+ string = {}
+ string.format = format
+end
+
+function fbuttonpress(self)
+ if(self.type == "VERTICAL") then
+ lbl_v.fgcolor = "255 0 0"
+ else
+ lbl_h.fgcolor = "255 0 0"
+ end
+ return iup.DEFAULT
+end
+
+function fbuttonrelease(self)
+ if(self.type == "VERTICAL") then
+ lbl_v.fgcolor = "0 0 0"
+ else
+ lbl_h.fgcolor = "0 0 0"
+ end
+ return iup.DEFAULT
+end
+
+function fmousemove(self, val)
+ local buffer = "iup.VALUE="..string.format('%.2f', val)
+ if (self.type == "VERTICAL") then
+ lbl_v.title=buffer
+ else
+ lbl_h.title=buffer
+ end
+ return iup.DEFAULT
+end
+
+val_v = iup.val{"VERTICAL"; min=0, max=1, value="0.3",
+ mousemove_cb=fmousemove,
+ button_press_cb=fbuttonpress,
+ button_release_cb=fbuttonrelease
+}
+
+lbl_v = iup.label{title="VALUE= ", size=70, type="1"}
+
+val_h = iup.val{"HORIZONTAL"; min=0, max=1, value=0,
+ mousemove_cb=fmousemove,
+ button_press_cb=fbuttonpress,
+ button_release_cb=fbuttonrelease
+}
+
+lbl_h = iup.label{title="VALUE= ", size=70, type="2"}
+
+dlg_val = iup.dialog
+{
+ iup.hbox
+ {
+ iup.frame
+ {
+ iup.vbox
+ {
+ val_v,
+ lbl_v
+ }
+ },
+ iup.frame
+ {
+ iup.vbox
+ {
+ val_h,
+ lbl_h
+ }
+ }
+ };
+ title="Valuator Test"
+}
+
+dlg_val:show()
+
+-- IupAlarm Example in IupLua
+-- Shows a dialog similar to the one shown when you exit a program
+-- without saving.
+
+b = iup.Alarm("IupAlarm Example", "File not saved! Save it now?" ,"Yes" ,"No" ,"Cancel")
+
+-- Shows a message for each selected button
+if b == 1 then
+ iup.Message("Save file", "File saved sucessfully - leaving program")
+elseif b == 2 then
+ iup.Message("Save file", "File not saved - leaving program anyway")
+elseif b == 3 then
+ iup.Message("Save file", "Operation canceled")
+end-- IupFileDlg Example in IupLua
+-- Shows a typical file-saving dialog.
+
+-- Creates a file dialog and sets its type, title, filter and filter info
+filedlg = iup.filedlg{dialogtype = "SAVE", title = "File save",
+ filter = "*.bmp", filterinfo = "Bitmap files",
+ directory="c:\\windows"}
+
+-- Shows file dialog in the center of the screen
+filedlg:popup (iup.ANYWHERE, iup.ANYWHERE)
+
+-- Gets file dialog status
+status = filedlg.status
+
+if status == "1" then
+ iup.Message("New file",filedlg.value)
+elseif status == "0" then
+ iup.Message("File already exists", filedlg.value)
+elseif status == "-1" then
+ iup.Message("IupFileDlg","Operation canceled")
+end-- IupGetFile Example in IupLua
+-- Shows a typical file-selection dialog.
+
+iup.SetLanguage("ENGLISH")
+f, err = iup.GetFile("*.txt")
+if err == 1 then
+ iup.Message("New file", f)
+elseif err == 0 then
+ iup.Message("File already exists", f)
+elseif err == -1 then
+ iup.Message("IupFileDlg", "Operation canceled")
+elseif err == -2 then
+ iup.Message("IupFileDlg", "Allocation errr")
+elseif err == -3 then
+ iup.Message("IupFileDlg", "Invalid parameter")
+end-- IupListDialog Example in IupLua
+-- Shows a color-selection dialog.
+
+iup.SetLanguage("ENGLISH")
+size = 8
+marks = { 0,0,0,0,1,1,0,0 }
+options = {"Blue", "Red", "Green", "Yellow", "Black", "White", "Gray", "Brown"}
+
+error = iup.ListDialog(2,"Color selection",size,options,0,16,5,marks);
+
+if error == -1 then
+ iup.Message("IupListDialog", "Operation canceled")
+else
+ local selection = ""
+ local i = 1
+ while i ~= size+1 do
+ if marks[i] ~= 0 then
+ selection = selection .. options[i] .. "\n"
+ end
+ i = i + 1
+ end
+ if selection == "" then
+ iup.Message("IupListDialog","No option selected")
+ else
+ iup.Message("Selected options",selection)
+ end
+end-- IupMessage Example in IupLua
+-- Shows a dialog with the message: “Click the button”.
+
+iup.Message ("IupMessage", "Press the button")-- IupScanf Example in IupLua
+-- Shows a dialog with three fields to be filled.
+-- One receives a string, the other receives a real number and
+-- the last receives an integer number.
+-- Note: In Lua, the function does not return the number of successfully read characters.
+
+iup.SetLanguage("ENGLISH")
+local integer = 12
+local real = 1e-3
+local text ="This is a vector of characters"
+local fmt = "IupScanf\nText:%300.40%s\nReal:%20.10%g\nInteger:%20.10%d\n"
+
+text, real, integer = iup.Scanf (fmt, text, real, integer)
+
+if text then
+ local string = "Text: "..text.."\nReal: "..real.."\nInteger: "..integer
+ iup.Message("IupScanf", string)
+else
+ iup.Message("IupScanf", "Operation canceled");
+end
+-- Creates four buttons. The first uses images, the second turns the first
+-- on and off, the third exits the application and the last does nothing
+
+-- defines released button image
+img_release = iup.image {
+ {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
+ {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,4,4,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,4,4,4,4,3,3,3,2,2},
+ {1,1,3,3,3,3,3,4,4,4,4,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,4,4,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},
+ {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2};
+ colors = { "215 215 215", "40 40 40", "30 50 210", "240 0 0" }
+}
+
+-- defines pressed button image
+img_press = iup.image {
+ {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
+ {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,4,4,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,4,4,4,4,3,3,3,3,2,2},
+ {1,1,3,3,3,3,4,4,4,4,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,4,4,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},
+ {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2};
+ colors = { "40 40 40", "215 215 215", "0 20 180", "210 0 0" }
+}
+
+-- defines deactivated button image
+img_inactive = iup.image {
+ {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
+ {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,4,4,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,4,4,4,4,3,3,3,2,2},
+ {1,1,3,3,3,3,3,4,4,4,4,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,4,4,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2},
+ {1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},
+ {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2};
+ colors = { "215 215 215", "40 40 40", "100 100 100", "200 200 200" }
+}
+
+-- creates a text box
+text = iup.text{ readonly = "YES", SIZE = "EIGHTH" }
+
+-- creates a button with image
+btn_image = iup.button{ title = "Button with image", image = img_release, impress = img_press, iminactive = img_inactive }
+
+-- creates a button
+btn_big = iup.button{ title = "Big useless button", size = "EIGHTHxEIGHTH" }
+
+-- creates a button entitled Exit
+btn_exit = iup.button{ title = "Exit" }
+
+-- creates a button entitled Activate
+btn_on_off = iup.button{ title = "Activate" }
+
+-- creates a dialog and sets dialog's title and turns off resize, menubox, maximize and minimize
+dlg = iup.dialog{ iup.vbox{ iup.hbox{ iup.fill{}, btn_image, btn_on_off, btn_exit, iup.fill{} }, text, btn_big }; title = "IupButton", resize = "NO", menubox = "NO", maxbox = "NO", minbox = "NO" }
+
+-- callback called when activate button is activated
+function btn_on_off:action()
+ if btn_image.active == "YES" then
+ btn_image.active = "NO"
+ else
+ btn_image.active = "YES"
+ end
+
+ return iup.DEFAULT
+end
+
+-- callback called when the button is pressed or released
+function btn_image:button( b, e )
+ if( b == iup.BUTTON1 ) then
+ if( e == 1 ) then
+ -- botão pressionado
+ text.value = "Red button pressed"
+ else
+ -- botão solto
+ text.value = "Red button released"
+ end
+ end
+ return iup.DEFAULT
+end
+
+-- callback called when the exit button is activated
+function btn_exit:action()
+ dlg:hide()
+end
+
+-- shows dialog
+dlg:showxy( iup.CENTER, iup.CENTER)--IupCanvas Example in IupLua
+
+cv = iup.canvas {size="300x100", xmin=0, xmax=99, posx=0, dx=10}
+dg = iup.dialog{iup.frame{cv}; title="IupCanvas"}
+
+function cv:motion_cb(x, y, r)
+ print(x, y, r)
+ return iup.DEFAULT
+end
+
+dg:showxy(iup.CENTER, iup.CENTER)
+--IupDialog Example in IupLua
+--Creates a simple dialog.
+
+vbox = iup.vbox { iup.label {title="Label"}, iup.button { title="Test" } }
+dlg = iup.dialog{vbox; title="Dialog"}
+dlg:show()
+
+tecgraf = iup.image{
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 02, 05, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 04, 05, 05, 05, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 11, 05, 05, 05, 05, 12, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 10, 06, 05, 03, 05, 05, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 07, 05, 01, 01, 03, 05, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 07, 05, 01, 01, 03, 05, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 02, 09, 09, 01, 01, 03, 07, 06, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 07, 06, 01, 01, 01, 01, 02, 07, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 07, 06, 01, 01, 01, 01, 04, 07, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 07, 06, 01, 01, 01, 01, 04, 07, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 11, 02, 07, 05, 04, 04, 04, 04, 04, 04, 11, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 07, 04, 04, 04, 06, 03, 03, 07, 05, 05, 07, 07, 04, 04, 04, 04, 10, 10, 10, 10, 10, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 04, 04, 04, 09, 09, 06, 05, 04, 08, 07, 05, 01, 01, 01, 01, 07, 05, 06, 03, 03, 03, 03, 04, 10, 07, 09, 01, 01, },
+ { 01, 01, 01, 04, 04, 06, 06, 08, 01, 01, 01, 01, 01, 10, 05, 01, 01, 01, 01, 10, 06, 01, 01, 01, 01, 01, 03, 03, 07, 07, 07, 01, },
+ { 01, 01, 02, 04, 04, 05, 01, 01, 01, 01, 01, 01, 01, 04, 05, 01, 01, 01, 01, 07, 09, 01, 01, 01, 01, 01, 01, 01, 07, 07, 05, 01, },
+ { 01, 01, 01, 03, 04, 04, 04, 01, 01, 01, 01, 01, 01, 04, 05, 01, 01, 01, 01, 07, 06, 01, 01, 01, 01, 01, 07, 07, 07, 09, 07, 01, },
+ { 01, 01, 01, 01, 03, 03, 03, 04, 10, 10, 10, 11, 01, 04, 05, 01, 01, 01, 01, 05, 06, 15, 05, 07, 07, 07, 09, 06, 05, 05, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 03, 03, 03, 03, 03, 02, 04, 07, 05, 05, 05, 05, 06, 09, 14, 14, 06, 05, 05, 05, 07, 12, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 06, 03, 03, 02, 02, 02, 04, 04, 02, 02, 10, 16, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 02, 05, 01, 01, 01, 01, 06, 07, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 02, 05, 01, 01, 01, 01, 06, 07, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 02, 05, 01, 01, 01, 01, 06, 07, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 03, 07, 09, 01, 01, 04, 09, 05, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 12, 03, 05, 01, 01, 05, 07, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 03, 05, 01, 01, 07, 07, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 03, 05, 05, 04, 07, 07, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 09, 03, 05, 07, 07, 13, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 03, 07, 07, 07, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 03, 04, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, },
+ { 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01 };
+ colors = {
+ "BGCOLOR",
+ "079 086 099",
+ "040 045 053",
+ "104 113 129",
+ "136 147 170",
+ "155 164 179",
+ "121 136 167",
+ "239 239 243",
+ "176 190 214",
+ "127 133 143",
+ "207 209 214",
+ "247 255 255",
+ "244 247 249",
+ "212 217 225",
+ "215 226 241",
+ "231 237 245"
+ },
+}
+
+dg = iup.dialog{iup.label{title="Tray example"}; title="Tray",
+ tray = "YES", traytip = "This is a tip at tray", trayimage = tecgraf}
+dg:show()
+
+dg.hidetaskbar = "YES"
+
+dg.trayclick_cb = function(self, b, press, dclick)
+ if b == 1 and press then
+ item_show = iup.item {title = "Show", action = function() dg:show() end}
+ item_exit = iup.item {title = "Exit", action = function() dg.tray = "NO" dg:hide() end}
+ menu = iup.menu{item_show, item_exit}
+ menu:popup(iup.MOUSEPOS, iup.MOUSEPOS)
+ end
+ return iup.DEFAULT
+end
+-- IupFill Example in IupLua
+-- Uses the Fill element to horizontally centralize a button and to
+-- justify it to the left and right.
+
+-- Creates frame with left aligned button
+frame_left = iup.frame
+{
+ iup.hbox
+ {
+ iup.button{ title = "Ok" },
+ iup.fill{},
+ }; title = "Left aligned" -- Sets frame's title
+}
+
+-- Creates frame with centered button
+frame_center = iup.frame
+{
+ iup.hbox
+ {
+ iup.fill{},
+ iup.button{ title = "Ok" },
+ iup.fill{},
+ } ; title = "Centered" -- Sets frame's title
+}
+
+-- Creates frame with right aligned button
+frame_right = iup.frame
+{
+ iup.hbox
+ {
+ iup.fill {},
+ iup.button { title = "Ok" },
+
+ } ; title = "Right aligned" -- Sets frame's title
+}
+
+-- Creates dialog with these three frames
+dialog = iup.dialog
+{
+ iup.vbox{frame_left, frame_center, frame_right,};
+ size = 120, title = "IupFill"
+}
+
+-- Shows dialog in the center of the screen
+dialog:showxy(iup.CENTER, iup.CENTER)-- IupFrame Example in IupLua
+-- Draws a frame around a button. Note that FGCOLOR is added to the frame but
+-- it is inherited by the button.
+
+-- Creates frame with a label
+frame = iup.frame
+ {
+ iup.hbox
+ {
+ iup.fill{},
+ iup.label{title="IupFrame Test"},
+ iup.fill{},
+ NULL
+ }
+ } ;
+
+-- Sets label's attributes
+frame.fgcolor = "255 0 0"
+frame.size = EIGHTHxEIGHTH
+frame.title = "This is the frame"
+frame.margin = "10x10"
+
+-- Creates dialog
+dialog = iup.dialog{frame};
+
+-- Sets dialog's title
+dialog.title = "IupFrame"
+
+dialog:showxy(iup.CENTER,iup.CENTER) -- Shows dialog in the center of the screen -- IupHbox Example in IupLua
+-- Creates a dialog with buttons placed side by side, with the purpose
+-- of showing the organization possibilities of elements inside an hbox.
+-- The ALIGNMENT attribute is explored in all its possibilities to obtain
+-- the given effect.
+
+fr1 = iup.frame
+{
+ iup.hbox
+ {
+ iup.fill{},
+ iup.button{title="1", size="30x30"},
+ iup.button{title="2", size="30x40"},
+ iup.button{title="3", size="30x50"},
+ iup.fill{};
+ alignment = "ATOP"
+ };
+ title = "Alignment = ATOP"
+}
+
+fr2 = iup.frame
+{
+ iup.hbox
+ {
+ iup.fill{},
+ iup.button{title="1", size="30x30", action=""},
+ iup.button{title="2", size="30x40", action=""},
+ iup.button{title="3", size="30x50", action=""},
+ iup.fill{};
+ alignment = "ACENTER"
+ };
+ title = "Alignment = ACENTER"
+}
+
+fr3 = iup.frame
+{
+ iup.hbox
+ {
+ iup.fill{},
+ iup.button{title="1", size="30x30", action=""},
+ iup.button{title="2", size="30x40", action=""},
+ iup.button{title="3", size="30x50", action=""},
+ iup.fill{};
+ alignment = "ABOTTOM"
+ };
+ title = "Alignment = ABOTTOM"
+}
+
+dlg = iup.dialog
+{
+ iup.frame
+ {
+ iup.vbox
+ {
+ fr1,
+ fr2,
+ fr3
+ }; title="HBOX",
+ };
+ title="Alignment",
+ size=140
+}
+
+dlg:show()-- IupImage Example in IupLua
+-- Creates a button, a label, a toggle and a radio using an image.
+-- Uses an image for the cursor as well.
+
+-- Defines an "X" image
+img_x = iup.image{
+ { 1,2,3,3,3,3,3,3,3,2,1 },
+ { 2,1,2,3,3,3,3,3,2,1,2 },
+ { 3,2,1,2,3,3,3,2,1,2,3 },
+ { 3,3,2,1,2,3,2,1,2,3,3 },
+ { 3,3,3,2,1,2,1,2,3,3,3 },
+ { 3,3,3,3,2,1,2,3,3,3,3 },
+ { 3,3,3,2,1,2,1,2,3,3,3 },
+ { 3,3,2,1,2,3,2,1,2,3,3 },
+ { 3,2,1,2,3,3,3,2,1,2,3 },
+ { 2,1,2,3,3,3,3,3,2,1,2 },
+ { 1,2,3,3,3,3,3,3,3,2,1 }
+ -- Sets "X" image colors
+ ; colors = { "0 1 0", "255 0 0", "255 255 0" }
+}
+
+-- Defines a cursor image
+img_cursor = iup.image{
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,2,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,2,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,1,2,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,1,1,2,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,1,2,2,2,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,1,2,0,0,2,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
+ -- Sets cursor image colors
+ ; colors = { "255 0 0", "128 0 0" }, hotspot = "21:10"
+}
+
+-- Creates a button entitled "Dummy" and associates image img_x to it
+btn = iup.button{ title = "", image = img_x }
+
+-- Creates a label entitled "Dummy" and associates image img_x to it
+lbl = iup.label{ title = "", image = img_x }
+
+-- Creates toggle entitled "Dummy" and associates image img_x to it
+tgl = iup.toggle{ title = "", image = img_x }
+
+-- Creates two toggles entitled "Dummy" and associates image img_x to them
+tgl_radio_1 = iup.toggle{ title = "", image = img_x }
+tgl_radio_2 = iup.toggle{ title = "", image = img_x }
+
+-- Creates label showing image size
+lbl_size = iup.label{ title = '"X" image width = '..img_x.width..'; "X" image height = '..img_x.height }
+
+-- Creates frames around the elements
+frm_btn = iup.frame{btn; title="button", size="EIGHTHxEIGHTH"}
+frm_lbl = iup.frame{lbl; title="label" , size="EIGHTHxEIGHTH"}
+frm_tgl = iup.frame{tgl; title="toggle", size="EIGHTHxEIGHTH"}
+
+frm_tgl_radio = iup.frame{
+ iup.radio{
+ iup.vbox
+ {
+ tgl_radio_1,
+ tgl_radio_2
+ }
+ };
+ title="radio", size="EIGHTHxEIGHTH"
+ }
+
+-- Creates dialog dlg with an hbox containing a button, a label, and a toggle
+dlg = iup.dialog
+ {
+ iup.vbox
+ {
+ iup.hbox{frm_btn, frm_lbl, frm_tgl, frm_tgl_radio},
+ iup.fill{},
+ iup.hbox{iup.fill{}, lbl_size, iup.fill{}}
+ }; title = "IupImage Example", size = "HALFxQUARTER",
+ cursor = img_cursor
+ }
+
+-- Shows dialog in the center of the screen
+dlg:showxy(iup.CENTER, iup.CENTER)
+text = iup.text {value = "This is an empty text"}
+
+item_save = iup.item {title = "Save\tCtrl+S", key = "K_cS", active = "NO"}
+item_autosave = iup.item {title = "Auto Save", key = "K_a", value = "ON"}
+item_exit = iup.item {title = "Exit", key = "K_x"}
+
+menu_file = iup.menu {item_save, item_autosave, item_exit}
+
+submenu_file = iup.submenu{menu_file; title = "File"}
+
+menu = iup.menu {submenu_file}
+
+dlg = iup.dialog{text; title ="IupItem", menu = menu}
+
+dlg:showxy(iup.CENTER, iup.CENTER)
+
+function item_autosave:action()
+ if item_autosave.value == "ON" then
+ iup.Message("Auto Save", "OFF")
+ item_autosave.value = "OFF"
+ else
+ iup.Message("Auto Save", "ON")
+ item_autosave.value = "ON"
+ end
+
+ return iup.DEFAULT
+end
+
+function item_exit:action()
+-- return iup.CLOSE
+ dlg:hide()
+end
+-- IupLabel Example in IupLua
+-- Creates three labels, one using all attributes except for image, other
+-- with normal text and the last one with an image..
+
+-- Defines a star image
+img_star = iup.image {
+ { 1,1,1,1,1,1,2,1,1,1,1,1,1 },
+ { 1,1,1,1,1,1,2,1,1,1,1,1,1 },
+ { 1,1,1,1,1,2,2,2,1,1,1,1,1 },
+ { 1,1,1,1,1,2,2,2,1,1,1,1,1 },
+ { 1,1,2,2,2,2,2,2,2,2,2,1,1 },
+ { 2,2,2,2,2,2,2,2,2,2,2,2,2 },
+ { 1,1,1,2,2,2,2,2,2,2,1,1,1 },
+ { 1,1,1,1,2,2,2,2,2,1,1,1,1 },
+ { 1,1,1,1,2,2,2,2,2,1,1,1,1 },
+ { 1,1,1,2,2,1,1,2,2,2,1,1,1 },
+ { 1,1,2,2,1,1,1,1,1,2,2,1,1 },
+ { 1,2,2,1,1,1,1,1,1,1,2,2,1 },
+ { 2,2,1,1,1,1,1,1,1,1,1,2,2 }
+ -- Sets star image colors
+ ; colors = { "0 0 0", "0 198 0" }
+}
+
+-- Creates a label and sets all the attributes of label lbl, except for image
+lbl = iup.label { title = "This label has the following attributes set:\nBGCOLOR = 255 255 0\nFGCOLOR = 0 0 255\nFONT = COURIER_NORMAL_14\nSIZE = HALFxQUARTER\nTITLE = All text contained here\nALIGNMENT = ACENTER\n", bgcolor = "255 255 0", fgcolor = "0 0 255", font = "COURIER_NORMAL_14", size = "HALFxQUARTER", alignment = "ACENTER" }
+
+-- Creates a label to explain that the label on the right has an image
+lbl_explain = iup.label { title = "The label on the right has the image of a star" }
+
+-- Creates a label whose title is not important, cause it will have an image
+lbl_star = iup.label { title = "Does not matter", image = img_star }
+
+-- Creates dialog with these three labels
+dlg = iup.dialog { iup.vbox { lbl, iup.hbox { lbl_explain, lbl_star } }
+ ; title = "IupLabel Example" }
+
+-- Shows dialog in the center of the screen
+dlg:showxy ( iup.CENTER, iup.CENTER )-- IupList Example in IupLua
+-- Creates a dialog with three frames, each one containing a list. The first is a simple list, the second one is a multiple list and the last one is a drop-down list. The second list has a callback associated.
+
+-- Creates a list and sets items, initial item and size
+list = iup.list {"Gold", "Silver", "Bronze", "None"
+ ; value = 4, size = "EIGHTHxEIGHTH"}
+
+-- Creates frame with simple list and sets its title
+frm_medal = iup.frame {list ; title = "Best medal"}
+
+-- Creates a list and sets its items, multiple selection, initial items and size
+list_multiple = iup.list {"100m dash", "Long jump", "Javelin throw", "110m hurdlers", "Hammer throw", "High jump"
+ ; multiple="YES", value="+--+--", size="EIGHTHxEIGHTH"}
+
+-- Creates frame with multiple list and sets its title
+frm_sport = iup.frame {list_multiple
+ ; title = "Competed in"}
+
+-- Creates a list and sets its items, dropdown and amount of visible items
+list_dropdown = iup.list {"Less than US$ 1000", "US$ 2000", "US$ 5000", "US$ 10000", "US$ 20000", "US$ 50000", "More than US$ 100000"
+ ; dropdown="YES", visible_items=5}
+
+-- Creates frame with dropdown list and sets its title
+frm_prize = iup.frame {list_dropdown
+ ; title = "Prizes won"}
+
+-- Creates a dialog with the the frames with three lists and sets its title
+dlg = iup.dialog {iup.hbox {frm_medal, frm_sport, frm_prize}
+ ; title = "IupList Example"}
+
+-- Shows dialog in the center of the screen
+dlg:showxy(iup.CENTER, iup.CENTER)
+
+function list_multiple:action(t, i, v)
+ if v == 0 then
+ state = "deselected"
+ else
+ state = "selected"
+ end
+ iup.Message("Competed in", "Item "..i.." - "..t.." - "..state)
+ return iup.DEFAULT
+end-- IupMenu Example in IupLua
+-- Creates a dialog with a menu with two submenus.
+
+-- Creates a text, sets its value and turns on text readonly mode
+text = iup.text {readonly = "YES", value = "Selecting show or hide will affect this text"}
+
+-- Creates items, sets its shortcut keys and deactivates edit item
+item_show = iup.item {title = "Show", key = "K_S"}
+item_hide = iup.item {title = "Hide\tCtrl+H", key = "K_H"}
+item_edit = iup.item {title = "Edit", key = "K_E", active = "NO"}
+item_exit = iup.item {title = "Exit", key = "K_x"}
+
+function item_show:action()
+ text.visible = "YES"
+ return iup.DEFAULT
+end
+
+function item_hide:action()
+ text.visible = "NO"
+ return iup.DEFAULT
+end
+
+function item_exit:action()
+ return iup.CLOSE
+end
+
+-- Creates two menus
+menu_file = iup.menu {item_exit}
+menu_text = iup.menu {item_show, item_hide, item_edit}
+
+-- Creates two submenus
+submenu_file = iup.submenu {menu_file; title = "File"}
+submenu_text = iup.submenu {menu_text; title = "Text"}
+
+-- Creates main menu with two submenus
+menu = iup.menu {submenu_file, submenu_text}
+
+-- Creates dialog with a text, sets its title and associates a menu to it
+dlg = iup.dialog{text; title="IupMenu Example", menu=menu}
+
+-- Shows dialog in the center of the screen
+dlg:showxy(iup.CENTER,iup.CENTER)
+
+
+l = iup.list{dropdown="YES"}
+
+iup.SetAttribute(l, "1", "HELVETICA_NORMAL_8")
+iup.SetAttribute(l, "2", "COURIER_NORMAL_8")
+iup.SetAttribute(l, "3", "TIMES_NORMAL_8")
+iup.SetAttribute(l, "4", "HELVETICA_ITALIC_8")
+iup.SetAttribute(l, "5", "COURIER_ITALIC_8")
+iup.SetAttribute(l, "6", "TIMES_ITALIC_8")
+iup.SetAttribute(l, "7", "HELVETICA_BOLD_8")
+iup.SetAttribute(l, "8", "COURIER_BOLD_8")
+iup.SetAttribute(l, "9", "TIMES_BOLD_8")
+iup.SetAttribute(l, "10", "HELVETICA_NORMAL_10")
+iup.SetAttribute(l, "11", "COURIER_NORMAL_10")
+iup.SetAttribute(l, "12", "TIMES_NORMAL_10")
+iup.SetAttribute(l, "13", "HELVETICA_ITALIC_10")
+iup.SetAttribute(l, "14", "COURIER_ITALIC_10")
+iup.SetAttribute(l, "15", "TIMES_ITALIC_10")
+iup.SetAttribute(l, "16", "HELVETICA_BOLD_10")
+iup.SetAttribute(l, "17", "COURIER_BOLD_10")
+iup.SetAttribute(l, "18", "TIMES_BOLD_10")
+iup.SetAttribute(l, "19", "HELVETICA_NORMAL_12")
+iup.SetAttribute(l, "20", "COURIER_NORMAL_12")
+iup.SetAttribute(l, "21", "TIMES_NORMAL_12")
+iup.SetAttribute(l, "22", "HELVETICA_ITALIC_12")
+iup.SetAttribute(l, "23", "COURIER_ITALIC_12")
+iup.SetAttribute(l, "24", "TIMES_ITALIC_12")
+iup.SetAttribute(l, "25", "HELVETICA_BOLD_12")
+iup.SetAttribute(l, "26", "COURIER_BOLD_12")
+iup.SetAttribute(l, "27", "TIMES_BOLD_12")
+iup.SetAttribute(l, "28", "HELVETICA_NORMAL_14")
+iup.SetAttribute(l, "29", "COURIER_NORMAL_14")
+iup.SetAttribute(l, "30", "TIMES_NORMAL_14")
+iup.SetAttribute(l, "31", "HELVETICA_ITALIC_14")
+iup.SetAttribute(l, "32", "COURIER_ITALIC_14")
+iup.SetAttribute(l, "33", "TIMES_ITALIC_14")
+iup.SetAttribute(l, "34", "HELVETICA_BOLD_14")
+iup.SetAttribute(l, "35", "COURIER_BOLD_14")
+iup.SetAttribute(l, "36", "TIMES_BOLD_14")
+
+dg = iup.dialog{l}
+dg.title = "title"
+
+dg2 = nil
+
+l.action = function(self, t, i ,v)
+
+ if dg2 then
+ iup.Hide(dg2)
+ end
+
+ if v == 1 then
+ ml = iup.multiline{}
+ ml.size = "200x200"
+ ml.value = "1234\nmmmmm\niiiii"
+
+ ml.font = t
+
+ dg2 = iup.dialog{ml}
+ dg2.title = t
+ dg2:show()
+ iup.SetFocus(l)
+ end
+end
+
+dg:show()
+-- IupMultiline Simple Example in IupLua
+-- Shows a multiline that ignores the treatment of the DEL key, canceling its effect.
+
+ml = iup.multiline{expand="YES", value="I ignore the DEL key!", border="YES"}
+
+ml.action = function(self, c, after)
+ if c == iup.K_DEL then
+ return iup.IGNORE
+ else
+ return iup.DEFAULT;
+ end
+end
+
+dlg = iup.dialog{ml; title="IupMultiline", size="QUARTERxQUARTER"}
+dlg:show()-- IupRadio Example in IupLua
+-- Creates a dialog for the user to select his/her gender.
+-- In this case, the radio element is essential to prevent the user from
+-- selecting both options.
+
+male = iup.toggle{title="Male"}
+female = iup.toggle{title="Female"}
+exclusive = iup.radio
+{
+ iup.vbox
+ {
+ male,
+ female
+ };
+ value=female,
+ tip="Two state button - Exclusive - RADIO"
+}
+
+frame = iup.frame{exclusive; title="Gender"}
+
+dialog = iup.dialog
+{
+ iup.hbox
+ {
+ iup.fill{},
+ frame,
+ iup.fill{}
+ };
+ title="IupRadio",
+ size=140,
+ resize="NO",
+ minbox="NO",
+ maxbox="NO"
+}
+
+dialog:show()-- IupSeparator Example in IupLua
+-- Creates a dialog with a menu and some items.
+-- A IupSeparator was used to separate the menu items.
+
+-- Creates a text, sets its value and turns on text readonly mode
+text = iup.text {value = "This text is here only to compose", expand = "YES"}
+
+-- Creates six items
+item_new = iup.item {title = "New"}
+item_open = iup.item {title = "Open"}
+item_close = iup.item {title = "Close"}
+item_pagesetup = iup.item {title = "Page Setup"}
+item_print = iup.item {title = "Print"}
+item_exit = iup.item {title = "Exit", action="return iup.CLOSE"}
+
+-- Creates file menus
+menu_file = iup.menu {item_new, item_open, item_close, iup.separator{}, item_pagesetup, item_print, iup.separator{}, item_exit }
+
+-- Creates file submenus
+submenu_file = iup.submenu {menu_file; title="File"}
+
+-- Creates main menu with file submenu
+menu = iup.menu {submenu_file}
+
+-- Creates dialog with a text, sets its title and associates a menu to it
+dlg = iup.dialog {text
+ ; title ="IupSeparator Example", menu = menu, size = "QUARTERxEIGHTH"}
+
+-- Shows dialog in the center of the screen
+dlg:showxy(iup.CENTER,iup.CENTER)-- IupSubmenu Example in IupLua
+-- Creates a dialog with a menu with three submenus. One of the submenus has a submenu, which has another submenu.
+
+-- Creates a text, sets its value and turns on text readonly mode
+text = iup.text {value = "This text is here only to compose", expand = "YES"}
+
+-- Creates items of menu file
+item_new = iup.item {title = "New"}
+item_open = iup.item {title = "Open"}
+item_close = iup.item {title = "Close"}
+item_exit = iup.item {title = "Exit"}
+
+-- Creates items of menu edit
+item_copy = iup.item {title = "Copy"}
+item_paste = iup.item {title = "Paste"}
+
+-- Creates items for menu triangle
+item_equilateral = iup.item {title = "Equilateral"}
+item_isoceles = iup.item {title = "Isoceles"}
+item_scalenus = iup.item {title = "Scalenus"}
+
+-- Creates menu triangle
+menu_triangle = iup.menu {item_equilateral, item_isoceles, item_scalenus}
+
+-- Creates submenu triangle
+submenu_triangle = iup.submenu {menu_triangle; title = "Triangle"}
+
+-- Creates items of menu create
+item_line = iup.item {title = "Line"}
+item_circle = iup.item {title = "Circle"}
+
+-- Creates menu create
+menu_create = iup.menu {item_line, item_circle, submenu_triangle}
+
+-- Creates submenu create
+submenu_create = iup.submenu {menu_create; title = "Create"}
+
+-- Creates items of menu help
+item_help = iup.item {title = "Help"}
+
+-- Creates menus of the main menu
+menu_file = iup.menu {item_new, item_open, item_close, iup.separator{}, item_exit }
+menu_edit = iup.menu {item_copy, item_paste, iup.separator{}, submenu_create}
+menu_help = iup.menu {item_help}
+
+-- Creates submenus of the main menu
+submenu_file = iup.submenu {menu_file; title = "File"}
+submenu_edit = iup.submenu {menu_edit; title = "Edit"}
+submenu_help = iup.submenu {menu_help; title = "Help"}
+
+-- Creates main menu with file submenu
+menu = iup.menu {submenu_file, submenu_edit, submenu_help}
+
+-- Creates dialog with a text, sets its title and associates a menu to it
+dlg = iup.dialog {text
+ ; title ="IupSubmenu Example", menu = menu, size = "QUARTERxEIGHTH"}
+
+-- Shows dialog in the center of the screen
+dlg:showxy (iup.CENTER,iup.CENTER)
+
+function item_help:action ()
+ iup.Message ("Warning", "Only Help and Exit items performs an operation")
+ return iup.DEFAULT
+end
+
+function item_exit:action ()
+ return iup.CLOSE
+end-- IupText Example in IupLua
+-- Allows the user to execute a Lua command
+
+text = iup.text{value = "Write a text; press Ctrl-Q to exit"}
+
+function text:action(c)
+ if c == iup.K_cQ then
+ return iup.CLOSE
+ end
+ return iup.DEFAULT
+end
+
+dlg = iup.dialog{text; title="IupText"}
+
+dlg:showxy(iup.CENTER, iup.CENTER)
+iup.SetFocus(text)
+-- IupTimer Example in Lua
+
+timer1 = iup.timer{time=100}
+timer2 = iup.timer{time=2000}
+
+function timer1:action_cb()
+ print("timer 1 called")
+ return iup.DEFAULT
+end
+
+function timer2:action_cb()
+ print("timer 2 called")
+ return iup.CLOSE
+end
+
+-- can only be set after the time is created
+timer1.run = "YES"
+timer2.run = "YES"
+
+dg = iup.dialog{iup.label{title="Timer example"}}
+dg:show()
+-- IupToggle Example in IupLua
+-- Creates 9 toggles:
+-- the first one has an image and an associated callback;
+-- the second has an image and is deactivated;
+-- the third is regular;
+-- the fourth has its foreground color changed;
+-- the fifth has its background color changed;
+-- the sixth has its foreground and background colors changed;
+-- the seventh is deactivated;
+-- the eight has its font changed;
+-- the ninth has its size changed.
+
+img1 = iup.image{
+ {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
+ {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
+ {1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1},
+ {1,1,1,1,1,1,2,2,1,1,1,1,1,1,1,1},
+ {1,1,1,1,1,2,1,2,1,1,1,1,1,1,1,1},
+ {1,1,1,1,2,1,1,2,1,1,1,1,1,1,1,1},
+ {1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1},
+ {1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1},
+ {1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1},
+ {1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1},
+ {1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1},
+ {1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1},
+ {1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1},
+ {1,1,1,2,2,2,2,2,2,2,2,2,1,1,1,1},
+ {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
+ {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
+ colors = {"255 255 255", "0 192 0"}
+}
+
+img2 = iup.image{
+ {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
+ {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
+ {1,1,1,1,2,2,2,2,2,2,1,1,1,1,1,1},
+ {1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1},
+ {1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1},
+ {1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1},
+ {1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1},
+ {1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1},
+ {1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1},
+ {1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1},
+ {1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1},
+ {1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1},
+ {1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1},
+ {1,1,1,2,2,2,2,2,2,2,2,2,1,1,1,1},
+ {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
+ {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
+ colors = {"255 255 255", "0 192 0"}
+}
+
+toggle1 = iup.toggle{title = "", image = img1}
+toggle2 = iup.toggle{title = "deactivated toggle with image", image = img2, active="NO"}
+toggle3 = iup.toggle{title = "regular toggle"}
+toggle4 = iup.toggle{title = "toggle with blue foreground color", fgcolor = BLUE }
+toggle5 = iup.toggle{title = "toggle with red background color", bgcolor = RED }
+toggle6 = iup.toggle{title = "toggle with black backgrounf color and green foreground color", fgcolor = GREEN, bgcolor = BLACK }
+toggle7 = iup.toggle{title = "deactivated toggle", active = "NO" }
+toggle8 = iup.toggle{title = "toggle with Courier 14 Bold font", font = "COURIER_BOLD_14" }
+toggle9 = iup.toggle{title = "toggle with size EIGHTxEIGHT", size = "EIGHTHxEIGHTH" }
+
+function toggle1:action(v)
+ if v == 1 then estado = "pressed" else estado = "released" end
+ iup.Message("Toggle 1",estado)
+end
+
+box = iup.vbox{
+ toggle1,
+ toggle2,
+ toggle3,
+ toggle4,
+ toggle5,
+ toggle6,
+ toggle7,
+ toggle8,
+ toggle9
+ }
+
+toggles = iup.radio{box; expand="YES"}
+dlg = iup.dialog{toggles; title = "IupToggle", margin="5x5", gap="5", resize="NO"}
+dlg:showxy(iup.CENTER, iup.CENTER)-- IupVbox Example in IupLua
+-- Creates a dialog with buttons placed one above the other, showing
+-- the organization possibilities of the elements inside a vbox.
+-- The ALIGNMENT attribute is explored in all its possibilities to obtain
+-- the effects. The attributes GAP, MARGIN and SIZE are also tested.
+
+-- Creates frame 1
+frm_1 = iup.frame
+{
+ iup.hbox
+ {
+ iup.fill {},
+ iup.vbox
+ {
+ iup.button {title = "1", size = "20x30", action = ""},
+ iup.button {title = "2", size = "30x30", action = ""},
+ iup.button {title = "3", size = "40x30", action = ""} ;
+ -- Sets alignment and gap of vbox
+ alignment = "ALEFT", gap = 10
+ },
+ iup.fill {}
+ } ;
+ -- Sets title of frame 1
+ title = "ALIGNMENT = ALEFT, GAP = 10"
+}
+
+-- Creates frame 2
+frm_2 = iup.frame
+{
+ iup.hbox
+ {
+ iup.fill {},
+ iup.vbox
+ {
+ iup.button {title = "1", size = "20x30", action = ""},
+ iup.button {title = "2", size = "30x30", action = ""},
+ iup.button {title = "3", size = "40x30", action = ""} ;
+ -- Sets alignment and margin of vbox
+ alignment = "ACENTER",
+ },
+ iup.fill {}
+ } ;
+ -- Sets title of frame 1
+ title = "ALIGNMENT = ACENTER"
+}
+
+-- Creates frame 3
+frm_3 = iup.frame
+{
+ iup.hbox
+ {
+ iup.fill {},
+ iup.vbox
+ {
+ iup.button {title = "1", size = "20x30", action = ""},
+ iup.button {title = "2", size = "30x30", action = ""},
+ iup.button {title = "3", size = "40x30", action = ""} ;
+ -- Sets alignment and size of vbox
+ alignment = "ARIGHT"
+ },
+ iup.fill {}
+ } ;
+ -- Sets title of frame 3
+ title = "ALIGNMENT = ARIGHT"
+}
+
+dlg = iup.dialog
+{
+ iup.vbox
+ {
+ frm_1,
+ frm_2,
+ frm_3
+ } ;
+ title = "IupVbox Example", size = "QUARTER"
+}
+
+-- Shows dialog in the center of the screen
+dlg:showxy (iup.CENTER, iup.CENTER)-- IupZbox Example in IupLua
+-- An application of a zbox could be a program requesting several entries from the user according to a previous selection. In this example, a list of possible layouts ,each one consisting of an element, is presented, and according to the selected option the dialog below the list is changed.
+
+fill = iup.fill {}
+text = iup.text {value = "Enter your text here", expand = "YES"}
+lbl = iup.label {title = "This element is a label"}
+btn = iup.button {title = "This button does nothing"}
+zbox = iup.zbox
+{
+ fill,
+ text,
+ lbl,
+ btn ;
+ alignment = "ACENTER", value=text
+}
+
+list = iup.list { "fill", "text", "lbl", "btn"; value="2"}
+ilist = {fill, text, lbl, btn}
+
+function list:action (t, o, selected)
+ if selected == 1 then
+ -- Sets the value of the zbox to the selected element
+ zbox.value=ilist[o]
+ end
+
+ return iup.DEFAULT
+end
+
+frm = iup.frame
+{
+ iup.hbox
+ {
+ iup.fill{},
+ list,
+ iup.fill{}
+ } ;
+ title = "Select an element"
+}
+
+dlg = iup.dialog
+{
+ iup.vbox
+ {
+ frm,
+ zbox
+ } ;
+ size = "QUARTER",
+ title = "IupZbox Example"
+}
+
+dlg:showxy (0, 0)
+--[[
+JSON4Lua example script.
+Demonstrates the simple functionality of the json module.
+]]--
+json = require('json')
+
+
+-- Object to JSON encode
+test = {
+ one='first',two='second',three={2,3,5}
+}
+
+jsonTest = json.encode(test)
+
+print('JSON encoded test is: ' .. jsonTest)
+
+-- Now JSON decode the json string
+result = json.decode(jsonTest)
+
+print ("The decoded table result:")
+table.foreach(result,print)
+print ("The decoded table result.three")
+table.foreach(result.three, print)
+--
+-- jsonrpc.lua
+-- Installed in a CGILua webserver environment (with necessary CGI Lua 5.0 patch)
+--
+require ('json.rpcserver')
+
+-- The Lua class that is to serve JSON RPC requests
+local myServer = {
+ echo = function (msg) return msg end,
+ average = function(...)
+ local total=0
+ local count=0
+ for i=1, table.getn(arg) do
+ total = total + arg[i]
+ count = count + 1
+ end
+ return { average= total/count, sum = total, n=count }
+ end
+}
+
+json.rpcserver.serve(myServer)--[[
+Some basic tests for JSON4Lua.
+]]--
+
+--- Compares two tables for being data-identical.
+function compareData(a,b)
+ if (type(a)=='string' or type(a)=='number' or type(a)=='boolean' or type(a)=='nil') then return a==b end
+ -- After basic data types, we're only interested in tables
+ if (type(a)~='table') then return true end
+ -- Check that a has everything b has
+ for k,v in pairs(b) do
+ if (not compareData( a[k], v ) ) then return false end
+ end
+ for k,v in pairs(a) do
+ if (not compareData( v, b[k] ) ) then return false end
+ end
+ return true
+end
+
+---
+-- Checks that our compareData function works properly
+function testCompareData()
+ s = "name"
+ r = "name"
+ assert(compareData(s,r))
+ assert(not compareData('fred',s))
+ assert(not compareData(nil, s))
+ assert(not compareData("123",123))
+ assert(not compareData(false, nil))
+ assert(compareData(true, true))
+ assert(compareData({1,2,3},{1,2,3}))
+ assert(compareData({'one',2,'three'},{'one',2,'three'}))
+ assert(not compareData({'one',2,4},{4,2,'one'}))
+ assert(compareData({one='ichi',two='nichi',three='san'}, {three='san',two='nichi',one='ichi'}))
+ s = { one={1,2,3}, two={one='hitotsu',two='futatsu',three='mitsu'} }
+ assert(compareData(s,s))
+ t = { one={1,2,3}, two={one='een',two='twee',three='drie'} }
+ assert(not compareData(s,t))
+end
+
+testCompareData()
+
+--
+--
+-- Performs some perfunctory tests on JSON module
+function testJSON4Lua()
+ json = require('json')
+
+ if nil then
+ -- Test encodeString
+ s = [["\"
+]]
+ r = json._encodeString(s)
+ assert(r=='\\"\\\\\\"\\n')
+ s = [["""\\\"]]
+ r = json._encodeString(s)
+ assert(r==[[\"\"\"\\\\\\\"]])
+
+ end
+
+ -- Test encode for basic strings (complicated strings)
+ s = [[Hello, Lua!]]
+ r = json.encode(s)
+ assert(r=='"Hello, Lua!"')
+ s = [["\"
+]]
+ r = json.encode(s)
+ assert(r=='\"\\"\\\\\\"\\n\"')
+ s = [["""\\\"]]
+ r = json.encode(s)
+ assert(r==[["\"\"\"\\\\\\\""]])
+
+ -- Test encode for numeric values
+ s = 23
+ r = json.encode(s)
+ assert(r=='23')
+ s=48.123
+ r = json.encode(s)
+ assert(r=='48.123')
+
+ -- Test encode for boolean values
+ assert(json.encode(true)=='true')
+ assert(json.encode(false)=='false')
+ assert(json.encode(nil)=='null')
+
+ -- Test encode for arrays
+ s = {1,2,3}
+ r = json.encode(s)
+ assert(r=="[1,2,3]")
+ s = {9,9,9}
+ r = json.encode(s)
+ assert(r=="[9,9,9]")
+
+ -- Complex array test
+ s = { 2, 'joe', false, nil, 'hi' }
+ r = json.encode(s)
+ assert(r=='[2,"joe",false,null,"hi"]')
+
+ -- Test encode for tables
+ s = {Name='Craig',email='craig@lateral.co.za',age=35}
+ r = json.encode(s)
+ -- NB: This test can fail because of order: need to test further once
+ -- decoding is supported.
+ assert(r==[[{"age":35,"Name":"Craig","email":"craig@lateral.co.za"}]])
+
+ -- Test decode_scanWhitespace
+ if nil then
+ s = " \n \r \t "
+ e = json._decode_scanWhitespace(s,1)
+ assert(e==string.len(s)+1)
+ s = " \n\r\t4"
+ assert(json._decode_scanWhitespace(s,1)==5)
+
+ -- Test decode_scanString
+ s = [["Test"]]
+ r,e = json._decode_scanString(s,1)
+ assert(r=='Test' and e==7)
+ s = [["This\nis a \"test"]]
+ r = json._decode_scanString(s,1)
+ assert(r=="This\nis a \"test")
+
+ -- Test decode_scanNumber
+ s = [[354]]
+ r,e = json._decode_scanNumber(s,1)
+ assert(r==354 and e==4)
+ s = [[ 4565.23 AND OTHER THINGS ]]
+ r,e = json._decode_scanNumber(s,2)
+ assert(r==4565.23 and e==9)
+ s = [[ -23.22 and ]]
+ r,e = json._decode_scanNumber(s,2)
+ assert(r==-23.22 and e==8)
+
+ -- Test decode_scanConstant
+ s = "true"
+ r,e = json._decode_scanConstant(s,1)
+ assert(r==true and e==5)
+ s = " false "
+ r,e = json._decode_scanConstant(s,3)
+ assert(r==false and e==8)
+ s = "1null6"
+ r,e = json._decode_scanConstant(s,2)
+ assert(r==nil and e==6)
+
+ -- Test decode_scanArray
+ s = "[1,2,3]"
+ r,e = json._decode_scanArray(s,1)
+ assert(compareData(r,{1,2,3}))
+ s = [[[ 1 , 3 ,5 , "Fred" , true, false, null, -23 ] ]]
+ r,e = json._decode_scanArray(s,1)
+ assert(compareData(r, {1,3,5,'Fred',true,false,nil,-23} ) )
+ s = "[3,5,null,7,9]"
+ r,e = json._decode_scanArray(s,1)
+ assert(compareData(r, {3,5,nil,7,9}))
+ s = "[3,5,null,7,9,null,null]"
+ r,e = json._decode_scanArray(s,1)
+ assert(compareData(r, {3,5,nil,7,9,nil,nil}))
+
+ end
+
+ -- Test decode_scanObject
+ s = [[ {"one":1, "two":2, "three":"three", "four":true} ]]
+ r,e = json.decode(s)
+ assert(compareData(r,{one=1,two=2,three='three',four=true}))
+ s = [[ { "one" : { "first":1,"second":2,"third":3}, "two":2, "three":false } ]]
+ r,e = json.decode(s)
+ assert(compareData(r, {one={first=1,second=2,third=3},two=2,three=false}))
+ s = [[ { "primes" : [2,3,5,7,9], "user":{"name":"craig","age":35,"programs_lua":true},
+ "lua_is_great":true } ]]
+ r,e = json.decode(s)
+ assert(compareData(r, {primes={2,3,5,7,9},user={name='craig',age=35,programs_lua=true},lua_is_great=true}))
+
+ -- Test json.null management
+ t = { 1,2,json.null,4 }
+ assert( json.encode(t)=="[1,2,null,4]" )
+ t = {x=json.null }
+ r = json.encode(t)
+ assert( json.encode(t) == '{"x":null}' )
+
+ -- Test comment decoding
+ s = [[ /* A comment
+ that spans
+ a few lines
+ */
+ "test"
+ ]]
+ r,e = json.decode(s)
+ assert(r=='test',"Comment decoding failed")
+end
+
+testJSON4Lua()
+
+print("JSON4Lua tests completed successfully")--[[
+ Some Time Trails for the JSON4Lua package
+]]--
+
+
+require('json')
+require('os')
+require('table')
+
+local t1 = os.clock()
+local jstr
+local v
+for i=1,100 do
+ local t = {}
+ for j=1,500 do
+ table.insert(t,j)
+ end
+ for j=1,500 do
+ table.insert(t,"VALUE")
+ end
+ jstr = json.encode(t)
+ v = json.decode(jstr)
+ --print(json.encode(t))
+end
+
+for i = 1,100 do
+ local t = {}
+ for j=1,500 do
+ local m= math.mod(j,3)
+ if (m==0) then
+ t['a'..j] = true
+ elseif m==1 then
+ t['a'..j] = json.null
+ else
+ t['a'..j] = j
+ end
+ end
+ jstr = json.encode(t)
+ v = json.decode(jstr)
+end
+
+print (jstr)
+--print(type(t1))
+local t2 = os.clock()
+
+print ("Elapsed time=" .. os.difftime(t2,t1) .. "s")-----------------------------------------------------------------------------
+-- JSON4Lua: JSON encoding / decoding support for the Lua language.
+-- json Module.
+-- Author: Craig Mason-Jones
+-- Homepage: http://json.luaforge.net/
+-- Version: 0.9.20
+-- This module is released under the The GNU General Public License (GPL).
+-- Please see LICENCE.txt for details.
+--
+-- USAGE:
+-- This module exposes two functions:
+-- encode(o)
+-- Returns the table / string / boolean / number / nil / json.null value as a JSON-encoded string.
+-- decode(json_string)
+-- Returns a Lua object populated with the data encoded in the JSON string json_string.
+--
+-- REQUIREMENTS:
+-- compat-5.1 if using Lua 5.0
+--
+-- CHANGELOG
+-- 0.9.20 Introduction of local Lua functions for private functions (removed _ function prefix).
+-- Fixed Lua 5.1 compatibility issues.
+-- Introduced json.null to have null values in associative arrays.
+-- encode() performance improvement (more than 50%) through table.concat rather than ..
+-- Introduced decode ability to ignore /**/ comments in the JSON string.
+-- 0.9.10 Fix to array encoding / decoding to correctly manage nil/null values in arrays.
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+-- Imports and dependencies
+-----------------------------------------------------------------------------
+local math = require('math')
+local string = require("string")
+local table = require("table")
+
+local base = _G
+
+-----------------------------------------------------------------------------
+-- Module declaration
+-----------------------------------------------------------------------------
+module("json")
+
+-- Public functions
+
+-- Private functions
+local decode_scanArray
+local decode_scanComment
+local decode_scanConstant
+local decode_scanNumber
+local decode_scanObject
+local decode_scanString
+local decode_scanWhitespace
+local encodeString
+local isArray
+local isEncodable
+
+-----------------------------------------------------------------------------
+-- PUBLIC FUNCTIONS
+-----------------------------------------------------------------------------
+--- Encodes an arbitrary Lua object / variable.
+-- @param v The Lua object / variable to be JSON encoded.
+-- @return String containing the JSON encoding in internal Lua string format (i.e. not unicode)
+function encode (v)
+ -- Handle nil values
+ if v==nil then
+ return "null"
+ end
+
+ local vtype = base.type(v)
+
+ -- Handle strings
+ if vtype=='string' then
+ return '"' .. encodeString(v) .. '"' -- Need to handle encoding in string
+ end
+
+ -- Handle booleans
+ if vtype=='number' or vtype=='boolean' then
+ return base.tostring(v)
+ end
+
+ -- Handle tables
+ if vtype=='table' then
+ local rval = {}
+ -- Consider arrays separately
+ local bArray, maxCount = isArray(v)
+ if bArray then
+ for i = 1,maxCount do
+ table.insert(rval, encode(v[i]))
+ end
+ else -- An object, not an array
+ for i,j in base.pairs(v) do
+ if isEncodable(i) and isEncodable(j) then
+ table.insert(rval, '"' .. encodeString(i) .. '":' .. encode(j))
+ end
+ end
+ end
+ if bArray then
+ return '[' .. table.concat(rval,',') ..']'
+ else
+ return '{' .. table.concat(rval,',') .. '}'
+ end
+ end
+
+ -- Handle null values
+ if vtype=='function' and v==null then
+ return 'null'
+ end
+
+ base.assert(false,'encode attempt to encode unsupported type ' .. vtype .. ':' .. base.tostring(v))
+end
+
+
+--- Decodes a JSON string and returns the decoded value as a Lua data structure / value.
+-- @param s The string to scan.
+-- @param [startPos] Optional starting position where the JSON string is located. Defaults to 1.
+-- @param Lua object, number The object that was scanned, as a Lua table / string / number / boolean or nil,
+-- and the position of the first character after
+-- the scanned JSON object.
+function decode(s, startPos)
+ startPos = startPos and startPos or 1
+ startPos = decode_scanWhitespace(s,startPos)
+ base.assert(startPos<=string.len(s), 'Unterminated JSON encoded object found at position in [' .. s .. ']')
+ local curChar = string.sub(s,startPos,startPos)
+ -- Object
+ if curChar=='{' then
+ return decode_scanObject(s,startPos)
+ end
+ -- Array
+ if curChar=='[' then
+ return decode_scanArray(s,startPos)
+ end
+ -- Number
+ if string.find("+-0123456789.e", curChar, 1, true) then
+ return decode_scanNumber(s,startPos)
+ end
+ -- String
+ if curChar==[["]] or curChar==[[']] then
+ return decode_scanString(s,startPos)
+ end
+ if string.sub(s,startPos,startPos+1)=='/*' then
+ return decode(s, decode_scanComment(s,startPos))
+ end
+ -- Otherwise, it must be a constant
+ return decode_scanConstant(s,startPos)
+end
+
+--- The null function allows one to specify a null value in an associative array (which is otherwise
+-- discarded if you set the value with 'nil' in Lua. Simply set t = { first=json.null }
+function null()
+ return null -- so json.null() will also return null ;-)
+end
+-----------------------------------------------------------------------------
+-- Internal, PRIVATE functions.
+-- Following a Python-like convention, I have prefixed all these 'PRIVATE'
+-- functions with an underscore.
+-----------------------------------------------------------------------------
+
+--- Scans an array from JSON into a Lua object
+-- startPos begins at the start of the array.
+-- Returns the array and the next starting position
+-- @param s The string being scanned.
+-- @param startPos The starting position for the scan.
+-- @return table, int The scanned array as a table, and the position of the next character to scan.
+function decode_scanArray(s,startPos)
+ local array = {} -- The return value
+ local stringLen = string.len(s)
+ base.assert(string.sub(s,startPos,startPos)=='[','decode_scanArray called but array does not start at position ' .. startPos .. ' in string:\n'..s )
+ startPos = startPos + 1
+ -- Infinite loop for array elements
+ repeat
+ startPos = decode_scanWhitespace(s,startPos)
+ base.assert(startPos<=stringLen,'JSON String ended unexpectedly scanning array.')
+ local curChar = string.sub(s,startPos,startPos)
+ if (curChar==']') then
+ return array, startPos+1
+ end
+ if (curChar==',') then
+ startPos = decode_scanWhitespace(s,startPos+1)
+ end
+ base.assert(startPos<=stringLen, 'JSON String ended unexpectedly scanning array.')
+ object, startPos = decode(s,startPos)
+ table.insert(array,object)
+ until false
+end
+
+--- Scans a comment and discards the comment.
+-- Returns the position of the next character following the comment.
+-- @param string s The JSON string to scan.
+-- @param int startPos The starting position of the comment
+function decode_scanComment(s, startPos)
+ base.assert( string.sub(s,startPos,startPos+1)=='/*', "decode_scanComment called but comment does not start at position " .. startPos)
+ local endPos = string.find(s,'*/',startPos+2)
+ base.assert(endPos~=nil, "Unterminated comment in string at " .. startPos)
+ return endPos+2
+end
+
+--- Scans for given constants: true, false or null
+-- Returns the appropriate Lua type, and the position of the next character to read.
+-- @param s The string being scanned.
+-- @param startPos The position in the string at which to start scanning.
+-- @return object, int The object (true, false or nil) and the position at which the next character should be
+-- scanned.
+function decode_scanConstant(s, startPos)
+ local consts = { ["true"] = true, ["false"] = false, ["null"] = nil }
+ local constNames = {"true","false","null"}
+
+ for i,k in base.pairs(constNames) do
+ --print ("[" .. string.sub(s,startPos, startPos + string.len(k) -1) .."]", k)
+ if string.sub(s,startPos, startPos + string.len(k) -1 )==k then
+ return consts[k], startPos + string.len(k)
+ end
+ end
+ base.assert(nil, 'Failed to scan constant from string ' .. s .. ' at starting position ' .. startPos)
+end
+
+--- Scans a number from the JSON encoded string.
+-- (in fact, also is able to scan numeric +- eqns, which is not
+-- in the JSON spec.)
+-- Returns the number, and the position of the next character
+-- after the number.
+-- @param s The string being scanned.
+-- @param startPos The position at which to start scanning.
+-- @return number, int The extracted number and the position of the next character to scan.
+function decode_scanNumber(s,startPos)
+ local endPos = startPos+1
+ local stringLen = string.len(s)
+ local acceptableChars = "+-0123456789.e"
+ while (string.find(acceptableChars, string.sub(s,endPos,endPos), 1, true)
+ and endPos<=stringLen
+ ) do
+ endPos = endPos + 1
+ end
+ local stringValue = 'return ' .. string.sub(s,startPos, endPos-1)
+ local stringEval = base.loadstring(stringValue)
+ base.assert(stringEval, 'Failed to scan number [ ' .. stringValue .. '] in JSON string at position ' .. startPos .. ' : ' .. endPos)
+ return stringEval(), endPos
+end
+
+--- Scans a JSON object into a Lua object.
+-- startPos begins at the start of the object.
+-- Returns the object and the next starting position.
+-- @param s The string being scanned.
+-- @param startPos The starting position of the scan.
+-- @return table, int The scanned object as a table and the position of the next character to scan.
+function decode_scanObject(s,startPos)
+ local object = {}
+ local stringLen = string.len(s)
+ local key, value
+ base.assert(string.sub(s,startPos,startPos)=='{','decode_scanObject called but object does not start at position ' .. startPos .. ' in string:\n' .. s)
+ startPos = startPos + 1
+ repeat
+ startPos = decode_scanWhitespace(s,startPos)
+ base.assert(startPos<=stringLen, 'JSON string ended unexpectedly while scanning object.')
+ local curChar = string.sub(s,startPos,startPos)
+ if (curChar=='}') then
+ return object,startPos+1
+ end
+ if (curChar==',') then
+ startPos = decode_scanWhitespace(s,startPos+1)
+ end
+ base.assert(startPos<=stringLen, 'JSON string ended unexpectedly scanning object.')
+ -- Scan the key
+ key, startPos = decode(s,startPos)
+ base.assert(startPos<=stringLen, 'JSON string ended unexpectedly searching for value of key ' .. key)
+ startPos = decode_scanWhitespace(s,startPos)
+ base.assert(startPos<=stringLen, 'JSON string ended unexpectedly searching for value of key ' .. key)
+ base.assert(string.sub(s,startPos,startPos)==':','JSON object key-value assignment mal-formed at ' .. startPos)
+ startPos = decode_scanWhitespace(s,startPos+1)
+ base.assert(startPos<=stringLen, 'JSON string ended unexpectedly searching for value of key ' .. key)
+ value, startPos = decode(s,startPos)
+ object[key]=value
+ until false -- infinite loop while key-value pairs are found
+end
+
+--- Scans a JSON string from the opening inverted comma or single quote to the
+-- end of the string.
+-- Returns the string extracted as a Lua string,
+-- and the position of the next non-string character
+-- (after the closing inverted comma or single quote).
+-- @param s The string being scanned.
+-- @param startPos The starting position of the scan.
+-- @return string, int The extracted string as a Lua string, and the next character to parse.
+function decode_scanString(s,startPos)
+ base.assert(startPos, 'decode_scanString(..) called without start position')
+ local startChar = string.sub(s,startPos,startPos)
+ base.assert(startChar==[[']] or startChar==[["]],'decode_scanString called for a non-string')
+ local escaped = false
+ local endPos = startPos + 1
+ local bEnded = false
+ local stringLen = string.len(s)
+ repeat
+ local curChar = string.sub(s,endPos,endPos)
+ if not escaped then
+ if curChar==[[\]] then
+ escaped = true
+ else
+ bEnded = curChar==startChar
+ end
+ else
+ -- If we're escaped, we accept the current character come what may
+ escaped = false
+ end
+ endPos = endPos + 1
+ base.assert(endPos <= stringLen+1, "String decoding failed: unterminated string at position " .. endPos)
+ until bEnded
+ local stringValue = 'return ' .. string.sub(s, startPos, endPos-1)
+ local stringEval = base.loadstring(stringValue)
+ base.assert(stringEval, 'Failed to load string [ ' .. stringValue .. '] in JSON4Lua.decode_scanString at position ' .. startPos .. ' : ' .. endPos)
+ return stringEval(), endPos
+end
+
+--- Scans a JSON string skipping all whitespace from the current start position.
+-- Returns the position of the first non-whitespace character, or nil if the whole end of string is reached.
+-- @param s The string being scanned
+-- @param startPos The starting position where we should begin removing whitespace.
+-- @return int The first position where non-whitespace was encountered, or string.len(s)+1 if the end of string
+-- was reached.
+function decode_scanWhitespace(s,startPos)
+ local whitespace=" \n\r\t"
+ local stringLen = string.len(s)
+ while ( string.find(whitespace, string.sub(s,startPos,startPos), 1, true) and startPos <= stringLen) do
+ startPos = startPos + 1
+ end
+ return startPos
+end
+
+--- Encodes a string to be JSON-compatible.
+-- This just involves back-quoting inverted commas, back-quotes and newlines, I think ;-)
+-- @param s The string to return as a JSON encoded (i.e. backquoted string)
+-- @return The string appropriately escaped.
+function encodeString(s)
+ s = string.gsub(s,'\\','\\\\')
+ s = string.gsub(s,'"','\\"')
+ s = string.gsub(s,"'","\\'")
+ s = string.gsub(s,'\n','\\n')
+ s = string.gsub(s,'\t','\\t')
+ return s
+end
+
+-- Determines whether the given Lua type is an array or a table / dictionary.
+-- We consider any table an array if it has indexes 1..n for its n items, and no
+-- other data in the table.
+-- I think this method is currently a little 'flaky', but can't think of a good way around it yet...
+-- @param t The table to evaluate as an array
+-- @return boolean, number True if the table can be represented as an array, false otherwise. If true,
+-- the second returned value is the maximum
+-- number of indexed elements in the array.
+function isArray(t)
+ -- Next we count all the elements, ensuring that any non-indexed elements are not-encodable
+ -- (with the possible exception of 'n')
+ local maxIndex = 0
+ for k,v in base.pairs(t) do
+ if (base.type(k)=='number' and math.floor(k)==k and 1<=k) then -- k,v is an indexed pair
+ if (not isEncodable(v)) then return false end -- All array elements must be encodable
+ maxIndex = math.max(maxIndex,k)
+ else
+ if (k=='n') then
+ if v ~= table.getn(t) then return false end -- False if n does not hold the number of elements
+ else -- Else of (k=='n')
+ if isEncodable(v) then return false end
+ end -- End of (k~='n')
+ end -- End of k,v not an indexed pair
+ end -- End of loop across all pairs
+ return true, maxIndex
+end
+
+--- Determines whether the given Lua object / table / variable can be JSON encoded. The only
+-- types that are JSON encodable are: string, boolean, number, nil, table and json.null.
+-- In this implementation, all other types are ignored.
+-- @param o The object to examine.
+-- @return boolean True if the object should be JSON encoded, false if it should be ignored.
+function isEncodable(o)
+ local t = base.type(o)
+ return (t=='string' or t=='boolean' or t=='number' or t=='nil' or t=='table') or (t=='function' and o==null)
+end
+
+-----------------------------------------------------------------------------
+-- JSONRPC4Lua: JSON RPC client calls over http for the Lua language.
+-- json.rpc Module.
+-- Author: Craig Mason-Jones
+-- Homepage: http://json.luaforge.net/
+-- Version: 0.9.10
+-- This module is released under the The GNU General Public License (GPL).
+-- Please see LICENCE.txt for details.
+--
+-- USAGE:
+-- This module exposes two functions:
+-- proxy( 'url')
+-- Returns a proxy object for calling the JSON RPC Service at the given url.
+-- call ( 'url', 'method', ...)
+-- Calls the JSON RPC server at the given url, invokes the appropriate method, and
+-- passes the remaining parameters. Returns the result and the error. If the result is nil, an error
+-- should be there (or the system returned a null). If an error is there, the result should be nil.
+--
+-- REQUIREMENTS:
+-- Lua socket 2.0 (http://www.cs.princeton.edu/~diego/professional/luasocket/)
+-- json (The JSON4Lua package with which it is bundled)
+-- compat-5.1 if using Lua 5.0.
+-----------------------------------------------------------------------------
+
+module('json.rpc')
+
+-----------------------------------------------------------------------------
+-- Imports and dependencies
+-----------------------------------------------------------------------------
+local json = require('json')
+local http = require("socket.http")
+
+-----------------------------------------------------------------------------
+-- PUBLIC functions
+-----------------------------------------------------------------------------
+
+--- Creates an RPC Proxy object for the given Url of a JSON-RPC server.
+-- @param url The URL for the JSON RPC Server.
+-- @return Object on which JSON-RPC remote methods can be called.
+-- EXAMPLE Usage:
+-- local jsolait = json.rpc.proxy('http://jsolait.net/testj.py')
+-- print(jsolait.echo('This is a test of the echo method!'))
+-- print(jsolait.args2String('first','second','third'))
+-- table.foreachi( jsolait.args2Array(5,4,3,2,1), print)
+function proxy(url)
+ local serverProxy = {}
+ local proxyMeta = {
+ __index = function(t, key)
+ return function(...)
+ return json.rpc.call(url, key, unpack(arg))
+ end
+ end
+ }
+ setmetatable(serverProxy, proxyMeta)
+ return serverProxy
+end
+
+--- Calls a JSON RPC method on a remote server.
+-- Returns a boolean true if the call succeeded, false otherwise.
+-- On success, the second returned parameter is the decoded
+-- JSON object from the server.
+-- On http failure, returns nil and an error message.
+-- On success, returns the result and nil.
+-- @param url The url of the JSON RPC server.
+-- @param method The method being called.
+-- @param ... Parameters to pass to the method.
+-- @return result, error The JSON RPC result and error. One or the other should be nil. If both
+-- are nil, this means that the result of the RPC call was nil.
+-- EXAMPLE Usage:
+-- print(json.rpc.call('http://jsolait.net/testj.py','echo','This string will be returned'))
+function call(url, method, ...)
+ assert(method,'method param is nil to call')
+ local JSONRequestArray = {
+ id="httpRequest",
+ ["method"]=method,
+ params = arg
+ }
+ local httpResponse, result , code
+ local jsonRequest = json.encode(JSONRequestArray)
+ -- We use the sophisticated http.request form (with ltn12 sources and sinks) so that
+ -- we can set the content-type to text/plain. While this shouldn't strictly-speaking be true,
+ -- it seems a good idea (Xavante won't work w/out a content-type header, although a patch
+ -- is needed to Xavante to make it work with text/plain)
+ local ltn12 = require('ltn12')
+ local resultChunks = {}
+ httpResponse, code = http.request(
+ { ['url'] = url,
+ sink = ltn12.sink.table(resultChunks),
+ method = 'POST',
+ headers = { ['content-type']='text/plain', ['content-length']=string.len(jsonRequest) },
+ source = ltn12.source.string(jsonRequest)
+ }
+ )
+ httpResponse = table.concat(resultChunks)
+ -- Check the http response code
+ if (code~=200) then
+ return nil, "HTTP ERROR: " .. code
+ end
+ -- And decode the httpResponse and check the JSON RPC result code
+ result = json.decode( httpResponse )
+ if result.result then
+ return result.result, nil
+ else
+ return nil, result.error
+ end
+end
+-----------------------------------------------------------------------------
+-- JSONRPC4Lua: JSON RPC server for exposing Lua objects as JSON RPC callable
+-- objects via http.
+-- json.rpcserver Module.
+-- Author: Craig Mason-Jones
+-- Homepage: http://json.luaforge.net/
+-- Version: 0.9.10
+-- This module is released under the The GNU General Public License (GPL).
+-- Please see LICENCE.txt for details.
+--
+-- USAGE:
+-- This module exposes one function:
+-- server(luaClass, packReturn)
+-- Manages incoming JSON RPC request forwarding the method call to the given
+-- object. If packReturn is true, multiple return values are packed into an
+-- array on return.
+--
+-- IMPORTANT NOTES:
+-- 1. This version ought really not be 0.9.10, since this particular part of the
+-- JSONRPC4Lua package is very first-draft. However, the JSON4Lua package with which
+-- it comes is quite solid, so there you have it :-)
+-- 2. This has only been tested with Xavante webserver, with which it works
+-- if you patch CGILua to accept 'text/plain' content type. See doc\cgilua_patch.html
+-- for details.
+----------------------------------------------------------------------------
+
+module ('json.rpcserver')
+
+---
+-- Implements a JSON RPC Server wrapping for luaClass, exposing each of luaClass's
+-- methods as JSON RPC callable methods.
+-- @param luaClass The JSON RPC class to expose.
+-- @param packReturn If true, the server will automatically wrap any
+-- multiple-value returns into an array. Single returns remain single returns. If
+-- false, when a function returns multiple values, only the first of these values will
+-- be returned.
+--
+function serve(luaClass, packReturn)
+ cgilua.contentheader('text','plain')
+ require('cgilua')
+ require ('json')
+ local postData = ""
+
+ if not cgilua.servervariable('CONTENT_LENGTH') then
+ cgilua.put("Please access JSON Request using HTTP POST Request")
+ return 0
+ else
+ postData = cgi[1] -- SAPI.Request.getpostdata() --[[{ "id":1, "method":"echo","params":["Hi there"]}]] --
+ end
+ -- @TODO Catch an error condition on decoding the data
+ local jsonRequest = json.decode(postData)
+ local jsonResponse = {}
+ jsonResponse.id = jsonRequest.id
+ local method = luaClass[ jsonRequest.method ]
+
+ if not method then
+ jsonResponse.error = 'Method ' .. jsonRequest.method .. ' does not exist at this server.'
+ else
+ local callResult = { pcall( method, unpack( jsonRequest.params ) ) }
+ if callResult[1] then -- Function call successfull
+ table.remove(callResult,1)
+ if packReturn and table.getn(callResult)>1 then
+ jsonResponse.result = callResult
+ else
+ jsonResponse.result = unpack(callResult) -- NB: Does not support multiple argument returns
+ end
+ else
+ jsonResponse.error = callResult[2]
+ end
+ end
+
+ -- Output the result
+ -- TODO: How to be sure that the result and error tags are there even when they are nil in Lua?
+ -- Can force them by hand... ?
+ cgilua.contentheader('text','plain')
+ cgilua.put( json.encode( jsonResponse ) )
+end
+
+--[[
+ Auctioneer Advanced
+ Version: <%version%> (<%codename%>)
+ Revision: $Id: CoreMain.lua 2233 2007-09-25 03:57:33Z norganna $
+ URL: http://auctioneeraddon.com/
+
+ This is an addon for World of Warcraft that adds statistical history to the auction data that is collected
+ when the auction is scanned, so that you can easily determine what price
+ you will be able to sell an item for at auction or at a vendor whenever you
+ mouse-over an item in the game
+
+ License:
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program(see GPL.txt); if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ Note:
+ This AddOn's source code is specifically designed to work with
+ World of Warcraft's interpreted AddOn system.
+ You have an implicit licence to use this AddOn with these facilities
+ since that is its designated purpose as per:
+ http://www.fsf.org/licensing/licenses/gpl-faq.html#InterpreterIncompat
+]]
+
+
+--[[
+ See CoreAPI.lua for a description of the modules API
+]]
+
+if (not AucAdvanced) then AucAdvanced = {} end
+if (not AucAdvancedData) then AucAdvancedData = {} end
+if (not AucAdvancedLocal) then AucAdvancedLocal = {} end
+if (not AucAdvancedConfig) then AucAdvancedConfig = {} end
+
+AucAdvanced.Version="<%version%>";
+if (AucAdvanced.Version == "<".."%version%>") then
+ AucAdvanced.Version = "5.0.DEV";
+end
+
+local private = {}
+
+-- For our modular stats system, each stats engine should add their
+-- subclass to AucAdvanced.Modules.<type>.<name> and store their data into their own
+-- data table in AucAdvancedData.Stats.<type><name>
+if (not AucAdvanced.Modules) then AucAdvanced.Modules = {Stat={},Util={},Filter={}} end
+if (not AucAdvancedData.Stats) then AucAdvancedData.Stats = {} end
+if (not AucAdvancedLocal.Stats) then AucAdvancedLocal.Stats = {} end
+
+function private.TooltipHook(vars, ret, frame, name, hyperlink, quality, quantity, cost, additional)
+ if EnhTooltip.LinkType(hyperlink) ~= "item" then
+ return -- Auctioneer hooks into item tooltips only
+ end
+
+ -- Check to see if we need to force load scandata
+ local getter = AucAdvanced.Settings.GetSetting
+ if (getter("scandata.tooltip.display") and getter("scandata.force")) then
+ AucAdvanced.Scan.GetImage()
+ end
+
+ for system, systemMods in pairs(AucAdvanced.Modules) do
+ for engine, engineLib in pairs(systemMods) do
+ if (engineLib.Processor) then engineLib.Processor("tooltip", frame, name, hyperlink, quality, quantity, cost, additional) end
+ end
+ end
+end
+
+function private.HookAH()
+ hooksecurefunc("AuctionFrameBrowse_Update", AucAdvanced.API.ListUpdate)
+ for system, systemMods in pairs(AucAdvanced.Modules) do
+ for engine, engineLib in pairs(systemMods) do
+ if (engineLib.Processor) then
+ engineLib.Processor("auctionui")
+ end
+ end
+ end
+end
+
+function private.OnLoad(addon)
+ addon = addon:lower()
+
+ -- Check if the actual addon itself is loading
+ if (addon == "auc-advanced") then
+ Stubby.RegisterAddOnHook("Blizzard_AuctionUi", "Auc-Advanced", private.HookAH)
+ Stubby.RegisterFunctionHook("EnhTooltip.AddTooltip", 600, private.TooltipHook)
+ for pos, module in ipairs(AucAdvanced.EmbeddedModules) do
+ -- These embedded modules have also just been loaded
+ private.OnLoad(module)
+ end
+ end
+
+ -- Notify the actual module if it exists
+ local auc, sys, eng = strsplit("-", addon)
+ if (auc == "auc" and sys and eng) then
+ for system, systemMods in pairs(AucAdvanced.Modules) do
+ if (sys == system:lower()) then
+ for engine, engineLib in pairs(systemMods) do
+ if (eng == engine:lower() and engineLib.OnLoad) then
+ engineLib.OnLoad(addon)
+ end
+ end
+ end
+ end
+ end
+
+ -- Check all modules' load triggers and pass event to processors
+ for system, systemMods in pairs(AucAdvanced.Modules) do
+ for engine, engineLib in pairs(systemMods) do
+ if (engineLib.LoadTriggers and engineLib.LoadTriggers[addon]) then
+ if (engineLib.OnLoad) then
+ engineLib.OnLoad(addon)
+ end
+ end
+ if (engineLib.Processor and auc == "auc" and sys and eng) then
+ engineLib.Processor("load", addon)
+ end
+ end
+ end
+end
+
+function private.OnUnload()
+ for system, systemMods in pairs(AucAdvanced.Modules) do
+ for engine, engineLib in pairs(systemMods) do
+ if (engineLib.OnUnload) then
+ engineLib.OnUnload()
+ end
+ end
+ end
+end
+
+private.Schedule = {}
+function private.OnEvent(...)
+ local event, arg = select(2, ...)
+ if (event == "ADDON_LOADED") then
+ local addon = string.lower(arg)
+ if (addon:sub(1,4) == "auc-") then
+ private.OnLoad(addon)
+ end
+ elseif (event == "AUCTION_HOUSE_SHOW") then
+ -- Do Nothing for now
+ elseif (event == "AUCTION_HOUSE_CLOSED") then
+ AucAdvanced.Scan.Interrupt()
+ elseif (event == "PLAYER_LOGOUT") then
+ AucAdvanced.Scan.Commit(true)
+ private.OnUnload()
+ elseif event == "UNIT_INVENTORY_CHANGED"
+ or event == "ITEM_LOCK_CHANGED"
+ or event == "CURSOR_UPDATE"
+ or event == "BAG_UPDATE"
+ then
+ private.Schedule["inventory"] = GetTime() + 0.15
+ end
+end
+
+function private.OnUpdate(...)
+ if event == "inventory" then
+ AucAdvanced.Post.AlertBagsChanged()
+ end
+
+ local now = GetTime()
+ for event, time in pairs(private.Schedule) do
+ if time > now then
+ for system, systemMods in pairs(AucAdvanced.Modules) do
+ for engine, engineLib in pairs(systemMods) do
+ if engineLib.Processor then
+ engineLib.Processor(event, time)
+ end
+ end
+ end
+ end
+ private.Schedule[event] = nil
+ end
+end
+
+private.Frame = CreateFrame("Frame")
+private.Frame:RegisterEvent("ADDON_LOADED")
+private.Frame:RegisterEvent("AUCTION_HOUSE_SHOW")
+private.Frame:RegisterEvent("AUCTION_HOUSE_CLOSED")
+private.Frame:RegisterEvent("UNIT_INVENTORY_CHANGED")
+private.Frame:RegisterEvent("ITEM_LOCK_CHANGED")
+private.Frame:RegisterEvent("CURSOR_UPDATE")
+private.Frame:RegisterEvent("BAG_UPDATE")
+private.Frame:RegisterEvent("PLAYER_LOGOUT")
+private.Frame:SetScript("OnEvent", private.OnEvent)
+private.Frame:SetScript("OnUpdate", private.OnUpdate)
+
+-- Auctioneer's debug functions
+AucAdvanced.Debug = {}
+local addonName = "Auctioneer" -- the addon's name as it will be displayed in
+ -- the debug messages
+-------------------------------------------------------------------------------
+-- Prints the specified message to nLog.
+--
+-- syntax:
+-- errorCode, message = debugPrint([message][, category][, title][, errorCode][, level])
+--
+-- parameters:
+-- message - (string) the error message
+-- nil, no error message specified
+-- category - (string) the category of the debug message
+-- nil, no category specified
+-- title - (string) the title for the debug message
+-- nil, no title specified
+-- errorCode - (number) the error code
+-- nil, no error code specified
+-- level - (string) nLog message level
+-- Any nLog.levels string is valid.
+-- nil, no level specified
+--
+-- returns:
+-- errorCode - (number) errorCode, if one is specified
+-- nil, otherwise
+-- message - (string) message, if one is specified
+-- nil, otherwise
+-------------------------------------------------------------------------------
+function AucAdvanced.Debug.DebugPrint(message, category, title, errorCode, level)
+ return DebugLib.DebugPrint(addonName, message, category, title, errorCode, level)
+end
+
+-------------------------------------------------------------------------------
+-- Used to make sure that conditions are met within functions.
+-- If test is false, the error message will be written to nLog and the user's
+-- default chat channel.
+--
+-- syntax:
+-- assertion = assert(test, message)
+--
+-- parameters:
+-- test - (any) false/nil, if the assertion failed
+-- anything else, otherwise
+-- message - (string) the message which will be output to the user
+--
+-- returns:
+-- assertion - (boolean) true, if the test passed
+-- false, otherwise
+-------------------------------------------------------------------------------
+function AucAdvanced.Debug.Assert(test, message)
+ return DebugLib.Assert(addonName, test, message)
+end
+
+
diff --git a/etc/todo/example.lua.zip b/etc/todo/example.lua.zip
new file mode 100644
index 0000000..60a022d
--- /dev/null
+++ b/etc/todo/example.lua.zip
Binary files differ
diff --git a/etc/todo/latex.rb b/etc/todo/latex.rb
new file mode 100644
index 0000000..5a6e309
--- /dev/null
+++ b/etc/todo/latex.rb
@@ -0,0 +1,44 @@
+module CodeRay
+module Encoders
+
+ class Latex < Encoder
+
+ include Streamable
+ register_for :latex
+
+ FILE_EXTENSION = 'tex'
+
+ ALLTT_ESCAPE = { #:nodoc:
+ '{' => '\lb',
+ '}' => '\rb',
+ '\\' => '\bs',
+ }
+
+ HTML_ESCAPE_PATTERN = /[\\{}]/
+
+ protected
+
+ def text_token text, kind
+ if text =~ /#{HTML_ESCAPE_PATTERN}/o
+ text = text.gsub(/#{HTML_ESCAPE_PATTERN}/o) { |m| @HTML_ESCAPE[m] }
+ end
+ k = Tokens::ClassOfKind[kind]
+ if k == :NO_HIGHLIGHT
+ text
+ else
+ "\\CR#{k}{#{text}}"
+ end
+ end
+
+ def open_token kind
+ "\\CR#{Tokens::ClassOfKind[kind]}{"
+ end
+
+ def close_token kind
+ "}"
+ end
+
+ end
+
+end
+end
diff --git a/etc/todo/scanners.zip b/etc/todo/scanners.zip
new file mode 100644
index 0000000..78eeca3
--- /dev/null
+++ b/etc/todo/scanners.zip
Binary files differ
diff --git a/etc/todo/scanners/applescript-sebastian.rb b/etc/todo/scanners/applescript-sebastian.rb
new file mode 100644
index 0000000..ec29091
--- /dev/null
+++ b/etc/todo/scanners/applescript-sebastian.rb
@@ -0,0 +1,219 @@
+# Scanner for AppleScript Created by Sebastian Yepes F.
+# Web: http://sebastian.yepes.in
+# e-Mail: sebastian@yepes.in
+
+module CodeRay
+module Scanners
+
+ class AppleScript < Scanner
+
+ register_for :applescript
+
+ RESERVED_WORDS = [
+ '#include', 'for', 'foreach', 'if', 'elseif', 'else', 'while', 'do', 'dowhile', 'end',
+ 'switch', 'case', 'return', 'break', 'continue', 'in', 'to', 'of', 'repeat', 'tell', 'then','as'
+ ]
+
+ KEYWORD_OPERATOR = [
+ 'is greater than', 'comes after', 'is less than', 'comes before',
+ 'is greater than or equal to', 'is less than or equal to', 'is equal to',
+ 'is', 'is not equal to', 'is not', 'contains', 'does not contain', 'is in',
+ 'is not in', 'starts with', 'ends with'
+ ]
+
+
+ DIRECTIVES = [
+ 'activate', '#endinitclip', '#initclip', '__proto__', '_accProps', '_alpha', '_currentframe',
+ '_droptarget', '_focusrect', '_framesloaded', '_height', '_highquality', '_lockroot',
+ '_name', '_parent', '_quality', '_root', '_rotation', '_soundbuftime', '_target', '_totalframes',
+ '_url', '_visible', '_width', '_x', '_xmouse', '_xscale', '_y', '_ymouse', '_yscale', 'abs',
+ 'Accessibility', 'acos', 'activityLevel', 'add', 'addListener', 'addPage', 'addProperty',
+ 'addRequestHeader', 'align', 'allowDomain', 'allowInsecureDomain', 'and', 'appendChild',
+ 'apply', 'Arguments', 'Array', 'asfunction', 'asin', 'atan', 'atan2', 'attachAudio', 'attachMovie',
+ 'attachSound', 'attachVideo', 'attributes', 'autosize', 'avHardwareDisable', 'background',
+ 'backgroundColor', 'BACKSPACE', 'bandwidth', 'beginFill', 'beginGradientFill', 'blockIndent',
+ 'bold', 'Boolean', 'border', 'borderColor', 'bottomScroll', 'bufferLength', 'bufferTime',
+ 'builtInItems', 'bullet', 'Button', 'bytesLoaded', 'bytesTotal', 'call', 'callee', 'caller',
+ 'Camera', 'capabilities', 'CAPSLOCK', 'caption', 'catch', 'ceil', 'charAt', 'charCodeAt',
+ 'childNodes', 'chr', 'clear', 'clearInterval', 'cloneNode', 'close', 'Color', 'concat',
+ 'connect', 'condenseWhite', 'constructor', 'contentType', 'ContextMenu', 'ContextMenuItem',
+ 'CONTROL', 'copy', 'cos', 'createElement', 'createEmptyMovieClip', 'createTextField',
+ 'createTextNode', 'currentFps', 'curveTo', 'CustomActions', 'customItems', 'data', 'Date',
+ 'deblocking', 'delete', 'DELETEKEY', 'docTypeDecl', 'domain', 'DOWN',
+ 'duplicateMovieClip', 'duration', 'dynamic', 'E', 'embedFonts', 'enabled',
+ 'endFill', 'ENTER', 'eq', 'Error', 'ESCAPE(Konstante)', 'escape(Funktion)', 'eval',
+ 'exactSettings', 'exp', 'extends', 'finally', 'findText', 'firstChild', 'floor',
+ 'flush', 'focusEnabled', 'font', 'fps', 'fromCharCode', 'fscommand',
+ 'gain', 'ge', 'get', 'getAscii', 'getBeginIndex', 'getBounds', 'getBytesLoaded', 'getBytesTotal',
+ 'getCaretIndex', 'getCode', 'getCount', 'getDate', 'getDay', 'getDepth', 'getEndIndex', 'getFocus',
+ 'getFontList', 'getFullYear', 'getHours', 'getInstanceAtDepth', 'getLocal', 'getMilliseconds',
+ 'getMinutes', 'getMonth', 'getNewTextFormat', 'getNextHighestDepth', 'getPan', 'getProgress',
+ 'getProperty', 'getRGB', 'getSeconds', 'getSelected', 'getSelectedText', 'getSize', 'getStyle',
+ 'getStyleNames', 'getSWFVersion', 'getText', 'getTextExtent', 'getTextFormat', 'getTextSnapshot',
+ 'getTime', 'getTimer', 'getTimezoneOffset', 'getTransform', 'getURL', 'getUTCDate', 'getUTCDay',
+ 'getUTCFullYear', 'getUTCHours', 'getUTCMilliseconds', 'getUTCMinutes', 'getUTCMonth', 'getUTCSeconds',
+ 'getVersion', 'getVolume', 'getYear', 'globalToLocal', 'goto', 'gotoAndPlay', 'gotoAndStop',
+ 'hasAccessibility', 'hasAudio', 'hasAudioEncoder', 'hasChildNodes', 'hasEmbeddedVideo', 'hasMP3',
+ 'hasPrinting', 'hasScreenBroadcast', 'hasScreenPlayback', 'hasStreamingAudio', 'hasStreamingVideo',
+ 'hasVideoEncoder', 'height', 'hide', 'hideBuiltInItems', 'hitArea', 'hitTest', 'hitTestTextNearPos',
+ 'HOME', 'hscroll', 'html', 'htmlText', 'ID3', 'ifFrameLoaded', 'ignoreWhite', 'implements',
+ 'import', 'indent', 'index', 'indexOf', 'Infinity', '-Infinity', 'INSERT', 'insertBefore', 'install',
+ 'instanceof', 'int', 'interface', 'isActive', 'isDebugger', 'isDown', 'isFinite', 'isNaN', 'isToggled',
+ 'italic', 'join', 'Key', 'language', 'lastChild', 'lastIndexOf', 'le', 'leading', 'LEFT', 'leftMargin',
+ 'length', 'level', 'lineStyle', 'lineTo', 'list', 'LN10', 'LN2', 'load', 'loadClip', 'loaded', 'loadMovie',
+ 'loadMovieNum', 'loadSound', 'loadVariables', 'loadVariablesNum', 'LoadVars', 'LocalConnection',
+ 'localFileReadDisable', 'localToGlobal', 'log', 'LOG10E', 'LOG2E', 'manufacturer', 'Math', 'max',
+ 'MAX_VALUE', 'maxChars', 'maxhscroll', 'maxscroll', 'mbchr', 'mblength', 'mbord', 'mbsubstring', 'menu',
+ 'message', 'Microphone', 'min', 'MIN_VALUE', 'MMExecute', 'motionLevel', 'motionTimeOut', 'Mouse',
+ 'mouseWheelEnabled', 'moveTo', 'Movieclip', 'MovieClipLoader', 'multiline', 'muted', 'name', 'names', 'NaN',
+ 'ne', 'NEGATIVE_INFINITY', 'NetConnection', 'NetStream', 'newline', 'nextFrame',
+ 'nextScene', 'nextSibling', 'nodeName', 'nodeType', 'nodeValue', 'not', 'Number', 'Object',
+ 'on', 'onActivity', 'onChanged', 'onClipEvent', 'onClose', 'onConnect', 'onData', 'onDragOut',
+ 'onDragOver', 'onEnterFrame', 'onID3', 'onKeyDown', 'onKeyUp', 'onKillFocus', 'onLoad', 'onLoadComplete',
+ 'onLoadError', 'onLoadInit', 'onLoadProgress', 'onLoadStart', 'onMouseDown', 'onMouseMove', 'onMouseUp',
+ 'onMouseWheel', 'onPress', 'onRelease', 'onReleaseOutside', 'onResize', 'onRollOut', 'onRollOver',
+ 'onScroller', 'onSelect', 'onSetFocus', 'onSoundComplete', 'onStatus', 'onUnload', 'onUpdate', 'onXML',
+ 'or(logischesOR)', 'ord', 'os', 'parentNode', 'parseCSS', 'parseFloat', 'parseInt', 'parseXML', 'password',
+ 'pause', 'PGDN', 'PGUP', 'PI', 'pixelAspectRatio', 'play', 'playerType', 'pop', 'position',
+ 'POSITIVE_INFINITY', 'pow', 'prevFrame', 'previousSibling', 'prevScene', 'print', 'printAsBitmap',
+ 'printAsBitmapNum', 'PrintJob', 'printNum', 'private', 'prototype', 'public', 'push', 'quality',
+ 'random', 'rate', 'registerClass', 'removeListener', 'removeMovieClip', 'removeNode', 'removeTextField',
+ 'replaceSel', 'replaceText', 'resolutionX', 'resolutionY', 'restrict', 'reverse', 'RIGHT',
+ 'rightMargin', 'round', 'scaleMode', 'screenColor', 'screenDPI', 'screenResolutionX', 'screenResolutionY',
+ 'scroll', 'seek', 'selectable', 'Selection', 'send', 'sendAndLoad', 'separatorBefore', 'serverString',
+ 'set', 'setvariable', 'setBufferTime', 'setClipboard', 'setDate', 'setFocus', 'setFullYear', 'setGain',
+ 'setHours', 'setInterval', 'setMask', 'setMilliseconds', 'setMinutes', 'setMode', 'setMonth',
+ 'setMotionLevel', 'setNewTextFormat', 'setPan', 'setProperty', 'setQuality', 'setRate', 'setRGB',
+ 'setSeconds', 'setSelectColor', 'setSelected', 'setSelection', 'setSilenceLevel', 'setStyle',
+ 'setTextFormat', 'setTime', 'setTransform', 'setUseEchoSuppression', 'setUTCDate', 'setUTCFullYear',
+ 'setUTCHours', 'setUTCMilliseconds', 'setUTCMinutes', 'setUTCMonth', 'setUTCSeconds', 'setVolume',
+ 'setYear', 'SharedObject', 'SHIFT(Konstante)', 'shift(Methode)', 'show', 'showMenu', 'showSettings',
+ 'silenceLevel', 'silenceTimeout', 'sin', 'size', 'slice', 'smoothing', 'sort', 'sortOn', 'Sound', 'SPACE',
+ 'splice', 'split', 'sqrt', 'SQRT1_2', 'SQRT2', 'Stage', 'start', 'startDrag', 'static', 'status', 'stop',
+ 'stopAllSounds', 'stopDrag', 'StyleSheet(Klasse)', 'styleSheet(Eigenschaft)', 'substr',
+ 'substring', 'super', 'swapDepths', 'System', 'TAB', 'tabChildren', 'tabEnabled', 'tabIndex',
+ 'tabStops', 'tan', 'target', 'targetPath', 'tellTarget', 'text', 'textColor', 'TextField', 'TextFormat',
+ 'textHeight', 'TextSnapshot', 'textWidth', 'this', 'throw', 'time', 'toggleHighQuality', 'toLowerCase',
+ 'toString', 'toUpperCase', 'trace', 'trackAsMenu', 'try', 'type', 'typeof', 'undefined',
+ 'underline', 'unescape', 'uninstall', 'unloadClip', 'unloadMovie', 'unLoadMovieNum', 'unshift', 'unwatch',
+ 'UP', 'updateAfterEvent', 'updateProperties', 'url', 'useCodePage', 'useEchoSuppression', 'useHandCursor',
+ 'UTC', 'valueOf', 'variable', 'version', 'Video', 'visible', 'void', 'watch', 'width',
+ 'with', 'wordwrap', 'XML', 'xmlDecl', 'XMLNode', 'XMLSocket'
+ ]
+
+ PREDEFINED_TYPES = [
+ 'boolean', 'small integer', 'integer', 'double integer',
+ 'small real', 'real', 'date','list', 'record', 'string', 'class'
+ ]
+
+ PREDEFINED_CONSTANTS = [
+ 'pi', 'true', 'false',
+ 'application responses', 'case', 'diacriticals', 'expansion', 'hyphens', 'punctuation', 'white space',
+ 'seconds', 'minutes', 'hours', 'days', 'weeks',
+ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun',
+ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',
+ 'anything', 'current application', 'it', 'me', 'missing value', 'my', 'result',
+ 'yes', 'no', 'ask',
+ 'return', 'space', 'tab',
+ 'all caps', 'all lowercase', 'bold', 'condensed', 'expanded', 'hidden', 'italic', 'outline', 'plain', 'shadow', 'small caps', 'strikethrough', 'subscript', 'superscript', 'underline',
+ 'version'
+ ]
+
+ PLAIN_STRING_CONTENT = {
+ "'" => /[^'\n]+/,
+ '"' => /[^"\n]+/,
+ }
+
+
+ IDENT_KIND = CaseIgnoringWordList.new(:ident).
+ add(RESERVED_WORDS, :reserved).
+ add(KEYWORD_OPERATOR, :operator).
+ add(DIRECTIVES, :directive).
+ add(PREDEFINED_TYPES, :pre_type).
+ add(PREDEFINED_CONSTANTS, :pre_constant)
+
+
+
+ def scan_tokens tokens, options
+
+ state = :initial
+ plain_string_content = @plain_string_content
+
+ until eos?
+
+ kind = nil
+ match = nil
+
+ if state == :initial
+
+ if scan(/\s+/x)
+ kind = :space
+
+ elsif scan(%r! \{ \$ [^}]* \}? | \(\* \$ (?: .*? \*\) | .* ) !mx)
+ kind = :preprocessor
+
+ elsif scan(/^[\s\t]*--.*/x)
+ kind = :comment
+ elsif scan(/\(\* (?: .*? \*\)$ | .* )/mx)
+ kind = :comment
+
+ elsif scan(/ [-+*\/=<>:;,.@\^|\(\)\[\]]+ /x)
+ kind = :operator
+
+ elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x)
+ kind = IDENT_KIND[match]
+
+ elsif match = scan(/ ' ( [^\n']|'' ) (?:'|$) /x)
+ tokens << [:open, :char]
+ tokens << ["'", :delimiter]
+ tokens << [self[1], :content]
+ tokens << ["'", :delimiter]
+ tokens << [:close, :char]
+ next
+
+ elsif match = scan(/["']/)
+ tokens << [:open, :string]
+ state = :string
+ plain_string_content = PLAIN_STRING_CONTENT[match]
+ kind = :delimiter
+
+ else
+ kind = :plain
+ getch
+
+ end
+
+ elsif state == :string
+ if scan(plain_string_content)
+ kind = :content
+ elsif scan(/['"]/)
+ tokens << [matched, :delimiter]
+ tokens << [:close, :string]
+ state = :initial
+ next
+ elsif scan(/ \\ | $ /x)
+ tokens << [:close, :string]
+ kind = :error
+ state = :initial
+ end
+
+ else
+ raise_inspect "else case \" reached; %p not handled." % peek(1), tokens
+ end
+
+ match ||= matched
+ if $DEBUG and not kind
+ raise_inspect 'Error token %p in line %d' %
+ [[match, kind], line], tokens
+ end
+ raise_inspect 'Empty token', tokens unless match
+ tokens << [match, kind]
+
+ end
+ tokens
+ end
+
+ end
+
+end
+end \ No newline at end of file
diff --git a/etc/todo/scanners/avrasm.rb b/etc/todo/scanners/avrasm.rb
new file mode 100644
index 0000000..b3fc28d
--- /dev/null
+++ b/etc/todo/scanners/avrasm.rb
@@ -0,0 +1,153 @@
+module CodeRay
+module Scanners
+
+ class AVRASM < Scanner
+
+ register_for :avrasm
+
+ RESERVED_WORDS = [
+ ]
+
+ PREDEFINED_TYPES = [
+ ]
+
+ PREDEFINED_CONSTANTS = [
+ ]
+
+ IDENT_KIND = CaseIgnoringWordList.new(:ident).
+ add(RESERVED_WORDS, :reserved).
+ add(PREDEFINED_TYPES, :pre_type).
+ add(PREDEFINED_CONSTANTS, :pre_constant)
+
+ ESCAPE = / [rbfnrtv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x
+ UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x
+
+ def scan_tokens tokens, options
+
+ state = :initial
+
+ until eos?
+
+ kind = nil
+ match = nil
+
+ case state
+
+ when :initial
+
+ if scan(/ \s+ | \\\n /x)
+ kind = :space
+
+ elsif scan(/;.*/x)
+ kind = :comment
+
+ elsif scan(/\.(\w*)/x)
+ kind = :preprocessor
+ state = :include_expected if self[1] == 'include'
+
+ elsif scan(/@[0-9]+/)
+ kind = :preprocessor
+
+ elsif scan(/ [-+*\/=<>?:;,!&^|()\[\]{}~%]+ | \.(?!\d) /x)
+ kind = :operator
+
+ elsif scan(/r[0-9]+/i)
+ # register R0-R31
+ kind = :pre_constant
+
+ elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x)
+ kind = IDENT_KIND[match]
+ if kind == :ident and check(/:(?!:)/)
+ match << scan(/:/)
+ kind = :label
+ end
+
+ elsif match = scan(/"/)
+ tokens << [:open, :string]
+ state = :string
+ kind = :delimiter
+
+ elsif scan(/ L?' (?: [^\'\n\\] | \\ #{ESCAPE} )? '? /ox)
+ kind = :char
+
+ elsif scan(/0[xX][0-9A-Fa-f]+/)
+ kind = :integer
+
+ elsif scan(/(?:0[0-7]+)(?![89.eEfF])/)
+ kind = :integer
+
+ elsif scan(/0[bB][0-9A-Fa-f]+/)
+ kind = :integer
+
+ elsif scan(/(?:\d+)(?![.eEfF])/)
+ kind = :integer
+
+ elsif scan(/\d[fF]?|\d*\.\d+(?:[eE][+-]?\d+)?[fF]?|\d+[eE][+-]?\d+[fF]?/)
+ kind = :float
+
+ else
+ getch
+ kind = :error
+
+ end
+
+ when :string
+ if scan(/[^\\\n"]+/)
+ kind = :content
+ elsif scan(/"/)
+ tokens << ['"', :delimiter]
+ tokens << [:close, :string]
+ state = :initial
+ next
+ elsif scan(/ \\ (?: #{ESCAPE} | #{UNICODE_ESCAPE} ) /mox)
+ kind = :char
+ elsif scan(/ \\ | $ /x)
+ tokens << [:close, :string]
+ kind = :error
+ state = :initial
+ else
+ raise_inspect "else case \" reached; %p not handled." % peek(1), tokens
+ end
+
+ when :include_expected
+ if scan(/<[^>\n]+>?|"[^"\n\\]*(?:\\.[^"\n\\]*)*"?/)
+ kind = :include
+ state = :initial
+
+ elsif match = scan(/\s+/)
+ kind = :space
+ state = :initial if match.index ?\n
+
+ else
+ getch
+ kind = :error
+
+ end
+
+ else
+ raise_inspect 'Unknown state', tokens
+
+ end
+
+ match ||= matched
+ if $DEBUG and not kind
+ raise_inspect 'Error token %p in line %d' %
+ [[match, kind], line], tokens
+ end
+ raise_inspect 'Empty token', tokens unless match
+
+ tokens << [match, kind]
+
+ end
+
+ if state == :string
+ tokens << [:close, :string]
+ end
+
+ tokens
+ end
+
+ end
+
+end
+end
diff --git a/etc/todo/scanners/css.rb b/etc/todo/scanners/css.rb
new file mode 100644
index 0000000..f1072f1
--- /dev/null
+++ b/etc/todo/scanners/css.rb
@@ -0,0 +1,170 @@
+module CodeRay
+module Scanners
+
+ class Css < Scanner
+
+ register_for :css
+
+ module RE
+ NonASCII = /[\x80-\xFF]/
+ Hex = /[0-9a-fA-F]/
+ Unicode = /\\#{Hex}{1,6}(?:\r\n|\s)?/ # differs from standard because it allows uppercase hex too
+ Escape = /#{Unicode}|\\[^\r\n\f0-9a-fA-F]/
+ NMChar = /[_a-zA-Z0-9-]|#{NonASCII}|#{Escape}/
+ NMStart = /[_a-zA-Z]|#{NonASCII}|#{Escape}/
+ NL = /\r\n|\r|\n|\f/
+ String1 = /"(?:[^\n\r\f\\"]|\\#{NL}|#{Escape})*"/
+ String2 = /'(?:[^\n\r\f\\']|\\#{NL}|#{Escape})*'/
+ String = /#{String1}|#{String2}/
+ Invalid1 = /"(?:[^\n\r\f\\"]|\\#{NL}|#{Escape})*/
+ Invalid2 = /'(?:[^\n\r\f\\']|\\#{NL}|#{Escape})*/
+ Invalid = /#{Invalid1}|#{Invalid2}/
+ W = /\s+/
+ S = W
+
+ HexColor = /#(?:#{Hex}{6}|#{Hex}{3})/
+ Color = /#{HexColor}/
+
+ Num = /-?(?:[0-9]+|[0-9]*\.[0-9]+)/
+ Name = /#{NMChar}+/
+ Ident = /-?#{NMStart}#{NMChar}*/
+ AtKeyword = /@#{Ident}/
+ Percentage = /#{Num}%/
+
+ reldimensions = %w[em ex px]
+ absdimensions = %w[in cm mm pt pc]
+ Unit = /#{(reldimensions + absdimensions).join('|')}/
+
+ Dimension = /#{Num}#{Unit}/
+
+ Comment = %r! /\* (?: .*? \*/ | .* ) !mx
+ URL = /url\((?:[^)\n\r\f]|\\\))*\)/
+
+
+ Id = /##{Name}/
+ Class = /\.#{Name}/
+
+ end
+
+ def scan_tokens tokens, options
+ states = [:initial]
+ i = 0
+ until eos?
+
+ kind = nil
+ match = nil
+
+ if states.last == :comment
+ if scan /(?:[^\n\r\f*]|\*(?!\/))+/
+ kind = :comment
+
+ elsif scan /\*\//
+ kind = :comment
+ states.pop
+
+ elsif scan RE::S
+ kind = :space
+ end
+
+ elsif scan RE::S
+ kind = :space
+
+ elsif scan /\/\*/
+ kind = :comment
+ states.push :comment
+
+ elsif scan RE::String
+ kind = :string
+
+ elsif scan RE::AtKeyword
+ kind = :reserved
+
+ elsif scan RE::Invalid
+ kind = :error
+
+ elsif scan RE::URL
+ kind = :string
+
+ elsif scan RE::Dimension
+ kind = :float
+
+ elsif scan RE::Percentage
+ kind = :float
+
+ elsif scan RE::Num
+ kind = :float
+
+ elsif scan /\{/
+ kind = :operator
+ states.push :block
+
+ elsif scan /\}/
+ if states.last == :block
+ kind = :operator
+ states.pop
+ else
+ kind = :error
+ end
+
+ elsif
+ case states.last
+ when :initial
+
+ if scan RE::Class
+ kind = :class
+
+ elsif scan RE::Id
+ kind = :constant
+
+ elsif scan RE::Ident
+ kind = :label
+
+ elsif scan RE::Name
+ kind = :identifier
+
+ end
+
+ when :block
+ if scan RE::Color
+ kind = :color
+
+ elsif scan RE::Ident
+ kind = :definition
+
+ elsif scan RE::Name
+ kind = :symbol
+
+ end
+
+ else
+ raise_inspect 'Unknown state', tokens
+
+ end
+
+ elsif scan(/ [-+*\/=<>?:;,!&^|()\[\]{}~%]+ | \.(?!\d) /x)
+ kind = :operator
+
+ else
+ getch
+ kind = :error
+
+ end
+
+ match ||= matched
+ if $DEBUG and not kind
+ raise_inspect 'Error token %p in line %d' %
+ [[match, kind], line], tokens
+ end
+ raise_inspect 'Empty token', tokens unless match
+
+ tokens << [match, kind]
+
+ end
+
+ tokens
+ end
+
+ end
+
+end
+end
diff --git a/etc/todo/scanners/javascript.rb b/etc/todo/scanners/javascript.rb
new file mode 100644
index 0000000..da67084
--- /dev/null
+++ b/etc/todo/scanners/javascript.rb
@@ -0,0 +1,199 @@
+module CodeRay
+module Scanners
+
+ # Basic Javascript scanner
+ class Javascript < Scanner
+
+ include Streamable
+
+ register_for :javascript
+
+ helper :patterns
+
+ DEFAULT_OPTIONS = {
+ }
+
+ private
+ def scan_tokens tokens, options
+ first_bake = saved_tokens = nil
+ last_token_dot = false
+ last_state = nil
+ state = :initial
+ depth = nil
+ inline_block_stack = []
+
+ patterns = Patterns # avoid constant lookup
+
+ until eos?
+ match = nil
+ kind = nil
+
+ if state.instance_of? patterns::StringState
+# {{{
+ match = scan_until(state.pattern) || scan_until(/\z/)
+ tokens << [match, :content] unless match.empty?
+ break if eos?
+
+ case match = getch
+
+ when state.delim
+ if state.paren
+ state.paren_depth -= 1
+ if state.paren_depth > 0
+ tokens << [match, :nesting_delimiter]
+ next
+ end
+ end
+ tokens << [match, :delimiter]
+ tokens << [:close, state.type]
+ state = state.next_state
+
+ when '\\'
+ if state.interpreted
+ if esc = scan(/ #{patterns::ESCAPE} /ox)
+ tokens << [match + esc, :char]
+ else
+ tokens << [match, :error]
+ end
+ else
+ case m = getch
+ when state.delim, '\\'
+ tokens << [match + m, :char]
+ when nil
+ tokens << [match, :error]
+ else
+ tokens << [match + m, :content]
+ end
+ end
+
+ when '#'
+ case peek(1)[0]
+ when ?{
+ inline_block_stack << [state, depth]
+ state = :initial
+ depth = 1
+ tokens << [:open, :inline]
+ tokens << [match + getch, :delimiter]
+ when ?$, ?@
+ tokens << [match, :escape]
+ last_state = state # scan one token as normal code, then return here
+ state = :initial
+ else
+ raise_inspect 'else-case # reached; #%p not handled' % peek(1), tokens
+ end
+
+ when state.paren
+ state.paren_depth += 1
+ tokens << [match, :nesting_delimiter]
+
+ else
+ raise_inspect 'else-case " reached; %p not handled, state = %p' % [match, state], tokens
+
+ end
+ next
+# }}}
+ else
+# {{{
+ if match = scan(/ [ \t\f]+ | \\? \n | \# .* /x)
+ case m = match[0]
+ when ?\s, ?\t, ?\f
+ match << scan(/\s*/) unless eos?
+ kind = :space
+ when ?\n, ?\\
+ kind = :space
+ match << scan(/\s*/) unless eos?
+ when ?#, ?=, ?_
+ kind = :comment
+ else
+ raise_inspect 'else-case _ reached, because case %p was not handled' % [matched[0].chr], tokens
+ end
+ tokens << [match, kind]
+ next
+
+ elsif state == :initial
+
+ # IDENTS #
+ if match = scan(/#{patterns::METHOD_NAME}/o)
+ kind = last_token_dot ? :ident :
+ patterns::IDENT_KIND[match]
+
+ # OPERATORS #
+ elsif (not last_token_dot and match = scan(/ ==?=? | \.\.?\.? | [\(\)\[\]\{\}] | :: | , /x)) or
+ (last_token_dot and match = scan(/#{patterns::METHOD_NAME_OPERATOR}/o))
+ last_token_dot = :set if match == '.' or match == '::'
+ kind = :operator
+ unless inline_block_stack.empty?
+ case match
+ when '{'
+ depth += 1
+ when '}'
+ depth -= 1
+ if depth == 0 # closing brace of inline block reached
+ state, depth = inline_block_stack.pop
+ tokens << [match, :delimiter]
+ kind = :inline
+ match = :close
+ end
+ end
+ end
+
+ elsif match = scan(/ ['"] /mx)
+ tokens << [:open, :string]
+ kind = :delimiter
+ state = patterns::StringState.new :string, match == '"', match # important for streaming
+
+ elsif match = scan(/#{patterns::NUMERIC}/o)
+ kind = if self[1] then :float else :integer end
+
+ elsif match = scan(/ \+\+ | -- | << | >> /x)
+ kind = :operator
+
+ elsif match = scan(/ [-+!~^]=? | [*|&]{1,2}=? | >>? /x)
+ kind = :operator
+
+ elsif match = scan(/ [\/%]=? | <(?:<|=>?)? | [?:;] /x)
+ kind = :operator
+
+ else
+ kind = :error
+ match = getch
+
+ end
+
+ end
+# }}}
+
+ last_token_dot = last_token_dot == :set
+
+ if $DEBUG and not kind
+ raise_inspect 'Error token %p in line %d' %
+ [[match, kind], line], tokens, state
+ end
+ raise_inspect 'Empty token', tokens unless match
+
+ tokens << [match, kind]
+
+ if last_state
+ state = last_state
+ last_state = nil
+ end
+ end
+ end
+
+ inline_block_stack << [state] if state.is_a? patterns::StringState
+ until inline_block_stack.empty?
+ this_block = inline_block_stack.pop
+ tokens << [:close, :inline] if this_block.size > 1
+ state = this_block.first
+ tokens << [:close, state.type]
+ end
+
+ tokens
+ end
+
+ end
+
+end
+end
+
+# vim:fdm=marker
diff --git a/etc/todo/scanners/lisp.rb b/etc/todo/scanners/lisp.rb
new file mode 100644
index 0000000..73ce0da
--- /dev/null
+++ b/etc/todo/scanners/lisp.rb
@@ -0,0 +1,102 @@
+# By Nathan Weizenbaum (http://nex3.leeweiz.net)
+# MIT License (http://www.opensource.org/licenses/mit-license.php)
+#
+# CodeRay scanner for Lisp.
+# The keywords are mostly geared towards Emacs Lisp,
+# but it should work fine for Common Lisp
+# and reasonably well for Scheme.
+
+require 'rubygems'
+require 'coderay'
+
+module CodeRay::Scanners
+ class Lisp < Scanner
+ register_for :lisp
+
+ NON_SYMBOL_CHARS = '();\s\[\]'
+ SYMBOL_RE = /[^#{NON_SYMBOL_CHARS}]+/
+ EXPONENT_RE = /(e[\-+]?[0-9]+)?/
+
+ GEN_DEFINES = %w{
+ defun defun* defsubst defmacro defadvice define-skeleton define-minor-mode
+ define-global-minor-mode define-globalized-minor-mode define-derived-mode
+ define-generic-mode define-compiler-macro define-modify-macro defsetf
+ define-setf-expander define-method-combination defgeneric defmethod
+ }
+ TYPE_DEFINES = %w{
+ defgroup deftheme deftype defstruct defclass define-condition
+ define-widget defface defpackage
+ }
+ VAR_DEFINES = %w{
+ defvar defconst defconstant defcustom defparameter define-symbol-macro
+ }
+ KEYWORDS = (GEN_DEFINES + TYPE_DEFINES + VAR_DEFINES + %w{
+ lambda autoload progn prog1 prog2 save-excursion save-window-excursion
+ save-selected-window save-restriction save-match-data save-current-buffer
+ with-current-buffer combine-after-change-calls with-output-to-string
+ with-temp-file with-temp-buffer with-temp-message with-syntax-table let
+ let* while if read-if catch condition-case unwind-protect
+ with-output-to-temp-buffer eval-after-load dolist dotimes when unless
+ }).inject({}) { |memo, str| memo[str] = nil; memo }
+
+ DEFINES = WordList.new.
+ add(GEN_DEFINES, :function).
+ add(TYPE_DEFINES, :class).
+ add(VAR_DEFINES, :variable)
+
+ def scan_tokens(tokens, options)
+ defined = false
+ until eos?
+ kind = nil
+ match = nil
+
+ if scan(/\s+/m)
+ kind = :space
+ else
+ if scan(/[\(\)\[\]]/)
+ kind = :delimiter
+ elsif scan(/'+#{SYMBOL_RE}/)
+ kind = :symbol
+ elsif scan(/\&#{SYMBOL_RE}/)
+ kind = :reserved
+ elsif scan(/:#{SYMBOL_RE}/)
+ kind = :constant
+ elsif scan(/\?#{SYMBOL_RE}/)
+ kind = :char
+ elsif match = scan(/"(\\"|[^"])+"/m)
+ tokens << [:open, :string] << ['"', :delimiter] <<
+ [match[1...-1], :content] << ['"', :delimiter] << [:close, :string]
+ next
+ elsif scan(/[\-+]?[0-9]*\.[0-9]+#{EXPONENT_RE}/)
+ kind = :float
+ elsif scan(/[\-+]?[0-9]+#{EXPONENT_RE}/)
+ kind = :integer
+ elsif scan(/;.*$/)
+ kind = :comment
+ elsif scan(SYMBOL_RE)
+ kind = :plain
+
+ if defined
+ kind = defined
+ else
+ sym = matched
+ if KEYWORDS.include? sym
+ kind = :reserved
+ defined = DEFINES[sym]
+ end
+ end
+ end
+ end
+
+ match ||= matched
+ raise_inspect 'Empty token', tokens unless match
+
+ defined = [:reserved, :comment, :space].include?(kind) && defined
+
+ tokens << [match, kind]
+ end
+
+ tokens
+ end
+ end
+end \ No newline at end of file
diff --git a/etc/todo/scanners/paste-333 (DIFF).rb b/etc/todo/scanners/paste-333 (DIFF).rb
new file mode 100644
index 0000000..e6e1dff
--- /dev/null
+++ b/etc/todo/scanners/paste-333 (DIFF).rb
@@ -0,0 +1,88 @@
+## diff.rb
+
+module CodeRay module Scanners
+
+ class Diff < Scanner
+
+ register_for :diff
+
+ def scan_tokens tokens, options
+
+ until eos?
+
+ kind = :space
+ match = nil
+
+ # remove newlines
+ if scan(/\n/)
+ kind = :space
+ elsif scan(/^[+-]{3} .*$/)
+ kind = :diffhead
+ elsif scan(/^[+].*$/)
+ kind = :add
+ elsif scan(/^[-].*$/)
+ kind = :delete
+ elsif scan(/^[^ ].*$/)
+ kind = :diffhead
+ elsif scan(/^ .*$/)
+ kind = :space
+ else
+ getch
+ end
+
+ match ||= matched
+ raise [match, kind], tokens if kind == :error
+
+ tokens << [match, kind]
+
+ end
+
+ tokens
+ end
+
+ end
+
+end end
+
+## styles (cycnus) [plain]
+
+.add { color:green; background:#dfd; }
+.delete { color:red; background:#fdd; }
+.diffhead { color:#999; background: #e7e7ff; }
+
+## tokens (encoder/html/classes.rb)
+
+ ClassOfKind = {
+ :add => "add",
+ :delete => "delete",
+ :diffhead => "diffhead",
+
+## example diff [diff]
+Index: /Users/jgoebel/rails/pastie/app/controllers/pastes_controller.rb
+===================================================================
+--- /Users/jgoebel/rails/pastie/app/controllers/pastes_controller.rb (revision 1431)
++++ /Users/jgoebel/rails/pastie/app/controllers/pastes_controller.rb (revision 1437)
+@@ -1,6 +1,10 @@
++require 'login_system'
+ require 'coderay'
+
+ class PastesController < ApplicationController
++ include LoginSystem
++
++ before_filter :attempt_cookie_login
+
+ # caches_action :recent
+
+@@ -10,11 +14,7 @@
+
+ def show
+ @paste = Paste.find(params[:id])
+- if params[:key] and params[:key]==User.new(@paste.nick).magic_mojo
+- session[:login]=@paste.nick
+- return redirect_to(:action => 'show', :id => @paste.id)
+- end
+-
++ attempt_key_login if not logged_in?
+ unless @paste.asset or not @paste.body.blank?
+ render :action => "edit"
+ end \ No newline at end of file
diff --git a/etc/todo/scanners/paste-693 (IO).rb b/etc/todo/scanners/paste-693 (IO).rb
new file mode 100644
index 0000000..664d893
--- /dev/null
+++ b/etc/todo/scanners/paste-693 (IO).rb
@@ -0,0 +1,134 @@
+module CodeRay module Scanners
+
+ #A simple scanner for a simple language: Io
+
+ class Io < Scanner
+
+ register_for :io
+
+ RESERVED_WORDS = [ 'clone','init', 'method', 'list', 'vector', 'block', 'if','ifTrue','ifFalse','ifTrueIfFalse','then', 'for','loop',
+ 'reverseForeach','foreach','map','continue','break','while','do','return',
+ 'self','sender','target','proto','parent','protos']
+
+ PREDEFINED_TYPES = []
+
+ PREDEFINED_CONSTANTS = ['Object', 'Lobby',
+ 'TRUE','true','FALSE','false','NULL','null','Null','Nil','nil','YES','NO']
+
+ IDENT_KIND = WordList.new(:ident).
+ add(RESERVED_WORDS, :reserved).
+ add(PREDEFINED_TYPES, :pre_type).
+ add(PREDEFINED_CONSTANTS, :pre_constant)
+
+ ESCAPE = / [rbfnrtv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x
+ UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x
+
+ def scan_tokens tokens, options
+
+ state = :initial
+
+ until eos?
+
+ kind = :error
+ match = nil
+
+ if state == :initial
+
+ if scan(/ \s+ | \\\n /x)
+ kind = :space
+
+ elsif scan(%r! // [^\n\\]* (?: \\. [^\n\\]* )* | /\* (?: .*? \*/ | .* ) !mx)
+ kind = :comment
+
+
+ elsif scan(/ [-+*\/\$\@=<>?:;,!&^|()\[\]{}~%]+ | \.(?!\d) /x)
+ kind = :operator
+
+ elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x)
+ kind = IDENT_KIND[match]
+ if kind == :ident and check(/:(?!:)/)
+ match << scan(/:/)
+ kind = :label
+ end
+
+ elsif match = scan(/L?"/)
+ tokens << [:open, :string]
+ if match[0] == ?L
+ tokens << ['L', :modifier]
+ match = '"'
+ end
+ state = :string
+ kind = :delimiter
+
+ elsif scan(/#\s*(\w*)/)
+ kind = :preprocessor # FIXME multiline preprocs
+ state = :include_expected if self[1] == 'include'
+
+ elsif scan(/ L?' (?: [^\'\n\\] | \\ #{ESCAPE} )? '? /ox)
+ kind = :char
+
+ elsif scan(/0[xX][0-9A-Fa-f]+/)
+ kind = :hex
+
+ elsif scan(/(?:0[0-7]+)(?![89.eEfF])/)
+ kind = :oct
+
+ elsif scan(/(?:\d+)(?![.eEfF])/)
+ kind = :integer
+
+ elsif scan(/\d[fF]?|\d*\.\d+(?:[eE][+-]?\d+)?[fF]?|\d+[eE][+-]?\d+[fF]?/)
+ kind = :float
+
+ else
+ getch
+ end
+
+ elsif state == :string
+ if scan(/[^\\"]+/)
+ kind = :content
+ elsif scan(/"/)
+ tokens << ['"', :delimiter]
+ tokens << [:close, :string]
+ state = :initial
+ next
+ elsif scan(/ \\ (?: #{ESCAPE} | #{UNICODE_ESCAPE} ) /mox)
+ kind = :char
+ elsif scan(/ \\ | $ /x)
+ kind = :error
+ state = :initial
+ else
+ raise "else case \" reached; %p not handled." % peek(1), tokens
+ end
+
+ elsif state == :include_expected
+ if scan(/<[^>\n]+>?|"[^"\n\\]*(?:\\.[^"\n\\]*)*"?/)
+ kind = :include
+ state = :initial
+
+ elsif match = scan(/\s+/)
+ kind = :space
+ state = :initial if match.index ?\n
+
+ else
+ getch
+
+ end
+
+ else
+ raise 'else-case reached', tokens
+
+ end
+
+ match ||= matched
+ raise [match, kind], tokens if kind == :error
+
+ tokens << [match, kind]
+
+ end
+
+ tokens
+ end
+
+ end
+
+end end \ No newline at end of file
diff --git a/etc/todo/scanners/php.rb b/etc/todo/scanners/php.rb
new file mode 100644
index 0000000..239fbf8
--- /dev/null
+++ b/etc/todo/scanners/php.rb
@@ -0,0 +1,282 @@
+class Regexp
+ def |(other)
+ Regexp.union(self, other)
+ end
+ def +(other)
+ /#{self}#{other}/
+ end
+end
+module CodeRay
+module Scanners
+
+ load :html
+
+ class PHP < Scanner
+
+ register_for :php
+
+ def setup
+ @html_scanner = CodeRay.scanner :html, :tokens => @tokens, :keep_tokens => true, :keep_state => true
+ end
+
+ def reset_instance
+ super
+ @html_scanner.reset
+ end
+
+ module Words
+ ControlKeywords = %w!
+ if else elseif while do for switch case default declare foreach as
+ endif endwhile endfor endforeach endswitch enddeclare return break
+ continue exit die try catch throw
+ !
+ OtherKeywords = %w!
+ function class extends implements instanceof parent self var const
+ private public protected static abstract final global new echo include
+ require include_once require_once eval print use unset isset empty
+ interface list array clone null true false
+ !
+
+ SpecialConstants = %w! __LINE__ __FILE__ __CLASS__
+ __METHOD__ __FUNCTION__
+ !
+ IdentKinds = WordList.new(:ident).
+ add(ControlKeywords, :reserved).
+ add(OtherKeywords, :pre_type).
+ add(SpecialConstants, :pre_constant)
+ end
+ module RE
+ def self.build_alternatives(array)
+ Regexp.new(array.map { |s| Regexp.escape(s) }.join('|') , Regexp::IGNORECASE)
+ end
+
+ PHPStart = /
+ <script language="php"> |
+ <script language='php'> |
+ <\?php |
+ <\?(?!xml) |
+ <%
+ /xi
+
+ PHPEnd = %r!
+ </script> |
+ \?> |
+ %>
+ !xi
+
+ IChar = /[a-z0-9_\x80-\xFF]/i
+ IStart = /[a-z_\x80-\xFF]/i
+ Identifier = /#{IStart}#{IChar}*/
+ Variable = /\$#{Identifier}/
+
+ Typecasts = build_alternatives %w!
+ float double real int integer bool boolean string array object null
+ !.map{|s| "(#{s})"}
+ OneLineComment1 = %r!//.*?(?=#{PHPEnd}|$)!
+ OneLineComment2 = %r!#.*?(?=#{PHPEnd}|$)!
+ OneLineComment = OneLineComment1 | OneLineComment2
+
+ HereDoc = /<<</ + Identifier
+
+ binops = %w!
+ + - * / << >> & | ^ . %
+ !
+
+ ComparisionOperator = build_alternatives %w$
+ === !== == != <= >=
+ $
+ IncDecOperator = build_alternatives %w! ++ -- !
+
+ BinaryOperator = build_alternatives binops
+ AssignOperator = build_alternatives binops.map {|s| "${s}=" }
+ LogicalOperator = build_alternatives %w! and or xor not !
+ ObjectOperator = build_alternatives %w! -> :: !
+ OtherOperator = build_alternatives %w$ => = ? : [ ] ( ) ; , ~ ! @ > <$
+
+ Operator = ComparisionOperator | IncDecOperator | LogicalOperator |
+ ObjectOperator | AssignOperator | BinaryOperator | OtherOperator
+
+
+ S = /\s+/
+
+ Integer = /-?0x[0-9a-fA-F]/ | /-?\d+/
+ Float = /-?(?:\d+\.\d*|\d*\.\d+)(?:e[+-]\d+)?/
+
+ end
+
+
+
+ def scan_tokens tokens, options
+ states = [:php, :html]
+ heredocdelim = nil
+
+ until eos?
+ match = nil
+ kind = nil
+ case states.last
+ when :html
+ if scan RE::PHPStart
+ kind = :delimiter
+ states.pop
+ else
+ match = scan_until(/(?=#{RE::PHPStart})/o) || scan_until(/\z/)
+ @html_scanner.tokenize match if not match.empty?
+ kind = :space
+ match = ''
+ end
+
+ when :php
+ if scan RE::PHPEnd
+ kind = :delimiter
+ states.push :html
+
+ elsif scan RE::S
+ kind = :space
+
+ elsif scan /\/\*/
+ kind = :comment
+ states.push :mlcomment
+
+ elsif scan RE::OneLineComment
+ kind = :comment
+
+ elsif match = scan(RE::Identifier)
+ kind = Words::IdentKinds[match]
+ if kind == :ident and check(/:(?!:)/) and tokens[-2][0] == 'case'
+# match << scan(/:/)
+ kind = :label
+ elsif kind == :ident and match =~ /^[A-Z]/
+ kind = :constant
+ end
+
+ elsif scan RE::Integer
+ kind = :integer
+
+ elsif scan RE::Float
+ kind = :float
+
+ elsif scan /'/
+ kind = :delimiter
+ states.push :sqstring
+
+ elsif scan /"/
+ kind = :delimiter
+ states.push :dqstring
+
+ elsif match = scan(RE::HereDoc)
+ heredocdelim = match[RE::Identifier]
+ kind = :delimiter
+ states.push = :heredocstring
+
+ elsif scan RE::Variable
+ kind = :local_variable
+
+ elsif scan /\{/
+ kind = :operator
+ states.push :php
+
+ elsif scan /\}/
+ if states.length == 1
+ kind = :error
+ else
+ kind = :operator
+ states.pop
+ end
+
+ elsif scan RE::Operator
+ kind = :operator
+
+ else
+ getch
+ kind = :error
+
+ end
+
+ when :mlcomment
+ if scan /(?:[^\n\r\f*]|\*(?!\/))+/
+ kind = :comment
+
+ elsif scan /\*\//
+ kind = :comment
+ states.pop
+
+ elsif scan /[\r\n\f]+/
+ kind = :space
+ end
+
+ when :sqstring
+ if scan /[^\r\n\f'\\]+/
+ kind = :string
+ elsif match = scan(/\\\\|\\'/)
+ kind = :char
+ elsif scan /\\/
+ kind = :string
+ elsif scan /[\r\n\f ]+/
+ kind = :space
+ elsif scan /'/
+ kind = :delimiter
+ states.pop
+ end
+
+ when :dqstring
+#todo: $foo[bar] kind of stuff
+ if scan /[^\r\n\f"${\\]+/
+ kind = :string
+ elsif scan /\\x[a-fA-F]{2}/
+ kind = :char
+ elsif scan /\\\d{3}/
+ kind = :char
+ elsif scan /\\["\\abcfnrtyv]/
+ kind = :char
+ elsif scan /\\/
+ kind = :string
+ elsif scan /[\r\n\f]+/
+ kind = :space
+ elsif match = scan(RE::Variable)
+ kind = :local_variable
+ if check(/\[#{RE::Identifier}\]/)
+ match << scan(/\[#{RE::Identifier}\]/)
+ elsif check(/\[/)
+ match << scan(/\[#{RE::Identifier}?/)
+ kind = :error
+ elsif check(/->#{RE::Identifier}/)
+ match << scan(/->#{RE::Identifier}/)
+ end
+ elsif scan /\{/
+ if check(/\$/)
+ kind = :operator
+ states.push :php
+ else
+ kind = :string
+ end
+ match = '{'
+ elsif scan /\$\{#{RE::Identifier}\}/
+ kind = :local_variable
+ elsif scan /\$/
+ kind = :string
+ elsif scan /"/
+ kind = :delimiter
+ states.pop
+ end
+ else
+ raise "Unknown state!"
+ end
+
+ match ||= matched
+ if $DEBUG and not kind
+ raise_inspect 'Error token %p in line %d' %
+ [[match, kind], line], tokens
+ end
+ raise_inspect 'Empty token', tokens unless match
+
+ tokens << [match, kind]
+
+ end
+ tokens
+
+ end
+
+ end
+
+end
+end
diff --git a/etc/todo/scanners/sql.rb b/etc/todo/scanners/sql.rb
new file mode 100644
index 0000000..57b5e8c
--- /dev/null
+++ b/etc/todo/scanners/sql.rb
@@ -0,0 +1,138 @@
+# by Josh Goebel
+module CodeRay module Scanners
+
+ class SQL < Scanner
+
+ register_for :sql
+
+ RESERVED_WORDS = [
+ 'create','table','index','trigger','drop',
+ 'primary','key',
+ 'select','insert','update','vacuum','delete','merge','replace','truncate',
+ 'into','on','from','values',
+ 'after','before',
+ 'and','or',
+ 'count','min','max','group','order','by','avg',
+ 'where','join','inner','outer','unique','union',
+ 'transaction',
+ 'begin','end',
+ ]
+
+ PREDEFINED_TYPES = [
+ 'char','varchar','enum','set','binary',
+ 'text','tinytext','mediumtext','longtext',
+ 'blob','tinyblob','mediumblob','longblob',
+ 'timestamp','date','time','datetime','year',
+ 'double','decimal','float',
+ 'int','integer','tinyint','mediumint','bigint',
+ 'bit','bool','boolean'
+ ]
+
+ PREDEFINED_CONSTANTS = [
+ 'null', 'true', 'false', 'not'
+ ]
+
+ SQL_KIND= CaseIgnoringWordList.new(:ident).
+ add(RESERVED_WORDS, :reserved).
+ add(PREDEFINED_TYPES, :pre_type).
+ add(PREDEFINED_CONSTANTS, :pre_constant)
+
+ IDENT_KIND = WordList.new(:ident)
+
+ ESCAPE = / [rbfnrtv\n\\\/'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x
+ UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x
+
+ def scan_tokens tokens, options
+
+ state = :initial
+ string_type = nil
+
+ until eos?
+
+ kind = :error
+ match = nil
+
+ if state == :initial
+
+ if scan(/ ^ -- .* $ /x)
+ kind = :comment
+ elsif scan(/ \s+ | \\\n /x)
+ kind = :space
+
+ elsif scan(%r! // [^\n\\]* (?: \\. [^\n\\]* )* | /\* (?: .*? \*/ | .* ) !mx)
+ kind = :comment
+
+ elsif match = scan(/ \# \s* if \s* 0 /x)
+ match << scan_until(/ ^\# (?:elif|else|endif) .*? $ | \z /xm) unless eos?
+ kind = :comment
+
+ elsif scan(/ [-+*\/=<>?:;,!&^|()\[\]{}~%] | \.(?!\d) /x)
+ kind = :operator
+
+ elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x)
+ kind = SQL_KIND[match.downcase]
+ kind = IDENT_KIND[match] if kind.nil?
+
+ elsif match = scan(/[`"']/)
+ tokens << [:open, :string]
+ string_type = matched
+ state = :string
+ kind = :delimiter
+
+ elsif scan(/0[xX][0-9A-Fa-f]+/)
+ kind = :hex
+
+ elsif scan(/(?:0[0-7]+)(?![89.eEfF])/)
+ kind = :oct
+
+ elsif scan(/(?:\d+)(?![.eEfF])/)
+ kind = :integer
+
+ elsif scan(/\d[fF]?|\d*\.\d+(?:[eE][+-]?\d+)?[fF]?|\d+[eE][+-]?\d+[fF]?/)
+ kind = :float
+
+ else
+ getch
+ end
+
+ elsif state == :string
+ if scan(/[^\\"'`]+/)
+ kind = :content
+ elsif scan(/["'`]/)
+ if string_type==matched
+ tokens << [matched, :delimiter]
+ tokens << [:close, :string]
+ state = :initial
+ string_type=nil
+ next
+ else
+ kind = :content
+ end
+ elsif scan(/ \\ (?: #{ESCAPE} | #{UNICODE_ESCAPE} ) /mox)
+ kind = :content
+ elsif scan(/ \\ | $ /x)
+ kind = :error
+ state = :initial
+ else
+ raise "else case \" reached; %p not handled." % peek(1), tokens
+ end
+
+ else
+ raise 'else-case reached', tokens
+
+ end
+
+ match ||= matched
+# raise [match, kind], tokens if kind == :error
+
+ tokens << [match, kind]
+
+ end
+# RAILS_DEFAULT_LOGGER.info tokens.inspect
+ tokens
+
+ end
+
+ end
+
+end end \ No newline at end of file
diff --git a/etc/todo/scanners/vhdl.rb b/etc/todo/scanners/vhdl.rb
new file mode 100644
index 0000000..0086001
--- /dev/null
+++ b/etc/todo/scanners/vhdl.rb
@@ -0,0 +1,132 @@
+module CodeRay
+module Scanners
+
+ class VHDL < Scanner
+
+ register_for :vhdl
+
+ RESERVED_WORDS = [
+ 'access','after','alias','all','assert','architecture','begin',
+ 'block','body','buffer','bus','case','component','configuration','constant',
+ 'disconnect','downto','else','elsif','end','entity','exit','file','for',
+ 'function','generate','generic','group','guarded','if','impure','in',
+ 'inertial','inout','is','label','library','linkage','literal','loop',
+ 'map','new','next','null','of','on','open','others','out','package',
+ 'port','postponed','procedure','process','pure','range','record','register',
+ 'reject','report','return','select','severity','signal','shared','subtype',
+ 'then','to','transport','type','unaffected','units','until','use','variable',
+ 'wait','when','while','with','note','warning','error','failure','and',
+ 'or','xor','not','nor',
+ 'array'
+ ]
+
+ PREDEFINED_TYPES = [
+ 'bit','bit_vector','character','boolean','integer','real','time','string',
+ 'severity_level','positive','natural','signed','unsigned','line','text',
+ 'std_logic','std_logic_vector','std_ulogic','std_ulogic_vector','qsim_state',
+ 'qsim_state_vector','qsim_12state','qsim_12state_vector','qsim_strength',
+ 'mux_bit','mux_vector','reg_bit','reg_vector','wor_bit','wor_vector'
+ ]
+
+ PREDEFINED_CONSTANTS = [
+
+ ]
+
+ IDENT_KIND = CaseIgnoringWordList.new(:ident).
+ add(RESERVED_WORDS, :reserved).
+ add(PREDEFINED_TYPES, :pre_type).
+ add(PREDEFINED_CONSTANTS, :pre_constant)
+
+ ESCAPE = / [rbfnrtv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x
+ UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x
+
+ def scan_tokens tokens, options
+
+ state = :initial
+
+ until eos?
+
+ kind = nil
+ match = nil
+
+ case state
+
+ when :initial
+
+ if scan(/ \s+ | \\\n /x)
+ kind = :space
+
+ elsif scan(/-- .*/x)
+ kind = :comment
+
+ elsif scan(/ [-+*\/=<>?:;,!&^|()\[\]{}~%]+ | \.(?!\d) /x)
+ kind = :operator
+
+ elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x)
+ kind = IDENT_KIND[match.downcase]
+
+ elsif match = scan(/[a-z]?"/i)
+ tokens << [:open, :string]
+ state = :string
+ kind = :delimiter
+
+ elsif scan(/ L?' (?: [^\'\n\\] | \\ #{ESCAPE} )? '? /ox)
+ kind = :char
+
+ elsif scan(/(?:\d+)(?![.eEfF])/)
+ kind = :integer
+
+ elsif scan(/\d[fF]?|\d*\.\d+(?:[eE][+-]?\d+)?[fF]?|\d+[eE][+-]?\d+[fF]?/)
+ kind = :float
+
+ else
+ getch
+ kind = :error
+
+ end
+
+ when :string
+ if scan(/[^\\\n"]+/)
+ kind = :content
+ elsif scan(/"/)
+ tokens << ['"', :delimiter]
+ tokens << [:close, :string]
+ state = :initial
+ next
+ elsif scan(/ \\ (?: #{ESCAPE} | #{UNICODE_ESCAPE} ) /mox)
+ kind = :char
+ elsif scan(/ \\ | $ /x)
+ tokens << [:close, :string]
+ kind = :error
+ state = :initial
+ else
+ raise_inspect "else case \" reached; %p not handled." % peek(1), tokens
+ end
+
+ else
+ raise_inspect 'Unknown state', tokens
+
+ end
+
+ match ||= matched
+ if $DEBUG and not kind
+ raise_inspect 'Error token %p in line %d' %
+ [[match, kind], line], tokens
+ end
+ raise_inspect 'Empty token', tokens unless match
+
+ tokens << [match, kind]
+
+ end
+
+ if state == :string
+ tokens << [:close, :string]
+ end
+
+ tokens
+ end
+
+ end
+
+end
+end
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/checkpoints/index.html b/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/checkpoints/index.html
new file mode 100755
index 0000000..a0a36d5
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/checkpoints/index.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/_darcs/checkpoints</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/_darcs/checkpoints</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/_darcs/">Parent Directory</a> -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/index.html b/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/index.html
new file mode 100755
index 0000000..f6a7303
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/index.html
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/_darcs</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/_darcs</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="checkpoints/">checkpoints/</a> 23-Sep-2006 21:34 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="inventories/">inventories/</a> 23-Sep-2006 21:34 -
+<img src="/icons/text.gif" alt="[TXT]" /> <a href="inventory">inventory</a> 28-Sep-2006 00:48 825
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="patches/">patches/</a> 28-Sep-2006 00:48 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="prefs/">prefs/</a> 23-Sep-2006 21:34 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="pristine/">pristine/</a> 23-Sep-2006 21:34 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/index.html@C=D;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/index.html@C=D;O=A
new file mode 100755
index 0000000..df9ef0b
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/index.html@C=D;O=A
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/_darcs</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/_darcs</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=D">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="checkpoints/">checkpoints/</a> 23-Sep-2006 21:34 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="inventories/">inventories/</a> 23-Sep-2006 21:34 -
+<img src="/icons/text.gif" alt="[TXT]" /> <a href="inventory">inventory</a> 28-Sep-2006 00:48 825
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="patches/">patches/</a> 28-Sep-2006 00:48 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="prefs/">prefs/</a> 23-Sep-2006 21:34 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="pristine/">pristine/</a> 23-Sep-2006 21:34 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/index.html@C=M;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/index.html@C=M;O=A
new file mode 100755
index 0000000..533958d
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/index.html@C=M;O=A
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/_darcs</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/_darcs</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=D">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="checkpoints/">checkpoints/</a> 23-Sep-2006 21:34 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="inventories/">inventories/</a> 23-Sep-2006 21:34 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="prefs/">prefs/</a> 23-Sep-2006 21:34 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="pristine/">pristine/</a> 23-Sep-2006 21:34 -
+<img src="/icons/text.gif" alt="[TXT]" /> <a href="inventory">inventory</a> 28-Sep-2006 00:48 825
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="patches/">patches/</a> 28-Sep-2006 00:48 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/index.html@C=N;O=D b/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/index.html@C=N;O=D
new file mode 100755
index 0000000..a175ae6
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/index.html@C=N;O=D
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/_darcs</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/_darcs</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="pristine/">pristine/</a> 23-Sep-2006 21:34 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="prefs/">prefs/</a> 23-Sep-2006 21:34 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="patches/">patches/</a> 28-Sep-2006 00:48 -
+<img src="/icons/text.gif" alt="[TXT]" /> <a href="inventory">inventory</a> 28-Sep-2006 00:48 825
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="inventories/">inventories/</a> 23-Sep-2006 21:34 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="checkpoints/">checkpoints/</a> 23-Sep-2006 21:34 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/index.html@C=S;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/index.html@C=S;O=A
new file mode 100755
index 0000000..0ac3f12
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/index.html@C=S;O=A
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/_darcs</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/_darcs</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=D">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="checkpoints/">checkpoints/</a> 23-Sep-2006 21:34 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="inventories/">inventories/</a> 23-Sep-2006 21:34 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="patches/">patches/</a> 28-Sep-2006 00:48 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="prefs/">prefs/</a> 23-Sep-2006 21:34 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="pristine/">pristine/</a> 23-Sep-2006 21:34 -
+<img src="/icons/text.gif" alt="[TXT]" /> <a href="inventory">inventory</a> 28-Sep-2006 00:48 825
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/inventories/index.html b/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/inventories/index.html
new file mode 100755
index 0000000..f6d1d38
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/inventories/index.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/_darcs/inventories</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/_darcs/inventories</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/_darcs/">Parent Directory</a> -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/inventory b/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/inventory
new file mode 100755
index 0000000..a7a8470
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/inventory
@@ -0,0 +1,17 @@
+[First version
+zoso@foton.es**20060923203447] [Add :wrap option to the LaTeX encoder
+zoso@foton.es**20060924125211]
+[Remove all non-alphanumeric characters from LaTeX commands
+zoso@foton.es**20060924143810]
+[Use \synbs instead of $\backslash$, seems to work better in verbatim
+zoso@foton.es**20060924143837]
+[Add a very basic Javascript scanner (adapted Ruby scanner)
+zoso@foton.es**20060924154208]
+[Improve LaTeX special character escaping
+zoso@foton.es**20060927233750
+ * Rewrite Latex#escape_latex method, so it uses only one pass (avoids some
+ escape-the-already-escaped-characters problems and it's probably faster)
+ * Now backslashes are substituted by "\synbs{}", to avoid problems with letters
+ that could be just after the \synbs, turning it into another, undefined
+ command like "\synbsn" or something
+]
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/patches/index.html b/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/patches/index.html
new file mode 100755
index 0000000..85ec1c7
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/patches/index.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/_darcs/patches</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/_darcs/patches</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/_darcs/">Parent Directory</a> -
+<img src="/icons/compressed.gif" alt="[CMP]" /> <a href="20060923203447-5140e-df04368a13906528ef99e9ab5718624532f05b31.gz">20060923203447-5140e-df04368a13906528ef99e9ab5718624532f05b31.gz</a> 23-Sep-2006 21:34 1.4K
+<img src="/icons/compressed.gif" alt="[CMP]" /> <a href="20060924125211-5140e-ea83d35d45314665af86e1bd2eeda952f953dd43.gz">20060924125211-5140e-ea83d35d45314665af86e1bd2eeda952f953dd43.gz</a> 24-Sep-2006 13:52 702
+<img src="/icons/compressed.gif" alt="[CMP]" /> <a href="20060924143810-5140e-a52edb9676be4736a6042e1607be7939e5ec3f28.gz">20060924143810-5140e-a52edb9676be4736a6042e1607be7939e5ec3f28.gz</a> 24-Sep-2006 15:39 250
+<img src="/icons/compressed.gif" alt="[CMP]" /> <a href="20060924143837-5140e-880669c10c7a8b9e8e601724eccce9fff3917f44.gz">20060924143837-5140e-880669c10c7a8b9e8e601724eccce9fff3917f44.gz</a> 24-Sep-2006 15:39 432
+<img src="/icons/compressed.gif" alt="[CMP]" /> <a href="20060924154208-5140e-8cc8c6fbe46d11ab2493b4206c8cc259c01bb883.gz">20060924154208-5140e-8cc8c6fbe46d11ab2493b4206c8cc259c01bb883.gz</a> 24-Sep-2006 16:58 3.3K
+<img src="/icons/compressed.gif" alt="[CMP]" /> <a href="20060927233750-5140e-589da45a369c268f1acb9fad63e9e3f3c8dd01b8.gz">20060927233750-5140e-589da45a369c268f1acb9fad63e9e3f3c8dd01b8.gz</a> 28-Sep-2006 00:48 795
+<img src="/icons/unknown.gif" alt="[ ]" /> <a href="pending">pending</a> 28-Sep-2006 00:48 4
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/prefs/index.html b/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/prefs/index.html
new file mode 100755
index 0000000..5288084
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/prefs/index.html
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/_darcs/prefs</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/_darcs/prefs</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/_darcs/">Parent Directory</a> -
+<img src="/icons/unknown.gif" alt="[ ]" /> <a href="binaries">binaries</a> 23-Sep-2006 21:34 395
+<img src="/icons/unknown.gif" alt="[ ]" /> <a href="boring">boring</a> 23-Sep-2006 21:34 534
+<img src="/icons/unknown.gif" alt="[ ]" /> <a href="defaultrepo">defaultrepo</a> 23-Sep-2006 21:34 28
+<img src="/icons/text.gif" alt="[TXT]" /> <a href="motd">motd</a> 23-Sep-2006 21:34 0
+<img src="/icons/unknown.gif" alt="[ ]" /> <a href="repos">repos</a> 23-Sep-2006 21:34 28
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/pristine/index.html b/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/pristine/index.html
new file mode 100755
index 0000000..14bd055
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/_darcs/pristine/index.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/_darcs/pristine</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/_darcs/pristine</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/_darcs/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="lib/">lib/</a> 23-Sep-2006 21:34 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="test/">test/</a> 28-Sep-2006 00:48 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/index.html b/etc/todo/www.demiurgo.org/darcs/coderay/index.html
new file mode 100755
index 0000000..d1b3aec
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/index.html
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="_darcs/">_darcs/</a> 28-Sep-2006 00:48 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="lib/">lib/</a> 23-Sep-2006 21:34 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="test/">test/</a> 28-Sep-2006 00:48 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=D;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=D;O=A
new file mode 100755
index 0000000..3cc4074
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=D;O=A
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=D">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="_darcs/">_darcs/</a> 28-Sep-2006 00:48 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="lib/">lib/</a> 23-Sep-2006 21:34 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="test/">test/</a> 28-Sep-2006 00:48 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=D;O=D b/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=D;O=D
new file mode 100755
index 0000000..8f9e380
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=D;O=D
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="test/">test/</a> 28-Sep-2006 00:48 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="lib/">lib/</a> 23-Sep-2006 21:34 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="_darcs/">_darcs/</a> 28-Sep-2006 00:48 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=M;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=M;O=A
new file mode 100755
index 0000000..9606f9a
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=M;O=A
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=D">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="lib/">lib/</a> 23-Sep-2006 21:34 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="_darcs/">_darcs/</a> 28-Sep-2006 00:48 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="test/">test/</a> 28-Sep-2006 00:48 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=M;O=D b/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=M;O=D
new file mode 100755
index 0000000..00a778c
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=M;O=D
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="test/">test/</a> 28-Sep-2006 00:48 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="_darcs/">_darcs/</a> 28-Sep-2006 00:48 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="lib/">lib/</a> 23-Sep-2006 21:34 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=N;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=N;O=A
new file mode 100755
index 0000000..d1b3aec
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=N;O=A
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="_darcs/">_darcs/</a> 28-Sep-2006 00:48 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="lib/">lib/</a> 23-Sep-2006 21:34 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="test/">test/</a> 28-Sep-2006 00:48 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=N;O=D b/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=N;O=D
new file mode 100755
index 0000000..8f9e380
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=N;O=D
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="test/">test/</a> 28-Sep-2006 00:48 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="lib/">lib/</a> 23-Sep-2006 21:34 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="_darcs/">_darcs/</a> 28-Sep-2006 00:48 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=S;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=S;O=A
new file mode 100755
index 0000000..a191676
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=S;O=A
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=D">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="_darcs/">_darcs/</a> 28-Sep-2006 00:48 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="lib/">lib/</a> 23-Sep-2006 21:34 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="test/">test/</a> 28-Sep-2006 00:48 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=S;O=D b/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=S;O=D
new file mode 100755
index 0000000..8f9e380
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/index.html@C=S;O=D
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="test/">test/</a> 28-Sep-2006 00:48 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="lib/">lib/</a> 23-Sep-2006 21:34 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="_darcs/">_darcs/</a> 28-Sep-2006 00:48 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/index.html b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/index.html
new file mode 100755
index 0000000..7ebac3a
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/index.html
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib/coderay/encoders</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib/coderay/encoders</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/lib/coderay/">Parent Directory</a> -
+<img src="/icons/unknown.gif" alt="[ ]" /> <a href="latex.rb">latex.rb</a> 28-Sep-2006 00:48 1.4K
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/index.html@C=D;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/index.html@C=D;O=A
new file mode 100755
index 0000000..7c7a8c4
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/index.html@C=D;O=A
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib/coderay/encoders</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib/coderay/encoders</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=D">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/lib/coderay/">Parent Directory</a> -
+<img src="/icons/unknown.gif" alt="[ ]" /> <a href="latex.rb">latex.rb</a> 28-Sep-2006 00:48 1.4K
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/index.html@C=M;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/index.html@C=M;O=A
new file mode 100755
index 0000000..9d9cd59
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/index.html@C=M;O=A
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib/coderay/encoders</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib/coderay/encoders</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=D">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/lib/coderay/">Parent Directory</a> -
+<img src="/icons/unknown.gif" alt="[ ]" /> <a href="latex.rb">latex.rb</a> 28-Sep-2006 00:48 1.4K
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/index.html@C=N;O=D b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/index.html@C=N;O=D
new file mode 100755
index 0000000..339f519
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/index.html@C=N;O=D
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib/coderay/encoders</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib/coderay/encoders</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/lib/coderay/">Parent Directory</a> -
+<img src="/icons/unknown.gif" alt="[ ]" /> <a href="latex.rb">latex.rb</a> 28-Sep-2006 00:48 1.4K
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/index.html@C=S;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/index.html@C=S;O=A
new file mode 100755
index 0000000..0d5687f
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/index.html@C=S;O=A
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib/coderay/encoders</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib/coderay/encoders</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=D">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/lib/coderay/">Parent Directory</a> -
+<img src="/icons/unknown.gif" alt="[ ]" /> <a href="latex.rb">latex.rb</a> 28-Sep-2006 00:48 1.4K
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/latex.rb b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/latex.rb
new file mode 100755
index 0000000..0a54872
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/encoders/latex.rb
@@ -0,0 +1,79 @@
+module CodeRay
+module Encoders
+
+ # = LaTeX Encoder
+ #
+ # Encoder producing LaTeX.
+ class Latex < Encoder
+
+ include Streamable
+ register_for :latex
+
+ FILE_EXTENSION = 'tex'
+
+ DEFAULT_OPTIONS = {
+ :wrap => true,
+ }
+
+ protected
+ def text_token text, kind
+ @out <<
+ if kind == :space
+ text
+ else
+ text = escape_latex(text)
+ "\\syn#{kind_to_command(kind)}{#{text}}"
+ end
+ end
+
+ def block_token action, kind
+ @out << super
+ end
+
+ def open_token kind
+ "\\syn#{kind_to_command(kind)}{"
+ end
+
+ def close_token kind
+ "}"
+ end
+
+ def kind_to_command kind
+ kind.to_s.gsub(/[^a-z0-9]/i, '').to_sym
+ end
+
+ def finish options
+ case options[:wrap]
+ when true, 1, :semiverbatim
+ @out = "\\begin{semiverbatim}\n#{@out}\n\\end{semiverbatim}\n"
+ when false, 0
+ # Nothing to do
+ else
+ raise ArgumentError, "Unknown :wrap option: '#{options[:wrap]}'"
+ end
+
+ super
+ end
+
+ # Escape text so it's interpreted literally by LaTeX compilers
+ def escape_latex string
+ string.to_s.gsub(/[$\\{}_%#&~^"]/) do |s|
+ case s
+ when '$'
+ '\$'
+ when '\\'
+ '\synbs{}'
+ when /[{}_%#&]/
+ "\\#{s}"
+ when /[~^]/
+ "\\#{s}{}"
+ when '"'
+ '"{}'
+ end
+ end
+ end
+
+ end
+
+end
+end
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html
new file mode 100755
index 0000000..a23f094
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib/coderay</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib/coderay</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/lib/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="encoders/">encoders/</a> 28-Sep-2006 00:48 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="scanners/">scanners/</a> 24-Sep-2006 16:58 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=D;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=D;O=A
new file mode 100755
index 0000000..9c255dc
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=D;O=A
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib/coderay</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib/coderay</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=D">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/lib/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="encoders/">encoders/</a> 28-Sep-2006 00:48 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="scanners/">scanners/</a> 24-Sep-2006 16:58 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=D;O=D b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=D;O=D
new file mode 100755
index 0000000..79e6552
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=D;O=D
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib/coderay</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib/coderay</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/lib/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="scanners/">scanners/</a> 24-Sep-2006 16:58 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="encoders/">encoders/</a> 28-Sep-2006 00:48 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=M;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=M;O=A
new file mode 100755
index 0000000..36ef38c
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=M;O=A
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib/coderay</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib/coderay</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=D">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/lib/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="scanners/">scanners/</a> 24-Sep-2006 16:58 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="encoders/">encoders/</a> 28-Sep-2006 00:48 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=M;O=D b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=M;O=D
new file mode 100755
index 0000000..55e3bee
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=M;O=D
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib/coderay</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib/coderay</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/lib/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="encoders/">encoders/</a> 28-Sep-2006 00:48 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="scanners/">scanners/</a> 24-Sep-2006 16:58 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=N;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=N;O=A
new file mode 100755
index 0000000..a23f094
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=N;O=A
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib/coderay</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib/coderay</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/lib/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="encoders/">encoders/</a> 28-Sep-2006 00:48 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="scanners/">scanners/</a> 24-Sep-2006 16:58 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=N;O=D b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=N;O=D
new file mode 100755
index 0000000..79e6552
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=N;O=D
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib/coderay</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib/coderay</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/lib/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="scanners/">scanners/</a> 24-Sep-2006 16:58 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="encoders/">encoders/</a> 28-Sep-2006 00:48 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=S;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=S;O=A
new file mode 100755
index 0000000..00c2252
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=S;O=A
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib/coderay</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib/coderay</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=D">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/lib/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="encoders/">encoders/</a> 28-Sep-2006 00:48 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="scanners/">scanners/</a> 24-Sep-2006 16:58 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=S;O=D b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=S;O=D
new file mode 100755
index 0000000..79e6552
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/index.html@C=S;O=D
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib/coderay</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib/coderay</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/lib/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="scanners/">scanners/</a> 24-Sep-2006 16:58 -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="encoders/">encoders/</a> 28-Sep-2006 00:48 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/index.html b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/index.html
new file mode 100755
index 0000000..a35fdd7
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/index.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib/coderay/scanners</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib/coderay/scanners</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/lib/coderay/">Parent Directory</a> -
+<img src="/icons/unknown.gif" alt="[ ]" /> <a href="javascript.rb">javascript.rb</a> 24-Sep-2006 16:58 5.5K
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="javascript/">javascript/</a> 24-Sep-2006 16:58 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/index.html@C=D;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/index.html@C=D;O=A
new file mode 100755
index 0000000..9b896d4
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/index.html@C=D;O=A
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib/coderay/scanners</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib/coderay/scanners</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=D">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/lib/coderay/">Parent Directory</a> -
+<img src="/icons/unknown.gif" alt="[ ]" /> <a href="javascript.rb">javascript.rb</a> 24-Sep-2006 16:58 5.5K
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="javascript/">javascript/</a> 24-Sep-2006 16:58 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/index.html@C=M;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/index.html@C=M;O=A
new file mode 100755
index 0000000..6860db0
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/index.html@C=M;O=A
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib/coderay/scanners</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib/coderay/scanners</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=D">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/lib/coderay/">Parent Directory</a> -
+<img src="/icons/unknown.gif" alt="[ ]" /> <a href="javascript.rb">javascript.rb</a> 24-Sep-2006 16:58 5.5K
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="javascript/">javascript/</a> 24-Sep-2006 16:58 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/index.html@C=N;O=D b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/index.html@C=N;O=D
new file mode 100755
index 0000000..e34a9bd
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/index.html@C=N;O=D
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib/coderay/scanners</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib/coderay/scanners</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/lib/coderay/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="javascript/">javascript/</a> 24-Sep-2006 16:58 -
+<img src="/icons/unknown.gif" alt="[ ]" /> <a href="javascript.rb">javascript.rb</a> 24-Sep-2006 16:58 5.5K
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/index.html@C=S;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/index.html@C=S;O=A
new file mode 100755
index 0000000..a92141d
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/index.html@C=S;O=A
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib/coderay/scanners</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib/coderay/scanners</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=D">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/lib/coderay/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="javascript/">javascript/</a> 24-Sep-2006 16:58 -
+<img src="/icons/unknown.gif" alt="[ ]" /> <a href="javascript.rb">javascript.rb</a> 24-Sep-2006 16:58 5.5K
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/javascript.rb b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/javascript.rb
new file mode 100755
index 0000000..da67084
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/javascript.rb
@@ -0,0 +1,199 @@
+module CodeRay
+module Scanners
+
+ # Basic Javascript scanner
+ class Javascript < Scanner
+
+ include Streamable
+
+ register_for :javascript
+
+ helper :patterns
+
+ DEFAULT_OPTIONS = {
+ }
+
+ private
+ def scan_tokens tokens, options
+ first_bake = saved_tokens = nil
+ last_token_dot = false
+ last_state = nil
+ state = :initial
+ depth = nil
+ inline_block_stack = []
+
+ patterns = Patterns # avoid constant lookup
+
+ until eos?
+ match = nil
+ kind = nil
+
+ if state.instance_of? patterns::StringState
+# {{{
+ match = scan_until(state.pattern) || scan_until(/\z/)
+ tokens << [match, :content] unless match.empty?
+ break if eos?
+
+ case match = getch
+
+ when state.delim
+ if state.paren
+ state.paren_depth -= 1
+ if state.paren_depth > 0
+ tokens << [match, :nesting_delimiter]
+ next
+ end
+ end
+ tokens << [match, :delimiter]
+ tokens << [:close, state.type]
+ state = state.next_state
+
+ when '\\'
+ if state.interpreted
+ if esc = scan(/ #{patterns::ESCAPE} /ox)
+ tokens << [match + esc, :char]
+ else
+ tokens << [match, :error]
+ end
+ else
+ case m = getch
+ when state.delim, '\\'
+ tokens << [match + m, :char]
+ when nil
+ tokens << [match, :error]
+ else
+ tokens << [match + m, :content]
+ end
+ end
+
+ when '#'
+ case peek(1)[0]
+ when ?{
+ inline_block_stack << [state, depth]
+ state = :initial
+ depth = 1
+ tokens << [:open, :inline]
+ tokens << [match + getch, :delimiter]
+ when ?$, ?@
+ tokens << [match, :escape]
+ last_state = state # scan one token as normal code, then return here
+ state = :initial
+ else
+ raise_inspect 'else-case # reached; #%p not handled' % peek(1), tokens
+ end
+
+ when state.paren
+ state.paren_depth += 1
+ tokens << [match, :nesting_delimiter]
+
+ else
+ raise_inspect 'else-case " reached; %p not handled, state = %p' % [match, state], tokens
+
+ end
+ next
+# }}}
+ else
+# {{{
+ if match = scan(/ [ \t\f]+ | \\? \n | \# .* /x)
+ case m = match[0]
+ when ?\s, ?\t, ?\f
+ match << scan(/\s*/) unless eos?
+ kind = :space
+ when ?\n, ?\\
+ kind = :space
+ match << scan(/\s*/) unless eos?
+ when ?#, ?=, ?_
+ kind = :comment
+ else
+ raise_inspect 'else-case _ reached, because case %p was not handled' % [matched[0].chr], tokens
+ end
+ tokens << [match, kind]
+ next
+
+ elsif state == :initial
+
+ # IDENTS #
+ if match = scan(/#{patterns::METHOD_NAME}/o)
+ kind = last_token_dot ? :ident :
+ patterns::IDENT_KIND[match]
+
+ # OPERATORS #
+ elsif (not last_token_dot and match = scan(/ ==?=? | \.\.?\.? | [\(\)\[\]\{\}] | :: | , /x)) or
+ (last_token_dot and match = scan(/#{patterns::METHOD_NAME_OPERATOR}/o))
+ last_token_dot = :set if match == '.' or match == '::'
+ kind = :operator
+ unless inline_block_stack.empty?
+ case match
+ when '{'
+ depth += 1
+ when '}'
+ depth -= 1
+ if depth == 0 # closing brace of inline block reached
+ state, depth = inline_block_stack.pop
+ tokens << [match, :delimiter]
+ kind = :inline
+ match = :close
+ end
+ end
+ end
+
+ elsif match = scan(/ ['"] /mx)
+ tokens << [:open, :string]
+ kind = :delimiter
+ state = patterns::StringState.new :string, match == '"', match # important for streaming
+
+ elsif match = scan(/#{patterns::NUMERIC}/o)
+ kind = if self[1] then :float else :integer end
+
+ elsif match = scan(/ \+\+ | -- | << | >> /x)
+ kind = :operator
+
+ elsif match = scan(/ [-+!~^]=? | [*|&]{1,2}=? | >>? /x)
+ kind = :operator
+
+ elsif match = scan(/ [\/%]=? | <(?:<|=>?)? | [?:;] /x)
+ kind = :operator
+
+ else
+ kind = :error
+ match = getch
+
+ end
+
+ end
+# }}}
+
+ last_token_dot = last_token_dot == :set
+
+ if $DEBUG and not kind
+ raise_inspect 'Error token %p in line %d' %
+ [[match, kind], line], tokens, state
+ end
+ raise_inspect 'Empty token', tokens unless match
+
+ tokens << [match, kind]
+
+ if last_state
+ state = last_state
+ last_state = nil
+ end
+ end
+ end
+
+ inline_block_stack << [state] if state.is_a? patterns::StringState
+ until inline_block_stack.empty?
+ this_block = inline_block_stack.pop
+ tokens << [:close, :inline] if this_block.size > 1
+ state = this_block.first
+ tokens << [:close, state.type]
+ end
+
+ tokens
+ end
+
+ end
+
+end
+end
+
+# vim:fdm=marker
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/javascript/index.html b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/javascript/index.html
new file mode 100755
index 0000000..9a3769c
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/coderay/scanners/javascript/index.html
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib/coderay/scanners/javascript</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib/coderay/scanners/javascript</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/lib/coderay/scanners/">Parent Directory</a> -
+<img src="/icons/text.gif" alt="[TXT]" /> <a href="patterns.rb">patterns.rb</a> 24-Sep-2006 16:58 2.5K
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html b/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html
new file mode 100755
index 0000000..af2e071
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="coderay/">coderay/</a> 24-Sep-2006 16:58 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=D;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=D;O=A
new file mode 100755
index 0000000..6c8f2f8
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=D;O=A
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=D">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="coderay/">coderay/</a> 24-Sep-2006 16:58 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=D;O=D b/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=D;O=D
new file mode 100755
index 0000000..80551b7
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=D;O=D
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="coderay/">coderay/</a> 24-Sep-2006 16:58 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=M;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=M;O=A
new file mode 100755
index 0000000..27bdbd0
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=M;O=A
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=D">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="coderay/">coderay/</a> 24-Sep-2006 16:58 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=M;O=D b/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=M;O=D
new file mode 100755
index 0000000..80551b7
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=M;O=D
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="coderay/">coderay/</a> 24-Sep-2006 16:58 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=N;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=N;O=A
new file mode 100755
index 0000000..af2e071
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=N;O=A
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="coderay/">coderay/</a> 24-Sep-2006 16:58 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=N;O=D b/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=N;O=D
new file mode 100755
index 0000000..80551b7
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=N;O=D
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="coderay/">coderay/</a> 24-Sep-2006 16:58 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=S;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=S;O=A
new file mode 100755
index 0000000..224354b
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=S;O=A
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=D">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="coderay/">coderay/</a> 24-Sep-2006 16:58 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=S;O=D b/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=S;O=D
new file mode 100755
index 0000000..80551b7
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/lib/index.html@C=S;O=D
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/lib</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/lib</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]" /> <a href="coderay/">coderay/</a> 24-Sep-2006 16:58 -
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/test/index.html b/etc/todo/www.demiurgo.org/darcs/coderay/test/index.html
new file mode 100755
index 0000000..8d79e63
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/test/index.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/test</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/test</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/">Parent Directory</a> -
+<img src="/icons/unknown.gif" alt="[ ]" /> <a href="test_javascript_scanner.rb">test_javascript_scanner.rb</a> 24-Sep-2006 16:58 3.9K
+<img src="/icons/text.gif" alt="[TXT]" /> <a href="test_latex_encoder.rb">test_latex_encoder.rb</a> 28-Sep-2006 00:48 4.0K
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/test/index.html@C=D;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/test/index.html@C=D;O=A
new file mode 100755
index 0000000..d3e4481
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/test/index.html@C=D;O=A
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/test</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/test</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=D">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/">Parent Directory</a> -
+<img src="/icons/unknown.gif" alt="[ ]" /> <a href="test_javascript_scanner.rb">test_javascript_scanner.rb</a> 24-Sep-2006 16:58 3.9K
+<img src="/icons/text.gif" alt="[TXT]" /> <a href="test_latex_encoder.rb">test_latex_encoder.rb</a> 28-Sep-2006 00:48 4.0K
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/test/index.html@C=M;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/test/index.html@C=M;O=A
new file mode 100755
index 0000000..0fa49ac
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/test/index.html@C=M;O=A
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/test</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/test</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=D">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/">Parent Directory</a> -
+<img src="/icons/unknown.gif" alt="[ ]" /> <a href="test_javascript_scanner.rb">test_javascript_scanner.rb</a> 24-Sep-2006 16:58 3.9K
+<img src="/icons/text.gif" alt="[TXT]" /> <a href="test_latex_encoder.rb">test_latex_encoder.rb</a> 28-Sep-2006 00:48 4.0K
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/test/index.html@C=N;O=D b/etc/todo/www.demiurgo.org/darcs/coderay/test/index.html@C=N;O=D
new file mode 100755
index 0000000..81f5381
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/test/index.html@C=N;O=D
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/test</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/test</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/">Parent Directory</a> -
+<img src="/icons/text.gif" alt="[TXT]" /> <a href="test_latex_encoder.rb">test_latex_encoder.rb</a> 28-Sep-2006 00:48 4.0K
+<img src="/icons/unknown.gif" alt="[ ]" /> <a href="test_javascript_scanner.rb">test_javascript_scanner.rb</a> 24-Sep-2006 16:58 3.9K
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/test/index.html@C=S;O=A b/etc/todo/www.demiurgo.org/darcs/coderay/test/index.html@C=S;O=A
new file mode 100755
index 0000000..fd7e1e9
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/test/index.html@C=S;O=A
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /darcs/coderay/test</title>
+ </head>
+ <body>
+<h1>Index of /darcs/coderay/test</h1>
+<pre><img src="/icons/blank.gif" alt="Icon " /> <a href="?C=N;O=A">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=D">Size</a> <a href="?C=D;O=A">Description</a><hr /><img src="/icons/back.gif" alt="[DIR]" /> <a href="/darcs/coderay/">Parent Directory</a> -
+<img src="/icons/unknown.gif" alt="[ ]" /> <a href="test_javascript_scanner.rb">test_javascript_scanner.rb</a> 24-Sep-2006 16:58 3.9K
+<img src="/icons/text.gif" alt="[TXT]" /> <a href="test_latex_encoder.rb">test_latex_encoder.rb</a> 28-Sep-2006 00:48 4.0K
+<hr /></pre>
+<address>Apache/2.0.46 (CentOS) Server at www.demiurgo.org Port 80</address>
+</body></html>
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/test/test_javascript_scanner.rb b/etc/todo/www.demiurgo.org/darcs/coderay/test/test_javascript_scanner.rb
new file mode 100755
index 0000000..e1bfe70
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/test/test_javascript_scanner.rb
@@ -0,0 +1,104 @@
+require 'test/unit'
+require 'coderay'
+
+class TC_Latex_Encoder < Test::Unit::TestCase
+ def setup
+ CodeRay::Encoders.plugin_path 'lib/coderay/encoders'
+ @enc = CodeRay::Encoders[:latex].new
+ end
+
+
+ def test_simple
+ source_text = <<EOD
+function update_stars(num)
+{
+ for (var i = 0; i < 10; ++i) {
+ var star = $("star"+(i+1));
+ if (i < num) {
+ if (! star.visible()) {
+ Effect.Appear(star);
+ }
+ } else {
+ if (star.visible()) {
+ Effect.Fade(star);
+ }
+ }
+ }
+}
+EOD
+ expected = [["function", :reserved],[" ", :space],["update_stars", :ident],
+ ["(", :operator], ["num", :ident], [")", :operator],
+ ["\n", :space],
+ ["{", :operator],
+ ["\n ", :space],
+ ["for", :reserved], [" ", :space],
+ ["(", :operator], ["var", :reserved], [" ", :space],
+ ["i", :ident],[" ", :space], ["=", :operator], [" ", :space],
+ ["0", :integer],
+ [";", :operator],
+ [" ", :space], ["i", :ident], [" ", :space],
+ ["<", :operator], [" ", :space], ["10", :integer],
+ [";", :operator],
+ [" ", :space], ["++", :operator], ["i", :ident],
+ [")", :operator], [" ", :space], ["{", :operator],
+ ["\n ", :space],
+ ["var", :reserved], [" ", :space], ["star", :ident],
+ [" ", :space], ["=", :operator], [" ", :space],
+ ["$", :ident], ["(", :operator],
+ [:open, :string], ["\"", :delimiter], ["star", :content],
+ ["\"", :delimiter], [:close, :string],
+ ["+", :operator],
+ ["(", :operator], ["i", :ident], ["+", :operator],
+ ["1", :integer], [")", :operator],
+ [")", :operator],
+ [";", :operator],
+ ["\n ", :space],
+ ["if", :reserved], [" ", :space],
+ ["(", :operator], ["i", :ident], [" ", :space],
+ ["<", :operator], [" ", :space], ["num", :ident],
+ [")", :operator], [" ", :space], ["{", :operator],
+ ["\n ", :space],
+ ["if", :reserved], [" ", :space],
+ ["(", :operator], ["!", :operator], [" ", :space],
+ ["star", :ident], [".", :operator], ["visible", :ident],
+ ["(", :operator], [")", :operator], [")", :operator],
+ [" ", :space],
+ ["{", :operator],
+ ["\n ", :space],
+ ["Effect", :ident], [".", :operator], ["Appear", :ident],
+ ["(", :operator], ["star", :ident], [")", :operator],
+ [";", :operator], ["\n ", :space],
+ ["}", :operator],
+ ["\n ", :space],
+ ["}", :operator],
+ [" ", :space], ["else", :reserved], [" ", :space],
+ ["{", :operator],
+ ["\n ", :space],
+ ["if", :reserved], [" ", :space],
+ ["(", :operator], ["star", :ident], [".", :operator],
+ ["visible", :ident], ["(", :operator], [")", :operator],
+ [")", :operator],
+ [" ", :space],
+ ["{", :operator],
+ ["\n ", :space],
+ ["Effect", :ident], [".", :operator], ["Fade", :ident],
+ ["(", :operator], ["star", :ident], [")", :operator],
+ [";", :operator],
+ ["\n ", :space],
+ ["}", :operator],
+ ["\n ", :space],
+ ["}", :operator],
+ ["\n ", :space],
+ ["}", :operator],
+ ["\n", :space],
+ ["}", :operator],
+ ["\n", :space]]
+ symbol_list = CodeRay.scan(source_text, :javascript)
+ assert_equal(expected, symbol_list)
+ end
+
+
+ def teardown
+ @enc = nil
+ end
+end
diff --git a/etc/todo/www.demiurgo.org/darcs/coderay/test/test_latex_encoder.rb b/etc/todo/www.demiurgo.org/darcs/coderay/test/test_latex_encoder.rb
new file mode 100755
index 0000000..686aa38
--- /dev/null
+++ b/etc/todo/www.demiurgo.org/darcs/coderay/test/test_latex_encoder.rb
@@ -0,0 +1,103 @@
+require 'test/unit'
+require 'coderay'
+
+class TC_Latex_Encoder < Test::Unit::TestCase
+ def setup
+ CodeRay::Encoders.plugin_path 'lib/coderay/encoders'
+ @enc = CodeRay::Encoders[:latex].new
+ end
+
+
+ def test_escape_latex
+ tests = {"I have $30, and new\\\nline" => "I have \\$30, and new\\synbs{}\nline",
+ 'I like "clean & simple" things just best than {obscure,complicated}' => 'I like "{}clean \& simple"{} things just best than \{obscure,complicated\}',
+ "The string '\\'' is valid... in C" => "The string '\\synbs{}'' is valid... in C",
+ "Escape dollars as \\$, and continue line, backslash at the end, like so: \\\n" => "Escape dollars as \\synbs{}\\$, and continue line, backslash at the end, like so: \\synbs{}\n",
+ "Perl: $foo{some_key} =~ /^#.*$/" => "Perl: \\$foo\\{some\\_key\\} =\\~{} /\\^{}\\#.*\\$/",
+ "Double backslash escaping: \\\\" => "Double backslash escaping: \\synbs{}\\synbs{}",
+ "\"Some\nmultiline\nstring\"" => "\"{}Some\nmultiline\nstring\"{}",
+ "printf(\"Hello, World\\n\");" => "printf(\"{}Hello, World\\synbs{}n\"{});"}
+ tests.each_pair do |k,v|
+ assert_equal(v, @enc.send(:escape_latex, k))
+ end
+ end
+
+
+ def test_simple
+ source_text = <<EOD
+require 'coderay'
+
+# scan some code
+tokens = CodeRay.scan('some_file.rb', :ruby)
+
+# dump using LaTeX
+puts tokens.latex
+EOD
+ expected = [["require", :ident], [" ", :space], [:open, :string],
+ ["'", :delimiter], ["coderay", :content], ["'", :delimiter],
+ [:close, :string], ["\n\n", :space],
+ ["# scan some code", :comment], ["\n", :space],
+ ["tokens", :ident], [" ", :space], ["=", :operator],
+ [" ", :space], ["CodeRay", :constant], [".", :operator],
+ ["scan", :ident], ["(", :operator], [:open, :string],
+ ["'", :delimiter], ["some_file.rb", :content],
+ ["'", :delimiter], [:close, :string], [",", :operator],
+ [" ", :space], [":ruby", :symbol], [")", :operator],
+ ["\n\n", :space], ["# dump using LaTeX", :comment],
+ ["\n", :space], ["puts", :ident], [" ", :space],
+ ["tokens", :ident], [".", :operator], ["latex", :ident],
+ ["\n", :space]]
+ symbol_list = CodeRay.scan(source_text, :ruby)
+ assert_equal(expected, symbol_list)
+
+ expected_latex = <<'EOD'
+\begin{semiverbatim}
+\synident{require} \synstring{\syndelimiter{'}\syncontent{coderay}\syndelimiter{'}}
+
+\syncomment{\# scan some code}
+\synident{tokens} \synoperator{=} \synconstant{CodeRay}\synoperator{.}\synident{scan}\synoperator{(}\synstring{\syndelimiter{'}\syncontent{some\_file.rb}\syndelimiter{'}}\synoperator{,} \synsymbol{:ruby}\synoperator{)}
+
+\syncomment{\# dump using LaTeX}
+\synident{puts} \synident{tokens}\synoperator{.}\synident{latex}
+
+\end{semiverbatim}
+EOD
+ assert_equal(expected_latex, symbol_list.latex)
+ end
+
+ def test_wrap
+ source_text = <<EOD
+require 'coderay'
+
+# scan some code
+tokens = CodeRay.scan('some_file.rb', :ruby)
+
+# dump using LaTeX
+puts tokens.latex
+EOD
+
+ expected_latex = <<'EOD'
+\synident{require} \synstring{\syndelimiter{'}\syncontent{coderay}\syndelimiter{'}}
+
+\syncomment{\# scan some code}
+\synident{tokens} \synoperator{=} \synconstant{CodeRay}\synoperator{.}\synident{scan}\synoperator{(}\synstring{\syndelimiter{'}\syncontent{some\_file.rb}\syndelimiter{'}}\synoperator{,} \synsymbol{:ruby}\synoperator{)}
+
+\syncomment{\# dump using LaTeX}
+\synident{puts} \synident{tokens}\synoperator{.}\synident{latex}
+EOD
+ expected_latex2 = <<EOD
+\\begin{semiverbatim}
+#{expected_latex}
+\\end{semiverbatim}
+EOD
+ symbols = CodeRay.scan(source_text, :ruby)
+ assert_equal(expected_latex, symbols.latex(:wrap => false))
+ assert_equal(expected_latex2, symbols.latex)
+ assert_equal(expected_latex2, symbols.latex(:wrap => true))
+ assert_equal(expected_latex2, symbols.latex(:wrap => :semiverbatim))
+ end
+
+ def teardown
+ @enc = nil
+ end
+end