Created
April 18, 2018 22:11
-
-
Save komali2/4bb2ac77e3456cc9bb212d07f613094f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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