]> git.lyx.org Git - lyx.git/blobdiff - src/MenuBackend.C
last Friday's text*.C -> text_func shuffle
[lyx.git] / src / MenuBackend.C
index 9a506537b07022445ae917812f37f949a463f6f5..9eb756c7f8527726690294299aa85fa1cf8cea57 100644 (file)
@@ -27,6 +27,7 @@
 #include "importer.h"
 #include "FloatList.h"
 #include "toc.h"
+#include "CutAndPaste.h"
 #include "frontends/LyXView.h"
 #include "support/LAssert.h"
 #include "support/filetools.h"
@@ -39,6 +40,8 @@
 extern BufferList bufferlist;
 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
 
+using namespace lyx::support;
+
 using std::endl;
 using std::vector;
 using std::max;
@@ -65,6 +68,7 @@ MenuItem::MenuItem(Kind kind, string const & label,
        case ImportFormats:
        case FloatListInsert:
        case FloatInsert:
+       case PasteRecent:
                break;
        case Command:
                action_ = lyxaction.LookupFunc(command);
@@ -199,6 +203,7 @@ Menu & Menu::read(LyXLex & lex)
                md_viewformats,
                md_floatlistinsert,
                md_floatinsert,
+               md_pasterecent,
                md_last
        };
 
@@ -213,6 +218,7 @@ Menu & Menu::read(LyXLex & lex)
                { "lastfiles", md_lastfiles },
                { "optitem", md_optitem },
                { "optsubmenu", md_optsubmenu },
+               { "pasterecent", md_pasterecent },
                { "separator", md_separator },
                { "submenu", md_submenu },
                { "toc", md_toc },
@@ -283,6 +289,10 @@ Menu & Menu::read(LyXLex & lex)
                        add(MenuItem(MenuItem::FloatInsert));
                        break;
 
+               case md_pasterecent:
+                       add(MenuItem(MenuItem::PasteRecent));
+                       break;
+
                case md_optsubmenu:
                        optional = true;
                        // fallback to md_submenu
@@ -607,6 +617,22 @@ void expandToc(Menu & tomenu, LyXView const * view)
 }
 
 
+void expandPasteRecent(Menu & tomenu, LyXView const * view)
+{
+       vector<string> const selL =
+               CutAndPaste::availableSelections(*view->buffer());
+
+       vector<string>::const_iterator cit = selL.begin();
+       vector<string>::const_iterator end = selL.end();
+
+       for (unsigned int index = 0; cit != end; ++cit, ++index) {
+               int const action = lyxaction.getPseudoAction(LFUN_PASTE,
+                                                            tostr(index));
+               tomenu.add(MenuItem(MenuItem::Command, *cit, action));
+       }
+}
+
+
 } // namespace anon
 
 
@@ -639,6 +665,10 @@ void MenuBackend::expand(Menu const & frommenu, Menu & tomenu,
                        expandFloatInsert(tomenu, view);
                        break;
 
+               case MenuItem::PasteRecent:
+                       expandPasteRecent(tomenu, view);
+                       break;
+
                case MenuItem::Toc:
                        expandToc(tomenu, view);
                        break;
@@ -752,7 +782,7 @@ Menu const & MenuBackend::getMenu(string const & name) const
                                     lyx::compare_memfun(&Menu::name, name));
        if (cit == end())
                lyxerr << "No submenu named " << name << endl;
-       lyx::Assert(cit != end());
+       Assert(cit != end());
        return (*cit);
 }
 
@@ -762,7 +792,7 @@ Menu & MenuBackend::getMenu(string const & name)
        MenuList::iterator it =
                find_if(menulist_.begin(), menulist_.end(),
                        lyx::compare_memfun(&Menu::name, name));
-       lyx::Assert(it != menulist_.end());
+       Assert(it != menulist_.end());
        return (*it);
 }