Cursor & cur = const_cast<Cursor &>(bv_->cursor());
// In some cases, we do not know how to record undo
if (&cur.inset() == &text_->inset())
- cur.recordUndo(ATOMIC_UNDO, pit, pit);
+ cur.recordUndo(pit, pit);
int const moveCursor = par.fixBiblio(buffer);
MacroContext mc(&buffer, parPos);
MetricsInfo mi(bv_, font.fontInfo(), w, mc);
ii->inset->metrics(mi, dim);
- Dimension const old_dim = pm.insetDimension(ii->inset);
+ Dimension const & old_dim = pm.insetDimension(ii->inset);
if (old_dim != dim) {
pm.setInsetDimension(ii->inset, dim);
changed = true;
/** This is the function where the hard work is done. The code here is
* very sensitive to small changes :) Note that part of the
- * intelligence is also in Row::shorten_if_needed
+ * intelligence is also in Row::shortenIfNeeded.
*/
void TextMetrics::breakRow(Row & row, int const right_margin, pit_type const pit) const
{
// if the row is too large, try to cut at last separator.
row.shortenIfNeeded(body_pos, width);
- // if the row ends with a separator that is not at end of
- // paragraph, remove it
- if (!row.empty() && row.back().type == Row::SEPARATOR
- && row.endpos() < par.size())
- row.pop_back();
-
// make sure that the RTL elements are in reverse ordering
row.reverseRTL(text_->isRTL(par));
}
}
if (!par.params().leftIndent().zero())
- l_margin += par.params().leftIndent().inPixels(max_width);
+ l_margin += par.params().leftIndent().inPixels(max_width, labelfont_metrics.em());
LyXAlignment align;
}
-void TextMetrics::drawParagraph(PainterInfo & pi, pit_type pit, int x, int y) const
+void TextMetrics::drawParagraph(PainterInfo & pi, pit_type const pit, int const x, int y) const
{
BufferParams const & bparams = bv_->buffer().params();
ParagraphMetrics const & pm = par_metrics_[pit];
for (size_t i = 0; i != nrows; ++i) {
Row const & row = pm.rows()[i];
+ int row_x = x;
if (i)
y += row.ascent();
+ CursorSlice rowSlice(const_cast<InsetText &>(text_->inset()));
+ rowSlice.pit() = pit;
+ rowSlice.pos() = row.pos();
+
bool const inside = (y + row.descent() >= 0
&& y - row.ascent() < ww);
+
+ // Adapt to cursor row scroll offset if applicable.
+ if (bv_->currentRowSlice() == rowSlice)
+ row_x -= bv_->horizScrollOffset();
+
// It is not needed to draw on screen if we are not inside.
pi.pain.setDrawingEnabled(inside && original_drawing_state);
- RowPainter rp(pi, *text_, pit, row, x, y);
+
+ RowPainter rp(pi, *text_, pit, row, row_x, y);
if (selection)
row.setSelectionAndMargins(sel_beg_par, sel_end_par);
}
// Row signature; has row changed since last paint?
- row.setCrc(pm.computeRowSignature(row, bparams));
- bool row_has_changed = row.changed();
+ if (pi.pain.isDrawingEnabled())
+ row.setCrc(pm.computeRowSignature(row, bparams));
+ bool row_has_changed = row.changed()
+ || rowSlice == bv_->lastRowSlice();
// Take this opportunity to spellcheck the row contents.
if (row_has_changed && lyxrc.spellcheck_continuously) {
// Clear background of this row if paragraph background was not
// already cleared because of a full repaint.
if (!pi.full_repaint && row_has_changed) {
- pi.pain.fillRectangle(x, y - row.ascent(),
+ LYXERR(Debug::PAINTING, "Clear rect@("
+ << max(row_x, 0) << ", " << y - row.ascent() << ")="
+ << width() << " x " << row.height());
+ pi.pain.fillRectangle(max(row_x, 0), y - row.ascent(),
width(), row.height(), pi.background_color);
}
LYXERR(Debug::PAINTING, foreword << "pit=" << pit << " row=" << i
<< " row_selection=" << row.selection()
<< " full_repaint=" << pi.full_repaint
- << " row_has_changed=" << row_has_changed);
+ << " row_has_changed=" << row_has_changed
+ << " drawingEnabled=" << pi.pain.isDrawingEnabled());
}
// Backup full_repaint status and force full repaint
rp.paintLast();
if (i == 0 && is_rtl)
rp.paintFirst();
+ rp.paintTooLargeMarks(row_x < 0,
+ row_x + row.width() > bv_->workWidth());
y += row.descent();
// Restore full_repaint status.