Skip to content

Instantly share code, notes, and snippets.

@komali2
Created April 18, 2018 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save komali2/4bb2ac77e3456cc9bb212d07f613094f to your computer and use it in GitHub Desktop.
Save komali2/4bb2ac77e3456cc9bb212d07f613094f to your computer and use it in GitHub Desktop.
define(function(require, exports, module) {
"use strict";
require('brace')
var oop = acequire("ace/lib/oop");
// defines the parent mode
var TextMode = acequire("ace/mode/text").Mode;
var CStyleFoldMode = acequire("ace/mode/folding/cstyle").FoldMode;
var CstyleBehaviour = acequire("ace/mode/behaviour/cstyle").CstyleBehaviour;
var MatchingBraceOutdent = acequire("ace/mode/matching_brace_outdent").MatchingBraceOutdent;
// defines the language specific highlighters and folding rules
var ElectricImpHighlightRules = require("@/lib/ace/mode/thing_hightlight_rules").ThingHighlightRules;
var Mode = function() {
this.HighlightRules = ThingHightlightRules;
this.$outdent = new MatchingBraceOutdent();
this.$behaviour = new CstyleBehaviour();
this.foldingRules = new CStyleFoldMode();
};
oop.inherits(Mode, TextMode);
(function() {
this.lineCommentStart = "//";
this.blockComment = {start: "/*", end: "*/"};
this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line);
var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
var tokens = tokenizedLine.tokens;
var endState = tokenizedLine.state;
var match;
if (tokens.length && tokens[tokens.length-1].type == "comment") {
return indent;
}
if (state == "start" || state == "no_regex") {
match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
if (match) {
indent += tab;
}
} else if (state == "doc-start") {
if (endState == "start" || endState == "no_regex") {
return "";
}
match = line.match(/^\s*(\/?)\*/);
if (match) {
if (match[1]) {
indent += " ";
}
indent += "* ";
}
}
return indent;
};
this.checkOutdent = function(state, line, input) {
return this.$outdent.checkOutdent(line, input);
};
this.autoOutdent = function(state, doc, row) {
this.$outdent.autoOutdent(doc, row);
};
this.$id = "lib/ace/mode/thing";
}).call(Mode.prototype);
exports.Mode = Mode;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment