You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
3.9 KiB

12 months ago
  1. ace.define("ace/mode/toml_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(acequire, exports, module) {
  2. "use strict";
  3. var oop = acequire("../lib/oop");
  4. var TextHighlightRules = acequire("./text_highlight_rules").TextHighlightRules;
  5. var TomlHighlightRules = function() {
  6. var keywordMapper = this.createKeywordMapper({
  7. "constant.language.boolean": "true|false"
  8. }, "identifier");
  9. var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
  10. this.$rules = {
  11. "start": [
  12. {
  13. token: "comment.toml",
  14. regex: /#.*$/
  15. },
  16. {
  17. token : "string",
  18. regex : '"(?=.)',
  19. next : "qqstring"
  20. },
  21. {
  22. token: ["variable.keygroup.toml"],
  23. regex: "(?:^\\s*)(\\[\\[([^\\]]+)\\]\\])"
  24. },
  25. {
  26. token: ["variable.keygroup.toml"],
  27. regex: "(?:^\\s*)(\\[([^\\]]+)\\])"
  28. },
  29. {
  30. token : keywordMapper,
  31. regex : identifierRe
  32. },
  33. {
  34. token : "support.date.toml",
  35. regex: "\\d{4}-\\d{2}-\\d{2}(T)\\d{2}:\\d{2}:\\d{2}(Z)"
  36. },
  37. {
  38. token: "constant.numeric.toml",
  39. regex: "-?\\d+(\\.?\\d+)?"
  40. }
  41. ],
  42. "qqstring" : [
  43. {
  44. token : "string",
  45. regex : "\\\\$",
  46. next : "qqstring"
  47. },
  48. {
  49. token : "constant.language.escape",
  50. regex : '\\\\[0tnr"\\\\]'
  51. },
  52. {
  53. token : "string",
  54. regex : '"|$',
  55. next : "start"
  56. },
  57. {
  58. defaultToken: "string"
  59. }
  60. ]
  61. };
  62. };
  63. oop.inherits(TomlHighlightRules, TextHighlightRules);
  64. exports.TomlHighlightRules = TomlHighlightRules;
  65. });
  66. ace.define("ace/mode/folding/ini",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(acequire, exports, module) {
  67. "use strict";
  68. var oop = acequire("../../lib/oop");
  69. var Range = acequire("../../range").Range;
  70. var BaseFoldMode = acequire("./fold_mode").FoldMode;
  71. var FoldMode = exports.FoldMode = function() {
  72. };
  73. oop.inherits(FoldMode, BaseFoldMode);
  74. (function() {
  75. this.foldingStartMarker = /^\s*\[([^\])]*)]\s*(?:$|[;#])/;
  76. this.getFoldWidgetRange = function(session, foldStyle, row) {
  77. var re = this.foldingStartMarker;
  78. var line = session.getLine(row);
  79. var m = line.match(re);
  80. if (!m) return;
  81. var startName = m[1] + ".";
  82. var startColumn = line.length;
  83. var maxRow = session.getLength();
  84. var startRow = row;
  85. var endRow = row;
  86. while (++row < maxRow) {
  87. line = session.getLine(row);
  88. if (/^\s*$/.test(line))
  89. continue;
  90. m = line.match(re);
  91. if (m && m[1].lastIndexOf(startName, 0) !== 0)
  92. break;
  93. endRow = row;
  94. }
  95. if (endRow > startRow) {
  96. var endColumn = session.getLine(endRow).length;
  97. return new Range(startRow, startColumn, endRow, endColumn);
  98. }
  99. };
  100. }).call(FoldMode.prototype);
  101. });
  102. ace.define("ace/mode/toml",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/toml_highlight_rules","ace/mode/folding/ini"], function(acequire, exports, module) {
  103. "use strict";
  104. var oop = acequire("../lib/oop");
  105. var TextMode = acequire("./text").Mode;
  106. var TomlHighlightRules = acequire("./toml_highlight_rules").TomlHighlightRules;
  107. var FoldMode = acequire("./folding/ini").FoldMode;
  108. var Mode = function() {
  109. this.HighlightRules = TomlHighlightRules;
  110. this.foldingRules = new FoldMode();
  111. this.$behaviour = this.$defaultBehaviour;
  112. };
  113. oop.inherits(Mode, TextMode);
  114. (function() {
  115. this.lineCommentStart = "#";
  116. this.$id = "ace/mode/toml";
  117. }).call(Mode.prototype);
  118. exports.Mode = Mode;
  119. });