comments for emacs handleKeyboard
This commit is contained in:
parent
9fd93a5e37
commit
a82fcd0dc2
1 changed files with 29 additions and 21 deletions
|
|
@ -164,6 +164,7 @@ exports.handler.bindKey = function(key, command) {
|
||||||
|
|
||||||
|
|
||||||
exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
|
exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
|
||||||
|
// insertstring data.count times
|
||||||
if (hashId == -1) {
|
if (hashId == -1) {
|
||||||
exports.setMarkMode(null);
|
exports.setMarkMode(null);
|
||||||
if (data.count) {
|
if (data.count) {
|
||||||
|
|
@ -177,6 +178,8 @@ exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var modifier = eMods[hashId];
|
var modifier = eMods[hashId];
|
||||||
|
|
||||||
|
// CTRL + number / universalArgument for setting data.count
|
||||||
if (modifier == "c-" || data.universalArgument) {
|
if (modifier == "c-" || data.universalArgument) {
|
||||||
var count = parseInt(key[key.length - 1]);
|
var count = parseInt(key[key.length - 1]);
|
||||||
if (count) {
|
if (count) {
|
||||||
|
|
@ -186,42 +189,47 @@ exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
|
||||||
}
|
}
|
||||||
data.universalArgument = false;
|
data.universalArgument = false;
|
||||||
|
|
||||||
if (modifier)
|
// this.commandKeyBinding maps key specs like "c-p" (for CTRL + P) to
|
||||||
key = modifier + key;
|
// command objects, for lookup key needs to include the modifier
|
||||||
|
if (modifier) key = modifier + key;
|
||||||
|
|
||||||
if (data.keyChain)
|
// Key combos like CTRL+X H build up the data.keyChain
|
||||||
key = data.keyChain += " " + key;
|
if (data.keyChain) key = data.keyChain += " " + key;
|
||||||
|
|
||||||
|
// Key combo prefixes get stored as "null" (String!) in this
|
||||||
|
// this.commmandKeyBinding. When encountered no command is invoked but we
|
||||||
|
// buld up data.keyChain
|
||||||
var command = this.commmandKeyBinding[key];
|
var command = this.commmandKeyBinding[key];
|
||||||
data.keyChain = command == "null" ? key : "";
|
data.keyChain = command == "null" ? key : "";
|
||||||
|
|
||||||
if (!command)
|
// there really is no command
|
||||||
return;
|
if (!command) return;
|
||||||
|
|
||||||
if (command == "null")
|
// we pass b/c of key combo or universalArgument
|
||||||
return {command: "null"};
|
if (command === "null") return {command: "null"};
|
||||||
|
|
||||||
if (command == "universalArgument") {
|
if (command === "universalArgument") {
|
||||||
data.universalArgument = true;
|
data.universalArgument = true;
|
||||||
return {command: "null"};
|
return {command: "null"};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof command != "string") {
|
// lookup command
|
||||||
var args = command.args;
|
// TODO extract special handling of markmode
|
||||||
command = command.command;
|
// TODO special case command.command is really unnecessary, remove
|
||||||
if (command == "goorselect") {
|
var args;
|
||||||
command = args[0];
|
if (typeof command !== "string") {
|
||||||
if (exports.markMode()) {
|
args = command.args;
|
||||||
command = args[1];
|
if (command.command) command = command.command;
|
||||||
}
|
if (command === "goorselect") {
|
||||||
|
command = exports.markMode() ? args[1] : args[0];
|
||||||
args = null;
|
args = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof command == "string") {
|
if (typeof command === "string") {
|
||||||
if (command == "insertstring" ||
|
if (command === "insertstring" ||
|
||||||
command == "splitline" ||
|
command === "splitline" ||
|
||||||
command == "togglecomment") {
|
command === "togglecomment") {
|
||||||
exports.setMarkMode(null);
|
exports.setMarkMode(null);
|
||||||
}
|
}
|
||||||
command = this.commands[command] || data.editor.commands.commands[command];
|
command = this.commands[command] || data.editor.commands.commands[command];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue