]> git.lyx.org Git - features.git/commitdiff
* no_bidi_isboundary.patch: added isRTLBoundary as a replacement to several reference...
authorStefan Schimanski <sts@lyx.org>
Thu, 7 Jun 2007 19:50:02 +0000 (19:50 +0000)
committerStefan Schimanski <sts@lyx.org>
Thu, 7 Jun 2007 19:50:02 +0000 (19:50 +0000)
  (fixes #3790, #3801, #3809)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18704 a592a061-630c-0410-9148-cb99ea01b6c8

src/Text.cpp
src/Text.h
src/Text2.cpp
src/Text3.cpp
src/TextMetrics.cpp

index 3bac412353826f1b26552e080d48b462dc18a047..444c46ff98fcead47bccf51091d9f3194737a2f9 100644 (file)
@@ -1524,7 +1524,7 @@ void Text::drawRowSelection(PainterInfo & pi, int x, Row const & row,
                // but for RTL boundaries don't, because: abc|DDEEFFghi -> abcDDEEF|Fghi
                if (cur.boundary()) {
                        cur.boundary(false);
-               }       else if (bidi.isBoundary(buffer, cur.paragraph(), cur.pos() + 1)) {
+               }       else if (isRTLBoundary(buffer, cur.paragraph(), cur.pos() + 1)) {
                        // in front of RTL boundary -> Stay on this side of the boundary because:
                        //   ab|cDDEEFFghi -> abc|DDEEFFghi
                        ++cur.pos();
index a6d4a745e4ae8dff64f3d1aa7a488e8d8664bf69..503bdee356eed8a2d25706162d9ca781082f1442 100644 (file)
@@ -335,6 +335,13 @@ public:
        bool isRTL(Buffer const &, Paragraph const & par) const;
        /// is this position in the paragraph right-to-left?
        bool isRTL(Buffer const & buffer, CursorSlice const & sl, bool boundary) const;
+       /// is between pos-1 and pos an RTL<->LTR boundary?
+       bool isRTLBoundary(Buffer const & buffer, Paragraph const & par,
+         pos_type pos) const;
+       /// would be a RTL<->LTR boundary between pos and the given font?
+       bool isRTLBoundary(Buffer const & buffer, Paragraph const & par,
+         pos_type pos, Font const & font) const;
+
        ///
        bool checkAndActivateInset(Cursor & cur, bool front);
 
index bbb2c4233bdc3600b24c45fd41295a51e36f37a2..66baea12ccda4b63396789c378ccb1da0972ec24 100644 (file)
@@ -795,7 +795,7 @@ void Text::setCurrentFont(Cursor & cur)
        real_current_font = getFont(cur.buffer(), par, pos);
 
        if (cur.pos() == cur.lastpos()
-           && bidi.isBoundary(cur.buffer(), par, cur.pos())
+           && isRTLBoundary(cur.buffer(), par, cur.pos())
            && !cur.boundary()) {
                Language const * lang = par.getParLanguage(bufparams);
                current_font.setLanguage(lang);
@@ -1037,7 +1037,7 @@ bool Text::cursorRight(Cursor & cur)
                // if left of boundary -> just jump to right side
          // but for RTL boundaries don't, because: abc|DDEEFFghi -> abcDDEEF|Fghi
          if (cur.boundary() && 
-                               !bidi.isBoundary(cur.buffer(), cur.paragraph(), cur.pos()))
+                               !isRTLBoundary(cur.buffer(), cur.paragraph(), cur.pos()))
                        return setCursor(cur, cur.pit(), cur.pos(), true, false);
 
                // next position is left of boundary, 
@@ -1066,7 +1066,7 @@ bool Text::cursorRight(Cursor & cur)
                
                // in front of RTL boundary? Stay on this side of the boundary because:
                //   ab|cDDEEFFghi -> abc|DDEEFFghi
-               if (bidi.isBoundary(cur.buffer(), cur.paragraph(), cur.pos() + 1))
+               if (isRTLBoundary(cur.buffer(), cur.paragraph(), cur.pos() + 1))
                        return setCursor(cur, cur.pit(), cur.pos() + 1, true, true);
                
                // move right
index e935f3db8a8aa3b323bb87488ef4628dbf7146c3..85187f50fa41292367c5135de12523968bcacf95 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;
index 622ca3268883b93f423e41f846444304f4ae0440..6f3d6a300c17e32d53b1924164b8cfb3581328d7 100644 (file)
@@ -893,7 +893,7 @@ pos_type TextMetrics::getColumnNearX(pit_type const pit,
                bool const rtl = (text_->bidi.level(c) % 2 == 1);
                if (left_side == rtl) {
                        ++c;
-                       boundary = text_->bidi.isBoundary(buffer, par, c);
+                       boundary = text_->isRTLBoundary(buffer, par, c);
                }
        }