datagram 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. data/.env.sample +7 -0
  2. data/.gitignore +20 -0
  3. data/.rbenv-version +1 -0
  4. data/Gemfile +12 -0
  5. data/LICENSE.txt +22 -0
  6. data/Procfile +1 -0
  7. data/README.md +29 -0
  8. data/Rakefile +1 -0
  9. data/config.ru +5 -0
  10. data/datagram.gemspec +23 -0
  11. data/db/migrate/1_create_queries.rb +9 -0
  12. data/db/migrate/2_add_name_to_queries.rb +5 -0
  13. data/lib/datagram/version.rb +3 -0
  14. data/lib/datagram.rb +135 -0
  15. data/lib/views/application.coffee +222 -0
  16. data/lib/views/index.haml +47 -0
  17. data/lib/views/layout.haml +17 -0
  18. data/lib/views/style.sass +179 -0
  19. data/public/ace/ace.js +15209 -0
  20. data/public/ace/ext-elastic_tabstops_lite.js +301 -0
  21. data/public/ace/ext-emmet.js +253 -0
  22. data/public/ace/ext-searchbox.js +441 -0
  23. data/public/ace/ext-spellcheck.js +67 -0
  24. data/public/ace/ext-static_highlight.js +96 -0
  25. data/public/ace/ext-textarea.js +492 -0
  26. data/public/ace/ext-whitespace.js +204 -0
  27. data/public/ace/keybinding-emacs.js +962 -0
  28. data/public/ace/keybinding-vim.js +1704 -0
  29. data/public/ace/mode-abap.js +260 -0
  30. data/public/ace/mode-asciidoc.js +372 -0
  31. data/public/ace/mode-c9search.js +182 -0
  32. data/public/ace/mode-c_cpp.js +737 -0
  33. data/public/ace/mode-clojure.js +299 -0
  34. data/public/ace/mode-coffee.js +426 -0
  35. data/public/ace/mode-coldfusion.js +1753 -0
  36. data/public/ace/mode-csharp.js +612 -0
  37. data/public/ace/mode-css.js +773 -0
  38. data/public/ace/mode-curly.js +1950 -0
  39. data/public/ace/mode-dart.js +945 -0
  40. data/public/ace/mode-diff.js +166 -0
  41. data/public/ace/mode-django.js +1969 -0
  42. data/public/ace/mode-dot.js +320 -0
  43. data/public/ace/mode-ftl.js +907 -0
  44. data/public/ace/mode-glsl.js +810 -0
  45. data/public/ace/mode-golang.js +632 -0
  46. data/public/ace/mode-groovy.js +1037 -0
  47. data/public/ace/mode-haml.js +487 -0
  48. data/public/ace/mode-haxe.js +609 -0
  49. data/public/ace/mode-html.js +1881 -0
  50. data/public/ace/mode-jade.js +1951 -0
  51. data/public/ace/mode-java.js +996 -0
  52. data/public/ace/mode-javascript.js +876 -0
  53. data/public/ace/mode-json.js +578 -0
  54. data/public/ace/mode-jsp.js +1351 -0
  55. data/public/ace/mode-jsx.js +635 -0
  56. data/public/ace/mode-latex.js +189 -0
  57. data/public/ace/mode-less.js +807 -0
  58. data/public/ace/mode-liquid.js +862 -0
  59. data/public/ace/mode-lisp.js +138 -0
  60. data/public/ace/mode-livescript.js +288 -0
  61. data/public/ace/mode-logiql.js +664 -0
  62. data/public/ace/mode-lsl.js +828 -0
  63. data/public/ace/mode-lua.js +455 -0
  64. data/public/ace/mode-luapage.js +2340 -0
  65. data/public/ace/mode-lucene.js +64 -0
  66. data/public/ace/mode-makefile.js +313 -0
  67. data/public/ace/mode-markdown.js +2280 -0
  68. data/public/ace/mode-mushcode.js +704 -0
  69. data/public/ace/mode-mushcode_high_rules.js +569 -0
  70. data/public/ace/mode-objectivec.js +659 -0
  71. data/public/ace/mode-ocaml.js +443 -0
  72. data/public/ace/mode-pascal.js +233 -0
  73. data/public/ace/mode-perl.js +316 -0
  74. data/public/ace/mode-pgsql.js +908 -0
  75. data/public/ace/mode-php.js +2291 -0
  76. data/public/ace/mode-powershell.js +618 -0
  77. data/public/ace/mode-python.js +264 -0
  78. data/public/ace/mode-r.js +404 -0
  79. data/public/ace/mode-rdoc.js +184 -0
  80. data/public/ace/mode-rhtml.js +2168 -0
  81. data/public/ace/mode-ruby.js +431 -0
  82. data/public/ace/mode-sass.js +442 -0
  83. data/public/ace/mode-scad.js +670 -0
  84. data/public/ace/mode-scala.js +1025 -0
  85. data/public/ace/mode-scheme.js +144 -0
  86. data/public/ace/mode-scss.js +832 -0
  87. data/public/ace/mode-sh.js +204 -0
  88. data/public/ace/mode-sql.js +118 -0
  89. data/public/ace/mode-stylus.js +483 -0
  90. data/public/ace/mode-svg.js +1442 -0
  91. data/public/ace/mode-tcl.js +319 -0
  92. data/public/ace/mode-tex.js +166 -0
  93. data/public/ace/mode-text.js +0 -0
  94. data/public/ace/mode-textile.js +170 -0
  95. data/public/ace/mode-tmsnippet.js +200 -0
  96. data/public/ace/mode-toml.js +180 -0
  97. data/public/ace/mode-typescript.js +961 -0
  98. data/public/ace/mode-vbscript.js +281 -0
  99. data/public/ace/mode-velocity.js +962 -0
  100. data/public/ace/mode-xml.js +789 -0
  101. data/public/ace/mode-xquery.js +2750 -0
  102. data/public/ace/mode-yaml.js +289 -0
  103. data/public/ace/theme-ambiance.js +202 -0
  104. data/public/ace/theme-chaos.js +182 -0
  105. data/public/ace/theme-chrome.js +161 -0
  106. data/public/ace/theme-clouds.js +135 -0
  107. data/public/ace/theme-clouds_midnight.js +136 -0
  108. data/public/ace/theme-cobalt.js +150 -0
  109. data/public/ace/theme-crimson_editor.js +154 -0
  110. data/public/ace/theme-dawn.js +146 -0
  111. data/public/ace/theme-dreamweaver.js +173 -0
  112. data/public/ace/theme-eclipse.js +122 -0
  113. data/public/ace/theme-github.js +136 -0
  114. data/public/ace/theme-idle_fingers.js +136 -0
  115. data/public/ace/theme-kr.js +143 -0
  116. data/public/ace/theme-merbivore.js +135 -0
  117. data/public/ace/theme-merbivore_soft.js +136 -0
  118. data/public/ace/theme-mono_industrial.js +148 -0
  119. data/public/ace/theme-monokai.js +140 -0
  120. data/public/ace/theme-pastel_on_dark.js +148 -0
  121. data/public/ace/theme-solarized_dark.js +128 -0
  122. data/public/ace/theme-solarized_light.js +131 -0
  123. data/public/ace/theme-terminal.js +154 -0
  124. data/public/ace/theme-textmate.js +0 -0
  125. data/public/ace/theme-tomorrow.js +147 -0
  126. data/public/ace/theme-tomorrow_night.js +147 -0
  127. data/public/ace/theme-tomorrow_night_blue.js +145 -0
  128. data/public/ace/theme-tomorrow_night_bright.js +147 -0
  129. data/public/ace/theme-tomorrow_night_eighties.js +144 -0
  130. data/public/ace/theme-twilight.js +147 -0
  131. data/public/ace/theme-vibrant_ink.js +131 -0
  132. data/public/ace/theme-xcode.js +125 -0
  133. data/public/ace/worker-coffee.js +7091 -0
  134. data/public/ace/worker-css.js +8289 -0
  135. data/public/ace/worker-javascript.js +6496 -0
  136. data/public/ace/worker-json.js +2305 -0
  137. data/public/ace/worker-lua.js +3313 -0
  138. data/public/ace/worker-php.js +6743 -0
  139. data/public/ace/worker-xquery.js +21897 -0
  140. data/public/font/FontAwesome.otf +0 -0
  141. data/public/font/fontawesome-webfont.eot +0 -0
  142. data/public/font/fontawesome-webfont.svg +284 -0
  143. data/public/font/fontawesome-webfont.ttf +0 -0
  144. data/public/font/fontawesome-webfont.woff +0 -0
  145. data/public/font-awesome.css +540 -0
  146. data/public/jquery.js +9597 -0
  147. data/script/migrate.sh +2 -0
  148. metadata +242 -0
@@ -0,0 +1,264 @@
1
+ /* ***** BEGIN LICENSE BLOCK *****
2
+ * Distributed under the BSD license:
3
+ *
4
+ * Copyright (c) 2010, Ajax.org B.V.
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are met:
9
+ * * Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ * * Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in the
13
+ * documentation and/or other materials provided with the distribution.
14
+ * * Neither the name of Ajax.org B.V. nor the
15
+ * names of its contributors may be used to endorse or promote products
16
+ * derived from this software without specific prior written permission.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
22
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+ *
29
+ * ***** END LICENSE BLOCK ***** */
30
+
31
+ define('ace/mode/python', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/python_highlight_rules', 'ace/mode/folding/pythonic', 'ace/range'], function(require, exports, module) {
32
+
33
+
34
+ var oop = require("../lib/oop");
35
+ var TextMode = require("./text").Mode;
36
+ var Tokenizer = require("../tokenizer").Tokenizer;
37
+ var PythonHighlightRules = require("./python_highlight_rules").PythonHighlightRules;
38
+ var PythonFoldMode = require("./folding/pythonic").FoldMode;
39
+ var Range = require("../range").Range;
40
+
41
+ var Mode = function() {
42
+ this.$tokenizer = new Tokenizer(new PythonHighlightRules().getRules());
43
+ this.foldingRules = new PythonFoldMode("\\:");
44
+ };
45
+ oop.inherits(Mode, TextMode);
46
+
47
+ (function() {
48
+
49
+ this.lineCommentStart = "#";
50
+
51
+ this.getNextLineIndent = function(state, line, tab) {
52
+ var indent = this.$getIndent(line);
53
+
54
+ var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
55
+ var tokens = tokenizedLine.tokens;
56
+
57
+ if (tokens.length && tokens[tokens.length-1].type == "comment") {
58
+ return indent;
59
+ }
60
+
61
+ if (state == "start") {
62
+ var match = line.match(/^.*[\{\(\[\:]\s*$/);
63
+ if (match) {
64
+ indent += tab;
65
+ }
66
+ }
67
+
68
+ return indent;
69
+ };
70
+
71
+ var outdents = {
72
+ "pass": 1,
73
+ "return": 1,
74
+ "raise": 1,
75
+ "break": 1,
76
+ "continue": 1
77
+ };
78
+
79
+ this.checkOutdent = function(state, line, input) {
80
+ if (input !== "\r\n" && input !== "\r" && input !== "\n")
81
+ return false;
82
+
83
+ var tokens = this.$tokenizer.getLineTokens(line.trim(), state).tokens;
84
+
85
+ if (!tokens)
86
+ return false;
87
+ do {
88
+ var last = tokens.pop();
89
+ } while (last && (last.type == "comment" || (last.type == "text" && last.value.match(/^\s+$/))));
90
+
91
+ if (!last)
92
+ return false;
93
+
94
+ return (last.type == "keyword" && outdents[last.value]);
95
+ };
96
+
97
+ this.autoOutdent = function(state, doc, row) {
98
+
99
+ row += 1;
100
+ var indent = this.$getIndent(doc.getLine(row));
101
+ var tab = doc.getTabString();
102
+ if (indent.slice(-tab.length) == tab)
103
+ doc.remove(new Range(row, indent.length-tab.length, row, indent.length));
104
+ };
105
+
106
+ }).call(Mode.prototype);
107
+
108
+ exports.Mode = Mode;
109
+ });
110
+
111
+ define('ace/mode/python_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
112
+
113
+
114
+ var oop = require("../lib/oop");
115
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
116
+
117
+ var PythonHighlightRules = function() {
118
+
119
+ var keywords = (
120
+ "and|as|assert|break|class|continue|def|del|elif|else|except|exec|" +
121
+ "finally|for|from|global|if|import|in|is|lambda|not|or|pass|print|" +
122
+ "raise|return|try|while|with|yield"
123
+ );
124
+
125
+ var builtinConstants = (
126
+ "True|False|None|NotImplemented|Ellipsis|__debug__"
127
+ );
128
+
129
+ var builtinFunctions = (
130
+ "abs|divmod|input|open|staticmethod|all|enumerate|int|ord|str|any|" +
131
+ "eval|isinstance|pow|sum|basestring|execfile|issubclass|print|super|" +
132
+ "binfile|iter|property|tuple|bool|filter|len|range|type|bytearray|" +
133
+ "float|list|raw_input|unichr|callable|format|locals|reduce|unicode|" +
134
+ "chr|frozenset|long|reload|vars|classmethod|getattr|map|repr|xrange|" +
135
+ "cmp|globals|max|reversed|zip|compile|hasattr|memoryview|round|" +
136
+ "__import__|complex|hash|min|set|apply|delattr|help|next|setattr|" +
137
+ "buffer|dict|hex|object|slice|coerce|dir|id|oct|sorted|intern"
138
+ );
139
+ var keywordMapper = this.createKeywordMapper({
140
+ "invalid.deprecated": "debugger",
141
+ "support.function": builtinFunctions,
142
+ "constant.language": builtinConstants,
143
+ "keyword": keywords
144
+ }, "identifier");
145
+
146
+ var strPre = "(?:r|u|ur|R|U|UR|Ur|uR)?";
147
+
148
+ var decimalInteger = "(?:(?:[1-9]\\d*)|(?:0))";
149
+ var octInteger = "(?:0[oO]?[0-7]+)";
150
+ var hexInteger = "(?:0[xX][\\dA-Fa-f]+)";
151
+ var binInteger = "(?:0[bB][01]+)";
152
+ var integer = "(?:" + decimalInteger + "|" + octInteger + "|" + hexInteger + "|" + binInteger + ")";
153
+
154
+ var exponent = "(?:[eE][+-]?\\d+)";
155
+ var fraction = "(?:\\.\\d+)";
156
+ var intPart = "(?:\\d+)";
157
+ var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))";
158
+ var exponentFloat = "(?:(?:" + pointFloat + "|" + intPart + ")" + exponent + ")";
159
+ var floatNumber = "(?:" + exponentFloat + "|" + pointFloat + ")";
160
+
161
+ this.$rules = {
162
+ "start" : [ {
163
+ token : "comment",
164
+ regex : "#.*$"
165
+ }, {
166
+ token : "string", // """ string
167
+ regex : strPre + '"{3}(?:[^\\\\]|\\\\.)*?"{3}'
168
+ }, {
169
+ token : "string", // multi line """ string start
170
+ regex : strPre + '"{3}.*$',
171
+ next : "qqstring"
172
+ }, {
173
+ token : "string", // " string
174
+ regex : strPre + '"(?:[^\\\\]|\\\\.)*?"'
175
+ }, {
176
+ token : "string", // ''' string
177
+ regex : strPre + "'{3}(?:[^\\\\]|\\\\.)*?'{3}"
178
+ }, {
179
+ token : "string", // multi line ''' string start
180
+ regex : strPre + "'{3}.*$",
181
+ next : "qstring"
182
+ }, {
183
+ token : "string", // ' string
184
+ regex : strPre + "'(?:[^\\\\]|\\\\.)*?'"
185
+ }, {
186
+ token : "constant.numeric", // imaginary
187
+ regex : "(?:" + floatNumber + "|\\d+)[jJ]\\b"
188
+ }, {
189
+ token : "constant.numeric", // float
190
+ regex : floatNumber
191
+ }, {
192
+ token : "constant.numeric", // long integer
193
+ regex : integer + "[lL]\\b"
194
+ }, {
195
+ token : "constant.numeric", // integer
196
+ regex : integer + "\\b"
197
+ }, {
198
+ token : keywordMapper,
199
+ regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
200
+ }, {
201
+ token : "keyword.operator",
202
+ regex : "\\+|\\-|\\*|\\*\\*|\\/|\\/\\/|%|<<|>>|&|\\||\\^|~|<|>|<=|=>|==|!=|<>|="
203
+ }, {
204
+ token : "paren.lparen",
205
+ regex : "[\\[\\(\\{]"
206
+ }, {
207
+ token : "paren.rparen",
208
+ regex : "[\\]\\)\\}]"
209
+ }, {
210
+ token : "text",
211
+ regex : "\\s+"
212
+ } ],
213
+ "qqstring" : [ {
214
+ token : "string", // multi line """ string end
215
+ regex : '(?:[^\\\\]|\\\\.)*?"{3}',
216
+ next : "start"
217
+ }, {
218
+ token : "string",
219
+ regex : '.+'
220
+ } ],
221
+ "qstring" : [ {
222
+ token : "string", // multi line ''' string end
223
+ regex : "(?:[^\\\\]|\\\\.)*?'{3}",
224
+ next : "start"
225
+ }, {
226
+ token : "string",
227
+ regex : '.+'
228
+ } ]
229
+ };
230
+ };
231
+
232
+ oop.inherits(PythonHighlightRules, TextHighlightRules);
233
+
234
+ exports.PythonHighlightRules = PythonHighlightRules;
235
+ });
236
+
237
+ define('ace/mode/folding/pythonic', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
238
+
239
+
240
+ var oop = require("../../lib/oop");
241
+ var BaseFoldMode = require("./fold_mode").FoldMode;
242
+
243
+ var FoldMode = exports.FoldMode = function(markers) {
244
+ this.foldingStartMarker = new RegExp("([\\[{])(?:\\s*)$|(" + markers + ")(?:\\s*)(?:#.*)?$");
245
+ };
246
+ oop.inherits(FoldMode, BaseFoldMode);
247
+
248
+ (function() {
249
+
250
+ this.getFoldWidgetRange = function(session, foldStyle, row) {
251
+ var line = session.getLine(row);
252
+ var match = line.match(this.foldingStartMarker);
253
+ if (match) {
254
+ if (match[1])
255
+ return this.openingBracketBlock(session, match[1], row, match.index);
256
+ if (match[2])
257
+ return this.indentationBlock(session, row, match.index + match[2].length);
258
+ return this.indentationBlock(session, row);
259
+ }
260
+ }
261
+
262
+ }).call(FoldMode.prototype);
263
+
264
+ });
@@ -0,0 +1,404 @@
1
+ /*
2
+ * r.js
3
+ *
4
+ * Copyright (C) 2009-11 by RStudio, Inc.
5
+ *
6
+ * The Initial Developer of the Original Code is
7
+ * Ajax.org B.V.
8
+ * Portions created by the Initial Developer are Copyright (C) 2010
9
+ * the Initial Developer. All Rights Reserved.
10
+ *
11
+ * This program is licensed to you under the terms of version 3 of the
12
+ * GNU Affero General Public License. This program is distributed WITHOUT
13
+ * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
14
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
15
+ * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
16
+ *
17
+ */
18
+ define('ace/mode/r', ['require', 'exports', 'module' , 'ace/range', 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/text_highlight_rules', 'ace/mode/r_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/unicode'], function(require, exports, module) {
19
+
20
+
21
+ var Range = require("../range").Range;
22
+ var oop = require("../lib/oop");
23
+ var TextMode = require("./text").Mode;
24
+ var Tokenizer = require("../tokenizer").Tokenizer;
25
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
26
+ var RHighlightRules = require("./r_highlight_rules").RHighlightRules;
27
+ var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
28
+ var unicode = require("../unicode");
29
+
30
+ var Mode = function()
31
+ {
32
+ this.$tokenizer = new Tokenizer(new RHighlightRules().getRules());
33
+ this.$outdent = new MatchingBraceOutdent();
34
+ };
35
+ oop.inherits(Mode, TextMode);
36
+
37
+ (function()
38
+ {
39
+ this.tokenRe = new RegExp("^["
40
+ + unicode.packages.L
41
+ + unicode.packages.Mn + unicode.packages.Mc
42
+ + unicode.packages.Nd
43
+ + unicode.packages.Pc + "._]+", "g"
44
+ );
45
+
46
+ this.nonTokenRe = new RegExp("^(?:[^"
47
+ + unicode.packages.L
48
+ + unicode.packages.Mn + unicode.packages.Mc
49
+ + unicode.packages.Nd
50
+ + unicode.packages.Pc + "._]|\s])+", "g"
51
+ );
52
+
53
+ this.$complements = {
54
+ "(": ")",
55
+ "[": "]",
56
+ '"': '"',
57
+ "'": "'",
58
+ "{": "}"
59
+ };
60
+ this.$reOpen = /^[(["'{]$/;
61
+ this.$reClose = /^[)\]"'}]$/;
62
+
63
+ this.getNextLineIndent = function(state, line, tab, tabSize, row)
64
+ {
65
+ return this.codeModel.getNextLineIndent(row, line, state, tab, tabSize);
66
+ };
67
+
68
+ this.allowAutoInsert = this.smartAllowAutoInsert;
69
+
70
+ this.checkOutdent = function(state, line, input) {
71
+ if (! /^\s+$/.test(line))
72
+ return false;
73
+
74
+ return /^\s*[\{\}\)]/.test(input);
75
+ };
76
+
77
+ this.getIndentForOpenBrace = function(openBracePos)
78
+ {
79
+ return this.codeModel.getIndentForOpenBrace(openBracePos);
80
+ };
81
+
82
+ this.autoOutdent = function(state, doc, row) {
83
+ if (row == 0)
84
+ return 0;
85
+
86
+ var line = doc.getLine(row);
87
+
88
+ var match = line.match(/^(\s*[\}\)])/);
89
+ if (match)
90
+ {
91
+ var column = match[1].length;
92
+ var openBracePos = doc.findMatchingBracket({row: row, column: column});
93
+
94
+ if (!openBracePos || openBracePos.row == row) return 0;
95
+
96
+ var indent = this.codeModel.getIndentForOpenBrace(openBracePos);
97
+ doc.replace(new Range(row, 0, row, column-1), indent);
98
+ }
99
+
100
+ match = line.match(/^(\s*\{)/);
101
+ if (match)
102
+ {
103
+ var column = match[1].length;
104
+ var indent = this.codeModel.getBraceIndent(row-1);
105
+ doc.replace(new Range(row, 0, row, column-1), indent);
106
+ }
107
+ };
108
+
109
+ this.$getIndent = function(line) {
110
+ var match = line.match(/^(\s+)/);
111
+ if (match) {
112
+ return match[1];
113
+ }
114
+
115
+ return "";
116
+ };
117
+
118
+ this.transformAction = function(state, action, editor, session, text) {
119
+ if (action === 'insertion' && text === "\n") {
120
+ var pos = editor.getSelectionRange().start;
121
+ var match = /^((\s*#+')\s*)/.exec(session.doc.getLine(pos.row));
122
+ if (match && editor.getSelectionRange().start.column >= match[2].length) {
123
+ return {text: "\n" + match[1]};
124
+ }
125
+ }
126
+ return false;
127
+ };
128
+ }).call(Mode.prototype);
129
+ exports.Mode = Mode;
130
+ });
131
+ define('ace/mode/r_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules', 'ace/mode/tex_highlight_rules'], function(require, exports, module) {
132
+
133
+ var oop = require("../lib/oop");
134
+ var lang = require("../lib/lang");
135
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
136
+ var TexHighlightRules = require("./tex_highlight_rules").TexHighlightRules;
137
+
138
+ var RHighlightRules = function()
139
+ {
140
+
141
+ var keywords = lang.arrayToMap(
142
+ ("function|if|in|break|next|repeat|else|for|return|switch|while|try|tryCatch|stop|warning|require|library|attach|detach|source|setMethod|setGeneric|setGroupGeneric|setClass")
143
+ .split("|")
144
+ );
145
+
146
+ var buildinConstants = lang.arrayToMap(
147
+ ("NULL|NA|TRUE|FALSE|T|F|Inf|NaN|NA_integer_|NA_real_|NA_character_|" +
148
+ "NA_complex_").split("|")
149
+ );
150
+
151
+ this.$rules = {
152
+ "start" : [
153
+ {
154
+ token : "comment.sectionhead",
155
+ regex : "#+(?!').*(?:----|====|####)\\s*$"
156
+ },
157
+ {
158
+ token : "comment",
159
+ regex : "#+'",
160
+ next : "rd-start"
161
+ },
162
+ {
163
+ token : "comment",
164
+ regex : "#.*$"
165
+ },
166
+ {
167
+ token : "string", // multi line string start
168
+ regex : '["]',
169
+ next : "qqstring"
170
+ },
171
+ {
172
+ token : "string", // multi line string start
173
+ regex : "[']",
174
+ next : "qstring"
175
+ },
176
+ {
177
+ token : "constant.numeric", // hex
178
+ regex : "0[xX][0-9a-fA-F]+[Li]?\\b"
179
+ },
180
+ {
181
+ token : "constant.numeric", // explicit integer
182
+ regex : "\\d+L\\b"
183
+ },
184
+ {
185
+ token : "constant.numeric", // number
186
+ regex : "\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d*)?i?\\b"
187
+ },
188
+ {
189
+ token : "constant.numeric", // number with leading decimal
190
+ regex : "\\.\\d+(?:[eE][+\\-]?\\d*)?i?\\b"
191
+ },
192
+ {
193
+ token : "constant.language.boolean",
194
+ regex : "(?:TRUE|FALSE|T|F)\\b"
195
+ },
196
+ {
197
+ token : "identifier",
198
+ regex : "`.*?`"
199
+ },
200
+ {
201
+ onMatch : function(value) {
202
+ if (keywords[value])
203
+ return "keyword";
204
+ else if (buildinConstants[value])
205
+ return "constant.language";
206
+ else if (value == '...' || value.match(/^\.\.\d+$/))
207
+ return "variable.language";
208
+ else
209
+ return "identifier";
210
+ },
211
+ regex : "[a-zA-Z.][a-zA-Z0-9._]*\\b"
212
+ },
213
+ {
214
+ token : "keyword.operator",
215
+ regex : "%%|>=|<=|==|!=|\\->|<\\-|\\|\\||&&|=|\\+|\\-|\\*|/|\\^|>|<|!|&|\\||~|\\$|:"
216
+ },
217
+ {
218
+ token : "keyword.operator", // infix operators
219
+ regex : "%.*?%"
220
+ },
221
+ {
222
+ token : "paren.keyword.operator",
223
+ regex : "[[({]"
224
+ },
225
+ {
226
+ token : "paren.keyword.operator",
227
+ regex : "[\\])}]"
228
+ },
229
+ {
230
+ token : "text",
231
+ regex : "\\s+"
232
+ }
233
+ ],
234
+ "qqstring" : [
235
+ {
236
+ token : "string",
237
+ regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
238
+ next : "start"
239
+ },
240
+ {
241
+ token : "string",
242
+ regex : '.+'
243
+ }
244
+ ],
245
+ "qstring" : [
246
+ {
247
+ token : "string",
248
+ regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
249
+ next : "start"
250
+ },
251
+ {
252
+ token : "string",
253
+ regex : '.+'
254
+ }
255
+ ]
256
+ };
257
+
258
+ var rdRules = new TexHighlightRules("comment").getRules();
259
+ for (var i = 0; i < rdRules["start"].length; i++) {
260
+ rdRules["start"][i].token += ".virtual-comment";
261
+ }
262
+
263
+ this.addRules(rdRules, "rd-");
264
+ this.$rules["rd-start"].unshift({
265
+ token: "text",
266
+ regex: "^",
267
+ next: "start"
268
+ });
269
+ this.$rules["rd-start"].unshift({
270
+ token : "keyword",
271
+ regex : "@(?!@)[^ ]*"
272
+ });
273
+ this.$rules["rd-start"].unshift({
274
+ token : "comment",
275
+ regex : "@@"
276
+ });
277
+ this.$rules["rd-start"].push({
278
+ token : "comment",
279
+ regex : "[^%\\\\[({\\])}]+"
280
+ });
281
+ };
282
+
283
+ oop.inherits(RHighlightRules, TextHighlightRules);
284
+
285
+ exports.RHighlightRules = RHighlightRules;
286
+ });
287
+ define('ace/mode/tex_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
288
+
289
+
290
+ var oop = require("../lib/oop");
291
+ var lang = require("../lib/lang");
292
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
293
+
294
+ var TexHighlightRules = function(textClass) {
295
+
296
+ if (!textClass)
297
+ textClass = "text";
298
+
299
+ this.$rules = {
300
+ "start" : [
301
+ {
302
+ token : "comment",
303
+ regex : "%.*$"
304
+ }, {
305
+ token : textClass, // non-command
306
+ regex : "\\\\[$&%#\\{\\}]"
307
+ }, {
308
+ token : "keyword", // command
309
+ regex : "\\\\(?:documentclass|usepackage|newcounter|setcounter|addtocounter|value|arabic|stepcounter|newenvironment|renewenvironment|ref|vref|eqref|pageref|label|cite[a-zA-Z]*|tag|begin|end|bibitem)\\b",
310
+ next : "nospell"
311
+ }, {
312
+ token : "keyword", // command
313
+ regex : "\\\\(?:[a-zA-z0-9]+|[^a-zA-z0-9])"
314
+ }, {
315
+ token : "paren.keyword.operator",
316
+ regex : "[[({]"
317
+ }, {
318
+ token : "paren.keyword.operator",
319
+ regex : "[\\])}]"
320
+ }, {
321
+ token : textClass,
322
+ regex : "\\s+"
323
+ }
324
+ ],
325
+ "nospell" : [
326
+ {
327
+ token : "comment",
328
+ regex : "%.*$",
329
+ next : "start"
330
+ }, {
331
+ token : "nospell." + textClass, // non-command
332
+ regex : "\\\\[$&%#\\{\\}]"
333
+ }, {
334
+ token : "keyword", // command
335
+ regex : "\\\\(?:documentclass|usepackage|newcounter|setcounter|addtocounter|value|arabic|stepcounter|newenvironment|renewenvironment|ref|vref|eqref|pageref|label|cite[a-zA-Z]*|tag|begin|end|bibitem)\\b"
336
+ }, {
337
+ token : "keyword", // command
338
+ regex : "\\\\(?:[a-zA-z0-9]+|[^a-zA-z0-9])",
339
+ next : "start"
340
+ }, {
341
+ token : "paren.keyword.operator",
342
+ regex : "[[({]"
343
+ }, {
344
+ token : "paren.keyword.operator",
345
+ regex : "[\\])]"
346
+ }, {
347
+ token : "paren.keyword.operator",
348
+ regex : "}",
349
+ next : "start"
350
+ }, {
351
+ token : "nospell." + textClass,
352
+ regex : "\\s+"
353
+ }, {
354
+ token : "nospell." + textClass,
355
+ regex : "\\w+"
356
+ }
357
+ ]
358
+ };
359
+ };
360
+
361
+ oop.inherits(TexHighlightRules, TextHighlightRules);
362
+
363
+ exports.TexHighlightRules = TexHighlightRules;
364
+ });
365
+
366
+ define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
367
+
368
+
369
+ var Range = require("../range").Range;
370
+
371
+ var MatchingBraceOutdent = function() {};
372
+
373
+ (function() {
374
+
375
+ this.checkOutdent = function(line, input) {
376
+ if (! /^\s+$/.test(line))
377
+ return false;
378
+
379
+ return /^\s*\}/.test(input);
380
+ };
381
+
382
+ this.autoOutdent = function(doc, row) {
383
+ var line = doc.getLine(row);
384
+ var match = line.match(/^(\s*\})/);
385
+
386
+ if (!match) return 0;
387
+
388
+ var column = match[1].length;
389
+ var openBracePos = doc.findMatchingBracket({row: row, column: column});
390
+
391
+ if (!openBracePos || openBracePos.row == row) return 0;
392
+
393
+ var indent = this.$getIndent(doc.getLine(openBracePos.row));
394
+ doc.replace(new Range(row, 0, row, column-1), indent);
395
+ };
396
+
397
+ this.$getIndent = function(line) {
398
+ return line.match(/^\s*/)[0];
399
+ };
400
+
401
+ }).call(MatchingBraceOutdent.prototype);
402
+
403
+ exports.MatchingBraceOutdent = MatchingBraceOutdent;
404
+ });