diff --git a/index.html b/index.html index e62be31..62fc52e 100644 --- a/index.html +++ b/index.html @@ -112,6 +112,7 @@
  • ALT+l: Focus on input bar
  • ALT-[0-9]: Focus on buffer
  • ALT-a: Focus on next buffer with activity
  • +
  • ALT-<: Switch to previous buffer
  • CTRL+G: Focus on buffer list filter
  • escape: disconnect
  • arrow keys: history navigation
  • diff --git a/js/glowingbear.js b/js/glowingbear.js index c29e1ac..2160e04 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -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(); diff --git a/js/models.js b/js/models.js index 8c3cb38..ee38cd7 100644 --- a/js/models.js +++ b/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) {