]> git.lyx.org Git - lyx.git/blobdiff - src/TextMetrics.cpp
Get rid of all-insets-toggle and explain how to replace it with inset-forall.
[lyx.git] / src / TextMetrics.cpp
index bf1b8cbac6f4d69cbc58a9406098760f0561d203..1aef414b7c7f983a9b77f101626522cf1c88c252 100644 (file)
@@ -306,11 +306,8 @@ bool TextMetrics::isRTL(CursorSlice const & sl, bool boundary) const
 
 bool TextMetrics::isRTLBoundary(pit_type pit, pos_type pos) const
 {
-       if (!lyxrc.rtl_support)
-               return false;
-
        // no RTL boundary at paragraph start
-       if (pos == 0)
+       if (!lyxrc.rtl_support || pos == 0)
                return false;
 
        Font const & left_font = displayFont(pit, pos - 1);
@@ -322,13 +319,14 @@ bool TextMetrics::isRTLBoundary(pit_type pit, pos_type pos) const
 bool TextMetrics::isRTLBoundary(pit_type pit, pos_type pos,
                Font const & font) const
 {
-       if (!lyxrc.rtl_support)
+       if (!lyxrc.rtl_support
+           // no RTL boundary at paragraph start
+           || pos == 0
+           // if the metrics have not been calculated, then we are not
+           // on screen and can safely ignore issues about boundaries.
+           || !contains(pit))
                return false;
 
-       // no RTL boundary at paragraph start
-       if (pos == 0)
-               return false;
-       
        ParagraphMetrics & pm = par_metrics_[pit];
        // no RTL boundary in empty paragraph
        if (pm.rows().empty())
@@ -343,13 +341,6 @@ bool TextMetrics::isRTLBoundary(pit_type pit, pos_type pos,
                return false;
 
        Paragraph const & par = text_->getPar(pit);
-       bool left = font.isVisibleRightToLeft();
-       bool right;
-       if (pos == par.size())
-               right = par.isRTL(bv_->buffer().params());
-       else
-               right = displayFont(pit, pos).isVisibleRightToLeft();
-       
        // no RTL boundary at line break:
        // abc|\n    -> move right ->   abc\n       (and not:    abc\n|
        // FED                          FED|                     FED     )
@@ -359,6 +350,13 @@ bool TextMetrics::isRTLBoundary(pit_type pit, pos_type pos,
                        || par.isSeparator(pos - 1)))
                return false;
        
+       bool left = font.isVisibleRightToLeft();
+       bool right;
+       if (pos == par.size())
+               right = par.isRTL(bv_->buffer().params());
+       else
+               right = displayFont(pit, pos).isVisibleRightToLeft();
+       
        return left != right;
 }
 
@@ -2255,7 +2253,7 @@ void TextMetrics::drawRowSelection(PainterInfo & pi, int x, Row const & row,
 
        // go through row and draw from RTL boundary to RTL boundary
        while (cur < end) {
-               bool drawNow = false;
+               bool draw_now = false;
 
                // simplified cursorForward code below which does not
                // descend into insets and which does not go into the
@@ -2270,7 +2268,7 @@ void TextMetrics::drawRowSelection(PainterInfo & pi, int x, Row const & row,
                        // because:  ab|cDDEEFFghi -> abc|DDEEFFghi
                        ++cur.pos();
                        cur.boundary(true);
-                       drawNow = true;
+                       draw_now = true;
                } else {
                        // move right
                        ++cur.pos();
@@ -2285,7 +2283,7 @@ void TextMetrics::drawRowSelection(PainterInfo & pi, int x, Row const & row,
                        x1 = cursorX(cur.top(), cur.boundary());
                }
 
-               if (!(cur < end) || drawNow) {
+               if (!(cur < end) || draw_now) {
                        x2 = cursorX(cur.top(), cur.boundary());
                        pi.pain.fillRectangle(x + min(x1,x2), y1, abs(x2 - x1), y2 - y1,
                                Color_selection);