}
+pit_type Text::lastInSequence(pit_type pit) const
+{
+ depth_type const depth = pars_[pit].getDepth();
+ pit_type newpit = pit;
+
+ while (size_t(newpit + 1) < pars_.size() &&
+ (pars_[newpit + 1].getDepth() > depth ||
+ (pars_[newpit + 1].getDepth() == depth &&
+ pars_[newpit + 1].layout() == pars_[pit].layout())))
+ ++newpit;
+
+ return newpit;
+}
+
+
int Text::getTocLevel(pit_type par_offset) const
{
Paragraph const & par = pars_[par_offset];
}
-void Text::deleteWordForward(Cursor & cur)
+void Text::deleteWordForward(Cursor & cur, bool const force)
{
LBUFERR(this == cur.text());
if (cur.lastpos() == 0)
cur.selection(true);
cursorForwardOneWord(cur);
cur.setSelection();
- cutSelection(cur, true, false);
- cur.checkBufferStructure();
+ if (force || !cur.confirmDeletion()) {
+ cutSelection(cur, true, false);
+ cur.checkBufferStructure();
+ }
}
}
-void Text::deleteWordBackward(Cursor & cur)
+void Text::deleteWordBackward(Cursor & cur, bool const force)
{
LBUFERR(this == cur.text());
if (cur.lastpos() == 0)
cur.selection(true);
cursorBackwardOneWord(cur);
cur.setSelection();
- cutSelection(cur, true, false);
- cur.checkBufferStructure();
+ if (force || !cur.confirmDeletion()) {
+ cutSelection(cur, true, false);
+ cur.checkBufferStructure();
+ }
}
}
void Text::shortenForOutliner(docstring & str, size_t const maxlen)
{
support::truncateWithEllipsis(str, maxlen);
- docstring::iterator it = str.begin();
- docstring::iterator end = str.end();
- for (; it != end; ++it)
- if ((*it) == L'\n' || (*it) == L'\t')
- (*it) = L' ';
+ for (char_type & c : str)
+ if (c == L'\n' || c == L'\t')
+ c = L' ';
+}
+
+
+void Text::forOutliner(docstring & os, size_t const maxlen,
+ bool const shorten) const
+{
+ pit_type end = pars_.size() - 1;
+ if (0 <= end && !pars_[0].labelString().empty())
+ os += pars_[0].labelString() + ' ';
+ forOutliner(os, maxlen, 0, end, shorten);
}
void Text::forOutliner(docstring & os, size_t const maxlen,
- bool const shorten) const
+ pit_type pit_start, pit_type pit_end,
+ bool const shorten) const
{
size_t tmplen = shorten ? maxlen + 1 : maxlen;
- for (size_t i = 0; i != pars_.size() && os.length() < tmplen; ++i)
- pars_[i].forOutliner(os, tmplen, false);
+ pit_type end = min(size_t(pit_end), pars_.size() - 1);
+ bool first = true;
+ for (pit_type i = pit_start; i <= end && os.length() < tmplen; ++i) {
+ if (!first)
+ os += ' ';
+ // This function lets the first label be treated separately
+ pars_[i].forOutliner(os, tmplen, false, !first);
+ first = false;
+ }
if (shorten)
shortenForOutliner(os, maxlen);
}