mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
Enable Open Citation menu item iff citation contain locator information or external search script is available.
Per Juergen's request.
This commit is contained in:
parent
9c9a2c1b92
commit
894ad70eba
@ -49,6 +49,9 @@
|
||||
* \ct_markup_copied true|false: determines whether change tracking markup should be
|
||||
preserved on copy/paste (default: false).
|
||||
|
||||
* \citation_search_view lyxpaperview: determines whether external script "lyxpaperview"
|
||||
should be used for looking up citation source.
|
||||
|
||||
|
||||
!!!The following pref variables were changed in 2.4:
|
||||
|
||||
|
@ -1310,6 +1310,8 @@ def checkOtherEntries():
|
||||
rc_entry = [ r'\nomencl_command "makeindex -s nomencl.ist"' ])
|
||||
checkProg('a python-pygments driver command', ['pygmentize'],
|
||||
rc_entry = [ r'\pygmentize_command "%%"' ])
|
||||
checkProg('external script for searching and showing citation sources',
|
||||
['lyxpaperview'], rc_entry = [ r'\citation_search_view "%%"' ])
|
||||
## FIXME: OCTAVE is not used anywhere
|
||||
# path, OCTAVE = checkProg('Octave', ['octave'])
|
||||
## FIXME: MAPLE is not used anywhere
|
||||
@ -1875,7 +1877,7 @@ if __name__ == '__main__':
|
||||
lyx_check_config = True
|
||||
lyx_kpsewhich = True
|
||||
outfile = 'lyxrc.defaults'
|
||||
lyxrc_fileformat = 31
|
||||
lyxrc_fileformat = 33
|
||||
rc_entries = ''
|
||||
lyx_keep_temps = False
|
||||
version_suffix = ''
|
||||
|
@ -129,6 +129,11 @@
|
||||
# Add ct_markup_copied.
|
||||
# No convergence necessary.
|
||||
|
||||
# Incremented to format 33, by sanda
|
||||
# Add \citation_search_view.
|
||||
# No conversion necessary.
|
||||
|
||||
|
||||
# NOTE: The format should also be updated in LYXRC.cpp and
|
||||
# in configure.py.
|
||||
|
||||
@ -479,5 +484,6 @@ conversions = [
|
||||
[ 29, [remove_use_pixmap_cache]],
|
||||
[ 30, []],
|
||||
[ 31, []],
|
||||
[ 32, []]
|
||||
[ 32, []],
|
||||
[ 33, []]
|
||||
]
|
||||
|
@ -61,7 +61,7 @@ namespace {
|
||||
|
||||
// The format should also be updated in configure.py, and conversion code
|
||||
// should be added to prefs2prefs_prefs.py.
|
||||
static unsigned int const LYXRC_FILEFORMAT = 32; // spitz: add \ct_markup_copied
|
||||
static unsigned int const LYXRC_FILEFORMAT = 33; // sanda: add \citation_search_view
|
||||
// when adding something to this array keep it sorted!
|
||||
LexerKeyword lyxrcTags[] = {
|
||||
{ "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
|
||||
@ -78,6 +78,7 @@ LexerKeyword lyxrcTags[] = {
|
||||
{ "\\bind_file", LyXRC::RC_BINDFILE },
|
||||
{ "\\check_lastfiles", LyXRC::RC_CHECKLASTFILES },
|
||||
{ "\\chktex_command", LyXRC::RC_CHKTEX_COMMAND },
|
||||
{ "\\citation_search_view", LyXRC::RC_CITATION_SEARCH_VIEW },
|
||||
{ "\\close_buffer_with_last_view", LyXRC::RC_CLOSE_BUFFER_WITH_LAST_VIEW },
|
||||
{ "\\completion_cursor_text", LyXRC::RC_COMPLETION_CURSOR_TEXT },
|
||||
{ "\\completion_inline_delay", LyXRC::RC_COMPLETION_INLINE_DELAY },
|
||||
@ -679,6 +680,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
|
||||
}
|
||||
break;
|
||||
|
||||
case RC_CITATION_SEARCH_VIEW:
|
||||
lexrc >> citation_search_view;
|
||||
break;
|
||||
|
||||
case RC_CT_ADDITIONS_UNDERLINED:
|
||||
lexrc >> ct_additions_underlined;
|
||||
break;
|
||||
@ -1602,6 +1607,15 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
|
||||
if (tag != RC_LAST)
|
||||
break;
|
||||
// fall through
|
||||
case RC_CITATION_SEARCH_VIEW:
|
||||
if (ignore_system_lyxrc ||
|
||||
citation_search_view != system_lyxrc.citation_search_view) {
|
||||
os << "\\citaton_search_view "
|
||||
<< citation_search_view << '\n';
|
||||
}
|
||||
if (tag != RC_LAST)
|
||||
break;
|
||||
// fall through
|
||||
case RC_CT_ADDITIONS_UNDERLINED:
|
||||
if (ignore_system_lyxrc ||
|
||||
ct_additions_underlined
|
||||
@ -2774,6 +2788,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
|
||||
case LyXRC::RC_BIBTEX_ALTERNATIVES:
|
||||
case LyXRC::RC_BIBTEX_COMMAND:
|
||||
case LyXRC::RC_BINDFILE:
|
||||
case LyXRC::RC_CITATION_SEARCH_VIEW:
|
||||
case LyXRC::RC_CHECKLASTFILES:
|
||||
case LyXRC::RC_COMPLETION_CURSOR_TEXT:
|
||||
case LyXRC::RC_COMPLETION_INLINE_DELAY:
|
||||
|
@ -53,6 +53,7 @@ public:
|
||||
RC_BINDFILE,
|
||||
RC_CHECKLASTFILES,
|
||||
RC_CHKTEX_COMMAND,
|
||||
RC_CITATION_SEARCH_VIEW,
|
||||
RC_COMPLETION_CURSOR_TEXT,
|
||||
RC_COMPLETION_INLINE_DELAY,
|
||||
RC_COMPLETION_INLINE_MATH,
|
||||
@ -243,6 +244,13 @@ public:
|
||||
/// default paper size for local xdvi/dvips/ghostview/whatever
|
||||
/// command to run chktex incl. options
|
||||
std::string chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
|
||||
// Name of external script, which searches for file corresponding to a
|
||||
// given citation. At this moment only script "lyxpaperview" is supported
|
||||
// (search for pdf based on author+year), but we can generalize if requested.
|
||||
// Citation context menu item "Open Citation Content" will be always enabled
|
||||
// if the name of this script in nonempty (last resort when citation entry
|
||||
// does not contain neccessary info.
|
||||
std::string citation_search_view;
|
||||
/// all available commands to run bibtex incl. options
|
||||
CommandSet bibtex_alternatives;
|
||||
/// command to run bibtex incl. options
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "FuncStatus.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "LyX.h"
|
||||
#include "LyXRC.h"
|
||||
#include "output_xhtml.h"
|
||||
#include "output_docbook.h"
|
||||
#include "ParIterator.h"
|
||||
@ -168,20 +169,41 @@ void InsetCitation::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetCitation::openCitation(){
|
||||
bool InsetCitation::openCitationPossible() const
|
||||
{
|
||||
Buffer const & buf = *buffer_;
|
||||
// Only after the buffer is loaded from file...
|
||||
// only after the buffer is loaded from file...
|
||||
if (!buf.isFullyLoaded())
|
||||
return;
|
||||
return false;
|
||||
|
||||
BiblioInfo const & bi = buf.masterBibInfo();
|
||||
if (bi.empty())
|
||||
return;
|
||||
return false;
|
||||
|
||||
docstring const & key = getParam("key");
|
||||
if (key.empty())
|
||||
return;
|
||||
return false;
|
||||
|
||||
// does bibtex item contains some locator?
|
||||
vector<docstring> keys = getVectorFromString(key);
|
||||
docstring doi, url, file;
|
||||
for (docstring const & kvar : keys) {
|
||||
bi.getLocators(kvar, doi, url, file);
|
||||
if (!file.empty() || !doi.empty() || !url.empty())
|
||||
return true;
|
||||
}
|
||||
|
||||
// last resort: is external script available?
|
||||
if (!lyxrc.citation_search_view.empty())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void InsetCitation::openCitation()
|
||||
{
|
||||
Buffer const & buf = *buffer_;
|
||||
BiblioInfo const & bi = buf.masterBibInfo();
|
||||
docstring const & key = getParam("key");
|
||||
|
||||
vector<docstring> keys = getVectorFromString(key);
|
||||
docstring year, author, doi, url, file;
|
||||
@ -246,7 +268,7 @@ bool InsetCitation::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
}
|
||||
return true;
|
||||
case LFUN_INSET_EDIT:
|
||||
return true;
|
||||
return openCitationPossible();
|
||||
default:
|
||||
return InsetCommand::getStatus(cur, cmd, status);
|
||||
}
|
||||
|
@ -94,7 +94,10 @@ public:
|
||||
QualifiedList getQualifiedLists(docstring const & p) const;
|
||||
///
|
||||
static bool last_literal;
|
||||
///
|
||||
/// Check whether citation contains necessary url/file entries
|
||||
/// or external search script is available
|
||||
bool openCitationPossible() const;
|
||||
/// search and open citation source
|
||||
void openCitation();
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user