Merge pull request #160 from cormier/previous-buffer
PR#155 with shortcut added in front page instructions close #155
This commit is contained in:
commit
5b5082dfd4
3 changed files with 24 additions and 5 deletions
|
@ -112,6 +112,7 @@
|
|||
<li>ALT+l: Focus on input bar</li>
|
||||
<li>ALT-[0-9]: Focus on buffer</li>
|
||||
<li>ALT-a: Focus on next buffer with activity</li>
|
||||
<li>ALT-<: Switch to previous buffer</li>
|
||||
<li>CTRL+G: Focus on buffer list filter</li>
|
||||
<li>escape: disconnect</li>
|
||||
<li>arrow keys: history navigation</li>
|
||||
|
|
|
@ -1021,6 +1021,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();
|
||||
|
|
18
js/models.js
18
js/models.js
|
@ -328,9 +328,8 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
|||
|
||||
|
||||
var BufferList = [];
|
||||
activeBuffer = null;
|
||||
unreads = 0;
|
||||
notifications = 0;
|
||||
var activeBuffer = null;
|
||||
var previousBuffer = null;
|
||||
|
||||
this.model = { 'buffers': {} };
|
||||
|
||||
|
@ -343,7 +342,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
|||
this.addBuffer = function(buffer) {
|
||||
BufferList[buffer.id] = buffer;
|
||||
if (BufferList.length === 1) {
|
||||
activeBuffer = buffer.id;
|
||||
activeBuffer = buffer;
|
||||
}
|
||||
this.model.buffers[buffer.id] = buffer;
|
||||
};
|
||||
|
@ -368,6 +367,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 +388,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