http://bugzilla.lyx.org/show_bug.cgi?id=961
The attached patch reimplements those lfuns. It also fixes InsetBibtex::delDatabase, which is broken in 1.3. The only drawback is that the lfuns are not working when the cursor sits behind the inset. The same applies to 1.3. The reason is that getInsetByCode stops at the end of the document. OK to apply? Jürgen
Index: BufferView_pimpl.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.584 diff -u -r1.584 BufferView_pimpl.C --- BufferView_pimpl.C 31 May 2005 14:40:23 -0000 1.584 +++ BufferView_pimpl.C 3 Jun 2005 13:14:31 -0000 @@ -51,6 +51,7 @@ #include "undo.h" #include "vspace.h" +#include "insets/insetbibtex.h" #include "insets/insetref.h" #include "insets/insettext.h" @@ -987,6 +988,8 @@ case LFUN_MARK_ON: case LFUN_SETMARK: case LFUN_CENTER: + case LFUN_BIBDB_ADD: + case LFUN_BIBDB_DEL: case LFUN_WORDS_COUNT: flag.enabled(true); break; @@ -1211,6 +1214,24 @@ case LFUN_CENTER: center(); break; + + case LFUN_BIBDB_ADD: { + InsetBibtex * inset = + getInsetByCode<InsetBibtex>(cursor_, + InsetBase::BIBTEX_CODE); + if (inset) + inset->addDatabase(cmd.argument); + break; + } + + case LFUN_BIBDB_DEL: { + InsetBibtex * inset = + getInsetByCode<InsetBibtex>(cursor_, + InsetBase::BIBTEX_CODE); + if (inset) + inset->delDatabase(cmd.argument); + break; + } case LFUN_WORDS_COUNT: { DocIterator from, to; Index: LyXAction.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.C,v retrieving revision 1.206 diff -u -r1.206 LyXAction.C --- LyXAction.C 8 May 2005 10:02:37 -0000 1.206 +++ LyXAction.C 3 Jun 2005 13:14:31 -0000 @@ -188,6 +188,8 @@ { LFUN_INSERT_LABEL, "label-insert", Noop }, { LFUN_INSET_OPTARG, "optional-insert", Noop }, { LFUN_INSERT_BIBITEM, "bibitem-insert", Noop }, + { LFUN_BIBDB_ADD, "bibtex-database-add", Noop }, + { LFUN_BIBDB_DEL, "bibtex-database-del", Noop }, { LFUN_INSERT_LINE, "line-insert", Noop }, { LFUN_INSERT_PAGEBREAK, "pagebreak-insert", Noop }, { LFUN_LANGUAGE, "language", Noop }, Index: lfuns.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lfuns.h,v retrieving revision 1.41 diff -u -r1.41 lfuns.h --- lfuns.h 8 May 2005 10:02:37 -0000 1.41 +++ lfuns.h 3 Jun 2005 13:14:32 -0000 @@ -355,6 +355,8 @@ // 270 LFUN_WORDS_COUNT, LFUN_OUTPUT_CHANGES, // jspitzm 20050121 + LFUN_BIBDB_ADD, + LFUN_BIBDB_DEL, LFUN_LASTACTION // end of the table }; Index: insets/insetbibtex.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbibtex.C,v retrieving revision 1.54 diff -u -r1.54 insetbibtex.C --- insets/insetbibtex.C 17 May 2005 11:11:45 -0000 1.54 +++ insets/insetbibtex.C 3 Jun 2005 13:14:36 -0000 @@ -283,16 +283,17 @@ bool InsetBibtex::delDatabase(string const & db) { - if (contains(getContents(), db)) { + string contents(getContents()); + if (contains(contents, db)) { + int const n = tokenPos(contents, ',', db); string bd = db; - int const n = tokenPos(getContents(), ',', bd); if (n > 0) { - // Weird code, would someone care to explain this?(Lgb) - string tmp(", "); - tmp += bd; - setContents(subst(getContents(), tmp, ", ")); + // this is not the first database + string tmp = ',' + bd; + setContents(subst(contents, tmp, "")); } else if (n == 0) - setContents(split(getContents(), bd, ',')); + // this is the first (or only) database + setContents(split(contents, bd, ',')); else return false; }