Added highlighting rule for regular expression
Fixed auto-outdenting when typing }
This commit is contained in:
parent
39fcc4e65f
commit
858f92d593
4 changed files with 20 additions and 4 deletions
|
|
@ -371,6 +371,7 @@ var Editor = function(renderer, doc) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.onTextInput = function(text) {
|
this.onTextInput = function(text) {
|
||||||
|
console.log("onTextInput was called");
|
||||||
if (this.$readOnly)
|
if (this.$readOnly)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -391,20 +392,24 @@ var Editor = function(renderer, doc) {
|
||||||
|
|
||||||
var _self = this;
|
var _self = this;
|
||||||
var row = cursor.row;
|
var row = cursor.row;
|
||||||
this.bgTokenizer.getState(cursor.row-1, function(lineState) {
|
this.bgTokenizer.getState(cursor.row-1, function (lineState) {
|
||||||
var shouldOutdent = _self.mode.checkOutdent(lineState, _self.doc.getLine(row), text);
|
var shouldOutdent = _self.mode.checkOutdent(lineState, _self.doc.getLine(row), text);
|
||||||
var line = _self.doc.getLine(row);
|
var line = _self.doc.getLine(row);
|
||||||
var end = _self.doc.insert(cursor, text);
|
var end = _self.doc.insert(cursor, text);
|
||||||
|
|
||||||
if (line != _self.doc.getLine(row) && text != "\n") {
|
/* TODO: This shortcut is somehow broken
|
||||||
|
if (!shouldOutdent && line != _self.doc.getLine(row) && text != "\n") {
|
||||||
_self.moveCursorToPosition(end);
|
_self.moveCursorToPosition(end);
|
||||||
_self.renderer.scrollCursorIntoView();
|
_self.renderer.scrollCursorIntoView();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
var line = _self.doc.getLine(row);
|
var line = _self.doc.getLine(row);
|
||||||
|
console.log("Poofing");
|
||||||
_self.bgTokenizer.getState(row, function(lineState) {
|
_self.bgTokenizer.getState(row, function(lineState) {
|
||||||
// multi line insert
|
// multi line insert
|
||||||
|
console.log("Poof " + row + "of" + end.row);
|
||||||
if (row !== end.row) {
|
if (row !== end.row) {
|
||||||
var indent = _self.mode.getNextLineIndent(lineState, line, _self.doc.getTabString());
|
var indent = _self.mode.getNextLineIndent(lineState, line, _self.doc.getTabString());
|
||||||
if (indent) {
|
if (indent) {
|
||||||
|
|
@ -412,7 +417,9 @@ var Editor = function(renderer, doc) {
|
||||||
end.column += _self.doc.indentRows(indentRange, indent);
|
end.column += _self.doc.indentRows(indentRange, indent);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
console.log("Last row");
|
||||||
if (shouldOutdent) {
|
if (shouldOutdent) {
|
||||||
|
console.log("We should outdent");
|
||||||
end.column += _self.mode.autoOutdent(lineState, _self.doc, row);
|
end.column += _self.mode.autoOutdent(lineState, _self.doc, row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,9 @@ JavaScriptHighlightRules = function() {
|
||||||
token : "comment", // multi line comment
|
token : "comment", // multi line comment
|
||||||
regex : "\\/\\*",
|
regex : "\\/\\*",
|
||||||
next : "comment"
|
next : "comment"
|
||||||
|
}, {
|
||||||
|
token : "regex",
|
||||||
|
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/][gimy]*\\s*(?=[).;]|$)"
|
||||||
}, {
|
}, {
|
||||||
token : "string", // single line
|
token : "string", // single line
|
||||||
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
|
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ var XmlHighlightRules = function() {
|
||||||
regex : "\\s+"
|
regex : "\\s+"
|
||||||
}, {
|
}, {
|
||||||
token : "text",
|
token : "text",
|
||||||
regex : ".+"
|
regex : "(?:[^\\]]|\\](?!\\]>))+"
|
||||||
} ],
|
} ],
|
||||||
|
|
||||||
comment : [ {
|
comment : [ {
|
||||||
|
|
@ -81,6 +81,8 @@ var XmlHighlightRules = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/fd/g
|
||||||
|
|
||||||
oop.inherits(XmlHighlightRules, TextHighlightRules);
|
oop.inherits(XmlHighlightRules, TextHighlightRules);
|
||||||
|
|
||||||
return XmlHighlightRules;
|
return XmlHighlightRules;
|
||||||
|
|
|
||||||
|
|
@ -116,4 +116,8 @@
|
||||||
|
|
||||||
.ace-tm .ace_marker-layer .ace_active_line {
|
.ace-tm .ace_marker-layer .ace_active_line {
|
||||||
background: rgb(232, 242, 254);
|
background: rgb(232, 242, 254);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ace-tm .ace_regex {
|
||||||
|
color: rgb(255, 0, 0)
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue