]> git.lyx.org Git - lyx.git/blobdiff - src/Bidi.C
* GuiView.C (updateTab): do not update early if current tab has
[lyx.git] / src / Bidi.C
index 28e729ce0d03bf77b5ce5c78d79f4f5efe92680d..2721ef87ce06123911c1393dec059b0e05a674f7 100644 (file)
@@ -8,39 +8,38 @@
  * Full author contact details are available in file CREDITS.
  */
 
+#include <config.h>
 
 #include "Bidi.h"
 #include "buffer.h"
-#include "insets/updatableinset.h"
 #include "lyxfont.h"
 #include "lyxrow.h"
-#include "lyxrow_funcs.h"
 #include "lyxrc.h"
 #include "paragraph.h"
 
 
-using lyx::pos_type;
+namespace lyx {
 
 
-lyx::pos_type Bidi::log2vis(lyx::pos_type pos) const
+pos_type Bidi::log2vis(pos_type pos) const
 {
        return (start_ == -1) ? pos : log2vis_list_[pos - start_];
 }
 
 
-lyx::pos_type Bidi::vis2log(lyx::pos_type pos) const
+pos_type Bidi::vis2log(pos_type pos) const
 {
        return (start_ == -1) ? pos : vis2log_list_[pos - start_];
 }
 
 
-lyx::pos_type Bidi::level(lyx::pos_type pos) const
+pos_type Bidi::level(pos_type pos) const
 {
        return (start_ == -1) ? 0 : levels_[pos - start_];
 }
 
 
-bool Bidi::inRange(lyx::pos_type pos) const
+bool Bidi::inRange(pos_type pos) const
 {
        return start_ == -1 || (start_ <= pos && pos <= end_);
 }
@@ -52,7 +51,7 @@ bool Bidi::same_direction() const
 
 
 void Bidi::computeTables(Paragraph const & par,
-       Buffer const & buf, Row & row)
+       Buffer const & buf, Row const & row)
 {
        same_direction_ = true;
        if (!lyxrc.rtl_support) {
@@ -60,15 +59,13 @@ void Bidi::computeTables(Paragraph const & par,
                return;
        }
 
-       InsetOld * inset = par.inInset();
-       if (inset && inset->owner() &&
-           inset->owner()->lyxCode() == InsetOld::ERT_CODE) {
+       if (par.ownerCode() == InsetBase::ERT_CODE) {
                start_ = -1;
                return;
        }
 
        start_ = row.pos();
-       end_ = lastPos(par, row);
+       end_ = row.endpos() - 1;
 
        if (start_ > end_) {
                start_ = -1;
@@ -94,7 +91,7 @@ void Bidi::computeTables(Paragraph const & par,
        int lev = 0;
        bool rtl = false;
        bool rtl0 = false;
-       pos_type const body_pos = par.beginningOfBody();
+       pos_type const body_pos = par.beginOfBody();
 
        for (pos_type lpos = start_; lpos <= end_; ++lpos) {
                bool is_space = par.isLineSeparator(lpos);
@@ -140,7 +137,7 @@ void Bidi::computeTables(Paragraph const & par,
                        log2vis_list_[lpos - start_] = rtl ? 1 : -1;
                } else if (lev < new_level) {
                        log2vis_list_[lpos - start_] = rtl ? -1 : 1;
-                       if (new_level > rtl_par)
+                       if (new_level > 0 && !rtl_par)
                                same_direction_ = false;
                } else
                        log2vis_list_[lpos - start_] = new_rtl ? -1 : 1;
@@ -210,3 +207,6 @@ bool Bidi::isBoundary(Buffer const & buf, Paragraph const & par,
                : par.isRightToLeftPar(buf.params());
        return rtl != rtl2;
 }
+
+
+} // namespace lyx