Martin Vermeer <[EMAIL PROTECTED]> writes: | On Fri, May 13, 2005 at 10:59:44PM +0200, Andre Poenitz wrote: >> On Fri, May 13, 2005 at 09:46:29PM +0300, Martin Vermeer wrote: >> > Actually it should be noted that paintText called from LyXScreen::redraw >> > still draws _three_ paragraphs: the one containing the cursor, and the >> > ones above and below, see rowpainter.C. I'm sure there is a good reason >> > for this when redrawing the whole screen... >> >> We need up-to-date metrics in the paragraph below to handle e.g. <Down> >> when the cursor is in the last line of a paragraph. >> >> I think this was the reason before the null painter was invented... >> >> > we could easily propagate the bool onlypar (by adding it to >> > ViewMetricsInfo?) to prevent also this, giving a further speed-up. >> > >> > Is this a sensible direction? >> >> I think so. >> >> > -void BufferView::update(bool fitcursor, bool forceupdate) >> > +void BufferView::update(bool fitcursor, bool forceupdate, bool onlypar) >> > { >> > - pimpl_->update(fitcursor, forceupdate); >> > + pimpl_->update(fitcursor, forceupdate, onlypar); >> > } >> >> Pretty much looks like the old update flags now. I knew there must have >> been a reason... >> >> enum UpdateFlags { UpdateFitCursor = 1, UpdateForce = 2, UpdateOnlyPar = >> 4 }; >> >> + void update(UpdateFlags = UpdateFitCursor | UpdateForce); >> >> >> This makes things like >> >> > + cur.bv().update(false, true, true); >> >> a bit mmore readble: >> >> cur.bv().update(UpdateForce | UpdateOnlyPar); >> >> Andre' > | So here is the patch again... OK to commit?
No. You have some fixing to do first. | -void BufferView::update(bool fitcursor, bool forceupdate) | +void BufferView::update(int updateflags) void Bufferview::update(UpdateFlags flags) | { | - pimpl_->update(fitcursor, forceupdate); | + pimpl_->update(updateflags); | } | | | Index: BufferView.h | =================================================================== | RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.h,v | retrieving revision 1.186 | diff -u -p -r1.186 BufferView.h | --- BufferView.h 26 Apr 2005 11:12:09 -0000 1.186 | +++ BufferView.h 15 May 2005 08:51:40 -0000 | @@ -81,7 +81,14 @@ public: | * position changes. \c forceupdate means to force an update | * in any case. | */ | - void update(bool fitcursor = true, bool forceupdate = true); | + | + enum UpdateFlags { | + UpdateFitCursor = 1, | + UpdateForce = 2, | + UpdateSinglePar = 4 | + }; | + | + void update(int updateflags = UpdateFitCursor | UpdateForce); void update(UpdateFlags flags = UpdateFutCursor | UpdateForce); | -void BufferView::Pimpl::update(bool fitcursor, bool forceupdate) | +void BufferView::Pimpl::update(int updateflags) void BufferView::Pimpl::update(UpdateFlags flags) | { | lyxerr << BOOST_CURRENT_FUNCTION | - << "[fitcursor = " << fitcursor << ',' | - << " forceupdate = " << forceupdate | + << "[fitcursor = " << (updateflags & UpdateFitCursor) | + << ", forceupdate = " << (updateflags & UpdateForce) | + << ", singlepar = " << (updateflags & UpdateSinglePar) | << "] buffer: " << buffer_ << endl; | | // Check needed to survive LyX startup | @@ -632,10 +633,11 @@ void BufferView::Pimpl::update(bool fitc | | // First drawing step | ViewMetricsInfo vi = metrics(); | + bool forceupdate(updateflags & UpdateForce); | | - if (fitcursor && fitCursor()) { | + if ((updateflags & UpdateFitCursor) && fitCursor()) { | forceupdate = true; | - vi = metrics(); | + vi = metrics(updateflags & UpdateSinglePar); | } | if (forceupdate) { | // Second drawing step | @@ -934,7 +936,10 @@ bool BufferView::Pimpl::workAreaDispatch | | if (cur.result().dispatched()) { | // Redraw if requested or necessary. | - update(cur.result().update(), cur.result().update()); | + if (cur.result().update()) | + update(UpdateFitCursor | UpdateForce); | + else | + update(); | } | | // See workAreaKeyPress | @@ -1246,7 +1251,7 @@ bool BufferView::Pimpl::dispatch(FuncReq | } | | | -ViewMetricsInfo BufferView::Pimpl::metrics() | +ViewMetricsInfo BufferView::Pimpl::metrics(bool singlepar) | { | // Remove old position cache | theCoords.clear(); | @@ -1274,7 +1279,7 @@ ViewMetricsInfo BufferView::Pimpl::metri | | // 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); | @@ -1298,7 +1303,7 @@ ViewMetricsInfo BufferView::Pimpl::metri | | // 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); | @@ -1321,5 +1326,5 @@ ViewMetricsInfo BufferView::Pimpl::metri | << " y2: " << y2 | << endl; | | - return ViewMetricsInfo(pit1, pit2, y1, y2); | + return ViewMetricsInfo(pit1, pit2, y1, y2, singlepar); | } | Index: BufferView_pimpl.h | =================================================================== | RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.h,v | retrieving revision 1.127 | diff -u -p -r1.127 BufferView_pimpl.h | --- BufferView_pimpl.h 19 Jan 2005 15:03:26 -0000 1.127 | +++ BufferView_pimpl.h 15 May 2005 08:51:40 -0000 | @@ -60,7 +60,7 @@ public: | // | bool fitCursor(); | /// | - void update(bool fitcursor = false, bool forceupdate = true); | + void update(int updateflags = UpdateForce); void update(UpdateFlags flags = UpdateForce); You might also have to make en operator| for the UpdateFlags enum. -- Lgb