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,737 @@
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/c_cpp', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/c_cpp_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], 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 c_cppHighlightRules = require("./c_cpp_highlight_rules").c_cppHighlightRules;
38
+ var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
39
+ var Range = require("../range").Range;
40
+ var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
41
+ var CStyleFoldMode = require("./folding/cstyle").FoldMode;
42
+
43
+ var Mode = function() {
44
+ this.$tokenizer = new Tokenizer(new c_cppHighlightRules().getRules());
45
+ this.$outdent = new MatchingBraceOutdent();
46
+ this.$behaviour = new CstyleBehaviour();
47
+ this.foldingRules = new CStyleFoldMode();
48
+ };
49
+ oop.inherits(Mode, TextMode);
50
+
51
+ (function() {
52
+
53
+ this.lineCommentStart = "//";
54
+ this.blockComment = {start: "/*", end: "*/"};
55
+
56
+ this.getNextLineIndent = function(state, line, tab) {
57
+ var indent = this.$getIndent(line);
58
+
59
+ var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
60
+ var tokens = tokenizedLine.tokens;
61
+ var endState = tokenizedLine.state;
62
+
63
+ if (tokens.length && tokens[tokens.length-1].type == "comment") {
64
+ return indent;
65
+ }
66
+
67
+ if (state == "start") {
68
+ var match = line.match(/^.*[\{\(\[]\s*$/);
69
+ if (match) {
70
+ indent += tab;
71
+ }
72
+ } else if (state == "doc-start") {
73
+ if (endState == "start") {
74
+ return "";
75
+ }
76
+ var match = line.match(/^\s*(\/?)\*/);
77
+ if (match) {
78
+ if (match[1]) {
79
+ indent += " ";
80
+ }
81
+ indent += "* ";
82
+ }
83
+ }
84
+
85
+ return indent;
86
+ };
87
+
88
+ this.checkOutdent = function(state, line, input) {
89
+ return this.$outdent.checkOutdent(line, input);
90
+ };
91
+
92
+ this.autoOutdent = function(state, doc, row) {
93
+ this.$outdent.autoOutdent(doc, row);
94
+ };
95
+
96
+ }).call(Mode.prototype);
97
+
98
+ exports.Mode = Mode;
99
+ });
100
+ define('ace/mode/c_cpp_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
101
+
102
+
103
+ var oop = require("../lib/oop");
104
+ var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
105
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
106
+ var cFunctions = exports.cFunctions = "\\s*\\bhypot(?:f|l)?|s(?:scanf|ystem|nprintf|ca(?:nf|lb(?:n(?:f|l)?|ln(?:f|l)?))|i(?:n(?:h(?:f|l)?|f|l)?|gn(?:al|bit))|tr(?:s(?:tr|pn)|nc(?:py|at|mp)|c(?:spn|hr|oll|py|at|mp)|to(?:imax|d|u(?:l(?:l)?|max)|k|f|l(?:d|l)?)|error|pbrk|ftime|len|rchr|xfrm)|printf|et(?:jmp|vbuf|locale|buf)|qrt(?:f|l)?|w(?:scanf|printf)|rand)|n(?:e(?:arbyint(?:f|l)?|xt(?:toward(?:f|l)?|after(?:f|l)?))|an(?:f|l)?)|c(?:s(?:in(?:h(?:f|l)?|f|l)?|qrt(?:f|l)?)|cos(?:h(?:f)?|f|l)?|imag(?:f|l)?|t(?:ime|an(?:h(?:f|l)?|f|l)?)|o(?:s(?:h(?:f|l)?|f|l)?|nj(?:f|l)?|pysign(?:f|l)?)|p(?:ow(?:f|l)?|roj(?:f|l)?)|e(?:il(?:f|l)?|xp(?:f|l)?)|l(?:o(?:ck|g(?:f|l)?)|earerr)|a(?:sin(?:h(?:f|l)?|f|l)?|cos(?:h(?:f|l)?|f|l)?|tan(?:h(?:f|l)?|f|l)?|lloc|rg(?:f|l)?|bs(?:f|l)?)|real(?:f|l)?|brt(?:f|l)?)|t(?:ime|o(?:upper|lower)|an(?:h(?:f|l)?|f|l)?|runc(?:f|l)?|gamma(?:f|l)?|mp(?:nam|file))|i(?:s(?:space|n(?:ormal|an)|cntrl|inf|digit|u(?:nordered|pper)|p(?:unct|rint)|finite|w(?:space|c(?:ntrl|type)|digit|upper|p(?:unct|rint)|lower|al(?:num|pha)|graph|xdigit|blank)|l(?:ower|ess(?:equal|greater)?)|al(?:num|pha)|gr(?:eater(?:equal)?|aph)|xdigit|blank)|logb(?:f|l)?|max(?:div|abs))|di(?:v|fftime)|_Exit|unget(?:c|wc)|p(?:ow(?:f|l)?|ut(?:s|c(?:har)?|wc(?:har)?)|error|rintf)|e(?:rf(?:c(?:f|l)?|f|l)?|x(?:it|p(?:2(?:f|l)?|f|l|m1(?:f|l)?)?))|v(?:s(?:scanf|nprintf|canf|printf|w(?:scanf|printf))|printf|f(?:scanf|printf|w(?:scanf|printf))|w(?:scanf|printf)|a_(?:start|copy|end|arg))|qsort|f(?:s(?:canf|e(?:tpos|ek))|close|tell|open|dim(?:f|l)?|p(?:classify|ut(?:s|c|w(?:s|c))|rintf)|e(?:holdexcept|set(?:e(?:nv|xceptflag)|round)|clearexcept|testexcept|of|updateenv|r(?:aiseexcept|ror)|get(?:e(?:nv|xceptflag)|round))|flush|w(?:scanf|ide|printf|rite)|loor(?:f|l)?|abs(?:f|l)?|get(?:s|c|pos|w(?:s|c))|re(?:open|e|ad|xp(?:f|l)?)|m(?:in(?:f|l)?|od(?:f|l)?|a(?:f|l|x(?:f|l)?)?))|l(?:d(?:iv|exp(?:f|l)?)|o(?:ngjmp|cal(?:time|econv)|g(?:1(?:p(?:f|l)?|0(?:f|l)?)|2(?:f|l)?|f|l|b(?:f|l)?)?)|abs|l(?:div|abs|r(?:int(?:f|l)?|ound(?:f|l)?))|r(?:int(?:f|l)?|ound(?:f|l)?)|gamma(?:f|l)?)|w(?:scanf|c(?:s(?:s(?:tr|pn)|nc(?:py|at|mp)|c(?:spn|hr|oll|py|at|mp)|to(?:imax|d|u(?:l(?:l)?|max)|k|f|l(?:d|l)?|mbs)|pbrk|ftime|len|r(?:chr|tombs)|xfrm)|to(?:b|mb)|rtomb)|printf|mem(?:set|c(?:hr|py|mp)|move))|a(?:s(?:sert|ctime|in(?:h(?:f|l)?|f|l)?)|cos(?:h(?:f|l)?|f|l)?|t(?:o(?:i|f|l(?:l)?)|exit|an(?:h(?:f|l)?|2(?:f|l)?|f|l)?)|b(?:s|ort))|g(?:et(?:s|c(?:har)?|env|wc(?:har)?)|mtime)|r(?:int(?:f|l)?|ound(?:f|l)?|e(?:name|alloc|wind|m(?:ove|quo(?:f|l)?|ainder(?:f|l)?))|a(?:nd|ise))|b(?:search|towc)|m(?:odf(?:f|l)?|em(?:set|c(?:hr|py|mp)|move)|ktime|alloc|b(?:s(?:init|towcs|rtowcs)|towc|len|r(?:towc|len)))\\b"
107
+
108
+ var c_cppHighlightRules = function() {
109
+
110
+ var keywordControls = (
111
+ "break|case|continue|default|do|else|for|goto|if|_Pragma|" +
112
+ "return|switch|while|catch|operator|try|throw|using"
113
+ );
114
+
115
+ var storageType = (
116
+ "asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|" +
117
+ "_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void|" +
118
+ "class|wchar_t|template"
119
+ );
120
+
121
+ var storageModifiers = (
122
+ "const|extern|register|restrict|static|volatile|inline|private:|" +
123
+ "protected:|public:|friend|explicit|virtual|export|mutable|typename"
124
+ );
125
+
126
+ var keywordOperators = (
127
+ "and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|typeid|xor|xor_eq" +
128
+ "const_cast|dynamic_cast|reinterpret_cast|static_cast|sizeof|namespace"
129
+ );
130
+
131
+ var builtinConstants = (
132
+ "NULL|true|false|TRUE|FALSE"
133
+ );
134
+
135
+ var keywordMapper = this.$keywords = this.createKeywordMapper({
136
+ "keyword.control" : keywordControls,
137
+ "storage.type" : storageType,
138
+ "storage.modifier" : storageModifiers,
139
+ "keyword.operator" : keywordOperators,
140
+ "variable.language": "this",
141
+ "constant.language": builtinConstants
142
+ }, "identifier");
143
+
144
+ var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\d\\$_\u00a1-\uffff]*\\b";
145
+
146
+ this.$rules = {
147
+ "start" : [
148
+ {
149
+ token : "comment",
150
+ regex : "\\/\\/.*$"
151
+ },
152
+ DocCommentHighlightRules.getStartRule("doc-start"),
153
+ {
154
+ token : "comment", // multi line comment
155
+ regex : "\\/\\*",
156
+ next : "comment"
157
+ }, {
158
+ token : "string", // single line
159
+ regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
160
+ }, {
161
+ token : "string", // multi line string start
162
+ regex : '["].*\\\\$',
163
+ next : "qqstring"
164
+ }, {
165
+ token : "string", // single line
166
+ regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
167
+ }, {
168
+ token : "string", // multi line string start
169
+ regex : "['].*\\\\$",
170
+ next : "qstring"
171
+ }, {
172
+ token : "constant.numeric", // hex
173
+ regex : "0[xX][0-9a-fA-F]+\\b"
174
+ }, {
175
+ token : "constant.numeric", // float
176
+ regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
177
+ }, {
178
+ token : "keyword", // pre-compiler directives
179
+ regex : "(?:#include|#import|#pragma|#line|#define|#undef|#if|#ifdef|#else|#elif|#ifndef)\\b",
180
+ next : "directive"
181
+ }, {
182
+ token : "keyword", // special case pre-compiler directive
183
+ regex : "(?:#endif)\\b"
184
+ }, {
185
+ token : "support.function.C99.c",
186
+ regex : cFunctions
187
+ }, {
188
+ token : keywordMapper,
189
+ regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
190
+ }, {
191
+ token : "keyword.operator",
192
+ regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|new|delete|typeof|void)"
193
+ }, {
194
+ token : "punctuation.operator",
195
+ regex : "\\?|\\:|\\,|\\;|\\."
196
+ }, {
197
+ token : "paren.lparen",
198
+ regex : "[[({]"
199
+ }, {
200
+ token : "paren.rparen",
201
+ regex : "[\\])}]"
202
+ }, {
203
+ token : "text",
204
+ regex : "\\s+"
205
+ }
206
+ ],
207
+ "comment" : [
208
+ {
209
+ token : "comment", // closing comment
210
+ regex : ".*?\\*\\/",
211
+ next : "start"
212
+ }, {
213
+ token : "comment", // comment spanning whole line
214
+ regex : ".+"
215
+ }
216
+ ],
217
+ "qqstring" : [
218
+ {
219
+ token : "string",
220
+ regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
221
+ next : "start"
222
+ }, {
223
+ token : "string",
224
+ regex : '.+'
225
+ }
226
+ ],
227
+ "qstring" : [
228
+ {
229
+ token : "string",
230
+ regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
231
+ next : "start"
232
+ }, {
233
+ token : "string",
234
+ regex : '.+'
235
+ }
236
+ ],
237
+ "directive" : [
238
+ {
239
+ token : "constant.other.multiline",
240
+ regex : /\\/
241
+ },
242
+ {
243
+ token : "constant.other.multiline",
244
+ regex : /.*\\/
245
+ },
246
+ {
247
+ token : "constant.other",
248
+ regex : "\\s*<.+?>",
249
+ next : "start"
250
+ },
251
+ {
252
+ token : "constant.other", // single line
253
+ regex : '\\s*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]',
254
+ next : "start"
255
+ },
256
+ {
257
+ token : "constant.other", // single line
258
+ regex : "\\s*['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']",
259
+ next : "start"
260
+ },
261
+ {
262
+ token : "constant.other",
263
+ regex : /[^\\\/]+/,
264
+ next : "start"
265
+ }
266
+ ]
267
+ };
268
+
269
+ this.embedRules(DocCommentHighlightRules, "doc-",
270
+ [ DocCommentHighlightRules.getEndRule("start") ]);
271
+ };
272
+
273
+ oop.inherits(c_cppHighlightRules, TextHighlightRules);
274
+
275
+ exports.c_cppHighlightRules = c_cppHighlightRules;
276
+ });
277
+
278
+ define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
279
+
280
+
281
+ var oop = require("../lib/oop");
282
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
283
+
284
+ var DocCommentHighlightRules = function() {
285
+
286
+ this.$rules = {
287
+ "start" : [ {
288
+ token : "comment.doc.tag",
289
+ regex : "@[\\w\\d_]+" // TODO: fix email addresses
290
+ }, {
291
+ token : "comment.doc.tag",
292
+ regex : "\\bTODO\\b"
293
+ }, {
294
+ defaultToken : "comment.doc"
295
+ }]
296
+ };
297
+ };
298
+
299
+ oop.inherits(DocCommentHighlightRules, TextHighlightRules);
300
+
301
+ DocCommentHighlightRules.getStartRule = function(start) {
302
+ return {
303
+ token : "comment.doc", // doc comment
304
+ regex : "\\/\\*(?=\\*)",
305
+ next : start
306
+ };
307
+ };
308
+
309
+ DocCommentHighlightRules.getEndRule = function (start) {
310
+ return {
311
+ token : "comment.doc", // closing comment
312
+ regex : "\\*\\/",
313
+ next : start
314
+ };
315
+ };
316
+
317
+
318
+ exports.DocCommentHighlightRules = DocCommentHighlightRules;
319
+
320
+ });
321
+
322
+ define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
323
+
324
+
325
+ var Range = require("../range").Range;
326
+
327
+ var MatchingBraceOutdent = function() {};
328
+
329
+ (function() {
330
+
331
+ this.checkOutdent = function(line, input) {
332
+ if (! /^\s+$/.test(line))
333
+ return false;
334
+
335
+ return /^\s*\}/.test(input);
336
+ };
337
+
338
+ this.autoOutdent = function(doc, row) {
339
+ var line = doc.getLine(row);
340
+ var match = line.match(/^(\s*\})/);
341
+
342
+ if (!match) return 0;
343
+
344
+ var column = match[1].length;
345
+ var openBracePos = doc.findMatchingBracket({row: row, column: column});
346
+
347
+ if (!openBracePos || openBracePos.row == row) return 0;
348
+
349
+ var indent = this.$getIndent(doc.getLine(openBracePos.row));
350
+ doc.replace(new Range(row, 0, row, column-1), indent);
351
+ };
352
+
353
+ this.$getIndent = function(line) {
354
+ return line.match(/^\s*/)[0];
355
+ };
356
+
357
+ }).call(MatchingBraceOutdent.prototype);
358
+
359
+ exports.MatchingBraceOutdent = MatchingBraceOutdent;
360
+ });
361
+
362
+ define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/token_iterator', 'ace/lib/lang'], function(require, exports, module) {
363
+
364
+
365
+ var oop = require("../../lib/oop");
366
+ var Behaviour = require("../behaviour").Behaviour;
367
+ var TokenIterator = require("../../token_iterator").TokenIterator;
368
+ var lang = require("../../lib/lang");
369
+
370
+ var SAFE_INSERT_IN_TOKENS =
371
+ ["text", "paren.rparen", "punctuation.operator"];
372
+ var SAFE_INSERT_BEFORE_TOKENS =
373
+ ["text", "paren.rparen", "punctuation.operator", "comment"];
374
+
375
+
376
+ var autoInsertedBrackets = 0;
377
+ var autoInsertedRow = -1;
378
+ var autoInsertedLineEnd = "";
379
+ var maybeInsertedBrackets = 0;
380
+ var maybeInsertedRow = -1;
381
+ var maybeInsertedLineStart = "";
382
+ var maybeInsertedLineEnd = "";
383
+
384
+ var CstyleBehaviour = function () {
385
+
386
+ CstyleBehaviour.isSaneInsertion = function(editor, session) {
387
+ var cursor = editor.getCursorPosition();
388
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
389
+ if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
390
+ var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
391
+ if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
392
+ return false;
393
+ }
394
+ iterator.stepForward();
395
+ return iterator.getCurrentTokenRow() !== cursor.row ||
396
+ this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
397
+ };
398
+
399
+ CstyleBehaviour.$matchTokenType = function(token, types) {
400
+ return types.indexOf(token.type || token) > -1;
401
+ };
402
+
403
+ CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
404
+ var cursor = editor.getCursorPosition();
405
+ var line = session.doc.getLine(cursor.row);
406
+ if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0]))
407
+ autoInsertedBrackets = 0;
408
+ autoInsertedRow = cursor.row;
409
+ autoInsertedLineEnd = bracket + line.substr(cursor.column);
410
+ autoInsertedBrackets++;
411
+ };
412
+
413
+ CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
414
+ var cursor = editor.getCursorPosition();
415
+ var line = session.doc.getLine(cursor.row);
416
+ if (!this.isMaybeInsertedClosing(cursor, line))
417
+ maybeInsertedBrackets = 0;
418
+ maybeInsertedRow = cursor.row;
419
+ maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
420
+ maybeInsertedLineEnd = line.substr(cursor.column);
421
+ maybeInsertedBrackets++;
422
+ };
423
+
424
+ CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
425
+ return autoInsertedBrackets > 0 &&
426
+ cursor.row === autoInsertedRow &&
427
+ bracket === autoInsertedLineEnd[0] &&
428
+ line.substr(cursor.column) === autoInsertedLineEnd;
429
+ };
430
+
431
+ CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
432
+ return maybeInsertedBrackets > 0 &&
433
+ cursor.row === maybeInsertedRow &&
434
+ line.substr(cursor.column) === maybeInsertedLineEnd &&
435
+ line.substr(0, cursor.column) == maybeInsertedLineStart;
436
+ };
437
+
438
+ CstyleBehaviour.popAutoInsertedClosing = function() {
439
+ autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
440
+ autoInsertedBrackets--;
441
+ };
442
+
443
+ CstyleBehaviour.clearMaybeInsertedClosing = function() {
444
+ maybeInsertedBrackets = 0;
445
+ maybeInsertedRow = -1;
446
+ };
447
+
448
+ this.add("braces", "insertion", function (state, action, editor, session, text) {
449
+ var cursor = editor.getCursorPosition();
450
+ var line = session.doc.getLine(cursor.row);
451
+ if (text == '{') {
452
+ var selection = editor.getSelectionRange();
453
+ var selected = session.doc.getTextRange(selection);
454
+ if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
455
+ return {
456
+ text: '{' + selected + '}',
457
+ selection: false
458
+ };
459
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
460
+ if (/[\]\}\)]/.test(line[cursor.column])) {
461
+ CstyleBehaviour.recordAutoInsert(editor, session, "}");
462
+ return {
463
+ text: '{}',
464
+ selection: [1, 1]
465
+ };
466
+ } else {
467
+ CstyleBehaviour.recordMaybeInsert(editor, session, "{");
468
+ return {
469
+ text: '{',
470
+ selection: [1, 1]
471
+ };
472
+ }
473
+ }
474
+ } else if (text == '}') {
475
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
476
+ if (rightChar == '}') {
477
+ var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
478
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
479
+ CstyleBehaviour.popAutoInsertedClosing();
480
+ return {
481
+ text: '',
482
+ selection: [1, 1]
483
+ };
484
+ }
485
+ }
486
+ } else if (text == "\n" || text == "\r\n") {
487
+ var closing = "";
488
+ if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
489
+ closing = lang.stringRepeat("}", maybeInsertedBrackets);
490
+ CstyleBehaviour.clearMaybeInsertedClosing();
491
+ }
492
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
493
+ if (rightChar == '}' || closing !== "") {
494
+ var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column}, '}');
495
+ if (!openBracePos)
496
+ return null;
497
+
498
+ var indent = this.getNextLineIndent(state, line.substring(0, cursor.column), session.getTabString());
499
+ var next_indent = this.$getIndent(line);
500
+
501
+ return {
502
+ text: '\n' + indent + '\n' + next_indent + closing,
503
+ selection: [1, indent.length, 1, indent.length]
504
+ };
505
+ }
506
+ }
507
+ });
508
+
509
+ this.add("braces", "deletion", function (state, action, editor, session, range) {
510
+ var selected = session.doc.getTextRange(range);
511
+ if (!range.isMultiLine() && selected == '{') {
512
+ var line = session.doc.getLine(range.start.row);
513
+ var rightChar = line.substring(range.end.column, range.end.column + 1);
514
+ if (rightChar == '}') {
515
+ range.end.column++;
516
+ return range;
517
+ } else {
518
+ maybeInsertedBrackets--;
519
+ }
520
+ }
521
+ });
522
+
523
+ this.add("parens", "insertion", function (state, action, editor, session, text) {
524
+ if (text == '(') {
525
+ var selection = editor.getSelectionRange();
526
+ var selected = session.doc.getTextRange(selection);
527
+ if (selected !== "" && editor.getWrapBehavioursEnabled()) {
528
+ return {
529
+ text: '(' + selected + ')',
530
+ selection: false
531
+ };
532
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
533
+ CstyleBehaviour.recordAutoInsert(editor, session, ")");
534
+ return {
535
+ text: '()',
536
+ selection: [1, 1]
537
+ };
538
+ }
539
+ } else if (text == ')') {
540
+ var cursor = editor.getCursorPosition();
541
+ var line = session.doc.getLine(cursor.row);
542
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
543
+ if (rightChar == ')') {
544
+ var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
545
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
546
+ CstyleBehaviour.popAutoInsertedClosing();
547
+ return {
548
+ text: '',
549
+ selection: [1, 1]
550
+ };
551
+ }
552
+ }
553
+ }
554
+ });
555
+
556
+ this.add("parens", "deletion", function (state, action, editor, session, range) {
557
+ var selected = session.doc.getTextRange(range);
558
+ if (!range.isMultiLine() && selected == '(') {
559
+ var line = session.doc.getLine(range.start.row);
560
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
561
+ if (rightChar == ')') {
562
+ range.end.column++;
563
+ return range;
564
+ }
565
+ }
566
+ });
567
+
568
+ this.add("brackets", "insertion", function (state, action, editor, session, text) {
569
+ if (text == '[') {
570
+ var selection = editor.getSelectionRange();
571
+ var selected = session.doc.getTextRange(selection);
572
+ if (selected !== "" && editor.getWrapBehavioursEnabled()) {
573
+ return {
574
+ text: '[' + selected + ']',
575
+ selection: false
576
+ };
577
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
578
+ CstyleBehaviour.recordAutoInsert(editor, session, "]");
579
+ return {
580
+ text: '[]',
581
+ selection: [1, 1]
582
+ };
583
+ }
584
+ } else if (text == ']') {
585
+ var cursor = editor.getCursorPosition();
586
+ var line = session.doc.getLine(cursor.row);
587
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
588
+ if (rightChar == ']') {
589
+ var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
590
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
591
+ CstyleBehaviour.popAutoInsertedClosing();
592
+ return {
593
+ text: '',
594
+ selection: [1, 1]
595
+ };
596
+ }
597
+ }
598
+ }
599
+ });
600
+
601
+ this.add("brackets", "deletion", function (state, action, editor, session, range) {
602
+ var selected = session.doc.getTextRange(range);
603
+ if (!range.isMultiLine() && selected == '[') {
604
+ var line = session.doc.getLine(range.start.row);
605
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
606
+ if (rightChar == ']') {
607
+ range.end.column++;
608
+ return range;
609
+ }
610
+ }
611
+ });
612
+
613
+ this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
614
+ if (text == '"' || text == "'") {
615
+ var quote = text;
616
+ var selection = editor.getSelectionRange();
617
+ var selected = session.doc.getTextRange(selection);
618
+ if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
619
+ return {
620
+ text: quote + selected + quote,
621
+ selection: false
622
+ };
623
+ } else {
624
+ var cursor = editor.getCursorPosition();
625
+ var line = session.doc.getLine(cursor.row);
626
+ var leftChar = line.substring(cursor.column-1, cursor.column);
627
+ if (leftChar == '\\') {
628
+ return null;
629
+ }
630
+ var tokens = session.getTokens(selection.start.row);
631
+ var col = 0, token;
632
+ var quotepos = -1; // Track whether we're inside an open quote.
633
+
634
+ for (var x = 0; x < tokens.length; x++) {
635
+ token = tokens[x];
636
+ if (token.type == "string") {
637
+ quotepos = -1;
638
+ } else if (quotepos < 0) {
639
+ quotepos = token.value.indexOf(quote);
640
+ }
641
+ if ((token.value.length + col) > selection.start.column) {
642
+ break;
643
+ }
644
+ col += tokens[x].value.length;
645
+ }
646
+ if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
647
+ if (!CstyleBehaviour.isSaneInsertion(editor, session))
648
+ return;
649
+ return {
650
+ text: quote + quote,
651
+ selection: [1,1]
652
+ };
653
+ } else if (token && token.type === "string") {
654
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
655
+ if (rightChar == quote) {
656
+ return {
657
+ text: '',
658
+ selection: [1, 1]
659
+ };
660
+ }
661
+ }
662
+ }
663
+ }
664
+ });
665
+
666
+ this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
667
+ var selected = session.doc.getTextRange(range);
668
+ if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
669
+ var line = session.doc.getLine(range.start.row);
670
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
671
+ if (rightChar == selected) {
672
+ range.end.column++;
673
+ return range;
674
+ }
675
+ }
676
+ });
677
+
678
+ };
679
+
680
+ oop.inherits(CstyleBehaviour, Behaviour);
681
+
682
+ exports.CstyleBehaviour = CstyleBehaviour;
683
+ });
684
+
685
+ define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
686
+
687
+
688
+ var oop = require("../../lib/oop");
689
+ var Range = require("../../range").Range;
690
+ var BaseFoldMode = require("./fold_mode").FoldMode;
691
+
692
+ var FoldMode = exports.FoldMode = function(commentRegex) {
693
+ if (commentRegex) {
694
+ this.foldingStartMarker = new RegExp(
695
+ this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
696
+ );
697
+ this.foldingStopMarker = new RegExp(
698
+ this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
699
+ );
700
+ }
701
+ };
702
+ oop.inherits(FoldMode, BaseFoldMode);
703
+
704
+ (function() {
705
+
706
+ this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
707
+ this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
708
+
709
+ this.getFoldWidgetRange = function(session, foldStyle, row) {
710
+ var line = session.getLine(row);
711
+ var match = line.match(this.foldingStartMarker);
712
+ if (match) {
713
+ var i = match.index;
714
+
715
+ if (match[1])
716
+ return this.openingBracketBlock(session, match[1], row, i);
717
+
718
+ return session.getCommentFoldRange(row, i + match[0].length, 1);
719
+ }
720
+
721
+ if (foldStyle !== "markbeginend")
722
+ return;
723
+
724
+ var match = line.match(this.foldingStopMarker);
725
+ if (match) {
726
+ var i = match.index + match[0].length;
727
+
728
+ if (match[1])
729
+ return this.closingBracketBlock(session, match[1], row, i);
730
+
731
+ return session.getCommentFoldRange(row, i, -1);
732
+ }
733
+ };
734
+
735
+ }).call(FoldMode.prototype);
736
+
737
+ });