From 504dfddf3517477a736885a9417421540c729f29 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Fri, 7 Oct 2005 14:51:39 +0000 Subject: [PATCH] reimplement citation-insert, which is needed by bibliography managers, as discussed on bugzilla (bug 2071) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10529 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 7 +++++++ src/LyXAction.C | 1 + src/lfuns.h | 1 + src/lyxfunc.C | 30 ++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+) diff --git a/src/ChangeLog b/src/ChangeLog index ff33553b42..7e3f5c0a3e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2005-10-07 Jürgen Spitzmüller + + * LyXAction.C: + * lfuns.h: + * lyxfunc.C: reimplement LFUN_INSERT_CITATION, which is needed + by bibliography managers (bug 2071). + 2005-10-07 Martin Vermeer * BufferView_pimpl.C (update): choose arguments to update call so diff --git a/src/LyXAction.C b/src/LyXAction.C index 97cd7949c6..baad189412 100644 --- a/src/LyXAction.C +++ b/src/LyXAction.C @@ -188,6 +188,7 @@ void LyXAction::init() { LFUN_INSERT_LABEL, "label-insert", Noop }, { LFUN_INSET_OPTARG, "optional-insert", Noop }, { LFUN_INSERT_BIBITEM, "bibitem-insert", Noop }, + { LFUN_INSERT_CITATION, "citation-insert", Noop }, { LFUN_BIBDB_ADD, "bibtex-database-add", Noop }, { LFUN_BIBDB_DEL, "bibtex-database-del", Noop }, { LFUN_INSERT_LINE, "line-insert", Noop }, diff --git a/src/lfuns.h b/src/lfuns.h index fc930af6b0..0ab0a1b15e 100644 --- a/src/lfuns.h +++ b/src/lfuns.h @@ -357,6 +357,7 @@ enum kb_action { LFUN_OUTPUT_CHANGES, // jspitzm 20050121 LFUN_BIBDB_ADD, LFUN_BIBDB_DEL, + LFUN_INSERT_CITATION, LFUN_LASTACTION // end of the table }; diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 274ff9678e..5429843cfd 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -536,6 +536,12 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const break; } + case LFUN_INSERT_CITATION: { + FuncRequest fr(LFUN_INSET_INSERT, "citation"); + enable = getStatus(fr).enabled(); + break; + } + // this one is difficult to get right. As a half-baked // solution, we consider only the first action of the sequence case LFUN_SEQUENCE: { @@ -1246,6 +1252,30 @@ void LyXFunc::dispatch(FuncRequest const & cmd) owner->getDialogs().disconnect(argument); break; + + case LFUN_INSERT_CITATION: { + 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) + ']'; + } + std::ostringstream os; + os << "citation LatexCommand\n" + << "\\cite" << opt1 << "{" << arg << "}\n" + << "\\end_inset"; + FuncRequest fr(LFUN_INSET_INSERT, os.str()); + dispatch(fr); + } else + dispatch(FuncRequest(LFUN_DIALOG_SHOW, "citation")); + break; + } + case LFUN_CHILDOPEN: { string const filename = MakeAbsPath(argument, owner->buffer()->filePath()); -- 2.39.2