From 5d0bc99d99c1d2b76e7985849e9847f93a67e7a8 Mon Sep 17 00:00:00 2001 From: Bernie Telles Date: Thu, 17 Nov 2011 18:41:45 -0800 Subject: [PATCH 1/5] Change HTML highlight rules to match chrome theme. Conflicts: lib/ace/mode/html_highlight_rules.js --- lib/ace/mode/html_highlight_rules.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/ace/mode/html_highlight_rules.js b/lib/ace/mode/html_highlight_rules.js index 21110a02..372e4027 100644 --- a/lib/ace/mode/html_highlight_rules.js +++ b/lib/ace/mode/html_highlight_rules.js @@ -51,7 +51,7 @@ var HtmlHighlightRules = function() { token : "string", regex : '".*?"' }, { - token : "string", // multi line string start + token : "meta.tag", // multi line string start merge : true, regex : '["].*$', next : state + "-qqstring" @@ -59,7 +59,7 @@ var HtmlHighlightRules = function() { token : "string", regex : "'.*?'" }, { - token : "string", // multi line string start + token : "meta.tag", // multi line string start merge : true, regex : "['].*$", next : state + "-qstring" @@ -68,7 +68,7 @@ var HtmlHighlightRules = function() { function multiLineString(quote, state) { return [{ - token : "string", + token : "meta.tag", merge : true, regex : ".*" + quote, next : state @@ -97,9 +97,12 @@ var HtmlHighlightRules = function() { states[name + "-qqstring"] = multiLineString("\"", name); states[name + "embed-attribute-list"] = [{ - token : "text", + token : "meta.tag", regex : ">", next : nextState + }, { + token : "meta.tag", + regex : "=" }, { token : "entity.other.attribute-name", regex : "[-_a-zA-Z0-9:]+" @@ -114,7 +117,7 @@ var HtmlHighlightRules = function() { this.$rules = { start : [ { - token : "text", + token : "meta.tag", merge : true, regex : "<\\!\\[CDATA\\[", next : "cdata" @@ -127,15 +130,15 @@ var HtmlHighlightRules = function() { regex : "<\\!--", next : "comment" }, { - token : "text", + token : "meta.tag", regex : "<(?=\s*script)", next : "script" }, { - token : "text", + token : "meta.tag", regex : "<(?=\s*style)", next : "css" }, { - token : "text", // opening tag + token : "meta.tag", // opening tag regex : "<\\/?", next : "tag" }, { @@ -176,17 +179,17 @@ var HtmlHighlightRules = function() { tag(this.$rules, "script", "js-start"); this.embedRules(JavaScriptHighlightRules, "js-", [{ - token: "comment", + token: "meta.tag", regex: "\\/\\/.*(?=<\\/script>)", next: "tag" }, { - token: "text", + token: "meta.tag", regex: "<\\/(?=script)", next: "tag" }]); this.embedRules(CssHighlightRules, "css-", [{ - token: "text", + token: "meta.tag", regex: "<\\/(?=style)", next: "tag" }]); From d3013ad835db3fb1d8caa975aacdd1c81a873b95 Mon Sep 17 00:00:00 2001 From: Sergi Mansilla Date: Tue, 29 Nov 2011 16:45:30 +0100 Subject: [PATCH 2/5] We are now passing along the original Keyboard event for keybindings The original keyboard event is now passed on, and `$composeBuffer` is returning with an extra property `keyIdentifier`, which contains the Unicode id of the pressed keybinding. --- lib/ace/keyboard/keybinding.js | 8 ++++---- lib/ace/keyboard/state_handler.js | 29 ++++++++++++++++++----------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/lib/ace/keyboard/keybinding.js b/lib/ace/keyboard/keybinding.js index 9caa76da..e1ab4faf 100644 --- a/lib/ace/keyboard/keybinding.js +++ b/lib/ace/keyboard/keybinding.js @@ -39,6 +39,7 @@ define(function(require, exports, module) { +var useragent = require("../lib/useragent"); var keyUtil = require("../lib/keys"); var event = require("../lib/event"); require("../commands/default_commands"); @@ -75,9 +76,8 @@ var KeyBinding = function(editor) { }; this.$callKeyboardHandlers = function (hashId, keyString, keyCode, e) { - var toExecute; for (var i = this.$handlers.length; i--;) { - toExecute = this.$handlers[i].handleKeyboard( + var toExecute = this.$handlers[i].handleKeyboard( this.$data, hashId, keyString, keyCode, e ); if (toExecute && toExecute.command) @@ -97,13 +97,13 @@ var KeyBinding = function(editor) { if (success && e) event.stopEvent(e); - return success; + return success }; this.handleKeyboard = function(data, hashId, keyString) { return { command: this.$editor.commands.findKeyCommand(hashId, keyString) - }; + } }; this.onCommandKey = function(e, hashId, keyCode) { diff --git a/lib/ace/keyboard/state_handler.js b/lib/ace/keyboard/state_handler.js index 15d17c8c..a5bc7fbf 100644 --- a/lib/ace/keyboard/state_handler.js +++ b/lib/ace/keyboard/state_handler.js @@ -73,7 +73,7 @@ StateHandler.prototype = { }); }, - $composeBuffer: function(data, hashId, key) { + $composeBuffer: function(data, hashId, key, e) { // Initialize the data object. if (data.state == null || data.buffer == null) { data.state = "start"; @@ -102,17 +102,23 @@ StateHandler.prototype = { data.buffer = bufferToUse; } - return { - bufferToUse: bufferToUse, - symbolicName: symbolicName + var bufferObj = { + bufferToUse: bufferToUse, + 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. 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) { var match; @@ -127,7 +133,7 @@ StateHandler.prototype = { } // 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; } @@ -194,20 +200,21 @@ StateHandler.prototype = { /** * 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. // 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))) { return null; } // 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 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) { console.log("KeyboardStateMapper#match", buffer, symbolicName, r); } From 147709312c9b7ab1300c6fe2d288103072971afc Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Wed, 30 Nov 2011 11:56:17 +0100 Subject: [PATCH 3/5] Avoids multiple duplicate messages in the gutter title. --- lib/ace/layer/gutter.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ace/layer/gutter.js b/lib/ace/layer/gutter.js index f5f527f3..71f2c132 100644 --- a/lib/ace/layer/gutter.js +++ b/lib/ace/layer/gutter.js @@ -84,7 +84,9 @@ var Gutter = function(parentEl) { }; for (var i=0; i Date: Wed, 30 Nov 2011 17:42:38 +0100 Subject: [PATCH 4/5] Small fixes in `keybinding.js` --- lib/ace/keyboard/keybinding.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/ace/keyboard/keybinding.js b/lib/ace/keyboard/keybinding.js index e1ab4faf..02ef6992 100644 --- a/lib/ace/keyboard/keybinding.js +++ b/lib/ace/keyboard/keybinding.js @@ -39,7 +39,6 @@ define(function(require, exports, module) { -var useragent = require("../lib/useragent"); var keyUtil = require("../lib/keys"); var event = require("../lib/event"); require("../commands/default_commands"); @@ -76,8 +75,9 @@ var KeyBinding = function(editor) { }; this.$callKeyboardHandlers = function (hashId, keyString, keyCode, e) { + var toExecute; for (var i = this.$handlers.length; i--;) { - var toExecute = this.$handlers[i].handleKeyboard( + toExecute = this.$handlers[i].handleKeyboard( this.$data, hashId, keyString, keyCode, e ); if (toExecute && toExecute.command) @@ -86,7 +86,9 @@ var KeyBinding = function(editor) { if (!toExecute || !toExecute.command) return false; - var success = false, commands = this.$editor.commands; + + var success = false; + var commands = this.$editor.commands; // allow keyboardHandler to consume keys if (toExecute.command != "null") @@ -97,13 +99,13 @@ var KeyBinding = function(editor) { if (success && e) event.stopEvent(e); - return success + return success; }; this.handleKeyboard = function(data, hashId, keyString) { return { command: this.$editor.commands.findKeyCommand(hashId, keyString) - } + }; }; this.onCommandKey = function(e, hashId, keyCode) { From 6e40a7d210819a295c5a60a05d943b0e846fc48d Mon Sep 17 00:00:00 2001 From: mikedeboer Date: Wed, 30 Nov 2011 18:31:49 +0100 Subject: [PATCH 5/5] check for delta.lines --- lib/ace/edit_session.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index 544a635c..eb5a8a6f 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -956,10 +956,12 @@ var EditSession = function(text, mode) { var removedFolds = null; if (action.indexOf("Lines") != -1) { - if (action == "insertLines") { - lastRow = firstRow + (e.data.lines.length); - } else { - lastRow = firstRow; + if (e.data.lines) { + if (action == "insertLines" && e.data.lines) { + lastRow = firstRow + (e.data.lines.length); + } else { + lastRow = firstRow; + } } len = e.data.lines ? e.data.lines.length : lastRow - firstRow; } else {