Merge pull request #1260 from ajaxorg/toggleComment
Improve toggleCommentLines and make it faster
This commit is contained in:
commit
1b8fb10e50
52 changed files with 371 additions and 774 deletions
|
|
@ -222,12 +222,12 @@ var EditSession = function(text, mode) {
|
||||||
this.$screenRowCache = [];
|
this.$screenRowCache = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var i = this.$getRowCacheIndex(this.$docRowCache, docRow) + 1;
|
|
||||||
var l = this.$docRowCache.length;
|
var l = this.$docRowCache.length;
|
||||||
|
var i = this.$getRowCacheIndex(this.$docRowCache, docRow) + 1;
|
||||||
|
if (l > i) {
|
||||||
this.$docRowCache.splice(i, l);
|
this.$docRowCache.splice(i, l);
|
||||||
this.$screenRowCache.splice(i, l);
|
this.$screenRowCache.splice(i, l);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$getRowCacheIndex = function(cacheArray, val) {
|
this.$getRowCacheIndex = function(cacheArray, val) {
|
||||||
|
|
@ -426,8 +426,7 @@ var EditSession = function(text, mode) {
|
||||||
|
|
||||||
self.$deltas = [];
|
self.$deltas = [];
|
||||||
}
|
}
|
||||||
this.$informUndoManager =
|
this.$informUndoManager = lang.delayedCall(this.$syncInformUndoManager);
|
||||||
lang.deferredCall(this.$syncInformUndoManager);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,6 @@ function Folding() {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
this.getFoldsInRange = function(range) {
|
this.getFoldsInRange = function(range) {
|
||||||
range = range.clone();
|
|
||||||
var start = range.start;
|
var start = range.start;
|
||||||
var end = range.end;
|
var end = range.end;
|
||||||
var foldLines = this.$foldData;
|
var foldLines = this.$foldData;
|
||||||
|
|
@ -104,6 +103,9 @@ function Folding() {
|
||||||
foundFolds.push(fold);
|
foundFolds.push(fold);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
start.column -= 1;
|
||||||
|
end.column += 1;
|
||||||
|
|
||||||
return foundFolds;
|
return foundFolds;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -591,8 +591,9 @@ var Editor = function(renderer, session) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
this.onChangeMode = function() {
|
this.onChangeMode = function(e) {
|
||||||
this.renderer.updateText();
|
this.renderer.updateText();
|
||||||
|
this._emit("changeMode", e);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -192,8 +192,8 @@ module.exports = {
|
||||||
assert.equal(["// abc", "// cde"].join("\n"), session.toString());
|
assert.equal(["// abc", "// cde"].join("\n"), session.toString());
|
||||||
|
|
||||||
var selection = editor.getSelectionRange();
|
var selection = editor.getSelectionRange();
|
||||||
assert.position(selection.start, 0, 4);
|
assert.position(selection.start, 0, 5);
|
||||||
assert.position(selection.end, 1, 4);
|
assert.position(selection.end, 1, 5);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: uncomment lines should perserve selection" : function() {
|
"test: uncomment lines should perserve selection" : function() {
|
||||||
|
|
@ -235,7 +235,7 @@ module.exports = {
|
||||||
editor.getSelection().selectDown();
|
editor.getSelection().selectDown();
|
||||||
|
|
||||||
editor.toggleCommentLines();
|
editor.toggleCommentLines();
|
||||||
assert.range(editor.getSelectionRange(), 0, 2, 1, 0);
|
assert.range(editor.getSelectionRange(), 0, 3, 1, 0);
|
||||||
|
|
||||||
// select up
|
// select up
|
||||||
var session = new EditSession(["abc", "cde"].join("\n"), new JavaScriptMode());
|
var session = new EditSession(["abc", "cde"].join("\n"), new JavaScriptMode());
|
||||||
|
|
@ -245,7 +245,7 @@ module.exports = {
|
||||||
editor.getSelection().selectUp();
|
editor.getSelection().selectUp();
|
||||||
|
|
||||||
editor.toggleCommentLines();
|
editor.toggleCommentLines();
|
||||||
assert.range(editor.getSelectionRange(), 0, 2, 1, 0);
|
assert.range(editor.getSelectionRange(), 0, 3, 1, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: move lines down should select moved lines" : function() {
|
"test: move lines down should select moved lines" : function() {
|
||||||
|
|
|
||||||
|
|
@ -982,45 +982,6 @@ if (!Date.now) {
|
||||||
// ======
|
// ======
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
// ES5 15.5.4.14
|
|
||||||
// http://es5.github.com/#x15.5.4.14
|
|
||||||
// [bugfix, chrome]
|
|
||||||
// If separator is undefined, then the result array contains just one String,
|
|
||||||
// which is the this value (converted to a String). If limit is not undefined,
|
|
||||||
// then the output array is truncated so that it contains no more than limit
|
|
||||||
// elements.
|
|
||||||
// "0".split(undefined, 0) -> []
|
|
||||||
if("0".split(void 0, 0).length) {
|
|
||||||
var string_split = String.prototype.split;
|
|
||||||
String.prototype.split = function(separator, limit) {
|
|
||||||
if(separator === void 0 && limit === 0)return [];
|
|
||||||
return string_split.apply(this, arguments);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ECMA-262, 3rd B.2.3
|
|
||||||
// Note an ECMAScript standart, although ECMAScript 3rd Edition has a
|
|
||||||
// non-normative section suggesting uniform semantics and it should be
|
|
||||||
// normalized across all browsers
|
|
||||||
// [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
|
|
||||||
if("".substr && "0b".substr(-1) !== "b") {
|
|
||||||
var string_substr = String.prototype.substr;
|
|
||||||
/**
|
|
||||||
* Get the substring of a string
|
|
||||||
* @param {integer} start where to start the substring
|
|
||||||
* @param {integer} length how many characters to return
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
String.prototype.substr = function(start, length) {
|
|
||||||
return string_substr.call(
|
|
||||||
this,
|
|
||||||
start < 0 ? (start = this.length + start) < 0 ? 0 : start : start,
|
|
||||||
length
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ES5 15.5.4.20
|
// ES5 15.5.4.20
|
||||||
// http://es5.github.com/#x15.5.4.20
|
// http://es5.github.com/#x15.5.4.20
|
||||||
var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
|
var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
|
||||||
|
|
@ -1033,12 +994,7 @@ if (!String.prototype.trim || ws.trim()) {
|
||||||
var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
|
var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
|
||||||
trimEndRegexp = new RegExp(ws + ws + "*$");
|
trimEndRegexp = new RegExp(ws + ws + "*$");
|
||||||
String.prototype.trim = function trim() {
|
String.prototype.trim = function trim() {
|
||||||
if (this === undefined || this === null) {
|
return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
|
||||||
throw new TypeError("can't convert "+this+" to object");
|
|
||||||
}
|
|
||||||
return String(this)
|
|
||||||
.replace(trimBeginRegexp, "")
|
|
||||||
.replace(trimEndRegexp, "");
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -144,34 +144,9 @@ exports.getMatchOffsets = function(string, regExp) {
|
||||||
|
|
||||||
/* deprecated */
|
/* deprecated */
|
||||||
exports.deferredCall = function(fcn) {
|
exports.deferredCall = function(fcn) {
|
||||||
|
if (typeof console != "undefined" && console.error)
|
||||||
var timer = null;
|
console.error("Deprecated: use lang.delayedCall")
|
||||||
var callback = function() {
|
return exports.delayedCall(fcn);
|
||||||
timer = null;
|
|
||||||
fcn();
|
|
||||||
};
|
|
||||||
|
|
||||||
var deferred = function(timeout) {
|
|
||||||
deferred.cancel();
|
|
||||||
timer = setTimeout(callback, timeout || 0);
|
|
||||||
return deferred;
|
|
||||||
};
|
|
||||||
|
|
||||||
deferred.schedule = deferred;
|
|
||||||
|
|
||||||
deferred.call = function() {
|
|
||||||
this.cancel();
|
|
||||||
fcn();
|
|
||||||
return deferred;
|
|
||||||
};
|
|
||||||
|
|
||||||
deferred.cancel = function() {
|
|
||||||
clearTimeout(timer);
|
|
||||||
timer = null;
|
|
||||||
return deferred;
|
|
||||||
};
|
|
||||||
|
|
||||||
return deferred;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -17,33 +17,8 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
(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);
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -51,34 +51,8 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
this.lineCommentStart = "//";
|
||||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
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);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -42,36 +42,8 @@ define(function(require, exports, module) {
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
this.lineCommentStart = "--";
|
||||||
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) {
|
||||||
if (state == "start" || state == "keyword.statementEnd") {
|
if (state == "start" || state == "keyword.statementEnd") {
|
||||||
|
|
|
||||||
|
|
@ -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,6 +47,8 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
this.lineCommentStart = "#";
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ function onMouseDown(e) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
} else if (!shift && alt && button == 0) {
|
} else if (alt && button == 0) {
|
||||||
e.stop();
|
e.stop();
|
||||||
|
|
||||||
if (isMultiSelect && !ctrl)
|
if (isMultiSelect && !ctrl)
|
||||||
|
|
@ -128,10 +128,15 @@ function onMouseDown(e) {
|
||||||
else if (!isMultiSelect && ctrl)
|
else if (!isMultiSelect && ctrl)
|
||||||
selection.addRange();
|
selection.addRange();
|
||||||
|
|
||||||
|
var rectSel = [];
|
||||||
|
if (shift) {
|
||||||
|
screenAnchor = session.documentToScreenPosition(selection.lead);
|
||||||
|
blockSelect();
|
||||||
|
} else {
|
||||||
selection.moveCursorToPosition(pos);
|
selection.moveCursorToPosition(pos);
|
||||||
selection.clearSelection();
|
selection.clearSelection();
|
||||||
|
}
|
||||||
|
|
||||||
var rectSel = [];
|
|
||||||
|
|
||||||
var onMouseSelectionEnd = function(e) {
|
var onMouseSelectionEnd = function(e) {
|
||||||
clearInterval(timerId);
|
clearInterval(timerId);
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,7 @@ var Split = function(container, theme, splits) {
|
||||||
|
|
||||||
// Overwrite the default $informUndoManager function such that new delas
|
// Overwrite the default $informUndoManager function such that new delas
|
||||||
// aren't added to the undo manager from the new and the old session.
|
// aren't added to the undo manager from the new and the old session.
|
||||||
s.$informUndoManager = lang.deferredCall(function() { s.$deltas = []; });
|
s.$informUndoManager = lang.delayedCall(function() { s.$deltas = []; });
|
||||||
|
|
||||||
// Copy over 'settings' from the session.
|
// Copy over 'settings' from the session.
|
||||||
s.setTabSize(session.getTabSize());
|
s.setTabSize(session.getTabSize());
|
||||||
|
|
|
||||||
|
|
@ -304,6 +304,11 @@ var VirtualRenderer = function(container, theme) {
|
||||||
size.height = height;
|
size.height = height;
|
||||||
|
|
||||||
size.scrollerHeight = this.scroller.clientHeight;
|
size.scrollerHeight = this.scroller.clientHeight;
|
||||||
|
if (!size.scrollerHeight) {
|
||||||
|
size.scrollerHeight = size.height;
|
||||||
|
if (this.$horizScroll)
|
||||||
|
size.scrollerHeight -= this.scrollBar.getWidth();
|
||||||
|
}
|
||||||
this.scrollBar.setHeight(size.scrollerHeight);
|
this.scrollBar.setHeight(size.scrollerHeight);
|
||||||
|
|
||||||
if (this.session) {
|
if (this.session) {
|
||||||
|
|
@ -332,6 +337,9 @@ var VirtualRenderer = function(container, theme) {
|
||||||
else
|
else
|
||||||
this.$loop.schedule(changes);
|
this.$loop.schedule(changes);
|
||||||
|
|
||||||
|
if (force)
|
||||||
|
this.$gutterLayer.$padding = null;
|
||||||
|
|
||||||
if (force)
|
if (force)
|
||||||
delete this.resizing;
|
delete this.resizing;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue