Stefan Schimanski wrote:

Ok, after rereading your previous mail I got it. Would be good to put a better documentation there like:

// Spaces at line breaks in bidi text can appear visually in the middle
// of a row and must be skipped during painting:
// * logically "abc_[HEBREW_\nHEBREW]"
// * visually "abc_[_WERBEH\nWERBEH]"

Haven't tested the patch, but it looks good.

Stefan

Thanks, Stefan. Attached the same patch, but better-commented...

Any other opinions?

Dov

Index: src/Text.cpp
===================================================================
--- src/Text.cpp        (revision 18899)
+++ src/Text.cpp        (working copy)
@@ -1718,6 +1718,12 @@
 
        pos_type const row_pos  = row.pos();
        pos_type const end      = row.endpos();
+       // Spaces at logical line breaks in bidi text must be skipped during 
+       // cursor positioning. 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;
 
        if (end <= row_pos)
                cursor_vpos = row_pos;
@@ -1743,7 +1749,15 @@
        FontMetrics const & labelfm = theFontMetrics(
                getLabelFont(buffer, par));
 
+       // If the last logical character is a separator, skip 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 < cursor_vpos; ++vpos) {
+               // Skip the separator which is at the logical end of the row
+               if (vpos == skipped_sep_vpos)
+                       continue;
                pos_type pos = bidi.vis2log(vpos);
                if (body_pos > 0 && pos == body_pos - 1) {
                        // FIXME UNICODE
Index: src/rowpainter.cpp
===================================================================
--- src/rowpainter.cpp  (revision 18899)
+++ src/rowpainter.cpp  (working copy)
@@ -734,6 +734,12 @@
 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 +757,21 @@
        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()) {

Reply via email to