#include "WordLangTuple.h"
#include "insets/InsetBibtex.h"
+#include "insets/InsetCitation.h"
#include "insets/InsetCommand.h" // ChangeRefs
#include "insets/InsetExternal.h"
#include "insets/InsetGraphics.h"
arg = token(argument, '|', 0);
opt1 = token(argument, '|', 1);
}
+
+ // if our cursor is direclty in front of or behind a citation inset,
+ // we will instead add the new key to it.
+ Inset * inset = cur.nextInset();
+ if (!inset || inset->lyxCode() != CITE_CODE)
+ inset = cur.prevInset();
+ if (inset->lyxCode() == CITE_CODE) {
+ InsetCitation * icite = static_cast<InsetCitation *>(inset);
+ if (icite->addKey(arg)) {
+ dr.forceBufferUpdate();
+ dr.screenUpdate(Update::FitCursor | Update::SinglePar);
+ if (!opt1.empty())
+ LYXERR0("Discarding optional argument to citation-insert.");
+ }
+ dispatched = true;
+ break;
+ }
InsetCommandParams icp(CITE_CODE);
icp["key"] = from_utf8(arg);
if (!opt1.empty())
}
+bool InsetCitation::addKey(string const & key)
+{
+ docstring const ukey = from_utf8(key);
+ docstring const & curkeys = getParam("key");
+ if (curkeys.empty()) {
+ setParam("key", ukey);
+ cache.recalculate = true;
+ return true;
+ }
+
+ vector<docstring> keys = getVectorFromString(curkeys);
+ vector<docstring>::const_iterator it = keys.begin();
+ vector<docstring>::const_iterator en = keys.end();
+ for (; it != en; ++it) {
+ if (*it == ukey) {
+ LYXERR0("Key " << key << " already present.");
+ return false;
+ }
+ }
+ keys.push_back(ukey);
+ setParam("key", getStringFromVector(keys));
+ cache.recalculate = true;
+ return true;
+}
+
+
docstring InsetCitation::toolTip(BufferView const & bv, int, int) const
{
Buffer const & buf = bv.buffer();
#include "InsetCommand.h"
#include "Citation.h"
+#include "support/strfwd.h"
namespace lyx {
///
~InsetCitation();
+ ///
+ bool addKey(std::string const & key);
+
/// \name Public functions inherited from Inset class
//@{
///