Added highlighting rule for regular expression

Fixed auto-outdenting when typing }
This commit is contained in:
Eddy Bruel 2010-10-25 18:14:46 +02:00
commit 858f92d593
4 changed files with 20 additions and 4 deletions

View file

@ -371,6 +371,7 @@ var Editor = function(renderer, doc) {
};
this.onTextInput = function(text) {
console.log("onTextInput was called");
if (this.$readOnly)
return;
@ -391,20 +392,24 @@ var Editor = function(renderer, doc) {
var _self = this;
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 line = _self.doc.getLine(row);
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.renderer.scrollCursorIntoView();
return;
}
*/
var line = _self.doc.getLine(row);
console.log("Poofing");
_self.bgTokenizer.getState(row, function(lineState) {
// multi line insert
console.log("Poof " + row + "of" + end.row);
if (row !== end.row) {
var indent = _self.mode.getNextLineIndent(lineState, line, _self.doc.getTabString());
if (indent) {
@ -412,7 +417,9 @@ var Editor = function(renderer, doc) {
end.column += _self.doc.indentRows(indentRange, indent);
}
} else {
console.log("Last row");
if (shouldOutdent) {
console.log("We should outdent");
end.column += _self.mode.autoOutdent(lineState, _self.doc, row);
}
}

View file

@ -45,6 +45,9 @@ JavaScriptHighlightRules = function() {
token : "comment", // multi line comment
regex : "\\/\\*",
next : "comment"
}, {
token : "regex",
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/][gimy]*\\s*(?=[).;]|$)"
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'

View file

@ -67,7 +67,7 @@ var XmlHighlightRules = function() {
regex : "\\s+"
}, {
token : "text",
regex : ".+"
regex : "(?:[^\\]]|\\](?!\\]>))+"
} ],
comment : [ {
@ -81,6 +81,8 @@ var XmlHighlightRules = function() {
};
};
/fd/g
oop.inherits(XmlHighlightRules, TextHighlightRules);
return XmlHighlightRules;

View file

@ -116,4 +116,8 @@
.ace-tm .ace_marker-layer .ace_active_line {
background: rgb(232, 242, 254);
}
.ace-tm .ace_regex {
color: rgb(255, 0, 0)
}