Begining of key binding

This commit is contained in:
2014-11-10 13:40:24 +01:00
parent 20a06686b9
commit 169b8397dc
2 changed files with 28 additions and 1 deletions

View File

@@ -181,6 +181,13 @@ function Buffer (client, buffId, path) {
this.remove = function (off, length, callback) { this.remove = function (off, length, callback) {
client.callFunction("remove", buffId, Types.position(off), length, callback); client.callFunction("remove", buffId, Types.position(off), length, callback);
}; };
var keysCallback = {};
this.registerKey = function (key, callback) {
client.specialKeys(key);
Object.defineProperty(keysCallback, key, { value: callback, configurable: true});
};
} }
util.inherits(Buffer, EventEmitter); util.inherits(Buffer, EventEmitter);

View File

@@ -277,6 +277,18 @@ function Controler(socket, authentication) {
buffers[buffId].emit.apply(buffers[buffId], Array.prototype.slice.call(arguments, 1)); buffers[buffId].emit.apply(buffers[buffId], Array.prototype.slice.call(arguments, 1));
delete buffers[buffId]; delete buffers[buffId];
} }
break;
case event.keyAtPos :
//Call the key registered callback if it exists.
var buffer = getBuffer(buffId);
if (keysCallback.indexOf(arguments[2]) >= 0) {
keysCallback.call(null, buffer, arguments[3].split("/")[0], arguments[3].split("/")[1]);
}
else if (buffer === undefined) {
}
break; break;
case event.fileOpened : case event.fileOpened :
//File opened. Check if it's already managed by controler. //File opened. Check if it's already managed by controler.
@@ -401,7 +413,7 @@ function Controler(socket, authentication) {
client.callFunction("getCursor", 0, callback); client.callFunction("getCursor", 0, callback);
}; };
/* CONNTROLER CONTROL */ /* CONTROLER CONTROL */
//Close the underlying connexion with Vim, but not Vim //Close the underlying connexion with Vim, but not Vim
this.detach = function () { this.detach = function () {
@@ -430,6 +442,14 @@ function Controler(socket, authentication) {
return buffers[buffId]; return buffers[buffId];
} }
}; };
var keysCallback = {};
this.registerKey = function (key, callback) {
self.specialKeys(key);
Object.defineProperty(keysCallback, key, { value: callback, configurable: true});
}
} }
util.inherits(Controler, EventEmitter); util.inherits(Controler, EventEmitter);