shortcuts: implement switching buffer using ALT-number
This commit is contained in:
parent
5cf635bc70
commit
6271dc6577
11
js/models.js
11
js/models.js
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue