New keybinding: Alt-< to switch to previous buffer. Same key as WeeChat
This commit is contained in:
parent
0bfbd3eb0b
commit
2aa1e02bea
2 changed files with 21 additions and 1 deletions
|
@ -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();
|
||||
|
|
12
js/models.js
12
js/models.js
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue