diff options
author | nyamatongwe <unknown> | 2007-04-07 00:57:03 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2007-04-07 00:57:03 +0000 |
commit | 6d82fda3c167c1ebdc7242f9ee6d42de2a47e838 (patch) | |
tree | 855af185b33b67caf44e49c655059ff76782ef35 | |
parent | cfc2acb4089acc872b9f06031ca39eef637c149c (diff) | |
download | scintilla-mirror-6d82fda3c167c1ebdc7242f9ee6d42de2a47e838.tar.gz |
More decoration code, with modifications reported from document to views
although this isn't optimal. Some checking for null changes. Messages
documented. Methods for changing indicators in Accessor so can be used by
lexers.
-rw-r--r-- | doc/ScintillaDoc.html | 62 | ||||
-rw-r--r-- | include/Accessor.h | 1 | ||||
-rw-r--r-- | include/WindowAccessor.h | 1 | ||||
-rw-r--r-- | src/Decoration.cxx | 7 | ||||
-rw-r--r-- | src/Decoration.h | 3 | ||||
-rw-r--r-- | src/Document.cxx | 11 | ||||
-rw-r--r-- | src/Document.h | 1 | ||||
-rw-r--r-- | src/DocumentAccessor.cxx | 4 | ||||
-rw-r--r-- | src/DocumentAccessor.h | 1 | ||||
-rw-r--r-- | src/Editor.cxx | 6 | ||||
-rw-r--r-- | src/RunStyles.cxx | 13 | ||||
-rw-r--r-- | src/RunStyles.h | 3 | ||||
-rw-r--r-- | src/WindowAccessor.cxx | 9 |
13 files changed, 106 insertions, 16 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 3a08f9db1..fbd77f29f 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -2134,7 +2134,7 @@ struct TextToFind { it was not selected. When there is no selection, the current insertion point is marked by the text caret. This is a vertical line that is normally blinking on and off to attract the users attention.</p> - <code><a class="message" href="#SCI_SETSELFORE">SCI_SETSELFORE(bool useSelectionForeColour, + <code><a class="message" href="#SCI_SETSELFORE">SCI_SETSELFORE(bool useSelectionForeColour, int <a class="jump" href="#colour">colour<a>)</a><br /> <a class="message" href="#SCI_SETSELBACK">SCI_SETSELBACK(bool useSelectionBackColour, int <a class="jump" href="#colour">colour<a>)</a><br /> @@ -2155,7 +2155,7 @@ struct TextToFind { <a class="message" href="#SCI_GETCARETPERIOD">SCI_GETCARETPERIOD</a><br /> <a class="message" href="#SCI_SETCARETWIDTH">SCI_SETCARETWIDTH(int pixels)</a><br /> <a class="message" href="#SCI_GETCARETWIDTH">SCI_GETCARETWIDTH</a><br /> - <a class="message" href="#SCI_SETHOTSPOTACTIVEFORE">SCI_SETHOTSPOTACTIVEFORE(bool useSetting, + <a class="message" href="#SCI_SETHOTSPOTACTIVEFORE">SCI_SETHOTSPOTACTIVEFORE(bool useSetting, int <a class="jump" href="#colour">colour<a>)</a><br /> <a class="message" href="#SCI_GETHOTSPOTACTIVEFORE">SCI_GETHOTSPOTACTIVEFORE</a><br /> <a class="message" href="#SCI_SETHOTSPOTACTIVEBACK">SCI_SETHOTSPOTACTIVEBACK(bool useSetting, @@ -3046,6 +3046,60 @@ struct TextToFind { <code>SCI_INDICSETFORE(1, 0xff0000);</code> (light blue)<br /> <code>SCI_INDICSETFORE(2, 0x0000ff);</code> (light red)</p> + <h2 id="Extended Indicators">Extended Indicators</h2> + <p>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.</p> + <p>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.</p> + <p>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.</p> + <p> + <b id="SCI_SETINDICATORCURRENT">SCI_SETINDICATORCURRENT(int indicator)</b><br /> + <b id="SCI_GETINDICATORCURRENT">SCI_GETINDICATORCURRENT</b><br /> + These two messages set and get the indicator that will be affected by calls to + <a class="jump" href="#SCI_INDICATORFILLRANGE">SCI_INDICATORFILLRANGE</a> and + <a class="jump" href="#SCI_INDICATORCLEARRANGE">SCI_INDICATORCLEARRANGE</a>. + </p> + + <p> + <b id="SCI_SETINDICATORVALUE">SCI_SETINDICATORVALUE(int value)</b><br /> + <b id="SCI_GETINDICATORVALUE">SCI_GETINDICATORVALUE</b><br /> + These two messages set and get the value that will be set by calls to + <a class="jump" href="#SCI_INDICATORFILLRANGE">SCI_INDICATORFILLRANGE</a>. + </p> + + <p> + <b id="SCI_INDICATORFILLRANGE">SCI_INDICATORFILLRANGE(int position, int fillLength)</b><br /> + <b id="SCI_INDICATORCLEARRANGE">SCI_INDICATORCLEARRANGE(int position, int clearLength)</b><br /> + These two messages fill or clear a range for the current indicator. + <code>SCI_INDICATORFILLRANGE</code> fills with the + the current value. + </p> + + <p> + <b id="SCI_INDICATORALLONFOR">SCI_INDICATORALLONFOR(int position)</b><br /> + Retrieve a bitmap value representing which indicators are non-zero at a position. + </p> + + <p> + <b id="SCI_INDICATORVALUEAT">SCI_INDICATORVALUEAT(int indicator, int position)</b><br /> + Retrieve the value of a particular indicator at a position. + </p> + + <p> + <b id="SCI_INDICATORSTART">SCI_INDICATORSTART(int indicator, int position)</b><br /> + <b id="SCI_INDICATOREND">SCI_INDICATOREND(int indicator, int position)</b><br /> + 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. + </p> + + <h2 id="Autocompletion">Autocompletion</h2> <p>Autocompletion displays a list box showing likely identifiers based upon the user's typing. @@ -3642,9 +3696,9 @@ struct TextToFind { <code>SCK_ADD</code>, <code>SCK_BACK</code>, <code>SCK_DELETE</code>, <code>SCK_DIVIDE</code>, <code>SCK_DOWN</code>, <code>SCK_END</code>, <code>SCK_ESCAPE</code>, <code>SCK_HOME</code>, <code>SCK_INSERT</code>, <code>SCK_LEFT</code>, <code>SCK_MENU</code>, <code>SCK_NEXT</code> (Page Down), - <code>SCK_PRIOR</code> (Page Up), <code>SCK_RETURN</code>, <code>SCK_RIGHT</code>, + <code>SCK_PRIOR</code> (Page Up), <code>SCK_RETURN</code>, <code>SCK_RIGHT</code>, <code>SCK_RWIN</code>, - <code>SCK_SUBTRACT</code>, <code>SCK_TAB</code>, <code>SCK_UP</code>, and + <code>SCK_SUBTRACT</code>, <code>SCK_TAB</code>, <code>SCK_UP</code>, and <code>SCK_WIN</code>.</p> <p>The modifiers are a combination of zero or more of <code>SCMOD_ALT</code>, 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); + } +} |