+2003-03-16 John Levon <levon@movementarian.org>
+
+ * insettext.C: remove unused s.refresh
+
2003-03-13 Angus Leeming <leeming@lyx.org>
* insettext.C (edit): replace Dialogs::updateParagraph with
sstate.selendboundary = t->selection.end.boundary();
sstate.selection = t->selection.set();
sstate.mark_set = t->selection.mark();
- sstate.refresh = t->refresh_row != 0;
} else {
sstate.lpar = 0;
}
void InsetText::restoreLyXTextState(BufferView * bv, LyXText * t) const
{
- if (sstate.lpar) {
- t->selection.set(true);
- /* at this point just to avoid the Delete-Empty-Paragraph
- * Mechanism when setting the cursor */
- t->selection.mark(sstate.mark_set);
- if (sstate.selection) {
- t->setCursor(bv, sstate.selstartpar, sstate.selstartpos,
- true, sstate.selstartboundary);
- t->selection.cursor = t->cursor;
- t->setCursor(bv, sstate.selendpar, sstate.selendpos,
- true, sstate.selendboundary);
- t->setSelection(bv);
- t->setCursor(bv, sstate.lpar, sstate.pos);
- } else {
- t->setCursor(bv, sstate.lpar, sstate.pos, true, sstate.boundary);
- t->selection.cursor = t->cursor;
- t->selection.set(false);
- }
- if (sstate.refresh) {
- }
+ if (!sstate.lpar)
+ return;
+
+ t->selection.set(true);
+ /* at this point just to avoid the DEPM when setting the cursor */
+ t->selection.mark(sstate.mark_set);
+ if (sstate.selection) {
+ t->setCursor(bv, sstate.selstartpar, sstate.selstartpos,
+ true, sstate.selstartboundary);
+ t->selection.cursor = t->cursor;
+ t->setCursor(bv, sstate.selendpar, sstate.selendpos,
+ true, sstate.selendboundary);
+ t->setSelection(bv);
+ t->setCursor(bv, sstate.lpar, sstate.pos);
+ } else {
+ t->setCursor(bv, sstate.lpar, sstate.pos, true, sstate.boundary);
+ t->selection.cursor = t->cursor;
+ t->selection.set(false);
}
}
/// Set the status to make a paint pending.
void status(BufferView *, text_status) const;
+ /// clear any pending paints
+ void clearPaint();
+
+ /// post notice that we changed during a draw
+ void postChangedInDraw();
+
+ /**
+ * Mark position y as the starting point for a repaint
+ */
+ void postPaint(BufferView & bv, int start_y);
+
+ /**
+ * Mark the given row at position y as needing a repaint.
+ */
+ void postRowPaint(BufferView & bv, Row * row, int start_y);
+
///
Inset::RESULT dispatch(FuncRequest const & cmd);
cursorLeft(bview);
}
- status(bview, LyXText::NEED_MORE_REFRESH);
- refresh_row = cursor.row();
- refresh_y = cursor.y() - cursor.row()->baseline();
+ int y = cursor.y() - cursor.row()->baseline();
// Do not forget the special right address boxes
if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
- while (refresh_row->previous() &&
- refresh_row->previous()->par() == refresh_row->par())
- {
- refresh_row = refresh_row->previous();
- refresh_y -= refresh_row->height();
+ Row * r = cursor.row();
+ while (r->previous() && r->previous()->par() == r->par()) {
+ r = r->previous();
+ y -= r->height();
}
}
+
+ postPaint(*bview, y);
+
removeParagraph(cursor.row());
// set the dimensions of the cursor row
setHeightOfRow(bview, row->previous());
y -= row->previous()->height();
- refresh_y = y;
- refresh_row = row->previous();
- status(bview, LyXText::NEED_MORE_REFRESH);
+
+ postPaint(*bview, y);
breakAgainOneRow(bview, row);
}
if (c == Paragraph::META_INSET || row->fill() < 0) {
- refresh_y = y;
- refresh_row = row;
- status(bview, LyXText::NEED_MORE_REFRESH);
+ postPaint(*bview, y);
breakAgainOneRow(bview, row);
// will the cursor be in another row now?
if (row->lastPos() <= cursor.pos() + 1 && row->next()) {
else
need_break_row = 0;
} else {
- refresh_y = y;
- refresh_row = row;
-
+ // FIXME: similar code is duplicated all over - make resetHeightOfRow
int const tmpheight = row->height();
+
setHeightOfRow(bview, row);
- if (tmpheight == row->height())
- status(bview, LyXText::NEED_VERY_LITTLE_REFRESH);
- else
- status(bview, LyXText::NEED_MORE_REFRESH);
+
+ if (tmpheight == row->height()) {
+ postRowPaint(*bview, row, y);
+ } else {
+ postPaint(*bview, y);
+ }
current_font = rawtmpfont;
real_current_font = realtmpfont;
++pos;
}
- if (to.row() != from.row()) {
- refresh_y = from.y() - from.row()->baseline();
- refresh_row = from.row();
- status(&bview, LyXText::NEED_MORE_REFRESH);
- }
+
+ if (to.row() != from.row())
+ postPaint(bview, from.y() - from.row()->baseline());
}
int const tmpheight = cursor.row()->height();
setHeightOfRow(bview, cursor.row());
if (cursor.row()->height() != tmpheight) {
- refresh_y = cursor.y() - cursor.row()->baseline();
- refresh_row = cursor.row();
- status(bview, LyXText::NEED_MORE_REFRESH);
+ postPaint(*bview, cursor.y() - cursor.row()->baseline());
}
return;
}
if (cursor.pos())
cursor.pos(cursor.pos() - 1);
- status(bview, LyXText::NEED_MORE_REFRESH);
- refresh_row = cursor.row();
- refresh_y = cursor.y() - cursor.row()->baseline();
+ postPaint(*bview, cursor.y() - cursor.row()->baseline());
// remove the lost paragraph
// This one is not safe, since the paragraph that the tmprow and the
tmprow->fill(fill(*bview, *tmprow, workWidth(*bview)));
setHeightOfRow(bview, tmprow);
- refresh_y = y;
- refresh_row = tmprow;
- status(bview, LyXText::NEED_MORE_REFRESH);
+ postPaint(*bview, y);
+
setCursor(bview, cursor.par(), cursor.pos(),
false, cursor.boundary());
//current_font = rawtmpfont;
if (row->lastPos() == row->par()->size() - 1)
removeRow(row->next());
- refresh_y = y;
- refresh_row = row;
- status(bview, LyXText::NEED_MORE_REFRESH);
+ postPaint(*bview, y);
breakAgainOneRow(bview, row);
// will the cursor be in another row now?
row->fill(fill(*bview, *row, workWidth(*bview)));
int const tmpheight = row->height();
setHeightOfRow(bview, row);
- if (tmpheight == row->height())
- status(bview, LyXText::NEED_VERY_LITTLE_REFRESH);
- else
- status(bview, LyXText::NEED_MORE_REFRESH);
- refresh_y = y;
- refresh_row = row;
+ if (tmpheight == row->height()) {
+ postRowPaint(*bview, row, y);
+ } else {
+ postPaint(*bview, y);
+ }
setCursor(bview, cursor.par(), cursor.pos(), false, cursor.boundary());
}
}
}
lastrow = 0;
- refresh_row = 0;
need_break_row = 0;
width = height = 0;
copylayouttype.erase();
- top_y(refresh_y = 0);
- status_ = LyXText::UNCHANGED;
+ top_y(0);
+ clearPaint();
} else if (firstrow)
return;
}
+void LyXText::clearPaint()
+{
+ status_ = UNCHANGED;
+ refresh_row = 0;
+ refresh_y = 0;
+}
+
+
+void LyXText::postChangedInDraw()
+{
+ status_ = CHANGED_IN_DRAW;
+}
+
+
+void LyXText::postPaint(BufferView & bv, int start_y)
+{
+ status_ = NEED_MORE_REFRESH;
+ refresh_y = start_y;
+ refresh_row = 0;
+
+ if (!inset_owner)
+ return;
+
+ // We are an inset's lyxtext. Tell the top-level lyxtext
+ // it needs to update the row we're in.
+
+ LyXText * t = bv.text;
+
+ // FIXME: but what if this row is below ?
+ if (!t->refresh_row) {
+ t->refresh_row = t->cursor.row();
+ t->refresh_y = t->cursor.y() - t->cursor.row()->baseline();
+ }
+}
+
+
+// FIXME: we should probably remove this y parameter,
+// make refresh_y be 0, and use row->y etc.
+void LyXText::postRowPaint(BufferView & bv, Row * row, int start_y)
+{
+ // FIXME: shouldn't this check that we're not updating
+ // above the existing refresh_y ??
+ if (status_ == NEED_MORE_REFRESH)
+ return;
+
+ status_ = NEED_VERY_LITTLE_REFRESH;
+ refresh_y = start_y;
+ refresh_row = row;
+
+ if (!inset_owner)
+ return;
+
+ // We are an inset's lyxtext. Tell the top-level lyxtext
+ // it needs to update the row we're in.
+
+ LyXText * t = bv.text;
+
+ // FIXME: but what if this new row is above ?
+ // Why the !t->refresh_row at all ?
+ if (!t->refresh_row) {
+ t->refresh_row = t->cursor.row();
+ t->refresh_y = t->cursor.y() - t->cursor.row()->baseline();
+ }
+}
+
+
bool LyXText::isTopLevel() const
{
/// only the top-level lyxtext has a non-null bv owner
par->params().startOfAppendix(start);
// we can set the refreshing parameters now
- status(cmd.view(), LyXText::NEED_MORE_REFRESH);
updateCounters(cmd.view());
redoHeightOfParagraph(bv);
- refresh_y = 0;
- refresh_row = 0;
+ postPaint(*cmd.view(), 0);
setCursor(cmd.view(), cursor.par(), cursor.pos());
update(bv);
break;