ace-rails-ap 3.0.2 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ace/rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/ace/ace.js +403 -326
  4. data/vendor/assets/javascripts/ace/ext-language_tools.js +56 -40
  5. data/vendor/assets/javascripts/ace/ext-modelist.js +7 -3
  6. data/vendor/assets/javascripts/ace/ext-settings_menu.js +8 -4
  7. data/vendor/assets/javascripts/ace/ext-static_highlight.js +12 -5
  8. data/vendor/assets/javascripts/ace/keybinding-vim.js +5234 -1558
  9. data/vendor/assets/javascripts/ace/mode-abap.js +1 -1
  10. data/vendor/assets/javascripts/ace/mode-abc.js +261 -0
  11. data/vendor/assets/javascripts/ace/mode-actionscript.js +47 -1
  12. data/vendor/assets/javascripts/ace/mode-apache_conf.js +47 -1
  13. data/vendor/assets/javascripts/ace/mode-applescript.js +47 -1
  14. data/vendor/assets/javascripts/ace/mode-autohotkey.js +47 -1
  15. data/vendor/assets/javascripts/ace/mode-batchfile.js +47 -1
  16. data/vendor/assets/javascripts/ace/mode-c_cpp.js +101 -56
  17. data/vendor/assets/javascripts/ace/mode-coffee.js +3 -3
  18. data/vendor/assets/javascripts/ace/mode-coldfusion.js +114 -63
  19. data/vendor/assets/javascripts/ace/mode-csharp.js +99 -55
  20. data/vendor/assets/javascripts/ace/mode-css.js +98 -53
  21. data/vendor/assets/javascripts/ace/mode-curly.js +114 -63
  22. data/vendor/assets/javascripts/ace/mode-d.js +47 -1
  23. data/vendor/assets/javascripts/ace/mode-dart.js +103 -58
  24. data/vendor/assets/javascripts/ace/mode-diff.js +85 -85
  25. data/vendor/assets/javascripts/ace/mode-django.js +114 -63
  26. data/vendor/assets/javascripts/ace/mode-dockerfile.js +97 -52
  27. data/vendor/assets/javascripts/ace/mode-dot.js +47 -1
  28. data/vendor/assets/javascripts/ace/mode-eiffel.js +30 -37
  29. data/vendor/assets/javascripts/ace/mode-ejs.js +117 -63
  30. data/vendor/assets/javascripts/ace/mode-elm.js +47 -1
  31. data/vendor/assets/javascripts/ace/mode-erlang.js +47 -1
  32. data/vendor/assets/javascripts/ace/mode-forth.js +47 -1
  33. data/vendor/assets/javascripts/ace/mode-ftl.js +10 -7
  34. data/vendor/assets/javascripts/ace/mode-glsl.js +101 -56
  35. data/vendor/assets/javascripts/ace/mode-golang.js +96 -51
  36. data/vendor/assets/javascripts/ace/mode-groovy.js +98 -53
  37. data/vendor/assets/javascripts/ace/mode-haml.js +3 -0
  38. data/vendor/assets/javascripts/ace/mode-handlebars.js +114 -63
  39. data/vendor/assets/javascripts/ace/mode-haskell.js +49 -3
  40. data/vendor/assets/javascripts/ace/mode-haxe.js +96 -51
  41. data/vendor/assets/javascripts/ace/mode-html.js +114 -63
  42. data/vendor/assets/javascripts/ace/mode-html_ruby.js +117 -63
  43. data/vendor/assets/javascripts/ace/mode-io.js +47 -1
  44. data/vendor/assets/javascripts/ace/mode-jack.js +96 -51
  45. data/vendor/assets/javascripts/ace/mode-jade.js +10 -7
  46. data/vendor/assets/javascripts/ace/mode-java.js +98 -53
  47. data/vendor/assets/javascripts/ace/mode-javascript.js +98 -53
  48. data/vendor/assets/javascripts/ace/mode-json.js +99 -54
  49. data/vendor/assets/javascripts/ace/mode-jsoniq.js +98 -51
  50. data/vendor/assets/javascripts/ace/mode-jsp.js +106 -58
  51. data/vendor/assets/javascripts/ace/mode-jsx.js +96 -51
  52. data/vendor/assets/javascripts/ace/mode-julia.js +47 -1
  53. data/vendor/assets/javascripts/ace/mode-latex.js +1 -1
  54. data/vendor/assets/javascripts/ace/mode-lean.js +281 -0
  55. data/vendor/assets/javascripts/ace/mode-less.js +96 -51
  56. data/vendor/assets/javascripts/ace/mode-liquid.js +10 -7
  57. data/vendor/assets/javascripts/ace/mode-live_script.js +481 -0
  58. data/vendor/assets/javascripts/ace/mode-livescript.js +5 -8
  59. data/vendor/assets/javascripts/ace/mode-logiql.js +49 -50
  60. data/vendor/assets/javascripts/ace/mode-lsl.js +96 -51
  61. data/vendor/assets/javascripts/ace/mode-lua.js +3 -3
  62. data/vendor/assets/javascripts/ace/mode-luapage.js +117 -66
  63. data/vendor/assets/javascripts/ace/mode-makefile.js +1 -1
  64. data/vendor/assets/javascripts/ace/mode-markdown.js +134 -67
  65. data/vendor/assets/javascripts/ace/mode-mask.js +1985 -0
  66. data/vendor/assets/javascripts/ace/mode-mel.js +96 -51
  67. data/vendor/assets/javascripts/ace/mode-mips_assembler.js +235 -0
  68. data/vendor/assets/javascripts/ace/mode-mipsassembler.js +196 -0
  69. data/vendor/assets/javascripts/ace/mode-nix.js +101 -56
  70. data/vendor/assets/javascripts/ace/mode-objectivec.js +52 -6
  71. data/vendor/assets/javascripts/ace/mode-perl.js +47 -1
  72. data/vendor/assets/javascripts/ace/mode-pgsql.js +1 -1
  73. data/vendor/assets/javascripts/ace/mode-php.js +139 -85
  74. data/vendor/assets/javascripts/ace/mode-powershell.js +96 -51
  75. data/vendor/assets/javascripts/ace/mode-praat.js +47 -1
  76. data/vendor/assets/javascripts/ace/mode-prolog.js +47 -1
  77. data/vendor/assets/javascripts/ace/mode-protobuf.js +101 -56
  78. data/vendor/assets/javascripts/ace/mode-rdoc.js +1 -1
  79. data/vendor/assets/javascripts/ace/mode-rhtml.js +114 -63
  80. data/vendor/assets/javascripts/ace/mode-ruby.js +52 -50
  81. data/vendor/assets/javascripts/ace/mode-rust.js +57 -18
  82. data/vendor/assets/javascripts/ace/mode-scad.js +96 -51
  83. data/vendor/assets/javascripts/ace/mode-scala.js +98 -53
  84. data/vendor/assets/javascripts/ace/mode-scss.js +96 -51
  85. data/vendor/assets/javascripts/ace/mode-sh.js +97 -52
  86. data/vendor/assets/javascripts/ace/mode-sjs.js +98 -53
  87. data/vendor/assets/javascripts/ace/mode-smarty.js +114 -63
  88. data/vendor/assets/javascripts/ace/mode-soy_template.js +114 -63
  89. data/vendor/assets/javascripts/ace/mode-stylus.js +1 -1
  90. data/vendor/assets/javascripts/ace/mode-svg.js +132 -65
  91. data/vendor/assets/javascripts/ace/mode-tcl.js +47 -1
  92. data/vendor/assets/javascripts/ace/mode-twig.js +114 -63
  93. data/vendor/assets/javascripts/ace/mode-typescript.js +98 -53
  94. data/vendor/assets/javascripts/ace/mode-vala.js +96 -51
  95. data/vendor/assets/javascripts/ace/mode-velocity.js +114 -63
  96. data/vendor/assets/javascripts/ace/mode-vhdl.js +21 -21
  97. data/vendor/assets/javascripts/ace/mode-xml.js +34 -12
  98. data/vendor/assets/javascripts/ace/mode-xquery.js +98 -51
  99. data/vendor/assets/javascripts/ace/snippets/abc.js +38 -0
  100. data/vendor/assets/javascripts/ace/snippets/elixir.js +7 -0
  101. data/vendor/assets/javascripts/ace/snippets/elm.js +7 -0
  102. data/vendor/assets/javascripts/ace/snippets/lean.js +7 -0
  103. data/vendor/assets/javascripts/ace/snippets/live_script.js +7 -0
  104. data/vendor/assets/javascripts/ace/snippets/mask.js +7 -0
  105. data/vendor/assets/javascripts/ace/snippets/mips_assembler.js +7 -0
  106. data/vendor/assets/javascripts/ace/snippets/mipsassembler.js +7 -0
  107. data/vendor/assets/javascripts/ace/snippets/r.js +1 -1
  108. data/vendor/assets/javascripts/ace/theme-clouds_midnight.js +1 -1
  109. data/vendor/assets/javascripts/ace/theme-github.js +7 -1
  110. data/vendor/assets/javascripts/ace/theme-katzenmilch.js +3 -0
  111. data/vendor/assets/javascripts/ace/theme-kuroir.js +3 -0
  112. data/vendor/assets/javascripts/ace/worker-coffee.js +6 -7
  113. data/vendor/assets/javascripts/ace/worker-css.js +5 -5
  114. data/vendor/assets/javascripts/ace/worker-html.js +4354 -4354
  115. data/vendor/assets/javascripts/ace/worker-javascript.js +2435 -1397
  116. data/vendor/assets/javascripts/ace/worker-json.js +6 -7
  117. data/vendor/assets/javascripts/ace/worker-lua.js +11 -11
  118. data/vendor/assets/javascripts/ace/worker-php.js +4 -8
  119. data/vendor/assets/javascripts/ace/worker-xml.js +3809 -0
  120. data/vendor/assets/javascripts/ace/worker-xquery.js +38 -47
  121. metadata +18 -9
  122. data/vendor/assets/javascripts/ace/ext-options.js +0 -252
  123. data/vendor/assets/javascripts/ace/mode-html_completions.js +0 -309
  124. data/vendor/assets/javascripts/ace/mode-luahtml.js +0 -2415
  125. data/vendor/assets/javascripts/ace/mode-mushcode_high_rules.js +0 -569
  126. data/vendor/assets/javascripts/ace/mode-tmsnippet.js +0 -200
  127. data/vendor/assets/javascripts/ace/theme-kr.js +0 -105
@@ -66,13 +66,13 @@ var c_cppHighlightRules = function() {
66
66
  var storageType = (
67
67
  "asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|" +
68
68
  "_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void|" +
69
- "class|wchar_t|template"
69
+ "class|wchar_t|template|char16_t|char32_t"
70
70
  );
71
71
 
72
72
  var storageModifiers = (
73
73
  "const|extern|register|restrict|static|volatile|inline|private|" +
74
74
  "protected|public|friend|explicit|virtual|export|mutable|typename|" +
75
- "constexpr|new|delete"
75
+ "constexpr|new|delete|alignas|alignof|decltype|noexcept|thread_local"
76
76
  );
77
77
 
78
78
  var keywordOperators = (
@@ -81,7 +81,7 @@ var c_cppHighlightRules = function() {
81
81
  );
82
82
 
83
83
  var builtinConstants = (
84
- "NULL|true|false|TRUE|FALSE"
84
+ "NULL|true|false|TRUE|FALSE|nullptr"
85
85
  );
86
86
 
87
87
  var keywordMapper = this.$keywords = this.createKeywordMapper({
@@ -129,11 +129,11 @@ var c_cppHighlightRules = function() {
129
129
  regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b"
130
130
  }, {
131
131
  token : "keyword", // pre-compiler directives
132
- regex : "#\\s*(?:include|import|pragma|line|define|undef|if|ifdef|else|elif|ifndef)\\b",
132
+ regex : "#\\s*(?:include|import|pragma|line|define|undef)\\b",
133
133
  next : "directive"
134
134
  }, {
135
135
  token : "keyword", // special case pre-compiler directive
136
- regex : "(?:#\\s*endif)\\b"
136
+ regex : "#\\s*(?:endif|if|ifdef|else|elif|ifndef)\\b"
137
137
  }, {
138
138
  token : "support.function.C99.c",
139
139
  regex : cFunctions
@@ -314,6 +314,19 @@ var initContext = function(editor) {
314
314
  };
315
315
  };
316
316
 
317
+ var getWrapped = function(selection, selected, opening, closing) {
318
+ var rowDiff = selection.end.row - selection.start.row;
319
+ return {
320
+ text: opening + selected + closing,
321
+ selection: [
322
+ 0,
323
+ selection.start.column + 1,
324
+ rowDiff,
325
+ selection.end.column + (rowDiff ? 0 : 1)
326
+ ]
327
+ };
328
+ };
329
+
317
330
  var CstyleBehaviour = function() {
318
331
  this.add("braces", "insertion", function(state, action, editor, session, text) {
319
332
  var cursor = editor.getCursorPosition();
@@ -323,10 +336,7 @@ var CstyleBehaviour = function() {
323
336
  var selection = editor.getSelectionRange();
324
337
  var selected = session.doc.getTextRange(selection);
325
338
  if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
326
- return {
327
- text: '{' + selected + '}',
328
- selection: false
329
- };
339
+ return getWrapped(selection, selected, '{', '}');
330
340
  } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
331
341
  if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
332
342
  CstyleBehaviour.recordAutoInsert(editor, session, "}");
@@ -406,10 +416,7 @@ var CstyleBehaviour = function() {
406
416
  var selection = editor.getSelectionRange();
407
417
  var selected = session.doc.getTextRange(selection);
408
418
  if (selected !== "" && editor.getWrapBehavioursEnabled()) {
409
- return {
410
- text: '(' + selected + ')',
411
- selection: false
412
- };
419
+ return getWrapped(selection, selected, '(', ')');
413
420
  } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
414
421
  CstyleBehaviour.recordAutoInsert(editor, session, ")");
415
422
  return {
@@ -454,10 +461,7 @@ var CstyleBehaviour = function() {
454
461
  var selection = editor.getSelectionRange();
455
462
  var selected = session.doc.getTextRange(selection);
456
463
  if (selected !== "" && editor.getWrapBehavioursEnabled()) {
457
- return {
458
- text: '[' + selected + ']',
459
- selection: false
460
- };
464
+ return getWrapped(selection, selected, '[', ']');
461
465
  } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
462
466
  CstyleBehaviour.recordAutoInsert(editor, session, "]");
463
467
  return {
@@ -503,49 +507,44 @@ var CstyleBehaviour = function() {
503
507
  var selection = editor.getSelectionRange();
504
508
  var selected = session.doc.getTextRange(selection);
505
509
  if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
506
- return {
507
- text: quote + selected + quote,
508
- selection: false
509
- };
510
- } else {
510
+ return getWrapped(selection, selected, quote, quote);
511
+ } else if (!selected) {
511
512
  var cursor = editor.getCursorPosition();
512
513
  var line = session.doc.getLine(cursor.row);
513
514
  var leftChar = line.substring(cursor.column-1, cursor.column);
514
- if (leftChar == '\\') {
515
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
516
+
517
+ var token = session.getTokenAt(cursor.row, cursor.column);
518
+ var rightToken = session.getTokenAt(cursor.row, cursor.column + 1);
519
+ if (leftChar == "\\" && token && /escape/.test(token.type))
515
520
  return null;
521
+
522
+ var stringBefore = token && /string/.test(token.type);
523
+ var stringAfter = !rightToken || /string/.test(rightToken.type);
524
+
525
+ var pair;
526
+ if (rightChar == quote) {
527
+ pair = stringBefore !== stringAfter;
528
+ } else {
529
+ if (stringBefore && !stringAfter)
530
+ return null; // wrap string with different quote
531
+ if (stringBefore && stringAfter)
532
+ return null; // do not pair quotes inside strings
533
+ var wordRe = session.$mode.tokenRe;
534
+ wordRe.lastIndex = 0;
535
+ var isWordBefore = wordRe.test(leftChar);
536
+ wordRe.lastIndex = 0;
537
+ var isWordAfter = wordRe.test(leftChar);
538
+ if (isWordBefore || isWordAfter)
539
+ return null; // before or after alphanumeric
540
+ if (rightChar && !/[\s;,.})\]\\]/.test(rightChar))
541
+ return null; // there is rightChar and it isn't closing
542
+ pair = true;
516
543
  }
517
- var tokens = session.getTokens(selection.start.row);
518
- var col = 0, token;
519
- var quotepos = -1; // Track whether we're inside an open quote.
520
-
521
- for (var x = 0; x < tokens.length; x++) {
522
- token = tokens[x];
523
- if (token.type == "string") {
524
- quotepos = -1;
525
- } else if (quotepos < 0) {
526
- quotepos = token.value.indexOf(quote);
527
- }
528
- if ((token.value.length + col) > selection.start.column) {
529
- break;
530
- }
531
- col += tokens[x].value.length;
532
- }
533
- 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)))) {
534
- if (!CstyleBehaviour.isSaneInsertion(editor, session))
535
- return;
536
- return {
537
- text: quote + quote,
538
- selection: [1,1]
539
- };
540
- } else if (token && token.type === "string") {
541
- var rightChar = line.substring(cursor.column, cursor.column + 1);
542
- if (rightChar == quote) {
543
- return {
544
- text: '',
545
- selection: [1, 1]
546
- };
547
- }
548
- }
544
+ return {
545
+ text: pair ? quote + quote : "",
546
+ selection: [1,1]
547
+ };
549
548
  }
550
549
  }
551
550
  });
@@ -657,12 +656,35 @@ var FoldMode = exports.FoldMode = function(commentRegex) {
657
656
  oop.inherits(FoldMode, BaseFoldMode);
658
657
 
659
658
  (function() {
660
-
659
+
661
660
  this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
662
661
  this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
662
+ this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
663
+ this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
664
+ this.startRegionRe = /^\s*(\/\*|\/\/)#region\b/;
665
+ this._getFoldWidgetBase = this.getFoldWidget;
666
+ this.getFoldWidget = function(session, foldStyle, row) {
667
+ var line = session.getLine(row);
668
+
669
+ if (this.singleLineBlockCommentRe.test(line)) {
670
+ if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
671
+ return "";
672
+ }
673
+
674
+ var fw = this._getFoldWidgetBase(session, foldStyle, row);
675
+
676
+ if (!fw && this.startRegionRe.test(line))
677
+ return "start"; // lineCommentRegionStart
678
+
679
+ return fw;
680
+ };
663
681
 
664
682
  this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
665
683
  var line = session.getLine(row);
684
+
685
+ if (this.startRegionRe.test(line))
686
+ return this.getCommentRegionBlock(session, line, row);
687
+
666
688
  var match = line.match(this.foldingStartMarker);
667
689
  if (match) {
668
690
  var i = match.index;
@@ -727,6 +749,29 @@ oop.inherits(FoldMode, BaseFoldMode);
727
749
 
728
750
  return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
729
751
  };
752
+
753
+ this.getCommentRegionBlock = function(session, line, row) {
754
+ var startColumn = line.search(/\s*$/);
755
+ var maxRow = session.getLength();
756
+ var startRow = row;
757
+
758
+ var re = /^\s*(?:\/\*|\/\/)#(end)?region\b/;
759
+ var depth = 1;
760
+ while (++row < maxRow) {
761
+ line = session.getLine(row);
762
+ var m = re.exec(line);
763
+ if (!m) continue;
764
+ if (m[1]) depth--;
765
+ else depth++;
766
+
767
+ if (!depth) break;
768
+ }
769
+
770
+ var endRow = row;
771
+ if (endRow > startRow) {
772
+ return new Range(startRow, startColumn, endRow, line.length);
773
+ }
774
+ };
730
775
 
731
776
  }).call(FoldMode.prototype);
732
777
 
@@ -66,13 +66,13 @@ var c_cppHighlightRules = function() {
66
66
  var storageType = (
67
67
  "asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|" +
68
68
  "_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void|" +
69
- "class|wchar_t|template"
69
+ "class|wchar_t|template|char16_t|char32_t"
70
70
  );
71
71
 
72
72
  var storageModifiers = (
73
73
  "const|extern|register|restrict|static|volatile|inline|private|" +
74
74
  "protected|public|friend|explicit|virtual|export|mutable|typename|" +
75
- "constexpr|new|delete"
75
+ "constexpr|new|delete|alignas|alignof|decltype|noexcept|thread_local"
76
76
  );
77
77
 
78
78
  var keywordOperators = (
@@ -81,7 +81,7 @@ var c_cppHighlightRules = function() {
81
81
  );
82
82
 
83
83
  var builtinConstants = (
84
- "NULL|true|false|TRUE|FALSE"
84
+ "NULL|true|false|TRUE|FALSE|nullptr"
85
85
  );
86
86
 
87
87
  var keywordMapper = this.$keywords = this.createKeywordMapper({
@@ -129,11 +129,11 @@ var c_cppHighlightRules = function() {
129
129
  regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b"
130
130
  }, {
131
131
  token : "keyword", // pre-compiler directives
132
- regex : "#\\s*(?:include|import|pragma|line|define|undef|if|ifdef|else|elif|ifndef)\\b",
132
+ regex : "#\\s*(?:include|import|pragma|line|define|undef)\\b",
133
133
  next : "directive"
134
134
  }, {
135
135
  token : "keyword", // special case pre-compiler directive
136
- regex : "(?:#\\s*endif)\\b"
136
+ regex : "#\\s*(?:endif|if|ifdef|else|elif|ifndef)\\b"
137
137
  }, {
138
138
  token : "support.function.C99.c",
139
139
  regex : cFunctions
@@ -586,12 +586,35 @@ var FoldMode = exports.FoldMode = function(commentRegex) {
586
586
  oop.inherits(FoldMode, BaseFoldMode);
587
587
 
588
588
  (function() {
589
-
589
+
590
590
  this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
591
591
  this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
592
+ this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
593
+ this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
594
+ this.startRegionRe = /^\s*(\/\*|\/\/)#region\b/;
595
+ this._getFoldWidgetBase = this.getFoldWidget;
596
+ this.getFoldWidget = function(session, foldStyle, row) {
597
+ var line = session.getLine(row);
598
+
599
+ if (this.singleLineBlockCommentRe.test(line)) {
600
+ if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
601
+ return "";
602
+ }
603
+
604
+ var fw = this._getFoldWidgetBase(session, foldStyle, row);
605
+
606
+ if (!fw && this.startRegionRe.test(line))
607
+ return "start"; // lineCommentRegionStart
608
+
609
+ return fw;
610
+ };
592
611
 
593
612
  this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
594
613
  var line = session.getLine(row);
614
+
615
+ if (this.startRegionRe.test(line))
616
+ return this.getCommentRegionBlock(session, line, row);
617
+
595
618
  var match = line.match(this.foldingStartMarker);
596
619
  if (match) {
597
620
  var i = match.index;
@@ -656,6 +679,29 @@ oop.inherits(FoldMode, BaseFoldMode);
656
679
 
657
680
  return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
658
681
  };
682
+
683
+ this.getCommentRegionBlock = function(session, line, row) {
684
+ var startColumn = line.search(/\s*$/);
685
+ var maxRow = session.getLength();
686
+ var startRow = row;
687
+
688
+ var re = /^\s*(?:\/\*|\/\/)#(end)?region\b/;
689
+ var depth = 1;
690
+ while (++row < maxRow) {
691
+ line = session.getLine(row);
692
+ var m = re.exec(line);
693
+ if (!m) continue;
694
+ if (m[1]) depth--;
695
+ else depth++;
696
+
697
+ if (!depth) break;
698
+ }
699
+
700
+ var endRow = row;
701
+ if (endRow > startRow) {
702
+ return new Range(startRow, startColumn, endRow, line.length);
703
+ }
704
+ };
659
705
 
660
706
  }).call(FoldMode.prototype);
661
707
 
@@ -191,12 +191,35 @@ var FoldMode = exports.FoldMode = function(commentRegex) {
191
191
  oop.inherits(FoldMode, BaseFoldMode);
192
192
 
193
193
  (function() {
194
-
194
+
195
195
  this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
196
196
  this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
197
+ this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
198
+ this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
199
+ this.startRegionRe = /^\s*(\/\*|\/\/)#region\b/;
200
+ this._getFoldWidgetBase = this.getFoldWidget;
201
+ this.getFoldWidget = function(session, foldStyle, row) {
202
+ var line = session.getLine(row);
203
+
204
+ if (this.singleLineBlockCommentRe.test(line)) {
205
+ if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
206
+ return "";
207
+ }
208
+
209
+ var fw = this._getFoldWidgetBase(session, foldStyle, row);
210
+
211
+ if (!fw && this.startRegionRe.test(line))
212
+ return "start"; // lineCommentRegionStart
213
+
214
+ return fw;
215
+ };
197
216
 
198
217
  this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
199
218
  var line = session.getLine(row);
219
+
220
+ if (this.startRegionRe.test(line))
221
+ return this.getCommentRegionBlock(session, line, row);
222
+
200
223
  var match = line.match(this.foldingStartMarker);
201
224
  if (match) {
202
225
  var i = match.index;
@@ -261,6 +284,29 @@ oop.inherits(FoldMode, BaseFoldMode);
261
284
 
262
285
  return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
263
286
  };
287
+
288
+ this.getCommentRegionBlock = function(session, line, row) {
289
+ var startColumn = line.search(/\s*$/);
290
+ var maxRow = session.getLength();
291
+ var startRow = row;
292
+
293
+ var re = /^\s*(?:\/\*|\/\/)#(end)?region\b/;
294
+ var depth = 1;
295
+ while (++row < maxRow) {
296
+ line = session.getLine(row);
297
+ var m = re.exec(line);
298
+ if (!m) continue;
299
+ if (m[1]) depth--;
300
+ else depth++;
301
+
302
+ if (!depth) break;
303
+ }
304
+
305
+ var endRow = row;
306
+ if (endRow > startRow) {
307
+ return new Range(startRow, startColumn, endRow, line.length);
308
+ }
309
+ };
264
310
 
265
311
  }).call(FoldMode.prototype);
266
312
 
@@ -533,7 +533,7 @@ var JavaScriptHighlightRules = function(options) {
533
533
  regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
534
534
  }, {
535
535
  token : ["punctuation.operator", "support.function.dom"],
536
- regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
536
+ regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName|ClassName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
537
537
  }, {
538
538
  token : ["punctuation.operator", "support.constant"],
539
539
  regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
@@ -58,7 +58,7 @@ var supportType = exports.supportType = "animation-fill-mode|alignment-adjust|al
58
58
  var supportFunction = exports.supportFunction = "rgb|rgba|url|attr|counter|counters";
59
59
  var supportConstant = exports.supportConstant = "absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero";
60
60
  var supportConstantColor = exports.supportConstantColor = "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow";
61
- var supportConstantFonts = exports.supportConstantFonts = "arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace";
61
+ var supportConstantFonts = exports.supportConstantFonts = "arial|century|comic|courier|cursive|fantasy|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace";
62
62
 
63
63
  var numRe = exports.numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
64
64
  var pseudoElements = exports.pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b";
@@ -320,7 +320,7 @@ var JavaScriptHighlightRules = function(options) {
320
320
  regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
321
321
  }, {
322
322
  token : ["punctuation.operator", "support.function.dom"],
323
- regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
323
+ regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName|ClassName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
324
324
  }, {
325
325
  token : ["punctuation.operator", "support.constant"],
326
326
  regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
@@ -551,6 +551,9 @@ var oop = require("../lib/oop");
551
551
  var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
552
552
 
553
553
  var XmlHighlightRules = function(normalize) {
554
+
555
+ var tagRegex = "[a-zA-Z][-_a-zA-Z0-9]*";
556
+
554
557
  this.$rules = {
555
558
  start : [
556
559
  {token : "string.cdata.xml", regex : "<\\!\\[CDATA\\[", next : "cdata"},
@@ -560,7 +563,7 @@ var XmlHighlightRules = function(normalize) {
560
563
  },
561
564
  {
562
565
  token : ["punctuation.instruction.xml", "keyword.instruction.xml"],
563
- regex : "(<\\?)([-_a-zA-Z0-9]+)", next : "processing_instruction",
566
+ regex : "(<\\?)(" + tagRegex + ")", next : "processing_instruction",
564
567
  },
565
568
  {token : "comment.xml", regex : "<\\!--", next : "comment"},
566
569
  {
@@ -576,7 +579,7 @@ var XmlHighlightRules = function(normalize) {
576
579
 
577
580
  xml_decl : [{
578
581
  token : "entity.other.attribute-name.decl-attribute-name.xml",
579
- regex : "(?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+"
582
+ regex : "(?:" + tagRegex + ":)?" + tagRegex + ""
580
583
  }, {
581
584
  token : "keyword.operator.decl-attribute-equals.xml",
582
585
  regex : "="
@@ -612,7 +615,7 @@ var XmlHighlightRules = function(normalize) {
612
615
  next: "pop"
613
616
  }, {
614
617
  token : ["punctuation.markup-decl.xml", "keyword.markup-decl.xml"],
615
- regex : "(<\\!)([-_a-zA-Z0-9]+)",
618
+ regex : "(<\\!)(" + tagRegex + ")",
616
619
  push : [{
617
620
  token : "text",
618
621
  regex : "\\s+"
@@ -648,7 +651,7 @@ var XmlHighlightRules = function(normalize) {
648
651
 
649
652
  tag : [{
650
653
  token : ["meta.tag.punctuation.tag-open.xml", "meta.tag.punctuation.end-tag-open.xml", "meta.tag.tag-name.xml"],
651
- regex : "(?:(<)|(</))((?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+)",
654
+ regex : "(?:(<)|(</))((?:" + tagRegex + ":)?" + tagRegex + ")",
652
655
  next: [
653
656
  {include : "attributes"},
654
657
  {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
@@ -679,7 +682,7 @@ var XmlHighlightRules = function(normalize) {
679
682
 
680
683
  attributes: [{
681
684
  token : "entity.other.attribute-name.xml",
682
- regex : "(?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+"
685
+ regex : "(?:" + tagRegex + ":)?" + tagRegex + ""
683
686
  }, {
684
687
  token : "keyword.operator.attribute-equals.xml",
685
688
  regex : "="
@@ -1956,6 +1959,19 @@ var initContext = function(editor) {
1956
1959
  };
1957
1960
  };
1958
1961
 
1962
+ var getWrapped = function(selection, selected, opening, closing) {
1963
+ var rowDiff = selection.end.row - selection.start.row;
1964
+ return {
1965
+ text: opening + selected + closing,
1966
+ selection: [
1967
+ 0,
1968
+ selection.start.column + 1,
1969
+ rowDiff,
1970
+ selection.end.column + (rowDiff ? 0 : 1)
1971
+ ]
1972
+ };
1973
+ };
1974
+
1959
1975
  var CstyleBehaviour = function() {
1960
1976
  this.add("braces", "insertion", function(state, action, editor, session, text) {
1961
1977
  var cursor = editor.getCursorPosition();
@@ -1965,10 +1981,7 @@ var CstyleBehaviour = function() {
1965
1981
  var selection = editor.getSelectionRange();
1966
1982
  var selected = session.doc.getTextRange(selection);
1967
1983
  if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
1968
- return {
1969
- text: '{' + selected + '}',
1970
- selection: false
1971
- };
1984
+ return getWrapped(selection, selected, '{', '}');
1972
1985
  } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
1973
1986
  if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
1974
1987
  CstyleBehaviour.recordAutoInsert(editor, session, "}");
@@ -2048,10 +2061,7 @@ var CstyleBehaviour = function() {
2048
2061
  var selection = editor.getSelectionRange();
2049
2062
  var selected = session.doc.getTextRange(selection);
2050
2063
  if (selected !== "" && editor.getWrapBehavioursEnabled()) {
2051
- return {
2052
- text: '(' + selected + ')',
2053
- selection: false
2054
- };
2064
+ return getWrapped(selection, selected, '(', ')');
2055
2065
  } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
2056
2066
  CstyleBehaviour.recordAutoInsert(editor, session, ")");
2057
2067
  return {
@@ -2096,10 +2106,7 @@ var CstyleBehaviour = function() {
2096
2106
  var selection = editor.getSelectionRange();
2097
2107
  var selected = session.doc.getTextRange(selection);
2098
2108
  if (selected !== "" && editor.getWrapBehavioursEnabled()) {
2099
- return {
2100
- text: '[' + selected + ']',
2101
- selection: false
2102
- };
2109
+ return getWrapped(selection, selected, '[', ']');
2103
2110
  } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
2104
2111
  CstyleBehaviour.recordAutoInsert(editor, session, "]");
2105
2112
  return {
@@ -2145,49 +2152,44 @@ var CstyleBehaviour = function() {
2145
2152
  var selection = editor.getSelectionRange();
2146
2153
  var selected = session.doc.getTextRange(selection);
2147
2154
  if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
2148
- return {
2149
- text: quote + selected + quote,
2150
- selection: false
2151
- };
2152
- } else {
2155
+ return getWrapped(selection, selected, quote, quote);
2156
+ } else if (!selected) {
2153
2157
  var cursor = editor.getCursorPosition();
2154
2158
  var line = session.doc.getLine(cursor.row);
2155
2159
  var leftChar = line.substring(cursor.column-1, cursor.column);
2156
- if (leftChar == '\\') {
2160
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
2161
+
2162
+ var token = session.getTokenAt(cursor.row, cursor.column);
2163
+ var rightToken = session.getTokenAt(cursor.row, cursor.column + 1);
2164
+ if (leftChar == "\\" && token && /escape/.test(token.type))
2157
2165
  return null;
2166
+
2167
+ var stringBefore = token && /string/.test(token.type);
2168
+ var stringAfter = !rightToken || /string/.test(rightToken.type);
2169
+
2170
+ var pair;
2171
+ if (rightChar == quote) {
2172
+ pair = stringBefore !== stringAfter;
2173
+ } else {
2174
+ if (stringBefore && !stringAfter)
2175
+ return null; // wrap string with different quote
2176
+ if (stringBefore && stringAfter)
2177
+ return null; // do not pair quotes inside strings
2178
+ var wordRe = session.$mode.tokenRe;
2179
+ wordRe.lastIndex = 0;
2180
+ var isWordBefore = wordRe.test(leftChar);
2181
+ wordRe.lastIndex = 0;
2182
+ var isWordAfter = wordRe.test(leftChar);
2183
+ if (isWordBefore || isWordAfter)
2184
+ return null; // before or after alphanumeric
2185
+ if (rightChar && !/[\s;,.})\]\\]/.test(rightChar))
2186
+ return null; // there is rightChar and it isn't closing
2187
+ pair = true;
2158
2188
  }
2159
- var tokens = session.getTokens(selection.start.row);
2160
- var col = 0, token;
2161
- var quotepos = -1; // Track whether we're inside an open quote.
2162
-
2163
- for (var x = 0; x < tokens.length; x++) {
2164
- token = tokens[x];
2165
- if (token.type == "string") {
2166
- quotepos = -1;
2167
- } else if (quotepos < 0) {
2168
- quotepos = token.value.indexOf(quote);
2169
- }
2170
- if ((token.value.length + col) > selection.start.column) {
2171
- break;
2172
- }
2173
- col += tokens[x].value.length;
2174
- }
2175
- 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)))) {
2176
- if (!CstyleBehaviour.isSaneInsertion(editor, session))
2177
- return;
2178
- return {
2179
- text: quote + quote,
2180
- selection: [1,1]
2181
- };
2182
- } else if (token && token.type === "string") {
2183
- var rightChar = line.substring(cursor.column, cursor.column + 1);
2184
- if (rightChar == quote) {
2185
- return {
2186
- text: '',
2187
- selection: [1, 1]
2188
- };
2189
- }
2190
- }
2189
+ return {
2190
+ text: pair ? quote + quote : "",
2191
+ selection: [1,1]
2192
+ };
2191
2193
  }
2192
2194
  }
2193
2195
  });
@@ -2299,12 +2301,35 @@ var FoldMode = exports.FoldMode = function(commentRegex) {
2299
2301
  oop.inherits(FoldMode, BaseFoldMode);
2300
2302
 
2301
2303
  (function() {
2302
-
2304
+
2303
2305
  this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
2304
2306
  this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
2307
+ this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
2308
+ this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
2309
+ this.startRegionRe = /^\s*(\/\*|\/\/)#region\b/;
2310
+ this._getFoldWidgetBase = this.getFoldWidget;
2311
+ this.getFoldWidget = function(session, foldStyle, row) {
2312
+ var line = session.getLine(row);
2313
+
2314
+ if (this.singleLineBlockCommentRe.test(line)) {
2315
+ if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
2316
+ return "";
2317
+ }
2318
+
2319
+ var fw = this._getFoldWidgetBase(session, foldStyle, row);
2320
+
2321
+ if (!fw && this.startRegionRe.test(line))
2322
+ return "start"; // lineCommentRegionStart
2323
+
2324
+ return fw;
2325
+ };
2305
2326
 
2306
2327
  this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
2307
2328
  var line = session.getLine(row);
2329
+
2330
+ if (this.startRegionRe.test(line))
2331
+ return this.getCommentRegionBlock(session, line, row);
2332
+
2308
2333
  var match = line.match(this.foldingStartMarker);
2309
2334
  if (match) {
2310
2335
  var i = match.index;
@@ -2369,6 +2394,29 @@ oop.inherits(FoldMode, BaseFoldMode);
2369
2394
 
2370
2395
  return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
2371
2396
  };
2397
+
2398
+ this.getCommentRegionBlock = function(session, line, row) {
2399
+ var startColumn = line.search(/\s*$/);
2400
+ var maxRow = session.getLength();
2401
+ var startRow = row;
2402
+
2403
+ var re = /^\s*(?:\/\*|\/\/)#(end)?region\b/;
2404
+ var depth = 1;
2405
+ while (++row < maxRow) {
2406
+ line = session.getLine(row);
2407
+ var m = re.exec(line);
2408
+ if (!m) continue;
2409
+ if (m[1]) depth--;
2410
+ else depth++;
2411
+
2412
+ if (!depth) break;
2413
+ }
2414
+
2415
+ var endRow = row;
2416
+ if (endRow > startRow) {
2417
+ return new Range(startRow, startColumn, endRow, line.length);
2418
+ }
2419
+ };
2372
2420
 
2373
2421
  }).call(FoldMode.prototype);
2374
2422
 
@@ -2444,7 +2492,7 @@ oop.inherits(Mode, TextMode);
2444
2492
  var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
2445
2493
  worker.attachToDocument(session.getDocument());
2446
2494
 
2447
- worker.on("jslint", function(results) {
2495
+ worker.on("annotate", function(results) {
2448
2496
  session.setAnnotations(results.data);
2449
2497
  });
2450
2498
 
@@ -2591,7 +2639,7 @@ oop.inherits(Mode, TextMode);
2591
2639
  var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker");
2592
2640
  worker.attachToDocument(session.getDocument());
2593
2641
 
2594
- worker.on("csslint", function(e) {
2642
+ worker.on("annotate", function(e) {
2595
2643
  session.setAnnotations(e.data);
2596
2644
  });
2597
2645
 
@@ -2727,6 +2775,8 @@ var XmlBehaviour = function () {
2727
2775
  var token = iterator.getCurrentToken();
2728
2776
 
2729
2777
  if (token && token.type.indexOf("tag-close") !== -1) {
2778
+ if (token.value == "/>")
2779
+ return;
2730
2780
  while (token && token.type.indexOf("tag-name") === -1) {
2731
2781
  token = iterator.stepBackward();
2732
2782
  }
@@ -2980,9 +3030,6 @@ function is(token, type) {
2980
3030
  if (!tag || top.tagName == tag.tagName) {
2981
3031
  return stack.pop();
2982
3032
  }
2983
- else if (this.optionalEndTags.hasOwnProperty(tag.tagName)) {
2984
- return;
2985
- }
2986
3033
  else if (this.optionalEndTags.hasOwnProperty(top.tagName)) {
2987
3034
  stack.pop();
2988
3035
  continue;
@@ -3008,6 +3055,8 @@ function is(token, type) {
3008
3055
  row: row,
3009
3056
  column: firstTag.start.column + firstTag.tagName.length + 2
3010
3057
  };
3058
+ if (firstTag.start.row == firstTag.end.row)
3059
+ start.column = firstTag.end.column;
3011
3060
  while (tag = this._readTagForward(iterator)) {
3012
3061
  if (tag.selfClosing) {
3013
3062
  if (!stack.length) {
@@ -3049,6 +3098,8 @@ function is(token, type) {
3049
3098
  this._pop(stack, tag);
3050
3099
  if (stack.length == 0) {
3051
3100
  tag.start.column += tag.tagName.length + 2;
3101
+ if (tag.start.row == tag.end.row && tag.start.column < tag.end.column)
3102
+ tag.start.column = tag.end.column;
3052
3103
  return Range.fromPoints(tag.start, end);
3053
3104
  }
3054
3105
  }
@@ -3457,6 +3508,24 @@ oop.inherits(PhpMode, TextMode);
3457
3508
 
3458
3509
  (function() {
3459
3510
 
3511
+ this.tokenRe = new RegExp("^["
3512
+ + unicode.packages.L
3513
+ + unicode.packages.Mn + unicode.packages.Mc
3514
+ + unicode.packages.Nd
3515
+ + unicode.packages.Pc + "\_]+", "g"
3516
+ );
3517
+
3518
+ this.nonTokenRe = new RegExp("^(?:[^"
3519
+ + unicode.packages.L
3520
+ + unicode.packages.Mn + unicode.packages.Mc
3521
+ + unicode.packages.Nd
3522
+ + unicode.packages.Pc + "\_]|\s])+", "g"
3523
+ );
3524
+
3525
+
3526
+ this.lineCommentStart = ["//", "#"];
3527
+ this.blockComment = {start: "/*", end: "*/"};
3528
+
3460
3529
  this.getNextLineIndent = function(state, line, tab) {
3461
3530
  var indent = this.$getIndent(line);
3462
3531
 
@@ -3502,8 +3571,10 @@ oop.inherits(PhpMode, TextMode);
3502
3571
 
3503
3572
  var Mode = function(opts) {
3504
3573
  if (opts && opts.inline) {
3505
- PhpMode.call(this);
3506
- return;
3574
+ var mode = new PhpMode();
3575
+ mode.createWorker = this.createWorker;
3576
+ mode.inlinePhp = true;
3577
+ return mode;
3507
3578
  }
3508
3579
  HtmlMode.call(this);
3509
3580
  this.HighlightRules = PhpHighlightRules;
@@ -3512,29 +3583,12 @@ var Mode = function(opts) {
3512
3583
  "css-": CssMode,
3513
3584
  "php-": PhpMode
3514
3585
  });
3586
+ this.foldingRules.subModes["php-"] = new CStyleFoldMode();
3515
3587
  };
3516
3588
  oop.inherits(Mode, HtmlMode);
3517
3589
 
3518
3590
  (function() {
3519
3591
 
3520
- this.tokenRe = new RegExp("^["
3521
- + unicode.packages.L
3522
- + unicode.packages.Mn + unicode.packages.Mc
3523
- + unicode.packages.Nd
3524
- + unicode.packages.Pc + "\_]+", "g"
3525
- );
3526
-
3527
- this.nonTokenRe = new RegExp("^(?:[^"
3528
- + unicode.packages.L
3529
- + unicode.packages.Mn + unicode.packages.Mc
3530
- + unicode.packages.Nd
3531
- + unicode.packages.Pc + "\_]|\s])+", "g"
3532
- );
3533
-
3534
-
3535
- this.lineCommentStart = ["//", "#"];
3536
- this.blockComment = {start: "/*", end: "*/"};
3537
-
3538
3592
  this.createWorker = function(session) {
3539
3593
  var worker = new WorkerClient(["ace"], "ace/mode/php_worker", "PhpWorker");
3540
3594
  worker.attachToDocument(session.getDocument());
@@ -3542,11 +3596,11 @@ oop.inherits(Mode, HtmlMode);
3542
3596
  if (this.inlinePhp)
3543
3597
  worker.call("setOptions", [{inline: true}]);
3544
3598
 
3545
- worker.on("error", function(e) {
3599
+ worker.on("annotate", function(e) {
3546
3600
  session.setAnnotations(e.data);
3547
3601
  });
3548
3602
 
3549
- worker.on("ok", function() {
3603
+ worker.on("terminate", function() {
3550
3604
  session.clearAnnotations();
3551
3605
  });
3552
3606