From 2813306346e4087679915c2b30f1be4949f0228a Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 20 Mar 2021 12:10:14 +1100 Subject: Use SurfaceMode struct as a way to inform Surface of modes like code page and bidirectional options in an extensible way instead of adding a call for each element. --- qt/ScintillaEditBase/PlatQt.cpp | 22 +++++++++++++--------- qt/ScintillaEditBase/PlatQt.h | 5 +++-- 2 files changed, 16 insertions(+), 11 deletions(-) (limited to 'qt') diff --git a/qt/ScintillaEditBase/PlatQt.cpp b/qt/ScintillaEditBase/PlatQt.cpp index f2681013a..6503d9c19 100644 --- a/qt/ScintillaEditBase/PlatQt.cpp +++ b/qt/ScintillaEditBase/PlatQt.cpp @@ -155,7 +155,7 @@ std::shared_ptr Font::Allocate(const FontParameters &fp) SurfaceImpl::SurfaceImpl() : device(nullptr), painter(nullptr), deviceOwned(false), painterOwned(false), x(0), y(0), - unicodeMode(false), codePage(0), codecName(nullptr), codec(nullptr) + codecName(nullptr), codec(nullptr) {} SurfaceImpl::~SurfaceImpl() { @@ -200,8 +200,12 @@ void SurfaceImpl::InitPixMap(int width, deviceOwned = true; device = new QPixmap(width, height); SurfaceImpl *psurfOther = dynamic_cast(surface); - SetUnicodeMode(psurfOther->unicodeMode); - SetDBCSMode(psurfOther->codePage); + mode = psurfOther->mode; +} + +void SurfaceImpl::SetMode(SurfaceMode mode_) +{ + mode = mode_; } void SurfaceImpl::Release() noexcept @@ -253,7 +257,7 @@ void SurfaceImpl::SetCodec(const Font *font) const FontAndCharacterSet *pfacs = AsFontAndCharacterSet(font); if (pfacs && pfacs->pfont) { const char *csid = "UTF-8"; - if (!unicodeMode) + if (!(mode.codePage == SC_CP_UTF8)) csid = CharacterSetID(pfacs->characterSet); if (csid != codecName) { codecName = csid; @@ -681,7 +685,7 @@ void SurfaceImpl::MeasureWidths(const Font *font, tlay.beginLayout(); QTextLine tl = tlay.createLine(); tlay.endLayout(); - if (unicodeMode) { + if (mode.codePage == SC_CP_UTF8) { int fit = su.size(); int ui=0; size_t i=0; @@ -701,11 +705,11 @@ void SurfaceImpl::MeasureWidths(const Font *font, while (i