On Wed, Sep 28, 2005 at 11:28:33AM +0200, Jean-Marc Lasgouttes wrote:
> >>>>> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:
>
> Martin> Alternatively, should we really try to interpret every boolean
> Martin> that gets returned somewhere as a sign that the screen needs
> Martin> updating?
>
> I do not like how this is basically removing Andre's effort of
> avoiding updates for no particular reason.
>
> As I understand it, it goes like:
>
> * beginning of LyXText::dispatch
>
> bool needsUpdate = !lyxaction.funcHasFlag(cmd.action,
> LyXAction::NoUpdate);
>
> So we have marked in LyXAction some lfuns which have no reason to
> require an update.
>
> * handling of such an lfun
>
> case LFUN_UP_PARAGRAPH:
> if (!cur.mark())
> cur.clearSelection();
> needsUpdate = cursorUpParagraph(cur);
> finishChange(cur, false);
> break;
>
> needsUpdate was false in this case, we set it to true only if DEPM
> triggered.
>
> * end of LyXFunc::dispatch
>
> default: {
> view()->cursor().dispatch(cmd);
> update |= view()->cursor().result().update();
> if (!view()->cursor().result().dispatched())
> update |= view()->dispatch(cmd);
> break;
> }
> }
>
> if (view()->available()) {
> // Redraw screen unless explicitly told otherwise.
> // This also initializes the position cache for all
> insets
> // in (at least partially) visible top-level paragraphs.
> if (update)
> view()->update(Update::FitCursor |
> Update::Force);
> else
> view()->update(Update::FitCursor);
>
> We dispatch to the cursor position, and look at the result. Depending
> on this result, we do the required update (seeing whether we changed
> screen is handled by Update::FitCursor of course).
>
> So my question is what is _your_ vision of the update mechanism. I
> guess I do not understand why you change the logic in
> BufferView::Pimpl::update.Slowly grasping it... perhaps you'll like the attached more. Note: no change to lyxfunc. Same functionality (I checked) - Martin
Index: ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.2291
diff -u -p -r1.2291 ChangeLog
--- ChangeLog 27 Sep 2005 08:48:52 -0000 1.2291
+++ ChangeLog 28 Sep 2005 12:09:33 -0000
@@ -1,3 +1,15 @@
+2005-09-28 Martin Vermeer <[EMAIL PROTECTED]>
+
+ * BufferView_pimpl.C (update): choose arguments to update call so
+ that single-par update works most times
+ * text3.C (dispatch): carefully tune updating separately for
+ whole-screen and current-paragraph (yes, can probably be sanitized)
+ * rowpainter.C (paintText): 1) replace painting by caching for
+ the two extra paragraphs, because we can;
+ 2) suppress greying out of areas below/above drawn area in case of
+ single-par refresh
+ * lyxfunc.C (dispatch): remove superfluous update
+
2005-09-27 J�rgen Spitzm�ller <[EMAIL PROTECTED]>
* text.C (redoParagraph): fix calcultation of inset width wrt
Index: BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.595
diff -u -p -r1.595 BufferView_pimpl.C
--- BufferView_pimpl.C 15 Sep 2005 13:55:45 -0000 1.595
+++ BufferView_pimpl.C 28 Sep 2005 12:09:34 -0000
@@ -666,12 +666,12 @@ void BufferView::Pimpl::update(Update::f
theCoords.startUpdating();
// First drawing step
- ViewMetricsInfo vi = metrics();
+ ViewMetricsInfo vi = metrics(flags & Update::SinglePar);
bool forceupdate(flags & Update::Force);
if ((flags & Update::FitCursor) && fitCursor()) {
forceupdate = true;
- vi = metrics(flags & Update::SinglePar);
+ vi = metrics();
}
if (forceupdate) {
// Second drawing step
@@ -1327,23 +1327,22 @@ ViewMetricsInfo BufferView::Pimpl::metri
int pit2 = pit;
size_t const npit = text->paragraphs().size();
- lyxerr[Debug::DEBUG]
- << BOOST_CURRENT_FUNCTION
- << " npit: " << npit
- << " pit1: " << pit1
- << " pit2: " << pit2
- << endl;
-
- // Rebreak anchor par
- text->redoParagraph(pit);
- int y0 = text->getPar(pit1).ascent() - offset_ref_;
+ // Rebreak anchor paragraph. In Single Paragraph mode, rebreak only
+ // 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())
+ text->redoParagraph(pit);
+ int y0 = text->getPar(pit).ascent() - offset_ref_;
- // Redo paragraphs above cursor if necessary
+ // Redo paragraphs above anchor if necessary; again, in Single Par
+ // mode, only if we encounter the (main text) one having the cursor.
int y1 = y0;
- while (!singlepar && y1 > 0 && pit1 > 0) {
+ while (y1 > 0 && pit1 > 0) {
y1 -= text->getPar(pit1).ascent();
--pit1;
- text->redoParagraph(pit1);
+ if (!singlepar || pit1 == cursor_.bottom().pit())
+ text->redoParagraph(pit1);
y1 -= text->getPar(pit1).descent();
}
@@ -1362,12 +1361,14 @@ ViewMetricsInfo BufferView::Pimpl::metri
anchor_ref_ = 0;
}
- // Redo paragraphs below cursor if necessary
+ // Redo paragraphs below the anchor if necessary. Single par mode:
+ // only the one containing the cursor if encountered.
int y2 = y0;
- while (!singlepar && y2 < bv.workHeight() && pit2 < int(npit) - 1) {
+ while (y2 < bv.workHeight() && pit2 < int(npit) - 1) {
y2 += text->getPar(pit2).descent();
++pit2;
- text->redoParagraph(pit2);
+ if (!singlepar || pit2 == cursor_.bottom().pit())
+ text->redoParagraph(pit2);
y2 += text->getPar(pit2).ascent();
}
@@ -1379,13 +1380,28 @@ ViewMetricsInfo BufferView::Pimpl::metri
for (lyx::pit_type pit = pit1; pit <= pit2; ++pit) {
y += text->getPar(pit).ascent();
theCoords.parPos()[text][pit] = Point(0, y);
+ if (singlepar && pit == cursor_.bottom().pit()) {
+ // In Single Paragraph mode, collect here the
+ // y1 and y2 of the (one) paragraph the cursor is in
+ y1 = y - text->getPar(pit).ascent();
+ y2 = y + text->getPar(pit).descent();
+ }
y += text->getPar(pit).descent();
}
+ if (singlepar) { // collect cursor paragraph iter bounds
+ pit1 = cursor_.bottom().pit();
+ pit2 = cursor_.bottom().pit();
+ }
+
lyxerr[Debug::DEBUG]
<< BOOST_CURRENT_FUNCTION
<< " y1: " << y1
<< " y2: " << y2
+ << " pit1: " << pit1
+ << " pit2: " << pit2
+ << " npit: " << npit
+ << " singlepar: " << singlepar
<< endl;
return ViewMetricsInfo(pit1, pit2, y1, y2, singlepar);
Index: text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.308
diff -u -p -r1.308 text3.C
--- text3.C 27 Sep 2005 08:42:28 -0000 1.308
+++ text3.C 28 Sep 2005 12:09:34 -0000
@@ -1117,6 +1117,9 @@ void LyXText::dispatch(LCursor & cur, Fu
current_font.setLanguage(lang);
real_current_font.setLanguage(lang);
+ // Remember the old paragraph metric
+ Dimension olddim = cur.paragraph().dim();
+
string::const_iterator cit = cmd.argument.begin();
string::const_iterator end = cmd.argument.end();
for (; cit != end; ++cit)
@@ -1125,10 +1128,11 @@ void LyXText::dispatch(LCursor & cur, Fu
cur.resetAnchor();
moveCursor(cur, false);
-
- needsUpdate = redoParagraph(cur.pit());
+ // Inserting characters changes par height
+ needsUpdate = cur.paragraph().dim().asc != olddim.asc ||
+ cur.paragraph().dim().des != olddim.des;
if (!needsUpdate) {
- // update only this paragraph
+ // if not, update _only_ this paragraph
cur.bv().update(Update::SinglePar | Update::Force);
}
Index: rowpainter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v
retrieving revision 1.157
diff -u -p -r1.157 rowpainter.C
--- rowpainter.C 19 Sep 2005 11:18:20 -0000 1.157
+++ rowpainter.C 28 Sep 2005 12:09:35 -0000
@@ -769,30 +769,30 @@ void paintText(BufferView const & bv, Vi
yy += text->getPar(pit).descent();
}
-
- // paint one paragraph above and one below
+ // Cache one paragraph above and one below
// Note MV: this cannot be suppressed even for singlepar.
// Try viewing the User Guide Mobius figure
+
if (vi.p1 > 0) {
text->redoParagraph(vi.p1 - 1);
- paintPar(pi, *bv.text(), vi.p1 - 1, 0,
- vi.y1 - text->getPar(vi.p1 - 1).descent());
+ 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) {
text->redoParagraph(vi.p2 + 1);
- paintPar(pi, *bv.text(), vi.p2 + 1, 0,
- vi.y2 + text->getPar(vi.p2 + 1).ascent());
+ theCoords.parPos()[bv.text()][vi.p2 + 1] =
+ Point(0, vi.y2 + text->getPar(vi.p2 + 1).ascent());
}
// and grey out above (should not happen later)
// lyxerr << "par ascent: " << text->getPar(vi.p1).ascent() << endl;
- if (vi.y1 > 0)
+ if (vi.y1 > 0 && !vi.singlepar)
pain.fillRectangle(0, 0, bv.workWidth(), vi.y1,
LColor::bottomarea);
// and possibly grey out below
// lyxerr << "par descent: " << text->getPar(vi.p1).ascent() << endl;
- if (vi.y2 < bv.workHeight())
+ if (vi.y2 < bv.workHeight() && !vi.singlepar)
pain.fillRectangle(0, vi.y2, bv.workWidth(), bv.workHeight() -
vi.y2, LColor::bottomarea);
}
Index: frontends/qt2/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/ChangeLog,v
retrieving revision 1.822
diff -u -p -r1.822 ChangeLog
--- frontends/qt2/ChangeLog 26 Sep 2005 18:42:54 -0000 1.822
+++ frontends/qt2/ChangeLog 28 Sep 2005 12:09:39 -0000
@@ -1,3 +1,8 @@
+2005-09-28 Martin Vermeer <[EMAIL PROTECTED]>
+
+ * QContentPane.C (QContentPane): make times 50 msec instead of 25,
+ will consume less CPU (Thanks Angus profiling)
+
2005-09-15 J�rgen Spitzm�ller <[EMAIL PROTECTED]>
* QTabular.C: disable newpageCB when !longtabular.
Index: frontends/qt2/QContentPane.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QContentPane.C,v
retrieving revision 1.35
diff -u -p -r1.35 QContentPane.C
--- frontends/qt2/QContentPane.C 6 Jun 2005 12:34:28 -0000 1.35
+++ frontends/qt2/QContentPane.C 28 Sep 2005 12:09:39 -0000
@@ -104,7 +104,7 @@ QContentPane::QContentPane(QWorkArea * p
this, SLOT(scrollBarChanged(int)));
// Start the timer, one-shot.
- step_timer_.start(25, true);
+ step_timer_.start(50, true);
}
pgpR8p7B5LuwI.pgp
Description: PGP signature
