From bbb4d259be6cf3637fdeec30da7a24e48ef50aed Mon Sep 17 00:00:00 2001 From: Magnus Hauge Bakke Date: Mon, 4 Apr 2016 12:04:34 +0200 Subject: [PATCH] Use arrow keys to select buffer in buffer search --- css/glowingbear.css | 6 ++++++ css/themes/dark.css | 5 +++++ css/themes/light.css | 5 +++++ index.html | 2 +- js/glowingbear.js | 24 +++++++++++++++++++++++- 5 files changed, 40 insertions(+), 2 deletions(-) diff --git a/css/glowingbear.css b/css/glowingbear.css index 33719e2..235f292 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -285,6 +285,12 @@ input[type=text], input[type=password], #sendMessage { color: #222; } +.nav-pills > li.highlight > a, .nav-pills > li.highlight > a span { + text-decoration: none; + color: #fff; + background: #428BCA; +} + .nav-pills > li > a { display: block; overflow: hidden; diff --git a/css/themes/dark.css b/css/themes/dark.css index 8d303aa..0e73900 100644 --- a/css/themes/dark.css +++ b/css/themes/dark.css @@ -35,6 +35,11 @@ html { color: #222; } +.nav-pills > li.highlight > a, .nav-pills > li.highlight > a span { + color: #fff; + background: #428BCA; +} + tr.bufferline:hover { background-color: #222222; } diff --git a/css/themes/light.css b/css/themes/light.css index 6a5c109..0ed9c14 100644 --- a/css/themes/light.css +++ b/css/themes/light.css @@ -22,6 +22,11 @@ html { background-color: #222; } +.nav-pills > li.highlight > a, .nav-pills > li.highlight > a span { + color: #fff; + background: #428BCA; +} + .btn-send, .btn-send-image, { background: none repeat scroll 0% 0% rgba(255, 255, 255, 0.3); diff --git a/index.html b/index.html index 4db5a59..211fd50 100644 --- a/index.html +++ b/index.html @@ -259,7 +259,7 @@ $ openssl req -nodes -newkey rsa:4096 -keyout relay.pem -x509 -days 365 -out rel -
  • +
  • {{ buffer.$quickKey }} diff --git a/js/glowingbear.js b/js/glowingbear.js index b2ee72f..63bd15f 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -750,17 +750,39 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $scope.handleSearchBoxKey = function($event) { // Support different browser quirks var code = $event.keyCode ? $event.keyCode : $event.charCode; + // Handle escape if (code === 27) { $event.preventDefault(); $scope.search = ''; } // Handle enter else if (code === 13) { + var index; $event.preventDefault(); if ($scope.filteredBuffers.length > 0) { - $scope.setActiveBuffer($scope.filteredBuffers[0].id); + // Go to highlighted buffer if available + // or first one + if ($scope.search_highlight_key) { + index = $scope.search_highlight_key; + } else { + index = 0; + } + $scope.setActiveBuffer($scope.filteredBuffers[index].id); } $scope.search = ''; + } // Handle arrow up + else if (code === 38) { + $event.preventDefault(); + if ($scope.search_highlight_key && $scope.search_highlight_key > 0) { + $scope.search_highlight_key = $scope.search_highlight_key - 1; + } + } // Handle arrow down and tab + else if (code === 40 || code === 9) { + $event.preventDefault(); + $scope.search_highlight_key = $scope.search_highlight_key + 1; + } // Set highlight key to zero on all other keypress + else { + $scope.search_highlight_key = 0; } };