diff --git a/lib/configure.py b/lib/configure.py index 6cfc27bd4e..d74c8d2df1 100644 --- a/lib/configure.py +++ b/lib/configure.py @@ -276,6 +276,13 @@ def checkFormatEntries(dtl_tools): \Format text3 txt "Plain text (ps2ascii)" "" "" "%%" "document" \Format text4 txt "Plain text (catdvi)" "" "" "%%" "document" \Format textparagraph txt "Plain Text, Join Lines" "" "" "%%" "document"''' ]) + # + checkViewer('a BibTeX editor', ['sensible-editor', 'pybliographic', 'bibdesk', 'gbib', 'kbib', \ + 'kbibtex', 'sixpack', 'bibedit', 'tkbibtex' \ + 'xemacs', 'gvim', 'kedit', 'kwrite', 'kate', \ + 'nedit', 'gedit', 'notepad'], + rc_entry = [r'''\Format asciichess asc "Plain text (chess output)" "" "" "%%" "" +\Format bibtex bib "BibTeX" "" "" "%%" ""''' ]) # #checkProg('a Postscript interpreter', ['gs'], # rc_entry = [ r'\ps_command "%%"' ]) diff --git a/lib/ui/stdcontext.inc b/lib/ui/stdcontext.inc index 69ae783a4b..7ae39fc6f5 100644 --- a/lib/ui/stdcontext.inc +++ b/lib/ui/stdcontext.inc @@ -83,10 +83,6 @@ Menuset Item "Settings...|S" "next-inset-toggle" End - Menu "edit_reftype" - - End - # # InsetLabel context menu # @@ -97,6 +93,17 @@ Menuset Item "Settings...|S" "next-inset-toggle" End + +# +# InsetBibtex context menu +# + Menu "context-bibtex" + Item "Settings...|S" "next-inset-toggle" + Separator + Item "Edit Database(s) externally...|x" "inset-edit" + End + + # # InsetCollapsable context menu # diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index 4394992e96..b1053e0147 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -17,7 +17,9 @@ #include "BufferParams.h" #include "DispatchResult.h" #include "Encoding.h" +#include "Format.h" #include "FuncRequest.h" +#include "FuncStatus.h" #include "LaTeXFeatures.h" #include "MetricsInfo.h" #include "OutputParams.h" @@ -25,6 +27,7 @@ #include "frontends/alert.h" +#include "support/convert.h" #include "support/debug.h" #include "support/docstream.h" #include "support/ExceptionMessage.h" @@ -67,6 +70,10 @@ void InsetBibtex::doDispatch(Cursor & cur, FuncRequest & cmd) { switch (cmd.action) { + case LFUN_INSET_EDIT: + editDatabases(); + break; + case LFUN_INSET_MODIFY: { InsetCommandParams p(BIBTEX_CODE); try { @@ -96,6 +103,49 @@ void InsetBibtex::doDispatch(Cursor & cur, FuncRequest & cmd) } +bool InsetBibtex::getStatus(Cursor & cur, FuncRequest const & cmd, + FuncStatus & flag) const +{ + switch (cmd.action) { + case LFUN_INSET_EDIT: + flag.enabled(true); + return true; + + default: + return InsetCommand::getStatus(cur, cmd, flag); + } +} + + +void InsetBibtex::editDatabases() const +{ + vector bibfilelist = getVectorFromString(getParam("bibfiles")); + + if (bibfilelist.empty()) + return; + + int nr_databases = bibfilelist.size(); + if (nr_databases > 1) { + docstring message = bformat(_("The BibTeX inset includes %1$s databases.\n" + "If you proceed, all of them will be opened."), + convert(nr_databases)); + int const ret = Alert::prompt(_("Open Databases?"), + message, 0, 1, _("&Cancel"), _("&Proceed")); + + if (ret == 0) + return; + } + + vector::const_iterator it = bibfilelist.begin(); + vector::const_iterator en = bibfilelist.end(); + for (; it != en; ++it) { + FileName bibfile = getBibTeXPath(*it, buffer()); + formats.edit(buffer(), bibfile, + formats.getFormatFromFile(bibfile)); + } +} + + docstring InsetBibtex::screenLabel() const { return _("BibTeX Generated Bibliography"); @@ -808,4 +858,10 @@ void InsetBibtex::validate(LaTeXFeatures & features) const } +docstring InsetBibtex::contextMenu(BufferView const &, int, int) const +{ + return from_ascii("context-bibtex"); +} + + } // namespace lyx diff --git a/src/insets/InsetBibtex.h b/src/insets/InsetBibtex.h index b7c8438f37..e8bd176b70 100644 --- a/src/insets/InsetBibtex.h +++ b/src/insets/InsetBibtex.h @@ -59,10 +59,17 @@ public: /// look up the path to the file using TeX static support::FileName getBibTeXPath(docstring const & filename, Buffer const & buf); + /// + docstring contextMenu(BufferView const &, int, int) const; private: /// void doDispatch(Cursor & cur, FuncRequest & cmd); /// + bool getStatus(Cursor & cur, FuncRequest const & cmd, + FuncStatus & flag) const; + /// + void editDatabases() const; + /// Inset * clone() const { return new InsetBibtex(*this); } };