On Fri, Dec 09, 2005 at 11:11:20AM -0500, Bennett Helm wrote: > On Dec 9, 2005, at 10:07 AM, Jean-Marc Lasgouttes wrote:
... > >Bennett> It's a little hard to tell the order of events given that > >Bennett> things happen so quickly. But it seems like as you type, the > >Bennett> individual character that gets typed gets updated, then the > >Bennett> info bar at the bottom of the window is updated, and then the > >Bennett> whole text area of the window is updated. It's that last item > >Bennett> that seems significant: the entire window is updated with > >Bennett> each keystroke. > > > >Even when typing at top-level? We should only update the paragraph at > >cursor, I think. > > Yes. Perhaps I should add that by "text area" I include the grey area > at the bottom of a document but above the info bar. So even in a 1- > line document, most of the window area flashes when a single > character is typed. That shouldn't happen, I think. Actual, physical redrawing should only happen in the cursor paragraph in this case. I don't see the flashing either, for what that is worth. What I did test, however, was another thing: how often is redoParagraph being called. I instrumented all the calls to this routine, and the result is rather disconcerting. When adding one character to a paragraph in the middle of a screen, that paragraph is "redone" no less than three times. The ones immediately above and below twice, and all other visible (and just-outside-screen) ones, once. That's way too much. I suspect that these calls, through the singleWidth font call, cause the slowness on Mac. Instrumentation attached. - Martin
Index: bufferview_funcs.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferview_funcs.C,v retrieving revision 1.157 Index: BufferView_pimpl.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.600 diff -u -p -r1.600 BufferView_pimpl.C --- BufferView_pimpl.C 29 Nov 2005 15:08:32 -0000 1.600 +++ BufferView_pimpl.C 9 Dec 2005 18:23:21 -0000 @@ -504,6 +504,7 @@ void BufferView::Pimpl::scrollDocView(in anchor_ref_ = int(bar * t.paragraphs().size()); if (anchor_ref_ > int(t.paragraphs().size()) - 1) anchor_ref_ = int(t.paragraphs().size()) - 1; + lyxerr << "scrolldoc -"; t.redoParagraph(anchor_ref_); int const h = t.getPar(anchor_ref_).height(); offset_ref_ = int((bar * t.paragraphs().size() - anchor_ref_) * h); @@ -816,6 +817,7 @@ void BufferView::Pimpl::center() { CursorSlice & bot = cursor_.bottom(); lyx::pit_type const pit = bot.pit(); + lyxerr << "center -"; bot.text()->redoParagraph(pit); Paragraph const & par = bot.text()->paragraphs()[pit]; anchor_ref_ = pit; @@ -1351,8 +1353,10 @@ ViewMetricsInfo BufferView::Pimpl::metri // the (main text, not inset!) paragraph containing the cursor. // (if this paragraph contains insets etc., rebreaking will // recursively descend) - if (!singlepar || pit == cursor_.bottom().pit()) + if (!singlepar || pit == cursor_.bottom().pit()) { + lyxerr << "at-anchor -"; text->redoParagraph(pit); + } int y0 = text->getPar(pit).ascent() - offset_ref_; // Redo paragraphs above anchor if necessary; again, in Single Par @@ -1361,8 +1365,10 @@ ViewMetricsInfo BufferView::Pimpl::metri while (y1 > 0 && pit1 > 0) { y1 -= text->getPar(pit1).ascent(); --pit1; - if (!singlepar || pit1 == cursor_.bottom().pit()) + if (!singlepar || pit1 == cursor_.bottom().pit()) { + lyxerr << "above-anchor -"; text->redoParagraph(pit1); + } y1 -= text->getPar(pit1).descent(); } @@ -1387,8 +1393,10 @@ ViewMetricsInfo BufferView::Pimpl::metri while (y2 < bv.workHeight() && pit2 < int(npit) - 1) { y2 += text->getPar(pit2).descent(); ++pit2; - if (!singlepar || pit2 == cursor_.bottom().pit()) + if (!singlepar || pit2 == cursor_.bottom().pit()) { + lyxerr << "below-anchor -"; text->redoParagraph(pit2); + } y2 += text->getPar(pit2).ascent(); } Index: cursor.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.C,v retrieving revision 1.139 diff -u -p -r1.139 cursor.C --- cursor.C 7 Nov 2005 15:02:07 -0000 1.139 +++ cursor.C 9 Dec 2005 18:23:22 -0000 @@ -884,6 +884,7 @@ void LCursor::setTargetX() { // For now this is good enough. A better solution would be to // avoid this rebreak by setting cursorX only after drawing + lyxerr << "setTargetX -"; bottom().text()->redoParagraph(bottom().pit()); int x; int y; Index: rowpainter.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v retrieving revision 1.159 diff -u -p -r1.159 rowpainter.C --- rowpainter.C 2 Dec 2005 13:20:26 -0000 1.159 +++ rowpainter.C 9 Dec 2005 18:23:23 -0000 @@ -775,12 +775,14 @@ void paintText(BufferView const & bv, Vi // Try viewing the User Guide Mobius figure if (vi.p1 > 0) { + lyxerr << "one above -"; text->redoParagraph(vi.p1 - 1); theCoords.parPos()[bv.text()][vi.p1 - 1] = Point(0, vi.y1 - text->getPar(vi.p1 - 1).descent()); } if (vi.p2 < lyx::pit_type(text->paragraphs().size()) - 1) { + lyxerr << "one below -"; text->redoParagraph(vi.p2 + 1); theCoords.parPos()[bv.text()][vi.p2 + 1] = Point(0, vi.y2 + text->getPar(vi.p2 + 1).ascent()); Index: text.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v retrieving revision 1.637 diff -u -p -r1.637 text.C --- text.C 6 Dec 2005 14:54:21 -0000 1.637 +++ text.C 9 Dec 2005 18:23:26 -0000 @@ -1730,7 +1730,8 @@ bool LyXText::redoParagraph(pit_type con bool const same = dim == par.dim(); par.dim() = dim; - //lyxerr << "redoParagraph: " << par.rows().size() << " rows\n"; + lyxerr << "redoParagraph: " << pit << "( " << par.rows().size() + << " rows)" << std::endl; return !same; } @@ -1749,6 +1750,7 @@ void LyXText::metrics(MetricsInfo & mi, unsigned int h = 0; unsigned int w = 0; for (pit_type pit = 0, n = paragraphs().size(); pit != n; ++pit) { + lyxerr << "metric -"; redoParagraph(pit); Paragraph & par = paragraphs()[pit]; h += par.height();
pgpRFTIR1geDE.pgp
Description: PGP signature