diff options
author | nyamatongwe <unknown> | 2007-04-19 13:21:08 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2007-04-19 13:21:08 +0000 |
commit | f1eb7da396f7a856006c15254216b5867ea23bc9 (patch) | |
tree | aba5d8f3e3758feb0f7fba7256d2a4c01b54044b | |
parent | 476e533e7277cfd122f3ca3472783831c9e47ca5 (diff) | |
download | scintilla-mirror-f1eb7da396f7a856006c15254216b5867ea23bc9.tar.gz |
Optimized indicator changing with separate SC_MOD_CHANGEINDICATOR
notification flag.
-rw-r--r-- | include/Scintilla.h | 3 | ||||
-rw-r--r-- | include/Scintilla.iface | 3 | ||||
-rw-r--r-- | src/Decoration.cxx | 2 | ||||
-rw-r--r-- | src/Decoration.h | 2 | ||||
-rw-r--r-- | src/Document.cxx | 5 | ||||
-rw-r--r-- | src/Editor.cxx | 12 | ||||
-rw-r--r-- | src/RunStyles.cxx | 45 | ||||
-rw-r--r-- | src/RunStyles.h | 4 |
8 files changed, 44 insertions, 32 deletions
diff --git a/include/Scintilla.h b/include/Scintilla.h index 153a5123c..67140a7d3 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -677,7 +677,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_MOD_BEFOREDELETE 0x800 #define SC_MULTILINEUNDOREDO 0x1000 #define SC_STARTACTION 0x2000 -#define SC_MODEVENTMASKALL 0x2FFF +#define SC_MOD_CHANGEINDICATOR 0x4000 +#define SC_MODEVENTMASKALL 0x6FFF #define SCEN_CHANGE 768 #define SCEN_SETFOCUS 512 #define SCEN_KILLFOCUS 256 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index ba9f61ec0..1e8c6478a 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -1819,7 +1819,8 @@ val SC_MOD_BEFOREINSERT=0x400 val SC_MOD_BEFOREDELETE=0x800 val SC_MULTILINEUNDOREDO=0x1000 val SC_STARTACTION=0x2000 -val SC_MODEVENTMASKALL=0x2FFF +val SC_MOD_CHANGEINDICATOR=0x4000 +val SC_MODEVENTMASKALL=0x6FFF # For compatibility, these go through the COMMAND notification rather than NOTIFY # and should have had exactly the same values as the EN_* constants. diff --git a/src/Decoration.cxx b/src/Decoration.cxx index 3d23833cc..6f19119e1 100644 --- a/src/Decoration.cxx +++ b/src/Decoration.cxx @@ -107,7 +107,7 @@ void DecorationList::SetCurrentValue(int value) { currentValue = value ? value : 1; } -bool DecorationList::FillRange(int position, int value, int fillLength) { +bool DecorationList::FillRange(int &position, int value, int &fillLength) { if (!current) { current = DecorationFromIndicator(currentIndicator); if (!current) { diff --git a/src/Decoration.h b/src/Decoration.h index 03c06c0e0..9f3473a3d 100644 --- a/src/Decoration.h +++ b/src/Decoration.h @@ -42,7 +42,7 @@ public: int GetCurrentValue() { return currentValue; } // Returns true if some values may have changed - bool FillRange(int position, int value, int fillLength); + bool FillRange(int &position, int value, int &fillLength); void InsertSpace(int position, int insertLength); void DeleteRange(int position, int deleteLength); diff --git a/src/Document.cxx b/src/Document.cxx index 3061bbc37..753d325ef 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -1344,12 +1344,9 @@ void Document::IncrementStyleClock() { void Document::DecorationFillRange(int position, int value, int fillLength) { if (decorations.FillRange(position, value, fillLength)) { - DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER, + DocModification mh(SC_MOD_CHANGEINDICATOR | SC_PERFORMED_USER, position, fillLength); NotifyModified(mh); - } else { - DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER, - position, fillLength); } } diff --git a/src/Editor.cxx b/src/Editor.cxx index 6f381a8ef..3a7a00f8e 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -3831,8 +3831,10 @@ void Editor::NotifyModified(Document*, DocModification mh, void *) { if (paintState == painting) { CheckForChangeOutsidePaint(Range(mh.position, mh.position + mh.length)); } - if (mh.modificationType & SC_MOD_CHANGESTYLE) { - pdoc->IncrementStyleClock(); + if (mh.modificationType & (SC_MOD_CHANGESTYLE|SC_MOD_CHANGEINDICATOR)) { + if (mh.modificationType & SC_MOD_CHANGESTYLE) { + pdoc->IncrementStyleClock(); + } if (paintState == notPainting) { if (mh.position < pdoc->LineStart(topLine)) { // Styling performed before this view @@ -3841,7 +3843,9 @@ void Editor::NotifyModified(Document*, DocModification mh, void *) { InvalidateRange(mh.position, mh.position + mh.length); } } - llc.Invalidate(LineLayout::llCheckTextAndStyle); + if (mh.modificationType & SC_MOD_CHANGESTYLE) { + llc.Invalidate(LineLayout::llCheckTextAndStyle); + } } else { // Move selection and brace highlights if (mh.modificationType & SC_MOD_INSERTTEXT) { @@ -3925,7 +3929,7 @@ void Editor::NotifyModified(Document*, DocModification mh, void *) { // If client wants to see this modification if (mh.modificationType & modEventMask) { - if ((mh.modificationType & SC_MOD_CHANGESTYLE) == 0) { + if ((mh.modificationType & (SC_MOD_CHANGESTYLE|SC_MOD_CHANGEINDICATOR)) == 0) { // Real modification made to text of document. NotifyChange(); // Send EN_CHANGE } diff --git a/src/RunStyles.cxx b/src/RunStyles.cxx index 9a644b1b4..da7cba2f9 100644 --- a/src/RunStyles.cxx +++ b/src/RunStyles.cxx @@ -27,14 +27,16 @@ int RunStyles::RunFromPosition(int position) { } // If there is no run boundary at position, insert one continuing style. -void RunStyles::SplitRun(int position) { +int RunStyles::SplitRun(int position) { int run = RunFromPosition(position); int posRun = starts->PositionFromPartition(run); if (posRun < position) { int runStyle = ValueAt(position); - starts->InsertPartition(run+1, position); - styles->InsertValue(run+1, 1, runStyle); + run++; + starts->InsertPartition(run, position); + styles->InsertValue(run, 1, runStyle); } + return run; } void RunStyles::RemoveRun(int run) { @@ -106,22 +108,31 @@ int RunStyles::EndRun(int position) { return starts->PositionFromPartition(starts->PartitionFromPosition(position) + 1); } -bool RunStyles::FillRange(int position, int value, int fillLength) { +bool RunStyles::FillRange(int &position, int value, int &fillLength) { int end = position + fillLength; - int runStart = RunFromPosition(position); - if (styles->ValueAt(runStart) == value) { - if (end <= starts->PositionFromPartition(runStart + 1)) { - // Whole range is already same as value + int runEnd = RunFromPosition(end); + if (styles->ValueAt(runEnd) == value) { + // End already has value so trim range. + end = starts->PositionFromPartition(runEnd); + if (position >= end) { + // Whole range is already same as value so no action return false; } - SplitRun(end); + fillLength = end - position; } else { - SplitRun(end); - SplitRun(position); - runStart = RunFromPosition(position); - styles->SetValueAt(runStart, value); + runEnd = SplitRun(end); } - int runEnd = RunFromPosition(end); + int runStart = RunFromPosition(position); + if (styles->ValueAt(runStart) == value) { + // Start is in expected value so trim range. + runStart++; + position = starts->PositionFromPartition(runStart); + fillLength = end - position; + } else { + runStart = SplitRun(position); + runEnd++; + } + styles->SetValueAt(runStart, value); // Remove each old run over the range for (int run=runStart+1; run<runEnd; run++) { RemoveRun(runStart+1); @@ -178,10 +189,8 @@ void RunStyles::DeleteRange(int position, int deleteLength) { // Deleting from inside one run starts->InsertText(runStart, -deleteLength); } else { - SplitRun(position); - SplitRun(end); - runStart = RunFromPosition(position); - runEnd = RunFromPosition(end); + runStart = SplitRun(position); + runEnd = SplitRun(end); starts->InsertText(runStart, -deleteLength); // Remove each old run over the range for (int run=runStart; run<runEnd; run++) { diff --git a/src/RunStyles.h b/src/RunStyles.h index 8d5022cb4..009bb6739 100644 --- a/src/RunStyles.h +++ b/src/RunStyles.h @@ -12,7 +12,7 @@ public: Partitioning *starts; SplitVector<int> *styles; int RunFromPosition(int position); - void SplitRun(int position); + int SplitRun(int position); void RemoveRun(int run); void RemoveRunIfEmpty(int run); void RemoveRunIfSameAsPrevious(int run); @@ -25,7 +25,7 @@ public: int StartRun(int position); int EndRun(int position); // Returns true if some values may have changed - bool FillRange(int position, int value, int fillLength); + bool FillRange(int &position, int value, int &fillLength); void InsertSpace(int position, int insertLength); void DeleteAll(); void DeleteRange(int position, int deleteLength); |