//lyxerr << "Text::metrics: width: " << mi.base.textwidth
// << " maxWidth: " << max_width_ << "\nfont: " << mi.base.font << endl;
-
+
bool changed = false;
unsigned int h = 0;
main_text_ = (text_ == &buffer.text());
bool changed = false;
- // FIXME: this has nothing to do here and is the reason why text_ is not
- // const.
- if (par.checkBiblio(buffer.params().trackChanges))
+ // FIXME This check ought to be done somewhere else. It is the reason
+ // why text_ is not const. But then, where else to do it?
+ // Well, how can you end up with either (a) a biblio environment that
+ // has no InsetBibitem or (b) a biblio environment with more than one
+ // InsetBibitem? I think the answer is: when paragraphs are merged;
+ // when layout is set; when material is pasted.
+ int const moveCursor = par.checkBiblio(buffer.params().trackChanges);
+ if (moveCursor > 0)
const_cast<Cursor &>(bv_->cursor()).posRight();
+ else if (moveCursor < 0) {
+ Cursor & cursor = const_cast<Cursor &>(bv_->cursor());
+ if (cursor.pos() >= -moveCursor)
+ cursor.posLeft();
+ }
// Optimisation: this is used in the next two loops
// so better to calculate that once here.
// Make sure that if a par ends in newline, there is one more row
// under it
- // FIXME this is a dirty trick. Now the _same_ position in the
- // paragraph occurs in _two_ different rows, and has two different
- // display positions, leading to weird behaviour when moving up/down.
if (z > 0 && par.isNewline(z - 1)) {
- Row row(z - 1);
- row.endpos(z - 1);
+ Row row(z);
+ row.endpos(z);
setRowWidth(right_margin, pit, row);
setHeightOfRow(pit, row);
pm.rows().push_back(row);
// The test on par.size() is to catch zero-size pars, which
// would trigger the assert in Paragraph::getInset().
//inset = par.size() ? par.getInset(row.pos()) : 0;
- if (!par.empty()
- && par.isInset(row.pos())
- && par.getInset(row.pos())->display())
+ if (row.pos() < par.size()
+ && par.isInset(row.pos()))
{
- align = LYX_ALIGN_CENTER;
+ switch(par.getInset(row.pos())->display()) {
+ case Inset::AlignLeft:
+ align = LYX_ALIGN_BLOCK;
+ break;
+ case Inset::AlignCenter:
+ align = LYX_ALIGN_CENTER;
+ break;
+ case Inset::Inline:
+ case Inset::AlignRight:
+ // unchanged (use align)
+ break;
+ }
}
switch (align) {
}
}
- text_->bidi.computeTables(par, buffer, row);
if (is_rtl) {
pos_type body_pos = par.beginOfBody();
pos_type end = row.endpos();
if (label.empty())
return 0;
- FontMetrics const & fm
+ FontMetrics const & fm
= theFontMetrics(text_->getLabelFont(buffer, par));
return max(0, fm.width(label) - w);
Font::FONT_SIZE maxsize =
par.highestFontInRange(row.pos(), pos_end, size);
if (maxsize > font.size()) {
- font.setSize(maxsize);
- maxasc = max(maxasc, fontmetrics.maxAscent());
- maxdesc = max(maxdesc, fontmetrics.maxDescent());
+ // use standard paragraph font with the maximal size
+ Font maxfont = font;
+ maxfont.setSize(maxsize);
+ FontMetrics const & maxfontmetrics = theFontMetrics(maxfont);
+ maxasc = max(maxasc, maxfontmetrics.maxAscent());
+ maxdesc = max(maxdesc, maxfontmetrics.maxDescent());
}
// This is nicer with box insets:
if (bufparams.paragraph_separation
== BufferParams::PARSEP_SKIP
&& par.ownerCode() != Inset::ERT_CODE
+ && par.ownerCode() != Inset::LISTINGS_CODE
&& pit > 0
&& ((layout->isParagraph() && par.getDepth() == 0)
|| (pars[pit - 1].layout()->isParagraph()
maxasc += int(layoutasc * 2 / (2 + pars[pit].getDepth()));
maxdesc += int(layoutdesc * 2 / (2 + pars[pit].getDepth()));
- // FIXME: the correct way is to do the following is to move the
- // following code in another method specially tailored for the
+ // FIXME: the correct way is to do the following is to move the
+ // following code in another method specially tailored for the
// main Text. The following test is thus bogus.
// Top and bottom margin of the document (only at top-level)
if (main_text_) {
if (pit == 0 && row.pos() == 0)
maxasc += 20;
if (pit + 1 == pit_type(pars.size()) &&
- row.endpos() == par.size())
+ row.endpos() == par.size() &&
+ !(row.endpos() > 0 && par.isNewline(row.endpos() - 1)))
maxdesc += 20;
}
x -= xo;
RowMetrics const r = computeRowMetrics(pit, row);
Paragraph const & par = text_->getPar(pit);
+ Bidi bidi;
+ bidi.computeTables(par, buffer, row);
pos_type vc = row.pos();
pos_type end = row.endpos();
return 0;
}
- frontend::FontMetrics const & fm
+ frontend::FontMetrics const & fm
= theFontMetrics(text_->getLabelFont(buffer, par));
while (vc < end && tmpx <= x) {
- c = text_->bidi.vis2log(vc);
+ c = bidi.vis2log(vc);
last_tmpx = tmpx;
if (body_pos > 0 && c == body_pos - 1) {
// FIXME UNICODE
(!rtl && !left_side && vc == end && x > tmpx + 5)))
c = end;
else if (vc == row.pos()) {
- c = text_->bidi.vis2log(vc);
- if (text_->bidi.level(c) % 2 == 1)
+ c = bidi.vis2log(vc);
+ if (bidi.level(c) % 2 == 1)
++c;
} else {
- c = text_->bidi.vis2log(vc - 1);
- bool const rtl = (text_->bidi.level(c) % 2 == 1);
+ c = bidi.vis2log(vc - 1);
+ bool const rtl = (bidi.level(c) % 2 == 1);
if (left_side == rtl) {
++c;
- boundary = text_->bidi.isBoundary(buffer, par, c);
+ boundary = text_->isRTLBoundary(buffer, par, c);
}
}
// specially, so cursor up/down doesn't get stuck in an air gap -- MV
// Newline inset, air gap below:
if (row.pos() < end && c >= end && par.isNewline(end - 1)) {
- if (text_->bidi.level(end -1) % 2 == 0)
+ if (bidi.level(end -1) % 2 == 0)
tmpx -= text_->singleWidth(buffer, par, end - 1);
else
tmpx += text_->singleWidth(buffer, par, end - 1);