]> git.lyx.org Git - features.git/commitdiff
* first step to proper RTL support of the completion. The cursor is still wrong.
authorStefan Schimanski <sts@lyx.org>
Fri, 22 Feb 2008 14:05:27 +0000 (14:05 +0000)
committerStefan Schimanski <sts@lyx.org>
Fri, 22 Feb 2008 14:05:27 +0000 (14:05 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23130 a592a061-630c-0410-9148-cb99ea01b6c8

src/rowpainter.cpp
src/rowpainter.h

index 363481195422a4edb65cced51cd19456ae12f5dd..75d6071ddb2dbeb9624f12ca8a82475056ff120d 100644 (file)
@@ -765,6 +765,10 @@ void RowPainter::paintText()
 
                        x_ += row_.label_hfill + lwidth - width_pos;
                }
+               
+               // Is the inline completion in front of character?
+               if (font.isRightToLeft() && vpos == inlineCompletionVPos_)
+                       paintInlineCompletion(vpos, font);              
 
                if (par_.isSeparator(pos)) {
                        Font const orig_font = text_metrics_.getDisplayFont(pit_, pos);
@@ -786,31 +790,9 @@ void RowPainter::paintText()
                        paintFromPos(vpos);
                }
 
-               // Is the inline completion here?
-               // FIXME: RTL support needed here
-               if (vpos - 1 == inlineCompletionVPos_) {
-                       docstring const & completion = pi_.base.bv->inlineCompletion();
-                       FontInfo f = font.fontInfo();
-
-                       // draw the unique and the non-unique completion part
-                       // Note: this is not time-critical as it is
-                       // only done once per screen.
-                       size_t uniqueTo = pi_.base.bv->inlineCompletionUniqueChars();
-                       docstring s1 = completion.substr(0, uniqueTo);
-                       docstring s2 = completion.substr(uniqueTo);
-
-                       if (s1.size() > 0) {
-                               f.setColor(Color_inlinecompletion);
-                               pi_.pain.text(x_, yo_, s1, f);
-                               x_ += theFontMetrics(font).width(s1);
-                       }
-
-                       if (s2.size() > 0) {
-                               f.setColor(Color_nonunique_inlinecompletion);
-                               pi_.pain.text(x_, yo_, s2, f);
-                               x_ += theFontMetrics(font).width(s2);
-                       }
-               }
+               // Is the inline completion after character?
+               if (!font.isRightToLeft() && vpos - 1 == inlineCompletionVPos_)
+                       paintInlineCompletion(vpos, font);
        }
 
        // if we reach the end of a struck out range, paint it
@@ -825,4 +807,34 @@ void RowPainter::paintText()
        }
 }
 
+
+void RowPainter::paintInlineCompletion(pos_type & vpos, Font const & font)
+{
+       docstring completion = pi_.base.bv->inlineCompletion();
+       FontInfo f = font.fontInfo();
+       
+       // right to left?
+       if (font.isRightToLeft())
+               reverse(completion.begin(), completion.end());
+       
+       // draw the unique and the non-unique completion part
+       // Note: this is not time-critical as it is
+       // only done once per screen.
+       size_t uniqueTo = pi_.base.bv->inlineCompletionUniqueChars();
+       docstring s1 = completion.substr(0, uniqueTo);
+       docstring s2 = completion.substr(uniqueTo);
+       
+       if (s1.size() > 0) {
+               f.setColor(Color_inlinecompletion);
+               pi_.pain.text(x_, yo_, s1, f);
+               x_ += theFontMetrics(font).width(s1);
+       }
+       
+       if (s2.size() > 0) {
+               f.setColor(Color_nonunique_inlinecompletion);
+               pi_.pain.text(x_, yo_, s2, f);
+               x_ += theFontMetrics(font).width(s2);
+       }
+}
+
 } // namespace lyx
index 854e665084d6d458219f222f72ec18467e3fdf3d..e7f21f0be3e267a56bca7b864829a2a8bf307aab 100644 (file)
@@ -63,7 +63,8 @@ private:
        int paintAppendixStart(int y);
        void paintFromPos(pos_type & vpos);
        void paintInset(Inset const * inset, pos_type const pos);
-
+       void paintInlineCompletion(pos_type & vpos, Font const & font);
+       
        /// return left margin
        int leftMargin() const;