AmberRack 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. data/.gitignore +74 -0
  2. data/.rvmrc +4 -0
  3. data/Gemfile +2 -0
  4. data/Gemfile.lock +62 -0
  5. data/README.md +17 -0
  6. data/Rakefile +24 -0
  7. data/amber-rack.gemspec +33 -0
  8. data/app/amber_app.rb +35 -0
  9. data/app/javascripts/Benchfib.deploy.js +159 -0
  10. data/app/javascripts/Benchfib.js +159 -0
  11. data/app/javascripts/Canvas.deploy.js +1464 -0
  12. data/app/javascripts/Canvas.js +1464 -0
  13. data/app/javascripts/Compiler.deploy.js +1587 -0
  14. data/app/javascripts/Compiler.js +1587 -0
  15. data/app/javascripts/Examples.deploy.js +800 -0
  16. data/app/javascripts/Examples.js +800 -0
  17. data/app/javascripts/IDE.deploy.js +3457 -0
  18. data/app/javascripts/IDE.js +3457 -0
  19. data/app/javascripts/IDE.js.bak +3420 -0
  20. data/app/javascripts/JQuery.deploy.js +898 -0
  21. data/app/javascripts/JQuery.js +898 -0
  22. data/app/javascripts/Kernel.deploy.js +6761 -0
  23. data/app/javascripts/Kernel.js +6761 -0
  24. data/app/javascripts/Parser.deploy.js +1655 -0
  25. data/app/javascripts/Parser.js +1655 -0
  26. data/app/javascripts/Raphael-Core.js +0 -0
  27. data/app/javascripts/Raphael-Graph.js +0 -0
  28. data/app/javascripts/SUnit.deploy.js +1059 -0
  29. data/app/javascripts/SUnit.js +1059 -0
  30. data/app/javascripts/application.js +2 -0
  31. data/app/javascripts/boot.js +466 -0
  32. data/app/javascripts/init.js +2 -0
  33. data/app/javascripts/jquery-1.4.4.min.js +167 -0
  34. data/app/javascripts/jquery-ui-1.8.9.custom.min.js +781 -0
  35. data/app/javascripts/jquery.textarea.js +267 -0
  36. data/app/javascripts/jtalk.js +78 -0
  37. data/app/javascripts/lib/CodeMirror/LICENSE +19 -0
  38. data/app/javascripts/lib/CodeMirror/README.md +6 -0
  39. data/app/javascripts/lib/CodeMirror/compress.html +92 -0
  40. data/app/javascripts/lib/CodeMirror/css/baboon.png +0 -0
  41. data/app/javascripts/lib/CodeMirror/css/baboon_vector.svg +153 -0
  42. data/app/javascripts/lib/CodeMirror/css/docs.css +154 -0
  43. data/app/javascripts/lib/CodeMirror/demo/activeline.html +72 -0
  44. data/app/javascripts/lib/CodeMirror/demo/changemode.html +51 -0
  45. data/app/javascripts/lib/CodeMirror/demo/complete.html +79 -0
  46. data/app/javascripts/lib/CodeMirror/demo/complete.js +151 -0
  47. data/app/javascripts/lib/CodeMirror/demo/fullscreen.html +158 -0
  48. data/app/javascripts/lib/CodeMirror/demo/marker.html +53 -0
  49. data/app/javascripts/lib/CodeMirror/demo/mustache.html +57 -0
  50. data/app/javascripts/lib/CodeMirror/demo/preview.html +75 -0
  51. data/app/javascripts/lib/CodeMirror/demo/resize.html +44 -0
  52. data/app/javascripts/lib/CodeMirror/demo/runmode.html +50 -0
  53. data/app/javascripts/lib/CodeMirror/demo/search.html +106 -0
  54. data/app/javascripts/lib/CodeMirror/demo/theme.html +53 -0
  55. data/app/javascripts/lib/CodeMirror/index.html +239 -0
  56. data/app/javascripts/lib/CodeMirror/internals.html +389 -0
  57. data/app/javascripts/lib/CodeMirror/lib/codemirror.css +67 -0
  58. data/app/javascripts/lib/CodeMirror/lib/codemirror.js +2144 -0
  59. data/app/javascripts/lib/CodeMirror/lib/overlay.js +51 -0
  60. data/app/javascripts/lib/CodeMirror/lib/runmode.js +27 -0
  61. data/app/javascripts/lib/CodeMirror/manual.html +854 -0
  62. data/app/javascripts/lib/CodeMirror/mode/clike/clike.js +247 -0
  63. data/app/javascripts/lib/CodeMirror/mode/clike/index.html +102 -0
  64. data/app/javascripts/lib/CodeMirror/mode/css/css.js +124 -0
  65. data/app/javascripts/lib/CodeMirror/mode/css/index.html +56 -0
  66. data/app/javascripts/lib/CodeMirror/mode/diff/diff.css +3 -0
  67. data/app/javascripts/lib/CodeMirror/mode/diff/diff.js +13 -0
  68. data/app/javascripts/lib/CodeMirror/mode/diff/index.html +99 -0
  69. data/app/javascripts/lib/CodeMirror/mode/haskell/haskell.js +242 -0
  70. data/app/javascripts/lib/CodeMirror/mode/haskell/index.html +60 -0
  71. data/app/javascripts/lib/CodeMirror/mode/htmlmixed/htmlmixed.js +79 -0
  72. data/app/javascripts/lib/CodeMirror/mode/htmlmixed/index.html +52 -0
  73. data/app/javascripts/lib/CodeMirror/mode/javascript/index.html +78 -0
  74. data/app/javascripts/lib/CodeMirror/mode/javascript/javascript.js +348 -0
  75. data/app/javascripts/lib/CodeMirror/mode/lua/index.html +72 -0
  76. data/app/javascripts/lib/CodeMirror/mode/lua/lua.js +138 -0
  77. data/app/javascripts/lib/CodeMirror/mode/php/index.html +49 -0
  78. data/app/javascripts/lib/CodeMirror/mode/php/php.js +110 -0
  79. data/app/javascripts/lib/CodeMirror/mode/plsql/index.html +63 -0
  80. data/app/javascripts/lib/CodeMirror/mode/plsql/plsql.js +217 -0
  81. data/app/javascripts/lib/CodeMirror/mode/python/LICENSE.txt +21 -0
  82. data/app/javascripts/lib/CodeMirror/mode/python/index.html +123 -0
  83. data/app/javascripts/lib/CodeMirror/mode/python/python.js +321 -0
  84. data/app/javascripts/lib/CodeMirror/mode/rst/index.html +526 -0
  85. data/app/javascripts/lib/CodeMirror/mode/rst/rst.css +75 -0
  86. data/app/javascripts/lib/CodeMirror/mode/rst/rst.js +333 -0
  87. data/app/javascripts/lib/CodeMirror/mode/scheme/index.html +65 -0
  88. data/app/javascripts/lib/CodeMirror/mode/scheme/scheme.js +181 -0
  89. data/app/javascripts/lib/CodeMirror/mode/smalltalk/index.html +56 -0
  90. data/app/javascripts/lib/CodeMirror/mode/smalltalk/smalltalk.js +134 -0
  91. data/app/javascripts/lib/CodeMirror/mode/sparql/index.html +41 -0
  92. data/app/javascripts/lib/CodeMirror/mode/sparql/sparql.js +143 -0
  93. data/app/javascripts/lib/CodeMirror/mode/stex/index.html +96 -0
  94. data/app/javascripts/lib/CodeMirror/mode/stex/stex.js +167 -0
  95. data/app/javascripts/lib/CodeMirror/mode/xml/index.html +42 -0
  96. data/app/javascripts/lib/CodeMirror/mode/xml/xml.js +231 -0
  97. data/app/javascripts/lib/CodeMirror/mode/yaml/index.html +68 -0
  98. data/app/javascripts/lib/CodeMirror/mode/yaml/yaml.js +95 -0
  99. data/app/javascripts/lib/CodeMirror/oldrelease.html +178 -0
  100. data/app/javascripts/lib/CodeMirror/test/index.html +29 -0
  101. data/app/javascripts/lib/CodeMirror/test/test.js +249 -0
  102. data/app/javascripts/lib/CodeMirror/theme/default.css +18 -0
  103. data/app/javascripts/lib/CodeMirror/theme/elegant.css +9 -0
  104. data/app/javascripts/lib/CodeMirror/theme/jtalk.css +21 -0
  105. data/app/javascripts/lib/CodeMirror/theme/neat.css +8 -0
  106. data/app/javascripts/lib/CodeMirror/theme/night.css +20 -0
  107. data/app/javascripts/lib/jQuery/jquery-1.4.4.min.js +167 -0
  108. data/app/javascripts/lib/jQuery/jquery-ui-1.8.9.custom.min.js +781 -0
  109. data/app/javascripts/lib/jQuery/jquery.textarea.js +267 -0
  110. data/app/smalltalk/Canvas.st +481 -0
  111. data/app/smalltalk/IDE.st +1752 -0
  112. data/config.ru +2 -0
  113. data/lib/amber-rack.rb +4 -0
  114. data/lib/amber-rack/version.rb +3 -0
  115. data/public/CodeMirror/LICENSE +19 -0
  116. data/public/CodeMirror/README.md +6 -0
  117. data/public/CodeMirror/compress.html +92 -0
  118. data/public/CodeMirror/css/baboon.png +0 -0
  119. data/public/CodeMirror/css/baboon_vector.svg +153 -0
  120. data/public/CodeMirror/css/docs.css +154 -0
  121. data/public/CodeMirror/demo/activeline.html +72 -0
  122. data/public/CodeMirror/demo/changemode.html +51 -0
  123. data/public/CodeMirror/demo/complete.html +79 -0
  124. data/public/CodeMirror/demo/complete.js +151 -0
  125. data/public/CodeMirror/demo/fullscreen.html +158 -0
  126. data/public/CodeMirror/demo/marker.html +53 -0
  127. data/public/CodeMirror/demo/mustache.html +57 -0
  128. data/public/CodeMirror/demo/preview.html +75 -0
  129. data/public/CodeMirror/demo/resize.html +44 -0
  130. data/public/CodeMirror/demo/runmode.html +50 -0
  131. data/public/CodeMirror/demo/search.html +106 -0
  132. data/public/CodeMirror/demo/theme.html +53 -0
  133. data/public/CodeMirror/index.html +239 -0
  134. data/public/CodeMirror/internals.html +389 -0
  135. data/public/CodeMirror/lib/codemirror.css +67 -0
  136. data/public/CodeMirror/lib/codemirror.js +2144 -0
  137. data/public/CodeMirror/lib/overlay.js +51 -0
  138. data/public/CodeMirror/lib/runmode.js +27 -0
  139. data/public/CodeMirror/manual.html +854 -0
  140. data/public/CodeMirror/mode/clike/clike.js +247 -0
  141. data/public/CodeMirror/mode/clike/index.html +102 -0
  142. data/public/CodeMirror/mode/css/css.js +124 -0
  143. data/public/CodeMirror/mode/css/index.html +56 -0
  144. data/public/CodeMirror/mode/diff/diff.css +3 -0
  145. data/public/CodeMirror/mode/diff/diff.js +13 -0
  146. data/public/CodeMirror/mode/diff/index.html +99 -0
  147. data/public/CodeMirror/mode/haskell/haskell.js +242 -0
  148. data/public/CodeMirror/mode/haskell/index.html +60 -0
  149. data/public/CodeMirror/mode/htmlmixed/htmlmixed.js +79 -0
  150. data/public/CodeMirror/mode/htmlmixed/index.html +52 -0
  151. data/public/CodeMirror/mode/javascript/index.html +78 -0
  152. data/public/CodeMirror/mode/javascript/javascript.js +348 -0
  153. data/public/CodeMirror/mode/lua/index.html +72 -0
  154. data/public/CodeMirror/mode/lua/lua.js +138 -0
  155. data/public/CodeMirror/mode/php/index.html +49 -0
  156. data/public/CodeMirror/mode/php/php.js +110 -0
  157. data/public/CodeMirror/mode/plsql/index.html +63 -0
  158. data/public/CodeMirror/mode/plsql/plsql.js +217 -0
  159. data/public/CodeMirror/mode/python/LICENSE.txt +21 -0
  160. data/public/CodeMirror/mode/python/index.html +123 -0
  161. data/public/CodeMirror/mode/python/python.js +321 -0
  162. data/public/CodeMirror/mode/rst/index.html +526 -0
  163. data/public/CodeMirror/mode/rst/rst.css +75 -0
  164. data/public/CodeMirror/mode/rst/rst.js +333 -0
  165. data/public/CodeMirror/mode/scheme/index.html +65 -0
  166. data/public/CodeMirror/mode/scheme/scheme.js +181 -0
  167. data/public/CodeMirror/mode/smalltalk/index.html +56 -0
  168. data/public/CodeMirror/mode/smalltalk/smalltalk.js +134 -0
  169. data/public/CodeMirror/mode/sparql/index.html +41 -0
  170. data/public/CodeMirror/mode/sparql/sparql.js +143 -0
  171. data/public/CodeMirror/mode/stex/index.html +96 -0
  172. data/public/CodeMirror/mode/stex/stex.js +167 -0
  173. data/public/CodeMirror/mode/xml/index.html +42 -0
  174. data/public/CodeMirror/mode/xml/xml.js +231 -0
  175. data/public/CodeMirror/mode/yaml/index.html +68 -0
  176. data/public/CodeMirror/mode/yaml/yaml.js +95 -0
  177. data/public/CodeMirror/oldrelease.html +178 -0
  178. data/public/CodeMirror/test/index.html +29 -0
  179. data/public/CodeMirror/test/test.js +249 -0
  180. data/public/CodeMirror/theme/default.css +18 -0
  181. data/public/CodeMirror/theme/elegant.css +9 -0
  182. data/public/CodeMirror/theme/jtalk.css +21 -0
  183. data/public/CodeMirror/theme/neat.css +8 -0
  184. data/public/CodeMirror/theme/night.css +20 -0
  185. data/public/css/jtalk.css +362 -0
  186. data/public/css/style.css +456 -0
  187. data/public/css/sunit.css +66 -0
  188. data/public/ide/fork_me.png +0 -0
  189. data/public/ide/screen2.png +0 -0
  190. data/public/ide/style.css +456 -0
  191. data/public/ide/syntax.css +61 -0
  192. data/public/ide/text_header.png +0 -0
  193. data/public/ide/title_container1.png +0 -0
  194. data/public/images/background_box.png +0 -0
  195. data/public/images/background_header.png +0 -0
  196. data/public/images/balloon_header.png +0 -0
  197. data/views/index.haml +66 -0
  198. metadata +341 -0
@@ -0,0 +1,68 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>CodeMirror 2: YAML mode</title>
5
+ <link rel="stylesheet" href="../../lib/codemirror.css">
6
+ <script src="../../lib/codemirror.js"></script>
7
+ <script src="yaml.js"></script>
8
+ <link rel="stylesheet" href="../../theme/default.css">
9
+ <style>.CodeMirror { border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; }</style>
10
+ <link rel="stylesheet" href="../../css/docs.css">
11
+ </head>
12
+ <body>
13
+ <h1>CodeMirror 2: YAML mode</h1>
14
+ <form><textarea id="code" name="code">
15
+ --- # Favorite movies
16
+ - Casablanca
17
+ - North by Northwest
18
+ - The Man Who Wasn't There
19
+ --- # Shopping list
20
+ [milk, pumpkin pie, eggs, juice]
21
+ --- # Indented Blocks, common in YAML data files, use indentation and new lines to separate the key: value pairs
22
+ name: John Smith
23
+ age: 33
24
+ --- # Inline Blocks, common in YAML data streams, use commas to separate the key: value pairs between braces
25
+ {name: John Smith, age: 33}
26
+ ---
27
+ receipt: Oz-Ware Purchase Invoice
28
+ date: 2007-08-06
29
+ customer:
30
+ given: Dorothy
31
+ family: Gale
32
+
33
+ items:
34
+ - part_no: A4786
35
+ descrip: Water Bucket (Filled)
36
+ price: 1.47
37
+ quantity: 4
38
+
39
+ - part_no: E1628
40
+ descrip: High Heeled "Ruby" Slippers
41
+ size: 8
42
+ price: 100.27
43
+ quantity: 1
44
+
45
+ bill-to: &id001
46
+ street: |
47
+ 123 Tornado Alley
48
+ Suite 16
49
+ city: East Centerville
50
+ state: KS
51
+
52
+ ship-to: *id001
53
+
54
+ specialDelivery: >
55
+ Follow the Yellow Brick
56
+ Road to the Emerald City.
57
+ Pay no attention to the
58
+ man behind the curtain.
59
+ ...
60
+ </textarea></form>
61
+ <script>
62
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
63
+ </script>
64
+
65
+ <p><strong>MIME types defined:</strong> <code>text/x-yaml</code>.</p>
66
+
67
+ </body>
68
+ </html>
@@ -0,0 +1,95 @@
1
+ CodeMirror.defineMode("yaml", function() {
2
+
3
+ var cons = ['true', 'false', 'on', 'off', 'yes', 'no'];
4
+ var keywordRegex = new RegExp("\\b(("+cons.join(")|(")+"))$", 'i');
5
+
6
+ return {
7
+ token: function(stream, state) {
8
+ var ch = stream.peek();
9
+ var esc = state.escaped;
10
+ state.escaped = false;
11
+ /* comments */
12
+ if (ch == "#") { stream.skipToEnd(); return "comment"; }
13
+ if (state.literal && stream.indentation() > state.keyCol) {
14
+ stream.skipToEnd(); return "string";
15
+ } else if (state.literal) { state.literal = false; }
16
+ if (stream.sol()) {
17
+ state.keyCol = 0;
18
+ state.pair = false;
19
+ state.pairStart = false;
20
+ /* document start */
21
+ if(stream.match(/---/)) { return "def"; }
22
+ /* document end */
23
+ if (stream.match(/\.\.\./)) { return "def"; }
24
+ /* array list item */
25
+ if (stream.match(/\s*-\s+/)) { return 'meta'; }
26
+ }
27
+ /* pairs (associative arrays) -> key */
28
+ if (!state.pair && stream.match(/^\s*([a-z0-9\._-])+(?=\s*:)/i)) {
29
+ state.pair = true;
30
+ state.keyCol = stream.indentation();
31
+ return "atom";
32
+ }
33
+ if (state.pair && stream.match(/^:\s*/)) { state.pairStart = true; return 'meta'; }
34
+
35
+ /* inline pairs/lists */
36
+ if (stream.match(/^(\{|\}|\[|\])/)) {
37
+ if (ch == '{')
38
+ state.inlinePairs++;
39
+ else if (ch == '}')
40
+ state.inlinePairs--;
41
+ else if (ch == '[')
42
+ state.inlineList++;
43
+ else
44
+ state.inlineList--;
45
+ return 'meta';
46
+ }
47
+
48
+ /* list seperator */
49
+ if (state.inlineList > 0 && !esc && ch == ',') {
50
+ stream.next();
51
+ return 'meta';
52
+ }
53
+ /* pairs seperator */
54
+ if (state.inlinePairs > 0 && !esc && ch == ',') {
55
+ state.keyCol = 0;
56
+ state.pair = false;
57
+ state.pairStart = false;
58
+ stream.next();
59
+ return 'meta';
60
+ }
61
+
62
+ /* start of value of a pair */
63
+ if (state.pairStart) {
64
+ /* block literals */
65
+ if (stream.match(/^\s*(\||\>)\s*/)) { state.literal = true; return 'meta'; };
66
+ /* references */
67
+ if (stream.match(/^\s*(\&|\*)[a-z0-9\._-]+\b/i)) { return 'variable-2'; }
68
+ /* numbers */
69
+ if (state.inlinePairs == 0 && stream.match(/^\s*-?[0-9\.\,]+\s?$/)) { return 'number'; }
70
+ if (state.inlinePairs > 0 && stream.match(/^\s*-?[0-9\.\,]+\s?(?=(,|}))/)) { return 'number'; }
71
+ /* keywords */
72
+ if (stream.match(keywordRegex)) { return 'keyword'; }
73
+ }
74
+
75
+ /* nothing found, continue */
76
+ state.pairStart = false;
77
+ state.escaped = (ch == '\\');
78
+ stream.next();
79
+ return null;
80
+ },
81
+ startState: function() {
82
+ return {
83
+ pair: false,
84
+ pairStart: false,
85
+ keyCol: 0,
86
+ inlinePairs: 0,
87
+ inlineList: 0,
88
+ literal: false,
89
+ escaped: false
90
+ };
91
+ }
92
+ };
93
+ });
94
+
95
+ CodeMirror.defineMIME("text/x-yaml", "yaml");
@@ -0,0 +1,178 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>CodeMirror</title>
5
+ <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Droid+Sans|Droid+Sans:bold"/>
6
+ <link rel="stylesheet" type="text/css" href="css/docs.css"/>
7
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
8
+ <link rel="alternate" href="http://twitter.com/statuses/user_timeline/242283288.rss" type="application/rss+xml"/>
9
+ </head>
10
+ <body>
11
+
12
+ <h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMirror</a></h1>
13
+
14
+ <pre class="grey">
15
+ <img src="css/baboon.png" class="logo" alt="logo"/>/* Old release history */
16
+
17
+ </pre>
18
+
19
+ <p class="rel">28-03-2011: <a href="http://codemirror.net/codemirror-2.0.zip">Version 2.0</a>:</p>
20
+ <p class="rel-note">CodeMirror 2 is a complete rewrite that's
21
+ faster, smaller, simpler to use, and less dependent on browser
22
+ quirks. See <a href="internals.html">this</a>
23
+ and <a href="http://groups.google.com/group/codemirror/browse_thread/thread/5a8e894024a9f580">this</a>
24
+ for more information.</a>
25
+
26
+ <p class="rel">28-03-2011: <a href="http://codemirror.net/codemirror-1.0.zip">Version 1.0</a>:</p>
27
+ <ul class="rel-note">
28
+ <li>Fix error when debug history overflows.</li>
29
+ <li>Refine handling of C# verbatim strings.</li>
30
+ <li>Fix some issues with JavaScript indentation.</li>
31
+ </ul>
32
+
33
+ <p class="rel">22-02-2011: <a href="https://github.com/marijnh/codemirror2/tree/beta2">Version 2.0 beta 2</a>:</p>
34
+ <p class="rel-note">Somewhate more mature API, lots of bugs shaken out.</a>
35
+
36
+ <p class="rel">17-02-2011: <a href="http://codemirror.net/codemirror-0.94.zip">Version 0.94</a>:</p>
37
+ <ul class="rel-note">
38
+ <li><code>tabMode: "spaces"</code> was modified slightly (now indents when something is selected).</li>
39
+ <li>Fixes a bug that would cause the selection code to break on some IE versions.</li>
40
+ <li>Disabling spell-check on WebKit browsers now works.</li>
41
+ </ul>
42
+
43
+ <p class="rel">08-02-2011: <a href="http://codemirror.net/2/">Version 2.0 beta 1</a>:</p>
44
+ <p class="rel-note">CodeMirror 2 is a complete rewrite of
45
+ CodeMirror, no longer depending on an editable frame.</p>
46
+
47
+ <p class="rel">19-01-2011: <a href="http://codemirror.net/codemirror-0.93.zip">Version 0.93</a>:</p>
48
+ <ul class="rel-note">
49
+ <li>Added a <a href="contrib/regex/index.html">Regular Expression</a> parser.</li>
50
+ <li>Fixes to the PHP parser.</li>
51
+ <li>Support for regular expression in search/replace.</li>
52
+ <li>Add <code>save</code> method to instances created with <code>fromTextArea</code>.</li>
53
+ <li>Add support for MS T-SQL in the SQL parser.</li>
54
+ <li>Support use of CSS classes for highlighting brackets.</li>
55
+ <li>Fix yet another hang with line-numbering in hidden editors.</li>
56
+ </ul>
57
+
58
+ <p class="rel">17-12-2010: <a href="http://codemirror.net/codemirror-0.92.zip">Version 0.92</a>:</p>
59
+ <ul class="rel-note">
60
+ <li>Make CodeMirror work in XHTML documents.</li>
61
+ <li>Fix bug in handling of backslashes in Python strings.</li>
62
+ <li>The <code>styleNumbers</code> option is now officially
63
+ supported and documented.</li>
64
+ <li><code>onLineNumberClick</code> option added.</li>
65
+ <li>More consistent names <code>onLoad</code> and
66
+ <code>onCursorActivity</code> callbacks. Old names still work, but
67
+ are deprecated.</li>
68
+ <li>Add a <a href="contrib/freemarker/index.html">Freemarker</a> mode.</li>
69
+ </ul>
70
+
71
+ <p class="rel">11-11-2010: <a
72
+ href="http://codemirror.net/codemirror-0.91.zip">Version 0.91</a>:</p>
73
+ <ul class="rel-note">
74
+ <li>Adds support for <a href="contrib/java">Java</a>.</li>
75
+ <li>Small additions to the <a href="contrib/php">PHP</a> and <a href="contrib/sql">SQL</a> parsers.</li>
76
+ <li>Work around various <a href="https://bugs.webkit.org/show_bug.cgi?id=47806">Webkit</a> <a href="https://bugs.webkit.org/show_bug.cgi?id=23474">issues</a>.</li>
77
+ <li>Fix <code>toTextArea</code> to update the code in the textarea.</li>
78
+ <li>Add a <code>noScriptCaching</code> option (hack to ease development).</li>
79
+ <li>Make sub-modes of <a href="mixedtest.html">HTML mixed</a> mode configurable.</li>
80
+ </ul>
81
+
82
+ <p class="rel">02-10-2010: <a
83
+ href="http://codemirror.net/codemirror-0.9.zip">Version 0.9</a>:</p>
84
+ <ul class="rel-note">
85
+ <li>Add support for searching backwards.</li>
86
+ <li>There are now parsers for <a href="contrib/scheme/index.html">Scheme</a>, <a href="contrib/xquery/index.html">XQuery</a>, and <a href="contrib/ometa/index.html">OmetaJS</a>.</li>
87
+ <li>Makes <code>height: "dynamic"</code> more robust.</li>
88
+ <li>Fixes bug where paste did not work on OS X.</li>
89
+ <li>Add a <code>enterMode</code> and <code>electricChars</code> options to make indentation even more customizable.</li>
90
+ <li>Add <code>firstLineNumber</code> option.</li>
91
+ <li>Fix bad handling of <code>@media</code> rules by the CSS parser.</li>
92
+ <li>Take a new, more robust approach to working around the invisible-last-line bug in WebKit.</li>
93
+ </ul>
94
+
95
+ <p class="rel">22-07-2010: <a
96
+ href="http://codemirror.net/codemirror-0.8.zip">Version 0.8</a>:</p>
97
+ <ul class="rel-note">
98
+ <li>Add a <code>cursorCoords</code> method to find the screen
99
+ coordinates of the cursor.</li>
100
+ <li>A number of fixes and support for more syntax in the PHP parser.</li>
101
+ <li>Fix indentation problem with JSON-mode JS parser in Webkit.</li>
102
+ <li>Add a <a href="compress.html">minification</a> UI.</li>
103
+ <li>Support a <code>height: dynamic</code> mode, where the editor's
104
+ height will adjust to the size of its content.</li>
105
+ <li>Better support for IME input mode.</li>
106
+ <li>Fix JavaScript parser getting confused when seeing a no-argument
107
+ function call.</li>
108
+ <li>Have CSS parser see the difference between selectors and other
109
+ identifiers.</li>
110
+ <li>Fix scrolling bug when pasting in a horizontally-scrolled
111
+ editor.</li>
112
+ <li>Support <code>toTextArea</code> method in instances created with
113
+ <code>fromTextArea</code>.</li>
114
+ <li>Work around new Opera cursor bug that causes the cursor to jump
115
+ when pressing backspace at the end of a line.</li>
116
+ </ul>
117
+
118
+ <p class="rel">27-04-2010: <a
119
+ href="http://codemirror.net/codemirror-0.67.zip">Version
120
+ 0.67</a>:</p>
121
+ <p class="rel-note">More consistent page-up/page-down behaviour
122
+ across browsers. Fix some issues with hidden editors looping forever
123
+ when line-numbers were enabled. Make PHP parser parse
124
+ <code>"\\"</code> correctly. Have <code>jumpToLine</code> work on
125
+ line handles, and add <code>cursorLine</code> function to fetch the
126
+ line handle where the cursor currently is. Add new
127
+ <code>setStylesheet</code> function to switch style-sheets in a
128
+ running editor.</p>
129
+
130
+ <p class="rel">01-03-2010: <a
131
+ href="http://codemirror.net/codemirror-0.66.zip">Version
132
+ 0.66</a>:</p>
133
+ <p class="rel-note">Adds <code>removeLine</code> method to API.
134
+ Introduces the <a href="contrib/plsql/index.html">PLSQL parser</a>.
135
+ Marks XML errors by adding (rather than replacing) a CSS class, so
136
+ that they can be disabled by modifying their style. Fixes several
137
+ selection bugs, and a number of small glitches.</p>
138
+
139
+ <p class="rel">12-11-2009: <a
140
+ href="http://codemirror.net/codemirror-0.65.zip">Version
141
+ 0.65</a>:</p>
142
+ <p class="rel-note">Add support for having both line-wrapping and
143
+ line-numbers turned on, make paren-highlighting style customisable
144
+ (<code>markParen</code> and <code>unmarkParen</code> config
145
+ options), work around a selection bug that Opera
146
+ <em>re</em>introduced in version 10.</p>
147
+
148
+ <p class="rel">23-10-2009: <a
149
+ href="http://codemirror.net/codemirror-0.64.zip">Version
150
+ 0.64</a>:</p>
151
+ <p class="rel-note">Solves some issues introduced by the
152
+ paste-handling changes from the previous release. Adds
153
+ <code>setSpellcheck</code>, <code>setTextWrapping</code>,
154
+ <code>setIndentUnit</code>, <code>setUndoDepth</code>,
155
+ <code>setTabMode</code>, and <code>setLineNumbers</code> to
156
+ customise a running editor. Introduces an <a
157
+ href="contrib/sql/index.html">SQL</a> parser. Fixes a few small
158
+ problems in the <a href="contrib/python/index.html">Python</a>
159
+ parser. And, as usual, add workarounds for various newly discovered
160
+ browser incompatibilities.</p>
161
+
162
+ <p class="rel"><em>31-08-2009</em>: <a
163
+ href="http://codemirror.net/codemirror-0.63.zip">Version
164
+ 0.63</a>:</p>
165
+ <p class="rel-note"> Overhaul of paste-handling (less fragile), fixes for several
166
+ serious IE8 issues (cursor jumping, end-of-document bugs) and a number
167
+ of small problems.</p>
168
+
169
+ <p class="rel"><em>30-05-2009</em>: <a
170
+ href="http://codemirror.net/codemirror-0.62.zip">Version
171
+ 0.62</a>:</p>
172
+ <p class="rel-note">Introduces <a href="contrib/python/index.html">Python</a>
173
+ and <a href="contrib/lua/index.html">Lua</a> parsers. Add
174
+ <code>setParser</code> (on-the-fly mode changing) and
175
+ <code>clearHistory</code> methods. Make parsing passes time-based
176
+ instead of lines-based (see the <code>passTime</code> option).</p>
177
+
178
+ </body></html>
@@ -0,0 +1,29 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>CodeMirror 2: Test Suite</title>
5
+ <link rel="stylesheet" href="../lib/codemirror.css">
6
+ <script src="../lib/codemirror.js"></script>
7
+ <link rel="stylesheet" href="../theme/default.css">
8
+ <script src="../mode/javascript/javascript.js"></script>
9
+
10
+ <style type="text/css">
11
+ .ok {color: #0e0;}
12
+ .failure {color: #e00;}
13
+ .error {color: #c90;}
14
+ </style>
15
+ </head>
16
+ <body>
17
+ <h1>CodeMirror 2: Test Suite</h1>
18
+
19
+ <p>A limited set of programmatic sanity tests for CodeMirror.</p>
20
+
21
+ <pre id=output></pre>
22
+
23
+ <div style="visibility: hidden" id=testground>
24
+ <form><textarea id="code" name="code"></textarea><input type=submit value=ok name=submit></form>
25
+ </div>
26
+
27
+ <script src="test.js"></script>
28
+ </body>
29
+ </html>
@@ -0,0 +1,249 @@
1
+ var tests = [];
2
+
3
+ test("fromTextArea", function() {
4
+ var te = document.getElementById("code");
5
+ te.value = "CONTENT";
6
+ var cm = CodeMirror.fromTextArea(te);
7
+ is(!te.offsetHeight);
8
+ eq(cm.getValue(), "CONTENT");
9
+ cm.setValue("foo\nbar");
10
+ eq(cm.getValue(), "foo\nbar");
11
+ cm.save();
12
+ is(/^foo\r?\nbar$/.test(te.value));
13
+ cm.setValue("xxx");
14
+ cm.toTextArea();
15
+ is(te.offsetHeight);
16
+ eq(te.value, "xxx");
17
+ });
18
+
19
+ testCM("getRange", function(cm) {
20
+ eq(cm.getLine(0), "1234");
21
+ eq(cm.getLine(1), "5678");
22
+ eq(cm.getLine(2), null);
23
+ eq(cm.getLine(-1), null);
24
+ eq(cm.getRange({line: 0, ch: 0}, {line: 0, ch: 3}), "123");
25
+ eq(cm.getRange({line: 0, ch: -1}, {line: 0, ch: 200}), "1234");
26
+ eq(cm.getRange({line: 0, ch: 2}, {line: 1, ch: 2}), "34\n56");
27
+ eq(cm.getRange({line: 1, ch: 2}, {line: 100, ch: 0}), "78");
28
+ }, {value: "1234\n5678"});
29
+
30
+ testCM("replaceRange", function(cm) {
31
+ eq(cm.getValue(), "");
32
+ cm.replaceRange("foo\n", {line: 0, ch: 0});
33
+ eq(cm.getValue(), "foo\n");
34
+ cm.replaceRange("a\nb", {line: 0, ch: 1});
35
+ eq(cm.getValue(), "fa\nboo\n");
36
+ eq(cm.lineCount(), 3);
37
+ cm.replaceRange("xyzzy", {line: 0, ch: 0}, {line: 1, ch: 1});
38
+ eq(cm.getValue(), "xyzzyoo\n");
39
+ cm.replaceRange("abc", {line: 0, ch: 0}, {line: 10, ch: 0});
40
+ eq(cm.getValue(), "abc");
41
+ eq(cm.lineCount(), 1);
42
+ });
43
+
44
+ testCM("selection", function(cm) {
45
+ cm.setSelection({line: 0, ch: 4}, {line: 2, ch: 2});
46
+ is(cm.somethingSelected());
47
+ eq(cm.getSelection(), "11\n222222\n33");
48
+ eqPos(cm.getCursor(false), {line: 2, ch: 2});
49
+ eqPos(cm.getCursor(true), {line: 0, ch: 4});
50
+ cm.setSelection({line: 1, ch: 0});
51
+ is(!cm.somethingSelected());
52
+ eq(cm.getSelection(), "");
53
+ eqPos(cm.getCursor(true), {line: 1, ch: 0});
54
+ cm.replaceSelection("abc");
55
+ eq(cm.getSelection(), "abc");
56
+ eq(cm.getValue(), "111111\nabc222222\n333333");
57
+ cm.replaceSelection("def", "end");
58
+ eq(cm.getSelection(), "");
59
+ eqPos(cm.getCursor(true), {line: 1, ch: 3});
60
+ cm.setCursor({line: 2, ch: 1});
61
+ eqPos(cm.getCursor(true), {line: 2, ch: 1});
62
+ cm.setCursor(1, 2);
63
+ eqPos(cm.getCursor(true), {line: 1, ch: 2});
64
+ }, {value: "111111\n222222\n333333"});
65
+
66
+ testCM("lines", function(cm) {
67
+ eq(cm.getLine(0), "111111");
68
+ eq(cm.getLine(1), "222222");
69
+ eq(cm.getLine(-1), null);
70
+ cm.removeLine(1);
71
+ cm.setLine(1, "abc");
72
+ eq(cm.getValue(), "111111\nabc");
73
+ }, {value: "111111\n222222\n333333"});
74
+
75
+ testCM("indent", function(cm) {
76
+ cm.indentLine(1);
77
+ eq(cm.getLine(1), " blah();");
78
+ cm.setOption("indentUnit", 8);
79
+ cm.indentLine(1);
80
+ eq(cm.getLine(1), "\tblah();");
81
+ }, {value: "if (x) {\nblah();\n}", indentUnit: 3, indentWithTabs: true});
82
+
83
+ test("defaults", function() {
84
+ var olddefaults = CodeMirror.defaults, defs = CodeMirror.defaults = {};
85
+ for (var opt in olddefaults) defs[opt] = olddefaults[opt];
86
+ defs.indentUnit = 5;
87
+ defs.value = "uu";
88
+ defs.enterMode = "keep";
89
+ defs.tabindex = 55;
90
+ var place = document.getElementById("testground"), cm = CodeMirror(place);
91
+ try {
92
+ eq(cm.getOption("indentUnit"), 5);
93
+ cm.setOption("indentUnit", 10);
94
+ eq(defs.indentUnit, 5);
95
+ eq(cm.getValue(), "uu");
96
+ eq(cm.getOption("enterMode"), "keep");
97
+ eq(cm.getInputField().tabindex, 55);
98
+ }
99
+ finally {
100
+ CodeMirror.defaults = olddefaults;
101
+ place.removeChild(cm.getWrapperElement());
102
+ }
103
+ });
104
+
105
+ testCM("lineInfo", function(cm) {
106
+ eq(cm.lineInfo(-1), null);
107
+ var lh = cm.setMarker(1, "FOO", "bar");
108
+ var info = cm.lineInfo(1);
109
+ eq(info.text, "222222");
110
+ eq(info.markerText, "FOO");
111
+ eq(info.markerClass, "bar");
112
+ eq(info.line, 1);
113
+ eq(cm.lineInfo(2).markerText, null);
114
+ cm.clearMarker(lh);
115
+ eq(cm.lineInfo(1).markerText, null);
116
+ }, {value: "111111\n222222\n333333"});
117
+
118
+ testCM("coords", function(cm) {
119
+ var scroller = cm.getWrapperElement().getElementsByClassName("CodeMirror-scroll")[0];
120
+ scroller.style.height = "100px";
121
+ var content = [];
122
+ for (var i = 0; i < 200; ++i) content.push("------------------------------" + i);
123
+ cm.setValue(content.join("\n"));
124
+ var top = cm.charCoords({line: 0, ch: 0});
125
+ var bot = cm.charCoords({line: 200, ch: 30});
126
+ is(top.x < bot.x);
127
+ is(top.y < bot.y);
128
+ is(top.y < top.yBot);
129
+ scroller.scrollTop = 100;
130
+ cm.refresh();
131
+ var top2 = cm.charCoords({line: 0, ch: 0});
132
+ is(top.y > top2.y);
133
+ eq(top.x, top2.x);
134
+ });
135
+
136
+ testCM("coordsChar", function(cm) {
137
+ var content = [];
138
+ for (var i = 0; i < 70; ++i) content.push("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
139
+ cm.setValue(content.join("\n"));
140
+ for (var x = 0; x < 35; x += 2) {
141
+ for (var y = 0; y < 70; y += 5) {
142
+ cm.setCursor(y, x);
143
+ var pos = cm.coordsChar(cm.charCoords({line: y, ch: x}));
144
+ eq(pos.line, y);
145
+ eq(pos.ch, x);
146
+ }
147
+ }
148
+ });
149
+
150
+ testCM("undo", function(cm) {
151
+ cm.setLine(0, "def");
152
+ eq(cm.historySize().undo, 1);
153
+ cm.undo();
154
+ eq(cm.getValue(), "abc");
155
+ eq(cm.historySize().undo, 0);
156
+ eq(cm.historySize().redo, 1);
157
+ cm.redo();
158
+ eq(cm.getValue(), "def");
159
+ eq(cm.historySize().undo, 1);
160
+ eq(cm.historySize().redo, 0);
161
+ cm.setValue("1\n\n\n2");
162
+ eq(cm.historySize().undo, 0);
163
+ for (var i = 0; i < 20; ++i) {
164
+ cm.replaceRange("a", {line: 0, ch: 0});
165
+ cm.replaceRange("b", {line: 3, ch: 0});
166
+ }
167
+ eq(cm.historySize().undo, 40);
168
+ for (var i = 0; i < 38; ++i) cm.undo();
169
+ eq(cm.historySize().undo, 2);
170
+ eq(cm.historySize().redo, 38);
171
+ eq(cm.getValue(), "a1\n\n\nb2");
172
+ cm.setOption("undoDepth", 10);
173
+ for (var i = 0; i < 20; ++i) {
174
+ cm.replaceRange("a", {line: 0, ch: 0});
175
+ cm.replaceRange("b", {line: 3, ch: 0});
176
+ }
177
+ eq(cm.historySize().undo, 10);
178
+ }, {value: "abc"});
179
+
180
+ testCM("undoMultiLine", function(cm) {
181
+ cm.replaceRange("x", {line:0, ch: 0});
182
+ cm.replaceRange("y", {line:1, ch: 0});
183
+ cm.undo();
184
+ eq(cm.getValue(), "abc\ndef\nghi");
185
+ cm.replaceRange("y", {line:1, ch: 0});
186
+ cm.replaceRange("x", {line:0, ch: 0});
187
+ cm.undo();
188
+ eq(cm.getValue(), "abc\ndef\nghi");
189
+ cm.replaceRange("y", {line:2, ch: 0});
190
+ cm.replaceRange("x", {line:1, ch: 0});
191
+ cm.replaceRange("z", {line:2, ch: 0});
192
+ cm.undo();
193
+ eq(cm.getValue(), "abc\ndef\nghi");
194
+ }, {value: "abc\ndef\nghi"});
195
+
196
+ // Scaffolding
197
+
198
+ function htmlEscape(str) {
199
+ return str.replace(/[<&]/g, function(str) {return str == "&" ? "&amp;" : "&lt;";});
200
+ }
201
+ function forEach(arr, f) {
202
+ for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
203
+ }
204
+
205
+ function Failure(why) {this.message = why;}
206
+
207
+ function test(name, run) {tests.push({name: name, func: run});}
208
+ function testCM(name, run, opts) {
209
+ test(name, function() {
210
+ var place = document.getElementById("testground"), cm = CodeMirror(place, opts);
211
+ try {run(cm);}
212
+ finally {place.removeChild(cm.getWrapperElement());}
213
+ });
214
+ }
215
+
216
+ function runTests() {
217
+ var failures = [], run = 0;
218
+ for (var i = 0; i < tests.length; ++i) {
219
+ var test = tests[i];
220
+ try {test.func();}
221
+ catch(e) {
222
+ if (e instanceof Failure)
223
+ failures.push({type: "failure", test: test.name, text: e.message});
224
+ else
225
+ failures.push({type: "error", test: test.name, text: e.toString()});
226
+ }
227
+ run++;
228
+ }
229
+ var html = [run + " tests run."];
230
+ if (failures.length)
231
+ forEach(failures, function(fail) {
232
+ html.push(fail.test + ': <span class="' + fail.type + '">' + htmlEscape(fail.text) + "</span>");
233
+ });
234
+ else html.push('<span class="ok">All passed.</span>');
235
+ document.getElementById("output").innerHTML = html.join("\n");
236
+ }
237
+
238
+ function eq(a, b, msg) {
239
+ if (a != b) throw new Failure(a + " != " + b + (msg ? " (" + msg + ")" : ""));
240
+ }
241
+ function eqPos(a, b, msg) {
242
+ eq(a.line, b.line, msg);
243
+ eq(a.ch, b.ch, msg);
244
+ }
245
+ function is(a, msg) {
246
+ if (!a) throw new Failure("assertion failed" + (msg ? " (" + msg + ")" : ""));
247
+ }
248
+
249
+ window.onload = runTests;