]> git.lyx.org Git - lyx.git/blobdiff - src/Bidi.cpp
* do not lookup the same macro all the time
[lyx.git] / src / Bidi.cpp
index 4df26662cb7c13807fa533835e96e269cb364553..df1f7495d6c11751b167d2cc0ceaec360e577d89 100644 (file)
@@ -12,7 +12,8 @@
 
 #include "Bidi.h"
 #include "Buffer.h"
-#include "LyXFont.h"
+#include "BufferView.h"
+#include "Font.h"
 #include "Row.h"
 #include "LyXRC.h"
 #include "Paragraph.h"
@@ -59,7 +60,7 @@ void Bidi::computeTables(Paragraph const & par,
                return;
        }
 
-       if (par.ownerCode() == Inset::ERT_CODE) {
+       if (par.ownerCode() == Inset::ERT_CODE || par.ownerCode() == Inset::LISTINGS_CODE) {
                start_ = -1;
                return;
        }
@@ -100,11 +101,11 @@ void Bidi::computeTables(Paragraph const & par,
                         !par.isLineSeparator(lpos + 1) &&
                         !par.isNewline(lpos + 1))
                        ? lpos + 1 : lpos;
-               LyXFont font = par.getFontSettings(bufparams, pos);
+               Font font = par.getFontSettings(bufparams, pos);
                if (pos != lpos && 0 < lpos && rtl0 && font.isRightToLeft() &&
-                   font.number() == LyXFont::ON &&
+                   font.number() == Font::ON &&
                    par.getFontSettings(bufparams, lpos - 1).number()
-                   == LyXFont::ON) {
+                   == Font::ON) {
                        font = par.getFontSettings(bufparams, lpos);
                        is_space = false;
                }
@@ -196,7 +197,7 @@ bool Bidi::isBoundary(Buffer const & buf, Paragraph const & par,
 
 
 bool Bidi::isBoundary(Buffer const & buf, Paragraph const & par,
-       pos_type pos, LyXFont const & font) const
+       pos_type pos, Font const & font) const
 {
        if (!lyxrc.rtl_support)
                return false;    // This is just for speedup
@@ -209,4 +210,24 @@ bool Bidi::isBoundary(Buffer const & buf, Paragraph const & par,
 }
 
 
+bool reverseDirectionNeeded(Cursor const & cur) 
+{
+       /*
+        * We determine the directions based on the direction of the
+        * bottom() --- i.e., outermost --- paragraph, because that is
+        * the only way to achieve consistency of the arrow's movements
+        * within a paragraph, and thus avoid situations in which the
+        * cursor gets stuck.
+        */
+       return cur.bottom().paragraph().isRightToLeftPar(
+                       cur.bv().buffer()->params());
+}
+
+
+bool isWithinRtlParagraph(Cursor const & cur)
+{
+       return cur.innerParagraph().isRightToLeftPar(
+               cur.bv().buffer()->params());
+}
+
 } // namespace lyx