Merge branch 'master' of github.com:ajaxorg/ace

This commit is contained in:
Fabian Jakobs 2011-12-01 12:07:22 +01:00
commit 64d8b93538
5 changed files with 44 additions and 28 deletions

View file

@ -988,10 +988,12 @@ var EditSession = function(text, mode) {
var removedFolds = null; var removedFolds = null;
if (action.indexOf("Lines") != -1) { if (action.indexOf("Lines") != -1) {
if (action == "insertLines") { if (e.data.lines) {
lastRow = firstRow + (e.data.lines.length); if (action == "insertLines" && e.data.lines) {
} else { lastRow = firstRow + (e.data.lines.length);
lastRow = firstRow; } else {
lastRow = firstRow;
}
} }
len = e.data.lines ? e.data.lines.length : lastRow - firstRow; len = e.data.lines ? e.data.lines.length : lastRow - firstRow;
} else { } else {

View file

@ -86,7 +86,9 @@ var KeyBinding = function(editor) {
if (!toExecute || !toExecute.command) if (!toExecute || !toExecute.command)
return false; return false;
var success = false, commands = this.$editor.commands;
var success = false;
var commands = this.$editor.commands;
// allow keyboardHandler to consume keys // allow keyboardHandler to consume keys
if (toExecute.command != "null") if (toExecute.command != "null")

View file

@ -73,7 +73,7 @@ StateHandler.prototype = {
}); });
}, },
$composeBuffer: function(data, hashId, key) { $composeBuffer: function(data, hashId, key, e) {
// Initialize the data object. // Initialize the data object.
if (data.state == null || data.buffer == null) { if (data.state == null || data.buffer == null) {
data.state = "start"; data.state = "start";
@ -102,17 +102,23 @@ StateHandler.prototype = {
data.buffer = bufferToUse; data.buffer = bufferToUse;
} }
return { var bufferObj = {
bufferToUse: bufferToUse, bufferToUse: bufferToUse,
symbolicName: symbolicName symbolicName: symbolicName,
}; };
if (e) {
bufferObj.keyIdentifier = e.keyIdentifier
}
return bufferObj;
}, },
$find: function(data, buffer, symbolicName, hashId, key) { $find: function(data, buffer, symbolicName, hashId, key, keyIdentifier) {
// Holds the command to execute and the args if a command matched. // Holds the command to execute and the args if a command matched.
var result = {}; var result = {};
// Loop over all the bindings of the keymapp until a match is found. // Loop over all the bindings of the keymap until a match is found.
this.keymapping[data.state].some(function(binding) { this.keymapping[data.state].some(function(binding) {
var match; var match;
@ -127,7 +133,7 @@ StateHandler.prototype = {
} }
// Check if the match function matches. // Check if the match function matches.
if (binding.match && !binding.match(buffer, hashId, key, symbolicName)) { if (binding.match && !binding.match(buffer, hashId, key, symbolicName, keyIdentifier)) {
return false; return false;
} }
@ -194,20 +200,21 @@ StateHandler.prototype = {
/** /**
* This function is called by keyBinding. * This function is called by keyBinding.
*/ */
handleKeyboard: function(data, hashId, key) { handleKeyboard: function(data, hashId, key, keyCode, e) {
// If we pressed any command key but no other key, then ignore the input. // If we pressed any command key but no other key, then ignore the input.
// Otherwise "shift-" is added to the buffer, and later on "shift-g" // Otherwise "shift-" is added to the buffer, and later on "shift-g"
// which results in "shift-shift-g" which doesn't make senese. // which results in "shift-shift-g" which doesn't make sense.
if (hashId != 0 && (key == "" || key == String.fromCharCode(0))) { if (hashId != 0 && (key == "" || key == String.fromCharCode(0))) {
return null; return null;
} }
// Compute the current value of the keyboard input buffer. // Compute the current value of the keyboard input buffer.
var r = this.$composeBuffer(data, hashId, key); var r = this.$composeBuffer(data, hashId, key, e);
var buffer = r.bufferToUse; var buffer = r.bufferToUse;
var symbolicName = r.symbolicName; var symbolicName = r.symbolicName;
var keyId = r.keyIdentifier;
r = this.$find(data, buffer, symbolicName, hashId, key); r = this.$find(data, buffer, symbolicName, hashId, key, keyId);
if (DEBUG) { if (DEBUG) {
console.log("KeyboardStateMapper#match", buffer, symbolicName, r); console.log("KeyboardStateMapper#match", buffer, symbolicName, r);
} }

View file

@ -85,7 +85,9 @@ var Gutter = function(parentEl) {
}; };
for (var i=0; i<rowAnnotations.length; i++) { for (var i=0; i<rowAnnotations.length; i++) {
var annotation = rowAnnotations[i]; var annotation = rowAnnotations[i];
rowInfo.text.push(annotation.text.replace(/"/g, "&quot;").replace(/'/g, "&#8217;").replace(/</, "&lt;")); var annoText = annotation.text.replace(/"/g, "&quot;").replace(/'/g, "&#8217;").replace(/</, "&lt;");
if (rowInfo.text.indexOf(annoText) === -1)
rowInfo.text.push(annoText);
var type = annotation.type; var type = annotation.type;
if (type == "error") if (type == "error")
rowInfo.className = "ace_error"; rowInfo.className = "ace_error";

View file

@ -51,7 +51,7 @@ var HtmlHighlightRules = function() {
token : "string", token : "string",
regex : '".*?"' regex : '".*?"'
}, { }, {
token : "string", // multi line string start token : "meta.tag", // multi line string start
merge : true, merge : true,
regex : '["].*$', regex : '["].*$',
next : state + "-qqstring" next : state + "-qqstring"
@ -59,7 +59,7 @@ var HtmlHighlightRules = function() {
token : "string", token : "string",
regex : "'.*?'" regex : "'.*?'"
}, { }, {
token : "string", // multi line string start token : "meta.tag", // multi line string start
merge : true, merge : true,
regex : "['].*$", regex : "['].*$",
next : state + "-qstring" next : state + "-qstring"
@ -68,7 +68,7 @@ var HtmlHighlightRules = function() {
function multiLineString(quote, state) { function multiLineString(quote, state) {
return [{ return [{
token : "string", token : "meta.tag",
merge : true, merge : true,
regex : ".*" + quote, regex : ".*" + quote,
next : state next : state
@ -97,9 +97,12 @@ var HtmlHighlightRules = function() {
states[name + "-qqstring"] = multiLineString("\"", name); states[name + "-qqstring"] = multiLineString("\"", name);
states[name + "embed-attribute-list"] = [{ states[name + "embed-attribute-list"] = [{
token : "text", token : "meta.tag",
regex : ">", regex : ">",
next : nextState next : nextState
}, {
token : "meta.tag",
regex : "="
}, { }, {
token : "entity.other.attribute-name", token : "entity.other.attribute-name",
regex : "[-_a-zA-Z0-9:]+" regex : "[-_a-zA-Z0-9:]+"
@ -114,7 +117,7 @@ var HtmlHighlightRules = function() {
this.$rules = { this.$rules = {
start : [ { start : [ {
token : "text", token : "meta.tag",
merge : true, merge : true,
regex : "<\\!\\[CDATA\\[", regex : "<\\!\\[CDATA\\[",
next : "cdata" next : "cdata"
@ -127,15 +130,15 @@ var HtmlHighlightRules = function() {
regex : "<\\!--", regex : "<\\!--",
next : "comment" next : "comment"
}, { }, {
token : "text", token : "meta.tag",
regex : "<(?=\s*script)", regex : "<(?=\s*script)",
next : "script" next : "script"
}, { }, {
token : "text", token : "meta.tag",
regex : "<(?=\s*style)", regex : "<(?=\s*style)",
next : "css" next : "css"
}, { }, {
token : "text", // opening tag token : "meta.tag", // opening tag
regex : "<\\/?", regex : "<\\/?",
next : "tag" next : "tag"
}, { }, {
@ -176,17 +179,17 @@ var HtmlHighlightRules = function() {
tag(this.$rules, "script", "js-start"); tag(this.$rules, "script", "js-start");
this.embedRules(JavaScriptHighlightRules, "js-", [{ this.embedRules(JavaScriptHighlightRules, "js-", [{
token: "comment", token: "meta.tag",
regex: "\\/\\/.*(?=<\\/script>)", regex: "\\/\\/.*(?=<\\/script>)",
next: "tag" next: "tag"
}, { }, {
token: "text", token: "meta.tag",
regex: "<\\/(?=script)", regex: "<\\/(?=script)",
next: "tag" next: "tag"
}]); }]);
this.embedRules(CssHighlightRules, "css-", [{ this.embedRules(CssHighlightRules, "css-", [{
token: "text", token: "meta.tag",
regex: "<\\/(?=style)", regex: "<\\/(?=style)",
next: "tag" next: "tag"
}]); }]);