e956ee932ed766d1e40c10a39bf62e58.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. ace.define("ace/mode/haskell_cabal_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){/**
  2. * Haskell Cabal files highlighter (https://www.haskell.org/cabal/users-guide/developing-packages.html)
  3. **/
  4. "use strict";
  5. var oop = require("../lib/oop");
  6. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  7. var CabalHighlightRules = function () {
  8. this.$rules = {
  9. "start": [
  10. {
  11. token: "comment",
  12. regex: "^\\s*--.*$"
  13. }, {
  14. token: ["keyword"],
  15. regex: /^(\s*\w.*?)(:(?:\s+|$))/
  16. }, {
  17. token: "constant.numeric",
  18. regex: /[\d_]+(?:(?:[\.\d_]*)?)/
  19. }, {
  20. token: "constant.language.boolean",
  21. regex: "(?:true|false|TRUE|FALSE|True|False|yes|no)\\b"
  22. }, {
  23. token: "markup.heading",
  24. regex: /^(\w.*)$/
  25. }
  26. ]
  27. };
  28. };
  29. oop.inherits(CabalHighlightRules, TextHighlightRules);
  30. exports.CabalHighlightRules = CabalHighlightRules;
  31. });
  32. ace.define("ace/mode/folding/haskell_cabal",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module){/*
  33. * Folding mode for Cabal files (Haskell): allow folding each seaction, including
  34. * the initial general section.
  35. */
  36. "use strict";
  37. var oop = require("../../lib/oop");
  38. var BaseFoldMode = require("./fold_mode").FoldMode;
  39. var Range = require("../../range").Range;
  40. var FoldMode = exports.FoldMode = function () { };
  41. oop.inherits(FoldMode, BaseFoldMode);
  42. (function () {
  43. this.isHeading = function (session, row) {
  44. var heading = "markup.heading";
  45. var token = session.getTokens(row)[0];
  46. return row == 0 || (token && token.type.lastIndexOf(heading, 0) === 0);
  47. };
  48. this.getFoldWidget = function (session, foldStyle, row) {
  49. if (this.isHeading(session, row)) {
  50. return "start";
  51. }
  52. else if (foldStyle === "markbeginend" && !(/^\s*$/.test(session.getLine(row)))) {
  53. var maxRow = session.getLength();
  54. while (++row < maxRow) {
  55. if (!(/^\s*$/.test(session.getLine(row)))) {
  56. break;
  57. }
  58. }
  59. if (row == maxRow || this.isHeading(session, row)) {
  60. return "end";
  61. }
  62. }
  63. return "";
  64. };
  65. this.getFoldWidgetRange = function (session, foldStyle, row) {
  66. var line = session.getLine(row);
  67. var startColumn = line.length;
  68. var maxRow = session.getLength();
  69. var startRow = row;
  70. var endRow = row;
  71. if (this.isHeading(session, row)) {
  72. while (++row < maxRow) {
  73. if (this.isHeading(session, row)) {
  74. row--;
  75. break;
  76. }
  77. }
  78. endRow = row;
  79. if (endRow > startRow) {
  80. while (endRow > startRow && /^\s*$/.test(session.getLine(endRow)))
  81. endRow--;
  82. }
  83. if (endRow > startRow) {
  84. var endColumn = session.getLine(endRow).length;
  85. return new Range(startRow, startColumn, endRow, endColumn);
  86. }
  87. }
  88. else if (this.getFoldWidget(session, foldStyle, row) === "end") {
  89. var endRow = row;
  90. var endColumn = session.getLine(endRow).length;
  91. while (--row >= 0) {
  92. if (this.isHeading(session, row)) {
  93. break;
  94. }
  95. }
  96. var line = session.getLine(row);
  97. var startColumn = line.length;
  98. return new Range(row, startColumn, endRow, endColumn);
  99. }
  100. };
  101. }).call(FoldMode.prototype);
  102. });
  103. ace.define("ace/mode/haskell_cabal",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/haskell_cabal_highlight_rules","ace/mode/folding/haskell_cabal"], function(require, exports, module){/**
  104. * Haskell Cabal files mode (https://www.haskell.org/cabal/users-guide/developing-packages.html)
  105. **/
  106. "use strict";
  107. var oop = require("../lib/oop");
  108. var TextMode = require("./text").Mode;
  109. var CabalHighlightRules = require("./haskell_cabal_highlight_rules").CabalHighlightRules;
  110. var FoldMode = require("./folding/haskell_cabal").FoldMode;
  111. var Mode = function () {
  112. this.HighlightRules = CabalHighlightRules;
  113. this.foldingRules = new FoldMode();
  114. this.$behaviour = this.$defaultBehaviour;
  115. };
  116. oop.inherits(Mode, TextMode);
  117. (function () {
  118. this.lineCommentStart = "--";
  119. this.blockComment = null;
  120. this.$id = "ace/mode/haskell_cabal";
  121. }).call(Mode.prototype);
  122. exports.Mode = Mode;
  123. }); (function() {
  124. ace.require(["ace/mode/haskell_cabal"], function(m) {
  125. if (typeof module == "object" && typeof exports == "object" && module) {
  126. module.exports = m;
  127. }
  128. });
  129. })();