App-Mxpress-PDF
view release on metacpan or search on metacpan
public/javascripts/ace/keybinding-emacs.js view on Meta::CPAN
eMods[hashId] = c.toLowerCase() + "-";
});
exports.handler.onCopy = function(e, editor) {
if (editor.$handlesEmacsOnCopy) return;
editor.$handlesEmacsOnCopy = true;
exports.handler.commands.killRingSave.exec(editor);
editor.$handlesEmacsOnCopy = false;
};
exports.handler.onPaste = function(e, editor) {
editor.pushEmacsMark(editor.getCursorPosition());
};
exports.handler.bindKey = function(key, command) {
if (typeof key == "object")
key = key[this.platform];
if (!key)
return;
var ckb = this.commandKeyBinding;
key.split("|").forEach(function(keyPart) {
keyPart = keyPart.toLowerCase();
ckb[keyPart] = command;
var keyParts = keyPart.split(" ").slice(0,-1);
keyParts.reduce(function(keyMapKeys, keyPart, i) {
var prefix = keyMapKeys[i-1] ? keyMapKeys[i-1] + ' ' : '';
return keyMapKeys.concat([prefix + keyPart]);
}, []).forEach(function(keyPart) {
if (!ckb[keyPart]) ckb[keyPart] = "null";
});
}, this);
};
exports.handler.getStatusText = function(editor, data) {
var str = "";
if (data.count)
str += data.count;
if (data.keyChain)
str += " " + data.keyChain;
return str;
};
exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
if (keyCode === -1) return undefined;
var editor = data.editor;
editor._signal("changeStatus");
if (hashId == -1) {
editor.pushEmacsMark();
if (data.count) {
var str = new Array(data.count + 1).join(key);
data.count = null;
return {command: "insertstring", args: str};
}
}
var modifier = eMods[hashId];
if (modifier == "c-" || data.count) {
var count = parseInt(key[key.length - 1]);
if (typeof count === 'number' && !isNaN(count)) {
data.count = Math.max(data.count, 0) || 0;
data.count = 10 * data.count + count;
return {command: "null"};
}
}
if (modifier) key = modifier + key;
if (data.keyChain) key = data.keyChain += " " + key;
var command = this.commandKeyBinding[key];
data.keyChain = command == "null" ? key : "";
if (!command) return undefined;
if (command === "null") return {command: "null"};
if (command === "universalArgument") {
data.count = -4;
return {command: "null"};
}
var args;
if (typeof command !== "string") {
args = command.args;
if (command.command) command = command.command;
if (command === "goorselect") {
command = editor.emacsMark() ? args[1] : args[0];
args = null;
}
}
if (typeof command === "string") {
if (command === "insertstring" ||
command === "splitline" ||
command === "togglecomment") {
editor.pushEmacsMark();
}
command = this.commands[command] || editor.commands.commands[command];
if (!command) return undefined;
}
if (!command.readOnly && !command.isYank)
data.lastCommand = null;
if (!command.readOnly && editor.emacsMark())
editor.setEmacsMark(null);
if (data.count) {
var count = data.count;
data.count = 0;
if (!command || !command.handlesCount) {
return {
args: args,
command: {
exec: function(editor, args) {
for (var i = 0; i < count; i++)
command.exec(editor, args);
},
multiSelectAction: command.multiSelectAction
}
};
} else {
if (!args) args = {};
if (typeof args === 'object') args.count = count;
}
( run in 0.590 second using v1.01-cache-2.11-cpan-ceb78f64989 )