diff options
author | Neil <nyamatongwe@gmail.com> | 2017-04-22 09:11:03 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2017-04-22 09:11:03 +1000 |
commit | 0801e0084a5cf87f424235d5947f5158474d5da4 (patch) | |
tree | c5e5a3be2dfd1d94dd3597cb39edadc510f0273e /src | |
parent | af243dd42dabdabd15a92a295d66f721e44dd473 (diff) | |
download | scintilla-mirror-0801e0084a5cf87f424235d5947f5158474d5da4.tar.gz |
Encapsulate the LexInterface of Document.
Diffstat (limited to 'src')
-rw-r--r-- | src/Document.cxx | 12 | ||||
-rw-r--r-- | src/Document.h | 5 | ||||
-rw-r--r-- | src/ScintillaBase.cxx | 6 |
3 files changed, 14 insertions, 9 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index d7e3bf62b..b4ab37244 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -129,8 +129,6 @@ Document::Document() { perLineData[ldAnnotation] = new LineAnnotation(); cb.SetPerLine(this); - - pli = 0; } Document::~Document() { @@ -142,8 +140,6 @@ Document::~Document() { pl = nullptr; } regex.release(); - delete pli; - pli = 0; delete pcf; pcf = 0; } @@ -2124,6 +2120,14 @@ void Document::LexerChanged() { } } +LexInterface *Document::GetLexInterface() const { + return pli.get(); +} + +void Document::SetLexInterface(LexInterface *pLexInterface) { + pli.reset(pLexInterface); +} + int SCI_METHOD Document::SetLineState(Sci_Position line, int state) { const int statePrevious = static_cast<LineState *>(perLineData[ldState])->SetLineState(line, state); if (state != statePrevious) { diff --git a/src/Document.h b/src/Document.h index b6c9c5bd1..788f9bd33 100644 --- a/src/Document.h +++ b/src/Document.h @@ -228,6 +228,7 @@ private: bool matchesValid; std::unique_ptr<RegexSearchBase> regex; + std::unique_ptr<LexInterface> pli; public: @@ -243,8 +244,6 @@ public: } }; - LexInterface *pli; - int eolMode; /// Can also be SC_CP_UTF8 to enable UTF-8 mode int dbcsCodePage; @@ -415,6 +414,8 @@ public: void IncrementStyleClock(); void SCI_METHOD DecorationSetCurrentIndicator(int indicator); void SCI_METHOD DecorationFillRange(Sci_Position position, int value, Sci_Position fillLength); + LexInterface *GetLexInterface() const; + void SetLexInterface(LexInterface *pLexInterface); int SCI_METHOD SetLineState(Sci_Position line, int state); int SCI_METHOD GetLineState(Sci_Position line) const; diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index 659a37b90..0fbf555d1 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -581,10 +581,10 @@ LexState::~LexState() { } LexState *ScintillaBase::DocumentLexState() { - if (!pdoc->pli) { - pdoc->pli = new LexState(pdoc); + if (!pdoc->GetLexInterface()) { + pdoc->SetLexInterface(new LexState(pdoc)); } - return static_cast<LexState *>(pdoc->pli); + return static_cast<LexState *>(pdoc->GetLexInterface()); } void LexState::SetLexerModule(const LexerModule *lex) { |