]> git.lyx.org Git - lyx.git/blobdiff - src/MenuBackend.C
Change to use preffered calling of Boost.Function
[lyx.git] / src / MenuBackend.C
index 180a98fbb93f41c2917dddb46fd6d909fb74dbc3..a4e02903c5b02db738fb7036efd1eca04ed58911 100644 (file)
@@ -137,13 +137,13 @@ string const MenuItem::binding() const
 
        // Get the keys bound to this action, but keep only the
        // first one later
-       string bindings = toplevel_keymap->findbinding(func_);
+       kb_keymap::Bindings bindings = toplevel_keymap->findbindings(func_);
 
-       if (!bindings.empty()) {
-               return bindings.substr(1, bindings.find(']') - 1);
+       if (bindings.size()) {
+               return bindings.begin()->print();
        } else {
                lyxerr[Debug::KBMAP]
-                       << "No bindings for "
+                       << "No binding for "
                        << lyxaction.getActionName(func_.action)
                        << '(' << func_.argument << ')' << endl;
                return string();
@@ -357,6 +357,20 @@ Menu & Menu::read(LyXLex & lex)
 }
 
 
+MenuItem const & Menu::operator[](size_type i) const
+{
+       return items_[i];
+}
+
+
+bool Menu::hasFunc(FuncRequest const & func) const
+{
+       return find_if(begin(), end(),
+                      bind(std::equal_to<FuncRequest>(),
+                           bind(&MenuItem::func, _1),
+                           func)) != end();
+}
+
 void Menu::checkShortcuts() const
 {
        // This is a quadratic algorithm, but we do not care because
@@ -383,6 +397,13 @@ void Menu::checkShortcuts() const
 }
 
 
+void MenuBackend::specialMenu(string const &name)
+{
+       if (hasMenu(name)) 
+               specialmenu_ = &getMenu(name);
+}
+
+
 namespace {
 
 class compare_format {
@@ -684,11 +705,11 @@ void expandPasteRecent(Menu & tomenu, LyXView const * view)
        if (!view || !view->buffer())
                return;
 
-       vector<string> const selL =
-               CutAndPaste::availableSelections(*view->buffer());
+       vector<string> const sel =
+               lyx::cap::availableSelections(*view->buffer());
 
-       vector<string>::const_iterator cit = selL.begin();
-       vector<string>::const_iterator end = selL.end();
+       vector<string>::const_iterator cit = sel.begin();
+       vector<string>::const_iterator end = sel.end();
 
        for (unsigned int index = 0; cit != end; ++cit, ++index) {
                tomenu.add(MenuItem(MenuItem::Command, *cit,
@@ -775,8 +796,14 @@ void MenuBackend::expand(Menu const & frommenu, Menu & tomenu,
                }
                break;
 
-               default:
+               case MenuItem::Separator:
                        tomenu.add(*cit, view);
+                       break;
+
+               case MenuItem::Command:
+                       if (!specialmenu_ 
+                           || !specialmenu_->hasFunc(cit->func()))
+                               tomenu.add(*cit, view);
                }
        }
 
@@ -790,27 +817,6 @@ void MenuBackend::expand(Menu const & frommenu, Menu & tomenu,
 }
 
 
-bool Menu::hasSubmenu(string const & name) const
-{
-#if 1
-       return find_if(begin(), end(),
-                      bind(std::equal_to<string>(),
-                           bind(&MenuItem::submenuname, _1),
-                           name)) != end();
-#else
-       // I would have prefered this, but I am not sure if it
-       // makes a difference. (Lgb)
-       return find_if(
-               make_transform_iterator(begin(),
-                                       bind(&MenuItem::submenuname, _1)),
-               make_transform_iterator(end(),
-                                       bind(&MenuItem::submenuname, _1)),
-               name
-               ).base() != end();
-#endif
-}
-
-
 void MenuBackend::read(LyXLex & lex)
 {
        enum Menutags {