void LyXScreen::redraw(LyXText * text, BufferView * bv)
{
- drawFromTo(text, bv, 0, owner.height());
+ drawFromTo(text, bv, 0, owner.height(), 0, 0, text == bv->text);
expose(0, 0, owner.workWidth(), owner.height());
if (cursor_visible) {
cursor_visible = false;
- showCursor(text, bv);
+ bv->showCursor();
}
}
void LyXScreen::drawFromTo(LyXText * text, BufferView * bv,
- int y1, int y2, int y_offset, int x_offset)
+ int y1, int y2, int y_offset, int x_offset,
+ bool internal)
{
int y_text = text->first + y1;
// y1 is now the real beginning of row on the screen
while (row != 0 && y < y2) {
- LyXText::text_status st = bv->text->status();
- do {
- bv->text->status(bv, st);
+ LyXText::text_status st = text->status();
+ text->getVisibleRow(bv, y + y_offset,
+ x_offset, row, y + text->first);
+ internal = internal && (st != LyXText::CHANGED_IN_DRAW);
+ while(internal && text->status() == LyXText::CHANGED_IN_DRAW) {
+ if (text->fullRebreak(bv)) {
+ st = LyXText::NEED_MORE_REFRESH;
+ text->setCursor(bv, text->cursor.par(), text->cursor.pos());
+ }
+ text->status(bv, st);
text->getVisibleRow(bv, y + y_offset,
- x_offset, row, y + text->first);
- } while (bv->text->status() == LyXText::CHANGED_IN_DRAW);
- bv->text->status(bv, st);
+ x_offset, row, y + text->first);
+ }
y += row->height();
row = row->next();
}
if (((y + row->height()) > 0) &&
((y - row->height()) <= static_cast<int>(owner.height()))) {
// ok there is something visible
+#if 0
LyXText::text_status st = bv->text->status();
do {
bv->text->status(bv, st);
text->getVisibleRow(bv, y, x_offset, row,
y + text->first);
- } while (bv->text->status() == LyXText::CHANGED_IN_DRAW);
+ } while (!text->inset_owner &&
+ text->status() == LyXText::CHANGED_IN_DRAW);
bv->text->status(bv, st);
+#else
+ text->getVisibleRow(bv, y, x_offset, row, y + text->first);
+#endif
}
force_clear = false;
}
/* draws the screen, starting with textposition y. uses as much already
-* printed pixels as possible */
+ * printed pixels as possible */
void LyXScreen::draw(LyXText * text, BufferView * bv, unsigned int y)
{
if (cursor_visible) hideCursor();
int const old_first = text->first;
+ bool internal = (text == bv->text);
text->first = y;
// is any optimiziation possible?
if ((y - old_first) < owner.height()
- && (old_first - y) < owner.height()) {
+ && (old_first - y) < owner.height())
+ {
if (text->first < old_first) {
- drawFromTo(text, bv, 0, old_first - text->first);
+ drawFromTo(text, bv, 0, old_first - text->first, 0, 0, internal);
XCopyArea (fl_get_display(),
owner.getWin(),
owner.getWin(),
old_first - text->first);
} else {
drawFromTo(text, bv,
- owner.height() + old_first - text->first,
- owner.height());
+ owner.height() + old_first - text->first,
+ owner.height(), 0, 0, internal);
XCopyArea (fl_get_display(),
owner.getWin(),
owner.getWin(),
}
} else {
// make a dumb new-draw
- drawFromTo(text, bv, 0, owner.height());
+ drawFromTo(text, bv, 0, owner.height(), 0, 0, internal);
expose(0, 0, owner.workWidth(), owner.height());
}
}
}
-void LyXScreen::cursorToggle(LyXText const * text, BufferView const * bv)
+void LyXScreen::cursorToggle(BufferView * bv) const
{
if (cursor_visible)
- hideCursor();
+ bv->hideCursor();
else
- showCursor(text, bv);
+ bv->showCursor();
}
void LyXScreen::update(LyXText * text, BufferView * bv,
- int y_offset, int x_offset)
+ int y_offset, int x_offset)
{
switch (text->status()) {
case LyXText::NEED_MORE_REFRESH:
int const y = max(int(text->refresh_y - text->first), 0);
drawFromTo(text, bv, y, owner.height(), y_offset, x_offset);
text->refresh_y = 0;
- text->status(bv, LyXText::UNCHANGED);
+ // otherwise this is called ONLY from BufferView_pimpl(update)
+ // or we should see to set this flag accordingly
+ if (text != bv->text)
+ text->status(bv, LyXText::UNCHANGED);
expose(0, y, owner.workWidth(), owner.height() - y);
}
break;
// ok I will update the current cursor row
drawOneRow(text, bv, text->refresh_row, text->refresh_y,
y_offset, x_offset);
- text->status(bv, LyXText::UNCHANGED);
- expose(0, text->refresh_y - text->first + y_offset,
- owner.workWidth(), text->refresh_row->height());
+ // this because if we had a major update the refresh_row could
+ // have been set to 0!
+ if (text->refresh_row) {
+ // otherwise this is called ONLY from BufferView_pimpl(update)
+ // or we should see to set this flag accordingly
+ if (text != bv->text)
+ text->status(bv, LyXText::UNCHANGED);
+ expose(0, text->refresh_y - text->first + y_offset,
+ owner.workWidth(), text->refresh_row->height());
+ }
}
break;
case LyXText::CHANGED_IN_DRAW: // just to remove the warning