PageRenderTime 165ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/files/ace/1.1.5/noconflict/mode-dot.js

https://gitlab.com/Mirros/jsdelivr
JavaScript | 361 lines | 323 code | 38 blank | 0 comment | 11 complexity | 89c4e5a8abab8becd27b339952a954d6 MD5 | raw file
  1. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
  2. "use strict";
  3. var Range = require("../range").Range;
  4. var MatchingBraceOutdent = function() {};
  5. (function() {
  6. this.checkOutdent = function(line, input) {
  7. if (! /^\s+$/.test(line))
  8. return false;
  9. return /^\s*\}/.test(input);
  10. };
  11. this.autoOutdent = function(doc, row) {
  12. var line = doc.getLine(row);
  13. var match = line.match(/^(\s*\})/);
  14. if (!match) return 0;
  15. var column = match[1].length;
  16. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  17. if (!openBracePos || openBracePos.row == row) return 0;
  18. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  19. doc.replace(new Range(row, 0, row, column-1), indent);
  20. };
  21. this.$getIndent = function(line) {
  22. return line.match(/^\s*/)[0];
  23. };
  24. }).call(MatchingBraceOutdent.prototype);
  25. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  26. });
  27. ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
  28. "use strict";
  29. var oop = require("../lib/oop");
  30. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  31. var DocCommentHighlightRules = function() {
  32. this.$rules = {
  33. "start" : [ {
  34. token : "comment.doc.tag",
  35. regex : "@[\\w\\d_]+" // TODO: fix email addresses
  36. }, {
  37. token : "comment.doc.tag",
  38. regex : "\\bTODO\\b"
  39. }, {
  40. defaultToken : "comment.doc"
  41. }]
  42. };
  43. };
  44. oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  45. DocCommentHighlightRules.getStartRule = function(start) {
  46. return {
  47. token : "comment.doc", // doc comment
  48. regex : "\\/\\*(?=\\*)",
  49. next : start
  50. };
  51. };
  52. DocCommentHighlightRules.getEndRule = function (start) {
  53. return {
  54. token : "comment.doc", // closing comment
  55. regex : "\\*\\/",
  56. next : start
  57. };
  58. };
  59. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  60. });
  61. ace.define("ace/mode/dot_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules","ace/mode/doc_comment_highlight_rules"], function(require, exports, module) {
  62. "use strict";
  63. var oop = require("../lib/oop");
  64. var lang = require("../lib/lang");
  65. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  66. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  67. var DotHighlightRules = function() {
  68. var keywords = lang.arrayToMap(
  69. ("strict|node|edge|graph|digraph|subgraph").split("|")
  70. );
  71. var attributes = lang.arrayToMap(
  72. ("damping|k|url|area|arrowhead|arrowsize|arrowtail|aspect|bb|bgcolor|center|charset|clusterrank|color|colorscheme|comment|compound|concentrate|constraint|decorate|defaultdist|dim|dimen|dir|diredgeconstraints|distortion|dpi|edgeurl|edgehref|edgetarget|edgetooltip|epsilon|esep|fillcolor|fixedsize|fontcolor|fontname|fontnames|fontpath|fontsize|forcelabels|gradientangle|group|headurl|head_lp|headclip|headhref|headlabel|headport|headtarget|headtooltip|height|href|id|image|imagepath|imagescale|label|labelurl|label_scheme|labelangle|labeldistance|labelfloat|labelfontcolor|labelfontname|labelfontsize|labelhref|labeljust|labelloc|labeltarget|labeltooltip|landscape|layer|layerlistsep|layers|layerselect|layersep|layout|len|levels|levelsgap|lhead|lheight|lp|ltail|lwidth|margin|maxiter|mclimit|mindist|minlen|mode|model|mosek|nodesep|nojustify|normalize|nslimit|nslimit1|ordering|orientation|outputorder|overlap|overlap_scaling|pack|packmode|pad|page|pagedir|pencolor|penwidth|peripheries|pin|pos|quadtree|quantum|rank|rankdir|ranksep|ratio|rects|regular|remincross|repulsiveforce|resolution|root|rotate|rotation|samehead|sametail|samplepoints|scale|searchsize|sep|shape|shapefile|showboxes|sides|size|skew|smoothing|sortv|splines|start|style|stylesheet|tailurl|tail_lp|tailclip|tailhref|taillabel|tailport|tailtarget|tailtooltip|target|tooltip|truecolor|vertices|viewport|voro_margin|weight|width|xlabel|xlp|z").split("|")
  73. );
  74. this.$rules = {
  75. "start" : [
  76. {
  77. token : "comment",
  78. regex : /\/\/.*$/
  79. }, {
  80. token : "comment",
  81. regex : /#.*$/
  82. }, {
  83. token : "comment", // multi line comment
  84. merge : true,
  85. regex : /\/\*/,
  86. next : "comment"
  87. }, {
  88. token : "string",
  89. regex : "'(?=.)",
  90. next : "qstring"
  91. }, {
  92. token : "string",
  93. regex : '"(?=.)',
  94. next : "qqstring"
  95. }, {
  96. token : "constant.numeric",
  97. regex : /[+\-]?\d+(?:(?:\.\d*)?(?:[eE][+\-]?\d+)?)?\b/
  98. }, {
  99. token : "keyword.operator",
  100. regex : /\+|=|\->/
  101. }, {
  102. token : "punctuation.operator",
  103. regex : /,|;/
  104. }, {
  105. token : "paren.lparen",
  106. regex : /[\[{]/
  107. }, {
  108. token : "paren.rparen",
  109. regex : /[\]}]/
  110. }, {
  111. token: "comment",
  112. regex: /^#!.*$/
  113. }, {
  114. token: function(value) {
  115. if (keywords.hasOwnProperty(value.toLowerCase())) {
  116. return "keyword";
  117. }
  118. else if (attributes.hasOwnProperty(value.toLowerCase())) {
  119. return "variable";
  120. }
  121. else {
  122. return "text";
  123. }
  124. },
  125. regex: "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
  126. }
  127. ],
  128. "comment" : [
  129. {
  130. token : "comment", // closing comment
  131. regex : ".*?\\*\\/",
  132. merge : true,
  133. next : "start"
  134. }, {
  135. token : "comment", // comment spanning whole line
  136. merge : true,
  137. regex : ".+"
  138. }
  139. ],
  140. "qqstring" : [
  141. {
  142. token : "string",
  143. regex : '[^"\\\\]+',
  144. merge : true
  145. }, {
  146. token : "string",
  147. regex : "\\\\$",
  148. next : "qqstring",
  149. merge : true
  150. }, {
  151. token : "string",
  152. regex : '"|$',
  153. next : "start",
  154. merge : true
  155. }
  156. ],
  157. "qstring" : [
  158. {
  159. token : "string",
  160. regex : "[^'\\\\]+",
  161. merge : true
  162. }, {
  163. token : "string",
  164. regex : "\\\\$",
  165. next : "qstring",
  166. merge : true
  167. }, {
  168. token : "string",
  169. regex : "'|$",
  170. next : "start",
  171. merge : true
  172. }
  173. ]
  174. };
  175. };
  176. oop.inherits(DotHighlightRules, TextHighlightRules);
  177. exports.DotHighlightRules = DotHighlightRules;
  178. });
  179. ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
  180. "use strict";
  181. var oop = require("../../lib/oop");
  182. var Range = require("../../range").Range;
  183. var BaseFoldMode = require("./fold_mode").FoldMode;
  184. var FoldMode = exports.FoldMode = function(commentRegex) {
  185. if (commentRegex) {
  186. this.foldingStartMarker = new RegExp(
  187. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  188. );
  189. this.foldingStopMarker = new RegExp(
  190. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  191. );
  192. }
  193. };
  194. oop.inherits(FoldMode, BaseFoldMode);
  195. (function() {
  196. this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
  197. this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
  198. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  199. var line = session.getLine(row);
  200. var match = line.match(this.foldingStartMarker);
  201. if (match) {
  202. var i = match.index;
  203. if (match[1])
  204. return this.openingBracketBlock(session, match[1], row, i);
  205. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  206. if (range && !range.isMultiLine()) {
  207. if (forceMultiline) {
  208. range = this.getSectionRange(session, row);
  209. } else if (foldStyle != "all")
  210. range = null;
  211. }
  212. return range;
  213. }
  214. if (foldStyle === "markbegin")
  215. return;
  216. var match = line.match(this.foldingStopMarker);
  217. if (match) {
  218. var i = match.index + match[0].length;
  219. if (match[1])
  220. return this.closingBracketBlock(session, match[1], row, i);
  221. return session.getCommentFoldRange(row, i, -1);
  222. }
  223. };
  224. this.getSectionRange = function(session, row) {
  225. var line = session.getLine(row);
  226. var startIndent = line.search(/\S/);
  227. var startRow = row;
  228. var startColumn = line.length;
  229. row = row + 1;
  230. var endRow = row;
  231. var maxRow = session.getLength();
  232. while (++row < maxRow) {
  233. line = session.getLine(row);
  234. var indent = line.search(/\S/);
  235. if (indent === -1)
  236. continue;
  237. if (startIndent > indent)
  238. break;
  239. var subRange = this.getFoldWidgetRange(session, "all", row);
  240. if (subRange) {
  241. if (subRange.start.row <= startRow) {
  242. break;
  243. } else if (subRange.isMultiLine()) {
  244. row = subRange.end.row;
  245. } else if (startIndent == indent) {
  246. break;
  247. }
  248. }
  249. endRow = row;
  250. }
  251. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  252. };
  253. }).call(FoldMode.prototype);
  254. });
  255. ace.define("ace/mode/dot",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/matching_brace_outdent","ace/mode/dot_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module) {
  256. "use strict";
  257. var oop = require("../lib/oop");
  258. var TextMode = require("./text").Mode;
  259. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  260. var DotHighlightRules = require("./dot_highlight_rules").DotHighlightRules;
  261. var DotFoldMode = require("./folding/cstyle").FoldMode;
  262. var Mode = function() {
  263. this.HighlightRules = DotHighlightRules;
  264. this.$outdent = new MatchingBraceOutdent();
  265. this.foldingRules = new DotFoldMode();
  266. };
  267. oop.inherits(Mode, TextMode);
  268. (function() {
  269. this.lineCommentStart = ["//", "#"];
  270. this.blockComment = {start: "/*", end: "*/"};
  271. this.getNextLineIndent = function(state, line, tab) {
  272. var indent = this.$getIndent(line);
  273. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  274. var tokens = tokenizedLine.tokens;
  275. var endState = tokenizedLine.state;
  276. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  277. return indent;
  278. }
  279. if (state == "start") {
  280. var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
  281. if (match) {
  282. indent += tab;
  283. }
  284. }
  285. return indent;
  286. };
  287. this.checkOutdent = function(state, line, input) {
  288. return this.$outdent.checkOutdent(line, input);
  289. };
  290. this.autoOutdent = function(state, doc, row) {
  291. this.$outdent.autoOutdent(doc, row);
  292. };
  293. this.$id = "ace/mode/dot";
  294. }).call(Mode.prototype);
  295. exports.Mode = Mode;
  296. });