aboutsummaryrefslogtreecommitdiff
path: root/src/ClientMenu.cc
diff options
context:
space:
mode:
authorMathias Gumz <akira@fluxbox.org>2015-01-28 15:02:59 (GMT)
committerMathias Gumz <akira@fluxbox.org>2015-01-28 15:02:59 (GMT)
commit03ce82a4737b834767c03341db9362ada24c775a (patch)
tree2444031bbd47d97b1e0af64aa2f1d2a037a08a2e /src/ClientMenu.cc
parentfc245408d6975d0813cd4440e7089d987b54d42e (diff)
downloadfluxbox-03ce82a4737b834767c03341db9362ada24c775a.zip
fluxbox-03ce82a4737b834767c03341db9362ada24c775a.tar.bz2
Feature: typeahead in menu matches text anywhere
This commit implements a tweak to the typeahead feature already existent in fluxbox: If the user opens up a menu and starts typing, fluxbox tries to detect matching menu items and makes them available for quick selection. The typed pattern is now search also in the middle of the text. I opted to strip down the code quite a bit and remove complexity by throwing out FbTk::TypeAhead and FbTk::SearchResult because I do not see the need for a general solution when the only use case for such a feature is in fluxbox' menus. FbTk::ITypeAheadable shrunk down to 2 functions; the whole file might be combined with the code that implements FbTk::Menu::TypeSearch. FbTk::Menu::setIndex() and related code is also gone: the position of each menu item is defined by it's position in the items container. This reduces the mount of book keeping fluxbox has to do. Fewer moving parts is a good thing. It's possible that users start to complaint because they expect their typed pattern to match only at the beginning of the text OR that some demand other tweaks. We will see. This commit also fixes a regression introduced by 8387742c. The bug made the menu vanish.
Diffstat (limited to 'src/ClientMenu.cc')
-rw-r--r--src/ClientMenu.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/ClientMenu.cc b/src/ClientMenu.cc
index 84f2025..1a7417a 100644
--- a/src/ClientMenu.cc
+++ b/src/ClientMenu.cc
@@ -26,11 +26,12 @@
26#include "Window.hh" 26#include "Window.hh"
27#include "WindowCmd.hh" 27#include "WindowCmd.hh"
28#include "FocusControl.hh" 28#include "FocusControl.hh"
29#include <X11/keysym.h>
30 29
31#include "FbTk/MenuItem.hh" 30#include "FbTk/MenuItem.hh"
32#include "FbTk/MemFun.hh" 31#include "FbTk/MemFun.hh"
33 32
33#include <X11/keysym.h>
34
34namespace { // anonymous 35namespace { // anonymous
35 36
36class ClientMenuItem: public FbTk::MenuItem { 37class ClientMenuItem: public FbTk::MenuItem {
@@ -159,5 +160,5 @@ void ClientMenu::clientDied(Focusable &win) {
159 160
160 // update accordingly 161 // update accordingly
161 if (cl_item) 162 if (cl_item)
162 remove(cl_item->getIndex()); 163 FbTk::Menu::removeItem(cl_item);
163} 164}