* of the cursor. Note we cannot do this inside
* dispatch() itself, because that's called recursively.
*/
- if (available()) {
- cursor_timeout.restart();
+ if (available())
screen().showCursor(*bv_);
- }
}
}
-void BufferView::Pimpl::update(bool fitcursor, bool forceupdate)
+void BufferView::Pimpl::update(Update::flags flags)
{
lyxerr << BOOST_CURRENT_FUNCTION
- << "[fitcursor = " << fitcursor << ','
- << " forceupdate = " << forceupdate
+ << "[fitcursor = " << (flags & Update::FitCursor)
+ << ", forceupdate = " << (flags & Update::Force)
+ << ", singlepar = " << (flags & Update::SinglePar)
<< "] buffer: " << buffer_ << endl;
// Check needed to survive LyX startup
CoordCache backup;
std::swap(theCoords, backup);
-
- // This call disallows cursor blink to call
- // processEvents. It is necessary to prevent screen
- // redraw being called recursively.
- screen().unAllowSync();
+
// This, together with doneUpdating(), verifies (using
- // asserts) that screen redraw is not called from
+ // asserts) that screen redraw is not called from
// within itself.
theCoords.startUpdating();
// First drawing step
ViewMetricsInfo vi = metrics();
+ bool forceupdate(flags & Update::Force);
- if (fitcursor && fitCursor()) {
+ if ((flags & Update::FitCursor) && fitCursor()) {
forceupdate = true;
- vi = metrics();
+ vi = metrics(flags & Update::SinglePar);
}
if (forceupdate) {
// Second drawing step
if (cur.result().dispatched()) {
// Redraw if requested or necessary.
- update(cur.result().update(), cur.result().update());
+ if (cur.result().update())
+ update(Update::FitCursor | Update::Force);
+ else
+ update();
}
// See workAreaKeyPress
case LFUN_FONT_STATE:
case LFUN_INSERT_LABEL:
case LFUN_BOOKMARK_SAVE:
- case LFUN_LABEL_GOTO:
case LFUN_GOTO_PARAGRAPH:
case LFUN_GOTOERROR:
case LFUN_GOTONOTE:
flag.enabled(true);
break;
+ case LFUN_LABEL_GOTO: {
+ flag.enabled(!cmd.argument.empty()
+ || getInsetByCode<InsetRef>(cursor_, InsetBase::REF_CODE));
+ break;
+ }
+
case LFUN_BOOKMARK_GOTO:
flag.enabled(isSavedPosition(convert<unsigned int>(cmd.argument)));
break;
}
-ViewMetricsInfo BufferView::Pimpl::metrics()
+ViewMetricsInfo BufferView::Pimpl::metrics(bool singlepar)
{
// Remove old position cache
theCoords.clear();
// Redo paragraphs above cursor if necessary
int y1 = y0;
- while (y1 > 0 && pit1 > 0) {
+ while (!singlepar && y1 > 0 && pit1 > 0) {
y1 -= text->getPar(pit1).ascent();
--pit1;
text->redoParagraph(pit1);
// Redo paragraphs below cursor if necessary
int y2 = y0;
- while (y2 < bv.workHeight() && pit2 < int(npit) - 1) {
+ while (!singlepar && y2 < bv.workHeight() && pit2 < int(npit) - 1) {
y2 += text->getPar(pit2).descent();
++pit2;
text->redoParagraph(pit2);
<< " y2: " << y2
<< endl;
- return ViewMetricsInfo(pit1, pit2, y1, y2);
+ return ViewMetricsInfo(pit1, pit2, y1, y2, singlepar);
}