aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/PositionCache.cxx
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2021-07-31 08:49:25 +1000
committerNeil <nyamatongwe@gmail.com>2021-07-31 08:49:25 +1000
commit4d1a31d6a74019c3d43de1c33e2be093ed6dfd11 (patch)
treed2b113b25d2cfcb751f4b5a961bb14a04261175f /src/PositionCache.cxx
parent297d17ace8501b23a32390163676c838dad71f9a (diff)
downloadscintilla-mirror-4d1a31d6a74019c3d43de1c33e2be093ed6dfd11.tar.gz
Implement StyleSetCheckMonospaced.
Diffstat (limited to 'src/PositionCache.cxx')
-rw-r--r--src/PositionCache.cxx16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx
index 714937dc1..fda736cc7 100644
--- a/src/PositionCache.cxx
+++ b/src/PositionCache.cxx
@@ -377,6 +377,14 @@ constexpr size_t AlignUp(size_t value, size_t alignment) noexcept {
constexpr size_t alignmentLLC = 20;
+constexpr bool GraphicASCII(char ch) noexcept {
+ return ch >= ' ' && ch <= '~';
+}
+
+bool AllGraphicASCII(std::string_view text) noexcept {
+ return std::all_of(text.cbegin(), text.cend(), GraphicASCII);
+}
+
}
@@ -895,6 +903,14 @@ void PositionCache::MeasureWidths(Surface *surface, const ViewStyle &vstyle, uns
probe = probe2;
}
}
+ if (vstyle.styles[styleNumber].monospaceASCII) {
+ if (AllGraphicASCII(sv)) {
+ for (size_t i = 0; i < sv.length(); i++) {
+ positions[i] = vstyle.styles[styleNumber].aveCharWidth * (i+1);
+ }
+ return;
+ }
+ }
const Font *fontStyle = vstyle.styles[styleNumber].font.get();
surface->MeasureWidths(fontStyle, sv, positions);
if (probe < pces.size()) {