diff --git a/lib/ui/stdmenus.inc b/lib/ui/stdmenus.inc index 0d43e5e87e..20d02e9611 100644 --- a/lib/ui/stdmenus.inc +++ b/lib/ui/stdmenus.inc @@ -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 diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 4d763e7c31..95bb417f87 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -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(d->cursor_, + EXTERNAL_CODE); + if (inset) + inset->dispatch(d->cursor_, fr); + break; + } + + + case LFUN_GRAPHICS_EDIT: { + FuncRequest fr(cmd); + InsetGraphics * inset = getInsetByCode(d->cursor_, + GRAPHICS_CODE); + if (inset) + inset->dispatch(d->cursor_, fr); + break; + } case LFUN_PARAGRAPH_GOTO: { int const id = convert(to_utf8(cmd.argument())); diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index 4df6aa1074..380d601b82 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -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_); diff --git a/src/insets/InsetExternal.cpp b/src/insets/InsetExternal.cpp index 79d47ca8a5..fcfef733c8 100644 --- a/src/insets/InsetExternal.cpp +++ b/src/insets/InsetExternal.cpp @@ -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; } diff --git a/src/insets/InsetGraphics.cpp b/src/insets/InsetGraphics.cpp index 0953912cf9..af7a279ec9 100644 --- a/src/insets/InsetGraphics.cpp +++ b/src/insets/InsetGraphics.cpp @@ -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) diff --git a/src/insets/InsetGraphics.h b/src/insets/InsetGraphics.h index b5c8043c23..281e3057c2 100644 --- a/src/insets/InsetGraphics.h +++ b/src/insets/InsetGraphics.h @@ -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; } diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp index 2768b831da..99d8552b74 100644 --- a/src/insets/InsetListings.cpp +++ b/src/insets/InsetListings.cpp @@ -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) { diff --git a/src/insets/InsetListings.h b/src/insets/InsetListings.h index 13efb881d1..d21bda8ce6 100644 --- a/src/insets/InsetListings.h +++ b/src/insets/InsetListings.h @@ -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);