mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-05 17:09:56 +00:00
Tooltips for InsetCitation (backported).
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@28935 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
b4a08eb307
commit
1cf1e65b63
@ -16,6 +16,7 @@
|
|||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
#include "buffer_funcs.h"
|
#include "buffer_funcs.h"
|
||||||
#include "BufferParams.h"
|
#include "BufferParams.h"
|
||||||
|
#include "BufferView.h"
|
||||||
#include "DispatchResult.h"
|
#include "DispatchResult.h"
|
||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
#include "LaTeXFeatures.h"
|
#include "LaTeXFeatures.h"
|
||||||
@ -382,6 +383,59 @@ bool InsetCitation::isCompatibleCommand(string const & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
docstring InsetCitation:: toolTip(BufferView const & bv, int, int) const
|
||||||
|
{
|
||||||
|
static unsigned int maxwdth = 80;
|
||||||
|
Buffer const & buf = bv.buffer();
|
||||||
|
// Only after the buffer is loaded from file...
|
||||||
|
if (!buf.isFullyLoaded())
|
||||||
|
return docstring();
|
||||||
|
|
||||||
|
BiblioInfo const & bi = buf.masterBibInfo();
|
||||||
|
if (bi.empty())
|
||||||
|
return _("No bibliography defined!");
|
||||||
|
|
||||||
|
docstring const & key = getParam("key");
|
||||||
|
if (key.empty())
|
||||||
|
return _("No citations selected!");
|
||||||
|
|
||||||
|
vector<docstring> keys = getVectorFromString(key);
|
||||||
|
vector<docstring>::const_iterator it = keys.begin();
|
||||||
|
vector<docstring>::const_iterator en = keys.end();
|
||||||
|
docstring tip;
|
||||||
|
for (; it != en; ++it) {
|
||||||
|
docstring key_info = bi.getInfo(*it);
|
||||||
|
if (key_info.empty())
|
||||||
|
continue;
|
||||||
|
if (!tip.empty())
|
||||||
|
tip += "\n";
|
||||||
|
docstring newkey;
|
||||||
|
while (key_info.size() > maxwdth) {
|
||||||
|
int i = maxwdth - 1;
|
||||||
|
// find the last space
|
||||||
|
for (; i >= 0; --i)
|
||||||
|
if (key_info[i] == ' ')
|
||||||
|
break;
|
||||||
|
if (i < 0) { // no space found?
|
||||||
|
key_info = key_info.substr(0, maxwdth - 3) + "...";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!newkey.empty())
|
||||||
|
newkey += "\n";
|
||||||
|
newkey += key_info.substr(0, i);
|
||||||
|
key_info = " " + key_info.substr(i);
|
||||||
|
//key_info = key_info.substr(0, maxtip - 3) + "...";
|
||||||
|
}
|
||||||
|
if (!newkey.empty())
|
||||||
|
newkey += "\n";
|
||||||
|
newkey += key_info;
|
||||||
|
tip += newkey;
|
||||||
|
}
|
||||||
|
return tip;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
docstring InsetCitation::generateLabel() const
|
docstring InsetCitation::generateLabel() const
|
||||||
{
|
{
|
||||||
docstring const before = getParam("before");
|
docstring const before = getParam("before");
|
||||||
|
@ -40,6 +40,8 @@ public:
|
|||||||
///
|
///
|
||||||
EDITABLE editable() const { return IS_EDITABLE; }
|
EDITABLE editable() const { return IS_EDITABLE; }
|
||||||
///
|
///
|
||||||
|
docstring toolTip(BufferView const & bv, int x, int y) const;
|
||||||
|
///
|
||||||
InsetCode lyxCode() const { return CITE_CODE; }
|
InsetCode lyxCode() const { return CITE_CODE; }
|
||||||
///
|
///
|
||||||
int latex(odocstream &, OutputParams const &) const;
|
int latex(odocstream &, OutputParams const &) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user