use general toggleCommentLines for all modes
This commit is contained in:
parent
528a103149
commit
e71fd47153
42 changed files with 321 additions and 680 deletions
|
|
@ -50,33 +50,8 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
this.lineCommentStart = "//";
|
||||||
var outdent = true;
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
var re = /^(\s*)\/\//;
|
|
||||||
|
|
||||||
for (var i=startRow; i<= endRow; i++) {
|
|
||||||
if (!re.test(doc.getLine(i))) {
|
|
||||||
outdent = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outdent) {
|
|
||||||
var deleteRange = new Range(0, 0, 0, 0);
|
|
||||||
for (var i=startRow; i<= endRow; i++)
|
|
||||||
{
|
|
||||||
var line = doc.getLine(i);
|
|
||||||
var m = line.match(re);
|
|
||||||
deleteRange.start.row = i;
|
|
||||||
deleteRange.end.row = i;
|
|
||||||
deleteRange.end.column = m[0].length;
|
|
||||||
doc.replace(deleteRange, m[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
doc.indentRows(startRow, endRow, "//");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
|
||||||
|
|
@ -46,33 +46,7 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
this.lineCommentStart = ";";
|
||||||
var outdent = true;
|
|
||||||
var re = /^(\s*)#/;
|
|
||||||
|
|
||||||
for (var i=startRow; i<= endRow; i++) {
|
|
||||||
if (!re.test(doc.getLine(i))) {
|
|
||||||
outdent = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outdent) {
|
|
||||||
var deleteRange = new Range(0, 0, 0, 0);
|
|
||||||
for (var i=startRow; i<= endRow; i++)
|
|
||||||
{
|
|
||||||
var line = doc.getLine(i);
|
|
||||||
var m = line.match(re);
|
|
||||||
deleteRange.start.row = i;
|
|
||||||
deleteRange.end.row = i;
|
|
||||||
deleteRange.end.column = m[0].length;
|
|
||||||
doc.replace(deleteRange, m[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
doc.indentRows(startRow, endRow, ";");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,9 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
this.lineCommentStart = "//";
|
||||||
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ oop.inherits(Mode, TextMode);
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.foldingRules = "cStyle";
|
this.foldingRules = "cStyle";
|
||||||
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,8 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
// Extra logic goes here.
|
// Extra logic goes here.
|
||||||
|
this.lineCommentStart = "//";
|
||||||
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
}).call(Mode.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
exports.Mode = Mode;
|
exports.Mode = Mode;
|
||||||
|
|
|
||||||
|
|
@ -18,33 +18,8 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
this.lineCommentStart = ["//", "#"];
|
||||||
var outdent = true;
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
var re = /^(\s*)\/\//;
|
|
||||||
|
|
||||||
for (var i=startRow; i<= endRow; i++) {
|
|
||||||
if (!re.test(doc.getLine(i))) {
|
|
||||||
outdent = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outdent) {
|
|
||||||
var deleteRange = new Range(0, 0, 0, 0);
|
|
||||||
for (var i=startRow; i<= endRow; i++)
|
|
||||||
{
|
|
||||||
var line = doc.getLine(i);
|
|
||||||
var m = line.match(re);
|
|
||||||
deleteRange.start.row = i;
|
|
||||||
deleteRange.end.row = i;
|
|
||||||
deleteRange.end.column = m[0].length;
|
|
||||||
doc.replace(deleteRange, m[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
doc.indentRows(startRow, endRow, "//");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
|
||||||
|
|
@ -1,80 +1,55 @@
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var oop = require("../lib/oop");
|
var oop = require("../lib/oop");
|
||||||
var TextMode = require("./text").Mode;
|
var TextMode = require("./text").Mode;
|
||||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||||
var GolangHighlightRules = require("./golang_highlight_rules").GolangHighlightRules;
|
var GolangHighlightRules = require("./golang_highlight_rules").GolangHighlightRules;
|
||||||
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
||||||
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
||||||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||||
|
|
||||||
var Mode = function() {
|
var Mode = function() {
|
||||||
this.$tokenizer = new Tokenizer(new GolangHighlightRules().getRules());
|
this.$tokenizer = new Tokenizer(new GolangHighlightRules().getRules());
|
||||||
this.$outdent = new MatchingBraceOutdent();
|
this.$outdent = new MatchingBraceOutdent();
|
||||||
this.foldingRules = new CStyleFoldMode();
|
this.foldingRules = new CStyleFoldMode();
|
||||||
};
|
};
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
this.lineCommentStart = "//";
|
||||||
var outdent = true;
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
var re = /^(\s*)\/\//;
|
|
||||||
|
|
||||||
for (var i=startRow; i<= endRow; i++) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
if (!re.test(doc.getLine(i))) {
|
var indent = this.$getIndent(line);
|
||||||
outdent = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outdent) {
|
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
|
||||||
var deleteRange = new Range(0, 0, 0, 0);
|
var tokens = tokenizedLine.tokens;
|
||||||
for (var i=startRow; i<= endRow; i++)
|
var endState = tokenizedLine.state;
|
||||||
{
|
|
||||||
var line = doc.getLine(i);
|
|
||||||
var m = line.match(re);
|
|
||||||
deleteRange.start.row = i;
|
|
||||||
deleteRange.end.row = i;
|
|
||||||
deleteRange.end.column = m[0].length;
|
|
||||||
doc.replace(deleteRange, m[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
doc.indentRows(startRow, endRow, "//");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
|
||||||
var indent = this.$getIndent(line);
|
|
||||||
|
|
||||||
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
|
|
||||||
var tokens = tokenizedLine.tokens;
|
|
||||||
var endState = tokenizedLine.state;
|
|
||||||
|
|
||||||
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
|
||||||
return indent;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state == "start") {
|
|
||||||
var match = line.match(/^.*[\{\(\[]\s*$/);
|
|
||||||
if (match) {
|
|
||||||
indent += tab;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||||
return indent;
|
return indent;
|
||||||
};//end getNextLineIndent
|
}
|
||||||
|
|
||||||
this.checkOutdent = function(state, line, input) {
|
if (state == "start") {
|
||||||
return this.$outdent.checkOutdent(line, input);
|
var match = line.match(/^.*[\{\(\[]\s*$/);
|
||||||
};
|
if (match) {
|
||||||
|
indent += tab;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.autoOutdent = function(state, doc, row) {
|
return indent;
|
||||||
this.$outdent.autoOutdent(doc, row);
|
};//end getNextLineIndent
|
||||||
};
|
|
||||||
|
|
||||||
}).call(Mode.prototype);
|
this.checkOutdent = function(state, line, input) {
|
||||||
|
return this.$outdent.checkOutdent(line, input);
|
||||||
|
};
|
||||||
|
|
||||||
exports.Mode = Mode;
|
this.autoOutdent = function(state, doc, row) {
|
||||||
|
this.$outdent.autoOutdent(doc, row);
|
||||||
|
};
|
||||||
|
|
||||||
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
|
exports.Mode = Mode;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,8 @@ var Mode = function() {
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
// Extra logic goes here.
|
this.lineCommentStart = ["//", "#"];
|
||||||
|
|
||||||
}).call(Mode.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
exports.Mode = Mode;
|
exports.Mode = Mode;
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ var Mode = function() {
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
this.lineCommentStart = "//";
|
||||||
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
|
||||||
|
|
@ -57,10 +57,7 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
this.blockComment = {start: "<!--", end: "-->"};
|
||||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
return this.$getIndent(line);
|
return this.$getIndent(line);
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
// Extra logic goes here.
|
// Extra logic goes here.
|
||||||
|
this.lineCommentStart = "//";
|
||||||
}).call(Mode.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
exports.Mode = Mode;
|
exports.Mode = Mode;
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ define(function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var oop = require("../lib/oop");
|
var oop = require("../lib/oop");
|
||||||
var lang = require("ace/lib/lang");
|
|
||||||
var TextMode = require("./text").Mode;
|
var TextMode = require("./text").Mode;
|
||||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||||
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
|
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
|
||||||
|
|
@ -53,42 +52,7 @@ oop.inherits(Mode, TextMode);
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.lineCommentStart = "//";
|
this.lineCommentStart = "//";
|
||||||
this.toggleCommentLines = function(state, session, startRow, endRow) {
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
var doc = session.doc;
|
|
||||||
var str = this.lineCommentStart;
|
|
||||||
var regexpStart = new RegExp("^\\s*"+lang.escapeRegExp(str) + " ?");
|
|
||||||
|
|
||||||
function isCommented(str) {
|
|
||||||
return regexpStart.test(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
var removeComment = true;
|
|
||||||
var minSpace = Infinity;
|
|
||||||
var indentations = [];
|
|
||||||
|
|
||||||
for (var i = startRow; i <= endRow; i++) {
|
|
||||||
var line = doc.getLine(i);
|
|
||||||
var indent = line.search(/\S|$/);
|
|
||||||
indentations[i] = indent;
|
|
||||||
if (indent < minSpace)
|
|
||||||
minSpace = indent;
|
|
||||||
if (removeComment && !isCommented(line))
|
|
||||||
removeComment = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (removeComment) {
|
|
||||||
for (var i = startRow; i <= endRow; i++) {
|
|
||||||
var line = doc.getLine(i);
|
|
||||||
var m = line.match(regexpStart);
|
|
||||||
doc.removeInLine(i, indentations[i], m[0].length);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
str += " ";
|
|
||||||
for (var i = startRow; i <= endRow; i++) {
|
|
||||||
doc.insertInLine({row: i, column: minSpace}, str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
|
||||||
|
|
@ -19,33 +19,36 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.lineCommentStart = "//";
|
||||||
var indent = this.$getIndent(line);
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
|
|
||||||
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var tokens = tokenizedLine.tokens;
|
var indent = this.$getIndent(line);
|
||||||
|
|
||||||
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
|
||||||
return indent;
|
var tokens = tokenizedLine.tokens;
|
||||||
}
|
|
||||||
|
|
||||||
if (state == "start") {
|
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||||
var match = line.match(/^.*[\{\(\[]\s*$/);
|
return indent;
|
||||||
if (match) {
|
}
|
||||||
indent += tab;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return indent;
|
if (state == "start") {
|
||||||
};
|
var match = line.match(/^.*[\{\(\[]\s*$/);
|
||||||
|
if (match) {
|
||||||
|
indent += tab;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.checkOutdent = function(state, line, input) {
|
return indent;
|
||||||
return this.$outdent.checkOutdent(line, input);
|
};
|
||||||
};
|
|
||||||
|
|
||||||
this.autoOutdent = function(state, doc, row) {
|
this.checkOutdent = function(state, line, input) {
|
||||||
this.$outdent.autoOutdent(doc, row);
|
return this.$outdent.checkOutdent(line, input);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.autoOutdent = function(state, doc, row) {
|
||||||
|
this.$outdent.autoOutdent(doc, row);
|
||||||
|
};
|
||||||
|
|
||||||
}).call(Mode.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,120 +1,120 @@
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
var oop = require("../lib/oop");
|
var oop = require("../lib/oop");
|
||||||
var lang = require("../lib/lang");
|
var lang = require("../lib/lang");
|
||||||
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
|
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
|
||||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||||
|
|
||||||
var JsxHighlightRules = function() {
|
var JsxHighlightRules = function() {
|
||||||
var keywords = lang.arrayToMap(
|
var keywords = lang.arrayToMap(
|
||||||
("break|do|instanceof|typeof|case|else|new|var|catch|finally|return|void|continue|for|switch|default|while|function|this|" +
|
("break|do|instanceof|typeof|case|else|new|var|catch|finally|return|void|continue|for|switch|default|while|function|this|" +
|
||||||
"if|throw|" +
|
"if|throw|" +
|
||||||
"delete|in|try|" +
|
"delete|in|try|" +
|
||||||
"class|extends|super|import|from|into|implements|interface|static|mixin|override|abstract|final|" +
|
"class|extends|super|import|from|into|implements|interface|static|mixin|override|abstract|final|" +
|
||||||
"number|int|string|boolean|variant|" +
|
"number|int|string|boolean|variant|" +
|
||||||
"log|assert").split("|")
|
"log|assert").split("|")
|
||||||
);
|
);
|
||||||
|
|
||||||
var buildinConstants = lang.arrayToMap(
|
var buildinConstants = lang.arrayToMap(
|
||||||
("null|true|false|NaN|Infinity|__FILE__|__LINE__|undefined").split("|")
|
("null|true|false|NaN|Infinity|__FILE__|__LINE__|undefined").split("|")
|
||||||
);
|
);
|
||||||
|
|
||||||
var reserved = lang.arrayToMap(
|
var reserved = lang.arrayToMap(
|
||||||
("debugger|with|" +
|
("debugger|with|" +
|
||||||
"const|export|" +
|
"const|export|" +
|
||||||
"let|private|public|yield|protected|" +
|
"let|private|public|yield|protected|" +
|
||||||
"extern|native|as|operator|__fake__|__readonly__").split("|")
|
"extern|native|as|operator|__fake__|__readonly__").split("|")
|
||||||
);
|
);
|
||||||
|
|
||||||
var identifierRe = "[a-zA-Z_][a-zA-Z0-9_]*\\b";
|
var identifierRe = "[a-zA-Z_][a-zA-Z0-9_]*\\b";
|
||||||
|
|
||||||
this.$rules = {
|
this.$rules = {
|
||||||
"start" : [
|
"start" : [
|
||||||
{
|
{
|
||||||
token : "comment",
|
token : "comment",
|
||||||
regex : "\\/\\/.*$"
|
regex : "\\/\\/.*$"
|
||||||
|
},
|
||||||
|
DocCommentHighlightRules.getStartRule("doc-start"),
|
||||||
|
{
|
||||||
|
token : "comment", // multi line comment
|
||||||
|
regex : "\\/\\*",
|
||||||
|
next : "comment"
|
||||||
|
}, {
|
||||||
|
token : "string.regexp",
|
||||||
|
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
|
||||||
|
}, {
|
||||||
|
token : "string", // single line
|
||||||
|
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
|
||||||
|
}, {
|
||||||
|
token : "string", // single line
|
||||||
|
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
|
||||||
|
}, {
|
||||||
|
token : "constant.numeric", // hex
|
||||||
|
regex : "0[xX][0-9a-fA-F]+\\b"
|
||||||
|
}, {
|
||||||
|
token : "constant.numeric", // float
|
||||||
|
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
||||||
|
}, {
|
||||||
|
token : "constant.language.boolean",
|
||||||
|
regex : "(?:true|false)\\b"
|
||||||
|
}, {
|
||||||
|
token : [
|
||||||
|
"storage.type",
|
||||||
|
"text",
|
||||||
|
"entity.name.function"
|
||||||
|
],
|
||||||
|
regex : "(function)(\\s+)(" + identifierRe + ")"
|
||||||
|
}, {
|
||||||
|
token : function(value) {
|
||||||
|
if (value == "this")
|
||||||
|
return "variable.language";
|
||||||
|
else if (value == "function")
|
||||||
|
return "storage.type";
|
||||||
|
else if (keywords.hasOwnProperty(value) || reserved.hasOwnProperty(value))
|
||||||
|
return "keyword";
|
||||||
|
else if (buildinConstants.hasOwnProperty(value))
|
||||||
|
return "constant.language";
|
||||||
|
else if (/^_?[A-Z][a-zA-Z0-9_]*$/.test(value))
|
||||||
|
return "language.support.class";
|
||||||
|
else
|
||||||
|
return "identifier";
|
||||||
},
|
},
|
||||||
DocCommentHighlightRules.getStartRule("doc-start"),
|
// TODO: Unicode escape sequences
|
||||||
{
|
// TODO: Unicode identifiers
|
||||||
token : "comment", // multi line comment
|
regex : identifierRe
|
||||||
regex : "\\/\\*",
|
}, {
|
||||||
next : "comment"
|
token : "keyword.operator",
|
||||||
}, {
|
regex : "!|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
|
||||||
token : "string.regexp",
|
}, {
|
||||||
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
|
token : "punctuation.operator",
|
||||||
}, {
|
regex : "\\?|\\:|\\,|\\;|\\."
|
||||||
token : "string", // single line
|
}, {
|
||||||
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
|
token : "paren.lparen",
|
||||||
}, {
|
regex : "[[({<]"
|
||||||
token : "string", // single line
|
}, {
|
||||||
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
|
token : "paren.rparen",
|
||||||
}, {
|
regex : "[\\])}>]"
|
||||||
token : "constant.numeric", // hex
|
}, {
|
||||||
regex : "0[xX][0-9a-fA-F]+\\b"
|
token : "text",
|
||||||
}, {
|
regex : "\\s+"
|
||||||
token : "constant.numeric", // float
|
}
|
||||||
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
],
|
||||||
}, {
|
"comment" : [
|
||||||
token : "constant.language.boolean",
|
{
|
||||||
regex : "(?:true|false)\\b"
|
token : "comment", // closing comment
|
||||||
}, {
|
regex : ".*?\\*\\/",
|
||||||
token : [
|
next : "start"
|
||||||
"storage.type",
|
}, {
|
||||||
"text",
|
token : "comment", // comment spanning whole line
|
||||||
"entity.name.function"
|
regex : ".+"
|
||||||
],
|
}
|
||||||
regex : "(function)(\\s+)(" + identifierRe + ")"
|
]
|
||||||
}, {
|
|
||||||
token : function(value) {
|
|
||||||
if (value == "this")
|
|
||||||
return "variable.language";
|
|
||||||
else if (value == "function")
|
|
||||||
return "storage.type";
|
|
||||||
else if (keywords.hasOwnProperty(value) || reserved.hasOwnProperty(value))
|
|
||||||
return "keyword";
|
|
||||||
else if (buildinConstants.hasOwnProperty(value))
|
|
||||||
return "constant.language";
|
|
||||||
else if (/^_?[A-Z][a-zA-Z0-9_]*$/.test(value))
|
|
||||||
return "language.support.class";
|
|
||||||
else
|
|
||||||
return "identifier";
|
|
||||||
},
|
|
||||||
// TODO: Unicode escape sequences
|
|
||||||
// TODO: Unicode identifiers
|
|
||||||
regex : identifierRe
|
|
||||||
}, {
|
|
||||||
token : "keyword.operator",
|
|
||||||
regex : "!|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
|
|
||||||
}, {
|
|
||||||
token : "punctuation.operator",
|
|
||||||
regex : "\\?|\\:|\\,|\\;|\\."
|
|
||||||
}, {
|
|
||||||
token : "paren.lparen",
|
|
||||||
regex : "[[({<]"
|
|
||||||
}, {
|
|
||||||
token : "paren.rparen",
|
|
||||||
regex : "[\\])}>]"
|
|
||||||
}, {
|
|
||||||
token : "text",
|
|
||||||
regex : "\\s+"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"comment" : [
|
|
||||||
{
|
|
||||||
token : "comment", // closing comment
|
|
||||||
regex : ".*?\\*\\/",
|
|
||||||
next : "start"
|
|
||||||
}, {
|
|
||||||
token : "comment", // comment spanning whole line
|
|
||||||
regex : ".+"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
this.embedRules(DocCommentHighlightRules, "doc-",
|
|
||||||
[ DocCommentHighlightRules.getEndRule("start") ]);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
oop.inherits(JsxHighlightRules, TextHighlightRules);
|
this.embedRules(DocCommentHighlightRules, "doc-",
|
||||||
|
[ DocCommentHighlightRules.getEndRule("start") ]);
|
||||||
|
};
|
||||||
|
|
||||||
exports.JsxHighlightRules = JsxHighlightRules;
|
oop.inherits(JsxHighlightRules, TextHighlightRules);
|
||||||
|
|
||||||
|
exports.JsxHighlightRules = JsxHighlightRules;
|
||||||
});
|
});
|
||||||
|
|
@ -15,41 +15,7 @@ var Mode = function() {
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
this.lineCommentStart = "%";
|
||||||
// This code is adapted from ruby.js
|
|
||||||
var outdent = true;
|
|
||||||
|
|
||||||
// LaTeX comments begin with % and go to the end of the line
|
|
||||||
var commentRegEx = /^(\s*)\%/;
|
|
||||||
|
|
||||||
for (var i = startRow; i <= endRow; i++) {
|
|
||||||
if (!commentRegEx.test(doc.getLine(i))) {
|
|
||||||
outdent = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outdent) {
|
|
||||||
var deleteRange = new Range(0, 0, 0, 0);
|
|
||||||
for (var i = startRow; i <= endRow; i++) {
|
|
||||||
var line = doc.getLine(i);
|
|
||||||
var m = line.match(commentRegEx);
|
|
||||||
deleteRange.start.row = i;
|
|
||||||
deleteRange.end.row = i;
|
|
||||||
deleteRange.end.column = m[0].length;
|
|
||||||
doc.replace(deleteRange, m[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
doc.indentRows(startRow, endRow, "%");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// There is no universally accepted way of indenting a tex document
|
|
||||||
// so just maintain the indentation of the previous line
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
|
||||||
return this.$getIndent(line);
|
|
||||||
};
|
|
||||||
|
|
||||||
}).call(Mode.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,9 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
this.lineCommentStart = "//";
|
||||||
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,34 +45,7 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
this.blockComment = {start: "<!--", end: "-->"};
|
||||||
var outdent = true;
|
|
||||||
var outentedRows = [];
|
|
||||||
var re = /^(\s*)#/;
|
|
||||||
|
|
||||||
for (var i=startRow; i<= endRow; i++) {
|
|
||||||
if (!re.test(doc.getLine(i))) {
|
|
||||||
outdent = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outdent) {
|
|
||||||
var deleteRange = new Range(0, 0, 0, 0);
|
|
||||||
for (var i=startRow; i<= endRow; i++)
|
|
||||||
{
|
|
||||||
var line = doc.getLine(i);
|
|
||||||
var m = line.match(re);
|
|
||||||
deleteRange.start.row = i;
|
|
||||||
deleteRange.end.row = i;
|
|
||||||
deleteRange.end.column = m[0].length;
|
|
||||||
doc.replace(deleteRange, m[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
doc.indentRows(startRow, endRow, "#");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,6 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -53,7 +49,9 @@ var Mode = function() {
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
// Extra logic goes here.
|
|
||||||
|
this.lineCommentStart = ";";
|
||||||
|
|
||||||
}).call(Mode.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
exports.Mode = Mode;
|
exports.Mode = Mode;
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,10 @@ var Mode = function() {
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
this.lineCommentStart = "--";
|
||||||
|
this.blockComment = {start: "--[", end: "]--"};
|
||||||
|
|
||||||
var indentKeywords = {
|
var indentKeywords = {
|
||||||
"function": 1,
|
"function": 1,
|
||||||
"then": 1,
|
"then": 1,
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,8 @@ var Mode = function() {
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
// Extra logic goes here.
|
|
||||||
|
this.lineCommentStart = "#";
|
||||||
}).call(Mode.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
exports.Mode = Mode;
|
exports.Mode = Mode;
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,9 @@ var Mode = function() {
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
this.lineCommentStart = ">";
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
if (state == "listblock") {
|
if (state == "listblock") {
|
||||||
var match = /^(\s*)(?:([-+*])|(\d+)\.)(\s+)/.exec(line);
|
var match = /^(\s*)(?:([-+*])|(\d+)\.)(\s+)/.exec(line);
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,8 @@ var Mode = function() {
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
// Extra logic goes here. (see below)
|
this.lineCommentStart = "//";
|
||||||
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
}).call(Mode.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
exports.Mode = Mode;
|
exports.Mode = Mode;
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,13 @@ var Mode = function() {
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
// Extra logic goes here.
|
|
||||||
|
this.lineCommentStart = ["--", "//"];
|
||||||
|
this.blockComment = [
|
||||||
|
{start: "(*", end: "*)"},
|
||||||
|
{start: "{", end: "}"}
|
||||||
|
];
|
||||||
|
|
||||||
}).call(Mode.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
exports.Mode = Mode;
|
exports.Mode = Mode;
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,6 @@ var PascalHighlightRules = function() {
|
||||||
'storage.type.prototype.pascal',
|
'storage.type.prototype.pascal',
|
||||||
'entity.name.function.prototype.pascal' ],
|
'entity.name.function.prototype.pascal' ],
|
||||||
regex: '\\b(function|procedure)(\\s+)(\\w+)(\\.\\w+)?(?=(?:\\(.*?\\))?;\\s*(?:attribute|forward|external))' },
|
regex: '\\b(function|procedure)(\\s+)(\\w+)(\\.\\w+)?(?=(?:\\(.*?\\))?;\\s*(?:attribute|forward|external))' },
|
||||||
{ token: 'keyword.operator',
|
|
||||||
regex: '[+\\-;,/*%]|:=|=' },
|
|
||||||
{ caseInsensitive: true,
|
{ caseInsensitive: true,
|
||||||
token:
|
token:
|
||||||
[ 'variable.pascal', "text",
|
[ 'variable.pascal', "text",
|
||||||
|
|
@ -116,7 +114,9 @@ var PascalHighlightRules = function() {
|
||||||
{ token: 'punctuation.definition.string.end.pascal',
|
{ token: 'punctuation.definition.string.end.pascal',
|
||||||
regex: '\'',
|
regex: '\'',
|
||||||
next: 'pop' },
|
next: 'pop' },
|
||||||
{ defaultToken: 'string.quoted.single.pascal' } ] } ] }
|
{ defaultToken: 'string.quoted.single.pascal' } ] },
|
||||||
|
{ token: 'keyword.operator',
|
||||||
|
regex: '[+\\-;,/*%]|:=|=' } ] }
|
||||||
|
|
||||||
this.normalizeRules();
|
this.normalizeRules();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -48,33 +48,7 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
this.lineCommentStart = "#";
|
||||||
var outdent = true;
|
|
||||||
var re = /^(\s*)#/;
|
|
||||||
|
|
||||||
for (var i=startRow; i<= endRow; i++) {
|
|
||||||
if (!re.test(doc.getLine(i))) {
|
|
||||||
outdent = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outdent) {
|
|
||||||
var deleteRange = new Range(0, 0, 0, 0);
|
|
||||||
for (var i=startRow; i<= endRow; i++)
|
|
||||||
{
|
|
||||||
var line = doc.getLine(i);
|
|
||||||
var m = line.match(re);
|
|
||||||
deleteRange.start.row = i;
|
|
||||||
deleteRange.end.row = i;
|
|
||||||
deleteRange.end.column = m[0].length;
|
|
||||||
doc.replace(deleteRange, m[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
doc.indentRows(startRow, endRow, "#");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
|
||||||
|
|
@ -30,58 +30,30 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var oop = require("../lib/oop");
|
var oop = require("../lib/oop");
|
||||||
var TextMode = require("../mode/text").Mode;
|
var TextMode = require("../mode/text").Mode;
|
||||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||||
var PgsqlHighlightRules = require("./pgsql_highlight_rules").PgsqlHighlightRules;
|
var PgsqlHighlightRules = require("./pgsql_highlight_rules").PgsqlHighlightRules;
|
||||||
var Range = require("../range").Range;
|
var Range = require("../range").Range;
|
||||||
|
|
||||||
var Mode = function() {
|
var Mode = function() {
|
||||||
this.$tokenizer = new Tokenizer(new PgsqlHighlightRules().getRules());
|
this.$tokenizer = new Tokenizer(new PgsqlHighlightRules().getRules());
|
||||||
};
|
};
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
this.lineCommentStart = "--";
|
||||||
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
|
|
||||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var outdent = true;
|
if (state == "start" || state == "keyword.statementEnd") {
|
||||||
// var outentedRows = [];
|
return "";
|
||||||
var re = /^(\s*)--/;
|
} else {
|
||||||
|
return this.$getIndent(line); // Keep whatever indent the previous line has
|
||||||
for (var i=startRow; i<= endRow; i++) {
|
|
||||||
if (!re.test(doc.getLine(i))) {
|
|
||||||
outdent = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outdent) {
|
|
||||||
var deleteRange = new Range(0, 0, 0, 0);
|
|
||||||
for (var i=startRow; i<= endRow; i++)
|
|
||||||
{
|
|
||||||
var line = doc.getLine(i);
|
|
||||||
var m = line.match(re);
|
|
||||||
deleteRange.start.row = i;
|
|
||||||
deleteRange.end.row = i;
|
|
||||||
deleteRange.end.column = m[0].length;
|
|
||||||
doc.replace(deleteRange, m[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
doc.indentRows(startRow, endRow, "--");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
|
||||||
if (state == "start" || state == "keyword.statementEnd") {
|
|
||||||
return "";
|
|
||||||
} else {
|
|
||||||
return this.$getIndent(line); // Keep whatever indent the previous line has
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}).call(Mode.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
exports.Mode = Mode;
|
exports.Mode = Mode;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -69,33 +69,9 @@ oop.inherits(Mode, TextMode);
|
||||||
+ unicode.packages.Pc + "\_]|\s])+", "g"
|
+ unicode.packages.Pc + "\_]|\s])+", "g"
|
||||||
);
|
);
|
||||||
|
|
||||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
|
||||||
var outdent = true;
|
|
||||||
var re = /^(\s*)#/;
|
|
||||||
|
|
||||||
for (var i=startRow; i<= endRow; i++) {
|
this.lineCommentStart = ["#", "//"];
|
||||||
if (!re.test(doc.getLine(i))) {
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
outdent = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outdent) {
|
|
||||||
var deleteRange = new Range(0, 0, 0, 0);
|
|
||||||
for (var i=startRow; i<= endRow; i++)
|
|
||||||
{
|
|
||||||
var line = doc.getLine(i);
|
|
||||||
var m = line.match(re);
|
|
||||||
deleteRange.start.row = i;
|
|
||||||
deleteRange.end.row = i;
|
|
||||||
deleteRange.end.column = m[0].length;
|
|
||||||
doc.replace(deleteRange, m[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
doc.indentRows(startRow, endRow, "#");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,9 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
this.lineCommentStart = "#";
|
||||||
|
this.blockComment = {start: "<#", end: "#>"};
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,33 +46,7 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
this.lineCommentStart = "#";
|
||||||
var outdent = true;
|
|
||||||
var re = /^(\s*)#/;
|
|
||||||
|
|
||||||
for (var i=startRow; i<= endRow; i++) {
|
|
||||||
if (!re.test(doc.getLine(i))) {
|
|
||||||
outdent = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outdent) {
|
|
||||||
var deleteRange = new Range(0, 0, 0, 0);
|
|
||||||
for (var i=startRow; i<= endRow; i++)
|
|
||||||
{
|
|
||||||
var line = doc.getLine(i);
|
|
||||||
var m = line.match(re);
|
|
||||||
deleteRange.start.row = i;
|
|
||||||
deleteRange.end.row = i;
|
|
||||||
deleteRange.end.column = m[0].length;
|
|
||||||
doc.replace(deleteRange, m[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
doc.indentRows(startRow, endRow, "#");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
|
||||||
|
|
@ -48,33 +48,8 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
|
||||||
var outdent = true;
|
|
||||||
var re = /^(\s*)#/;
|
|
||||||
|
|
||||||
for (var i=startRow; i<= endRow; i++) {
|
this.lineCommentStart = "#";
|
||||||
if (!re.test(doc.getLine(i))) {
|
|
||||||
outdent = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outdent) {
|
|
||||||
var deleteRange = new Range(0, 0, 0, 0);
|
|
||||||
for (var i=startRow; i<= endRow; i++)
|
|
||||||
{
|
|
||||||
var line = doc.getLine(i);
|
|
||||||
var m = line.match(re);
|
|
||||||
deleteRange.start.row = i;
|
|
||||||
deleteRange.end.row = i;
|
|
||||||
deleteRange.end.column = m[0].length;
|
|
||||||
doc.replace(deleteRange, m[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
doc.indentRows(startRow, endRow, "#");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ var Mode = function() {
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
this.lineCommentStart = "//";
|
||||||
}).call(Mode.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
exports.Mode = Mode;
|
exports.Mode = Mode;
|
||||||
|
|
|
||||||
|
|
@ -50,33 +50,8 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
this.lineCommentStart = "//";
|
||||||
var outdent = true;
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
var re = /^(\s*)\/\//;
|
|
||||||
|
|
||||||
for (var i=startRow; i<= endRow; i++) {
|
|
||||||
if (!re.test(doc.getLine(i))) {
|
|
||||||
outdent = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outdent) {
|
|
||||||
var deleteRange = new Range(0, 0, 0, 0);
|
|
||||||
for (var i=startRow; i<= endRow; i++)
|
|
||||||
{
|
|
||||||
var line = doc.getLine(i);
|
|
||||||
var m = line.match(re);
|
|
||||||
deleteRange.start.row = i;
|
|
||||||
deleteRange.end.row = i;
|
|
||||||
deleteRange.end.column = m[0].length;
|
|
||||||
doc.replace(deleteRange, m[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
doc.indentRows(startRow, endRow, "//");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,9 @@ var Mode = function() {
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
// Extra logic goes here.
|
|
||||||
|
this.lineCommentStart = ";";
|
||||||
|
|
||||||
}).call(Mode.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
exports.Mode = Mode;
|
exports.Mode = Mode;
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,9 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
this.lineCommentStart = "//";
|
||||||
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,33 +44,8 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
|
||||||
var outdent = true;
|
|
||||||
var re = /^(\s*)#/;
|
|
||||||
|
|
||||||
for (var i=startRow; i<= endRow; i++) {
|
this.lineCommentStart = "#";
|
||||||
if (!re.test(doc.getLine(i))) {
|
|
||||||
outdent = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outdent) {
|
|
||||||
var deleteRange = new Range(0, 0, 0, 0);
|
|
||||||
for (var i=startRow; i<= endRow; i++)
|
|
||||||
{
|
|
||||||
var line = doc.getLine(i);
|
|
||||||
var m = line.match(re);
|
|
||||||
deleteRange.start.row = i;
|
|
||||||
deleteRange.end.row = i;
|
|
||||||
deleteRange.end.column = m[0].length;
|
|
||||||
doc.replace(deleteRange, m[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
doc.indentRows(startRow, endRow, "#");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
|
||||||
|
|
@ -44,34 +44,7 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
this.lineCommentStart = "--";
|
||||||
var outdent = true;
|
|
||||||
var outentedRows = [];
|
|
||||||
var re = /^(\s*)--/;
|
|
||||||
|
|
||||||
for (var i=startRow; i<= endRow; i++) {
|
|
||||||
if (!re.test(doc.getLine(i))) {
|
|
||||||
outdent = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outdent) {
|
|
||||||
var deleteRange = new Range(0, 0, 0, 0);
|
|
||||||
for (var i=startRow; i<= endRow; i++)
|
|
||||||
{
|
|
||||||
var line = doc.getLine(i);
|
|
||||||
var m = line.match(re);
|
|
||||||
deleteRange.start.row = i;
|
|
||||||
deleteRange.end.row = i;
|
|
||||||
deleteRange.end.column = m[0].length;
|
|
||||||
doc.replace(deleteRange, m[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
doc.indentRows(startRow, endRow, "--");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}).call(Mode.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,33 +48,7 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
this.lineCommentStart = "#";
|
||||||
var outdent = true;
|
|
||||||
var re = /^(\s*)#/;
|
|
||||||
|
|
||||||
for (var i=startRow; i<= endRow; i++) {
|
|
||||||
if (!re.test(doc.getLine(i))) {
|
|
||||||
outdent = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outdent) {
|
|
||||||
var deleteRange = new Range(0, 0, 0, 0);
|
|
||||||
for (var i=startRow; i<= endRow; i++)
|
|
||||||
{
|
|
||||||
var line = doc.getLine(i);
|
|
||||||
var m = line.match(re);
|
|
||||||
deleteRange.start.row = i;
|
|
||||||
deleteRange.end.row = i;
|
|
||||||
deleteRange.end.column = m[0].length;
|
|
||||||
doc.replace(deleteRange, m[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
doc.indentRows(startRow, endRow, "#");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ var Tokenizer = require("../tokenizer").Tokenizer;
|
||||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||||
var Behaviour = require("./behaviour").Behaviour;
|
var Behaviour = require("./behaviour").Behaviour;
|
||||||
var unicode = require("../unicode");
|
var unicode = require("../unicode");
|
||||||
|
var lang = require("../lib/lang");
|
||||||
|
|
||||||
var Mode = function() {
|
var Mode = function() {
|
||||||
this.$tokenizer = new Tokenizer(new TextHighlightRules().getRules());
|
this.$tokenizer = new Tokenizer(new TextHighlightRules().getRules());
|
||||||
|
|
@ -61,7 +62,46 @@ var Mode = function() {
|
||||||
return this.$tokenizer;
|
return this.$tokenizer;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
this.toggleCommentLines = function(state, session, startRow, endRow) {
|
||||||
|
var doc = session.doc;
|
||||||
|
var regexpStart, lineCommentStart;
|
||||||
|
if (!this.lineCommentStart) {
|
||||||
|
return false
|
||||||
|
} else if (Array.isArray(this.lineCommentStart)) {
|
||||||
|
regexpStart = this.lineCommentStart.map(lang.escapeRegExp).join("|");
|
||||||
|
lineCommentStart = this.lineCommentStart[0];
|
||||||
|
} else {
|
||||||
|
regexpStart = lang.escapeRegExp(this.lineCommentStart);
|
||||||
|
lineCommentStart = this.lineCommentStart;
|
||||||
|
}
|
||||||
|
regexpStart = new RegExp("^\\s*(?:" + regexpStart + ") ?");
|
||||||
|
|
||||||
|
var removeComment = true;
|
||||||
|
var minSpace = Infinity;
|
||||||
|
var indentations = [];
|
||||||
|
|
||||||
|
for (var i = startRow; i <= endRow; i++) {
|
||||||
|
var line = doc.getLine(i);
|
||||||
|
var indent = line.search(/\S|$/);
|
||||||
|
indentations[i] = indent;
|
||||||
|
if (indent < minSpace)
|
||||||
|
minSpace = indent;
|
||||||
|
if (removeComment && !regexpStart.test(line))
|
||||||
|
removeComment = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (removeComment) {
|
||||||
|
for (var i = startRow; i <= endRow; i++) {
|
||||||
|
var line = doc.getLine(i);
|
||||||
|
var m = line.match(regexpStart);
|
||||||
|
doc.removeInLine(i, indentations[i], m[0].length);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lineCommentStart += " ";
|
||||||
|
for (var i = startRow; i <= endRow; i++) {
|
||||||
|
doc.insertInLine({row: i, column: minSpace}, lineCommentStart);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
|
|
|
||||||
|
|
@ -26,11 +26,6 @@
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,9 @@ var Mode = function() {
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
// Extra logic goes here.
|
|
||||||
|
this.lineCommentStart = ["'", "REM"];
|
||||||
|
|
||||||
}).call(Mode.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
exports.Mode = Mode;
|
exports.Mode = Mode;
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,7 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.blockComment = {start: "<!--", end: "-->"};
|
||||||
return this.$getIndent(line);
|
|
||||||
};
|
|
||||||
|
|
||||||
}).call(Mode.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,9 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.lineCommentStart = "#";
|
||||||
|
|
||||||
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
||||||
if (state == "start") {
|
if (state == "start") {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue