mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-26 22:17:41 +00:00
Use the much faster forOutliner also to get the tooltip text.
This commit is contained in:
parent
a5ea77410e
commit
cf64064db7
@ -3269,8 +3269,6 @@ void Paragraph::forOutliner(docstring & os, size_t const maxlen,
|
||||
char_type const c = d->text_[i];
|
||||
if (isPrintable(c))
|
||||
os += c;
|
||||
else if (c == '\t' || c == '\n')
|
||||
os += ' ';
|
||||
else if (c == META_INSET)
|
||||
getInset(i)->forOutliner(os, tmplen, false);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ std::string insetName(InsetCode);
|
||||
/// Eg, insetDisplayName(BRANCH_CODE) == _("Branch")
|
||||
docstring insetDisplayName(InsetCode);
|
||||
///
|
||||
static int const TOC_ENTRY_LENGTH = 128;
|
||||
static int const TOC_ENTRY_LENGTH = 120;
|
||||
|
||||
/// Common base class to all insets
|
||||
|
||||
|
@ -357,10 +357,14 @@ void InsetBranch::addToToc(DocIterator const & cpit, bool output_active,
|
||||
DocIterator pit = cpit;
|
||||
pit.push_back(CursorSlice(const_cast<InsetBranch &>(*this)));
|
||||
|
||||
docstring tooltip;
|
||||
text().forOutliner(tooltip, TOC_ENTRY_LENGTH);
|
||||
docstring str = params_.branch + ": " + tooltip;
|
||||
tooltip = support::wrapParas(tooltip, 0, 60, 2);
|
||||
|
||||
shared_ptr<Toc> toc = buffer().tocBackend().toc("branch");
|
||||
docstring str = params_.branch + ": ";
|
||||
text().forOutliner(str, TOC_ENTRY_LENGTH);
|
||||
toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60)));
|
||||
toc->push_back(TocItem(pit, 0, str, output_active, tooltip));
|
||||
|
||||
// Proceed with the rest of the inset.
|
||||
bool const doing_output = output_active && isBranchSelected();
|
||||
InsetCollapsable::addToToc(cpit, doing_output, utype);
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "support/debug.h"
|
||||
#include "support/docstream.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -80,10 +81,14 @@ void InsetFoot::addToToc(DocIterator const & cpit, bool output_active,
|
||||
DocIterator pit = cpit;
|
||||
pit.push_back(CursorSlice(const_cast<InsetFoot &>(*this)));
|
||||
|
||||
docstring tooltip;
|
||||
text().forOutliner(tooltip, TOC_ENTRY_LENGTH);
|
||||
docstring str = custom_label_ + ": " + tooltip;
|
||||
tooltip = support::wrapParas(tooltip, 0, 60, 2);
|
||||
|
||||
shared_ptr<Toc> toc = buffer().tocBackend().toc("footnote");
|
||||
docstring str = custom_label_ + ": ";
|
||||
text().forOutliner(str, TOC_ENTRY_LENGTH);
|
||||
toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60)));
|
||||
toc->push_back(TocItem(pit, 0, str, output_active, tooltip));
|
||||
|
||||
// Proceed with the rest of the inset.
|
||||
InsetFootlike::addToToc(cpit, output_active, utype);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "support/docstream.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
namespace lyx {
|
||||
|
||||
@ -57,10 +58,14 @@ void InsetMarginal::addToToc(DocIterator const & cpit, bool output_active,
|
||||
DocIterator pit = cpit;
|
||||
pit.push_back(CursorSlice(const_cast<InsetMarginal &>(*this)));
|
||||
|
||||
docstring tooltip;
|
||||
text().forOutliner(tooltip, TOC_ENTRY_LENGTH);
|
||||
docstring const str = tooltip;
|
||||
tooltip = support::wrapParas(tooltip, 0, 60, 2);
|
||||
|
||||
shared_ptr<Toc> toc = buffer().tocBackend().toc("marginalnote");
|
||||
docstring str;
|
||||
text().forOutliner(str, TOC_ENTRY_LENGTH);
|
||||
toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60)));
|
||||
toc->push_back(TocItem(pit, 0, str, output_active, tooltip));
|
||||
|
||||
// Proceed with the rest of the inset.
|
||||
InsetFootlike::addToToc(cpit, output_active, utype);
|
||||
}
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "support/debug.h"
|
||||
#include "support/docstream.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/Translator.h"
|
||||
|
||||
#include "frontends/Application.h"
|
||||
@ -213,11 +214,14 @@ void InsetNote::addToToc(DocIterator const & cpit, bool output_active,
|
||||
DocIterator pit = cpit;
|
||||
pit.push_back(CursorSlice(const_cast<InsetNote &>(*this)));
|
||||
|
||||
shared_ptr<Toc> toc = buffer().tocBackend().toc("note");
|
||||
InsetLayout const & il = getLayout();
|
||||
docstring str = translateIfPossible(il.labelstring()) + from_ascii(": ");
|
||||
text().forOutliner(str, TOC_ENTRY_LENGTH);
|
||||
toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60)));
|
||||
docstring tooltip;
|
||||
text().forOutliner(tooltip, TOC_ENTRY_LENGTH);
|
||||
docstring str = translateIfPossible(il.labelstring()) + ": " + tooltip;
|
||||
tooltip = support::wrapParas(tooltip, 0, 60, 2);
|
||||
|
||||
shared_ptr<Toc> toc = buffer().tocBackend().toc("note");
|
||||
toc->push_back(TocItem(pit, 0, str, output_active, tooltip));
|
||||
|
||||
// Proceed with the rest of the inset.
|
||||
bool doing_output = output_active && producesOutput();
|
||||
|
@ -201,6 +201,9 @@ public:
|
||||
/// e.g., "Index: ".
|
||||
/// \param numlines: the number of lines in the tooltip
|
||||
/// \param len: length of those lines
|
||||
/// NOTE This routine is kind of slow. It's fine to use it within the
|
||||
/// GUI, but definitely do not try to use it in updateBuffer or anything
|
||||
/// of that sort.
|
||||
docstring toolTipText(docstring prefix = empty_docstring(),
|
||||
size_t numlines = 5, size_t len = 80) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user