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,72 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>CodeMirror 2: Lua mode</title>
5
+ <link rel="stylesheet" href="../../lib/codemirror.css">
6
+ <script src="../../lib/codemirror.js"></script>
7
+ <script src="lua.js"></script>
8
+ <link rel="stylesheet" href="../../theme/neat.css">
9
+ <style>.CodeMirror {border: 1px solid black;}</style>
10
+ <link rel="stylesheet" href="../../css/docs.css">
11
+ </head>
12
+ <body>
13
+ <h1>CodeMirror 2: Lua mode</h1>
14
+ <form><textarea id="code" name="code">
15
+ --[[
16
+ example useless code to show lua syntax highlighting
17
+ this is multiline comment
18
+ ]]
19
+
20
+ function blahblahblah(x)
21
+
22
+ local table = {
23
+ "asd" = 123,
24
+ "x" = 0.34,
25
+ }
26
+ if x ~= 3 then
27
+ print( x )
28
+ elseif x == "string"
29
+ my_custom_function( 0x34 )
30
+ else
31
+ unknown_function( "some string" )
32
+ end
33
+
34
+ --single line comment
35
+
36
+ end
37
+
38
+ function blablabla3()
39
+
40
+ for k,v in ipairs( table ) do
41
+ --abcde..
42
+ y=[=[
43
+ x=[[
44
+ x is a multi line string
45
+ ]]
46
+ but its definition is iside a highest level string!
47
+ ]=]
48
+ print(" \"\" ")
49
+
50
+ s = math.sin( x )
51
+ end
52
+
53
+ end
54
+ </textarea></form>
55
+ <script>
56
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
57
+ tabMode: "indent",
58
+ matchBrackets: true,
59
+ theme: "neat"
60
+ });
61
+ </script>
62
+
63
+ <p>Loosely based on Franciszek
64
+ Wawrzak's <a href="http://codemirror.net/1/contrib/lua">CodeMirror
65
+ 1 mode</a>. One configuration parameter is
66
+ supported, <code>specials</code>, to which you can provide an
67
+ array of strings to have those identifiers highlighted with
68
+ the <code>lua-special</code> style.</p>
69
+ <p><strong>MIME types defined:</strong> <code>text/x-lua</code>.</p>
70
+
71
+ </body>
72
+ </html>
@@ -0,0 +1,138 @@
1
+ // LUA mode. Ported to CodeMirror 2 from Franciszek Wawrzak's
2
+ // CodeMirror 1 mode.
3
+ // highlights keywords, strings, comments (no leveling supported! ("[==[")), tokens, basic indenting
4
+
5
+ CodeMirror.defineMode("lua", function(config, parserConfig) {
6
+ var indentUnit = config.indentUnit;
7
+
8
+ function prefixRE(words) {
9
+ return new RegExp("^(?:" + words.join("|") + ")", "i");
10
+ }
11
+ function wordRE(words) {
12
+ return new RegExp("^(?:" + words.join("|") + ")$", "i");
13
+ }
14
+ var specials = wordRE(parserConfig.specials || []);
15
+
16
+ // long list of standard functions from lua manual
17
+ var builtins = wordRE([
18
+ "_G","_VERSION","assert","collectgarbage","dofile","error","getfenv","getmetatable","ipairs","load",
19
+ "loadfile","loadstring","module","next","pairs","pcall","print","rawequal","rawget","rawset","require",
20
+ "select","setfenv","setmetatable","tonumber","tostring","type","unpack","xpcall",
21
+
22
+ "coroutine.create","coroutine.resume","coroutine.running","coroutine.status","coroutine.wrap","coroutine.yield",
23
+
24
+ "debug.debug","debug.getfenv","debug.gethook","debug.getinfo","debug.getlocal","debug.getmetatable",
25
+ "debug.getregistry","debug.getupvalue","debug.setfenv","debug.sethook","debug.setlocal","debug.setmetatable",
26
+ "debug.setupvalue","debug.traceback",
27
+
28
+ "close","flush","lines","read","seek","setvbuf","write",
29
+
30
+ "io.close","io.flush","io.input","io.lines","io.open","io.output","io.popen","io.read","io.stderr","io.stdin",
31
+ "io.stdout","io.tmpfile","io.type","io.write",
32
+
33
+ "math.abs","math.acos","math.asin","math.atan","math.atan2","math.ceil","math.cos","math.cosh","math.deg",
34
+ "math.exp","math.floor","math.fmod","math.frexp","math.huge","math.ldexp","math.log","math.log10","math.max",
35
+ "math.min","math.modf","math.pi","math.pow","math.rad","math.random","math.randomseed","math.sin","math.sinh",
36
+ "math.sqrt","math.tan","math.tanh",
37
+
38
+ "os.clock","os.date","os.difftime","os.execute","os.exit","os.getenv","os.remove","os.rename","os.setlocale",
39
+ "os.time","os.tmpname",
40
+
41
+ "package.cpath","package.loaded","package.loaders","package.loadlib","package.path","package.preload",
42
+ "package.seeall",
43
+
44
+ "string.byte","string.char","string.dump","string.find","string.format","string.gmatch","string.gsub",
45
+ "string.len","string.lower","string.match","string.rep","string.reverse","string.sub","string.upper",
46
+
47
+ "table.concat","table.insert","table.maxn","table.remove","table.sort"
48
+ ]);
49
+ var keywords = wordRE(["and","break","elseif","false","nil","not","or","return",
50
+ "true","function", "end", "if", "then", "else", "do",
51
+ "while", "repeat", "until", "for", "in", "local" ]);
52
+
53
+ var indentTokens = wordRE(["function", "if","repeat","for","while", "\\(", "{"]);
54
+ var dedentTokens = wordRE(["end", "until", "\\)", "}"]);
55
+ var dedentPartial = prefixRE(["end", "until", "\\)", "}", "else", "elseif"]);
56
+
57
+ function readBracket(stream) {
58
+ var level = 0;
59
+ while (stream.eat("=")) ++level;
60
+ stream.eat("[");
61
+ return level;
62
+ }
63
+
64
+ function normal(stream, state) {
65
+ var ch = stream.next();
66
+ if (ch == "-" && stream.eat("-")) {
67
+ if (stream.eat("["))
68
+ return (state.cur = bracketed(readBracket(stream), "comment"))(stream, state);
69
+ stream.skipToEnd();
70
+ return "comment";
71
+ }
72
+ if (ch == "\"" || ch == "'")
73
+ return (state.cur = string(ch))(stream, state);
74
+ if (ch == "[" && /[\[=]/.test(stream.peek()))
75
+ return (state.cur = bracketed(readBracket(stream), "string"))(stream, state);
76
+ if (/\d/.test(ch)) {
77
+ stream.eatWhile(/[\w.%]/);
78
+ return "number";
79
+ }
80
+ if (/[\w_]/.test(ch)) {
81
+ stream.eatWhile(/[\w\\\-_.]/);
82
+ return "variable";
83
+ }
84
+ return null;
85
+ }
86
+
87
+ function bracketed(level, style) {
88
+ return function(stream, state) {
89
+ var curlev = null, ch;
90
+ while ((ch = stream.next()) != null) {
91
+ if (curlev == null) {if (ch == "]") curlev = 0;}
92
+ else if (ch == "=") ++curlev;
93
+ else if (ch == "]" && curlev == level) { state.cur = normal; break; }
94
+ else curlev = null;
95
+ }
96
+ return style;
97
+ };
98
+ }
99
+
100
+ function string(quote) {
101
+ return function(stream, state) {
102
+ var escaped = false, ch;
103
+ while ((ch = stream.next()) != null) {
104
+ if (ch == quote && !escaped) break;
105
+ escaped = !escaped && ch == "\\";
106
+ }
107
+ if (!escaped) state.cur = normal;
108
+ return "string";
109
+ };
110
+ }
111
+
112
+ return {
113
+ startState: function(basecol) {
114
+ return {basecol: basecol || 0, indentDepth: 0, cur: normal};
115
+ },
116
+
117
+ token: function(stream, state) {
118
+ if (stream.eatSpace()) return null;
119
+ var style = state.cur(stream, state);
120
+ var word = stream.current();
121
+ if (style == "variable") {
122
+ if (keywords.test(word)) style = "keyword";
123
+ else if (builtins.test(word)) style = "builtin";
124
+ else if (specials.test(word)) style = "variable-2";
125
+ }
126
+ if (indentTokens.test(word)) ++state.indentDepth;
127
+ else if (dedentTokens.test(word)) --state.indentDepth;
128
+ return style;
129
+ },
130
+
131
+ indent: function(state, textAfter) {
132
+ var closing = dedentPartial.test(textAfter);
133
+ return state.basecol + indentUnit * (state.indentDepth - (closing ? 1 : 0));
134
+ }
135
+ };
136
+ });
137
+
138
+ CodeMirror.defineMIME("text/x-lua", "lua");
@@ -0,0 +1,49 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>CodeMirror 2: PHP mode</title>
5
+ <link rel="stylesheet" href="../../lib/codemirror.css">
6
+ <script src="../../lib/codemirror.js"></script>
7
+ <script src="../xml/xml.js"></script>
8
+ <script src="../javascript/javascript.js"></script>
9
+ <script src="../css/css.js"></script>
10
+ <script src="../clike/clike.js"></script>
11
+ <script src="php.js"></script>
12
+ <link rel="stylesheet" href="../../theme/default.css">
13
+ <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
14
+ <link rel="stylesheet" href="../../css/docs.css">
15
+ </head>
16
+ <body>
17
+ <h1>CodeMirror 2: PHP mode</h1>
18
+
19
+ <form><textarea id="code" name="code">
20
+ <?php
21
+ function hello($who) {
22
+ return "Hello " . $who;
23
+ }
24
+ ?>
25
+ <p>The program says <?= hello("World") ?>.</p>
26
+ <script>
27
+ alert("And here is some JS code"); // also colored
28
+ </script>
29
+ </textarea></form>
30
+
31
+ <script>
32
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
33
+ lineNumbers: true,
34
+ matchBrackets: true,
35
+ mode: "application/x-httpd-php",
36
+ indentUnit: 8,
37
+ indentWithTabs: true,
38
+ enterMode: "keep",
39
+ tabMode: "shift"
40
+ });
41
+ </script>
42
+
43
+ <p>Simple HTML/PHP mode based on
44
+ the <a href="../clike/">C-like</a> mode. Depends on XML,
45
+ JavaScript, CSS, and C-like modes.</p>
46
+
47
+ <p><strong>MIME types defined:</strong> <code>application/x-httpd-php</code> (HTML with PHP code), <code>text/x-php</code> (plain, non-wrapped PHP code).</p>
48
+ </body>
49
+ </html>
@@ -0,0 +1,110 @@
1
+ (function() {
2
+ function keywords(str) {
3
+ var obj = {}, words = str.split(" ");
4
+ for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
5
+ return obj;
6
+ }
7
+ function heredoc(delim) {
8
+ return function(stream, state) {
9
+ if (stream.match(delim)) state.tokenize = null;
10
+ else stream.skipToEnd();
11
+ return "string";
12
+ }
13
+ }
14
+ var phpConfig = {
15
+ name: "clike",
16
+ keywords: keywords("abstract and array as break case catch cfunction class clone const continue declare " +
17
+ "default do else elseif enddeclare endfor endforeach endif endswitch endwhile extends " +
18
+ "final for foreach function global goto if implements interface instanceof namespace " +
19
+ "new or private protected public static switch throw try use var while xor return"),
20
+ blockKeywords: keywords("catch do else elseif for foreach if switch try while"),
21
+ atoms: keywords("true false null"),
22
+ multiLineStrings: true,
23
+ hooks: {
24
+ "$": function(stream, state) {
25
+ stream.eatWhile(/[\w\$_]/);
26
+ return "variable-2";
27
+ },
28
+ "<": function(stream, state) {
29
+ if (stream.match(/<</)) {
30
+ stream.eatWhile(/[\w\.]/);
31
+ state.tokenize = heredoc(stream.current().slice(3));
32
+ return state.tokenize(stream, state);
33
+ }
34
+ return false;
35
+ }
36
+ }
37
+ };
38
+
39
+ CodeMirror.defineMode("php", function(config, parserConfig) {
40
+ var htmlMode = CodeMirror.getMode(config, "text/html");
41
+ var jsMode = CodeMirror.getMode(config, "text/javascript");
42
+ var cssMode = CodeMirror.getMode(config, "text/css");
43
+ var phpMode = CodeMirror.getMode(config, phpConfig);
44
+
45
+ function dispatch(stream, state) { // TODO open PHP inside text/css
46
+ if (state.curMode == htmlMode) {
47
+ var style = htmlMode.token(stream, state.curState);
48
+ if (style == "meta" && /^<\?/.test(stream.current())) {
49
+ state.curMode = phpMode;
50
+ state.curState = state.php;
51
+ state.curClose = /^\?>/;
52
+ }
53
+ else if (style == "tag" && stream.current() == ">" && state.curState.context) {
54
+ if (/^script$/i.test(state.curState.context.tagName)) {
55
+ state.curMode = jsMode;
56
+ state.curState = jsMode.startState(htmlMode.indent(state.curState, ""));
57
+ state.curClose = /^<\/\s*script\s*>/i;
58
+ }
59
+ else if (/^style$/i.test(state.curState.context.tagName)) {
60
+ state.curMode = cssMode;
61
+ state.curState = cssMode.startState(htmlMode.indent(state.curState, ""));
62
+ state.curClose = /^<\/\s*style\s*>/i;
63
+ }
64
+ }
65
+ return style;
66
+ }
67
+ else if (stream.match(state.curClose, false)) {
68
+ state.curMode = htmlMode;
69
+ state.curState = state.html;
70
+ state.curClose = null;
71
+ return dispatch(stream, state);
72
+ }
73
+ else return state.curMode.token(stream, state.curState);
74
+ }
75
+
76
+ return {
77
+ startState: function() {
78
+ var html = htmlMode.startState();
79
+ return {html: html,
80
+ php: phpMode.startState(),
81
+ curMode: parserConfig.startOpen ? phpMode : htmlMode,
82
+ curState: parserConfig.startOpen ? phpMode.startState() : html,
83
+ curClose: parserConfig.startOpen ? /^\?>/ : null}
84
+ },
85
+
86
+ copyState: function(state) {
87
+ var html = state.html, htmlNew = CodeMirror.copyState(htmlMode, html),
88
+ php = state.php, phpNew = CodeMirror.copyState(phpMode, php), cur;
89
+ if (state.curState == html) cur = htmlNew;
90
+ else if (state.curState == php) cur = phpNew;
91
+ else cur = CodeMirror.copyState(state.curMode, state.curState);
92
+ return {html: htmlNew, php: phpNew, curMode: state.curMode, curState: cur, curClose: state.curClose};
93
+ },
94
+
95
+ token: dispatch,
96
+
97
+ indent: function(state, textAfter) {
98
+ if ((state.curMode != phpMode && /^\s*<\//.test(textAfter)) ||
99
+ (state.curMode == phpMode && /^\?>/.test(textAfter)))
100
+ return htmlMode.indent(state.html, textAfter);
101
+ return state.curMode.indent(state.curState, textAfter);
102
+ },
103
+
104
+ electricChars: "/{}:"
105
+ }
106
+ });
107
+ CodeMirror.defineMIME("application/x-httpd-php", "php");
108
+ CodeMirror.defineMIME("application/x-httpd-php-open", {name: "php", startOpen: true});
109
+ CodeMirror.defineMIME("text/x-php", phpConfig);
110
+ })();
@@ -0,0 +1,63 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>CodeMirror 2: Oracle PL/SQL mode</title>
5
+ <link rel="stylesheet" href="../../lib/codemirror.css">
6
+ <script src="../../lib/codemirror.js"></script>
7
+ <script src="plsql.js"></script>
8
+ <link rel="stylesheet" href="../../theme/default.css">
9
+ <link rel="stylesheet" href="../../css/docs.css">
10
+ <style>.CodeMirror {border: 2px inset #dee;}</style>
11
+ </head>
12
+ <body>
13
+ <h1>CodeMirror 2: Oracle PL/SQL mode</h1>
14
+
15
+ <form><textarea id="code" name="code">
16
+ -- Oracle PL/SQL Code Demo
17
+ /*
18
+ based on c-like mode, adapted to PL/SQL by Peter Raganitsch ( http://www.oracle-and-apex.com/ )
19
+ April 2011
20
+ */
21
+ DECLARE
22
+ vIdx NUMBER;
23
+ vString VARCHAR2(100);
24
+ cText CONSTANT VARCHAR2(100) := 'That''s it! Have fun with CodeMirror 2';
25
+ BEGIN
26
+ vIdx := 0;
27
+ --
28
+ FOR rDATA IN
29
+ ( SELECT *
30
+ FROM EMP
31
+ ORDER BY EMPNO
32
+ )
33
+ LOOP
34
+ vIdx := vIdx + 1;
35
+ vString := rDATA.EMPNO || ' - ' || rDATA.ENAME;
36
+ --
37
+ UPDATE EMP
38
+ SET SAL = SAL * 101/100
39
+ WHERE EMPNO = rDATA.EMPNO
40
+ ;
41
+ END LOOP;
42
+ --
43
+ SYS.DBMS_OUTPUT.Put_Line (cText);
44
+ END;
45
+ --
46
+ </textarea></form>
47
+
48
+ <script>
49
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
50
+ lineNumbers: true,
51
+ matchBrackets: true,
52
+ indentUnit: 4,
53
+ mode: "text/x-plsql"
54
+ });
55
+ </script>
56
+
57
+ <p>
58
+ Simple mode that handles Oracle PL/SQL language (and Oracle SQL, of course).
59
+ </p>
60
+
61
+ <p><strong>MIME type defined:</strong> <code>text/x-plsql</code>
62
+ (PLSQL code)
63
+ </html>
@@ -0,0 +1,217 @@
1
+ CodeMirror.defineMode("plsql", function(config, parserConfig) {
2
+ var indentUnit = config.indentUnit,
3
+ keywords = parserConfig.keywords,
4
+ functions = parserConfig.functions,
5
+ types = parserConfig.types,
6
+ sqlplus = parserConfig.sqlplus,
7
+ multiLineStrings = parserConfig.multiLineStrings;
8
+ var isOperatorChar = /[+\-*&%=<>!?:\/|]/;
9
+ function chain(stream, state, f) {
10
+ state.tokenize = f;
11
+ return f(stream, state);
12
+ }
13
+
14
+ var type;
15
+ function ret(tp, style) {
16
+ type = tp;
17
+ return style;
18
+ }
19
+
20
+ function tokenBase(stream, state) {
21
+ var ch = stream.next();
22
+ // start of string?
23
+ if (ch == '"' || ch == "'")
24
+ return chain(stream, state, tokenString(ch));
25
+ // is it one of the special signs []{}().,;? Seperator?
26
+ else if (/[\[\]{}\(\),;\.]/.test(ch))
27
+ return ret(ch);
28
+ // start of a number value?
29
+ else if (/\d/.test(ch)) {
30
+ stream.eatWhile(/[\w\.]/);
31
+ return ret("number", "number");
32
+ }
33
+ // multi line comment or simple operator?
34
+ else if (ch == "/") {
35
+ if (stream.eat("*")) {
36
+ return chain(stream, state, tokenComment);
37
+ }
38
+ else {
39
+ stream.eatWhile(isOperatorChar);
40
+ return ret("operator", "operator");
41
+ }
42
+ }
43
+ // single line comment or simple operator?
44
+ else if (ch == "-") {
45
+ if (stream.eat("-")) {
46
+ stream.skipToEnd();
47
+ return ret("comment", "comment");
48
+ }
49
+ else {
50
+ stream.eatWhile(isOperatorChar);
51
+ return ret("operator", "operator");
52
+ }
53
+ }
54
+ // pl/sql variable?
55
+ else if (ch == "@" || ch == "$") {
56
+ stream.eatWhile(/[\w\d\$_]/);
57
+ return ret("word", "variable");
58
+ }
59
+ // is it a operator?
60
+ else if (isOperatorChar.test(ch)) {
61
+ stream.eatWhile(isOperatorChar);
62
+ return ret("operator", "operator");
63
+ }
64
+ else {
65
+ // get the whole word
66
+ stream.eatWhile(/[\w\$_]/);
67
+ // is it one of the listed keywords?
68
+ if (keywords && keywords.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "keyword");
69
+ // is it one of the listed functions?
70
+ if (functions && functions.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "builtin");
71
+ // is it one of the listed types?
72
+ if (types && types.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "variable-2");
73
+ // is it one of the listed sqlplus keywords?
74
+ if (sqlplus && sqlplus.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "variable-3");
75
+ // default: just a "word"
76
+ return ret("word", "plsql-word");
77
+ }
78
+ }
79
+
80
+ function tokenString(quote) {
81
+ return function(stream, state) {
82
+ var escaped = false, next, end = false;
83
+ while ((next = stream.next()) != null) {
84
+ if (next == quote && !escaped) {end = true; break;}
85
+ escaped = !escaped && next == "\\";
86
+ }
87
+ if (end || !(escaped || multiLineStrings))
88
+ state.tokenize = tokenBase;
89
+ return ret("string", "plsql-string");
90
+ };
91
+ }
92
+
93
+ function tokenComment(stream, state) {
94
+ var maybeEnd = false, ch;
95
+ while (ch = stream.next()) {
96
+ if (ch == "/" && maybeEnd) {
97
+ state.tokenize = tokenBase;
98
+ break;
99
+ }
100
+ maybeEnd = (ch == "*");
101
+ }
102
+ return ret("comment", "plsql-comment");
103
+ }
104
+
105
+ // Interface
106
+
107
+ return {
108
+ startState: function(basecolumn) {
109
+ return {
110
+ tokenize: tokenBase,
111
+ startOfLine: true
112
+ };
113
+ },
114
+
115
+ token: function(stream, state) {
116
+ if (stream.eatSpace()) return null;
117
+ var style = state.tokenize(stream, state);
118
+ return style;
119
+ }
120
+ };
121
+ });
122
+
123
+ (function() {
124
+ function keywords(str) {
125
+ var obj = {}, words = str.split(" ");
126
+ for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
127
+ return obj;
128
+ }
129
+ var cKeywords = "abort accept access add all alter and any array arraylen as asc assert assign at attributes audit " +
130
+ "authorization avg " +
131
+ "base_table begin between binary_integer body boolean by " +
132
+ "case cast char char_base check close cluster clusters colauth column comment commit compress connect " +
133
+ "connected constant constraint crash create current currval cursor " +
134
+ "data_base database date dba deallocate debugoff debugon decimal declare default definition delay delete " +
135
+ "desc digits dispose distinct do drop " +
136
+ "else elsif enable end entry escape exception exception_init exchange exclusive exists exit external " +
137
+ "fast fetch file for force form from function " +
138
+ "generic goto grant group " +
139
+ "having " +
140
+ "identified if immediate in increment index indexes indicator initial initrans insert interface intersect " +
141
+ "into is " +
142
+ "key " +
143
+ "level library like limited local lock log logging long loop " +
144
+ "master maxextents maxtrans member minextents minus mislabel mode modify multiset " +
145
+ "new next no noaudit nocompress nologging noparallel not nowait number_base " +
146
+ "object of off offline on online only open option or order out " +
147
+ "package parallel partition pctfree pctincrease pctused pls_integer positive positiven pragma primary prior " +
148
+ "private privileges procedure public " +
149
+ "raise range raw read rebuild record ref references refresh release rename replace resource restrict return " +
150
+ "returning reverse revoke rollback row rowid rowlabel rownum rows run " +
151
+ "savepoint schema segment select separate session set share snapshot some space split sql start statement " +
152
+ "storage subtype successful synonym " +
153
+ "tabauth table tables tablespace task terminate then to trigger truncate type " +
154
+ "union unique unlimited unrecoverable unusable update use using " +
155
+ "validate value values variable view views " +
156
+ "when whenever where while with work";
157
+
158
+ var cFunctions = "abs acos add_months ascii asin atan atan2 average " +
159
+ "bfilename " +
160
+ "ceil chartorowid chr concat convert cos cosh count " +
161
+ "decode deref dual dump dup_val_on_index " +
162
+ "empty error exp " +
163
+ "false floor found " +
164
+ "glb greatest " +
165
+ "hextoraw " +
166
+ "initcap instr instrb isopen " +
167
+ "last_day least lenght lenghtb ln lower lpad ltrim lub " +
168
+ "make_ref max min mod months_between " +
169
+ "new_time next_day nextval nls_charset_decl_len nls_charset_id nls_charset_name nls_initcap nls_lower " +
170
+ "nls_sort nls_upper nlssort no_data_found notfound null nvl " +
171
+ "others " +
172
+ "power " +
173
+ "rawtohex reftohex round rowcount rowidtochar rpad rtrim " +
174
+ "sign sin sinh soundex sqlcode sqlerrm sqrt stddev substr substrb sum sysdate " +
175
+ "tan tanh to_char to_date to_label to_multi_byte to_number to_single_byte translate true trunc " +
176
+ "uid upper user userenv " +
177
+ "variance vsize";
178
+
179
+ var cTypes = "bfile blob " +
180
+ "character clob " +
181
+ "dec " +
182
+ "float " +
183
+ "int integer " +
184
+ "mlslabel " +
185
+ "natural naturaln nchar nclob number numeric nvarchar2 " +
186
+ "real rowtype " +
187
+ "signtype smallint string " +
188
+ "varchar varchar2";
189
+
190
+ var cSqlplus = "appinfo arraysize autocommit autoprint autorecovery autotrace " +
191
+ "blockterminator break btitle " +
192
+ "cmdsep colsep compatibility compute concat copycommit copytypecheck " +
193
+ "define describe " +
194
+ "echo editfile embedded escape exec execute " +
195
+ "feedback flagger flush " +
196
+ "heading headsep " +
197
+ "instance " +
198
+ "linesize lno loboffset logsource long longchunksize " +
199
+ "markup " +
200
+ "native newpage numformat numwidth " +
201
+ "pagesize pause pno " +
202
+ "recsep recsepchar release repfooter repheader " +
203
+ "serveroutput shiftinout show showmode size spool sqlblanklines sqlcase sqlcode sqlcontinue sqlnumber " +
204
+ "sqlpluscompatibility sqlprefix sqlprompt sqlterminator suffix " +
205
+ "tab term termout time timing trimout trimspool ttitle " +
206
+ "underline " +
207
+ "verify version " +
208
+ "wrap";
209
+
210
+ CodeMirror.defineMIME("text/x-plsql", {
211
+ name: "plsql",
212
+ keywords: keywords(cKeywords),
213
+ functions: keywords(cFunctions),
214
+ types: keywords(cTypes),
215
+ sqlplus: keywords(cSqlplus)
216
+ });
217
+ }());