]> git.lyx.org Git - lyx.git/blobdiff - src/rowpainter.cpp
[the "translation" patch series] Part 2: fixing document label translations
[lyx.git] / src / rowpainter.cpp
index e3dfefba8f9acd60db54af12817cf2100183e8f5..d9e41253e62d56983d1f73525f8b93d3a5699c6d 100644 (file)
@@ -471,7 +471,8 @@ void RowPainter::paintChangeBar()
 
 void RowPainter::paintAppendix()
 {
-       if (!par_.params().appendix())
+       // only draw the appendix frame once (for the main text)
+       if (!par_.params().appendix() || !text_.isMainText(*bv_.buffer()))
                return;
 
        int y = yo_ - row_.ascent();
@@ -734,6 +735,12 @@ void RowPainter::paintLast()
 void RowPainter::paintText()
 {
        pos_type const end = row_.endpos();
+       // Spaces at logical line breaks in bidi text must be skipped during 
+       // painting. However, they may appear visually in the middle
+       // of a row; they must be skipped, wherever they are...
+       // * logically "abc_[HEBREW_\nHEBREW]"
+       // * visually "abc_[_WERBEH\nWERBEH]"
+       pos_type skipped_sep_vpos = -1;
        pos_type body_pos = par_.beginOfBody();
        if (body_pos > 0 &&
                (body_pos > end || !par_.isLineSeparator(body_pos - 1))) {
@@ -751,10 +758,21 @@ void RowPainter::paintText()
        Font font;
        Buffer const & buffer = *bv_.buffer();
 
+       // If the last logical character is a separator, don't paint it, unless
+       // it's in the last row of a paragraph; see skipped_sep_vpos declaration
+       if (end > 0 && end < par_.size() && par_.isSeparator(end - 1))
+               skipped_sep_vpos = bidi_.log2vis(end - 1);
+       
        for (pos_type vpos = row_.pos(); vpos < end; ) {
                if (x_ > bv_.workWidth())
                        break;
 
+               // Skip the separator at the logical end of the row
+               if (vpos == skipped_sep_vpos) {
+                       ++vpos;
+                       continue;
+               }
+
                pos_type const pos = bidi_.vis2log(vpos);
 
                if (pos >= par_.size()) {
@@ -900,13 +918,21 @@ bool inNarrowInset(PainterInfo & pi)
 {
        // check whether the current inset is nested in a non-wide inset
        Cursor & cur = pi.base.bv->cursor();
-       for (int i = cur.depth() - 1; --i >= 0; ) {
+       Inset const * cur_in = &cur.inset();
+       // check all higher nested insets
+       for (size_type i = 1; i < cur.depth(); ++i) {
                Inset * const in = &cur[i].inset();
-               if (in) {
+               if (in == cur_in)
+                       // we reached the level of the current inset, so stop
+                       return false;
+               else if (in) {
+                       if (in->hasFixedWidth())
+                               return true;
                        InsetText * t =
                                const_cast<InsetText *>(in->asTextInset());
-                       if (t)
-                               return !t->wide();
+                       if (t && !t->wide())
+                               // OK, we are in a non-wide() inset
+                               return true;
                }
        }
        return false;
@@ -982,7 +1008,7 @@ void paintPar
                        // Clear background of this row
                        // (if paragraph background was not cleared)
                        if (!repaintAll &&
-                           (!(in_inset_alone_on_row && leftEdgeFixed)
+                           (!(in_inset_alone_on_row && leftEdgeFixed && !inNarrowIns)
                                || row_has_changed)) {
                                pi.pain.fillRectangle(x, y - rit->ascent(),
                                    rp.maxWidth(), rit->height(),