diff options
author | Neil <nyamatongwe@gmail.com> | 2021-06-10 16:56:08 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2021-06-10 16:56:08 +1000 |
commit | a4ed33d6e60725d8b2908e81c5e7383d36c87494 (patch) | |
tree | 93a36f46d9ba2297dbe1c6e26839aac5f0f33ea2 /src/EditView.cxx | |
parent | 1fdd0b8dc8f2895c5942b23410f11ea21dd4e3f4 (diff) | |
download | scintilla-mirror-a4ed33d6e60725d8b2908e81c5e7383d36c87494.tar.gz |
Use the position cache when possibe for representations.
Diffstat (limited to 'src/EditView.cxx')
-rw-r--r-- | src/EditView.cxx | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/EditView.cxx b/src/EditView.cxx index 92c1450cc..a71f385e7 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -366,6 +366,10 @@ constexpr bool IsControlCharacter(int ch) noexcept { return (ch >= 0 && ch < ' ') || (ch == 127); } +bool ViewIsASCII(std::string_view text) { + return std::all_of(text.cbegin(), text.cend(), IsASCII); +} + } /** @@ -475,7 +479,14 @@ void EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewSt if (representationWidth <= 0.0) { assert(ts.representation->stringRep.length() <= Representation::maxLength); XYPOSITION positionsRepr[Representation::maxLength+1]; - surface->MeasureWidthsUTF8(vstyle.styles[StyleControlChar].font.get(), ts.representation->stringRep, positionsRepr); + // ts.representation->stringRep is UTF-8 which only matches cache if document is UTF-8 + // or it only contains ASCII which is a subset of all currently supported encodings. + if ((CpUtf8 == model.pdoc->dbcsCodePage) || ViewIsASCII(ts.representation->stringRep)) { + posCache.MeasureWidths(surface, vstyle, StyleControlChar, ts.representation->stringRep, + positionsRepr); + } else { + surface->MeasureWidthsUTF8(vstyle.styles[StyleControlChar].font.get(), ts.representation->stringRep, positionsRepr); + } representationWidth = positionsRepr[ts.representation->stringRep.length() - 1]; if (FlagSet(ts.representation->appearance, RepresentationAppearance::Blob)) { representationWidth += vstyle.ctrlCharPadding; |