marty 2.4.7 → 2.4.8

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 (225) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile.dummy +8 -5
  3. data/Gemfile.lock +1 -1
  4. data/README.md +8 -0
  5. data/app/assets/javascripts/marty/application.js +1 -0
  6. data/app/assets/javascripts/marty/codemirror/codemirror.js +9730 -0
  7. data/app/{components/marty/script_form/client → assets/javascripts/marty/codemirror}/mode/delorean/delorean.js +0 -0
  8. data/app/assets/javascripts/marty/codemirror/mode/javascript/javascript.js +900 -0
  9. data/app/assets/javascripts/marty/codemirror/mode/python/python.js +399 -0
  10. data/app/{components/marty/script_form/client → assets/javascripts/marty/codemirror}/mode/ruby/ruby.js +135 -34
  11. data/app/{components/marty/script_form/client/Ext.ux.form.field.CodeMirror.js → assets/javascripts/marty/extjs/extensions/marty.js} +87 -6
  12. data/app/assets/stylesheets/marty/application.css +1 -13
  13. data/app/assets/stylesheets/marty/codemirror/codemirror.css +346 -0
  14. data/app/{components/marty/script_form/client → assets/stylesheets/marty/codemirror}/delorean.css +0 -0
  15. data/app/components/marty/auth_app/client/auth_app.js +82 -80
  16. data/app/components/marty/data_grid_view.rb +1 -54
  17. data/app/components/marty/data_grid_view/client/data_grid_view.js +49 -0
  18. data/app/components/marty/form.rb +1 -5
  19. data/app/components/marty/form/client/form.js +5 -0
  20. data/app/components/marty/grid.rb +1 -146
  21. data/app/components/marty/grid/client/grid.js +146 -0
  22. data/app/components/marty/import_view.rb +1 -32
  23. data/app/components/marty/import_view/client/import_view.js +32 -0
  24. data/app/components/marty/live_search_grid_panel.rb +1 -21
  25. data/app/components/marty/live_search_grid_panel/client/live_search_grid_panel.js +27 -0
  26. data/app/components/marty/main_auth_app.rb +4 -145
  27. data/app/components/marty/main_auth_app/client/main_auth_app.js +124 -0
  28. data/app/components/marty/mcfly_grid_panel.rb +1 -17
  29. data/app/components/marty/mcfly_grid_panel/client/mcfly_grid_panel.js +37 -0
  30. data/app/components/marty/new_posting_form.rb +1 -6
  31. data/app/components/marty/new_posting_form/client/new_posting_form.js +6 -0
  32. data/app/components/marty/panel.rb +1 -5
  33. data/app/components/marty/panel/client/panel.js +5 -0
  34. data/app/components/marty/posting_grid.rb +4 -55
  35. data/app/components/marty/posting_grid/client/posting_grid.js +50 -0
  36. data/app/components/marty/promise_view.rb +2 -75
  37. data/app/components/marty/promise_view/client/promise_view.css +12 -9
  38. data/app/components/marty/promise_view/client/promise_view.js +57 -0
  39. data/app/components/marty/report_form.rb +3 -69
  40. data/app/components/marty/report_form/client/report_form.js +78 -0
  41. data/app/components/marty/report_select.rb +1 -45
  42. data/app/components/marty/report_select/client/report_select.js +50 -0
  43. data/app/components/marty/reporting.rb +1 -8
  44. data/app/components/marty/reporting/client/reporting.js +8 -0
  45. data/app/components/marty/script_form.rb +2 -63
  46. data/app/components/marty/script_form/client/script_form.js +44 -0
  47. data/app/components/marty/script_tester.rb +1 -7
  48. data/app/components/marty/script_tester/client/script_tester.js +7 -0
  49. data/app/components/marty/scripting.rb +1 -55
  50. data/app/components/marty/scripting/client/scripting.js +62 -0
  51. data/app/components/marty/simple_app/client/simple_app.js +21 -13
  52. data/app/models/marty/promise.rb +22 -1
  53. data/app/views/layouts/marty/application.html.erb +8 -6
  54. data/docker-compose.dummy.yml +2 -0
  55. data/lib/marty/monkey.rb +0 -16
  56. data/lib/marty/version.rb +1 -1
  57. data/spec/dummy/config/initializers/assets.rb +1 -0
  58. data/spec/features/reporting_spec.rb +1 -0
  59. data/spec/features/scripting_spec.rb +4 -4
  60. data/spec/spec_helper.rb +1 -0
  61. data/spec/support/chromedriver.rb +5 -1
  62. data/spec/support/shared_connection_db_helpers.rb +42 -2
  63. metadata +29 -168
  64. data/app/assets/images/marty/.gitkeep +0 -0
  65. data/app/components/marty/mcfly_grid_panel/client/dup_in_form.js +0 -20
  66. data/app/components/marty/script_form/client/codemirror.css +0 -172
  67. data/app/components/marty/script_form/client/codemirror.js +0 -3130
  68. data/app/components/marty/script_form/client/mode/clike/clike.js +0 -284
  69. data/app/components/marty/script_form/client/mode/clike/index.html +0 -102
  70. data/app/components/marty/script_form/client/mode/clike/scala.html +0 -766
  71. data/app/components/marty/script_form/client/mode/clojure/clojure.js +0 -206
  72. data/app/components/marty/script_form/client/mode/clojure/index.html +0 -67
  73. data/app/components/marty/script_form/client/mode/coffeescript/LICENSE +0 -22
  74. data/app/components/marty/script_form/client/mode/coffeescript/coffeescript.js +0 -346
  75. data/app/components/marty/script_form/client/mode/coffeescript/index.html +0 -728
  76. data/app/components/marty/script_form/client/mode/commonlisp/commonlisp.js +0 -101
  77. data/app/components/marty/script_form/client/mode/commonlisp/index.html +0 -165
  78. data/app/components/marty/script_form/client/mode/css/css.js +0 -448
  79. data/app/components/marty/script_form/client/mode/css/index.html +0 -58
  80. data/app/components/marty/script_form/client/mode/css/test.js +0 -501
  81. data/app/components/marty/script_form/client/mode/diff/diff.js +0 -32
  82. data/app/components/marty/script_form/client/mode/diff/index.html +0 -105
  83. data/app/components/marty/script_form/client/mode/ecl/ecl.js +0 -203
  84. data/app/components/marty/script_form/client/mode/ecl/index.html +0 -42
  85. data/app/components/marty/script_form/client/mode/erlang/erlang.js +0 -463
  86. data/app/components/marty/script_form/client/mode/erlang/index.html +0 -63
  87. data/app/components/marty/script_form/client/mode/gfm/gfm.js +0 -150
  88. data/app/components/marty/script_form/client/mode/gfm/index.html +0 -48
  89. data/app/components/marty/script_form/client/mode/go/go.js +0 -170
  90. data/app/components/marty/script_form/client/mode/go/index.html +0 -73
  91. data/app/components/marty/script_form/client/mode/groovy/groovy.js +0 -210
  92. data/app/components/marty/script_form/client/mode/groovy/index.html +0 -72
  93. data/app/components/marty/script_form/client/mode/haskell/haskell.js +0 -242
  94. data/app/components/marty/script_form/client/mode/haskell/index.html +0 -61
  95. data/app/components/marty/script_form/client/mode/haxe/haxe.js +0 -429
  96. data/app/components/marty/script_form/client/mode/haxe/index.html +0 -91
  97. data/app/components/marty/script_form/client/mode/htmlembedded/htmlembedded.js +0 -72
  98. data/app/components/marty/script_form/client/mode/htmlembedded/index.html +0 -50
  99. data/app/components/marty/script_form/client/mode/htmlmixed/htmlmixed.js +0 -84
  100. data/app/components/marty/script_form/client/mode/htmlmixed/index.html +0 -52
  101. data/app/components/marty/script_form/client/mode/javascript/index.html +0 -78
  102. data/app/components/marty/script_form/client/mode/javascript/javascript.js +0 -361
  103. data/app/components/marty/script_form/client/mode/jinja2/index.html +0 -38
  104. data/app/components/marty/script_form/client/mode/jinja2/jinja2.js +0 -42
  105. data/app/components/marty/script_form/client/mode/less/index.html +0 -740
  106. data/app/components/marty/script_form/client/mode/less/less.js +0 -266
  107. data/app/components/marty/script_form/client/mode/lua/index.html +0 -73
  108. data/app/components/marty/script_form/client/mode/lua/lua.js +0 -140
  109. data/app/components/marty/script_form/client/mode/markdown/index.html +0 -343
  110. data/app/components/marty/script_form/client/mode/markdown/markdown.js +0 -382
  111. data/app/components/marty/script_form/client/mode/markdown/test.js +0 -1084
  112. data/app/components/marty/script_form/client/mode/mysql/index.html +0 -42
  113. data/app/components/marty/script_form/client/mode/mysql/mysql.js +0 -186
  114. data/app/components/marty/script_form/client/mode/ntriples/index.html +0 -33
  115. data/app/components/marty/script_form/client/mode/ntriples/ntriples.js +0 -172
  116. data/app/components/marty/script_form/client/mode/ocaml/index.html +0 -130
  117. data/app/components/marty/script_form/client/mode/ocaml/ocaml.js +0 -114
  118. data/app/components/marty/script_form/client/mode/pascal/LICENSE +0 -7
  119. data/app/components/marty/script_form/client/mode/pascal/index.html +0 -49
  120. data/app/components/marty/script_form/client/mode/pascal/pascal.js +0 -94
  121. data/app/components/marty/script_form/client/mode/perl/LICENSE +0 -19
  122. data/app/components/marty/script_form/client/mode/perl/index.html +0 -63
  123. data/app/components/marty/script_form/client/mode/perl/perl.js +0 -816
  124. data/app/components/marty/script_form/client/mode/php/index.html +0 -49
  125. data/app/components/marty/script_form/client/mode/php/php.js +0 -148
  126. data/app/components/marty/script_form/client/mode/pig/index.html +0 -43
  127. data/app/components/marty/script_form/client/mode/pig/pig.js +0 -172
  128. data/app/components/marty/script_form/client/mode/plsql/index.html +0 -63
  129. data/app/components/marty/script_form/client/mode/plsql/plsql.js +0 -217
  130. data/app/components/marty/script_form/client/mode/properties/index.html +0 -41
  131. data/app/components/marty/script_form/client/mode/properties/properties.js +0 -63
  132. data/app/components/marty/script_form/client/mode/python/LICENSE.txt +0 -21
  133. data/app/components/marty/script_form/client/mode/python/index.html +0 -123
  134. data/app/components/marty/script_form/client/mode/python/python.js +0 -338
  135. data/app/components/marty/script_form/client/mode/r/LICENSE +0 -24
  136. data/app/components/marty/script_form/client/mode/r/index.html +0 -74
  137. data/app/components/marty/script_form/client/mode/r/r.js +0 -141
  138. data/app/components/marty/script_form/client/mode/rpm/changes/changes.js +0 -19
  139. data/app/components/marty/script_form/client/mode/rpm/changes/index.html +0 -54
  140. data/app/components/marty/script_form/client/mode/rpm/spec/index.html +0 -100
  141. data/app/components/marty/script_form/client/mode/rpm/spec/spec.css +0 -5
  142. data/app/components/marty/script_form/client/mode/rpm/spec/spec.js +0 -66
  143. data/app/components/marty/script_form/client/mode/rst/index.html +0 -526
  144. data/app/components/marty/script_form/client/mode/rst/rst.js +0 -326
  145. data/app/components/marty/script_form/client/mode/ruby/LICENSE +0 -24
  146. data/app/components/marty/script_form/client/mode/ruby/index.html +0 -172
  147. data/app/components/marty/script_form/client/mode/rust/index.html +0 -49
  148. data/app/components/marty/script_form/client/mode/rust/rust.js +0 -432
  149. data/app/components/marty/script_form/client/mode/scheme/index.html +0 -65
  150. data/app/components/marty/script_form/client/mode/scheme/scheme.js +0 -230
  151. data/app/components/marty/script_form/client/mode/shell/index.html +0 -50
  152. data/app/components/marty/script_form/client/mode/shell/shell.js +0 -118
  153. data/app/components/marty/script_form/client/mode/sieve/LICENSE +0 -23
  154. data/app/components/marty/script_form/client/mode/sieve/index.html +0 -81
  155. data/app/components/marty/script_form/client/mode/sieve/sieve.js +0 -156
  156. data/app/components/marty/script_form/client/mode/smalltalk/index.html +0 -56
  157. data/app/components/marty/script_form/client/mode/smalltalk/smalltalk.js +0 -139
  158. data/app/components/marty/script_form/client/mode/smarty/index.html +0 -83
  159. data/app/components/marty/script_form/client/mode/smarty/smarty.js +0 -148
  160. data/app/components/marty/script_form/client/mode/sparql/index.html +0 -41
  161. data/app/components/marty/script_form/client/mode/sparql/sparql.js +0 -143
  162. data/app/components/marty/script_form/client/mode/stex/index.html +0 -98
  163. data/app/components/marty/script_form/client/mode/stex/stex.js +0 -182
  164. data/app/components/marty/script_form/client/mode/stex/test.js +0 -343
  165. data/app/components/marty/script_form/client/mode/tiddlywiki/index.html +0 -141
  166. data/app/components/marty/script_form/client/mode/tiddlywiki/tiddlywiki.css +0 -14
  167. data/app/components/marty/script_form/client/mode/tiddlywiki/tiddlywiki.js +0 -384
  168. data/app/components/marty/script_form/client/mode/tiki/index.html +0 -83
  169. data/app/components/marty/script_form/client/mode/tiki/tiki.css +0 -26
  170. data/app/components/marty/script_form/client/mode/tiki/tiki.js +0 -309
  171. data/app/components/marty/script_form/client/mode/vb/LICENSE.txt +0 -21
  172. data/app/components/marty/script_form/client/mode/vb/index.html +0 -89
  173. data/app/components/marty/script_form/client/mode/vb/vb.js +0 -260
  174. data/app/components/marty/script_form/client/mode/vbscript/index.html +0 -43
  175. data/app/components/marty/script_form/client/mode/vbscript/vbscript.js +0 -26
  176. data/app/components/marty/script_form/client/mode/velocity/index.html +0 -104
  177. data/app/components/marty/script_form/client/mode/velocity/velocity.js +0 -146
  178. data/app/components/marty/script_form/client/mode/verilog/index.html +0 -211
  179. data/app/components/marty/script_form/client/mode/verilog/verilog.js +0 -194
  180. data/app/components/marty/script_form/client/mode/xml/index.html +0 -45
  181. data/app/components/marty/script_form/client/mode/xml/xml.js +0 -318
  182. data/app/components/marty/script_form/client/mode/xquery/LICENSE +0 -20
  183. data/app/components/marty/script_form/client/mode/xquery/index.html +0 -223
  184. data/app/components/marty/script_form/client/mode/xquery/test/index.html +0 -27
  185. data/app/components/marty/script_form/client/mode/xquery/test/testBase.js +0 -42
  186. data/app/components/marty/script_form/client/mode/xquery/test/testEmptySequenceKeyword.js +0 -16
  187. data/app/components/marty/script_form/client/mode/xquery/test/testMultiAttr.js +0 -16
  188. data/app/components/marty/script_form/client/mode/xquery/test/testNamespaces.js +0 -91
  189. data/app/components/marty/script_form/client/mode/xquery/test/testProcessingInstructions.js +0 -16
  190. data/app/components/marty/script_form/client/mode/xquery/test/testQuotes.js +0 -19
  191. data/app/components/marty/script_form/client/mode/xquery/xquery.js +0 -451
  192. data/app/components/marty/script_form/client/mode/yaml/index.html +0 -68
  193. data/app/components/marty/script_form/client/mode/yaml/yaml.js +0 -95
  194. data/app/components/marty/script_form/client/theme/ambiance.css +0 -81
  195. data/app/components/marty/script_form/client/theme/blackboard.css +0 -25
  196. data/app/components/marty/script_form/client/theme/cobalt.css +0 -18
  197. data/app/components/marty/script_form/client/theme/eclipse.css +0 -25
  198. data/app/components/marty/script_form/client/theme/elegant.css +0 -10
  199. data/app/components/marty/script_form/client/theme/erlang-dark.css +0 -21
  200. data/app/components/marty/script_form/client/theme/lesser-dark.css +0 -44
  201. data/app/components/marty/script_form/client/theme/monokai.css +0 -28
  202. data/app/components/marty/script_form/client/theme/neat.css +0 -9
  203. data/app/components/marty/script_form/client/theme/night.css +0 -21
  204. data/app/components/marty/script_form/client/theme/rubyblue.css +0 -21
  205. data/app/components/marty/script_form/client/theme/vibrant-ink.css +0 -27
  206. data/app/components/marty/script_form/client/theme/xq-dark.css +0 -46
  207. data/app/components/marty/script_form/client/util/closetag.js +0 -164
  208. data/app/components/marty/script_form/client/util/dialog.css +0 -27
  209. data/app/components/marty/script_form/client/util/dialog.js +0 -70
  210. data/app/components/marty/script_form/client/util/foldcode.js +0 -196
  211. data/app/components/marty/script_form/client/util/formatting.js +0 -193
  212. data/app/components/marty/script_form/client/util/javascript-hint.js +0 -134
  213. data/app/components/marty/script_form/client/util/loadmode.js +0 -51
  214. data/app/components/marty/script_form/client/util/match-highlighter.js +0 -44
  215. data/app/components/marty/script_form/client/util/multiplex.js +0 -77
  216. data/app/components/marty/script_form/client/util/overlay.js +0 -54
  217. data/app/components/marty/script_form/client/util/pig-hint.js +0 -123
  218. data/app/components/marty/script_form/client/util/runmode-standalone.js +0 -90
  219. data/app/components/marty/script_form/client/util/runmode.js +0 -53
  220. data/app/components/marty/script_form/client/util/search.js +0 -118
  221. data/app/components/marty/script_form/client/util/searchcursor.js +0 -119
  222. data/app/components/marty/script_form/client/util/simple-hint.css +0 -16
  223. data/app/components/marty/script_form/client/util/simple-hint.js +0 -97
  224. data/app/components/marty/script_form/client/util/xml-hint.js +0 -137
  225. data/lib/marty/javascript/grid_view_in_form.js +0 -81
@@ -1,193 +0,0 @@
1
- // ============== Formatting extensions ============================
2
- (function() {
3
- // Define extensions for a few modes
4
- CodeMirror.extendMode("css", {
5
- commentStart: "/*",
6
- commentEnd: "*/",
7
- wordWrapChars: [";", "\\{", "\\}"],
8
- autoFormatLineBreaks: function (text) {
9
- return text.replace(new RegExp("(;|\\{|\\})([^\r\n])", "g"), "$1\n$2");
10
- }
11
- });
12
-
13
- function jsNonBreakableBlocks(text) {
14
- var nonBreakableRegexes = [/for\s*?\((.*?)\)/,
15
- /\"(.*?)(\"|$)/,
16
- /\'(.*?)(\'|$)/,
17
- /\/\*(.*?)(\*\/|$)/,
18
- /\/\/.*/];
19
- var nonBreakableBlocks = [];
20
- for (var i = 0; i < nonBreakableRegexes.length; i++) {
21
- var curPos = 0;
22
- while (curPos < text.length) {
23
- var m = text.substr(curPos).match(nonBreakableRegexes[i]);
24
- if (m != null) {
25
- nonBreakableBlocks.push({
26
- start: curPos + m.index,
27
- end: curPos + m.index + m[0].length
28
- });
29
- curPos += m.index + Math.max(1, m[0].length);
30
- }
31
- else { // No more matches
32
- break;
33
- }
34
- }
35
- }
36
- nonBreakableBlocks.sort(function (a, b) {
37
- return a.start - b.start;
38
- });
39
-
40
- return nonBreakableBlocks;
41
- }
42
-
43
- CodeMirror.extendMode("javascript", {
44
- commentStart: "/*",
45
- commentEnd: "*/",
46
- wordWrapChars: [";", "\\{", "\\}"],
47
-
48
- autoFormatLineBreaks: function (text) {
49
- var curPos = 0;
50
- var reLinesSplitter = /(;|\{|\})([^\r\n;])/g;
51
- var nonBreakableBlocks = jsNonBreakableBlocks(text);
52
- if (nonBreakableBlocks != null) {
53
- var res = "";
54
- for (var i = 0; i < nonBreakableBlocks.length; i++) {
55
- if (nonBreakableBlocks[i].start > curPos) { // Break lines till the block
56
- res += text.substring(curPos, nonBreakableBlocks[i].start).replace(reLinesSplitter, "$1\n$2");
57
- curPos = nonBreakableBlocks[i].start;
58
- }
59
- if (nonBreakableBlocks[i].start <= curPos
60
- && nonBreakableBlocks[i].end >= curPos) { // Skip non-breakable block
61
- res += text.substring(curPos, nonBreakableBlocks[i].end);
62
- curPos = nonBreakableBlocks[i].end;
63
- }
64
- }
65
- if (curPos < text.length)
66
- res += text.substr(curPos).replace(reLinesSplitter, "$1\n$2");
67
- return res;
68
- } else {
69
- return text.replace(reLinesSplitter, "$1\n$2");
70
- }
71
- }
72
- });
73
-
74
- CodeMirror.extendMode("xml", {
75
- commentStart: "<!--",
76
- commentEnd: "-->",
77
- wordWrapChars: [">"],
78
-
79
- autoFormatLineBreaks: function (text) {
80
- var lines = text.split("\n");
81
- var reProcessedPortion = new RegExp("(^\\s*?<|^[^<]*?)(.+)(>\\s*?$|[^>]*?$)");
82
- var reOpenBrackets = new RegExp("<", "g");
83
- var reCloseBrackets = new RegExp("(>)([^\r\n])", "g");
84
- for (var i = 0; i < lines.length; i++) {
85
- var mToProcess = lines[i].match(reProcessedPortion);
86
- if (mToProcess != null && mToProcess.length > 3) { // The line starts with whitespaces and ends with whitespaces
87
- lines[i] = mToProcess[1]
88
- + mToProcess[2].replace(reOpenBrackets, "\n$&").replace(reCloseBrackets, "$1\n$2")
89
- + mToProcess[3];
90
- continue;
91
- }
92
- }
93
- return lines.join("\n");
94
- }
95
- });
96
-
97
- function localModeAt(cm, pos) {
98
- return CodeMirror.innerMode(cm.getMode(), cm.getTokenAt(pos).state).mode;
99
- }
100
-
101
- function enumerateModesBetween(cm, line, start, end) {
102
- var outer = cm.getMode(), text = cm.getLine(line);
103
- if (end == null) end = text.length;
104
- if (!outer.innerMode) return [{from: start, to: end, mode: outer}];
105
- var state = cm.getTokenAt({line: line, ch: start}).state;
106
- var mode = CodeMirror.innerMode(outer, state).mode;
107
- var found = [], stream = new CodeMirror.StringStream(text);
108
- stream.pos = stream.start = start;
109
- for (;;) {
110
- outer.token(stream, state);
111
- var curMode = CodeMirror.innerMode(outer, state).mode;
112
- if (curMode != mode) {
113
- var cut = stream.start;
114
- // Crappy heuristic to deal with the fact that a change in
115
- // mode can occur both at the end and the start of a token,
116
- // and we don't know which it was.
117
- if (mode.name == "xml" && text.charAt(stream.pos - 1) == ">") cut = stream.pos;
118
- found.push({from: start, to: cut, mode: mode});
119
- start = cut;
120
- mode = curMode;
121
- }
122
- if (stream.pos >= end) break;
123
- stream.start = stream.pos;
124
- }
125
- if (start < end) found.push({from: start, to: end, mode: mode});
126
- return found;
127
- }
128
-
129
- // Comment/uncomment the specified range
130
- CodeMirror.defineExtension("commentRange", function (isComment, from, to) {
131
- var curMode = localModeAt(this, from);
132
- this.operation(function() {
133
- if (isComment) { // Comment range
134
- this.replaceRange(curMode.commentEnd, to);
135
- this.replaceRange(curMode.commentStart, from);
136
- if (from.line == to.line && from.ch == to.ch) // An empty comment inserted - put cursor inside
137
- this.setCursor(from.line, from.ch + curMode.commentStart.length);
138
- } else { // Uncomment range
139
- var selText = this.getRange(from, to);
140
- var startIndex = selText.indexOf(curMode.commentStart);
141
- var endIndex = selText.lastIndexOf(curMode.commentEnd);
142
- if (startIndex > -1 && endIndex > -1 && endIndex > startIndex) {
143
- // Take string till comment start
144
- selText = selText.substr(0, startIndex)
145
- // From comment start till comment end
146
- + selText.substring(startIndex + curMode.commentStart.length, endIndex)
147
- // From comment end till string end
148
- + selText.substr(endIndex + curMode.commentEnd.length);
149
- }
150
- this.replaceRange(selText, from, to);
151
- }
152
- });
153
- });
154
-
155
- // Applies automatic mode-aware indentation to the specified range
156
- CodeMirror.defineExtension("autoIndentRange", function (from, to) {
157
- var cmInstance = this;
158
- this.operation(function () {
159
- for (var i = from.line; i <= to.line; i++) {
160
- cmInstance.indentLine(i, "smart");
161
- }
162
- });
163
- });
164
-
165
- // Applies automatic formatting to the specified range
166
- CodeMirror.defineExtension("autoFormatRange", function (from, to) {
167
- var cm = this;
168
- cm.operation(function () {
169
- for (var cur = from.line, end = to.line; cur <= end; ++cur) {
170
- var f = {line: cur, ch: cur == from.line ? from.ch : 0};
171
- var t = {line: cur, ch: cur == end ? to.ch : null};
172
- var modes = enumerateModesBetween(cm, cur, f.ch, t.ch), mangled = "";
173
- var text = cm.getRange(f, t);
174
- for (var i = 0; i < modes.length; ++i) {
175
- var part = modes.length > 1 ? text.slice(modes[i].from, modes[i].to) : text;
176
- if (mangled) mangled += "\n";
177
- if (modes[i].mode.autoFormatLineBreaks) {
178
- mangled += modes[i].mode.autoFormatLineBreaks(part);
179
- } else mangled += text;
180
- }
181
- if (mangled != text) {
182
- for (var count = 0, pos = mangled.indexOf("\n"); pos != -1; pos = mangled.indexOf("\n", pos + 1), ++count) {}
183
- cm.replaceRange(mangled, f, t);
184
- cur += count;
185
- end += count;
186
- }
187
- }
188
- for (var cur = from.line + 1; cur <= end; ++cur)
189
- cm.indentLine(cur, "smart");
190
- cm.setSelection(from, cm.getCursor(false));
191
- });
192
- });
193
- })();
@@ -1,134 +0,0 @@
1
- (function () {
2
- function forEach(arr, f) {
3
- for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
4
- }
5
-
6
- function arrayContains(arr, item) {
7
- if (!Array.prototype.indexOf) {
8
- var i = arr.length;
9
- while (i--) {
10
- if (arr[i] === item) {
11
- return true;
12
- }
13
- }
14
- return false;
15
- }
16
- return arr.indexOf(item) != -1;
17
- }
18
-
19
- function scriptHint(editor, keywords, getToken) {
20
- // Find the token at the cursor
21
- var cur = editor.getCursor(), token = getToken(editor, cur), tprop = token;
22
- // If it's not a 'word-style' token, ignore the token.
23
- if (!/^[\w$_]*$/.test(token.string)) {
24
- token = tprop = {start: cur.ch, end: cur.ch, string: "", state: token.state,
25
- className: token.string == "." ? "property" : null};
26
- }
27
- // If it is a property, find out what it is a property of.
28
- while (tprop.className == "property") {
29
- tprop = getToken(editor, {line: cur.line, ch: tprop.start});
30
- if (tprop.string != ".") return;
31
- tprop = getToken(editor, {line: cur.line, ch: tprop.start});
32
- if (tprop.string == ')') {
33
- var level = 1;
34
- do {
35
- tprop = getToken(editor, {line: cur.line, ch: tprop.start});
36
- switch (tprop.string) {
37
- case ')': level++; break;
38
- case '(': level--; break;
39
- default: break;
40
- }
41
- } while (level > 0);
42
- tprop = getToken(editor, {line: cur.line, ch: tprop.start});
43
- if (tprop.className == 'variable')
44
- tprop.className = 'function';
45
- else return; // no clue
46
- }
47
- if (!context) var context = [];
48
- context.push(tprop);
49
- }
50
- return {list: getCompletions(token, context, keywords),
51
- from: {line: cur.line, ch: token.start},
52
- to: {line: cur.line, ch: token.end}};
53
- }
54
-
55
- CodeMirror.javascriptHint = function(editor) {
56
- return scriptHint(editor, javascriptKeywords,
57
- function (e, cur) {return e.getTokenAt(cur);});
58
- };
59
-
60
- function getCoffeeScriptToken(editor, cur) {
61
- // This getToken, it is for coffeescript, imitates the behavior of
62
- // getTokenAt method in javascript.js, that is, returning "property"
63
- // type and treat "." as indepenent token.
64
- var token = editor.getTokenAt(cur);
65
- if (cur.ch == token.start + 1 && token.string.charAt(0) == '.') {
66
- token.end = token.start;
67
- token.string = '.';
68
- token.className = "property";
69
- }
70
- else if (/^\.[\w$_]*$/.test(token.string)) {
71
- token.className = "property";
72
- token.start++;
73
- token.string = token.string.replace(/\./, '');
74
- }
75
- return token;
76
- }
77
-
78
- CodeMirror.coffeescriptHint = function(editor) {
79
- return scriptHint(editor, coffeescriptKeywords, getCoffeeScriptToken);
80
- };
81
-
82
- var stringProps = ("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight " +
83
- "toUpperCase toLowerCase split concat match replace search").split(" ");
84
- var arrayProps = ("length concat join splice push pop shift unshift slice reverse sort indexOf " +
85
- "lastIndexOf every some filter forEach map reduce reduceRight ").split(" ");
86
- var funcProps = "prototype apply call bind".split(" ");
87
- var javascriptKeywords = ("break case catch continue debugger default delete do else false finally for function " +
88
- "if in instanceof new null return switch throw true try typeof var void while with").split(" ");
89
- var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
90
- "if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");
91
-
92
- function getCompletions(token, context, keywords) {
93
- var found = [], start = token.string;
94
- function maybeAdd(str) {
95
- if (str.indexOf(start) == 0 && !arrayContains(found, str)) found.push(str);
96
- }
97
- function gatherCompletions(obj) {
98
- if (typeof obj == "string") forEach(stringProps, maybeAdd);
99
- else if (obj instanceof Array) forEach(arrayProps, maybeAdd);
100
- else if (obj instanceof Function) forEach(funcProps, maybeAdd);
101
- for (var name in obj) maybeAdd(name);
102
- }
103
-
104
- if (context) {
105
- // If this is a property, see if it belongs to some object we can
106
- // find in the current environment.
107
- var obj = context.pop(), base;
108
- if (obj.className == "variable")
109
- base = window[obj.string];
110
- else if (obj.className == "string")
111
- base = "";
112
- else if (obj.className == "atom")
113
- base = 1;
114
- else if (obj.className == "function") {
115
- if (window.jQuery != null && (obj.string == '$' || obj.string == 'jQuery') &&
116
- (typeof window.jQuery == 'function'))
117
- base = window.jQuery();
118
- else if (window._ != null && (obj.string == '_') && (typeof window._ == 'function'))
119
- base = window._();
120
- }
121
- while (base != null && context.length)
122
- base = base[context.pop().string];
123
- if (base != null) gatherCompletions(base);
124
- }
125
- else {
126
- // If not, just look in the window object and any local scope
127
- // (reading into JS mode internals to get at the local variables)
128
- for (var v = token.state.localVars; v; v = v.next) maybeAdd(v.name);
129
- gatherCompletions(window);
130
- forEach(keywords, maybeAdd);
131
- }
132
- return found;
133
- }
134
- })();
@@ -1,51 +0,0 @@
1
- (function() {
2
- if (!CodeMirror.modeURL) CodeMirror.modeURL = "../mode/%N/%N.js";
3
-
4
- var loading = {};
5
- function splitCallback(cont, n) {
6
- var countDown = n;
7
- return function() { if (--countDown == 0) cont(); };
8
- }
9
- function ensureDeps(mode, cont) {
10
- var deps = CodeMirror.modes[mode].dependencies;
11
- if (!deps) return cont();
12
- var missing = [];
13
- for (var i = 0; i < deps.length; ++i) {
14
- if (!CodeMirror.modes.hasOwnProperty(deps[i]))
15
- missing.push(deps[i]);
16
- }
17
- if (!missing.length) return cont();
18
- var split = splitCallback(cont, missing.length);
19
- for (var i = 0; i < missing.length; ++i)
20
- CodeMirror.requireMode(missing[i], split);
21
- }
22
-
23
- CodeMirror.requireMode = function(mode, cont) {
24
- if (typeof mode != "string") mode = mode.name;
25
- if (CodeMirror.modes.hasOwnProperty(mode)) return ensureDeps(mode, cont);
26
- if (loading.hasOwnProperty(mode)) return loading[mode].push(cont);
27
-
28
- var script = document.createElement("script");
29
- script.src = CodeMirror.modeURL.replace(/%N/g, mode);
30
- var others = document.getElementsByTagName("script")[0];
31
- others.parentNode.insertBefore(script, others);
32
- var list = loading[mode] = [cont];
33
- var count = 0, poll = setInterval(function() {
34
- if (++count > 100) return clearInterval(poll);
35
- if (CodeMirror.modes.hasOwnProperty(mode)) {
36
- clearInterval(poll);
37
- loading[mode] = null;
38
- ensureDeps(mode, function() {
39
- for (var i = 0; i < list.length; ++i) list[i]();
40
- });
41
- }
42
- }, 200);
43
- };
44
-
45
- CodeMirror.autoLoadMode = function(instance, mode) {
46
- if (!CodeMirror.modes.hasOwnProperty(mode))
47
- CodeMirror.requireMode(mode, function() {
48
- instance.setOption("mode", instance.getOption("mode"));
49
- });
50
- };
51
- }());
@@ -1,44 +0,0 @@
1
- // Define match-highlighter commands. Depends on searchcursor.js
2
- // Use by attaching the following function call to the onCursorActivity event:
3
- //myCodeMirror.matchHighlight(minChars);
4
- // And including a special span.CodeMirror-matchhighlight css class (also optionally a separate one for .CodeMirror-focused -- see demo matchhighlighter.html)
5
-
6
- (function() {
7
- var DEFAULT_MIN_CHARS = 2;
8
-
9
- function MatchHighlightState() {
10
- this.marked = [];
11
- }
12
- function getMatchHighlightState(cm) {
13
- return cm._matchHighlightState || (cm._matchHighlightState = new MatchHighlightState());
14
- }
15
-
16
- function clearMarks(cm) {
17
- var state = getMatchHighlightState(cm);
18
- for (var i = 0; i < state.marked.length; ++i)
19
- state.marked[i].clear();
20
- state.marked = [];
21
- }
22
-
23
- function markDocument(cm, className, minChars) {
24
- clearMarks(cm);
25
- minChars = (typeof minChars !== 'undefined' ? minChars : DEFAULT_MIN_CHARS);
26
- if (cm.somethingSelected() && cm.getSelection().replace(/^\s+|\s+$/g, "").length >= minChars) {
27
- var state = getMatchHighlightState(cm);
28
- var query = cm.getSelection();
29
- cm.operation(function() {
30
- if (cm.lineCount() < 2000) { // This is too expensive on big documents.
31
- for (var cursor = cm.getSearchCursor(query); cursor.findNext();) {
32
- //Only apply matchhighlight to the matches other than the one actually selected
33
- if (!(cursor.from().line === cm.getCursor(true).line && cursor.from().ch === cm.getCursor(true).ch))
34
- state.marked.push(cm.markText(cursor.from(), cursor.to(), className));
35
- }
36
- }
37
- });
38
- }
39
- }
40
-
41
- CodeMirror.defineExtension("matchHighlight", function(className, minChars) {
42
- markDocument(this, className, minChars);
43
- });
44
- })();
@@ -1,77 +0,0 @@
1
- CodeMirror.multiplexingMode = function(outer /*, others */) {
2
- // Others should be {open, close, mode [, delimStyle]} objects
3
- var others = Array.prototype.slice.call(arguments, 1);
4
- var n_others = others.length;
5
-
6
- function indexOf(string, pattern, from) {
7
- if (typeof pattern == "string") return string.indexOf(pattern, from);
8
- var m = pattern.exec(from ? string.slice(from) : string);
9
- return m ? m.index + from : -1;
10
- }
11
-
12
- return {
13
- startState: function() {
14
- return {
15
- outer: CodeMirror.startState(outer),
16
- innerActive: null,
17
- inner: null
18
- };
19
- },
20
-
21
- copyState: function(state) {
22
- return {
23
- outer: CodeMirror.copyState(outer, state.outer),
24
- innerActive: state.innerActive,
25
- inner: state.innerActive && CodeMirror.copyState(state.innerActive.mode, state.inner)
26
- };
27
- },
28
-
29
- token: function(stream, state) {
30
- if (!state.innerActive) {
31
- var cutOff = Infinity, oldContent = stream.string;
32
- for (var i = 0; i < n_others; ++i) {
33
- var other = others[i];
34
- var found = indexOf(oldContent, other.open, stream.pos);
35
- if (found == stream.pos) {
36
- stream.match(other.open);
37
- state.innerActive = other;
38
- state.inner = CodeMirror.startState(other.mode, outer.indent ? outer.indent(state.outer, "") : 0);
39
- return other.delimStyle;
40
- } else if (found != -1 && found < cutOff) {
41
- cutOff = found;
42
- }
43
- }
44
- if (cutOff != Infinity) stream.string = oldContent.slice(0, cutOff);
45
- var outerToken = outer.token(stream, state.outer);
46
- if (cutOff != Infinity) stream.string = oldContent;
47
- return outerToken;
48
- } else {
49
- var curInner = state.innerActive, oldContent = stream.string;
50
- var found = indexOf(oldContent, curInner.close, stream.pos);
51
- if (found == stream.pos) {
52
- stream.match(curInner.close);
53
- state.innerActive = state.inner = null;
54
- return curInner.delimStyle;
55
- }
56
- if (found > -1) stream.string = oldContent.slice(0, found);
57
- var innerToken = curInner.mode.token(stream, state.inner);
58
- if (found > -1) stream.string = oldContent;
59
- var cur = stream.current(), found = cur.indexOf(curInner.close);
60
- if (found > -1) stream.backUp(cur.length - found);
61
- return innerToken;
62
- }
63
- },
64
-
65
- indent: function(state, textAfter) {
66
- var mode = state.innerActive ? state.innerActive.mode : outer;
67
- if (!mode.indent) return CodeMirror.Pass;
68
- return mode.indent(state.innerActive ? state.inner : state.outer, textAfter);
69
- },
70
-
71
- electricChars: outer.electricChars,
72
-
73
- innerMode: function(state) {
74
- return state.inner ? {state: state.inner, mode: state.innerActive.mode} : {state: state.outer, mode: outer};
75
- }
76
- };
77
- };