New keybinding: Alt-< to switch to previous buffer. Same key as WeeChat

This commit is contained in:
Tor Hveem 2014-02-19 10:56:44 +01:00
parent 0bfbd3eb0b
commit 2aa1e02bea
2 changed files with 21 additions and 1 deletions

View file

@ -968,6 +968,16 @@ weechat.directive('inputBar', function() {
return true;
}
// Alt+< -> switch to previous buffer
if ($event.altKey && code === 60) {
var previousBuffer = models.getPreviousBuffer();
if (previousBuffer) {
models.setActiveBuffer(previousBuffer.id);
$event.preventDefault();
return true;
}
}
// Escape -> disconnect
if (code === 27) {
$event.preventDefault();

View file

@ -329,6 +329,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
var BufferList = [];
activeBuffer = null;
previousBuffer = null;
unreads = 0;
notifications = 0;
@ -368,6 +369,15 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
return activeBuffer;
};
/*
* Returns the previous current active buffer
*
* @return previous buffer object
*/
this.getPreviousBuffer = function() {
return previousBuffer;
};
/*
* Sets the buffer specifiee by bufferId as active.
* Deactivates the previous current buffer.
@ -380,7 +390,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
key = 'id';
}
var previousBuffer = this.getActiveBuffer();
previousBuffer = this.getActiveBuffer();
activeBuffer = _.find(this.model.buffers, function(buffer) {
if (buffer[key] === bufferId) {