]> git.lyx.org Git - lyx.git/blobdiff - src/Text3.cpp
* Only enter inset which return true on isActive(). This is the behavior in the curso...
[lyx.git] / src / Text3.cpp
index 4584d6932bc21a488232dbfa0db3a53c9d6e646a..d3a4d376e69bc3b22f63a56b7c65c83fa749916f 100644 (file)
@@ -99,7 +99,6 @@ namespace {
        Font freefont(Font::ALL_IGNORE);
        bool toggleall = false;
 
-
        void toggleAndShow(Cursor & cur, Text * text,
                Font const & font, bool toggleall = true)
        {
@@ -108,13 +107,10 @@ namespace {
                if (font.language() != ignore_language ||
                                font.number() != Font::IGNORE) {
                        Paragraph & par = cur.paragraph();
-                       text->bidi.computeTables(par, cur.buffer(), cur.textRow());
-                       if (cur.boundary() !=
-                                       text->bidi.isBoundary(cur.buffer(), par,
-                                                       cur.pos(),
-                                                       text->real_current_font))
+                       if (cur.boundary() != text->isRTLBoundary(cur.buffer(), par,
+                                               cur.pos(), text->real_current_font))
                                text->setCursor(cur, cur.pit(), cur.pos(),
-                                               false, !cur.boundary());
+                                               false, !cur.boundary());
                }
        }
 
@@ -301,7 +297,7 @@ bool Text::isRTL(Buffer const & buffer, Paragraph const & par) const
 
 bool Text::isRTL(Buffer const & buffer, CursorSlice const & sl, bool boundary) const
 {
-       if (!sl.text())
+       if (!lyxrc.rtl_support && !sl.text())
                return false;
 
        int correction = 0;
@@ -313,6 +309,42 @@ bool Text::isRTL(Buffer const & buffer, CursorSlice const & sl, bool boundary) c
 }
 
 
+bool Text::isRTLBoundary(Buffer const & buffer, Paragraph const & par,
+                         pos_type pos) const
+{
+       if (!lyxrc.rtl_support)
+               return false;
+
+       // no RTL boundary at line start
+       if (pos == 0)
+               return false;
+
+       bool left = getFont(buffer, par, pos - 1).isVisibleRightToLeft();
+       bool right;
+       if (pos == par.size())
+               right = par.isRightToLeftPar(buffer.params());
+       else
+               right = getFont(buffer, par, pos).isVisibleRightToLeft();
+       return left != right;
+}
+
+
+bool Text::isRTLBoundary(Buffer const & buffer, Paragraph const & par,
+                         pos_type pos, Font const & font) const
+{
+       if (!lyxrc.rtl_support)
+               return false;
+
+       bool left = font.isVisibleRightToLeft();
+       bool right;
+       if (pos == par.size())
+               right = par.isRightToLeftPar(buffer.params());
+       else
+               right = getFont(buffer, par, pos).isVisibleRightToLeft();
+       return left != right;
+}
+
+
 void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 {
        LYXERR(Debug::ACTION) << "Text::dispatch: cmd: " << cmd << endl;
@@ -457,8 +489,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                && cur.boundary() == oldBoundary) {
                        cur.undispatched();
                        cmd = FuncRequest(LFUN_FINISHED_RIGHT);
-               }
-               if (cur.selection())
+               } else if (cur.selection())
                        saveSelection(cur);
                break;
 
@@ -1047,8 +1078,10 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                bv->switchKeyMap();
                                bv->buffer()->markDirty();
                                finishUndo();
-                       } else
+                       } else {
+                               bv->mouseSetCursor(cur);
                                lyx::dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph"));
+                       }
                }
 
                // we have to update after dePM triggered
@@ -1341,7 +1374,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_MATH_DELIM:
        case LFUN_MATH_BIGDELIM: {
                cur.insert(new InsetMathHull(hullSimple));
-               cur.dispatch(FuncRequest(LFUN_CHAR_FORWARD));
+               checkAndActivateInset(cur, true);
                BOOST_ASSERT(cur.inMathed());
                cur.dispatch(cmd);
                break;