Merge pull request #160 from cormier/previous-buffer

PR#155 with shortcut added in front page instructions
close #155
This commit is contained in:
David Cormier 2014-02-19 11:53:06 -05:00
commit 5b5082dfd4
3 changed files with 24 additions and 5 deletions

View file

@ -112,6 +112,7 @@
<li>ALT+l: Focus on input bar</li> <li>ALT+l: Focus on input bar</li>
<li>ALT-[0-9]: Focus on buffer</li> <li>ALT-[0-9]: Focus on buffer</li>
<li>ALT-a: Focus on next buffer with activity</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>CTRL+G: Focus on buffer list filter</li>
<li>escape: disconnect</li> <li>escape: disconnect</li>
<li>arrow keys: history navigation</li> <li>arrow keys: history navigation</li>

View file

@ -1021,6 +1021,16 @@ weechat.directive('inputBar', function() {
return true; 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 // Escape -> disconnect
if (code === 27) { if (code === 27) {
$event.preventDefault(); $event.preventDefault();

View file

@ -328,9 +328,8 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
var BufferList = []; var BufferList = [];
activeBuffer = null; var activeBuffer = null;
unreads = 0; var previousBuffer = null;
notifications = 0;
this.model = { 'buffers': {} }; this.model = { 'buffers': {} };
@ -343,7 +342,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
this.addBuffer = function(buffer) { this.addBuffer = function(buffer) {
BufferList[buffer.id] = buffer; BufferList[buffer.id] = buffer;
if (BufferList.length === 1) { if (BufferList.length === 1) {
activeBuffer = buffer.id; activeBuffer = buffer;
} }
this.model.buffers[buffer.id] = buffer; this.model.buffers[buffer.id] = buffer;
}; };
@ -368,6 +367,15 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
return activeBuffer; 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. * Sets the buffer specifiee by bufferId as active.
* Deactivates the previous current buffer. * Deactivates the previous current buffer.
@ -380,7 +388,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
key = 'id'; key = 'id';
} }
var previousBuffer = this.getActiveBuffer(); previousBuffer = this.getActiveBuffer();
activeBuffer = _.find(this.model.buffers, function(buffer) { activeBuffer = _.find(this.model.buffers, function(buffer) {
if (buffer[key] === bufferId) { if (buffer[key] === bufferId) {