]> git.lyx.org Git - lyx.git/blobdiff - src/Bidi.cpp
Fulfill promise to Andre: TextClass_ptr --> TextClassPtr.
[lyx.git] / src / Bidi.cpp
index f90e007be16458c99ecf3a2acda875aa105c1648..02d0df8026cd10bfd7a4f7f4d4e4bed310b494a8 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "Bidi.h"
 #include "Buffer.h"
+#include "BufferView.h"
 #include "Font.h"
 #include "Row.h"
 #include "LyXRC.h"
@@ -87,14 +88,21 @@ void Bidi::computeTables(Paragraph const & par,
 
        BufferParams const & bufparams = buf.params();
        pos_type stack[2];
-       bool const rtl_par = par.isRightToLeftPar(bufparams);
+       bool const rtl_par = par.isRTL(bufparams);
        int lev = 0;
        bool rtl = false;
        bool rtl0 = false;
        pos_type const body_pos = par.beginOfBody();
 
        for (pos_type lpos = start_; lpos <= end_; ++lpos) {
-               bool is_space = par.isLineSeparator(lpos);
+               bool is_space = false;
+               // We do not handle spaces around an RTL segment in a special way anymore.
+               // Neither do we do so when generating the LaTeX, so setting is_space
+               // to false makes the view in the GUI consistent with the output of LaTeX 
+               // later. The old setting was:
+               //bool is_space = par.isLineSeparator(lpos);
+               // FIXME: once we're sure that this is what we really want, we should just
+               // get rid of this variable...
                pos_type const pos =
                        (is_space && lpos + 1 <= end_ &&
                         !par.isLineSeparator(lpos + 1) &&
@@ -190,7 +198,7 @@ bool Bidi::isBoundary(Buffer const & buf, Paragraph const & par,
        bool const rtl = level(pos - 1) % 2;
        bool const rtl2 = inRange(pos)
                ? level(pos) % 2
-               : par.isRightToLeftPar(buf.params());
+               : par.isRTL(buf.params());
        return rtl != rtl2;
 }
 
@@ -204,9 +212,27 @@ bool Bidi::isBoundary(Buffer const & buf, Paragraph const & par,
        bool const rtl = font.isVisibleRightToLeft();
        bool const rtl2 = inRange(pos)
                ? level(pos) % 2
-               : par.isRightToLeftPar(buf.params());
+               : par.isRTL(buf.params());
        return rtl != rtl2;
 }
 
 
+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().isRTL(cur.bv().buffer().params());
+}
+
+
+bool isWithinRtlParagraph(Cursor const & cur)
+{
+       return cur.innerParagraph().isRTL(cur.bv().buffer().params());
+}
+
 } // namespace lyx