]> git.lyx.org Git - lyx.git/blobdiff - src/text3.C
Two fixes involving RtL text drawing
[lyx.git] / src / text3.C
index 35fc074caf94ed8bd045b2357b98e63c9d54204f..5718a20136762361bf5ada5949da4777f81c62c0 100644 (file)
@@ -292,6 +292,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
        BOOST_ASSERT(cur.text() == this);
        BufferView * bv = &cur.bv();
        CursorSlice oldTopSlice = cur.top();
+       bool oldBoundary = cur.boundary();
        bool sel = cur.selection();
        bool needsUpdate = !lyxaction.funcHasFlag(cmd.action, LyXAction::NoUpdate);
 
@@ -406,14 +407,16 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
 
        case LFUN_RIGHT:
        case LFUN_RIGHTSEL:
-               lyxerr << BOOST_CURRENT_FUNCTION
-                      << " LFUN_RIGHT[SEL]:\n" << cur << endl;
+               //lyxerr << BOOST_CURRENT_FUNCTION
+               //       << " LFUN_RIGHT[SEL]:\n" << cur << endl;
                cur.selHandle(cmd.action == LFUN_RIGHTSEL);
                if (isRTL(cur.paragraph()))
                        needsUpdate = cursorLeft(cur);
                else
                        needsUpdate = cursorRight(cur);
-               if (!needsUpdate && oldTopSlice == cur.top()) {
+
+               if (!needsUpdate && oldTopSlice == cur.top()
+                               && cur.boundary() == oldBoundary) {
                        cur.undispatched();
                        cmd = FuncRequest(LFUN_FINISHED_RIGHT);
                }
@@ -427,7 +430,9 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                        needsUpdate = cursorRight(cur);
                else
                        needsUpdate = cursorLeft(cur);
-               if (oldTopSlice == cur.top()) {
+
+               if (!needsUpdate && oldTopSlice == cur.top()
+                       && cur.boundary() == oldBoundary) {
                        cur.undispatched();
                        cmd = FuncRequest(LFUN_FINISHED_LEFT);
                }
@@ -438,8 +443,10 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                update(cur);
                //lyxerr << "handle LFUN_UP[SEL]:\n" << cur << endl;
                cur.selHandle(cmd.action == LFUN_UPSEL);
+
                needsUpdate = cursorUp(cur);
-               if (oldTopSlice == cur.top()) {
+               if (!needsUpdate && oldTopSlice == cur.top()
+                         && cur.boundary() == oldBoundary) {
                        cur.undispatched();
                        cmd = FuncRequest(LFUN_FINISHED_UP);
                }
@@ -451,7 +458,9 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                //lyxerr << "handle LFUN_DOWN[SEL]:\n" << cur << endl;
                cur.selHandle(cmd.action == LFUN_DOWNSEL);
                needsUpdate = cursorDown(cur);
-               if (oldTopSlice == cur.top()) {
+               if (!needsUpdate && oldTopSlice == cur.top() &&
+                   cur.boundary() == oldBoundary)
+               {
                        cur.undispatched();
                        cmd = FuncRequest(LFUN_FINISHED_DOWN);
                }
@@ -727,8 +736,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
        }
 
        case LFUN_INSET_SETTINGS:
-               if (cur.inset().asUpdatableInset())
-                       cur.inset().asUpdatableInset()->showInsetDialog(bv);
+               cur.inset().showInsetDialog(bv);
                break;
 
        case LFUN_NEXT_INSET_TOGGLE: {
@@ -819,8 +827,8 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                break;
 
        case LFUN_GETXY:
-               cur.message(convert<string>(cursorX(cur.top())) + ' '
-                         + convert<string>(cursorY(cur.top())));
+               cur.message(convert<string>(cursorX(cur.top(), cur.boundary())) + ' '
+                         + convert<string>(cursorY(cur.top(), cur.boundary())));
                break;
 
        case LFUN_SETXY: {
@@ -911,6 +919,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                cur.clearSelection();
                string const clip = bv->getClipboard();
                if (!clip.empty()) {
+                       recordUndo(cur);
                        if (cmd.argument == "paragraph")
                                insertStringAsParagraphs(cur, clip);
                        else
@@ -1245,7 +1254,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                        int const nargs = s1.empty() ? 0 : convert<int>(s1);
                        string const s2 = token(s, ' ', 2);
                        string const type = s2.empty() ? "newcommand" : s2;
-                       cur.insert(new MathMacroTemplate(token(s, ' ', 0), nargs, s2));
+                       cur.insert(new MathMacroTemplate(token(s, ' ', 0), nargs, type));
                        //cur.nextInset()->edit(cur, true);
                }
                break;
@@ -1506,13 +1515,15 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                        cur.selection() = false;
                } else {
                        cur.undispatched();
-                       cmd = FuncRequest(LFUN_FINISHED_LEFT);
+                       cmd = FuncRequest(LFUN_FINISHED_RIGHT);
                }
                break;
 
        default:
-               lyxerr << BOOST_CURRENT_FUNCTION
-                      << " Not DISPATCHED by LyXText" << endl;
+               lyxerr[Debug::ACTION] 
+                       << BOOST_CURRENT_FUNCTION
+                       << ": Command " << cmd 
+                       << " not DISPATCHED by LyXText" << endl;
                cur.undispatched();
                break;
        }