diff --git a/src/BufferView.cpp b/src/BufferView.cpp index cce0932f98..61a40a2ead 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -1146,6 +1146,14 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag) flag.setEnabled(!cur.inset().getLayout().isPassThru()); break; + case LFUN_CITATION_INSERT: { + FuncRequest fr(LFUN_INSET_INSERT, "citation"); + // FIXME: This could turn in a recursive hell. + // Shouldn't we use Buffer::getStatus() instead? + flag.setEnabled(lyx::getStatus(fr).enabled()); + break; + } + default: flag.setEnabled(false); return false; @@ -1790,6 +1798,31 @@ bool BufferView::dispatch(FuncRequest const & cmd) break; } + case LFUN_CITATION_INSERT: { + if (argument.empty()) { + lyx::dispatch(FuncRequest(LFUN_DIALOG_SHOW_NEW_INSET, "citation")); + break; + } + // we can have one optional argument, delimited by '|' + // citation-insert | + // this should be enhanced to also support text_after + // and citation style + string arg = argument; + string opt1; + if (contains(argument, "|")) { + arg = token(argument, '|', 0); + opt1 = token(argument, '|', 1); + } + InsetCommandParams icp(CITE_CODE); + icp["key"] = from_utf8(arg); + if (!opt1.empty()) + icp["before"] = from_utf8(opt1); + string icstr = InsetCommand::params2string("citation", icp); + FuncRequest fr(LFUN_INSET_INSERT, icstr); + lyx::dispatch(fr); + break; + } + default: return false; } diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index 2dda89129e..3f4bd1481e 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -58,8 +58,6 @@ #include "Session.h" #include "SpellChecker.h" -#include "insets/InsetCommand.h" - #include "frontends/alert.h" #include "frontends/Application.h" #include "frontends/KeySymbol.h" @@ -366,12 +364,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const bool enable = true; switch (cmd.action) { - case LFUN_CITATION_INSERT: { - FuncRequest fr(LFUN_INSET_INSERT, "citation"); - enable = getStatus(fr).enabled(); - break; - } - // This could be used for the no-GUI version. The GUI version is handled in // LyXView::getStatus(). See above. /* @@ -579,31 +571,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd) theServer().notifyClient(to_utf8(dispatch_buffer)); break; - case LFUN_CITATION_INSERT: { - LASSERT(lv, /**/); - if (!argument.empty()) { - // we can have one optional argument, delimited by '|' - // citation-insert | - // this should be enhanced to also support text_after - // and citation style - string arg = argument; - string opt1; - if (contains(argument, "|")) { - arg = token(argument, '|', 0); - opt1 = token(argument, '|', 1); - } - InsetCommandParams icp(CITE_CODE); - icp["key"] = from_utf8(arg); - if (!opt1.empty()) - icp["before"] = from_utf8(opt1); - string icstr = InsetCommand::params2string("citation", icp); - FuncRequest fr(LFUN_INSET_INSERT, icstr); - dispatch(fr); - } else - dispatch(FuncRequest(LFUN_DIALOG_SHOW_NEW_INSET, "citation")); - break; - } - case LFUN_CURSOR_FOLLOWS_SCROLLBAR_TOGGLE: LASSERT(lv, /**/); lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;