dd0c5a4ed6f5fb11d7cf1f1eff6d60e0.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. ace.define("ace/mode/abc_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){/* This file was partially autogenerated from https://github.com/jimhawkridge/SublimeABC
  2. Modifications
  3. - more classes to express the abc semantic
  4. - added syntax highlighting for Zupfnoter conventions (https://github.com/bwl21/zupfnoter)
  5. - separate note pitch and note duration - even if it looks the same
  6. ***********************************************************************************************/
  7. "use strict";
  8. var oop = require("../lib/oop");
  9. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  10. var ABCHighlightRules = function () {
  11. this.$rules = {
  12. start: [
  13. {
  14. token: ['zupfnoter.information.comment.line.percentage', 'information.keyword', 'in formation.keyword.embedded'],
  15. regex: '(%%%%)(hn\\.[a-z]*)(.*)',
  16. comment: 'Instruction Comment'
  17. },
  18. {
  19. token: ['information.comment.line.percentage', 'information.keyword.embedded'],
  20. regex: '(%%)(.*)',
  21. comment: 'Instruction Comment'
  22. },
  23. {
  24. token: 'comment.line.percentage',
  25. regex: '%.*',
  26. comment: 'Comments'
  27. },
  28. {
  29. token: 'barline.keyword.operator',
  30. regex: '[\\[:]*[|:][|\\]:]*(?:\\[?[0-9]+)?|\\[[0-9]+',
  31. comment: 'Bar lines'
  32. },
  33. {
  34. token: ['information.keyword.embedded', 'information.argument.string.unquoted'],
  35. regex: '(\\[[A-Za-z]:)([^\\]]*\\])',
  36. comment: 'embedded Header lines'
  37. },
  38. {
  39. token: ['information.keyword', 'information.argument.string.unquoted'],
  40. regex: '^([A-Za-z]:)([^%\\\\]*)',
  41. comment: 'Header lines'
  42. },
  43. {
  44. token: ['text', 'entity.name.function', 'string.unquoted', 'text'],
  45. regex: '(\\[)([A-Z]:)(.*?)(\\])',
  46. comment: 'Inline fields'
  47. },
  48. {
  49. token: ['accent.constant.language', 'pitch.constant.numeric', 'duration.constant.numeric'],
  50. regex: '([\\^=_]*)([A-Ga-gz][,\']*)([0-9]*/*[><0-9]*)',
  51. comment: 'Notes'
  52. },
  53. {
  54. token: 'zupfnoter.jumptarget.string.quoted',
  55. regex: '[\\"!]\\^\\:.*?[\\"!]',
  56. comment: 'Zupfnoter jumptarget'
  57. }, {
  58. token: 'zupfnoter.goto.string.quoted',
  59. regex: '[\\"!]\\^\\@.*?[\\"!]',
  60. comment: 'Zupfnoter goto'
  61. },
  62. {
  63. token: 'zupfnoter.annotation.string.quoted',
  64. regex: '[\\"!]\\^\\!.*?[\\"!]',
  65. comment: 'Zupfnoter annoation'
  66. },
  67. {
  68. token: 'zupfnoter.annotationref.string.quoted',
  69. regex: '[\\"!]\\^\\#.*?[\\"!]',
  70. comment: 'Zupfnoter annotation reference'
  71. },
  72. {
  73. token: 'chordname.string.quoted',
  74. regex: '[\\"!]\\^.*?[\\"!]',
  75. comment: 'abc chord'
  76. },
  77. {
  78. token: 'string.quoted',
  79. regex: '[\\"!].*?[\\"!]',
  80. comment: 'abc annotation'
  81. }
  82. ]
  83. };
  84. this.normalizeRules();
  85. };
  86. ABCHighlightRules.metaData = {
  87. fileTypes: ['abc'],
  88. name: 'ABC',
  89. scopeName: 'text.abcnotation'
  90. };
  91. oop.inherits(ABCHighlightRules, TextHighlightRules);
  92. exports.ABCHighlightRules = ABCHighlightRules;
  93. });
  94. ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict";
  95. var oop = require("../../lib/oop");
  96. var Range = require("../../range").Range;
  97. var BaseFoldMode = require("./fold_mode").FoldMode;
  98. var FoldMode = exports.FoldMode = function (commentRegex) {
  99. if (commentRegex) {
  100. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  101. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  102. }
  103. };
  104. oop.inherits(FoldMode, BaseFoldMode);
  105. (function () {
  106. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  107. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  108. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  109. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  110. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  111. this._getFoldWidgetBase = this.getFoldWidget;
  112. this.getFoldWidget = function (session, foldStyle, row) {
  113. var line = session.getLine(row);
  114. if (this.singleLineBlockCommentRe.test(line)) {
  115. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  116. return "";
  117. }
  118. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  119. if (!fw && this.startRegionRe.test(line))
  120. return "start"; // lineCommentRegionStart
  121. return fw;
  122. };
  123. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  124. var line = session.getLine(row);
  125. if (this.startRegionRe.test(line))
  126. return this.getCommentRegionBlock(session, line, row);
  127. var match = line.match(this.foldingStartMarker);
  128. if (match) {
  129. var i = match.index;
  130. if (match[1])
  131. return this.openingBracketBlock(session, match[1], row, i);
  132. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  133. if (range && !range.isMultiLine()) {
  134. if (forceMultiline) {
  135. range = this.getSectionRange(session, row);
  136. }
  137. else if (foldStyle != "all")
  138. range = null;
  139. }
  140. return range;
  141. }
  142. if (foldStyle === "markbegin")
  143. return;
  144. var match = line.match(this.foldingStopMarker);
  145. if (match) {
  146. var i = match.index + match[0].length;
  147. if (match[1])
  148. return this.closingBracketBlock(session, match[1], row, i);
  149. return session.getCommentFoldRange(row, i, -1);
  150. }
  151. };
  152. this.getSectionRange = function (session, row) {
  153. var line = session.getLine(row);
  154. var startIndent = line.search(/\S/);
  155. var startRow = row;
  156. var startColumn = line.length;
  157. row = row + 1;
  158. var endRow = row;
  159. var maxRow = session.getLength();
  160. while (++row < maxRow) {
  161. line = session.getLine(row);
  162. var indent = line.search(/\S/);
  163. if (indent === -1)
  164. continue;
  165. if (startIndent > indent)
  166. break;
  167. var subRange = this.getFoldWidgetRange(session, "all", row);
  168. if (subRange) {
  169. if (subRange.start.row <= startRow) {
  170. break;
  171. }
  172. else if (subRange.isMultiLine()) {
  173. row = subRange.end.row;
  174. }
  175. else if (startIndent == indent) {
  176. break;
  177. }
  178. }
  179. endRow = row;
  180. }
  181. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  182. };
  183. this.getCommentRegionBlock = function (session, line, row) {
  184. var startColumn = line.search(/\s*$/);
  185. var maxRow = session.getLength();
  186. var startRow = row;
  187. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  188. var depth = 1;
  189. while (++row < maxRow) {
  190. line = session.getLine(row);
  191. var m = re.exec(line);
  192. if (!m)
  193. continue;
  194. if (m[1])
  195. depth--;
  196. else
  197. depth++;
  198. if (!depth)
  199. break;
  200. }
  201. var endRow = row;
  202. if (endRow > startRow) {
  203. return new Range(startRow, startColumn, endRow, line.length);
  204. }
  205. };
  206. }).call(FoldMode.prototype);
  207. });
  208. ace.define("ace/mode/abc",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/abc_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){/*
  209. THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
  210. */
  211. "use strict";
  212. var oop = require("../lib/oop");
  213. var TextMode = require("./text").Mode;
  214. var ABCHighlightRules = require("./abc_highlight_rules").ABCHighlightRules;
  215. var FoldMode = require("./folding/cstyle").FoldMode;
  216. var Mode = function () {
  217. this.HighlightRules = ABCHighlightRules;
  218. this.foldingRules = new FoldMode();
  219. this.$behaviour = this.$defaultBehaviour;
  220. };
  221. oop.inherits(Mode, TextMode);
  222. (function () {
  223. this.lineCommentStart = "%";
  224. this.$id = "ace/mode/abc";
  225. this.snippetFileId = "ace/snippets/abc";
  226. }).call(Mode.prototype);
  227. exports.Mode = Mode;
  228. }); (function() {
  229. ace.require(["ace/mode/abc"], function(m) {
  230. if (typeof module == "object" && typeof exports == "object" && module) {
  231. module.exports = m;
  232. }
  233. });
  234. })();