]> git.lyx.org Git - features.git/commitdiff
Move LFUN_GRAPHICS_EDIT and LFUN_EXTERNAL_EDIT from LyXFunc.cpp to BufferView.cpp...
authorBo Peng <bpeng@lyx.org>
Mon, 24 Mar 2008 04:27:43 +0000 (04:27 +0000)
committerBo Peng <bpeng@lyx.org>
Mon, 24 Mar 2008 04:27:43 +0000 (04:27 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23910 a592a061-630c-0410-9148-cb99ea01b6c8

lib/ui/stdmenus.inc
src/BufferView.cpp
src/LyXFunc.cpp
src/insets/InsetExternal.cpp
src/insets/InsetGraphics.cpp
src/insets/InsetGraphics.h
src/insets/InsetListings.cpp
src/insets/InsetListings.h

index 0d43e5e87e2a8e1ac0e7af991fce16c6a81af7f1..20d02e961169e837d641f3e6607f9135a8961dcc 100644 (file)
@@ -601,4 +601,19 @@ Menuset
                Item "Remove Last Parameter Spitting Out To The Right" "math-macro-remove-greedy-param"
        End
 
+       Menu "context-listings"
+               Item "Cut" "cut"
+               Item "Copy" "copy"
+               Item "Paste" "paste"
+               Submenu "Paste Recent|e" "edit_pasterecent"
+               Separator
+               Item "Settings...|S" "inset-settings listings"
+       End
+       
+       Menu "context-graphics"
+               Item "Edit...|E" "graphics-edit"
+               Separator
+               Item "Settings...|S" "next-inset-toggle"
+       End
+
 End
index 4d763e7c319f3947d30820b25975f276471f7c99..95bb417f87cf849785c63661bbd4feb974857f29 100644 (file)
@@ -55,6 +55,8 @@
 
 #include "insets/InsetBibtex.h"
 #include "insets/InsetCommand.h" // ChangeRefs
+#include "insets/InsetExternal.h"
+#include "insets/InsetGraphics.h"
 #include "insets/InsetRef.h"
 #include "insets/InsetText.h"
 
@@ -846,6 +848,8 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
        case LFUN_FONT_STATE:
        case LFUN_LABEL_INSERT:
        case LFUN_INFO_INSERT:
+       case LFUN_EXTERNAL_EDIT:
+       case LFUN_GRAPHICS_EDIT:
        case LFUN_PARAGRAPH_GOTO:
        case LFUN_NOTE_NEXT:
        case LFUN_REFERENCE_NEXT:
@@ -1030,6 +1034,25 @@ bool BufferView::dispatch(FuncRequest const & cmd)
                        gotoLabel(label);
                break;
        }
+       
+       case LFUN_EXTERNAL_EDIT: {
+               FuncRequest fr(cmd);
+               InsetExternal * inset = getInsetByCode<InsetExternal>(d->cursor_,
+                       EXTERNAL_CODE);
+               if (inset)
+                       inset->dispatch(d->cursor_, fr);
+               break;
+       }
+
+
+       case LFUN_GRAPHICS_EDIT: {
+               FuncRequest fr(cmd);
+               InsetGraphics * inset = getInsetByCode<InsetGraphics>(d->cursor_,
+                       GRAPHICS_CODE);
+               if (inset)
+                       inset->dispatch(d->cursor_, fr);
+               break;
+       }
 
        case LFUN_PARAGRAPH_GOTO: {
                int const id = convert<int>(to_utf8(cmd.argument()));
index 4df6aa1074af0f0fad0e807e1a88af84e63d9545..380d601b82c9605c7d4c52c56c184c9512b89ef4 100644 (file)
@@ -1440,23 +1440,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        lyx_view_->message(from_utf8(argument));
                        break;
 
-               case LFUN_EXTERNAL_EDIT: {
-                       BOOST_ASSERT(lyx_view_);
-                       FuncRequest fr(action, argument);
-                       InsetExternal ie;
-                       ie.setBuffer(*lyx_view_->buffer());
-                       ie.dispatch(view()->cursor(), fr);
-                       break;
-               }
-
-               case LFUN_GRAPHICS_EDIT: {
-                       BOOST_ASSERT(lyx_view_);
-                       FuncRequest fr(action, argument);
-                       InsetGraphics ig;
-                       ig.setBuffer(*lyx_view_->buffer());
-                       ig.dispatch(view()->cursor(), fr);
-                       break;
-               }
 
                case LFUN_ALL_INSETS_TOGGLE: {
                        BOOST_ASSERT(lyx_view_);
index 79d47ca8a519aa2b3ee085b0792cc406c0799c17..fcfef733c8a00522f2ad306e7f830fa0444aac7d 100644 (file)
@@ -452,8 +452,9 @@ void InsetExternal::doDispatch(Cursor & cur, FuncRequest & cmd)
        switch (cmd.action) {
 
        case LFUN_EXTERNAL_EDIT: {
-               InsetExternalParams p;
-               InsetExternalMailer::string2params(to_utf8(cmd.argument()), buffer(), p);
+               InsetExternalParams p =  params();
+               if (!cmd.argument().empty())
+                       InsetExternalMailer::string2params(to_utf8(cmd.argument()), buffer(), p);
                external::editExternal(p, buffer());
                break;
        }
index 0953912cf970e013586565a1d8ccaf50cef3e333..af7a279ec99dc8926833e37ae22b1b85c283bca3 100644 (file)
@@ -175,8 +175,9 @@ void InsetGraphics::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
        switch (cmd.action) {
        case LFUN_GRAPHICS_EDIT: {
-               InsetGraphicsParams p;
-               InsetGraphicsMailer::string2params(to_utf8(cmd.argument()), buffer(), p);
+               InsetGraphicsParams p = params();
+               if (!cmd.argument().empty())
+                       InsetGraphicsMailer::string2params(to_utf8(cmd.argument()), buffer(), p);
                editGraphics(p, buffer());
                break;
        }
@@ -939,6 +940,12 @@ void InsetGraphics::addToToc(ParConstIterator const & cpit) const
 }
 
 
+docstring InsetGraphics::contextMenu(BufferView const &, int, int) const
+{
+       return from_ascii("context-graphics");
+}
+
+
 string const InsetGraphicsMailer::name_("graphics");
 
 InsetGraphicsMailer::InsetGraphicsMailer(InsetGraphics & inset)
index b5c8043c23a38bd2f1ee57bb805be4cb8f37cce7..281e3057c2e9f482918237f94835b438175e5102 100644 (file)
@@ -84,6 +84,8 @@ public:
        void updateEmbeddedFile(EmbeddedFile const &);
        ///
        void addToToc(ParConstIterator const &) const;
+       ///
+       docstring contextMenu(BufferView const & bv, int x, int y) const;
 
        /// Force inset into LTR environment if surroundings are RTL?
        virtual bool forceLTR() const { return true; }
index 2768b831da270634d08b25c3d79c843fe9f32f74..99d8552b74eccf5ecefb3a40fb2f06470281bdcf 100644 (file)
@@ -197,6 +197,12 @@ int InsetListings::latex(odocstream & os, OutputParams const & runparams) const
 }
 
 
+docstring InsetListings::contextMenu(BufferView const &, int, int) const
+{
+       return from_ascii("context-listings");
+}
+
+
 void InsetListings::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
        switch (cmd.action) {
index 13efb881d15ef15c05816fb578d720601a583615..d21bda8ce6b538dac157e32c60f0e34d73ca4619 100644 (file)
@@ -56,6 +56,9 @@ public:
        InsetListingsParams const & params() const { return params_; }
        ///
        InsetListingsParams & params() { return params_; }
+       ///
+       docstring contextMenu(BufferView const & bv, int x, int y) const;
+
 private:
        ///
        void doDispatch(Cursor & cur, FuncRequest & cmd);