Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update ace

  • Loading branch information...
commit 3b07d9473e268a6c52ad45845462801e090d7cac 1 parent 49c236b
@nightwing nightwing authored
View
6 .xpiignore
@@ -1,4 +1,2 @@
-exclude chrome/content/ace/
-include chrome/content/ace/build/src/theme-\.*
-include chrome/content/ace/build/src/(theme|keybinding|ace)-\.*
-include chrome/content/ace/build/src/mode-(html|xml|coffee|svg)\.*
+exclude chrome/content/ace++/(boot|consoleOutputMode|edit-protocol-editor|editApp|fbeditor-devel|log-view).js
+exclude chrome/content/ace++/(log-view|simple-editor).html
View
9 chrome/content/ace++/fbeditor.html
@@ -27,7 +27,7 @@
var aceRoot = './res/ace/';
var PATHS = {
'ace/theme/' : aceRoot + 'theme-',
- 'ace/keyboard/keybinding/': aceRoot + 'keybinding-',
+ 'ace/keyboard/' : aceRoot + 'keybinding-',
'ace/mode/' : aceRoot + 'mode-',
'fbace/' : '',
'res/' : 'res/',
@@ -128,11 +128,10 @@
}
if (typeof module === 'function') {
- var exports = {};
- module(require, exports, { id: moduleName, uri: '' });
+ var exports = {}, req = require, mod = {id: moduleName, uri: ''};
+ module(req, exports, mod);
// cache the resulting module object for next time
- require.modules[moduleName] = exports;
- return exports;
+ return require.modules[moduleName] = mod.exports || exports;
}
return module;
View
12 chrome/content/ace++/res/ace/ace-uncompressed.js
@@ -5200,7 +5200,7 @@ oop.inherits(CommandManager, HashHandler);
return true;
};
- this.toggleRecording = function() {
+ this.toggleRecording = function(editor) {
if (this.$inReplay)
return;
if (this.recording) {
@@ -5210,7 +5210,7 @@ oop.inherits(CommandManager, HashHandler);
if (!this.macro.length)
this.macro = this.oldMacro;
- editor.status.set("");
+ //editor && editor.status.set("");
return this.recording = false;
}
this.oldMacro = this.macro;
@@ -5220,7 +5220,7 @@ oop.inherits(CommandManager, HashHandler);
this.macro.push([command, args]);
return this.normal_exec(command, editor, args);
};
- editor.status.set("recording_macro");
+ //editor && editor.status.set("recording_macro");
return this.recording = true;
};
@@ -5233,7 +5233,7 @@ oop.inherits(CommandManager, HashHandler);
try {
this.$inReplay = true;
- editor.status.set("in_replay");
+ //editor.status.set("in_replay");
this.macro.forEach(function(x) {
if (typeof x == "string")
this.exec(x, editor);
@@ -5242,7 +5242,7 @@ oop.inherits(CommandManager, HashHandler);
}, this)
} finally {
this.$inReplay = false;
- editor.status.set("replay_finished", 2);
+ //editor && editor.status.set("replay_finished", 2);
}
};
@@ -5499,7 +5499,7 @@ exports.commands = [{
}, {
name: "togglerecording",
bindKey: bindKey("Ctrl-Alt-E", "Command-Option-E"),
- exec: function(editor) { editor.commands.toggleRecording(); },
+ exec: function(editor) { editor.commands.toggleRecording(editor); },
readOnly: true
}, {
name: "replaymacro",
View
335 chrome/content/ace++/res/ace/keybinding-vim.js
@@ -527,44 +527,39 @@ module.exports = {
onVisualLineMode: false,
currentMode: 'normal',
insertMode: function(editor) {
- var _self = this;
- var theme = editor && editor.getTheme() || "ace/theme/textmate";
-
- require(["require", theme], function (require) {
- var isDarkTheme = require(theme).isDark;
-
- _self.currentMode = 'insert';
- // Switch editor to insert mode
- editor.unsetStyle('insert-mode');
-
- var cursor = document.getElementsByClassName("ace_cursor")[0];
- if (cursor) {
- cursor.style.display = null;
- cursor.style.backgroundColor = null;
- cursor.style.opacity = null;
- cursor.style.border = null;
- cursor.style.borderLeftColor = isDarkTheme? "#eeeeee" : "#333333";
- cursor.style.borderLeftStyle = "solid";
- cursor.style.borderLeftWidth = "2px";
- }
-
- editor.setOverwrite(false);
- editor.keyBinding.$data.buffer = "";
- editor.keyBinding.$data.state = "insertMode";
- _self.onVisualMode = false;
- _self.onVisualLineMode = false;
- if(_self.onInsertReplaySequence) {
- // Ok, we're apparently replaying ("."), so let's do it
- editor.commands.macro = _self.onInsertReplaySequence;
- editor.commands.replay(editor);
- _self.onInsertReplaySequence = null;
- _self.normalMode(editor);
- } else {
- // Record any movements, insertions in insert mode
- if(!editor.commands.recording)
- editor.commands.toggleRecording();
- }
- });
+ var isDarkTheme = editor.container.className.indexOf("ace_dark") != -1;
+
+ this.currentMode = 'insert';
+ // Switch editor to insert mode
+ editor.unsetStyle('insert-mode');
+
+ var cursor = document.getElementsByClassName("ace_cursor")[0];
+ if (cursor) {
+ cursor.style.display = null;
+ cursor.style.backgroundColor = null;
+ cursor.style.opacity = null;
+ cursor.style.border = null;
+ cursor.style.borderLeftColor = isDarkTheme? "#eeeeee" : "#333333";
+ cursor.style.borderLeftStyle = "solid";
+ cursor.style.borderLeftWidth = "2px";
+ }
+
+ editor.setOverwrite(false);
+ editor.keyBinding.$data.buffer = "";
+ editor.keyBinding.$data.state = "insertMode";
+ this.onVisualMode = false;
+ this.onVisualLineMode = false;
+ if(this.onInsertReplaySequence) {
+ // Ok, we're apparently replaying ("."), so let's do it
+ editor.commands.macro = this.onInsertReplaySequence;
+ editor.commands.replay(editor);
+ this.onInsertReplaySequence = null;
+ this.normalMode(editor);
+ } else {
+ // Record any movements, insertions in insert mode
+ if(!editor.commands.recording)
+ editor.commands.toggleRecording();
+ }
},
normalMode: function(editor) {
// Switch editor to normal mode
@@ -609,9 +604,9 @@ module.exports = {
},
getLeftNthChar: function(editor, cursor, char, n) {
var line = editor.getSession().getLine(cursor.row);
- var matches = line.substr(0, cursor.column + 1).split(char);
+ var matches = line.substr(0, cursor.column).split(char);
- return n < matches.length ? matches.slice(-1 * n).join(char).length + 1: 0;
+ return n < matches.length ? matches.slice(-1 * n).join(char).length + 2 : 0;
},
toRealChar: function(char) {
if (char.length === 1)
@@ -746,6 +741,14 @@ module.exports = {
editor.selection.selectWordRight();
}
},
+ "shift-w": {
+ nav: function(editor) {
+ editor.navigateWordRight();
+ },
+ sel: function(editor) {
+ editor.selection.selectWordRight();
+ }
+ },
"b": {
nav: function(editor) {
editor.navigateWordLeft();
@@ -754,6 +757,14 @@ module.exports = {
editor.selection.selectWordLeft();
}
},
+ "shift-b": {
+ nav: function(editor) {
+ editor.navigateWordLeft();
+ },
+ sel: function(editor) {
+ editor.selection.selectWordLeft();
+ }
+ },
"l": {
nav: function(editor) {
editor.navigateRight();
@@ -839,6 +850,30 @@ module.exports = {
}
}
},
+ "shift-f": {
+ param: true,
+ nav: function(editor, range, count, param) {
+ count = parseInt(count, 10) || 1;
+ var ed = editor;
+ var cursor = ed.getCursorPosition();
+ var column = util.getLeftNthChar(editor, cursor, param, count);
+
+ if (typeof column === "number") {
+ ed.selection.clearSelection(); // Why does it select in the first place?
+ ed.moveCursorTo(cursor.row, cursor.column - column + 1);
+ }
+ },
+ sel: function(editor, range, count, param) {
+ count = parseInt(count, 10) || 1;
+ var ed = editor;
+ var cursor = ed.getCursorPosition();
+ var column = util.getLeftNthChar(editor, cursor, param, count);
+
+ if (typeof column === "number") {
+ ed.moveCursorTo(cursor.row, cursor.column - column + 1);
+ }
+ }
+ },
"t": {
param: true,
nav: function(editor, range, count, param) {
@@ -1233,8 +1268,6 @@ module.exports = {
define("ace/keyboard/vim/registers",[], function(require, exports, module) {
-"never use strict";
-
module.exports = {
_default: {
text: "",
@@ -1244,3 +1277,221 @@ module.exports = {
});
+define("ace/keyboard/state_handler",[], function(require, exports, module) {
+
+// If you're developing a new keymapping and want to get an idea what's going
+// on, then enable debugging.
+var DEBUG = false;
+
+function StateHandler(keymapping) {
+ this.keymapping = this.$buildKeymappingRegex(keymapping);
+}
+
+StateHandler.prototype = {
+ /**
+ * Build the RegExp from the keymapping as RegExp can't stored directly
+ * in the metadata JSON and as the RegExp used to match the keys/buffer
+ * need to be adapted.
+ */
+ $buildKeymappingRegex: function(keymapping) {
+ for (var state in keymapping) {
+ this.$buildBindingsRegex(keymapping[state]);
+ }
+ return keymapping;
+ },
+
+ $buildBindingsRegex: function(bindings) {
+ // Escape a given Regex string.
+ bindings.forEach(function(binding) {
+ if (binding.key) {
+ binding.key = new RegExp('^' + binding.key + '$');
+ } else if (Array.isArray(binding.regex)) {
+ if (!('key' in binding))
+ binding.key = new RegExp('^' + binding.regex[1] + '$');
+ binding.regex = new RegExp(binding.regex.join('') + '$');
+ } else if (binding.regex) {
+ binding.regex = new RegExp(binding.regex + '$');
+ }
+ });
+ },
+
+ $composeBuffer: function(data, hashId, key, e) {
+ // Initialize the data object.
+ if (data.state == null || data.buffer == null) {
+ data.state = "start";
+ data.buffer = "";
+ }
+
+ var keyArray = [];
+ if (hashId & 1) keyArray.push("ctrl");
+ if (hashId & 8) keyArray.push("command");
+ if (hashId & 2) keyArray.push("option");
+ if (hashId & 4) keyArray.push("shift");
+ if (key) keyArray.push(key);
+
+ var symbolicName = keyArray.join("-");
+ var bufferToUse = data.buffer + symbolicName;
+
+ // Don't add the symbolic name to the key buffer if the alt_ key is
+ // part of the symbolic name. If it starts with alt_, this means
+ // that the user hit an alt keycombo and there will be a single,
+ // new character detected after this event, which then will be
+ // added to the buffer (e.g. alt_j will result in ∆).
+ //
+ // We test for 2 and not for & 2 as we only want to exclude the case where
+ // the option key is pressed alone.
+ if (hashId != 2) {
+ data.buffer = bufferToUse;
+ }
+
+ var bufferObj = {
+ bufferToUse: bufferToUse,
+ symbolicName: symbolicName,
+ };
+
+ if (e) {
+ bufferObj.keyIdentifier = e.keyIdentifier
+ }
+
+ return bufferObj;
+ },
+
+ $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 keymap until a match is found.
+ this.keymapping[data.state].some(function(binding) {
+ var match;
+
+ // Check if the key matches.
+ if (binding.key && !binding.key.test(symbolicName)) {
+ return false;
+ }
+
+ // Check if the regex matches.
+ if (binding.regex && !(match = binding.regex.exec(buffer))) {
+ return false;
+ }
+
+ // Check if the match function matches.
+ if (binding.match && !binding.match(buffer, hashId, key, symbolicName, keyIdentifier)) {
+ return false;
+ }
+
+ // Check for disallowed matches.
+ if (binding.disallowMatches) {
+ for (var i = 0; i < binding.disallowMatches.length; i++) {
+ if (!!match[binding.disallowMatches[i]]) {
+ return false;
+ }
+ }
+ }
+
+ // If there is a command to execute, then figure out the
+ // command and the arguments.
+ if (binding.exec) {
+ result.command = binding.exec;
+
+ // Build the arguments.
+ if (binding.params) {
+ var value;
+ result.args = {};
+ binding.params.forEach(function(param) {
+ if (param.match != null && match != null) {
+ value = match[param.match] || param.defaultValue;
+ } else {
+ value = param.defaultValue;
+ }
+
+ if (param.type === 'number') {
+ value = parseInt(value);
+ }
+
+ result.args[param.name] = value;
+ });
+ }
+ data.buffer = "";
+ }
+
+ // Handle the 'then' property.
+ if (binding.then) {
+ data.state = binding.then;
+ data.buffer = "";
+ }
+
+ // If no command is set, then execute the "null" fake command.
+ if (result.command == null) {
+ result.command = "null";
+ }
+
+ if (DEBUG) {
+ console.log("KeyboardStateMapper#find", binding);
+ }
+ return true;
+ });
+
+ if (result.command) {
+ return result;
+ } else {
+ data.buffer = "";
+ return false;
+ }
+ },
+
+ /**
+ * This function is called by keyBinding.
+ */
+ 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 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, e);
+ var buffer = r.bufferToUse;
+ var symbolicName = r.symbolicName;
+ var keyId = r.keyIdentifier;
+
+ r = this.$find(data, buffer, symbolicName, hashId, key, keyId);
+ if (DEBUG) {
+ console.log("KeyboardStateMapper#match", buffer, symbolicName, r);
+ }
+
+ return r;
+ }
+}
+
+/**
+ * This is a useful matching function and therefore is defined here so that
+ * users of KeyboardStateMapper can use it.
+ *
+ * @return boolean
+ * If no command key (Command|Option|Shift|Ctrl) is pressed, it
+ * returns true. If the only the Shift key is pressed + a character
+ * true is returned as well. Otherwise, false is returned.
+ * Summing up, the function returns true whenever the user typed
+ * a normal character on the keyboard and no shortcut.
+ */
+exports.matchCharacterOnly = function(buffer, hashId, key, symbolicName) {
+ // If no command keys are pressed, then catch the input.
+ if (hashId == 0) {
+ return true;
+ }
+ // If only the shift key is pressed and a character key, then
+ // catch that input as well.
+ else if ((hashId == 4) && key.length == 1) {
+ return true;
+ }
+ // Otherwise, we let the input got through.
+ else {
+ return false;
+ }
+};
+
+exports.StateHandler = StateHandler;
+});
+
View
6 chrome/content/ace++/startup.js
@@ -178,14 +178,14 @@ exports.launch = function(env, options) {
env.editor.setKeyboardHandler(null);
return;
}
- var path = "ace/keyboard/keybinding/" + name.toLowerCase();
+ var path = "ace/keyboard/" + name.toLowerCase();
var module = require(path);
if (!module)
require([path], function(module) {
- env.editor.setKeyboardHandler(env.editor.normalKeySet = module[name]);
+ env.editor.setKeyboardHandler(env.editor.normalKeySet = module.handler);
});
else
- env.editor.setKeyboardHandler(env.editor.normalKeySet = module[name]);
+ env.editor.setKeyboardHandler(env.editor.normalKeySet = module.handler);
};
//since we are using separate window make everything global for now
View
2  chrome/content/options.js
@@ -31,7 +31,7 @@ function makeReq(href) {
}
function getThemeNames() {
- var str = makeReq('chrome://acebug/content/ace/build/src/');
+ var str = makeReq('chrome://acebug/content/ace++/res/ace');
var themeNames = str.match(/theme-.*\.js/g).map(function(x) {
return x.slice(6, -3);
});
Please sign in to comment.
Something went wrong with that request. Please try again.