Proof of principle, rough and ready. See patch.
On Fri, May 13, 2005 at 06:15:25PM +0300, Martin Vermeer wrote: > > Did some with the Users' Guide. The operation performed was character insert > by holding the > 'a' key down. I just counted how many seconds until reaching the right edge... > > Results: > > 1) In a fresh empty document: 7 s (for comparison: right-arrowing from the > left to the right > edge of a paragraph takes 6 s, so this is OK) Unchanged. > 2) In a screen packed with text (full paragraphs, at most one sectioning > header): 22 s, 28 s > (two different places) 11s, 13 s. > 3) In a rather empty screen (enum lists with one word per item): 10 s. (not done) I think it clearly works, at a modest cost in extra code and complexity. 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 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? - Martin
Index: BufferView.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.C,v retrieving revision 1.260 diff -u -p -r1.260 BufferView.C --- BufferView.C 22 Feb 2005 11:41:19 -0000 1.260 +++ BufferView.C 13 May 2005 18:33:05 -0000 @@ -142,9 +142,9 @@ bool BufferView::fitCursor() } -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); } 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 13 May 2005 18:33:05 -0000 @@ -81,7 +81,8 @@ public: * position changes. \c forceupdate means to force an update * in any case. */ - void update(bool fitcursor = true, bool forceupdate = true); + void update(bool fitcursor = true, bool forceupdate = true, + bool onlypar = false); /// move the screen to fit the cursor. Only to be called with /// good y coordinates (after a bv::metrics) bool fitCursor(); Index: BufferView_pimpl.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.583 diff -u -p -r1.583 BufferView_pimpl.C --- BufferView_pimpl.C 11 May 2005 07:44:18 -0000 1.583 +++ BufferView_pimpl.C 13 May 2005 18:33:05 -0000 @@ -606,7 +606,8 @@ bool BufferView::Pimpl::fitCursor() } -void BufferView::Pimpl::update(bool fitcursor, bool forceupdate) +void BufferView::Pimpl::update(bool fitcursor, bool forceupdate, + bool onlypar) { lyxerr << BOOST_CURRENT_FUNCTION << "[fitcursor = " << fitcursor << ',' @@ -635,7 +636,7 @@ void BufferView::Pimpl::update(bool fitc if (fitcursor && fitCursor()) { forceupdate = true; - vi = metrics(); + vi = metrics(onlypar); } if (forceupdate) { // Second drawing step @@ -1246,7 +1247,7 @@ bool BufferView::Pimpl::dispatch(FuncReq } -ViewMetricsInfo BufferView::Pimpl::metrics() +ViewMetricsInfo BufferView::Pimpl::metrics(bool onlypar) { // Remove old position cache theCoords.clear(); @@ -1274,14 +1275,12 @@ ViewMetricsInfo BufferView::Pimpl::metri // Redo paragraphs above cursor if necessary int y1 = y0; - while (y1 > 0 && pit1 > 0) { + while (!onlypar && y1 > 0 && pit1 > 0) { y1 -= text->getPar(pit1).ascent(); --pit1; text->redoParagraph(pit1); y1 -= text->getPar(pit1).descent(); } - - // Take care of ascent of first line y1 -= text->getPar(pit1).ascent(); @@ -1298,7 +1297,7 @@ ViewMetricsInfo BufferView::Pimpl::metri // Redo paragraphs below cursor if necessary int y2 = y0; - while (y2 < bv.workHeight() && pit2 < int(npit) - 1) { + while (!onlypar && y2 < bv.workHeight() && pit2 < int(npit) - 1) { y2 += text->getPar(pit2).descent(); ++pit2; text->redoParagraph(pit2); 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 13 May 2005 18:33:05 -0000 @@ -33,7 +33,6 @@ #include <boost/shared_ptr.hpp> #include <boost/signals/trackable.hpp> - class Change; class LyXKeySym; class LyXView; @@ -60,7 +59,8 @@ public: // bool fitCursor(); /// - void update(bool fitcursor = false, bool forceupdate = true); + void update(bool fitcursor = false, bool forceupdate = true, + bool onlypar = false); /// void newFile(std::string const &, std::string const &, bool); /// @@ -186,7 +186,7 @@ private: /// int offset_ref_; /// - ViewMetricsInfo metrics(); + ViewMetricsInfo metrics(bool onlypar = false); }; Index: text.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v retrieving revision 1.601 diff -u -p -r1.601 text.C --- text.C 5 May 2005 18:33:47 -0000 1.601 +++ text.C 13 May 2005 18:33:05 -0000 @@ -1649,7 +1649,7 @@ Row const & LyXText::firstRow() const } -void LyXText::redoParagraph(pit_type const pit) +bool LyXText::redoParagraph(pit_type const pit) { // remove rows of paragraph, keep track of height changes Paragraph & par = pars_[pit]; @@ -1700,8 +1700,15 @@ void LyXText::redoParagraph(pit_type con dim.asc += par.rows()[0].ascent(); dim.des -= par.rows()[0].ascent(); + + bool same((dim.wid == par.dim().wid) && + (dim.asc == par.dim().asc) && + (dim.des == par.dim().des)); + par.dim() = dim; //lyxerr << "redoParagraph: " << par.rows().size() << " rows\n"; + + return !same; } Index: text3.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v retrieving revision 1.293 diff -u -p -r1.293 text3.C --- text3.C 5 May 2005 13:13:56 -0000 1.293 +++ text3.C 13 May 2005 18:33:05 -0000 @@ -1129,10 +1129,15 @@ void LyXText::dispatch(LCursor & cur, Fu cur.resetAnchor(); moveCursor(cur, false); + needsUpdate = redoParagraph(cur.pit()); + if (!needsUpdate) + // update only this paragraph + cur.bv().update(false, true, true); + // real_current_font.number can change so we need to // update the minibuffer if (old_font != real_current_font) - bv->updateScrollbar(); + bv->updateScrollbar(); break; }
pgpyETOdz8hRe.pgp
Description: PGP signature