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,75 @@
1
+ .cm-s-default span.cm-emphasis {
2
+ font-style: italic;
3
+ }
4
+
5
+ .cm-s-default span.cm-strong {
6
+ font-weight: bold;
7
+ }
8
+
9
+ .cm-s-default span.cm-interpreted {
10
+ color: #33cc66;
11
+ }
12
+
13
+ .cm-s-default span.cm-inline {
14
+ color: #3399cc;
15
+ }
16
+
17
+ .cm-s-default span.cm-role {
18
+ color: #666699;
19
+ }
20
+
21
+ .cm-s-default span.cm-list {
22
+ color: #cc0099;
23
+ font-weight: bold;
24
+ }
25
+
26
+ .cm-s-default span.cm-body {
27
+ color: #6699cc;
28
+ }
29
+
30
+ .cm-s-default span.cm-verbatim {
31
+ color: #3366ff;
32
+ }
33
+
34
+ .cm-s-default span.cm-comment {
35
+ color: #aa7700;
36
+ }
37
+
38
+ .cm-s-default span.cm-directive {
39
+ font-weight: bold;
40
+ color: #3399ff;
41
+ }
42
+
43
+ .cm-s-default span.cm-hyperlink {
44
+ font-weight: bold;
45
+ color: #3366ff;
46
+ }
47
+
48
+ .cm-s-default span.cm-footnote {
49
+ font-weight: bold;
50
+ color: #3333ff;
51
+ }
52
+
53
+ .cm-s-default span.cm-citation {
54
+ font-weight: bold;
55
+ color: #3300ff;
56
+ }
57
+
58
+ .cm-s-default span.cm-replacement {
59
+ color: #9933cc;
60
+ }
61
+
62
+ .cm-s-default span.cm-section {
63
+ font-weight: bold;
64
+ color: #cc0099;
65
+ }
66
+
67
+ .cm-s-default span.cm-directive-marker {
68
+ font-weight: bold;
69
+ color: #3399ff;
70
+ }
71
+
72
+ .cm-s-default span.cm-verbatim-marker {
73
+ font-weight: bold;
74
+ color: #9900ff;
75
+ }
@@ -0,0 +1,333 @@
1
+ CodeMirror.defineMode('rst', function(config, options) {
2
+ function setState(state, fn, ctx) {
3
+ state.fn = fn;
4
+ setCtx(state, ctx);
5
+ }
6
+
7
+ function setCtx(state, ctx) {
8
+ state.ctx = ctx || {};
9
+ }
10
+
11
+ function setNormal(state, ch) {
12
+ if (ch && (typeof ch !== 'string')) {
13
+ var str = ch.current();
14
+ ch = str[str.length-1];
15
+ }
16
+
17
+ setState(state, normal, {back: ch});
18
+ }
19
+
20
+ function hasMode(mode) {
21
+ if (mode) {
22
+ var modes = CodeMirror.listModes();
23
+
24
+ for (var i in modes) {
25
+ if (modes[i] == mode) {
26
+ return true;
27
+ }
28
+ }
29
+ }
30
+
31
+ return false;
32
+ }
33
+
34
+ function getMode(mode) {
35
+ if (hasMode(mode)) {
36
+ return CodeMirror.getMode(config, mode);
37
+ } else {
38
+ return null;
39
+ }
40
+ }
41
+
42
+ var verbatimMode = getMode(options.verbatim);
43
+ var pythonMode = getMode('python');
44
+
45
+ var reSection = /^[!"#$%&'()*+,-./:;<=>?@[\\\]^_`{|}~]/;
46
+ var reDirective = /^\s*\w([-:.\w]*\w)?::(\s|$)/;
47
+ var reHyperlink = /^\s*_[\w-]+:(\s|$)/;
48
+ var reFootnote = /^\s*\[(\d+|#)\](\s|$)/;
49
+ var reCitation = /^\s*\[[A-Za-z][\w-]*\](\s|$)/;
50
+ var reFootnoteRef = /^\[(\d+|#)\]_/;
51
+ var reCitationRef = /^\[[A-Za-z][\w-]*\]_/;
52
+ var reDirectiveMarker = /^\.\.(\s|$)/;
53
+ var reVerbatimMarker = /^::\s*$/;
54
+ var rePreInline = /^[-\s"([{</:]/;
55
+ var rePostInline = /^[-\s`'")\]}>/:.,;!?\\_]/;
56
+ var reEnumeratedList = /^\s*((\d+|[A-Za-z#])[.)]|\((\d+|[A-Z-a-z#])\))\s/;
57
+ var reBulletedList = /^\s*[-\+\*]\s/;
58
+ var reExamples = /^\s+(>>>|In \[\d+\]:)\s/;
59
+
60
+ function normal(stream, state) {
61
+ var ch, sol, i;
62
+
63
+ if (stream.eat(/\\/)) {
64
+ ch = stream.next();
65
+ setNormal(state, ch);
66
+ return null;
67
+ }
68
+
69
+ sol = stream.sol();
70
+
71
+ if (sol && (ch = stream.eat(reSection))) {
72
+ for (i = 0; stream.eat(ch); i++);
73
+
74
+ if (i >= 3 && stream.match(/^\s*$/)) {
75
+ setNormal(state, null);
76
+ return 'section';
77
+ } else {
78
+ stream.backUp(i + 1);
79
+ }
80
+ }
81
+
82
+ if (sol && stream.match(reDirectiveMarker)) {
83
+ if (!stream.eol()) {
84
+ setState(state, directive);
85
+ }
86
+
87
+ return 'directive-marker';
88
+ }
89
+
90
+ if (stream.match(reVerbatimMarker)) {
91
+ if (!verbatimMode) {
92
+ setState(state, verbatim);
93
+ } else {
94
+ var mode = verbatimMode;
95
+
96
+ setState(state, verbatim, {
97
+ mode: mode,
98
+ local: mode.startState()
99
+ });
100
+ }
101
+
102
+ return 'verbatim-marker';
103
+ }
104
+
105
+ if (sol && stream.match(reExamples, false)) {
106
+ if (!pythonMode) {
107
+ setState(state, verbatim);
108
+ return 'verbatim-marker';
109
+ } else {
110
+ var mode = pythonMode;
111
+
112
+ setState(state, verbatim, {
113
+ mode: mode,
114
+ local: mode.startState()
115
+ });
116
+
117
+ return null;
118
+ }
119
+ }
120
+
121
+ if (sol && (stream.match(reEnumeratedList) ||
122
+ stream.match(reBulletedList))) {
123
+ setNormal(state, stream);
124
+ return 'list';
125
+ }
126
+
127
+ function testBackward(re) {
128
+ return sol || !state.ctx.back || re.test(state.ctx.back);
129
+ }
130
+
131
+ function testForward(re) {
132
+ return stream.eol() || stream.match(re, false);
133
+ }
134
+
135
+ function testInline(re) {
136
+ return stream.match(re) && testBackward(/\W/) && testForward(/\W/);
137
+ }
138
+
139
+ if (testInline(reFootnoteRef)) {
140
+ setNormal(state, stream);
141
+ return 'footnote';
142
+ }
143
+
144
+ if (testInline(reCitationRef)) {
145
+ setNormal(state, stream);
146
+ return 'citation';
147
+ }
148
+
149
+ ch = stream.next();
150
+
151
+ if (testBackward(rePreInline)) {
152
+ if ((ch === ':' || ch === '|') && stream.eat(/\S/)) {
153
+ var token;
154
+
155
+ if (ch === ':') {
156
+ token = 'role';
157
+ } else {
158
+ token = 'replacement';
159
+ }
160
+
161
+ setState(state, inline, {
162
+ ch: ch,
163
+ wide: false,
164
+ prev: null,
165
+ token: token
166
+ });
167
+
168
+ return token;
169
+ }
170
+
171
+ if (ch === '*' || ch === '`') {
172
+ var orig = ch,
173
+ wide = false;
174
+
175
+ ch = stream.next();
176
+
177
+ if (ch == orig) {
178
+ wide = true;
179
+ ch = stream.next();
180
+ }
181
+
182
+ if (ch && !/\s/.test(ch)) {
183
+ var token;
184
+
185
+ if (orig === '*') {
186
+ token = wide ? 'strong' : 'emphasis';
187
+ } else {
188
+ token = wide ? 'inline' : 'interpreted';
189
+ }
190
+
191
+ setState(state, inline, {
192
+ ch: orig, // inline() has to know what to search for
193
+ wide: wide, // are we looking for `ch` or `chch`
194
+ prev: null, // terminator must not be preceeded with whitespace
195
+ token: token // I don't want to recompute this all the time
196
+ });
197
+
198
+ return token;
199
+ }
200
+ }
201
+ }
202
+
203
+ setNormal(state, ch);
204
+ return null;
205
+ }
206
+
207
+ function inline(stream, state) {
208
+ var ch = stream.next(),
209
+ token = state.ctx.token;
210
+
211
+ function finish(ch) {
212
+ state.ctx.prev = ch;
213
+ return token;
214
+ }
215
+
216
+ if (ch != state.ctx.ch) {
217
+ return finish(ch);
218
+ }
219
+
220
+ if (/\s/.test(state.ctx.prev)) {
221
+ return finish(ch);
222
+ }
223
+
224
+ if (state.ctx.wide) {
225
+ ch = stream.next();
226
+
227
+ if (ch != state.ctx.ch) {
228
+ return finish(ch);
229
+ }
230
+ }
231
+
232
+ if (!stream.eol() && !rePostInline.test(stream.peek())) {
233
+ if (state.ctx.wide) {
234
+ stream.backUp(1);
235
+ }
236
+
237
+ return finish(ch);
238
+ }
239
+
240
+ setState(state, normal);
241
+ setNormal(state, ch);
242
+
243
+ return token;
244
+ }
245
+
246
+ function directive(stream, state) {
247
+ var token = null;
248
+
249
+ if (stream.match(reDirective)) {
250
+ token = 'directive';
251
+ } else if (stream.match(reHyperlink)) {
252
+ token = 'hyperlink';
253
+ } else if (stream.match(reFootnote)) {
254
+ token = 'footnote';
255
+ } else if (stream.match(reCitation)) {
256
+ token = 'citation';
257
+ } else {
258
+ stream.eatSpace();
259
+
260
+ if (stream.eol()) {
261
+ setNormal(state, stream);
262
+ return null;
263
+ } else {
264
+ stream.skipToEnd();
265
+ setState(state, comment);
266
+ return 'comment';
267
+ }
268
+ }
269
+
270
+ setState(state, body, {start: true});
271
+ return token;
272
+ }
273
+
274
+ function body(stream, state) {
275
+ var token = 'body';
276
+
277
+ if (!state.ctx.start || stream.sol()) {
278
+ return block(stream, state, token);
279
+ }
280
+
281
+ stream.skipToEnd();
282
+ setCtx(state);
283
+
284
+ return token;
285
+ }
286
+
287
+ function comment(stream, state) {
288
+ return block(stream, state, 'comment');
289
+ }
290
+
291
+ function verbatim(stream, state) {
292
+ if (!verbatimMode) {
293
+ return block(stream, state, 'verbatim');
294
+ } else {
295
+ if (stream.sol()) {
296
+ if (!stream.eatSpace()) {
297
+ setNormal(state, stream);
298
+ }
299
+
300
+ return null;
301
+ }
302
+
303
+ return verbatimMode.token(stream, state.ctx.local);
304
+ }
305
+ }
306
+
307
+ function block(stream, state, token) {
308
+ if (stream.eol() || stream.eatSpace()) {
309
+ stream.skipToEnd();
310
+ return token;
311
+ } else {
312
+ setNormal(state, stream);
313
+ return null;
314
+ }
315
+ }
316
+
317
+ return {
318
+ startState: function() {
319
+ return {fn: normal, ctx: {}};
320
+ },
321
+
322
+ copyState: function(state) {
323
+ return {fn: state.fn, ctx: state.ctx};
324
+ },
325
+
326
+ token: function(stream, state) {
327
+ var token = state.fn(stream, state);
328
+ return token;
329
+ }
330
+ };
331
+ });
332
+
333
+ CodeMirror.defineMIME("text/x-rst", "rst");
@@ -0,0 +1,65 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>CodeMirror 2: Scheme mode</title>
5
+ <link rel="stylesheet" href="../../lib/codemirror.css">
6
+ <script src="../../lib/codemirror.js"></script>
7
+ <script src="scheme.js"></script>
8
+ <link rel="stylesheet" href="../../theme/default.css">
9
+ <style>.CodeMirror {background: #f8f8f8;}</style>
10
+ <link rel="stylesheet" href="../../css/docs.css">
11
+ </head>
12
+ <body>
13
+ <h1>CodeMirror 2: Scheme mode</h1>
14
+ <form><textarea id="code" name="code">
15
+ ; See if the input starts with a given symbol.
16
+ (define (match-symbol input pattern)
17
+ (cond ((null? (remain input)) #f)
18
+ ((eqv? (car (remain input)) pattern) (r-cdr input))
19
+ (else #f)))
20
+
21
+ ; Allow the input to start with one of a list of patterns.
22
+ (define (match-or input pattern)
23
+ (cond ((null? pattern) #f)
24
+ ((match-pattern input (car pattern)))
25
+ (else (match-or input (cdr pattern)))))
26
+
27
+ ; Allow a sequence of patterns.
28
+ (define (match-seq input pattern)
29
+ (if (null? pattern)
30
+ input
31
+ (let ((match (match-pattern input (car pattern))))
32
+ (if match (match-seq match (cdr pattern)) #f))))
33
+
34
+ ; Match with the pattern but no problem if it does not match.
35
+ (define (match-opt input pattern)
36
+ (let ((match (match-pattern input (car pattern))))
37
+ (if match match input)))
38
+
39
+ ; Match anything (other than '()), until pattern is found. The rather
40
+ ; clumsy form of requiring an ending pattern is needed to decide where
41
+ ; the end of the match is. If none is given, this will match the rest
42
+ ; of the sentence.
43
+ (define (match-any input pattern)
44
+ (cond ((null? (remain input)) #f)
45
+ ((null? pattern) (f-cons (remain input) (clear-remain input)))
46
+ (else
47
+ (let ((accum-any (collector)))
48
+ (define (match-pattern-any input pattern)
49
+ (cond ((null? (remain input)) #f)
50
+ (else (accum-any (car (remain input)))
51
+ (cond ((match-pattern (r-cdr input) pattern))
52
+ (else (match-pattern-any (r-cdr input) pattern))))))
53
+ (let ((retval (match-pattern-any input (car pattern))))
54
+ (if retval
55
+ (f-cons (accum-any) retval)
56
+ #f))))))
57
+ </textarea></form>
58
+ <script>
59
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
60
+ </script>
61
+
62
+ <p><strong>MIME types defined:</strong> <code>text/x-scheme</code>.</p>
63
+
64
+ </body>
65
+ </html>