AmberRack 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,151 @@
1
+ (function () {
2
+ // Minimal event-handling wrapper.
3
+ function stopEvent() {
4
+ if (this.preventDefault) {this.preventDefault(); this.stopPropagation();}
5
+ else {this.returnValue = false; this.cancelBubble = true;}
6
+ }
7
+ function addStop(event) {
8
+ if (!event.stop) event.stop = stopEvent;
9
+ return event;
10
+ }
11
+ function connect(node, type, handler) {
12
+ function wrapHandler(event) {handler(addStop(event || window.event));}
13
+ if (typeof node.addEventListener == "function")
14
+ node.addEventListener(type, wrapHandler, false);
15
+ else
16
+ node.attachEvent("on" + type, wrapHandler);
17
+ }
18
+
19
+ function forEach(arr, f) {
20
+ for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
21
+ }
22
+
23
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
24
+ lineNumbers: true,
25
+ theme: "night",
26
+ onKeyEvent: function(i, e) {
27
+ // Hook into ctrl-space
28
+ if (e.keyCode == 32 && (e.ctrlKey || e.metaKey) && !e.altKey) {
29
+ e.stop();
30
+ return startComplete();
31
+ }
32
+ }
33
+ });
34
+
35
+ function startComplete() {
36
+ // We want a single cursor position.
37
+ if (editor.somethingSelected()) return;
38
+ // Find the token at the cursor
39
+ var cur = editor.getCursor(false), token = editor.getTokenAt(cur), tprop = token;
40
+ // If it's not a 'word-style' token, ignore the token.
41
+ if (!/^[\w$_]*$/.test(token.string)) {
42
+ token = tprop = {start: cur.ch, end: cur.ch, string: "", state: token.state,
43
+ className: token.string == "." ? "js-property" : null};
44
+ }
45
+ // If it is a property, find out what it is a property of.
46
+ while (tprop.className == "js-property") {
47
+ tprop = editor.getTokenAt({line: cur.line, ch: tprop.start});
48
+ if (tprop.string != ".") return;
49
+ tprop = editor.getTokenAt({line: cur.line, ch: tprop.start});
50
+ if (!context) var context = [];
51
+ context.push(tprop);
52
+ }
53
+ var completions = getCompletions(token, context);
54
+ if (!completions.length) return;
55
+ function insert(str) {
56
+ editor.replaceRange(str, {line: cur.line, ch: token.start}, {line: cur.line, ch: token.end});
57
+ }
58
+ // When there is only one completion, use it directly.
59
+ if (completions.length == 1) {insert(completions[0]); return true;}
60
+
61
+ // Build the select widget
62
+ var complete = document.createElement("div");
63
+ complete.className = "completions";
64
+ var sel = complete.appendChild(document.createElement("select"));
65
+ sel.multiple = true;
66
+ for (var i = 0; i < completions.length; ++i) {
67
+ var opt = sel.appendChild(document.createElement("option"));
68
+ opt.appendChild(document.createTextNode(completions[i]));
69
+ }
70
+ sel.firstChild.selected = true;
71
+ sel.size = Math.min(10, completions.length);
72
+ var pos = editor.cursorCoords();
73
+ complete.style.left = pos.x + "px";
74
+ complete.style.top = pos.yBot + "px";
75
+ document.body.appendChild(complete);
76
+ // Hack to hide the scrollbar.
77
+ if (completions.length <= 10)
78
+ complete.style.width = (sel.clientWidth - 1) + "px";
79
+
80
+ var done = false;
81
+ function close() {
82
+ if (done) return;
83
+ done = true;
84
+ complete.parentNode.removeChild(complete);
85
+ }
86
+ function pick() {
87
+ insert(sel.options[sel.selectedIndex].value);
88
+ close();
89
+ setTimeout(function(){editor.focus();}, 50);
90
+ }
91
+ connect(sel, "blur", close);
92
+ connect(sel, "keydown", function(event) {
93
+ var code = event.keyCode;
94
+ // Enter and space
95
+ if (code == 13 || code == 32) {event.stop(); pick();}
96
+ // Escape
97
+ else if (code == 27) {event.stop(); close(); editor.focus();}
98
+ else if (code != 38 && code != 40) {close(); editor.focus(); setTimeout(startComplete, 50);}
99
+ });
100
+ connect(sel, "dblclick", pick);
101
+
102
+ sel.focus();
103
+ // Opera sometimes ignores focusing a freshly created node
104
+ if (window.opera) setTimeout(function(){if (!done) sel.focus();}, 100);
105
+ return true;
106
+ }
107
+
108
+ var stringProps = ("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight " +
109
+ "toUpperCase toLowerCase split concat match replace search").split(" ");
110
+ var arrayProps = ("length concat join splice push pop shift unshift slice reverse sort indexOf " +
111
+ "lastIndexOf every some filter forEach map reduce reduceRight ").split(" ");
112
+ var funcProps = "prototype apply call bind".split(" ");
113
+ var keywords = ("break case catch continue debugger default delete do else false finally for function " +
114
+ "if in instanceof new null return switch throw true try typeof var void while with").split(" ");
115
+
116
+ function getCompletions(token, context) {
117
+ var found = [], start = token.string;
118
+ function maybeAdd(str) {
119
+ if (str.indexOf(start) == 0) found.push(str);
120
+ }
121
+ function gatherCompletions(obj) {
122
+ if (typeof obj == "string") forEach(stringProps, maybeAdd);
123
+ else if (obj instanceof Array) forEach(arrayProps, maybeAdd);
124
+ else if (obj instanceof Function) forEach(funcProps, maybeAdd);
125
+ for (var name in obj) maybeAdd(name);
126
+ }
127
+
128
+ if (context) {
129
+ // If this is a property, see if it belongs to some object we can
130
+ // find in the current environment.
131
+ var obj = context.pop(), base;
132
+ if (obj.className == "js-variable")
133
+ base = window[obj.string];
134
+ else if (obj.className == "js-string")
135
+ base = "";
136
+ else if (obj.className == "js-atom")
137
+ base = 1;
138
+ while (base != null && context.length)
139
+ base = base[context.pop().string];
140
+ if (base != null) gatherCompletions(base);
141
+ }
142
+ else {
143
+ // If not, just look in the window object and any local scope
144
+ // (reading into JS mode internals to get at the local variables)
145
+ for (var v = token.state.localVars; v; v = v.next) maybeAdd(v.name);
146
+ gatherCompletions(window);
147
+ forEach(keywords, maybeAdd);
148
+ }
149
+ return found;
150
+ }
151
+ })();
@@ -0,0 +1,158 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>CodeMirror 2: Full Screen Editing</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
+ <link rel="stylesheet" href="../theme/night.css">
9
+ <script src="../mode/xml/xml.js"></script>
10
+ <link rel="stylesheet" href="../css/docs.css">
11
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
12
+
13
+ <style type="text/css">
14
+ .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
15
+ .fullscreen {
16
+ display: block;
17
+ position: absolute;
18
+ top: 0;
19
+ left: 0;
20
+ width: 100%;
21
+ height: 100%;
22
+ z-index: 9999;
23
+ margin: 0;
24
+ padding: 0;
25
+ border: 0px solid #BBBBBB;
26
+ opacity: 1;
27
+ }
28
+ </style>
29
+ </head>
30
+ <body>
31
+ <h1>CodeMirror 2: Full Screen Editing</h1>
32
+
33
+ <form><textarea id="code" name="code" rows="5">
34
+ <dt id="option_indentWithTabs"><code>indentWithTabs (boolean)</code></dt>
35
+ <dd>Whether, when indenting, the first N*8 spaces should be
36
+ replaced by N tabs. Default is false.</dd>
37
+
38
+ <dt id="option_tabMode"><code>tabMode (string)</code></dt>
39
+ <dd>Determines what happens when the user presses the tab key.
40
+ Must be one of the following:
41
+ <dl>
42
+ <dt><code>"classic" (the default)</code></dt>
43
+ <dd>When nothing is selected, insert a tab. Otherwise,
44
+ behave like the <code>"shift"</code> mode. (When shift is
45
+ held, this behaves like the <code>"indent"</code> mode.)</dd>
46
+ <dt><code>"shift"</code></dt>
47
+ <dd>Indent all selected lines by
48
+ one <a href="#option_indentUnit"><code>indentUnit</code></a>.
49
+ If shift was held while pressing tab, un-indent all selected
50
+ lines one unit.</dd>
51
+ <dt><code>"indent"</code></dt>
52
+ <dd>Indent the line the 'correctly', based on its syntactic
53
+ context. Only works if the
54
+ mode <a href="#indent">supports</a> it.</dd>
55
+ <dt><code>"default"</code></dt>
56
+ <dd>Do not capture tab presses, let the browser apply its
57
+ default behaviour (which usually means it skips to the next
58
+ control).</dd>
59
+ </dl></dd>
60
+
61
+ <dt id="option_enterMode"><code>enterMode (string)</code></dt>
62
+ <dd>Determines whether and how new lines are indented when the
63
+ enter key is pressed. The following modes are supported:
64
+ <dl>
65
+ <dt><code>"indent" (the default)</code></dt>
66
+ <dd>Use the mode's indentation rules to give the new line
67
+ the correct indentation.</dd>
68
+ <dt><code>"keep"</code></dt>
69
+ <dd>Indent the line the same as the previous line.</dd>
70
+ <dt><code>"flat"</code></dt>
71
+ <dd>Do not indent the new line.</dd>
72
+ </dl></dd>
73
+
74
+ <dt id="option_enterMode"><code>enterMode (string)</code></dt>
75
+ <dd>Determines whether and how new lines are indented when the
76
+ enter key is pressed. The following modes are supported:
77
+ <dl>
78
+ <dt><code>"indent" (the default)</code></dt>
79
+ <dd>Use the mode's indentation rules to give the new line
80
+ the correct indentation.</dd>
81
+ <dt><code>"keep"</code></dt>
82
+ <dd>Indent the line the same as the previous line.</dd>
83
+ <dt><code>"flat"</code></dt>
84
+ <dd>Do not indent the new line.</dd>
85
+ </dl></dd>
86
+
87
+ <dt id="option_enterMode"><code>enterMode (string)</code></dt>
88
+ <dd>Determines whether and how new lines are indented when the
89
+ enter key is pressed. The following modes are supported:
90
+ <dl>
91
+ <dt><code>"indent" (the default)</code></dt>
92
+ <dd>Use the mode's indentation rules to give the new line
93
+ the correct indentation.</dd>
94
+ <dt><code>"keep"</code></dt>
95
+ <dd>Indent the line the same as the previous line.</dd>
96
+ <dt><code>"flat"</code></dt>
97
+ <dd>Do not indent the new line.</dd>
98
+ </dl></dd>
99
+
100
+ <dt id="option_enterMode"><code>enterMode (string)</code></dt>
101
+ <dd>Determines whether and how new lines are indented when the
102
+ enter key is pressed. The following modes are supported:
103
+ <dl>
104
+ <dt><code>"indent" (the default)</code></dt>
105
+ <dd>Use the mode's indentation rules to give the new line
106
+ the correct indentation.</dd>
107
+ <dt><code>"keep"</code></dt>
108
+ <dd>Indent the line the same as the previous line.</dd>
109
+ <dt><code>"flat"</code></dt>
110
+ <dd>Do not indent the new line.</dd>
111
+ </dl></dd>
112
+
113
+ </textarea></form>
114
+ <script>
115
+
116
+ (function () {
117
+
118
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
119
+ lineNumbers: true,
120
+ theme: "night",
121
+ onKeyEvent: function(i, e) {
122
+ // Hook into F11
123
+ if ((e.keyCode == 122 || e.keyCode == 27) && e.type == 'keydown') {
124
+ e.stop();
125
+ return toggleFullscreenEditing();
126
+ }
127
+ }
128
+ });
129
+
130
+ function toggleFullscreenEditing()
131
+ {
132
+ var editorDiv = $('.CodeMirror-scroll');
133
+ if (!editorDiv.hasClass('fullscreen')) {
134
+ toggleFullscreenEditing.beforeFullscreen = { height: editorDiv.height(), width: editorDiv.width() }
135
+ editorDiv.addClass('fullscreen');
136
+ editorDiv.height('100%');
137
+ editorDiv.width('100%');
138
+ editor.refresh();
139
+ }
140
+ else {
141
+ editorDiv.removeClass('fullscreen');
142
+ editorDiv.height(toggleFullscreenEditing.beforeFullscreen.height);
143
+ editorDiv.width(toggleFullscreenEditing.beforeFullscreen.width);
144
+ editor.refresh();
145
+ }
146
+ }
147
+
148
+ })();
149
+ </script>
150
+
151
+ <p>Press <strong>F11</strong> (or <strong>ESC</strong> in Safari on Mac OS X) when cursor is in the editor to toggle full screen editing.</p>
152
+
153
+ <p><strong>Note:</strong> Does not currently work correctly in IE
154
+ 6 and 7, where setting the height of something
155
+ to <code>100%</code> doesn't make it full-screen.</p>
156
+
157
+ </body>
158
+ </html>
@@ -0,0 +1,53 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>CodeMirror 2: Breakpoint Demo</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
+ <link rel="stylesheet" href="../css/docs.css">
10
+
11
+ <style type="text/css">
12
+ .CodeMirror-gutter {
13
+ width: 3em;
14
+ background: white;
15
+ }
16
+ .CodeMirror {
17
+ border: 1px solid #aaa;
18
+ }
19
+ </style>
20
+ </head>
21
+ <body>
22
+ <h1>CodeMirror 2: Breakpoint demo</h1>
23
+
24
+ <form><textarea id="code" name="code">
25
+ CodeMirror.fromTextArea(document.getElementById("code"), {
26
+ lineNumbers: true,
27
+ onGutterClick: function(cm, n) {
28
+ var info = cm.lineInfo(n);
29
+ if (info.markerText)
30
+ cm.clearMarker(n);
31
+ else
32
+ cm.setMarker(n, "<span style=\"color: #900\">●</span> %N%");
33
+ }
34
+ });
35
+ </textarea></form>
36
+
37
+ <p>Click the line-number gutter to add or remove 'breakpoints'.</p>
38
+
39
+ <script>
40
+ CodeMirror.fromTextArea(document.getElementById("code"), {
41
+ lineNumbers: true,
42
+ onGutterClick: function(cm, n) {
43
+ var info = cm.lineInfo(n);
44
+ if (info.markerText)
45
+ cm.clearMarker(n);
46
+ else
47
+ cm.setMarker(n, "<span style=\"color: #900\">●</span> %N%");
48
+ }
49
+ });
50
+ </script>
51
+
52
+ </body>
53
+ </html>
@@ -0,0 +1,57 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>CodeMirror 2: Overlay Parser Demo</title>
5
+ <link rel="stylesheet" href="../lib/codemirror.css">
6
+ <script src="../lib/codemirror.js"></script>
7
+ <script src="../lib/overlay.js"></script>
8
+ <link rel="stylesheet" href="../theme/default.css">
9
+ <script src="../mode/xml/xml.js"></script>
10
+ <link rel="stylesheet" href="../css/docs.css">
11
+
12
+ <style type="text/css">
13
+ .CodeMirror {border: 1px solid black;}
14
+ .mustache {color: #0ca;}
15
+ </style>
16
+ </head>
17
+ <body>
18
+ <h1>CodeMirror 2: Overlay Parser Demo</h1>
19
+
20
+ <form><textarea id="code" name="code">
21
+ <html>
22
+ <body>
23
+ <h1>{{title}}</h1>
24
+ <p>These are links to {{things}}:</p>
25
+ <ul>{{#links}}
26
+ <li><a href="{{url}}">{{text}}</a></li>
27
+ {{/links}}</ul>
28
+ </body>
29
+ </html>
30
+ </textarea></form>
31
+
32
+ <script>
33
+ CodeMirror.defineMode("mustache", function(config, parserConfig) {
34
+ var mustacheOverlay = {
35
+ token: function(stream, state) {
36
+ if (stream.match("{{")) {
37
+ while ((ch = stream.next()) != null)
38
+ if (ch == "}" && stream.next() == "}") break;
39
+ return "mustache";
40
+ }
41
+ while (stream.next() != null && !stream.match("{{", false)) {}
42
+ return null;
43
+ }
44
+ };
45
+ return CodeMirror.overlayParser(CodeMirror.getMode(config, parserConfig.backdrop || "text/html"), mustacheOverlay);
46
+ });
47
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {mode: "mustache"});
48
+ </script>
49
+
50
+ <p>Demonstration of a mode that parses HTML, highlighting
51
+ the <a href="http://mustache.github.com/">Mustache</a> templating
52
+ directives inside of it by using the code
53
+ in <a href="../lib/overlay.js"><code>overlay.js</code></a>. View
54
+ source to see the 15 lines of code needed to accomplish this.</p>
55
+
56
+ </body>
57
+ </html>
@@ -0,0 +1,75 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>CodeMirror 2: HTML5 preview</title>
5
+ <meta charset=utf-8>
6
+ <script src=../lib/codemirror.js></script>
7
+ <script src=../mode/xml/xml.js></script>
8
+ <script src=../mode/javascript/javascript.js></script>
9
+ <script src=../mode/css/css.js></script>
10
+ <script src=../mode/htmlmixed/htmlmixed.js></script>
11
+ <link rel=stylesheet href=../lib/codemirror.css>
12
+ <link rel=stylesheet href=../theme/default.css>
13
+ <link rel=stylesheet href=../css/docs.css>
14
+ <style type=text/css>
15
+ .CodeMirror {
16
+ float: left;
17
+ width: 50%;
18
+ border: 1px solid black;
19
+ }
20
+ iframe {
21
+ width: 49%;
22
+ float: left;
23
+ height: 300px;
24
+ border: 1px solid black;
25
+ border-left: 0px;
26
+ }
27
+ </style>
28
+ </head>
29
+ <body>
30
+ <h1>CodeMirror 2: HTML5 preview</h1>
31
+ <textarea id=code name=code>
32
+ <!doctype html>
33
+ <html>
34
+ <head>
35
+ <title>HTML5 canvas demo</title>
36
+ <meta charset=utf-8>
37
+ </head>
38
+ <body>
39
+ <canvas id=tutorial width=250 height=250></canvas>
40
+ <script>
41
+ var canvas = document.getElementById('tutorial');
42
+ var context = canvas.getContext('2d');
43
+
44
+ context.fillStyle = 'rgb(250,0,0)';
45
+ context.fillRect(10, 10, 55, 50);
46
+
47
+ context.fillStyle = 'rgba(0, 0, 250, 0.5)';
48
+ context.fillRect(30, 30, 55, 50);
49
+ </script>
50
+ </body>
51
+ </html>
52
+ </textarea>
53
+ <iframe id=preview></iframe>
54
+ <script>
55
+ var delay;
56
+ // Initialize CodeMirror editor with a nice html5 canvas demo.
57
+ var editor = CodeMirror.fromTextArea(document.getElementById('code'), {
58
+ mode: 'text/html',
59
+ tabMode: 'indent',
60
+ onChange: function() {
61
+ clearTimeout(delay);
62
+ delay = setTimeout(updatePreview, 300);
63
+ }
64
+ });
65
+
66
+ function updatePreview() {
67
+ var preview = document.getElementById('preview').contentDocument;
68
+ preview.open();
69
+ preview.write(editor.getValue());
70
+ preview.close();
71
+ }
72
+ setTimeout(updatePreview, 300);
73
+ </script>
74
+ </body>
75
+ </html>