-void RowPainter::paintChars(pos_type & vpos, Font const & font)
-{
- // This method takes up 70% of time when typing
- pos_type pos = bidi_.vis2log(vpos);
- pos_type start_pos = pos;
- // first character
- docstring str;
- str.reserve(100);
- char_type const c = par_.getChar(pos);
- str.push_back(c);
-
- FontSpan const font_span = par_.fontSpan(pos);
- // Track-change status.
- Change const & change_running = par_.lookupChange(pos);
- // spelling correct?
- bool const spell_state =
- lyxrc.spellcheck_continuously && par_.isMisspelled(pos);
-
- // collect as much similar chars as we can
- pos_type const end = row_.endpos();
- for (++vpos ; vpos < end ; ++vpos) {
- pos = bidi_.vis2log(vpos);
-
- if (!font_span.inside(pos))
- break;
-
- bool const new_spell_state =
- lyxrc.spellcheck_continuously && par_.isMisspelled(pos);
- if (new_spell_state != spell_state)
- // Spell checker state changed here.
- break;
-
- Change const & change = par_.lookupChange(pos);
- if (!change_running.isSimilarTo(change))
- // Track change type or author has changed.
- break;
-
- char_type const c = par_.getChar(pos);
-
- if (c == '\t')
- break;
-
- if (!isPrintableNonspace(c))
- break;
-
- str.push_back(c);
- }
-
- // Make pos point to the last character in the string.
- // Using "pos = bidi_.vis2log(vpos)" does not work for some reason.
- if (vpos < end)
- pos = bidi_.vis2log(vpos - 1);
-
- // Now make pos point to the position _after_ the string.
- // Using vis2log for that is not a good idea in general, we
- // want logical ordering.
- if (font.isVisibleRightToLeft())
- --pos;
- else
- ++pos;
-
- if (str[0] == '\t')
- str.replace(0,1,from_ascii(" "));
-
- /* Because we do our own bidi, at this point the strings are
- * already in visual order. However, Qt also applies its own
- * bidi algorithm to strings that it paints to the screen.
- * Therefore, if we were to paint Hebrew/Arabic words as a
- * single string, the letters in the words would get reversed
- * again. In order to avoid that, we force LTR drawing.
- * See also http://thread.gmane.org/gmane.editors.lyx.devel/79740
- * for an earlier thread on the subject
- */
- if (font.isVisibleRightToLeft()) {
- reverse(str.begin(), str.end());
- // If the string is reversed, the positions need to be adjusted
- ++pos;
- ++start_pos;
- swap(start_pos, pos);
- }
-
- // at least part of text selected?
- bool const some_sel = (pos >= row_.sel_beg && start_pos < row_.sel_end)
- || pi_.selected;
- // all the text selected?
- bool const all_sel = (start_pos >= row_.sel_beg && pos < row_.sel_end)
- || pi_.selected;
-
- if (all_sel) {
- Font copy = font;
- copy.fontInfo().setPaintColor(Color_selectiontext);
- x_ += pi_.pain.text(int(x_), yo_, str, copy);
- } else if (change_running.changed()) {
- Font copy = font;
- copy.fontInfo().setPaintColor(change_running.color());
- x_ += pi_.pain.text(int(x_), yo_, str, copy);
- } else if (!some_sel) {
- x_ += pi_.pain.text(int(x_), yo_, str, font);
- } else {
- x_ += pi_.pain.text(int(x_), yo_, str, font, Color_selectiontext,
- max(row_.sel_beg, start_pos) - start_pos,
- min(row_.sel_end, pos) - start_pos);
- }
-}
-
-
-void RowPainter::paintSeparator(double orig_x, double width,
- FontInfo const & font)