shortcuts: implement switching buffer using ALT-number

This commit is contained in:
David Cormier 2013-10-12 12:54:13 -04:00
parent 5cf635bc70
commit 6271dc6577
2 changed files with 24 additions and 0 deletions

View file

@ -115,6 +115,17 @@ models.service('models', ['colors', function(colors) {
this.model.buffers[buffer.id] = buffer;
}
this.getBufferByIndex = function(index) {
var i = 0;
for (var v in BufferList) {
if (index == ++i) {
return BufferList[v];
}
}
}
/*
* Returns the current active buffer
*

View file

@ -536,6 +536,19 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
// Support different browser quirks
var code = $event.keyCode ? $event.keyCode : $event.charCode;
if ($event.altKey && (code > 47 && code < 58)) {
if (code == 48) {
code = 58;
}
var bufferNumber = code - 48;
var activeBuffer = models.getBufferByIndex(bufferNumber);
if (activeBuffer) {
models.setActiveBuffer(activeBuffer.id);
$event.preventDefault();
}
}
//console.log('keypress', $event.charCode, $event.altKey);
// Handle alt-a