mode-scss.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. ace.define("ace/mode/scss_highlight_rules",[], function(require, exports, module) {
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var lang = require("../lib/lang");
  5. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  6. var ScssHighlightRules = function() {
  7. var properties = lang.arrayToMap( (function () {
  8. var browserPrefix = ("-webkit-|-moz-|-o-|-ms-|-svg-|-pie-|-khtml-").split("|");
  9. var prefixProperties = ("appearance|background-clip|background-inline-policy|background-origin|" +
  10. "background-size|binding|border-bottom-colors|border-left-colors|" +
  11. "border-right-colors|border-top-colors|border-end|border-end-color|" +
  12. "border-end-style|border-end-width|border-image|border-start|" +
  13. "border-start-color|border-start-style|border-start-width|box-align|" +
  14. "box-direction|box-flex|box-flexgroup|box-ordinal-group|box-orient|" +
  15. "box-pack|box-sizing|column-count|column-gap|column-width|column-rule|" +
  16. "column-rule-width|column-rule-style|column-rule-color|float-edge|" +
  17. "font-feature-settings|font-language-override|force-broken-image-icon|" +
  18. "image-region|margin-end|margin-start|opacity|outline|outline-color|" +
  19. "outline-offset|outline-radius|outline-radius-bottomleft|" +
  20. "outline-radius-bottomright|outline-radius-topleft|outline-radius-topright|" +
  21. "outline-style|outline-width|padding-end|padding-start|stack-sizing|" +
  22. "tab-size|text-blink|text-decoration-color|text-decoration-line|" +
  23. "text-decoration-style|transform|transform-origin|transition|" +
  24. "transition-delay|transition-duration|transition-property|" +
  25. "transition-timing-function|user-focus|user-input|user-modify|user-select|" +
  26. "window-shadow|border-radius").split("|");
  27. var properties = ("azimuth|background-attachment|background-color|background-image|" +
  28. "background-position|background-repeat|background|border-bottom-color|" +
  29. "border-bottom-style|border-bottom-width|border-bottom|border-collapse|" +
  30. "border-color|border-left-color|border-left-style|border-left-width|" +
  31. "border-left|border-right-color|border-right-style|border-right-width|" +
  32. "border-right|border-spacing|border-style|border-top-color|" +
  33. "border-top-style|border-top-width|border-top|border-width|border|bottom|" +
  34. "box-shadow|box-sizing|caption-side|clear|clip|color|content|counter-increment|" +
  35. "counter-reset|cue-after|cue-before|cue|cursor|direction|display|" +
  36. "elevation|empty-cells|float|font-family|font-size-adjust|font-size|" +
  37. "font-stretch|font-style|font-variant|font-weight|font|height|left|" +
  38. "letter-spacing|line-height|list-style-image|list-style-position|" +
  39. "list-style-type|list-style|margin-bottom|margin-left|margin-right|" +
  40. "margin-top|marker-offset|margin|marks|max-height|max-width|min-height|" +
  41. "min-width|opacity|orphans|outline-color|" +
  42. "outline-style|outline-width|outline|overflow|overflow-x|overflow-y|padding-bottom|" +
  43. "padding-left|padding-right|padding-top|padding|page-break-after|" +
  44. "page-break-before|page-break-inside|page|pause-after|pause-before|" +
  45. "pause|pitch-range|pitch|play-during|position|quotes|richness|right|" +
  46. "size|speak-header|speak-numeral|speak-punctuation|speech-rate|speak|" +
  47. "stress|table-layout|text-align|text-decoration|text-indent|" +
  48. "text-shadow|text-transform|top|unicode-bidi|vertical-align|" +
  49. "visibility|voice-family|volume|white-space|widows|width|word-spacing|" +
  50. "z-index").split("|");
  51. var ret = [];
  52. for (var i=0, ln=browserPrefix.length; i<ln; i++) {
  53. Array.prototype.push.apply(
  54. ret,
  55. (( browserPrefix[i] + prefixProperties.join("|" + browserPrefix[i]) ).split("|"))
  56. );
  57. }
  58. Array.prototype.push.apply(ret, prefixProperties);
  59. Array.prototype.push.apply(ret, properties);
  60. return ret;
  61. })() );
  62. var functions = lang.arrayToMap(
  63. ("hsl|hsla|rgb|rgba|url|attr|counter|counters|abs|adjust_color|adjust_hue|" +
  64. "alpha|join|blue|ceil|change_color|comparable|complement|darken|desaturate|" +
  65. "floor|grayscale|green|hue|if|invert|join|length|lighten|lightness|mix|" +
  66. "nth|opacify|opacity|percentage|quote|red|round|saturate|saturation|" +
  67. "scale_color|transparentize|type_of|unit|unitless|unquote").split("|")
  68. );
  69. var constants = lang.arrayToMap(
  70. ("absolute|all-scroll|always|armenian|auto|baseline|below|bidi-override|" +
  71. "block|bold|bolder|border-box|both|bottom|break-all|break-word|capitalize|center|" +
  72. "char|circle|cjk-ideographic|col-resize|collapse|content-box|crosshair|dashed|" +
  73. "decimal-leading-zero|decimal|default|disabled|disc|" +
  74. "distribute-all-lines|distribute-letter|distribute-space|" +
  75. "distribute|dotted|double|e-resize|ellipsis|fixed|georgian|groove|" +
  76. "hand|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|" +
  77. "ideograph-alpha|ideograph-numeric|ideograph-parenthesis|" +
  78. "ideograph-space|inactive|inherit|inline-block|inline|inset|inside|" +
  79. "inter-ideograph|inter-word|italic|justify|katakana-iroha|katakana|" +
  80. "keep-all|left|lighter|line-edge|line-through|line|list-item|loose|" +
  81. "lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|" +
  82. "medium|middle|move|n-resize|ne-resize|newspaper|no-drop|no-repeat|" +
  83. "nw-resize|none|normal|not-allowed|nowrap|oblique|outset|outside|" +
  84. "overline|pointer|progress|relative|repeat-x|repeat-y|repeat|right|" +
  85. "ridge|row-resize|rtl|s-resize|scroll|se-resize|separate|small-caps|" +
  86. "solid|square|static|strict|super|sw-resize|table-footer-group|" +
  87. "table-header-group|tb-rl|text-bottom|text-top|text|thick|thin|top|" +
  88. "transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|" +
  89. "vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|" +
  90. "zero").split("|")
  91. );
  92. var colors = lang.arrayToMap(
  93. ("aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|" +
  94. "blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|" +
  95. "chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|" +
  96. "darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|" +
  97. "darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|" +
  98. "darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|" +
  99. "darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|" +
  100. "dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|" +
  101. "ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|" +
  102. "hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|" +
  103. "lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|" +
  104. "lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|" +
  105. "lightsalmon|lightseagreen|lightskyblue|lightslategray|" +
  106. "lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|" +
  107. "magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|" +
  108. "mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|" +
  109. "mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|" +
  110. "moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|" +
  111. "orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|" +
  112. "papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|" +
  113. "red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|" +
  114. "seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|" +
  115. "springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|" +
  116. "wheat|white|whitesmoke|yellow|yellowgreen").split("|")
  117. );
  118. var keywords = lang.arrayToMap(
  119. ("@mixin|@extend|@include|@import|@media|@debug|@warn|@if|@for|@each|@while|@else|@font-face|@-webkit-keyframes|if|and|!default|module|def|end|declare").split("|")
  120. );
  121. var tags = lang.arrayToMap(
  122. ("a|abbr|acronym|address|applet|area|article|aside|audio|b|base|basefont|bdo|" +
  123. "big|blockquote|body|br|button|canvas|caption|center|cite|code|col|colgroup|" +
  124. "command|datalist|dd|del|details|dfn|dir|div|dl|dt|em|embed|fieldset|" +
  125. "figcaption|figure|font|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|" +
  126. "header|hgroup|hr|html|i|iframe|img|input|ins|keygen|kbd|label|legend|li|" +
  127. "link|map|mark|menu|meta|meter|nav|noframes|noscript|object|ol|optgroup|" +
  128. "option|output|p|param|pre|progress|q|rp|rt|ruby|s|samp|script|section|select|" +
  129. "small|source|span|strike|strong|style|sub|summary|sup|table|tbody|td|" +
  130. "textarea|tfoot|th|thead|time|title|tr|tt|u|ul|var|video|wbr|xmp").split("|")
  131. );
  132. var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
  133. this.$rules = {
  134. "start" : [
  135. {
  136. token : "comment",
  137. regex : "\\/\\/.*$"
  138. },
  139. {
  140. token : "comment", // multi line comment
  141. regex : "\\/\\*",
  142. next : "comment"
  143. }, {
  144. token : "string", // single line
  145. regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  146. }, {
  147. token : "string", // multi line string start
  148. regex : '["].*\\\\$',
  149. next : "qqstring"
  150. }, {
  151. token : "string", // single line
  152. regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  153. }, {
  154. token : "string", // multi line string start
  155. regex : "['].*\\\\$",
  156. next : "qstring"
  157. }, {
  158. token : "constant.numeric",
  159. regex : numRe + "(?:em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)"
  160. }, {
  161. token : "constant.numeric", // hex6 color
  162. regex : "#[a-f0-9]{6}"
  163. }, {
  164. token : "constant.numeric", // hex3 color
  165. regex : "#[a-f0-9]{3}"
  166. }, {
  167. token : "constant.numeric",
  168. regex : numRe
  169. }, {
  170. token : ["support.function", "string", "support.function"],
  171. regex : "(url\\()(.*)(\\))"
  172. }, {
  173. token : function(value) {
  174. if (properties.hasOwnProperty(value.toLowerCase()))
  175. return "support.type";
  176. if (keywords.hasOwnProperty(value))
  177. return "keyword";
  178. else if (constants.hasOwnProperty(value))
  179. return "constant.language";
  180. else if (functions.hasOwnProperty(value))
  181. return "support.function";
  182. else if (colors.hasOwnProperty(value.toLowerCase()))
  183. return "support.constant.color";
  184. else if (tags.hasOwnProperty(value.toLowerCase()))
  185. return "variable.language";
  186. else
  187. return "text";
  188. },
  189. regex : "\\-?[@a-z_][@a-z0-9_\\-]*"
  190. }, {
  191. token : "variable",
  192. regex : "[a-z_\\-$][a-z0-9_\\-$]*\\b"
  193. }, {
  194. token: "variable.language",
  195. regex: "#[a-z0-9-_]+"
  196. }, {
  197. token: "variable.language",
  198. regex: "\\.[a-z0-9-_]+"
  199. }, {
  200. token: "variable.language",
  201. regex: ":[a-z0-9-_]+"
  202. }, {
  203. token: "constant",
  204. regex: "[a-z0-9-_]+"
  205. }, {
  206. token : "keyword.operator",
  207. regex : "<|>|<=|>=|==|!=|-|%|#|\\+|\\$|\\+|\\*"
  208. }, {
  209. token : "paren.lparen",
  210. regex : "[[({]"
  211. }, {
  212. token : "paren.rparen",
  213. regex : "[\\])}]"
  214. }, {
  215. token : "text",
  216. regex : "\\s+"
  217. }, {
  218. caseInsensitive: true
  219. }
  220. ],
  221. "comment" : [
  222. {
  223. token : "comment", // closing comment
  224. regex : "\\*\\/",
  225. next : "start"
  226. }, {
  227. defaultToken : "comment"
  228. }
  229. ],
  230. "qqstring" : [
  231. {
  232. token : "string",
  233. regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
  234. next : "start"
  235. }, {
  236. token : "string",
  237. regex : '.+'
  238. }
  239. ],
  240. "qstring" : [
  241. {
  242. token : "string",
  243. regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
  244. next : "start"
  245. }, {
  246. token : "string",
  247. regex : '.+'
  248. }
  249. ]
  250. };
  251. };
  252. oop.inherits(ScssHighlightRules, TextHighlightRules);
  253. exports.ScssHighlightRules = ScssHighlightRules;
  254. });
  255. ace.define("ace/mode/matching_brace_outdent",[], function(require, exports, module) {
  256. "use strict";
  257. var Range = require("../range").Range;
  258. var MatchingBraceOutdent = function() {};
  259. (function() {
  260. this.checkOutdent = function(line, input) {
  261. if (! /^\s+$/.test(line))
  262. return false;
  263. return /^\s*\}/.test(input);
  264. };
  265. this.autoOutdent = function(doc, row) {
  266. var line = doc.getLine(row);
  267. var match = line.match(/^(\s*\})/);
  268. if (!match) return 0;
  269. var column = match[1].length;
  270. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  271. if (!openBracePos || openBracePos.row == row) return 0;
  272. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  273. doc.replace(new Range(row, 0, row, column-1), indent);
  274. };
  275. this.$getIndent = function(line) {
  276. return line.match(/^\s*/)[0];
  277. };
  278. }).call(MatchingBraceOutdent.prototype);
  279. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  280. });
  281. ace.define("ace/mode/behaviour/css",[], function(require, exports, module) {
  282. "use strict";
  283. var oop = require("../../lib/oop");
  284. var Behaviour = require("../behaviour").Behaviour;
  285. var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
  286. var TokenIterator = require("../../token_iterator").TokenIterator;
  287. var CssBehaviour = function () {
  288. this.inherit(CstyleBehaviour);
  289. this.add("colon", "insertion", function (state, action, editor, session, text) {
  290. if (text === ':' && editor.selection.isEmpty()) {
  291. var cursor = editor.getCursorPosition();
  292. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  293. var token = iterator.getCurrentToken();
  294. if (token && token.value.match(/\s+/)) {
  295. token = iterator.stepBackward();
  296. }
  297. if (token && token.type === 'support.type') {
  298. var line = session.doc.getLine(cursor.row);
  299. var rightChar = line.substring(cursor.column, cursor.column + 1);
  300. if (rightChar === ':') {
  301. return {
  302. text: '',
  303. selection: [1, 1]
  304. };
  305. }
  306. if (/^(\s+[^;]|\s*$)/.test(line.substring(cursor.column))) {
  307. return {
  308. text: ':;',
  309. selection: [1, 1]
  310. };
  311. }
  312. }
  313. }
  314. });
  315. this.add("colon", "deletion", function (state, action, editor, session, range) {
  316. var selected = session.doc.getTextRange(range);
  317. if (!range.isMultiLine() && selected === ':') {
  318. var cursor = editor.getCursorPosition();
  319. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  320. var token = iterator.getCurrentToken();
  321. if (token && token.value.match(/\s+/)) {
  322. token = iterator.stepBackward();
  323. }
  324. if (token && token.type === 'support.type') {
  325. var line = session.doc.getLine(range.start.row);
  326. var rightChar = line.substring(range.end.column, range.end.column + 1);
  327. if (rightChar === ';') {
  328. range.end.column ++;
  329. return range;
  330. }
  331. }
  332. }
  333. });
  334. this.add("semicolon", "insertion", function (state, action, editor, session, text) {
  335. if (text === ';' && editor.selection.isEmpty()) {
  336. var cursor = editor.getCursorPosition();
  337. var line = session.doc.getLine(cursor.row);
  338. var rightChar = line.substring(cursor.column, cursor.column + 1);
  339. if (rightChar === ';') {
  340. return {
  341. text: '',
  342. selection: [1, 1]
  343. };
  344. }
  345. }
  346. });
  347. this.add("!important", "insertion", function (state, action, editor, session, text) {
  348. if (text === '!' && editor.selection.isEmpty()) {
  349. var cursor = editor.getCursorPosition();
  350. var line = session.doc.getLine(cursor.row);
  351. if (/^\s*(;|}|$)/.test(line.substring(cursor.column))) {
  352. return {
  353. text: '!important',
  354. selection: [10, 10]
  355. };
  356. }
  357. }
  358. });
  359. };
  360. oop.inherits(CssBehaviour, CstyleBehaviour);
  361. exports.CssBehaviour = CssBehaviour;
  362. });
  363. ace.define("ace/mode/folding/cstyle",[], function(require, exports, module) {
  364. "use strict";
  365. var oop = require("../../lib/oop");
  366. var Range = require("../../range").Range;
  367. var BaseFoldMode = require("./fold_mode").FoldMode;
  368. var FoldMode = exports.FoldMode = function(commentRegex) {
  369. if (commentRegex) {
  370. this.foldingStartMarker = new RegExp(
  371. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  372. );
  373. this.foldingStopMarker = new RegExp(
  374. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  375. );
  376. }
  377. };
  378. oop.inherits(FoldMode, BaseFoldMode);
  379. (function() {
  380. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  381. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  382. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  383. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  384. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  385. this._getFoldWidgetBase = this.getFoldWidget;
  386. this.getFoldWidget = function(session, foldStyle, row) {
  387. var line = session.getLine(row);
  388. if (this.singleLineBlockCommentRe.test(line)) {
  389. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  390. return "";
  391. }
  392. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  393. if (!fw && this.startRegionRe.test(line))
  394. return "start"; // lineCommentRegionStart
  395. return fw;
  396. };
  397. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  398. var line = session.getLine(row);
  399. if (this.startRegionRe.test(line))
  400. return this.getCommentRegionBlock(session, line, row);
  401. var match = line.match(this.foldingStartMarker);
  402. if (match) {
  403. var i = match.index;
  404. if (match[1])
  405. return this.openingBracketBlock(session, match[1], row, i);
  406. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  407. if (range && !range.isMultiLine()) {
  408. if (forceMultiline) {
  409. range = this.getSectionRange(session, row);
  410. } else if (foldStyle != "all")
  411. range = null;
  412. }
  413. return range;
  414. }
  415. if (foldStyle === "markbegin")
  416. return;
  417. var match = line.match(this.foldingStopMarker);
  418. if (match) {
  419. var i = match.index + match[0].length;
  420. if (match[1])
  421. return this.closingBracketBlock(session, match[1], row, i);
  422. return session.getCommentFoldRange(row, i, -1);
  423. }
  424. };
  425. this.getSectionRange = function(session, row) {
  426. var line = session.getLine(row);
  427. var startIndent = line.search(/\S/);
  428. var startRow = row;
  429. var startColumn = line.length;
  430. row = row + 1;
  431. var endRow = row;
  432. var maxRow = session.getLength();
  433. while (++row < maxRow) {
  434. line = session.getLine(row);
  435. var indent = line.search(/\S/);
  436. if (indent === -1)
  437. continue;
  438. if (startIndent > indent)
  439. break;
  440. var subRange = this.getFoldWidgetRange(session, "all", row);
  441. if (subRange) {
  442. if (subRange.start.row <= startRow) {
  443. break;
  444. } else if (subRange.isMultiLine()) {
  445. row = subRange.end.row;
  446. } else if (startIndent == indent) {
  447. break;
  448. }
  449. }
  450. endRow = row;
  451. }
  452. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  453. };
  454. this.getCommentRegionBlock = function(session, line, row) {
  455. var startColumn = line.search(/\s*$/);
  456. var maxRow = session.getLength();
  457. var startRow = row;
  458. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  459. var depth = 1;
  460. while (++row < maxRow) {
  461. line = session.getLine(row);
  462. var m = re.exec(line);
  463. if (!m) continue;
  464. if (m[1]) depth--;
  465. else depth++;
  466. if (!depth) break;
  467. }
  468. var endRow = row;
  469. if (endRow > startRow) {
  470. return new Range(startRow, startColumn, endRow, line.length);
  471. }
  472. };
  473. }).call(FoldMode.prototype);
  474. });
  475. ace.define("ace/mode/scss",[], function(require, exports, module) {
  476. "use strict";
  477. var oop = require("../lib/oop");
  478. var TextMode = require("./text").Mode;
  479. var ScssHighlightRules = require("./scss_highlight_rules").ScssHighlightRules;
  480. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  481. var CssBehaviour = require("./behaviour/css").CssBehaviour;
  482. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  483. var Mode = function() {
  484. this.HighlightRules = ScssHighlightRules;
  485. this.$outdent = new MatchingBraceOutdent();
  486. this.$behaviour = new CssBehaviour();
  487. this.foldingRules = new CStyleFoldMode();
  488. };
  489. oop.inherits(Mode, TextMode);
  490. (function() {
  491. this.lineCommentStart = "//";
  492. this.blockComment = {start: "/*", end: "*/"};
  493. this.getNextLineIndent = function(state, line, tab) {
  494. var indent = this.$getIndent(line);
  495. var tokens = this.getTokenizer().getLineTokens(line, state).tokens;
  496. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  497. return indent;
  498. }
  499. var match = line.match(/^.*\{\s*$/);
  500. if (match) {
  501. indent += tab;
  502. }
  503. return indent;
  504. };
  505. this.checkOutdent = function(state, line, input) {
  506. return this.$outdent.checkOutdent(line, input);
  507. };
  508. this.autoOutdent = function(state, doc, row) {
  509. this.$outdent.autoOutdent(doc, row);
  510. };
  511. this.$id = "ace/mode/scss";
  512. }).call(Mode.prototype);
  513. exports.Mode = Mode;
  514. });
  515. (function() {
  516. ace.require(["ace/mode/scss"], function(m) {
  517. if (typeof module == "object" && typeof exports == "object" && module) {
  518. module.exports = m;
  519. }
  520. });
  521. })();