Jean-Marc Lasgouttes wrote:
Abdelrazak Younes <[EMAIL PROTECTED]> writes:

do you have an easy fix handy ;-)
What about this... could you try please?

How come cursorLeft does not set the font correctly? I tried to follow
that code, but I am not sure I understand. Ideally, the call to
setCurrentFont should be automatic.

JMarc


Hi!

Attached find a patch which fixes this issue.

The actual fix is what's being done in the LFUN_FINISHED_* lfuns. The fixes in cursorLeft and cursorRight aren't relevant to the problem we're dealing with, but I'm pretty sure they are necessary for the cases they are meant to deal with (in fact, I think that currently the function being called is a void, although we're using it as a return?).

I don't really understand all the implications of this change --- we should understand those before applying. But it does fix the current issue.

The flow seems a little strange to me:
*) LFUN_CHAR_FORWARD calls cursorRight
*) cursorRight is in charge of almost all the cursor movement, except for the case of exiting an inset. In this case (end of last paragraph), cursorRight does nothing. *) if cursorRight did nothing (well, if it didn't set needsUpdate and a few other things) then LFUN_FINISHED_RIGHT is called. *) LFUN_FINISHED_RIGHT is where we move forward in this case, by just advancing the cursor position (and with this fix, set the font according to the new position).

I don't understand why everything can't be done in cursorRight, and what the LFUN_FINISHED_* are needed for?

Dov
diff -r cde60b203dce src/Text2.cpp
--- a/src/Text2.cpp     Sun Sep 23 00:38:38 2007 +0200
+++ b/src/Text2.cpp     Sun Sep 23 02:34:15 2007 +0200
@@ -636,7 +636,7 @@ bool Text::cursorLeft(Cursor & cur)
 
        // move to the previous paragraph or do nothing
        if (cur.pit() > 0)
-               return setCursor(cur, cur.pit() - 1, getPar(cur.pit() - 
1).size());
+               return setCursor(cur, cur.pit() - 1, getPar(cur.pit() - 
1).size(), true, false);
        return false;
 }
 
@@ -693,7 +693,7 @@ bool Text::cursorRight(Cursor & cur)
 
        // move to next paragraph
        if (cur.pit() != cur.lastpit())
-               return setCursor(cur, cur.pit() + 1, 0);
+               return setCursor(cur, cur.pit() + 1, 0, true, false);
        return false;
 }
 
diff -r cde60b203dce src/Text3.cpp
--- a/src/Text3.cpp     Sun Sep 23 00:38:38 2007 +0200
+++ b/src/Text3.cpp     Sun Sep 23 02:34:15 2007 +0200
@@ -1375,14 +1375,18 @@ void Text::dispatch(Cursor & cur, FuncRe
 
        case LFUN_FINISHED_LEFT:
                LYXERR(Debug::DEBUG) << "handle LFUN_FINISHED_LEFT:\n" << cur 
<< endl;
-               if (reverseDirectionNeeded(cur))
+               if (reverseDirectionNeeded(cur)) {
                        ++cur.pos();
+                       cur.setCurrentFont();
+               }
                break;
 
        case LFUN_FINISHED_RIGHT:
                LYXERR(Debug::DEBUG) << "handle LFUN_FINISHED_RIGHT:\n" << cur 
<< endl;
-               if (!reverseDirectionNeeded(cur))
+               if (!reverseDirectionNeeded(cur)) {
                        ++cur.pos();
+                       cur.setCurrentFont();
+               }
                break;
 
        case LFUN_LAYOUT_PARAGRAPH: {

Reply via email to