Jean-Marc Lasgouttes wrote:
Richard Heck <[EMAIL PROTECTED]> writes:
Attached is a simple patch Mael wrote based on a suggestion of mine
for dealing with this bug. It seems to do the trick.
We looked at it with Martin, and the conclusion is: this is not very
nice but the wide() code is not nice either. I do not see a better
solution than what you propose.
Agreed on both scores.
So please put this in trunk and branch provided that:

- you move the method to one of the Text?.cpp file (I am not sure
  which one)
I'm not sure I understand this request. Here's the patch, for reference:

--- lyx-1.5.1-orig/src/insets/InsetText.h       2007-06-09 15:08:44.000000000 
+0200
+++ lyx-1.5.1-patch/src/insets/InsetText.h      2007-08-12 18:33:46.000000000 
+0200
@@ -123,13 +123,15 @@ public:
        /// number of cells in this inset
        size_t nargs() const { return 1; }
        ///
+       virtual bool notifyCursorLeaves(Cursor & cur) { if(wide()) 
cur.updateFlags(cur.disp_.update() | Update::Force); return false; }
+       ///
        ParagraphList & paragraphs();
        ///
        ParagraphList const & paragraphs() const;

The routine being modified here is over-riding Inset::notifyCursorLeaves(), so it can't just be moved to TextN. So you must have meant I should move the idea there, roughly speaking. But I don't see how to do that, either.

Here's what I take to be the relevant code, from Text3.cpp:
case LFUN_UP_SELECT:
case LFUN_DOWN_SELECT:
case LFUN_UP:
case LFUN_DOWN: {
// stop/start the selection
bool select = cmd.action == LFUN_DOWN_SELECT ||
cmd.action == LFUN_UP_SELECT;
cur.selHandle(select);

// move cursor up/down
bool up = cmd.action == LFUN_UP_SELECT || cmd.action == LFUN_UP;
bool const successful = cur.upDownInText(up, needsUpdate);
if (successful) {
// notify insets which were left and get their update flags
notifyCursorLeaves(cur.beforeDispatchCursor(), cur);
cur.fixIfBroken();

// redraw if you leave mathed (for the decorations)
needsUpdate |= cur.beforeDispatchCursor().inMathed();
} else
cur.undispatched();

break;
}
It's only with the call to notifyCursorLeaves()---which is in Cursor.cpp---that we get a chance to find out if we've left an inset. (There's a comment in upDownInText about leaving insets, but I don't think it's to the point) Here's that code:
bool notifyCursorLeaves(DocIterator const & old, Cursor & cur)
{
// find inset in common
size_type i;
for (i = 0; i < old.depth() && i < cur.depth(); ++i) {
if (&old.inset() != &cur.inset())
break;
}

// notify everything on top of the common part in old cursor,
// but stop if the inset claims the cursor to be invalid now
for (; i < old.depth(); ++i) {
if (old[i].inset().notifyCursorLeaves(cur))
return true;
}

return false;
}
So this returns true if an inset returns true, which is supposed to mean that the cursor is invalid. But I take it that the cursor isn't invalid---or, anyway, we've been returning false all this time, so that must be OK, and we don't just want InsetText::notifyCursorLeaves() to return true come what may. So we can't check that return value. So the way to handle this seems to be to override InsetText::notifyCursorLeaves(), so we can check wide() there---and in all of the insets we might have left---which is what I'd done.

But if you've got another idea....
-you add a FIXME indicating that this should be removed when wide() is
 gone.
I'm happy to do this.

Richard

--
==================================================================
Richard G Heck, Jr
Professor of Philosophy
Brown University
http://frege.brown.edu/heck/
==================================================================
Get my public key from http://sks.keyserver.penguin.de
Hash: 0x1DE91F1E66FFBDEC
Learn how to sign your email using Thunderbird and GnuPG at:
http://dudu.dyn.2-h.org/nist/gpg-enigmail-howto

Reply via email to