>>>>> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:
Martin> On Fri, 2005-10-07 at 15:30 +0200, Jean-Marc Lasgouttes wrote: >> >>>>> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes: >> Martin> You're in good company. But your patch works... for page down. Martin> Apparently it should be extended for cursorPrevious ;-) >> Yes, I mentioned that in my message. Should I apply it as-is or >> try to use metrics() instead of update()? Do we care? Martin> Which is best for understandability? It is more a matter of speed, the drawing phase is unwanted. I guess we do not really care for now. Actually, dEPM could do it in a finer way by removing a paragraph and updating the cached values for all paragraphs after it (it is just a vertical translation). Here is the combined patch I came up with. JMarc
Index: src/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v retrieving revision 1.2298 diff -u -p -r1.2298 ChangeLog --- src/ChangeLog 7 Oct 2005 12:00:39 -0000 1.2298 +++ src/ChangeLog 7 Oct 2005 13:45:32 -0000 @@ -1,3 +1,14 @@ +2005-10-07 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * text.C (setCursorFromCoordinates): return a bool telling whether + dEPM triggered. + + * text3.C (cursorPrevious): update if needed after + setCursorFromCoordinates (when dEPM triggered). + + * text2.C (cursorDown, cursorUp): make sure to reset the anchor + (otherwise the anchor may be completely wrong and make dEPM assert). + 2005-10-07 Martin Vermeer <[EMAIL PROTECTED]> * BufferView_pimpl.C (update): choose arguments to update call so Index: src/lyxtext.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v retrieving revision 1.327 diff -u -p -r1.327 lyxtext.h --- src/lyxtext.h 20 Sep 2005 08:31:34 -0000 1.327 +++ src/lyxtext.h 7 Oct 2005 13:45:32 -0000 @@ -176,8 +176,8 @@ public: void recUndo(pit_type first, pit_type last) const; /// void recUndo(pit_type first) const; - /// - void setCursorFromCoordinates(LCursor & cur, int x, int y); + /// returns true if par was empty and was removed + bool setCursorFromCoordinates(LCursor & cur, int x, int y); /// InsetBase * editXY(LCursor & cur, int x, int y); /// Move cursor one line up. Index: src/text.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v retrieving revision 1.631 diff -u -p -r1.631 text.C --- src/text.C 5 Oct 2005 08:41:22 -0000 1.631 +++ src/text.C 7 Oct 2005 13:45:32 -0000 @@ -2315,7 +2315,7 @@ pos_type LyXText::x2pos(pit_type pit, in // x,y are screen coordinates // sets cursor only within this LyXText -void LyXText::setCursorFromCoordinates(LCursor & cur, int const x, int const y) +bool LyXText::setCursorFromCoordinates(LCursor & cur, int const x, int const y) { pit_type pit = getPitNearY(y); int yy = theCoords.get(this, pit).y_ - pars_[pit].ascent(); @@ -2354,5 +2354,5 @@ void LyXText::setCursorFromCoordinates(L << " pos: " << pos << endl; - setCursor(cur, pit, pos, true, bound); + return setCursor(cur, pit, pos, true, bound); } Index: src/text2.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v retrieving revision 1.632 diff -u -p -r1.632 text2.C --- src/text2.C 26 Sep 2005 22:54:12 -0000 1.632 +++ src/text2.C 7 Oct 2005 13:45:32 -0000 @@ -1056,6 +1056,7 @@ bool LyXText::cursorUp(LCursor & cur) int const y = bv_funcs::getPos(cur, cur.boundary()).y_; LCursor old = cur; editXY(cur, x, y - par.rows()[row].ascent() - 1); + cur.clearSelection(); // This happens when you move out of an inset. // And to give the DEPM the possibility of doing @@ -1101,6 +1102,7 @@ bool LyXText::cursorDown(LCursor & cur) int const y = bv_funcs::getPos(cur, cur.boundary()).y_; LCursor old = cur; editXY(cur, x, y + par.rows()[row].descent() + 1); + cur.clearSelection(); // This happens when you move out of an inset. // And to give the DEPM the possibility of doing Index: src/text3.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v retrieving revision 1.310 diff -u -p -r1.310 text3.C --- src/text3.C 7 Oct 2005 12:00:40 -0000 1.310 +++ src/text3.C 7 Oct 2005 13:45:32 -0000 @@ -190,8 +190,10 @@ bool LyXText::cursorPrevious(LCursor & c int x = cur.x_target(); - setCursorFromCoordinates(cur, x, 0); - bool updated = cursorUp(cur); + bool updated = setCursorFromCoordinates(cur, x, 0); + if (updated) + cur.bv().update(); + updated |= cursorUp(cur); if (cpar == cur.pit() && cpos == cur.pos()) { // we have a row which is taller than the workarea. The @@ -211,8 +213,10 @@ bool LyXText::cursorNext(LCursor & cur) lyx::pit_type cpar = cur.pit(); int x = cur.x_target(); - setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1); - bool updated = cursorDown(cur); + bool updated = setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1); + if (updated) + cur.bv().update(); + updated |= cursorDown(cur); if (cpar == cur.pit() && cpos == cur.pos()) { // we have a row which is taller than the workarea. The