use text mate keybindings for the macros. fix #534

This commit is contained in:
Fabian Jakobs 2011-11-28 16:02:49 +01:00
commit 09a04bdc32
3 changed files with 14 additions and 14 deletions

View file

@ -254,12 +254,12 @@ exports.commands = [{
readOnly: true readOnly: true
}, { }, {
name: "togglerecording", name: "togglerecording",
bindKey: bindKey("Ctrl-Shift-E", "Ctrl-Shift-E"), bindKey: bindKey("Ctrl-Alt-E", "Command-Option-E"),
exec: function(editor) { editor.commands.toggleRecording(); }, exec: function(editor) { editor.commands.toggleRecording(); },
readOnly: true readOnly: true
}, { }, {
name: "replaymacro", name: "replaymacro",
bindKey: bindKey("Ctrl-E", "Ctrl-E"), bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"),
exec: function(editor) { editor.commands.replay(editor); }, exec: function(editor) { editor.commands.replay(editor); },
readOnly: true readOnly: true
}, },

View file

@ -39,7 +39,6 @@
define(function(require, exports, module) { define(function(require, exports, module) {
var useragent = require("../lib/useragent");
var keyUtil = require("../lib/keys"); var keyUtil = require("../lib/keys");
var event = require("../lib/event"); var event = require("../lib/event");
require("../commands/default_commands"); require("../commands/default_commands");
@ -76,8 +75,9 @@ var KeyBinding = function(editor) {
}; };
this.$callKeyboardHandlers = function (hashId, keyString, keyCode, e) { this.$callKeyboardHandlers = function (hashId, keyString, keyCode, e) {
var toExecute;
for (var i = this.$handlers.length; i--;) { for (var i = this.$handlers.length; i--;) {
var toExecute = this.$handlers[i].handleKeyboard( toExecute = this.$handlers[i].handleKeyboard(
this.$data, hashId, keyString, keyCode, e this.$data, hashId, keyString, keyCode, e
); );
if (toExecute && toExecute.command) if (toExecute && toExecute.command)
@ -97,13 +97,13 @@ var KeyBinding = function(editor) {
if (success && e) if (success && e)
event.stopEvent(e); event.stopEvent(e);
return success return success;
}; };
this.handleKeyboard = function(data, hashId, keyString) { this.handleKeyboard = function(data, hashId, keyString) {
return { return {
command: this.$editor.commands.findKeyCommand(hashId, keyString) command: this.$editor.commands.findKeyCommand(hashId, keyString)
} };
}; };
this.onCommandKey = function(e, hashId, keyCode) { this.onCommandKey = function(e, hashId, keyCode) {

View file

@ -47,7 +47,7 @@ var TextInput = function(parentNode, host) {
var text = dom.createElement("textarea"); var text = dom.createElement("textarea");
if (useragent.isTouchPad) if (useragent.isTouchPad)
text.setAttribute("x-palm-disable-auto-cap", true); text.setAttribute("x-palm-disable-auto-cap", true);
text.style.left = "-10000px"; text.style.left = "-10000px";
parentNode.appendChild(text); parentNode.appendChild(text);
@ -201,7 +201,7 @@ var TextInput = function(parentNode, host) {
clipboardData.setData("Text", copyText); clipboardData.setData("Text", copyText);
host.onCut(); host.onCut();
} }
event.preventDefault(e) event.preventDefault(e);
} }
}); });
} }
@ -213,10 +213,10 @@ var TextInput = function(parentNode, host) {
event.addListener(text, "compositionstart", onCompositionStart); event.addListener(text, "compositionstart", onCompositionStart);
if (useragent.isGecko) { if (useragent.isGecko) {
event.addListener(text, "text", onCompositionUpdate); event.addListener(text, "text", onCompositionUpdate);
}; }
if (useragent.isWebKit) { if (useragent.isWebKit) {
event.addListener(text, "keyup", onCompositionUpdate); event.addListener(text, "keyup", onCompositionUpdate);
}; }
event.addListener(text, "compositionend", onCompositionEnd); event.addListener(text, "compositionend", onCompositionEnd);
event.addListener(text, "blur", function() { event.addListener(text, "blur", function() {
@ -240,7 +240,7 @@ var TextInput = function(parentNode, host) {
function isFocused() { function isFocused() {
return document.activeElement === text; return document.activeElement === text;
}; }
this.isFocused = isFocused; this.isFocused = isFocused;
this.getElement = function() { this.getElement = function() {
@ -254,12 +254,12 @@ var TextInput = function(parentNode, host) {
text.style.cssText = text.style.cssText =
'position:fixed; z-index:1000;' + 'position:fixed; z-index:1000;' +
'left:' + (mousePos.x - 2) + 'px; top:' + (mousePos.y - 2) + 'px;' 'left:' + (mousePos.x - 2) + 'px; top:' + (mousePos.y - 2) + 'px;';
} }
if (isEmpty) if (isEmpty)
text.value=''; text.value='';
} };
this.onContextMenuClose = function(){ this.onContextMenuClose = function(){
setTimeout(function () { setTimeout(function () {
@ -269,7 +269,7 @@ var TextInput = function(parentNode, host) {
} }
sendText(); sendText();
}, 0); }, 0);
} };
}; };
exports.TextInput = TextInput; exports.TextInput = TextInput;