aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/ITypeAheadable.hh
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/FbTk/ITypeAheadable.hh
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/FbTk/ITypeAheadable.hh')
-rw-r--r--src/FbTk/ITypeAheadable.hh15
1 files changed, 0 insertions, 15 deletions
diff --git a/src/FbTk/ITypeAheadable.hh b/src/FbTk/ITypeAheadable.hh
index 9c8e819..f3d432f 100644
--- a/src/FbTk/ITypeAheadable.hh
+++ b/src/FbTk/ITypeAheadable.hh
@@ -24,12 +24,6 @@
24 24
25#include "FbString.hh" 25#include "FbString.hh"
26 26
27#ifdef HAVE_CCTYPE
28 #include <cctype>
29#else
30 #include <ctype.h>
31#endif // HAVE_CCTYPE
32
33namespace FbTk { 27namespace FbTk {
34 28
35// abstract base class providing access and validation 29// abstract base class providing access and validation
@@ -39,15 +33,6 @@ public:
39 33
40 virtual const std::string &iTypeString() const = 0; 34 virtual const std::string &iTypeString() const = 0;
41 virtual bool isEnabled() const { return true; } 35 virtual bool isEnabled() const { return true; }
42 char iTypeChar(size_t i) const { return iTypeString()[i]; }
43 bool iTypeCheckStringSize(size_t sz) const {
44 return (iTypeString().size() > sz);
45 }
46 bool iTypeCompareChar(char ch, size_t sz) const {
47 return (bool)iTypeCheckStringSize(sz) &&
48 tolower(iTypeChar(sz)) == tolower(ch);
49 }
50
51}; 36};
52 37
53} // end namespace FbTk 38} // end namespace FbTk