X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Frowpainter.cpp;h=6d56c27b60db69ccbb6743e91c3930cc8d68000e;hb=2455bc258f3b62c29ec4a41cb88070ff8518e842;hp=d53389fd11546d76bfa7928beead2fa3976a913c;hpb=fb8914b9cabeb61555e4f60f72c4758bcb3f7584;p=lyx.git diff --git a/src/rowpainter.cpp b/src/rowpainter.cpp index d53389fd11..6d56c27b60 100644 --- a/src/rowpainter.cpp +++ b/src/rowpainter.cpp @@ -224,10 +224,6 @@ void RowPainter::paintChars(pos_type & vpos, FontInfo const & font, { // This method takes up 70% of time when typing pos_type pos = bidi_.vis2log(vpos); - pos_type const end = row_.endpos(); - FontSpan const font_span = par_.fontSpan(pos); - Change::Type const prev_change = par_.lookupChange(pos).type; - // first character vector str; str.reserve(100); @@ -242,6 +238,10 @@ void RowPainter::paintChars(pos_type & vpos, FontInfo const & font, str[0] = par_.transformChar(c, pos); } + pos_type const end = row_.endpos(); + FontSpan const font_span = par_.fontSpan(pos); + // Track-change status. + Change::Type const change_type = par_.lookupChange(pos).type; // selected text? bool const selection = pos >= row_.sel_beg && pos < row_.sel_end; @@ -252,10 +252,12 @@ void RowPainter::paintChars(pos_type & vpos, FontInfo const & font, break; bool const new_selection = pos >= row_.sel_beg && pos < row_.sel_end; - if (selection != new_selection) + if (new_selection != selection) + // Selection ends or starts here. break; - if (prev_change != par_.lookupChange(pos).type) + if (change_type != par_.lookupChange(pos).type) + // Track change type has changed. break; char_type c = par_.getChar(pos); @@ -304,18 +306,18 @@ void RowPainter::paintChars(pos_type & vpos, FontInfo const & font, docstring s(&str[0], str.size()); - if (!selection && prev_change == Change::UNCHANGED) { + if (!selection && change_type == Change::UNCHANGED) { x_ += pi_.pain.text(int(x_), yo_, s, font); return; } FontInfo copy = font; - if (selection) - copy.setColor(Color_selectiontext); - else if (prev_change == Change::DELETED) + if (change_type == Change::DELETED) copy.setColor(Color_deletedtext); - else if (prev_change == Change::INSERTED) + else if (change_type == Change::INSERTED) copy.setColor(Color_addedtext); + else if (selection) + copy.setColor(Color_selectiontext); x_ += pi_.pain.text(int(x_), yo_, s, copy); } @@ -836,8 +838,6 @@ void RowPainter::paintInlineCompletion(Font const & font) // right to left? if (rtl) { swap(s1, s2); - reverse(s1.begin(), s1.end()); - reverse(s2.begin(), s2.end()); swap(c1, c2); }