diff options
author | Neil <nyamatongwe@gmail.com> | 2021-03-20 12:10:14 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2021-03-20 12:10:14 +1100 |
commit | 2813306346e4087679915c2b30f1be4949f0228a (patch) | |
tree | b503f9539900c5623f50e8d6a88da14df7e9ed24 /gtk | |
parent | 2f0011955fe7d3ac0b80247abc88ee0461104eb6 (diff) | |
download | scintilla-mirror-2813306346e4087679915c2b30f1be4949f0228a.tar.gz |
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.
Diffstat (limited to 'gtk')
-rwxr-xr-x | gtk/PlatGTK.cxx | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index 1732c217e..495c0d790 100755 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -126,6 +126,7 @@ namespace Scintilla { // SurfaceID is a cairo_t* class SurfaceImpl : public Surface { + SurfaceMode mode; encodingType et; cairo_t *context; cairo_surface_t *psurf; @@ -152,6 +153,8 @@ public: void Init(SurfaceID sid, WindowID wid) override; void InitPixMap(int width, int height, Surface *surface_, WindowID wid) override; + void SetMode(SurfaceMode mode_) override; + void Clear() noexcept; void Release() noexcept override; int Supports(int feature) noexcept override; @@ -400,7 +403,18 @@ void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_, WindowID cairo_set_line_width(context, 1); createdGC = true; inited = true; - et = surfImpl->et; + SetMode(surfImpl->mode); +} + +void SurfaceImpl::SetMode(SurfaceMode mode_) { + mode = mode_; + if (mode.codePage == SC_CP_UTF8) { + et = UTF8; + } else if (mode.codePage) { + et = dbcs; + } else { + et = singleByte; + } } int SurfaceImpl::Supports(int feature) noexcept { @@ -1263,13 +1277,24 @@ void SurfaceImpl::PopClip() { void SurfaceImpl::FlushCachedState() {} void SurfaceImpl::SetUnicodeMode(bool unicodeMode_) { - if (unicodeMode_) + if (unicodeMode_) { + mode.codePage = SC_CP_UTF8; et = UTF8; + } else { + mode.codePage = 0; + et = singleByte; + } } void SurfaceImpl::SetDBCSMode(int codePage) { - if (codePage && (codePage != SC_CP_UTF8)) + mode.codePage = codePage; + if (mode.codePage == SC_CP_UTF8) { + et = UTF8; + } else if (mode.codePage) { et = dbcs; + } else { + et = singleByte; + } } void SurfaceImpl::SetBidiR2L(bool) { |