datagram 0.0.1

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 (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,612 @@
1
+ define('ace/mode/csharp', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/csharp_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) {
2
+
3
+
4
+ var oop = require("../lib/oop");
5
+ var TextMode = require("./text").Mode;
6
+ var Tokenizer = require("../tokenizer").Tokenizer;
7
+ var CSharpHighlightRules = require("./csharp_highlight_rules").CSharpHighlightRules;
8
+ var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
9
+ var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
10
+ var CStyleFoldMode = require("./folding/cstyle").FoldMode;
11
+
12
+ var Mode = function() {
13
+ this.$tokenizer = new Tokenizer(new CSharpHighlightRules().getRules());
14
+ this.$outdent = new MatchingBraceOutdent();
15
+ this.$behaviour = new CstyleBehaviour();
16
+ this.foldingRules = new CStyleFoldMode();
17
+ };
18
+ oop.inherits(Mode, TextMode);
19
+
20
+ (function() {
21
+
22
+ this.lineCommentStart = "//";
23
+ this.blockComment = {start: "/*", end: "*/"};
24
+
25
+ this.getNextLineIndent = function(state, line, tab) {
26
+ var indent = this.$getIndent(line);
27
+
28
+ var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
29
+ var tokens = tokenizedLine.tokens;
30
+
31
+ if (tokens.length && tokens[tokens.length-1].type == "comment") {
32
+ return indent;
33
+ }
34
+
35
+ if (state == "start") {
36
+ var match = line.match(/^.*[\{\(\[]\s*$/);
37
+ if (match) {
38
+ indent += tab;
39
+ }
40
+ }
41
+
42
+ return indent;
43
+ };
44
+
45
+ this.checkOutdent = function(state, line, input) {
46
+ return this.$outdent.checkOutdent(line, input);
47
+ };
48
+
49
+ this.autoOutdent = function(state, doc, row) {
50
+ this.$outdent.autoOutdent(doc, row);
51
+ };
52
+
53
+
54
+ this.createWorker = function(session) {
55
+ return null;
56
+ };
57
+
58
+ }).call(Mode.prototype);
59
+
60
+ exports.Mode = Mode;
61
+ });
62
+ define('ace/mode/csharp_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
63
+
64
+
65
+ var oop = require("../lib/oop");
66
+ var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
67
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
68
+
69
+ var CSharpHighlightRules = function() {
70
+ var keywordMapper = this.createKeywordMapper({
71
+ "variable.language": "this",
72
+ "keyword": "abstract|event|new|struct|as|explicit|null|switch|base|extern|object|this|bool|false|operator|throw|break|finally|out|true|byte|fixed|override|try|case|float|params|typeof|catch|for|private|uint|char|foreach|protected|ulong|checked|goto|public|unchecked|class|if|readonly|unsafe|const|implicit|ref|ushort|continue|in|return|using|decimal|int|sbyte|virtual|default|interface|sealed|volatile|delegate|internal|short|void|do|is|sizeof|while|double|lock|stackalloc|else|long|static|enum|namespace|string|var|dynamic",
73
+ "constant.language": "null|true|false"
74
+ }, "identifier");
75
+
76
+ this.$rules = {
77
+ "start" : [
78
+ {
79
+ token : "comment",
80
+ regex : "\\/\\/.*$"
81
+ },
82
+ DocCommentHighlightRules.getStartRule("doc-start"),
83
+ {
84
+ token : "comment", // multi line comment
85
+ regex : "\\/\\*",
86
+ next : "comment"
87
+ }, {
88
+ token : "string.regexp",
89
+ regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
90
+ }, {
91
+ token : "string", // character
92
+ regex : /'(?:.|\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n]))'/
93
+ }, {
94
+ token : "string", start : '"', end : '"|$', next: [
95
+ {token: "constant.language.escape", regex: /\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n])/},
96
+ {token: "invalid", regex: /\\./}
97
+ ]
98
+ }, {
99
+ token : "string", start : '@"', end : '"', next:[
100
+ {token: "constant.language.escape", regex: '""'}
101
+ ]
102
+ }, {
103
+ token : "constant.numeric", // hex
104
+ regex : "0[xX][0-9a-fA-F]+\\b"
105
+ }, {
106
+ token : "constant.numeric", // float
107
+ regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
108
+ }, {
109
+ token : "constant.language.boolean",
110
+ regex : "(?:true|false)\\b"
111
+ }, {
112
+ token : keywordMapper,
113
+ regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
114
+ }, {
115
+ token : "keyword.operator",
116
+ regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
117
+ }, {
118
+ token : "punctuation.operator",
119
+ regex : "\\?|\\:|\\,|\\;|\\."
120
+ }, {
121
+ token : "paren.lparen",
122
+ regex : "[[({]"
123
+ }, {
124
+ token : "paren.rparen",
125
+ regex : "[\\])}]"
126
+ }, {
127
+ token : "text",
128
+ regex : "\\s+"
129
+ }
130
+ ],
131
+ "comment" : [
132
+ {
133
+ token : "comment", // closing comment
134
+ regex : ".*?\\*\\/",
135
+ next : "start"
136
+ }, {
137
+ token : "comment", // comment spanning whole line
138
+ regex : ".+"
139
+ }
140
+ ]
141
+ };
142
+
143
+ this.embedRules(DocCommentHighlightRules, "doc-",
144
+ [ DocCommentHighlightRules.getEndRule("start") ]);
145
+ this.normalizeRules();
146
+ };
147
+
148
+ oop.inherits(CSharpHighlightRules, TextHighlightRules);
149
+
150
+ exports.CSharpHighlightRules = CSharpHighlightRules;
151
+ });
152
+
153
+ define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
154
+
155
+
156
+ var oop = require("../lib/oop");
157
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
158
+
159
+ var DocCommentHighlightRules = function() {
160
+
161
+ this.$rules = {
162
+ "start" : [ {
163
+ token : "comment.doc.tag",
164
+ regex : "@[\\w\\d_]+" // TODO: fix email addresses
165
+ }, {
166
+ token : "comment.doc.tag",
167
+ regex : "\\bTODO\\b"
168
+ }, {
169
+ defaultToken : "comment.doc"
170
+ }]
171
+ };
172
+ };
173
+
174
+ oop.inherits(DocCommentHighlightRules, TextHighlightRules);
175
+
176
+ DocCommentHighlightRules.getStartRule = function(start) {
177
+ return {
178
+ token : "comment.doc", // doc comment
179
+ regex : "\\/\\*(?=\\*)",
180
+ next : start
181
+ };
182
+ };
183
+
184
+ DocCommentHighlightRules.getEndRule = function (start) {
185
+ return {
186
+ token : "comment.doc", // closing comment
187
+ regex : "\\*\\/",
188
+ next : start
189
+ };
190
+ };
191
+
192
+
193
+ exports.DocCommentHighlightRules = DocCommentHighlightRules;
194
+
195
+ });
196
+
197
+ define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
198
+
199
+
200
+ var Range = require("../range").Range;
201
+
202
+ var MatchingBraceOutdent = function() {};
203
+
204
+ (function() {
205
+
206
+ this.checkOutdent = function(line, input) {
207
+ if (! /^\s+$/.test(line))
208
+ return false;
209
+
210
+ return /^\s*\}/.test(input);
211
+ };
212
+
213
+ this.autoOutdent = function(doc, row) {
214
+ var line = doc.getLine(row);
215
+ var match = line.match(/^(\s*\})/);
216
+
217
+ if (!match) return 0;
218
+
219
+ var column = match[1].length;
220
+ var openBracePos = doc.findMatchingBracket({row: row, column: column});
221
+
222
+ if (!openBracePos || openBracePos.row == row) return 0;
223
+
224
+ var indent = this.$getIndent(doc.getLine(openBracePos.row));
225
+ doc.replace(new Range(row, 0, row, column-1), indent);
226
+ };
227
+
228
+ this.$getIndent = function(line) {
229
+ return line.match(/^\s*/)[0];
230
+ };
231
+
232
+ }).call(MatchingBraceOutdent.prototype);
233
+
234
+ exports.MatchingBraceOutdent = MatchingBraceOutdent;
235
+ });
236
+
237
+ define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/token_iterator', 'ace/lib/lang'], function(require, exports, module) {
238
+
239
+
240
+ var oop = require("../../lib/oop");
241
+ var Behaviour = require("../behaviour").Behaviour;
242
+ var TokenIterator = require("../../token_iterator").TokenIterator;
243
+ var lang = require("../../lib/lang");
244
+
245
+ var SAFE_INSERT_IN_TOKENS =
246
+ ["text", "paren.rparen", "punctuation.operator"];
247
+ var SAFE_INSERT_BEFORE_TOKENS =
248
+ ["text", "paren.rparen", "punctuation.operator", "comment"];
249
+
250
+
251
+ var autoInsertedBrackets = 0;
252
+ var autoInsertedRow = -1;
253
+ var autoInsertedLineEnd = "";
254
+ var maybeInsertedBrackets = 0;
255
+ var maybeInsertedRow = -1;
256
+ var maybeInsertedLineStart = "";
257
+ var maybeInsertedLineEnd = "";
258
+
259
+ var CstyleBehaviour = function () {
260
+
261
+ CstyleBehaviour.isSaneInsertion = function(editor, session) {
262
+ var cursor = editor.getCursorPosition();
263
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
264
+ if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
265
+ var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
266
+ if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
267
+ return false;
268
+ }
269
+ iterator.stepForward();
270
+ return iterator.getCurrentTokenRow() !== cursor.row ||
271
+ this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
272
+ };
273
+
274
+ CstyleBehaviour.$matchTokenType = function(token, types) {
275
+ return types.indexOf(token.type || token) > -1;
276
+ };
277
+
278
+ CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
279
+ var cursor = editor.getCursorPosition();
280
+ var line = session.doc.getLine(cursor.row);
281
+ if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0]))
282
+ autoInsertedBrackets = 0;
283
+ autoInsertedRow = cursor.row;
284
+ autoInsertedLineEnd = bracket + line.substr(cursor.column);
285
+ autoInsertedBrackets++;
286
+ };
287
+
288
+ CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
289
+ var cursor = editor.getCursorPosition();
290
+ var line = session.doc.getLine(cursor.row);
291
+ if (!this.isMaybeInsertedClosing(cursor, line))
292
+ maybeInsertedBrackets = 0;
293
+ maybeInsertedRow = cursor.row;
294
+ maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
295
+ maybeInsertedLineEnd = line.substr(cursor.column);
296
+ maybeInsertedBrackets++;
297
+ };
298
+
299
+ CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
300
+ return autoInsertedBrackets > 0 &&
301
+ cursor.row === autoInsertedRow &&
302
+ bracket === autoInsertedLineEnd[0] &&
303
+ line.substr(cursor.column) === autoInsertedLineEnd;
304
+ };
305
+
306
+ CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
307
+ return maybeInsertedBrackets > 0 &&
308
+ cursor.row === maybeInsertedRow &&
309
+ line.substr(cursor.column) === maybeInsertedLineEnd &&
310
+ line.substr(0, cursor.column) == maybeInsertedLineStart;
311
+ };
312
+
313
+ CstyleBehaviour.popAutoInsertedClosing = function() {
314
+ autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
315
+ autoInsertedBrackets--;
316
+ };
317
+
318
+ CstyleBehaviour.clearMaybeInsertedClosing = function() {
319
+ maybeInsertedBrackets = 0;
320
+ maybeInsertedRow = -1;
321
+ };
322
+
323
+ this.add("braces", "insertion", function (state, action, editor, session, text) {
324
+ var cursor = editor.getCursorPosition();
325
+ var line = session.doc.getLine(cursor.row);
326
+ if (text == '{') {
327
+ var selection = editor.getSelectionRange();
328
+ var selected = session.doc.getTextRange(selection);
329
+ if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
330
+ return {
331
+ text: '{' + selected + '}',
332
+ selection: false
333
+ };
334
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
335
+ if (/[\]\}\)]/.test(line[cursor.column])) {
336
+ CstyleBehaviour.recordAutoInsert(editor, session, "}");
337
+ return {
338
+ text: '{}',
339
+ selection: [1, 1]
340
+ };
341
+ } else {
342
+ CstyleBehaviour.recordMaybeInsert(editor, session, "{");
343
+ return {
344
+ text: '{',
345
+ selection: [1, 1]
346
+ };
347
+ }
348
+ }
349
+ } else if (text == '}') {
350
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
351
+ if (rightChar == '}') {
352
+ var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
353
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
354
+ CstyleBehaviour.popAutoInsertedClosing();
355
+ return {
356
+ text: '',
357
+ selection: [1, 1]
358
+ };
359
+ }
360
+ }
361
+ } else if (text == "\n" || text == "\r\n") {
362
+ var closing = "";
363
+ if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
364
+ closing = lang.stringRepeat("}", maybeInsertedBrackets);
365
+ CstyleBehaviour.clearMaybeInsertedClosing();
366
+ }
367
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
368
+ if (rightChar == '}' || closing !== "") {
369
+ var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column}, '}');
370
+ if (!openBracePos)
371
+ return null;
372
+
373
+ var indent = this.getNextLineIndent(state, line.substring(0, cursor.column), session.getTabString());
374
+ var next_indent = this.$getIndent(line);
375
+
376
+ return {
377
+ text: '\n' + indent + '\n' + next_indent + closing,
378
+ selection: [1, indent.length, 1, indent.length]
379
+ };
380
+ }
381
+ }
382
+ });
383
+
384
+ this.add("braces", "deletion", function (state, action, editor, session, range) {
385
+ var selected = session.doc.getTextRange(range);
386
+ if (!range.isMultiLine() && selected == '{') {
387
+ var line = session.doc.getLine(range.start.row);
388
+ var rightChar = line.substring(range.end.column, range.end.column + 1);
389
+ if (rightChar == '}') {
390
+ range.end.column++;
391
+ return range;
392
+ } else {
393
+ maybeInsertedBrackets--;
394
+ }
395
+ }
396
+ });
397
+
398
+ this.add("parens", "insertion", function (state, action, editor, session, text) {
399
+ if (text == '(') {
400
+ var selection = editor.getSelectionRange();
401
+ var selected = session.doc.getTextRange(selection);
402
+ if (selected !== "" && editor.getWrapBehavioursEnabled()) {
403
+ return {
404
+ text: '(' + selected + ')',
405
+ selection: false
406
+ };
407
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
408
+ CstyleBehaviour.recordAutoInsert(editor, session, ")");
409
+ return {
410
+ text: '()',
411
+ selection: [1, 1]
412
+ };
413
+ }
414
+ } else if (text == ')') {
415
+ var cursor = editor.getCursorPosition();
416
+ var line = session.doc.getLine(cursor.row);
417
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
418
+ if (rightChar == ')') {
419
+ var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
420
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
421
+ CstyleBehaviour.popAutoInsertedClosing();
422
+ return {
423
+ text: '',
424
+ selection: [1, 1]
425
+ };
426
+ }
427
+ }
428
+ }
429
+ });
430
+
431
+ this.add("parens", "deletion", function (state, action, editor, session, range) {
432
+ var selected = session.doc.getTextRange(range);
433
+ if (!range.isMultiLine() && selected == '(') {
434
+ var line = session.doc.getLine(range.start.row);
435
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
436
+ if (rightChar == ')') {
437
+ range.end.column++;
438
+ return range;
439
+ }
440
+ }
441
+ });
442
+
443
+ this.add("brackets", "insertion", function (state, action, editor, session, text) {
444
+ if (text == '[') {
445
+ var selection = editor.getSelectionRange();
446
+ var selected = session.doc.getTextRange(selection);
447
+ if (selected !== "" && editor.getWrapBehavioursEnabled()) {
448
+ return {
449
+ text: '[' + selected + ']',
450
+ selection: false
451
+ };
452
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
453
+ CstyleBehaviour.recordAutoInsert(editor, session, "]");
454
+ return {
455
+ text: '[]',
456
+ selection: [1, 1]
457
+ };
458
+ }
459
+ } else if (text == ']') {
460
+ var cursor = editor.getCursorPosition();
461
+ var line = session.doc.getLine(cursor.row);
462
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
463
+ if (rightChar == ']') {
464
+ var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
465
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
466
+ CstyleBehaviour.popAutoInsertedClosing();
467
+ return {
468
+ text: '',
469
+ selection: [1, 1]
470
+ };
471
+ }
472
+ }
473
+ }
474
+ });
475
+
476
+ this.add("brackets", "deletion", function (state, action, editor, session, range) {
477
+ var selected = session.doc.getTextRange(range);
478
+ if (!range.isMultiLine() && selected == '[') {
479
+ var line = session.doc.getLine(range.start.row);
480
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
481
+ if (rightChar == ']') {
482
+ range.end.column++;
483
+ return range;
484
+ }
485
+ }
486
+ });
487
+
488
+ this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
489
+ if (text == '"' || text == "'") {
490
+ var quote = text;
491
+ var selection = editor.getSelectionRange();
492
+ var selected = session.doc.getTextRange(selection);
493
+ if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
494
+ return {
495
+ text: quote + selected + quote,
496
+ selection: false
497
+ };
498
+ } else {
499
+ var cursor = editor.getCursorPosition();
500
+ var line = session.doc.getLine(cursor.row);
501
+ var leftChar = line.substring(cursor.column-1, cursor.column);
502
+ if (leftChar == '\\') {
503
+ return null;
504
+ }
505
+ var tokens = session.getTokens(selection.start.row);
506
+ var col = 0, token;
507
+ var quotepos = -1; // Track whether we're inside an open quote.
508
+
509
+ for (var x = 0; x < tokens.length; x++) {
510
+ token = tokens[x];
511
+ if (token.type == "string") {
512
+ quotepos = -1;
513
+ } else if (quotepos < 0) {
514
+ quotepos = token.value.indexOf(quote);
515
+ }
516
+ if ((token.value.length + col) > selection.start.column) {
517
+ break;
518
+ }
519
+ col += tokens[x].value.length;
520
+ }
521
+ 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)))) {
522
+ if (!CstyleBehaviour.isSaneInsertion(editor, session))
523
+ return;
524
+ return {
525
+ text: quote + quote,
526
+ selection: [1,1]
527
+ };
528
+ } else if (token && token.type === "string") {
529
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
530
+ if (rightChar == quote) {
531
+ return {
532
+ text: '',
533
+ selection: [1, 1]
534
+ };
535
+ }
536
+ }
537
+ }
538
+ }
539
+ });
540
+
541
+ this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
542
+ var selected = session.doc.getTextRange(range);
543
+ if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
544
+ var line = session.doc.getLine(range.start.row);
545
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
546
+ if (rightChar == selected) {
547
+ range.end.column++;
548
+ return range;
549
+ }
550
+ }
551
+ });
552
+
553
+ };
554
+
555
+ oop.inherits(CstyleBehaviour, Behaviour);
556
+
557
+ exports.CstyleBehaviour = CstyleBehaviour;
558
+ });
559
+
560
+ define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
561
+
562
+
563
+ var oop = require("../../lib/oop");
564
+ var Range = require("../../range").Range;
565
+ var BaseFoldMode = require("./fold_mode").FoldMode;
566
+
567
+ var FoldMode = exports.FoldMode = function(commentRegex) {
568
+ if (commentRegex) {
569
+ this.foldingStartMarker = new RegExp(
570
+ this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
571
+ );
572
+ this.foldingStopMarker = new RegExp(
573
+ this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
574
+ );
575
+ }
576
+ };
577
+ oop.inherits(FoldMode, BaseFoldMode);
578
+
579
+ (function() {
580
+
581
+ this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
582
+ this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
583
+
584
+ this.getFoldWidgetRange = function(session, foldStyle, row) {
585
+ var line = session.getLine(row);
586
+ var match = line.match(this.foldingStartMarker);
587
+ if (match) {
588
+ var i = match.index;
589
+
590
+ if (match[1])
591
+ return this.openingBracketBlock(session, match[1], row, i);
592
+
593
+ return session.getCommentFoldRange(row, i + match[0].length, 1);
594
+ }
595
+
596
+ if (foldStyle !== "markbeginend")
597
+ return;
598
+
599
+ var match = line.match(this.foldingStopMarker);
600
+ if (match) {
601
+ var i = match.index + match[0].length;
602
+
603
+ if (match[1])
604
+ return this.closingBracketBlock(session, match[1], row, i);
605
+
606
+ return session.getCommentFoldRange(row, i, -1);
607
+ }
608
+ };
609
+
610
+ }).call(FoldMode.prototype);
611
+
612
+ });