]> git.lyx.org Git - lyx.git/commitdiff
reimplement citation-insert, which is needed by bibliography managers, as discussed...
authorJürgen Spitzmüller <spitz@lyx.org>
Fri, 7 Oct 2005 14:51:39 +0000 (14:51 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Fri, 7 Oct 2005 14:51:39 +0000 (14:51 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10529 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/LyXAction.C
src/lfuns.h
src/lyxfunc.C

index ff33553b42030fd81a241bb8d08756d296d3fc9e..7e3f5c0a3e7fa13a2144af82652fab703a5c9ec9 100644 (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>
 
        * BufferView_pimpl.C (update): choose arguments to update call so
index 97cd7949c661a16676241c4d7c9ef2a1aaca2581..baad18941243cb12a9bc0ef98a3e6a7219dadefd 100644 (file)
@@ -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 },
index fc930af6b01a7a9115afbca7796be0a45050405b..0ab0a1b15e5eb6314b660acd61c88d511838073e 100644 (file)
@@ -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
 };
index 274ff9678e57a053bf7917f45d33028228d9baa6..5429843cfd30bd1054cfd18f4b6c3711fd70a5fb 100644 (file)
@@ -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 <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: {
                        string const filename =
                                MakeAbsPath(argument, owner->buffer()->filePath());