* 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
This commit is contained in:
Stefan Schimanski 2008-02-22 14:05:27 +00:00
parent aa532e094f
commit 7b0ea48d31
2 changed files with 39 additions and 26 deletions

View File

@ -765,6 +765,10 @@ void RowPainter::paintText()
x_ += row_.label_hfill + lwidth - width_pos; 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)) { if (par_.isSeparator(pos)) {
Font const orig_font = text_metrics_.getDisplayFont(pit_, pos); Font const orig_font = text_metrics_.getDisplayFont(pit_, pos);
@ -786,31 +790,9 @@ void RowPainter::paintText()
paintFromPos(vpos); paintFromPos(vpos);
} }
// Is the inline completion here? // Is the inline completion after character?
// FIXME: RTL support needed here if (!font.isRightToLeft() && vpos - 1 == inlineCompletionVPos_)
if (vpos - 1 == inlineCompletionVPos_) { paintInlineCompletion(vpos, font);
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);
}
}
} }
// if we reach the end of a struck out range, paint it // 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 } // namespace lyx

View File

@ -63,7 +63,8 @@ private:
int paintAppendixStart(int y); int paintAppendixStart(int y);
void paintFromPos(pos_type & vpos); void paintFromPos(pos_type & vpos);
void paintInset(Inset const * inset, pos_type const pos); void paintInset(Inset const * inset, pos_type const pos);
void paintInlineCompletion(pos_type & vpos, Font const & font);
/// return left margin /// return left margin
int leftMargin() const; int leftMargin() const;