mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 13:31:49 +00:00
Transfer LFUN_CITATION_INSERT to BufferView
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31469 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
09f96833bf
commit
e80a46ba4f
@ -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 <key>|<text_before>
|
||||
// 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;
|
||||
}
|
||||
|
@ -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 <key>|<text_before>
|
||||
// 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;
|
||||
|
Loading…
Reference in New Issue
Block a user