diff options
-rw-r--r-- | doc/ScintillaDoc.html | 63 | ||||
-rw-r--r-- | include/Scintilla.h | 5 | ||||
-rw-r--r-- | include/Scintilla.iface | 5 | ||||
-rw-r--r-- | src/Editor.cxx | 26 | ||||
-rw-r--r-- | src/Editor.h | 3 |
5 files changed, 88 insertions, 14 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index f120e29f1..b8c2a38ae 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -5687,6 +5687,9 @@ struct SCNotification { int listType; // SCN_USERLISTSELECTION, SCN_AUTOCSELECTION int x; // SCN_DWELLSTART, SCN_DWELLEND int y; // SCN_DWELLSTART, SCN_DWELLEND + int token; // SCN_MODIFIED with SC_MOD_CONTAINER + int annotationLinesAdded; // SC_MOD_CHANGEANNOTATION + int updated; // SCN_UPDATEUI }; </pre> @@ -5787,13 +5790,59 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber); double click and the <code>line</code> field is set to the line of the double click.</p> <p><b id="SCN_UPDATEUI">SCN_UPDATEUI</b><br /> - Either the text or styling of the document has changed or the selection range has changed. Now - would be a good time to update any container UI elements that depend on document or view state. - This was previously called <code><a class="message" - href="#SCN_CHECKBRACE">SCN_CHECKBRACE</a></code> because a common use is to check whether the - caret is next to a brace and set highlights on this brace and its corresponding matching brace. - This also replaces <a class="message" href="#SCN_POSCHANGED"><code>SCN_POSCHANGED</code></a>, - which is now deprecated.</p> + Either the text or styling of the document has changed or the selection range or scroll position has changed. + Now would be a good time to update any container UI elements that depend on document or view state. + The <code>updated</code> field is set to the bit set of things changed since the previous notiication.</p> + <table cellpadding="1" cellspacing="2" border="0" summary="Modify notification type flags"> + <tbody> + <tr> + <th align="left">Symbol</th> + + <th>Value</th> + + <th align="left">Meaning</th> + + </tr> + </tbody> + + <tbody valign="top"> + <tr> + <td align="left"><code>SC_UPDATE_CONTENT</code></td> + + <td align="center">0x01</td> + + <td>Contents, styling or markers have been changed.</td> + + </tr> + + <tr> + <td align="left"><code>SC_UPDATE_SELECTION</code></td> + + <td align="center">0x02</td> + + <td>Selection has been changed.</td> + + </tr> + + <tr> + <td align="left"><code>SC_UPDATE_V_SCROLL</code></td> + + <td align="center">0x04</td> + + <td>Scrolled vertically.</td> + + </tr> + + <tr> + <td align="left"><code>SC_UPDATE_H_SCROLL</code></td> + + <td align="center">0x08</td> + + <td>Scrolled horizontally.</td> + + </tr> + </tbody> + </table> <p><b id="SCN_MODIFIED">SCN_MODIFIED</b><br /> This notification is sent when the text or styling of the document changes or is about to diff --git a/include/Scintilla.h b/include/Scintilla.h index 0e1159b53..c0bb32332 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -832,6 +832,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_MOD_CONTAINER 0x40000 #define SC_MOD_LEXERSTATE 0x80000 #define SC_MODEVENTMASKALL 0xFFFFF +#define SC_UPDATE_CONTENT 0x1 +#define SC_UPDATE_SELECTION 0x2 +#define SC_UPDATE_V_SCROLL 0x4 +#define SC_UPDATE_H_SCROLL 0x8 #define SCEN_CHANGE 768 #define SCEN_SETFOCUS 512 #define SCEN_KILLFOCUS 256 @@ -971,6 +975,7 @@ struct SCNotification { int y; /* SCN_DWELLSTART, SCN_DWELLEND */ int token; /* SCN_MODIFIED with SC_MOD_CONTAINER */ int annotationLinesAdded; /* SC_MOD_CHANGEANNOTATION */ + int updated; /* SCN_UPDATEUI */ }; #ifdef SCI_NAMESPACE diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 405fc0552..1a81aca98 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -2193,6 +2193,11 @@ val SC_MOD_CONTAINER=0x40000 val SC_MOD_LEXERSTATE=0x80000 val SC_MODEVENTMASKALL=0xFFFFF +val SC_UPDATE_CONTENT=0x1 +val SC_UPDATE_SELECTION=0x2 +val SC_UPDATE_V_SCROLL=0x4 +val SC_UPDATE_H_SCROLL=0x8 + # For compatibility, these go through the COMMAND notification rather than NOTIFY # and should have had exactly the same values as the EN_* constants. # Unfortunately the SETFOCUS and KILLFOCUS are flipped over from EN_* diff --git a/src/Editor.cxx b/src/Editor.cxx index e9a30ee72..89c67b433 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -175,7 +175,8 @@ Editor::Editor() { lengthForEncode = -1; - needUpdateUI = true; + needUpdateUI = 0; + ContainerNeedsUpdate(SC_UPDATE_CONTENT); braces[0] = invalidPosition; braces[1] = invalidPosition; bracesMatchStyle = STYLE_BRACEBAD; @@ -434,7 +435,10 @@ int Editor::LineFromLocation(Point pt) { } void Editor::SetTopLine(int topLineNew) { - topLine = topLineNew; + if (topLine != topLineNew) { + topLine = topLineNew; + ContainerNeedsUpdate(SC_UPDATE_V_SCROLL); + } posTopLine = pdoc->LineStart(cs.DocFromDisplay(topLine)); } @@ -741,7 +745,7 @@ void Editor::InvalidateSelection(SelectionRange newMain, bool invalidateWholeSel lastAffected = Platform::Maximum(lastAffected, sel.Range(r).anchor.Position()); } } - needUpdateUI = true; + ContainerNeedsUpdate(SC_UPDATE_SELECTION); InvalidateRange(firstAffected, lastAffected); } @@ -982,6 +986,7 @@ void Editor::HorizontalScrollTo(int xPos) { xPos = 0; if ((wrapState == eWrapNone) && (xOffset != xPos)) { xOffset = xPos; + ContainerNeedsUpdate(SC_UPDATE_H_SCROLL); SetHorizontalScrollPos(); RedrawRect(GetClientRectangle()); } @@ -1291,6 +1296,7 @@ void Editor::SetXYScroll(XYScrollPosition newXY) { } if (newXY.xOffset != xOffset) { xOffset = newXY.xOffset; + ContainerNeedsUpdate(SC_UPDATE_H_SCROLL); if (newXY.xOffset > 0) { PRectangle rcText = GetTextRectangle(); if (horizontalScrollBarVisible && @@ -3307,7 +3313,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { surfaceWindow->SetPalette(&palTemp, true); NotifyUpdateUI(); - needUpdateUI = false; + needUpdateUI = 0; RefreshStyleData(); RefreshPixMaps(surfaceWindow); @@ -4213,6 +4219,7 @@ void Editor::NotifyHotSpotReleaseClick(int position, bool shift, bool ctrl, bool void Editor::NotifyUpdateUI() { SCNotification scn = {0}; scn.nmhdr.code = SCN_UPDATEUI; + scn.updated = needUpdateUI; NotifyParent(scn); } @@ -4329,7 +4336,7 @@ static inline int MovePositionForDeletion(int position, int startDeletion, int l } void Editor::NotifyModified(Document *, DocModification mh, void *) { - needUpdateUI = true; + ContainerNeedsUpdate(SC_UPDATE_CONTENT); if (paintState == painting) { CheckForChangeOutsidePaint(Range(mh.position, mh.position + mh.length)); } @@ -4611,6 +4618,11 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lPar NotifyParent(scn); } +// Something has changed that the container should know about +void Editor::ContainerNeedsUpdate(int flags) { + needUpdateUI |= flags; +} + /** * Force scroll and keep position relative to top of window. * @@ -6338,7 +6350,7 @@ void Editor::IdleStyling() { if (needUpdateUI) { NotifyUpdateUI(); - needUpdateUI = false; + needUpdateUI = 0; } styleNeeded.Reset(); } @@ -6995,6 +7007,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETXOFFSET: xOffset = wParam; + ContainerNeedsUpdate(SC_UPDATE_H_SCROLL); SetHorizontalScrollPos(); Redraw(); break; @@ -7459,6 +7472,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; } xOffset = 0; + ContainerNeedsUpdate(SC_UPDATE_H_SCROLL); InvalidateStyleRedraw(); ReconfigureScrollBars(); break; diff --git a/src/Editor.h b/src/Editor.h index 288addee0..a618e1e40 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -208,7 +208,7 @@ protected: // ScintillaBase subclass needs access to much of Editor int posTopLine; int lengthForEncode; - bool needUpdateUI; + int needUpdateUI; Position braces[2]; int bracesMatchStyle; int highlightGuideColumn; @@ -438,6 +438,7 @@ protected: // ScintillaBase subclass needs access to much of Editor void NotifyErrorOccurred(Document *doc, void *userData, int status); void NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lParam); + void ContainerNeedsUpdate(int flags); void PageMove(int direction, Selection::selTypes sel=Selection::noSel, bool stuttered = false); enum { cmSame, cmUpper, cmLower } caseMap; virtual std::string CaseMapString(const std::string &s, int caseMapping); |