if (!isMainText())
applyOuterFont(font);
- // Find the pit value belonging to paragraph. This will not break
+ // Find the pit value belonging to paragraph. This will not break
// even if pars_ would not be a vector anymore.
// Performance appears acceptable.
// the cursor set functions have a special mechanism. When they
// realize you left an empty paragraph, they will delete it.
-void LyXText::cursorHome(LCursor & cur)
+bool LyXText::cursorHome(LCursor & cur)
{
BOOST_ASSERT(this == cur.text());
Row const & row = cur.paragraph().getRow(cur.pos(),cur.boundary());
- setCursor(cur, cur.pit(), row.pos());
+ return setCursor(cur, cur.pit(), row.pos());
}
-void LyXText::cursorEnd(LCursor & cur)
+bool LyXText::cursorEnd(LCursor & cur)
{
BOOST_ASSERT(this == cur.text());
// if not on the last row of the par, put the cursor before
pos_type end = cur.textRow().endpos();
if (end == 0)
// empty text, end-1 is no valid position
- return;
+ return false;
bool boundary = false;
if (end != cur.lastpos()) {
if (!cur.paragraph().isLineSeparator(end-1)
else
--end;
}
- setCursor(cur, cur.pit(), end, true, boundary);
+ return setCursor(cur, cur.pit(), end, true, boundary);
}
-void LyXText::cursorTop(LCursor & cur)
+bool LyXText::cursorTop(LCursor & cur)
{
BOOST_ASSERT(this == cur.text());
- setCursor(cur, 0, 0);
+ return setCursor(cur, 0, 0);
}
-void LyXText::cursorBottom(LCursor & cur)
+bool LyXText::cursorBottom(LCursor & cur)
{
BOOST_ASSERT(this == cur.text());
- setCursor(cur, cur.lastpit(), boost::prior(paragraphs().end())->size());
+ return setCursor(cur, cur.lastpit(), boost::prior(paragraphs().end())->size());
}
linestr[i] = ' ';
newline_inserted = true;
}
- } else if (IsPrintable(linestr[i])) {
+ } else if (isPrintable(linestr[i])) {
newline_inserted = false;
}
}
// This should be just before or just behind the
// cursor position set above.
BOOST_ASSERT((pos != 0 && inset == pars_[pit].getInset(pos - 1))
- || inset == pars_[pit].getInset(pos));
+ || inset == pars_[pit].getInset(pos));
// Make sure the cursor points to the position before
// this inset.
if (inset == pars_[pit].getInset(pos - 1))
if (oldpar.empty() || (oldpar.size() == 1 && oldpar.isLineSeparator(0))) {
// Delete old par.
recordUndo(old, Undo::ATOMIC,
- max(old.pit() - 1, 0),
+ max(old.pit() - 1, pit_type(0)),
min(old.pit() + 1, old.lastpit()));
ParagraphList & plist = old.text()->paragraphs();
- plist.erase(plist.begin() + old.pit());
+ plist.erase(boost::next(plist.begin(), old.pit()));
// see #warning above
if (cur.depth() >= old.depth()) {
CursorSlice & curslice = cur[old.depth() - 1];
- if (&curslice.inset() == &old.inset()
+ if (&curslice.inset() == &old.inset()
&& curslice.pit() > old.pit()) {
--curslice.pit();
// since a paragraph has been deleted, all the
cur.resetAnchor();
}
}
- updateCounters(old.buffer());
+ ParIterator par_it(old);
+ if (needsUpdateCounters(old.buffer(), par_it))
+ updateCounters(old.buffer());
return true;
}