pars_[pit].rows().clear();
current_font = getFont(pars_[0], 0);
- updateCounters(*bv->buffer());
+ updateLabels(*bv->buffer());
}
LyXFont f = par.getFontSettings(params, pos);
if (!isMainText())
applyOuterFont(f);
- if (layout->labeltype == LABEL_MANUAL && pos < body_pos)
- return f.realize(layout->reslabelfont);
- else
- return f.realize(layout->resfont);
+ LyXFont lf;
+ LyXFont rlf;
+ if (layout->labeltype == LABEL_MANUAL && pos < body_pos) {
+ lf = layout->labelfont;
+ rlf = layout->reslabelfont;
+ } else {
+ lf = layout->font;
+ rlf = layout->resfont;
+ }
+ // In case the default family has been customized
+ if (lf.family() == LyXFont::INHERIT_FAMILY)
+ rlf.setFamily(params.getFont().family());
+ return f.realize(rlf);
}
// The uncommon case need not be optimized as much
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.
break;
}
// Realize against environment font information
- if (pit < pars_.size())
+ // NOTE: the cast to pit_type should be removed when pit_type
+ // changes to a unsigned integer.
+ if (pit < pit_type(pars_.size()))
font.realize(outerFont(pit, pars_));
// Realize with the fonts of lesser depth.
{
LyXLayout_ptr const & layout = pars_[pit].layout();
- if (!pars_[pit].getDepth())
- return layout->resfont;
+ if (!pars_[pit].getDepth()) {
+ LyXFont lf = layout->resfont;
+ // In case the default family has been customized
+ if (layout->font.family() == LyXFont::INHERIT_FAMILY)
+ lf.setFamily(bv()->buffer()->params().getFont().family());
+ return lf;
+ }
LyXFont font = layout->font;
// Realize with the fonts of lesser depth.
{
LyXLayout_ptr const & layout = par.layout();
- if (!par.getDepth())
- return layout->reslabelfont;
+ if (!par.getDepth()) {
+ LyXFont lf = layout->reslabelfont;
+ // In case the default family has been customized
+ if (layout->labelfont.family() == LyXFont::INHERIT_FAMILY)
+ lf.setFamily(bv()->buffer()->params().getFont().family());
+ return lf;
+ }
LyXFont font = layout->labelfont;
// Realize with the fonts of lesser depth.
if (lyxlayout->is_environment) {
// move everything in a new environment inset
lyxerr[Debug::DEBUG] << "setting layout " << layout << endl;
- bv.owner()->dispatch(FuncRequest(LFUN_HOME));
- bv.owner()->dispatch(FuncRequest(LFUN_ENDSEL));
+ bv.owner()->dispatch(FuncRequest(LFUN_LINE_BEGIN));
+ bv.owner()->dispatch(FuncRequest(LFUN_LINE_END_SELECT));
bv.owner()->dispatch(FuncRequest(LFUN_CUT));
InsetBase * inset = new InsetEnvironment(params, layout);
insertInset(cur, inset);
pit_type undopit = undoSpan(end - 1);
recUndo(start, undopit - 1);
setLayout(start, end, layout);
- updateCounters(cur.buffer());
+ updateLabels(cur.buffer());
}
}
// this handles the counter labels, and also fixes up
// depth values for follow-on (child) paragraphs
- updateCounters(cur.buffer());
+ updateLabels(cur.buffer());
}
// 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());
+ // There is a crash reported by Edwin Leuven (16/04/2006) because of:
+ //ParIterator par_it(old);
+ //updateLabels(old.buffer(), par_it);
+ // So for now we do the full update:
+ updateLabels(old.buffer());
return true;
}