--- blackbox/lib/Menu.cc 2003-12-13 15:49:31.000000000 -0500 +++ blackbox_incsearch/lib/Menu.cc 2003-12-13 15:52:20.000000000 -0500 @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -603,6 +604,17 @@ void bt::Menu::show(void) { if (isVisible()) return; + + currInc = ""; + ItemList::iterator i = _items.begin(); + const ItemList::iterator &end = _items.end(); + while(i != end) { + if(i->isTempDisabled() && isItemEnabled(i->id()) == false) { + i->disabled(false); + setItemEnabled(i->id(), true); + } + i++; + } if (menudelay.hidemenu == this) menudelay.hidemenu = 0; @@ -1057,6 +1069,50 @@ } break; } + + case XK_Tab: { + // For inc search, we want to save these results and + // restart.. Should act similar to the bash tab-complete + currInc = ""; + break; + } + + default: { + // No matches, you are mine.. All mine! + char ans[1]; + KeySym ffo; + XKeyEvent * evv = (XKeyEvent *)event; + int len = XLookupString(evv, ans, 1, &ffo, 0); + + if(ans != NULL && len == 1) { + currInc += ans[0]; + ItemList::iterator i = _items.begin(); + const ItemList::iterator &end = _items.end(); + int c = 0; + MenuItem *mi; + mi = &(*i); // Fix for compiler warning. + while(i != end) { + if(i->label().find(currInc) == std::string::npos) { + setItemEnabled(i->id(), false); + i->disabled(true); + } else if(isItemEnabled(i->id())) { + mi = &(*i); + if(c++ == 0) activateIndex(i->index()); + } + i++; + } + if(c == 0) { // There is nothing left + hide(); + } else if(c == 1) { + if (mi->sub) { + activateSubmenu(); + } else { + itemClicked(mi->id(), 1); + hideAll(); + } + } + } + } // default } // switch } --- blackbox/lib/Menu.hh 2003-12-13 15:49:32.000000000 -0500 +++ blackbox_incsearch/lib/Menu.hh 2003-12-13 15:29:11.000000000 -0500 @@ -36,7 +36,6 @@ #include #include - namespace bt { class Application; @@ -52,14 +51,15 @@ active(0), title(0), enabled(1), checked(0) { } inline MenuItem(Menu *s, const std::string& l) : sub(s), lbl(l), ident(~0u), indx(~0u), height(0), separator(0), - active(0), title(0), enabled(1), checked(0) { } + active(0), title(0), enabled(1), checked(0), _disabled(false) { } bool isSeparator(void) const { return bool(separator); } bool isActive(void) const { return bool(active); } bool isTitle(void) const { return bool(title); } bool isEnabled(void) const { return bool(enabled); } bool isChecked(void) const { return bool(checked); } - + bool isTempDisabled(void) const { return _disabled; } + void disabled(bool d) { _disabled = d;} unsigned int id(void) const { return ident; } unsigned int index(void) const { return indx; } @@ -67,6 +67,7 @@ const std::string& label(void) const { return lbl; } + private: Menu *sub; std::string lbl; @@ -79,6 +80,8 @@ unsigned int enabled : 1; unsigned int checked : 1; + bool _disabled; + friend class Menu; }; @@ -277,6 +280,8 @@ bool _size_dirty; bool _show_title; bool _visible; + + std::string currInc; };