From 6d82fda3c167c1ebdc7242f9ee6d42de2a47e838 Mon Sep 17 00:00:00 2001
From: nyamatongwe
SCI_SETSELFORE(bool useSelectionForeColour,
+ SCI_SETSELFORE(bool useSelectionForeColour,
int colour)
SCI_SETSELBACK(bool useSelectionBackColour,
int colour)
@@ -2155,7 +2155,7 @@ struct TextToFind {
SCI_GETCARETPERIOD
SCI_SETCARETWIDTH(int pixels)
SCI_GETCARETWIDTH
- SCI_SETHOTSPOTACTIVEFORE(bool useSetting,
+ SCI_SETHOTSPOTACTIVEFORE(bool useSetting,
int colour)
SCI_GETHOTSPOTACTIVEFORE
SCI_SETHOTSPOTACTIVEBACK(bool useSetting,
@@ -3046,6 +3046,60 @@ struct TextToFind {
SCI_INDICSETFORE(1, 0xff0000); (light blue)
SCI_INDICSETFORE(2, 0x0000ff); (light red)
+ Extended Indicators
+ Incorporating indicators within style bytes has proved limiting so Scintilla is changing to store
+ indicators separately from style bytes. The following APIs should be used for new code and existing
+ code should be updated to use these APIs rather than style bytes. After the transition is complete,
+ indicators within style bytes will be removed so that all the bits in each style byte can be used for
+ lexical states.
+ Up to 32 indicators may be used. Lexers should use indicators 3 to 7 and containers
+ 8 to 31 to ensure they do not conflict. Indicators 0, 1, and 2 are the existing style byte indicators and should
+ be avoided in the transition period.
+ Extended indicators are stored in a format similar to run length encoding which is efficient in both
+ speed and storage for sparse information.
+ An indicator may store different values for each range but currently all values are drawn the same.
+ In the future, it may be possible to draw different values in different styles.
+
+ SCI_SETINDICATORCURRENT(int indicator)
+ SCI_GETINDICATORCURRENT
+ These two messages set and get the indicator that will be affected by calls to
+ SCI_INDICATORFILLRANGE and
+ SCI_INDICATORCLEARRANGE.
+
+
+
+ SCI_SETINDICATORVALUE(int value)
+ SCI_GETINDICATORVALUE
+ These two messages set and get the value that will be set by calls to
+ SCI_INDICATORFILLRANGE.
+
+
+
+ SCI_INDICATORFILLRANGE(int position, int fillLength)
+ SCI_INDICATORCLEARRANGE(int position, int clearLength)
+ These two messages fill or clear a range for the current indicator.
+ SCI_INDICATORFILLRANGE fills with the
+ the current value.
+
+
+
+ SCI_INDICATORALLONFOR(int position)
+ Retrieve a bitmap value representing which indicators are non-zero at a position.
+
+
+
+ SCI_INDICATORVALUEAT(int indicator, int position)
+ Retrieve the value of a particular indicator at a position.
+
+
+
+ SCI_INDICATORSTART(int indicator, int position)
+ SCI_INDICATOREND(int indicator, int position)
+ Find the start or end of a range with one value from a position within the range.
+ Can be used to iterate through the document to discover all the indicator positions.
+
+
+
Autocompletion
Autocompletion displays a list box showing likely identifiers based upon the user's typing.
@@ -3642,9 +3696,9 @@ struct TextToFind {
SCK_ADD, SCK_BACK, SCK_DELETE, SCK_DIVIDE,
SCK_DOWN, SCK_END, SCK_ESCAPE, SCK_HOME,
SCK_INSERT, SCK_LEFT, SCK_MENU, SCK_NEXT (Page Down),
- SCK_PRIOR (Page Up), SCK_RETURN, SCK_RIGHT,
+ SCK_PRIOR (Page Up), SCK_RETURN, SCK_RIGHT,
SCK_RWIN,
- SCK_SUBTRACT, SCK_TAB, SCK_UP, and
+ SCK_SUBTRACT, SCK_TAB, SCK_UP, and
SCK_WIN.
The modifiers are a combination of zero or more of SCMOD_ALT,
diff --git a/include/Accessor.h b/include/Accessor.h
index 0b2c4baee..d9db9c7bf 100644
--- a/include/Accessor.h
+++ b/include/Accessor.h
@@ -75,4 +75,5 @@ public:
virtual void ColourTo(unsigned int pos, int chAttr)=0;
virtual void SetLevel(int line, int level)=0;
virtual int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0)=0;
+ virtual void IndicatorFill(int start, int end, int indicator, int value)=0;
};
diff --git a/include/WindowAccessor.h b/include/WindowAccessor.h
index 6c16b150f..a55c2c459 100644
--- a/include/WindowAccessor.h
+++ b/include/WindowAccessor.h
@@ -54,4 +54,5 @@ public:
void ColourTo(unsigned int pos, int chAttr);
void SetLevel(int line, int level);
int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0);
+ void IndicatorFill(int start, int end, int indicator, int value);
};
diff --git a/src/Decoration.cxx b/src/Decoration.cxx
index f1c9c5ae3..3d23833cc 100644
--- a/src/Decoration.cxx
+++ b/src/Decoration.cxx
@@ -104,20 +104,21 @@ void DecorationList::SetCurrentIndicator(int indicator) {
}
void DecorationList::SetCurrentValue(int value) {
- currentValue = value;
+ currentValue = value ? value : 1;
}
-void DecorationList::FillRange(int position, int value, int fillLength) {
+bool DecorationList::FillRange(int position, int value, int fillLength) {
if (!current) {
current = DecorationFromIndicator(currentIndicator);
if (!current) {
current = Create(currentIndicator, lengthDocument);
}
}
- current->rs.FillRange(position, value, fillLength);
+ bool changed = current->rs.FillRange(position, value, fillLength);
if (current->Empty()) {
Delete(currentIndicator);
}
+ return changed;
}
void DecorationList::InsertSpace(int position, int insertLength) {
diff --git a/src/Decoration.h b/src/Decoration.h
index 1810b0fb3..03c06c0e0 100644
--- a/src/Decoration.h
+++ b/src/Decoration.h
@@ -41,7 +41,8 @@ public:
void SetCurrentValue(int value);
int GetCurrentValue() { return currentValue; }
- void FillRange(int position, int value, int fillLength);
+ // Returns true if some values may have changed
+ 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 964d4808b..a25e3070d 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -1340,6 +1340,17 @@ 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,
+ position, fillLength);
+ NotifyModified(mh);
+ } else {
+ DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER,
+ position, fillLength);
+ }
+}
+
bool Document::AddWatcher(DocWatcher *watcher, void *userData) {
for (int i = 0; i < lenWatchers; i++) {
if ((watchers[i].watcher == watcher) &&
diff --git a/src/Document.h b/src/Document.h
index 90b4fe1b5..3659f86a4 100644
--- a/src/Document.h
+++ b/src/Document.h
@@ -218,6 +218,7 @@ public:
void EnsureStyledTo(int pos);
int GetStyleClock() { return styleClock; }
void IncrementStyleClock();
+ void DecorationFillRange(int position, int value, int fillLength);
int SetLineState(int line, int state) { return cb.SetLineState(line, state); }
int GetLineState(int line) { return cb.GetLineState(line); }
diff --git a/src/DocumentAccessor.cxx b/src/DocumentAccessor.cxx
index afe4670a4..e28264f73 100644
--- a/src/DocumentAccessor.cxx
+++ b/src/DocumentAccessor.cxx
@@ -190,3 +190,7 @@ int DocumentAccessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnI
return indent;
}
+void DocumentAccessor::IndicatorFill(int start, int end, int indicator, int value) {
+ pdoc->decorations.SetCurrentIndicator(indicator);
+ pdoc->DecorationFillRange(start, value, end - start);
+}
diff --git a/src/DocumentAccessor.h b/src/DocumentAccessor.h
index 740652045..28f676db3 100644
--- a/src/DocumentAccessor.h
+++ b/src/DocumentAccessor.h
@@ -64,4 +64,5 @@ public:
void ColourTo(unsigned int pos, int chAttr);
void SetLevel(int line, int level);
int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0);
+ void IndicatorFill(int start, int end, int indicator, int value);
};
diff --git a/src/Editor.cxx b/src/Editor.cxx
index cdbd81474..6f381a8ef 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -7147,13 +7147,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return pdoc->decorations.GetCurrentValue();
case SCI_INDICATORFILLRANGE:
- pdoc->decorations.FillRange(wParam, pdoc->decorations.GetCurrentValue(), lParam);
- InvalidateRange(wParam, wParam + lParam);
+ pdoc->DecorationFillRange(wParam, pdoc->decorations.GetCurrentValue(), lParam);
break;
case SCI_INDICATORCLEARRANGE:
- pdoc->decorations.FillRange(wParam, 0, lParam);
- InvalidateRange(wParam, wParam + lParam);
+ pdoc->DecorationFillRange(wParam, 0, lParam);
break;
case SCI_INDICATORALLONFOR:
diff --git a/src/RunStyles.cxx b/src/RunStyles.cxx
index a7cf40e81..9a644b1b4 100644
--- a/src/RunStyles.cxx
+++ b/src/RunStyles.cxx
@@ -106,11 +106,17 @@ int RunStyles::EndRun(int position) {
return starts->PositionFromPartition(starts->PartitionFromPosition(position) + 1);
}
-void RunStyles::FillRange(int position, int value, int fillLength) {
+bool RunStyles::FillRange(int position, int value, int fillLength) {
int end = position + fillLength;
- SplitRun(end);
int runStart = RunFromPosition(position);
- if (styles->ValueAt(runStart) != value) {
+ if (styles->ValueAt(runStart) == value) {
+ if (end <= starts->PositionFromPartition(runStart + 1)) {
+ // Whole range is already same as value
+ return false;
+ }
+ SplitRun(end);
+ } else {
+ SplitRun(end);
SplitRun(position);
runStart = RunFromPosition(position);
styles->SetValueAt(runStart, value);
@@ -123,6 +129,7 @@ void RunStyles::FillRange(int position, int value, int fillLength) {
runEnd = RunFromPosition(end);
RemoveRunIfSameAsPrevious(runEnd);
RemoveRunIfSameAsPrevious(runStart);
+ return true;
}
void RunStyles::InsertSpace(int position, int insertLength) {
diff --git a/src/RunStyles.h b/src/RunStyles.h
index 539e5de47..8d5022cb4 100644
--- a/src/RunStyles.h
+++ b/src/RunStyles.h
@@ -24,7 +24,8 @@ public:
int FindNextChange(int position, int end);
int StartRun(int position);
int EndRun(int position);
- void FillRange(int position, int value, int fillLength);
+ // Returns true if some values may have changed
+ bool FillRange(int position, int value, int fillLength);
void InsertSpace(int position, int insertLength);
void DeleteAll();
void DeleteRange(int position, int deleteLength);
diff --git a/src/WindowAccessor.cxx b/src/WindowAccessor.cxx
index ce42534e7..8132b584e 100644
--- a/src/WindowAccessor.cxx
+++ b/src/WindowAccessor.cxx
@@ -176,3 +176,12 @@ int WindowAccessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsC
return indent;
}
+void WindowAccessor::IndicatorFill(int start, int end, int indicator, int value) {
+ Platform::SendScintilla(id, SCI_SETINDICATORCURRENT, indicator);
+ if (value) {
+ Platform::SendScintilla(id, SCI_SETINDICATORVALUE, value);
+ Platform::SendScintilla(id, SCI_INDICATORFILLRANGE, start, end - start);
+ } else {
+ Platform::SendScintilla(id, SCI_INDICATORCLEARRANGE, start, end - start);
+ }
+}
--
cgit v1.2.3