code simplification.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22225 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-12-21 09:45:04 +00:00
parent 717db0a59e
commit d3980b14a8

View File

@ -387,35 +387,27 @@ void BufferView::processUpdateFlags(Update::flags flags)
return; return;
} }
bool const full_metrics = flags & Update::Force; bool const full_metrics = flags & Update::Force || !singleParUpdate();
if (full_metrics || !singleParUpdate()) { if (full_metrics)
if (flags & Update::FitCursor && fitCursor()) {
showCursor();
return;
}
// We have to update the full screen metrics. // We have to update the full screen metrics.
updateMetrics(); updateMetrics();
}
if (!(flags & Update::FitCursor)) { if (!(flags & Update::FitCursor)) {
// Nothing to do anymore. Trigger a redraw and return
buffer_.changed(); buffer_.changed();
return; return;
} }
//FIXME: updateMetrics() does not update paragraph position // updateMetrics() does not update paragraph position
// This is done at draw() time. So we need a redraw! // This is done at draw() time. So we need a redraw!
buffer_.changed(); buffer_.changed();
if (!fitCursor())
// The screen has already been updated thanks to the
// 'buffer_.changed()' call three line above. So no need
// to redraw again.
return;
// The screen needs to be recentered around the cursor position so if (fitCursor()) {
// refresh it: // The cursor is off screen so ensure it is visible.
showCursor(); // refresh it:
showCursor();
}
} }
@ -691,9 +683,9 @@ void BufferView::showCursor()
int ypos = pm.position() + offset; int ypos = pm.position() + offset;
Dimension const & row_dim = d->cursor_.textRow().dimension(); Dimension const & row_dim = d->cursor_.textRow().dimension();
if (ypos - row_dim.ascent() < 0) if (ypos - row_dim.ascent() < 0)
scrollUp(- ypos + d->cursor_.textRow().ascent()); scrollUp(- ypos + row_dim.ascent());
else if (ypos + row_dim.descent() > height_) else if (ypos + row_dim.descent() > height_)
scrollDown(ypos - height_ + d->cursor_.textRow().descent()); scrollDown(ypos - height_ + row_dim.descent());
// else, nothing to do, the cursor is already visible so we just return. // else, nothing to do, the cursor is already visible so we just return.
return; return;
} }