Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Avoid label values when using LLVM

  • Loading branch information...
commit 5666b63a80b3e7d71e1f2c2b3344d08a706cd4d6 1 parent ec92f75
@feeley authored
Showing with 32,219 additions and 1,580 deletions.
  1. +6 −6 configure
  2. +2 −2 configure.ac
  3. +80 −36 examples/iOS/AccessoryView.xib
  4. +1 −3 examples/iOS/AppDelegate.m
  5. BIN  examples/iOS/GambitREPL.xcodeproj.tgz
  6. +5 −3 examples/iOS/Info.plist
  7. +45 −24 examples/iOS/MainWindow.xib
  8. +58 −14 examples/iOS/ViewController.h
  9. +417 −113 examples/iOS/ViewController.m
  10. +539 −28 examples/iOS/ViewController.xib
  11. +4 −3 examples/iOS/build-gambit-iOS
  12. BIN  examples/iOS/button-abc.png
  13. BIN  examples/iOS/button-cancel.png
  14. BIN  examples/iOS/button-compass.png
  15. BIN  examples/iOS/button-empty.png
  16. BIN  examples/iOS/button-left-left.png
  17. BIN  examples/iOS/button-left.png
  18. BIN  examples/iOS/button-question.png
  19. BIN  examples/iOS/button-right-right.png
  20. BIN  examples/iOS/button-right.png
  21. BIN  examples/iOS/button-up-arrow.png
  22. BIN  examples/iOS/button-up.png
  23. +19,641 −0 examples/iOS/gambit-c.html
  24. +100 −0 examples/iOS/help.html
  25. +2 −1  examples/iOS/html.scm
  26. +115 −0 examples/iOS/intf#.scm
  27. +16 −0 examples/iOS/intf.h
  28. +681 −0 examples/iOS/intf.scm
  29. +27 −12 examples/iOS/makefile.in
  30. +0 −16 examples/iOS/program.h
  31. +652 −1,295 examples/iOS/program.scm
  32. +9,309 −0 examples/iOS/r5rs.html
  33. BIN  examples/iOS/r5rs.pdf
  34. +15 −0 examples/iOS/repl-server#.scm
  35. +155 −0 examples/iOS/repl-server.scm
  36. +18 −0 examples/iOS/repo#.scm
  37. +71 −0 examples/iOS/repo.scm
  38. +27 −0 examples/iOS/script#.scm
  39. +175 −0 examples/iOS/script.scm
  40. +2 −1  examples/iOS/wiki#.scm
  41. +50 −21 examples/iOS/wiki.scm
  42. +5 −1 include/gambit.h.in
  43. +1 −1  makefile.in
View
12 configure
@@ -2192,7 +2192,7 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test -n "$ac_tool_prefix"; then
- for ac_prog in i686-apple-darwin11-gcc-4.2.1 gcc cc
+ for ac_prog in gcc cc
do
# Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
@@ -2236,7 +2236,7 @@ fi
fi
if test -z "$CC"; then
ac_ct_CC=$CC
- for ac_prog in i686-apple-darwin11-gcc-4.2.1 gcc cc
+ for ac_prog in gcc cc
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
@@ -2908,7 +2908,7 @@ ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
- # Try to avoid LLVM gcc
+
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -3159,7 +3159,7 @@ if test -z "$CXX"; then
CXX=$CCC
else
if test -n "$ac_tool_prefix"; then
- for ac_prog in i686-apple-darwin11-g++-4.2.1 g++
+ for ac_prog in g++
do
# Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
@@ -3203,7 +3203,7 @@ fi
fi
if test -z "$CXX"; then
ac_ct_CXX=$CXX
- for ac_prog in i686-apple-darwin11-g++-4.2.1 g++
+ for ac_prog in g++
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
@@ -3512,7 +3512,7 @@ ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
- # Try to avoid LLVM gcc
+
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
View
4 configure.ac
@@ -77,14 +77,14 @@ if test "${LDFLAGS+set}" != set; then
fi
AC_LANG(C)
-AC_PROG_CC([i686-apple-darwin11-gcc-4.2.1 gcc cc]) # Try to avoid LLVM gcc
+AC_PROG_CC([gcc cc])
AC_PROG_CPP
C_COMPILER=$CC
C_PREPROC=$CPP
if test "$ENABLE_CPLUSPLUS" = yes; then
AC_LANG(C++)
- AC_PROG_CXX([i686-apple-darwin11-g++-4.2.1 g++]) # Try to avoid LLVM gcc
+ AC_PROG_CXX([g++])
AC_PROG_CXXCPP
C_COMPILER=$CXX
C_PREPROC=$CXXCPP
View
116 examples/iOS/AccessoryView.xib
@@ -2,9 +2,9 @@
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1056</int>
- <string key="IBDocument.SystemVersion">10J869</string>
+ <string key="IBDocument.SystemVersion">10K540</string>
<string key="IBDocument.InterfaceBuilderVersion">1305</string>
- <string key="IBDocument.AppKitVersion">1038.35</string>
+ <string key="IBDocument.AppKitVersion">1038.36</string>
<string key="IBDocument.HIToolboxVersion">461.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
@@ -197,13 +197,13 @@
<string key="NSResourceName">key-quote-46x42.png</string>
</object>
</object>
- <object class="IBUIButton" id="420911439">
+ <object class="IBUIButton" id="47015903">
<reference key="NSNextResponder" ref="795231795"/>
<int key="NSvFlags">297</int>
- <string key="NSFrame">{{593, 2}, {46, 42}}</string>
+ <string key="NSFrame">{{545, 2}, {46, 42}}</string>
<reference key="NSSuperview" ref="795231795"/>
<reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="965625217"/>
+ <reference key="NSNextKeyView" ref="420911439"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">2</int>
<bytes key="NSRGB">MC42MTE3NjQ3MjkgMC42MDc4NDMxNjA2IDAuNjUwOTgwNDEzAA</bytes>
@@ -213,7 +213,11 @@
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">0</int>
- <reference key="IBUIFont" ref="262793430"/>
+ <object class="NSFont" key="IBUIFont">
+ <string key="NSName">CourierNewPS-BoldMT</string>
+ <double key="NSSize">14</double>
+ <int key="NSfFlags">16</int>
+ </object>
<string key="IBUINormalTitle">STOP</string>
<reference key="IBUIHighlightedTitleColor" ref="107046278"/>
<object class="NSColor" key="IBUINormalTitleColor">
@@ -226,13 +230,13 @@
<string key="NSResourceName">key-stop-46x42.png</string>
</object>
</object>
- <object class="IBUIButton" id="47015903">
+ <object class="IBUIButton" id="420911439">
<reference key="NSNextResponder" ref="795231795"/>
<int key="NSvFlags">297</int>
- <string key="NSFrame">{{545, 2}, {46, 42}}</string>
+ <string key="NSFrame">{{593, 2}, {46, 42}}</string>
<reference key="NSSuperview" ref="795231795"/>
<reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="420911439"/>
+ <reference key="NSNextKeyView" ref="965625217"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">2</int>
<bytes key="NSRGB">MC42MTE3NjQ3MjkgMC42MDc4NDMxNjA2IDAuNjUwOTgwNDEzAA</bytes>
@@ -242,22 +246,19 @@
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">0</int>
- <object class="NSFont" key="IBUIFont">
- <string key="NSName">CourierNewPS-BoldMT</string>
- <double key="NSSize">14</double>
- <int key="NSfFlags">16</int>
- </object>
- <string key="IBUINormalTitle">EDIT</string>
+ <reference key="IBUIFont" ref="262793430"/>
+ <string key="IBUINormalTitle">COMMA</string>
<reference key="IBUIHighlightedTitleColor" ref="107046278"/>
<object class="NSColor" key="IBUINormalTitleColor">
<int key="NSColorSpace">2</int>
<bytes key="NSRGB">MC4yMzkyMTU3MDE4IDAuMjM5MjE1NzAxOCAwLjI0MzEzNzI3MDIAA</bytes>
</object>
<reference key="IBUINormalTitleShadowColor" ref="811716299"/>
- <object class="NSCustomResource" key="IBUINormalImage">
+ <object class="NSCustomResource" key="IBUINormalImage" id="561697142">
<string key="NSClassName">NSImage</string>
- <string key="NSResourceName">key-edit-46x42.png</string>
+ <string key="NSResourceName">key-comma-46x42.png</string>
</object>
+ <reference key="IBUINormalBackgroundImage" ref="561697142"/>
</object>
<object class="IBUIButton" id="949690578">
<reference key="NSNextResponder" ref="795231795"/>
@@ -1046,15 +1047,6 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
- <string key="label">touch_up_F13:</string>
- <reference key="source" ref="420911439"/>
- <reference key="destination" ref="372490531"/>
- <int key="IBEventType">7</int>
- </object>
- <int key="connectionID">162</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">touch_up_QUOTE:</string>
<reference key="source" ref="965625217"/>
<reference key="destination" ref="372490531"/>
@@ -1071,6 +1063,15 @@
</object>
<int key="connectionID">164</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchEventConnection" key="connection">
+ <string key="label">touch_up_COMMA:</string>
+ <reference key="source" ref="420911439"/>
+ <reference key="destination" ref="372490531"/>
+ <int key="IBEventType">7</int>
+ </object>
+ <int key="connectionID">165</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -1104,7 +1105,6 @@
<reference ref="933032107"/>
<reference ref="214816834"/>
<reference ref="965625217"/>
- <reference ref="420911439"/>
<reference ref="47015903"/>
<reference ref="949690578"/>
<reference ref="237724049"/>
@@ -1118,6 +1118,7 @@
<reference ref="996814062"/>
<reference ref="305193239"/>
<reference ref="1057799585"/>
+ <reference ref="420911439"/>
</object>
<reference key="parent" ref="0"/>
</object>
@@ -1160,6 +1161,7 @@
<int key="objectID">57</int>
<reference key="object" ref="420911439"/>
<reference key="parent" ref="795231795"/>
+ <string key="objectName">Button - COMMA</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">60</int>
@@ -1215,7 +1217,7 @@
<int key="objectID">118</int>
<reference key="object" ref="996814062"/>
<reference key="parent" ref="795231795"/>
- <string key="objectName">Button</string>
+ <string key="objectName">Button - F2</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">121</int>
@@ -1388,7 +1390,7 @@
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
- <int key="maxID">164</int>
+ <int key="maxID">165</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -1400,6 +1402,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <string>navigation_changed:</string>
<string>touch_down:</string>
<string>touch_up_COMMA:</string>
<string>touch_up_DQUOTE:</string>
@@ -1451,12 +1454,14 @@
<string>id</string>
<string>id</string>
<string>id</string>
+ <string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <string>navigation_changed:</string>
<string>touch_down:</string>
<string>touch_up_COMMA:</string>
<string>touch_up_DQUOTE:</string>
@@ -1485,6 +1490,10 @@
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBActionInfo">
+ <string key="name">navigation_changed:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ <object class="IBActionInfo">
<string key="name">touch_down:</string>
<string key="candidateClassName">id</string>
</object>
@@ -1587,13 +1596,23 @@
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>accessoryView</string>
- <string>textView</string>
- <string>webView</string>
+ <string>imageView0</string>
+ <string>imageView1</string>
+ <string>segmCtrl</string>
+ <string>textView0</string>
+ <string>textView1</string>
+ <string>webView0</string>
+ <string>webView1</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>UIView</string>
+ <string>UIImageView</string>
+ <string>UIImageView</string>
+ <string>UISegmentedControl</string>
<string>UITextView</string>
+ <string>UITextView</string>
+ <string>UIWebView</string>
<string>UIWebView</string>
</object>
</object>
@@ -1602,8 +1621,13 @@
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>accessoryView</string>
- <string>textView</string>
- <string>webView</string>
+ <string>imageView0</string>
+ <string>imageView1</string>
+ <string>segmCtrl</string>
+ <string>textView0</string>
+ <string>textView1</string>
+ <string>webView0</string>
+ <string>webView1</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1612,11 +1636,31 @@
<string key="candidateClassName">UIView</string>
</object>
<object class="IBToOneOutletInfo">
- <string key="name">textView</string>
+ <string key="name">imageView0</string>
+ <string key="candidateClassName">UIImageView</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">imageView1</string>
+ <string key="candidateClassName">UIImageView</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">segmCtrl</string>
+ <string key="candidateClassName">UISegmentedControl</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">textView0</string>
+ <string key="candidateClassName">UITextView</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">textView1</string>
<string key="candidateClassName">UITextView</string>
</object>
<object class="IBToOneOutletInfo">
- <string key="name">webView</string>
+ <string key="name">webView0</string>
+ <string key="candidateClassName">UIWebView</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">webView1</string>
<string key="candidateClassName">UIWebView</string>
</object>
</object>
@@ -1644,8 +1688,8 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <string>key-comma-46x42.png</string>
<string>key-doublequote-46x42.png</string>
- <string>key-edit-46x42.png</string>
<string>key-f1-46x42.png</string>
<string>key-f10-46x42.png</string>
<string>key-f11-46x42.png</string>
View
4 examples/iOS/AppDelegate.m
@@ -23,8 +23,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[window addSubview:viewController.view];
[window makeKeyAndVisible];
- viewController.keyboardSounds = -1;
-
return YES;
}
@@ -73,7 +71,7 @@ Restart any tasks that were paused (or not yet started) while the
the background, optionally refresh the user interface.
*/
- viewController.keyboardSounds = -1; // delay check of user preferences
+ [viewController app_become_active];
}
View
BIN  examples/iOS/GambitREPL.xcodeproj.tgz
Binary file not shown
View
8 examples/iOS/Info.plist
@@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
- <string>Gambit REPL</string>
+ <string>Gambit REPL dev</string>
<key>CFBundleDocumentTypes</key>
<array/>
<key>CFBundleExecutable</key>
@@ -28,17 +28,19 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
- <string>2.0</string>
+ <string>6.0</string>
<key>CFBundleSignature</key>
<string>GamC</string>
<key>CFBundleURLTypes</key>
<array/>
<key>CFBundleVersion</key>
- <string>2.0</string>
+ <string>6.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSMainNibFile</key>
<string>MainWindow</string>
+ <key>UIFileSharingEnabled</key>
+ <true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
View
69 examples/iOS/MainWindow.xib
@@ -53,7 +53,7 @@
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
<bool key="IBUIHorizontal">NO</bool>
</object>
- <object class="IBUIWindow" id="225323145">
+ <object class="IBUIWindow" id="774030385">
<reference key="NSNextResponder"/>
<int key="NSvFlags">292</int>
<string key="NSFrameSize">{768, 1024}</string>
@@ -61,8 +61,8 @@
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<object class="NSColor" key="IBUIBackgroundColor">
- <int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MQA</bytes>
+ <int key="NSColorSpace">1</int>
+ <bytes key="NSRGB">MSAxIDEAA</bytes>
</object>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
@@ -70,6 +70,8 @@
<int key="IBUIStatusBarStyle">2</int>
</object>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ <bool key="IBUIVisibleAtLaunch">YES</bool>
+ <bool key="IBUIResizesToFullScreen">YES</bool>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
@@ -77,14 +79,6 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
- <string key="label">window</string>
- <reference key="source" ref="807868132"/>
- <reference key="destination" ref="225323145"/>
- </object>
- <int key="connectionID">8</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="841351856"/>
<reference key="destination" ref="807868132"/>
@@ -99,6 +93,14 @@
</object>
<int key="connectionID">28</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">rootViewController</string>
+ <reference key="source" ref="774030385"/>
+ <reference key="destination" ref="1044503176"/>
+ </object>
+ <int key="connectionID">30</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -133,8 +135,8 @@
<string key="objectName">View Controller</string>
</object>
<object class="IBObjectRecord">
- <int key="objectID">7</int>
- <reference key="object" ref="225323145"/>
+ <int key="objectID">29</int>
+ <reference key="object" ref="774030385"/>
<reference key="parent" ref="0"/>
</object>
</object>
@@ -145,25 +147,23 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.CustomClassName</string>
<string>-2.CustomClassName</string>
+ <string>29.IBPluginDependency</string>
<string>3.CustomClassName</string>
<string>3.IBPluginDependency</string>
<string>4.CustomClassName</string>
<string>4.IBEditorWindowLastContentRect</string>
<string>4.IBPluginDependency</string>
- <string>7.IBEditorWindowLastContentRect</string>
- <string>7.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>UIApplication</string>
<string>UIResponder</string>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>AppDelegate</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>ViewController</string>
<string>{{52, 4}, {783, 852}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- <string>{{289, 4}, {783, 852}}</string>
- <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
@@ -178,7 +178,7 @@
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
- <int key="maxID">28</int>
+ <int key="maxID">30</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -230,6 +230,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <string>navigation_changed:</string>
<string>touch_down:</string>
<string>touch_up_COMMA:</string>
<string>touch_up_DQUOTE:</string>
@@ -281,12 +282,14 @@
<string>id</string>
<string>id</string>
<string>id</string>
+ <string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <string>navigation_changed:</string>
<string>touch_down:</string>
<string>touch_up_COMMA:</string>
<string>touch_up_DQUOTE:</string>
@@ -315,6 +318,10 @@
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBActionInfo">
+ <string key="name">navigation_changed:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ <object class="IBActionInfo">
<string key="name">touch_down:</string>
<string key="candidateClassName">id</string>
</object>
@@ -417,12 +424,16 @@
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>accessoryView</string>
- <string>textView</string>
- <string>webView</string>
+ <string>imageView0</string>
+ <string>segmCtrl</string>
+ <string>textView0</string>
+ <string>webView0</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>UIView</string>
+ <string>UIImageView</string>
+ <string>UISegmentedControl</string>
<string>UITextView</string>
<string>UIWebView</string>
</object>
@@ -432,8 +443,10 @@
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>accessoryView</string>
- <string>textView</string>
- <string>webView</string>
+ <string>imageView0</string>
+ <string>segmCtrl</string>
+ <string>textView0</string>
+ <string>webView0</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -442,11 +455,19 @@
<string key="candidateClassName">UIView</string>
</object>
<object class="IBToOneOutletInfo">
- <string key="name">textView</string>
+ <string key="name">imageView0</string>
+ <string key="candidateClassName">UIImageView</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">segmCtrl</string>
+ <string key="candidateClassName">UISegmentedControl</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">textView0</string>
<string key="candidateClassName">UITextView</string>
</object>
<object class="IBToOneOutletInfo">
- <string key="name">webView</string>
+ <string key="name">webView0</string>
<string key="candidateClassName">UIWebView</string>
</object>
</object>
View
72 examples/iOS/ViewController.h
@@ -10,38 +10,82 @@
// ViewController methods callable from Scheme.
-void show_textView();
-void show_webView();
-NSString *get_textView_content();
-void set_textView_font(NSString *name, int size);
-void set_textView_content(NSString *str);
-void add_output_to_textView(NSString *str);
-void add_input_to_textView(NSString *str);
-void set_webView_content(NSString *str, BOOL enable_scaling, NSString *mime_type);
+void set_navigation(int n);
+void show_cancelButton();
+void hide_cancelButton();
+void show_webView(int view);
+void show_textView(int view);
+void show_imageView(int view);
+void set_textView_font(int view, NSString *name, int size);
+void set_textView_content(int view, NSString *str);
+NSString *get_textView_content(int view);
+void add_output_to_textView(int view, NSString *str);
+void add_input_to_textView(int view, NSString *str);
+void set_webView_content(int view, NSString *str, BOOL enable_scaling, NSString *mime_type);
+void set_webView_content_from_file(int view, NSString *path, BOOL enable_scaling, NSString *mime_type);
+NSString *eval_js_in_webView(int view, NSString *script);
void open_URL(NSString *url);
+void segm_ctrl_set_title(int segment, NSString *title);
+void segm_ctrl_insert(int segment, NSString *title);
void set_pref(NSString *key, NSString *value);
NSString *get_pref(NSString *key);
+void set_pasteboard(NSString *value);
+NSString *get_pasteboard();
+NSString *get_documents_dir();
+void popup_alert(NSString *title, NSString *msg, NSString *cancel_button, NSString *accept_button);
+#define NB_WEBVIEWS 4
+#define NB_TEXTVIEWS 2
+#define NB_IMAGEVIEWS 2
-@interface ViewController : UIViewController <UITextViewDelegate,UIWebViewDelegate> {
+@interface ViewController : UIViewController <UITextViewDelegate,UIWebViewDelegate,UIAlertViewDelegate> {
- UITextView *textView;
+ UISegmentedControl *segmCtrl;
+ UIWebView *webViews[NB_WEBVIEWS];
+ UIWebView *webView0;
+ UIWebView *webView1;
+ UIWebView *webView2;
+ UIWebView *webView3;
+ UITextView *textViews[NB_TEXTVIEWS];
+ UITextView *textView0;
+ UITextView *textView1;
+ UIImageView *imageViews[NB_IMAGEVIEWS];
+ UIImageView *imageView0;
+ UIImageView *imageView1;
+ UIButton *cancelButton;
UIView *accessoryView;
- UIWebView *webView;
int keyboardSounds;
NSTimer *timer;
+ NSMutableArray *queuedActions;
}
-@property (nonatomic, retain) IBOutlet UITextView *textView;
+@property (nonatomic, assign) IBOutlet UISegmentedControl *segmCtrl;
+@property (nonatomic, assign) IBOutlet UIWebView *webView0;
+@property (nonatomic, assign) IBOutlet UIWebView *webView1;
+@property (nonatomic, assign) IBOutlet UIWebView *webView2;
+@property (nonatomic, assign) IBOutlet UIWebView *webView3;
+@property (nonatomic, retain) IBOutlet UITextView *textView0;
+@property (nonatomic, retain) IBOutlet UITextView *textView1;
+@property (nonatomic, retain) IBOutlet UIImageView *imageView0;
+@property (nonatomic, retain) IBOutlet UIImageView *imageView1;
+@property (nonatomic, assign) IBOutlet UIButton *cancelButton;
@property (nonatomic, assign) IBOutlet UIView *accessoryView;
-@property (nonatomic, assign) IBOutlet UIWebView *webView;
@property (assign) int keyboardSounds;
@property (assign) NSTimer *timer;
+@property (assign) NSMutableArray *queuedActions;
-- (void)up_key:(NSString*)name;
+- (void)queue_action:(void(^)())action;
+- (void)send_event:(NSString*)name;
+- (void)send_key:(NSString*)name;
- (void)heartbeat_tick;
- (void)schedule_next_heartbeat_tick:(double)interval;
+- (void)app_become_active;
+
+- (IBAction)navigation_changed:(id)sender;
+
+- (IBAction)touch_up_cancel:(id)sender;
+
- (IBAction)touch_down:(id)sender;
- (IBAction)touch_up_F1:(id)sender;
- (IBAction)touch_up_F2:(id)sender;
View
530 examples/iOS/ViewController.m
@@ -15,7 +15,7 @@
@implementation ViewController
-@synthesize textView, accessoryView, webView, keyboardSounds, timer;
+@synthesize segmCtrl, webView0, webView1, webView2, webView3, textView0, textView1, imageView0, imageView1, cancelButton, accessoryView, keyboardSounds, timer, queuedActions;
//-----------------------------------------------------------------------------
@@ -43,7 +43,7 @@ @implementation ViewController
extern char **main_argv;
-
+___UCS_2 ucs2_gambcdir[1024];
void gambit_setup()
{
@@ -55,6 +55,8 @@ void gambit_setup()
int debug_settings = ___DEBUG_SETTINGS_INITIAL;
___UCS_2STRING *ucs2_argv;
+ int last_dir_sep;
+ int i;
if (___NONNULLCHARSTRINGLIST_to_NONNULLUCS_2STRINGLIST
(main_argv,
@@ -62,6 +64,21 @@ void gambit_setup()
!= ___FIX(___NO_ERR))
exit(1);
+ last_dir_sep = 0;
+ i = 0;
+
+ while (ucs2_argv[0][i] != '\0')
+ {
+ if (ucs2_argv[0][i] == '/')
+ last_dir_sep = i;
+ i++;
+ }
+
+ for (i=0; i<last_dir_sep; i++)
+ ucs2_gambcdir[i] = ucs2_argv[0][i];
+
+ ucs2_gambcdir[i] = '\0';
+
// Set debugging settings so that all threads with uncaught
// exceptions start a REPL.
@@ -84,6 +101,7 @@ void gambit_setup()
setup_params.version = ___VERSION;
setup_params.linker = SCHEME_LIBRARY_LINKER;
setup_params.argv = ucs2_argv;
+ setup_params.gambcdir = ucs2_gambcdir;
setup_params.debug_settings = debug_settings;
___setup (&setup_params);
@@ -107,15 +125,30 @@ - (void)viewDidLoad {
[super viewDidLoad];
+ webViews[0] = webView0;
+ webViews[1] = webView1;
+ webViews[2] = webView2;
+ webViews[3] = webView3;
+
+ textViews[0] = textView0;
+ textViews[1] = textView1;
+
+ imageViews[0] = imageView0;
+ imageViews[1] = imageView1;
+
theViewController = self;
- set_textView_font(@"Courier-Bold", 16);
+ set_textView_font(0, @"Courier-Bold", 16);
+
+ segmCtrl.selectedSegmentIndex = UISegmentedControlNoSegment;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
timer = nil;
+ queuedActions = [[NSMutableArray alloc] init];
+
gambit_setup();
[self heartbeat_tick];
@@ -129,9 +162,23 @@ - (void)viewDidUnload {
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
- textView = nil;
+ segmCtrl = nil;
+
+ webView0 = nil;
+ webView1 = nil;
+ webView2 = nil;
+ webView3 = nil;
+
+ textView0 = nil;
+ textView1 = nil;
+
+ imageView0 = nil;
+ imageView1 = nil;
+
+ cancelButton = nil;
+
accessoryView = nil;
- webView = nil;
+
theViewController = nil;
gambit_cleanup();
@@ -161,16 +208,15 @@ - (void)didReceiveMemoryWarning {
- (BOOL)textViewShouldBeginEditing:(UITextView *)aTextView {
- if (textView.inputAccessoryView == nil)
+ if (textViews[0].inputAccessoryView == nil)
{
-
[[NSBundle mainBundle] loadNibNamed:@"AccessoryView" owner:self options:nil];
- textView.inputAccessoryView = accessoryView;
+ textViews[0].inputAccessoryView = accessoryView;
accessoryView = nil;
- show_textView();
+ show_textView(0);
}
return YES;
@@ -219,7 +265,7 @@ - (void)keyboardWillShow:(NSNotification *)notification {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:animationDuration];
- textView.frame = newTextViewFrame;
+ textViews[0].frame = newTextViewFrame;
[UIView commitAnimations];
}
@@ -242,40 +288,71 @@ Restore the size of the text view (fill self's view). Animate the
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:animationDuration];
- textView.frame = self.view.bounds;
+ textViews[0].frame = self.view.bounds;
[UIView commitAnimations];
}
-#include "program.h"
-
+#include "intf.h"
-- (void)up_key:(NSString*)name {
- ___enable_heartbeat_interrupts ();
+void set_navigation(int n) {
- ___ON_THROW(
+ ViewController *vc = theViewController;
+ if (vc != nil)
{
- [self schedule_next_heartbeat_tick:send_key(name)];
- },
- exit(0);
- );
+ [vc->segmCtrl removeTarget:vc action:@selector(navigation_changed:) forControlEvents:UIControlEventValueChanged];
+ vc->segmCtrl.selectedSegmentIndex = n;
+ [vc->segmCtrl addTarget:vc action:@selector(navigation_changed:) forControlEvents:UIControlEventValueChanged];
+ }
+}
- ___disable_heartbeat_interrupts ();
+
+- (void)queue_action:(void(^)())action {
+
+ [queuedActions addObject:[action copy]];
+}
+
+
+- (void)queue_action_asap:(void(^)())action {
+
+ [self queue_action:action];
+
+ [self schedule_next_heartbeat_tick:0.0];
+}
+
+
+- (void)send_event:(NSString*)name {
+
+ [self queue_action_asap:^{ send_event(name); }];
+}
+
+
+- (void)send_key:(NSString*)name {
+
+ [self queue_action_asap:^{ send_key(name); }];
}
- (void)heartbeat_tick {
+ [self queue_action:^{ [self schedule_next_heartbeat_tick:heartbeat()]; }];
+
___enable_heartbeat_interrupts ();
- ___ON_THROW(
+ while ([queuedActions count] > 0)
{
- [self schedule_next_heartbeat_tick:heartbeat()];
- },
- exit(0);
- );
+ void (^action)(void) = [queuedActions objectAtIndex:0];
+ [queuedActions removeObjectAtIndex:0];
+
+ ___ON_THROW(
+ {
+ action();
+ },
+ exit(0);
+ );
+ }
___disable_heartbeat_interrupts ();
}
@@ -283,7 +360,7 @@ - (void)heartbeat_tick {
- (void)schedule_next_heartbeat_tick:(double)interval {
- if (interval > 0)
+ if (interval >= 0)
{
if (timer != nil)
{
@@ -296,121 +373,274 @@ - (void)schedule_next_heartbeat_tick:(double)interval {
}
-void show_textView() {
+- (void)app_become_active {
+
+ theViewController.keyboardSounds = -1; // delay check of user preferences
+
+ [self send_event:@"app-become-active"];
+}
+
+
+void show_cancelButton() {
ViewController *vc = theViewController;
if (vc != nil)
{
- [vc.webView resignFirstResponder];
- vc.textView.hidden = NO;
- vc.webView.hidden = YES;
- [vc.textView becomeFirstResponder];
+ vc->cancelButton.hidden = NO;
}
}
-void show_webView() {
+void hide_cancelButton() {
ViewController *vc = theViewController;
if (vc != nil)
{
- [vc.textView resignFirstResponder];
- vc.webView.hidden = NO;
- vc.textView.hidden = YES;
- [vc.webView becomeFirstResponder];
+ vc->cancelButton.hidden = YES;
}
}
-void set_textView_content(NSString *str) {
+void show_webView(int view) {
ViewController *vc = theViewController;
if (vc != nil)
{
- vc.textView.text = str;
+ int i;
+
+ for (int i=0; i<NB_WEBVIEWS; i++)
+ if (i != view)
+ {
+ [vc->webViews[i] resignFirstResponder];
+ vc->webViews[i].hidden = YES;
+ }
+
+ for (int i=0; i<NB_TEXTVIEWS; i++)
+ {
+ [vc->textViews[i] resignFirstResponder];
+ vc->textViews[i].hidden = YES;
+ }
+
+ for (int i=0; i<NB_IMAGEVIEWS; i++)
+ {
+ [vc->imageViews[i] resignFirstResponder];
+ vc->imageViews[i].hidden = YES;
+ }
+
+ [vc->webViews[view] becomeFirstResponder];
+ vc->webViews[view].hidden = NO;
}
}
-NSString *get_textView_content() {
+void show_textView(int view) {
ViewController *vc = theViewController;
if (vc != nil)
{
- return vc.textView.text;
+ int i;
+
+ for (int i=0; i<NB_WEBVIEWS; i++)
+ {
+ [vc->webViews[i] resignFirstResponder];
+ vc->webViews[i].hidden = YES;
+ }
+
+ for (int i=0; i<NB_TEXTVIEWS; i++)
+ if (i != view)
+ {
+ [vc->textViews[i] resignFirstResponder];
+ vc->textViews[i].hidden = YES;
+ }
+
+ for (int i=0; i<NB_IMAGEVIEWS; i++)
+ {
+ [vc->imageViews[i] resignFirstResponder];
+ vc->imageViews[i].hidden = YES;
+ }
+
+ [vc->textViews[view] becomeFirstResponder];
+ vc->textViews[view].hidden = NO;
}
+}
- return @"";
+
+void show_imageView(int view) {
+
+ ViewController *vc = theViewController;
+ if (vc != nil)
+ {
+ int i;
+
+ for (int i=0; i<NB_WEBVIEWS; i++)
+ {
+ [vc->webViews[i] resignFirstResponder];
+ vc->webViews[i].hidden = YES;
+ }
+
+ for (int i=0; i<NB_TEXTVIEWS; i++)
+ {
+ [vc->textViews[i] resignFirstResponder];
+ vc->textViews[i].hidden = YES;
+ }
+
+ for (int i=0; i<NB_IMAGEVIEWS; i++)
+ if (i != view)
+ {
+ [vc->imageViews[i] resignFirstResponder];
+ vc->imageViews[i].hidden = YES;
+ }
+
+ [vc->imageViews[view] becomeFirstResponder];
+ vc->imageViews[view].hidden = NO;
+ }
+}
+
+
+void set_textView_font(int view, NSString *name, int size) {
+
+ ViewController *vc = theViewController;
+ if (vc != nil)
+ {
+ vc->textViews[view].font = [UIFont fontWithName:name size:size];
+ }
+}
+
+
+void set_textView_content(int view, NSString *str) {
+
+ ViewController *vc = theViewController;
+ if (vc != nil)
+ {
+ vc->textViews[view].text = str;
+ }
}
-void set_textView_font(NSString *name, int size) {
+NSString *get_textView_content(int view) {
ViewController *vc = theViewController;
if (vc != nil)
{
- vc.textView.font = [UIFont fontWithName:name size:size];
+ return vc->textViews[view].text;
}
+
+ return @"";
}
-void add_to_textView(NSString *str) {
+void add_to_textView(int view, NSString *str) {
ViewController *vc = theViewController;
if (vc != nil)
{
- NSMutableString *new_text = [vc.textView.text mutableCopy];
+ NSMutableString *new_text = [vc->textViews[view].text mutableCopy];
[new_text appendString:str];
- vc.textView.text = new_text;
+ vc->textViews[view].text = new_text;
[new_text release];
}
}
-void add_output_to_textView(NSString *str) {
+void add_output_to_textView(int view, NSString *str) {
- add_to_textView([str stringByReplacingOccurrencesOfString:@" " withString:@"\u2007"]);
+ add_to_textView(view, [str stringByReplacingOccurrencesOfString:@" " withString:@"\u2007"]);
}
-void add_input_to_textView(NSString *str) {
+void add_input_to_textView(int view, NSString *str) {
ViewController *vc = theViewController;
if (vc != nil)
{
- NSMutableString *new_text = [vc.textView.text mutableCopy];
- NSRange selectedRange = vc.textView.selectedRange;
+ NSMutableString *new_text = [vc->textViews[view].text mutableCopy];
+ NSRange selectedRange = vc->textViews[view].selectedRange;
[new_text replaceCharactersInRange:selectedRange withString:str];
- vc.textView.text = new_text;
+ vc->textViews[view].text = new_text;
[new_text release];
}
}
-void set_webView_content(NSString *str, BOOL enable_scaling, NSString *mime_type) {
+void set_webView_content(int view, NSString *str, BOOL enable_scaling, NSString *mime_type) {
ViewController *vc = theViewController;
if (vc != nil)
{
- [vc.webView
+ [vc->webViews[view]
loadData:[str dataUsingEncoding:NSUnicodeStringEncoding]
MIMEType:mime_type
textEncodingName:@"UTF-8"
baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]
];
- vc.webView.scalesPageToFit = enable_scaling;
+ vc->webViews[0].scalesPageToFit = enable_scaling;
+ }
+}
+
+
+void set_webView_content_from_file(int view, NSString *path, BOOL enable_scaling, NSString *mime_type) {
+
+ ViewController *vc = theViewController;
+ if (vc != nil)
+ {
+ NSString *p = [[NSBundle mainBundle] pathForResource:path ofType:nil];
+ if (p != nil)
+ {
+ NSData *data = [NSData dataWithContentsOfFile:p];
+ if (data != nil)
+ {
+ [vc->webViews[view]
+ loadData:data
+ MIMEType:mime_type
+ textEncodingName:@"UTF-8"
+ baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]
+ ];
+ vc->webViews[view].scalesPageToFit = enable_scaling;
+ }
+ }
}
}
+NSString *eval_js_in_webView(int view, NSString *script) {
+
+ ViewController *vc = theViewController;
+ if (vc != nil)
+ {
+ return [vc->webViews[view] stringByEvaluatingJavaScriptFromString:script];
+ }
+
+ return nil;
+}
+
void open_URL(NSString *url) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}
+void segm_ctrl_set_title(int segment, NSString *title) {
+
+ ViewController *vc = theViewController;
+ if (vc != nil)
+ {
+ [vc->segmCtrl setTitle:title forSegmentAtIndex:segment];
+ }
+}
+
+
+void segm_ctrl_insert(int segment, NSString *title) {
+
+ ViewController *vc = theViewController;
+ if (vc != nil)
+ {
+ [vc->segmCtrl insertSegmentWithTitle:title atIndex:segment animated:true];
+ }
+}
+
+
void set_pref(NSString *key, NSString *value) {
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
@@ -426,49 +656,118 @@ void set_pref(NSString *key, NSString *value) {
}
+void set_pasteboard(NSString *value) {
+
+ UIPasteboard *pb = [UIPasteboard generalPasteboard];
+ pb.string = value;
+}
+
+
+NSString *get_pasteboard() {
+
+ UIPasteboard *pb = [UIPasteboard generalPasteboard];
+ return pb.string;
+}
+
+
+NSString *get_documents_dir() {
+
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ return [paths objectAtIndex:0];
+}
+
+
+void popup_alert(NSString *title, NSString *msg, NSString *cancel_button, NSString *accept_button) {
+
+ UIAlertView *alert = [[UIAlertView alloc]
+ initWithTitle: title
+ message: msg
+ delegate: theViewController
+ cancelButtonTitle: cancel_button
+ otherButtonTitles: accept_button, nil];
+ [alert show];
+ [alert release];
+}
+
+
+// Called when an alertview button is touched
+- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
+
+ NSString *event;
+
+ switch (buttonIndex) {
+
+ case 1:
+ event = @"popup-alert-accept";
+ break;
+
+ default:
+ case 0:
+ event = @"popup-alert-cancel";
+ break;
+ }
+
+ [self send_event:event];
+}
+
+
+#pragma mark -
+#pragma mark Toolbar action
+
+- (IBAction)navigation_changed:(id)sender {
+ int n = segmCtrl.selectedSegmentIndex;
+ if (n >= 0)
+ [self send_event:[NSString stringWithFormat:@"NAV%d", n]];
+}
+
+
+#pragma mark -
+#pragma mark Cancel button action
+
+- (IBAction)touch_up_cancel:(id)sender {
+ [self send_event:@"cancel"];
+}
+
+
- (BOOL)textView:(UITextView *)textView2 shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
if ([text hasSuffix:@"\n"])
{
unichar c;
- int end = [textView.text length];
+ int end = [textViews[0].text length];
int line_start = range.location+range.length;
while (line_start > 0 &&
- (c = [textView.text characterAtIndex:line_start-1]) != '\n' &&
+ (c = [textViews[0].text characterAtIndex:line_start-1]) != '\n' &&
c != 0x2007) // non breaking space
line_start--;
int line_end = range.location+range.length;
while (line_end < end &&
- [textView.text characterAtIndex:line_end] != '\n')
+ [textViews[0].text characterAtIndex:line_end] != '\n')
line_end++;
- NSString *line = [textView.text substringWithRange:NSMakeRange(line_start, line_end-line_start)];
-
- if (line_end == end)
+ if (line_start == line_end)
{
- add_to_textView(text);
-
- ___enable_heartbeat_interrupts ();
+ [textViews[0] resignFirstResponder]; // Hide the keyboard after "return" key is pressed on empty line
+ }
+ else
+ {
+ NSString *line = [textViews[0].text substringWithRange:NSMakeRange(line_start, line_end-line_start)];
- ___ON_THROW(
+ if (line_end == end)
{
- [self schedule_next_heartbeat_tick:send_input([line stringByAppendingString:text])];
- },
- exit(0);
- );
-
- ___disable_heartbeat_interrupts ();
-
-#if 0
- [textView resignFirstResponder]; // Hide the keyboard after "return" key is pressed
-#endif
+ add_to_textView(0, text);
+
+ [self queue_action_asap:^{
+ send_input([line stringByAppendingString:text]);
+ }];
+ }
+ else
+ add_to_textView(0, line);
}
- else
- add_to_textView(line);
return NO;
}
@@ -479,7 +778,7 @@ - (BOOL)textView:(UITextView *)textView2 shouldChangeTextInRange:(NSRange)range
- (IBAction)touch_up_Char:(id)sender withString:(NSString *)aString {
- add_input_to_textView(aString);
+ add_input_to_textView(0, aString);
}
@@ -511,7 +810,7 @@ - (IBAction)touch_down:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_F1:(id)sender {
- [self up_key:@"F1"];
+ [self send_key:@"F1"];
}
@@ -519,7 +818,7 @@ - (IBAction)touch_up_F1:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_F2:(id)sender {
- [self up_key:@"F2"];
+ [self send_key:@"F2"];
}
@@ -527,7 +826,7 @@ - (IBAction)touch_up_F2:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_F3:(id)sender {
- [self up_key:@"F3"];
+ [self send_key:@"F3"];
}
@@ -535,7 +834,7 @@ - (IBAction)touch_up_F3:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_F4:(id)sender {
- [self up_key:@"F4"];
+ [self send_key:@"F4"];
}
@@ -543,7 +842,7 @@ - (IBAction)touch_up_F4:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_F5:(id)sender {
- [self up_key:@"F5"];
+ [self send_key:@"F5"];
}
@@ -551,7 +850,7 @@ - (IBAction)touch_up_F5:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_F6:(id)sender {
- [self up_key:@"F6"];
+ [self send_key:@"F6"];
}
@@ -559,7 +858,7 @@ - (IBAction)touch_up_F6:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_F7:(id)sender {
- [self up_key:@"F7"];
+ [self send_key:@"F7"];
}
@@ -567,7 +866,7 @@ - (IBAction)touch_up_F7:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_F8:(id)sender {
- [self up_key:@"F8"];
+ [self send_key:@"F8"];
}
@@ -575,7 +874,7 @@ - (IBAction)touch_up_F8:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_F9:(id)sender {
- [self up_key:@"F9"];
+ [self send_key:@"F9"];
}
@@ -583,7 +882,7 @@ - (IBAction)touch_up_F9:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_F10:(id)sender {
- [self up_key:@"F10"];
+ [self send_key:@"F10"];
}
@@ -591,7 +890,7 @@ - (IBAction)touch_up_F10:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_F11:(id)sender {
- [self up_key:@"F11"];
+ [self send_key:@"F11"];
}
@@ -599,7 +898,7 @@ - (IBAction)touch_up_F11:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_F12:(id)sender {
- [self up_key:@"F12"];
+ [self send_key:@"F12"];
}
@@ -607,7 +906,7 @@ - (IBAction)touch_up_F12:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_F13:(id)sender {
- [self up_key:@"F13"];
+ [self send_key:@"F13"];
}
@@ -615,7 +914,7 @@ - (IBAction)touch_up_F13:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_SHARP:(id)sender {
- [self up_key:@"#"];
+ [self send_key:@"#"];
}
@@ -623,7 +922,7 @@ - (IBAction)touch_up_SHARP:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_DQUOTE:(id)sender {
- [self up_key:@"\""];
+ [self send_key:@"\""];
}
@@ -631,7 +930,7 @@ - (IBAction)touch_up_DQUOTE:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_QUOTE:(id)sender {
- [self up_key:@"'"];
+ [self send_key:@"'"];
}
@@ -639,7 +938,7 @@ - (IBAction)touch_up_QUOTE:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_COMMA:(id)sender {
- [self up_key:@","];
+ [self send_key:@","];
}
@@ -647,7 +946,7 @@ - (IBAction)touch_up_COMMA:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_PLUS:(id)sender {
- [self up_key:@"+"];
+ [self send_key:@"+"];
}
@@ -655,7 +954,7 @@ - (IBAction)touch_up_PLUS:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_MINUS:(id)sender {
- [self up_key:@"-"];
+ [self send_key:@"-"];
}
@@ -663,7 +962,7 @@ - (IBAction)touch_up_MINUS:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_STAR:(id)sender {
- [self up_key:@"*"];
+ [self send_key:@"*"];
}
@@ -671,7 +970,7 @@ - (IBAction)touch_up_STAR:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_SLASH:(id)sender {
- [self up_key:@"/"];
+ [self send_key:@"/"];
}
@@ -679,7 +978,7 @@ - (IBAction)touch_up_SLASH:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_LPAREN:(id)sender {
- [self up_key:@"("];
+ [self send_key:@"("];
}
@@ -687,7 +986,7 @@ - (IBAction)touch_up_LPAREN:(id)sender {
#pragma mark Accessory view action
- (IBAction)touch_up_RPAREN:(id)sender {
- [self up_key:@")"];
+ [self send_key:@")"];
}
@@ -697,16 +996,7 @@ - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)
if ([url hasPrefix:@"event:"])
{
- ___enable_heartbeat_interrupts ();
-
- ___ON_THROW(
- {
- [self schedule_next_heartbeat_tick:send_event([url stringByAppendingString:@"\n"])];
- },
- exit(0);
- );
-
- ___disable_heartbeat_interrupts ();
+ [self send_event:url];
return NO;
}
@@ -720,8 +1010,22 @@ - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)
- (void)dealloc {
+ int i;
+
[[NSNotificationCenter defaultCenter] removeObserver:self name:nil object:nil];
- [textView release];
+
+ [segmCtrl release];
+
+ for (i=0; i<NB_WEBVIEWS; i++)
+ [webViews[i] release];
+
+ for (i=0; i<NB_TEXTVIEWS; i++)
+ [textViews[i] release];
+
+ for (i=0; i<NB_IMAGEVIEWS; i++)
+ [imageViews[i] release];
+
+ [cancelButton release];
[super dealloc];
}
View
567 examples/iOS/ViewController.xib
@@ -12,10 +12,15 @@
</object>
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <string>IBProxyObject</string>
+ <string>IBUIBarButtonItem</string>
+ <string>IBUIImageView</string>
+ <string>IBUIToolbar</string>
+ <string>IBUIButton</string>
<string>IBUIWebView</string>
<string>IBUITextView</string>
+ <string>IBUISegmentedControl</string>
<string>IBUIView</string>
- <string>IBProxyObject</string>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -43,17 +48,61 @@
<int key="NSvFlags">292</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="IBUITextView" id="382596724">
+ <object class="IBUIWebView" id="742341718">
<reference key="NSNextResponder" ref="766721923"/>
- <int key="NSvFlags">274</int>
- <string key="NSFrameSize">{768, 1004}</string>
+ <int key="NSvFlags">-2147483374</int>
+ <string key="NSFrameSize">{768, 960}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="742341718"/>
+ <reference key="NSNextKeyView" ref="53140855"/>
<object class="NSColor" key="IBUIBackgroundColor" id="735581002">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MSAxIDEAA</bytes>
</object>
+ <bool key="IBUIMultipleTouchEnabled">YES</bool>
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ </object>
+ <object class="IBUIWebView" id="53140855">
+ <reference key="NSNextResponder" ref="766721923"/>
+ <int key="NSvFlags">-2147483374</int>
+ <string key="NSFrameSize">{768, 960}</string>
+ <reference key="NSSuperview" ref="766721923"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="94888966"/>
+ <reference key="IBUIBackgroundColor" ref="735581002"/>
+ <bool key="IBUIMultipleTouchEnabled">YES</bool>
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ </object>
+ <object class="IBUIWebView" id="94888966">
+ <reference key="NSNextResponder" ref="766721923"/>
+ <int key="NSvFlags">-2147483374</int>
+ <string key="NSFrameSize">{768, 960}</string>
+ <reference key="NSSuperview" ref="766721923"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="977500972"/>
+ <reference key="IBUIBackgroundColor" ref="735581002"/>
+ <bool key="IBUIMultipleTouchEnabled">YES</bool>
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ </object>
+ <object class="IBUIWebView" id="977500972">
+ <reference key="NSNextResponder" ref="766721923"/>
+ <int key="NSvFlags">-2147483374</int>
+ <string key="NSFrameSize">{768, 960}</string>
+ <reference key="NSSuperview" ref="766721923"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="382596724"/>
+ <reference key="IBUIBackgroundColor" ref="735581002"/>
+ <bool key="IBUIMultipleTouchEnabled">YES</bool>
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ </object>
+ <object class="IBUITextView" id="382596724">
+ <reference key="NSNextResponder" ref="766721923"/>
+ <int key="NSvFlags">-2147483374</int>
+ <string key="NSFrameSize">{768, 960}</string>
+ <reference key="NSSuperview" ref="766721923"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="894914323"/>
+ <reference key="IBUIBackgroundColor" ref="735581002"/>
<bool key="IBUIClipsSubviews">YES</bool>
<bool key="IBUIMultipleTouchEnabled">YES</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
@@ -65,26 +114,169 @@
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
</object>
- <object class="IBUIWebView" id="742341718">
+ <object class="IBUITextView" id="894914323">
<reference key="NSNextResponder" ref="766721923"/>
<int key="NSvFlags">-2147483374</int>
- <string key="NSFrameSize">{768, 1004}</string>
+ <string key="NSFrameSize">{768, 960}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
- <reference key="NSNextKeyView"/>
+ <reference key="NSNextKeyView" ref="747090650"/>
<reference key="IBUIBackgroundColor" ref="735581002"/>
+ <bool key="IBUIClipsSubviews">YES</bool>
<bool key="IBUIMultipleTouchEnabled">YES</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ <bool key="IBUIShowsHorizontalScrollIndicator">NO</bool>
+ <string key="IBUIText"/>
+ <object class="IBUITextInputTraits" key="IBUITextInputTraits">
+ <int key="IBUIAutocorrectionType">1</int>
+ <int key="IBUIKeyboardType">1</int>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ </object>
+ <object class="IBUIImageView" id="747090650">
+ <reference key="NSNextResponder" ref="766721923"/>
+ <int key="NSvFlags">-2147483356</int>
+ <string key="NSFrameSize">{768, 960}</string>
+ <reference key="NSSuperview" ref="766721923"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="217127702"/>
+ <int key="IBUIContentMode">1</int>
+ <bool key="IBUIUserInteractionEnabled">NO</bool>
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ </object>
+ <object class="IBUIImageView" id="217127702">
+ <reference key="NSNextResponder" ref="766721923"/>
+ <int key="NSvFlags">-2147483356</int>
+ <string key="NSFrameSize">{768, 960}</string>
+ <reference key="NSSuperview" ref="766721923"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="634231874"/>
+ <int key="IBUIContentMode">1</int>
+ <bool key="IBUIUserInteractionEnabled">NO</bool>
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ </object>
+ <object class="IBUIToolbar" id="791792189">
+ <reference key="NSNextResponder" ref="766721923"/>
+ <int key="NSvFlags">266</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBUISegmentedControl" id="252233658">
+ <reference key="NSNextResponder" ref="791792189"/>
+ <int key="NSvFlags">292</int>
+ <string key="NSFrame">{{234, 8}, {300, 30}}</string>
+ <reference key="NSSuperview" ref="791792189"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView"/>
+ <bool key="IBUIOpaque">NO</bool>
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ <int key="IBSegmentControlStyle">2</int>
+ <int key="IBNumberOfSegments">4</int>
+ <int key="IBSelectedSegmentIndex">0</int>
+ <object class="NSArray" key="IBSegmentTitles">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>REPL</string>
+ <string>Wiki</string>
+ <string>Help</string>
+ <string>Edit</string>
+ </object>
+ <object class="NSMutableArray" key="IBSegmentWidths">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <real value="0.0"/>
+ <real value="0.0"/>
+ <real value="0.0"/>
+ <real value="0.0"/>
+ </object>
+ <object class="NSMutableArray" key="IBSegmentEnabledStates">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <boolean value="YES"/>
+ <boolean value="YES"/>
+ <boolean value="YES"/>
+ <boolean value="YES"/>
+ </object>
+ <object class="NSMutableArray" key="IBSegmentContentOffsets">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>{0, 0}</string>
+ <string>{0, 0}</string>
+ <string>{0, 0}</string>
+ <string>{0, 0}</string>
+ </object>
+ <object class="NSMutableArray" key="IBSegmentImages">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSNull" id="4"/>
+ <reference ref="4"/>
+ <reference ref="4"/>
+ <reference ref="4"/>
+ </object>
+ </object>
+ </object>
+ <string key="NSFrame">{{0, 960}, {768, 44}}</string>
+ <reference key="NSSuperview" ref="766721923"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="252233658"/>
+ <bool key="IBUIOpaque">NO</bool>
+ <bool key="IBUIClearsContextBeforeDrawing">NO</bool>
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ <object class="NSMutableArray" key="IBUIItems">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBUIBarButtonItem" id="336382563">
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ <reference key="IBUIToolbar" ref="791792189"/>
+ <int key="IBUISystemItemIdentifier">5</int>
+ </object>
+ <object class="IBUIBarButtonItem" id="33006082">
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ <float key="IBUIWidth">300</float>
+ <reference key="IBUICustomView" ref="252233658"/>
+ <reference key="IBUIToolbar" ref="791792189"/>
+ </object>
+ <object class="IBUIBarButtonItem" id="980281595">
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ <reference key="IBUIToolbar" ref="791792189"/>
+ <int key="IBUISystemItemIdentifier">5</int>
+ </object>
+ </object>
+ </object>
+ <object class="IBUIButton" id="634231874">
+ <reference key="NSNextResponder" ref="766721923"/>
+ <int key="NSvFlags">-2147483359</int>
+ <string key="NSFrame">{{732, 2}, {32, 32}}</string>
+ <reference key="NSSuperview" ref="766721923"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="791792189"/>
+ <bool key="IBUIOpaque">NO</bool>
+ <float key="IBUIAlpha">0.60000002384185791</float>
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ <int key="IBUIContentHorizontalAlignment">0</int>
+ <int key="IBUIContentVerticalAlignment">0</int>
+ <object class="NSFont" key="IBUIFont">
+ <string key="NSName">Helvetica-Bold</string>
+ <double key="NSSize">15</double>
+ <int key="NSfFlags">16</int>
+ </object>
+ <bool key="IBUIShowsTouchWhenHighlighted">YES</bool>
+ <object class="NSColor" key="IBUIHighlightedTitleColor" id="873201213">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MQA</bytes>
+ </object>
+ <object class="NSColor" key="IBUINormalTitleColor">
+ <int key="NSColorSpace">1</int>
+ <bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
+ </object>
+ <object class="NSColor" key="IBUINormalTitleShadowColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MC41AA</bytes>
+ </object>
+ <object class="NSCustomResource" key="IBUINormalImage">
+ <string key="NSClassName">NSImage</string>
+ <string key="NSResourceName">button-cancel.png</string>
+ </object>
</object>
</object>
<string key="NSFrame">{{0, 20}, {768, 1004}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="382596724"/>
- <object class="NSColor" key="IBUIBackgroundColor">
- <int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MQA</bytes>
- </object>
+ <reference key="NSNextKeyView" ref="742341718"/>
+ <reference key="IBUIBackgroundColor" ref="873201213"/>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
<bool key="IBUIMultipleTouchEnabled">YES</bool>
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics">
@@ -107,34 +299,148 @@
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">delegate</string>
+ <reference key="source" ref="742341718"/>
+ <reference key="destination" ref="841351856"/>
+ </object>
+ <int key="connectionID">28</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">delegate</string>
<reference key="source" ref="382596724"/>
<reference key="destination" ref="841351856"/>
</object>
- <int key="connectionID">24</int>
+ <int key="connectionID">68</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
- <string key="label">textView</string>
+ <string key="label">textView0</string>
<reference key="source" ref="841351856"/>
<reference key="destination" ref="382596724"/>
</object>
- <int key="connectionID">25</int>
+ <int key="connectionID">70</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchEventConnection" key="connection">
+ <string key="label">navigation_changed:</string>
+ <reference key="source" ref="252233658"/>
+ <reference key="destination" ref="841351856"/>
+ <int key="IBEventType">13</int>
+ </object>
+ <int key="connectionID">75</int>
</object>
<object class="IBConnectionRecord">
<