From 7b0ea48d31054455ea4a022cafed3efc4ae2b359 Mon Sep 17 00:00:00 2001 From: Stefan Schimanski Date: Fri, 22 Feb 2008 14:05:27 +0000 Subject: [PATCH] * first step to proper RTL support of the completion. The cursor is still wrong. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23130 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/rowpainter.cpp | 62 +++++++++++++++++++++++++++------------------- src/rowpainter.h | 3 ++- 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/src/rowpainter.cpp b/src/rowpainter.cpp index 3634811954..75d6071ddb 100644 --- a/src/rowpainter.cpp +++ b/src/rowpainter.cpp @@ -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 diff --git a/src/rowpainter.h b/src/rowpainter.h index 854e665084..e7f21f0be3 100644 --- a/src/rowpainter.h +++ b/src/rowpainter.h @@ -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;