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
This commit is contained in:
Jürgen Spitzmüller 2005-10-07 14:51:39 +00:00
parent ebcb289b7c
commit 504dfddf35
4 changed files with 39 additions and 0 deletions

View File

@ -1,3 +1,10 @@
2005-10-07 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* LyXAction.C:
* lfuns.h:
* lyxfunc.C: reimplement LFUN_INSERT_CITATION, which is needed
by bibliography managers (bug 2071).
2005-10-07 Martin Vermeer <martin.vermeer@hut.fi> 2005-10-07 Martin Vermeer <martin.vermeer@hut.fi>
* BufferView_pimpl.C (update): choose arguments to update call so * BufferView_pimpl.C (update): choose arguments to update call so

View File

@ -188,6 +188,7 @@ void LyXAction::init()
{ LFUN_INSERT_LABEL, "label-insert", Noop }, { LFUN_INSERT_LABEL, "label-insert", Noop },
{ LFUN_INSET_OPTARG, "optional-insert", Noop }, { LFUN_INSET_OPTARG, "optional-insert", Noop },
{ LFUN_INSERT_BIBITEM, "bibitem-insert", Noop }, { LFUN_INSERT_BIBITEM, "bibitem-insert", Noop },
{ LFUN_INSERT_CITATION, "citation-insert", Noop },
{ LFUN_BIBDB_ADD, "bibtex-database-add", Noop }, { LFUN_BIBDB_ADD, "bibtex-database-add", Noop },
{ LFUN_BIBDB_DEL, "bibtex-database-del", Noop }, { LFUN_BIBDB_DEL, "bibtex-database-del", Noop },
{ LFUN_INSERT_LINE, "line-insert", Noop }, { LFUN_INSERT_LINE, "line-insert", Noop },

View File

@ -357,6 +357,7 @@ enum kb_action {
LFUN_OUTPUT_CHANGES, // jspitzm 20050121 LFUN_OUTPUT_CHANGES, // jspitzm 20050121
LFUN_BIBDB_ADD, LFUN_BIBDB_ADD,
LFUN_BIBDB_DEL, LFUN_BIBDB_DEL,
LFUN_INSERT_CITATION,
LFUN_LASTACTION // end of the table LFUN_LASTACTION // end of the table
}; };

View File

@ -536,6 +536,12 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
break; 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 // this one is difficult to get right. As a half-baked
// solution, we consider only the first action of the sequence // solution, we consider only the first action of the sequence
case LFUN_SEQUENCE: { case LFUN_SEQUENCE: {
@ -1246,6 +1252,30 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
owner->getDialogs().disconnect(argument); owner->getDialogs().disconnect(argument);
break; break;
case LFUN_INSERT_CITATION: {
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) + ']';
}
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: { case LFUN_CHILDOPEN: {
string const filename = string const filename =
MakeAbsPath(argument, owner->buffer()->filePath()); MakeAbsPath(argument, owner->buffer()->filePath());