]> git.lyx.org Git - lyx.git/blobdiff - src/MenuBackend.C
move some selection related stuff over to textcursor.C
[lyx.git] / src / MenuBackend.C
index c9beb750722f8b35d52a8447b6897575ee9086ae..3ce73b3636b7e20b8c8c2ab615200c2ee398a7bc 100644 (file)
@@ -11,7 +11,6 @@
 
 #include <config.h>
 
-#include <algorithm>
 #include "MenuBackend.h"
 #include "lyxlex.h"
 #include "LyXAction.h"
 #include "importer.h"
 #include "FloatList.h"
 #include "toc.h"
+#include "CutAndPaste.h"
 #include "frontends/LyXView.h"
 #include "support/LAssert.h"
 #include "support/filetools.h"
 #include "support/lyxfunctional.h"
 #include "support/lstrings.h"
+#include "support/tostr.h"
+
+#include <algorithm>
 
 extern BufferList bufferlist;
 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
@@ -63,6 +66,7 @@ MenuItem::MenuItem(Kind kind, string const & label,
        case ImportFormats:
        case FloatListInsert:
        case FloatInsert:
+       case PasteRecent:
                break;
        case Command:
                action_ = lyxaction.LookupFunc(command);
@@ -197,6 +201,7 @@ Menu & Menu::read(LyXLex & lex)
                md_viewformats,
                md_floatlistinsert,
                md_floatinsert,
+               md_pasterecent,
                md_last
        };
 
@@ -211,6 +216,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 },
@@ -281,6 +287,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
@@ -605,6 +615,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
 
 
@@ -637,6 +663,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;