mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Improve functions for bibliography managers (#8193)
- new function to list bibtex databases - citation-insert returns the list of undefined keys if the request comes from the LyX server Original patch from Benjamin Piwowarski (2012!). Modified and updated by Riki Heck and myself.
This commit is contained in:
parent
8d6a53f8f8
commit
9fc190d61c
@ -128,6 +128,10 @@
|
||||
|
||||
!!!The following new LyX functions have been introduced in 2.4:
|
||||
|
||||
* bibtex-database-list: output a list of all bibtex files used in the current buffer.
|
||||
The function outputs absolute paths in the OS style and separated by the os-specific
|
||||
path separator. This function is intended for bibliography managers.
|
||||
|
||||
* buffer-reset-export advises LyX to remove the auxiliary files before doing the next
|
||||
export.
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "Buffer.h"
|
||||
#include "BufferList.h"
|
||||
#include "BufferParams.h"
|
||||
#include "BiblioInfo.h"
|
||||
#include "CoordCache.h"
|
||||
#include "Cursor.h"
|
||||
#include "CutAndPaste.h"
|
||||
@ -69,6 +70,7 @@
|
||||
#include "support/convert.h"
|
||||
#include "support/debug.h"
|
||||
#include "support/docstring.h"
|
||||
#include "support/docstring_list.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lassert.h"
|
||||
@ -1223,6 +1225,7 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
|
||||
case LFUN_SCREEN_SHOW_CURSOR:
|
||||
case LFUN_BIBTEX_DATABASE_ADD:
|
||||
case LFUN_BIBTEX_DATABASE_DEL:
|
||||
case LFUN_BIBTEX_DATABASE_LIST:
|
||||
case LFUN_STATISTICS:
|
||||
case LFUN_KEYMAP_OFF:
|
||||
case LFUN_KEYMAP_PRIMARY:
|
||||
@ -1928,6 +1931,25 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_BIBTEX_DATABASE_LIST: {
|
||||
docstring_list const & files = buffer_.getBibfiles();
|
||||
bool first = true;
|
||||
docstring result;
|
||||
char const separator(os::path_separator());
|
||||
for (auto const & file : files) {
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
result += separator;
|
||||
|
||||
FileName const fn = buffer_.getBibfilePath(file);
|
||||
string const path = fn.realPath();
|
||||
result += from_utf8(os::external_path(path));
|
||||
}
|
||||
dr.setMessage(result);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_STATISTICS: {
|
||||
DocIterator from, to;
|
||||
if (cur.selection()) {
|
||||
@ -2281,6 +2303,28 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
||||
string icstr = InsetCommand::params2string(icp);
|
||||
FuncRequest fr(LFUN_INSET_INSERT, icstr);
|
||||
lyx::dispatch(fr);
|
||||
|
||||
// if the request comes from the LyX server, then we
|
||||
// return a list of the undefined keys, in case some
|
||||
// action could be taken.
|
||||
if (cmd.origin() != FuncRequest::LYXSERVER)
|
||||
break;
|
||||
|
||||
vector<docstring> keys = getVectorFromString(from_utf8(arg));
|
||||
vector<docstring>::iterator it = keys.begin();
|
||||
vector<docstring>::const_iterator end = keys.end();
|
||||
|
||||
BiblioInfo const & bibInfo = buffer_.masterBibInfo();
|
||||
const BiblioInfo::const_iterator bibEnd = bibInfo.end();
|
||||
while (it != end) {
|
||||
if (bibInfo.find(*it) != bibEnd) {
|
||||
it = keys.erase(it);
|
||||
end = keys.end();
|
||||
} else
|
||||
++it;
|
||||
}
|
||||
dr.setMessage(getStringFromVector(keys));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -507,6 +507,7 @@ enum FuncCode
|
||||
LFUN_TAB_GROUP_NEXT, // daniel 20220130
|
||||
LFUN_TAB_GROUP_PREVIOUS, // daniel 20220130
|
||||
// 395
|
||||
LFUN_BIBTEX_DATABASE_LIST, // bpiwowar, 20221218
|
||||
LFUN_LASTACTION // end of the table
|
||||
};
|
||||
|
||||
|
@ -331,6 +331,16 @@ void LyXAction::init()
|
||||
*/
|
||||
{ LFUN_BIBTEX_DATABASE_DEL, "bibtex-database-del", Noop, Edit },
|
||||
|
||||
/*!
|
||||
* \var lyx::FuncCode lyx::LFUN_BIBTEX_DATABASE_LIST
|
||||
* \li Action: Lists the available databases (separated by path separator common
|
||||
* on the used OS).
|
||||
* \li Notion: Used by bibliographic managers
|
||||
* \li Syntax: bibtex-database-list
|
||||
* \li Origin: bpiwowar, 11 june 2012
|
||||
* \endvar
|
||||
*/
|
||||
{ LFUN_BIBTEX_DATABASE_LIST, "bibtex-database-list", ReadOnly, System },
|
||||
|
||||
/*!
|
||||
* \var lyx::FuncCode lyx::LFUN_BOOKMARK_CLEAR
|
||||
|
Loading…
Reference in New Issue
Block a user