diff options
author | Prakash Sahni <unknown> | 2020-06-12 09:34:59 +1000 |
---|---|---|
committer | Prakash Sahni <unknown> | 2020-06-12 09:34:59 +1000 |
commit | 1da92e82c03b517c9c814fce343d86d382a90a0a (patch) | |
tree | 6a25f06b19774f48cf73fdaac8e8e48fdcec2c54 | |
parent | e1421b5feaff77e9a047a53a7859c577616fae2b (diff) | |
download | scintilla-mirror-1da92e82c03b517c9c814fce343d86d382a90a0a.tar.gz |
Bug [#2141]. Implement end of line annotations.
-rw-r--r-- | doc/ScintillaDoc.html | 95 | ||||
-rw-r--r-- | doc/ScintillaHistory.html | 5 | ||||
-rw-r--r-- | doc/eolannotation.png | bin | 0 -> 21161 bytes | |||
-rw-r--r-- | include/Scintilla.h | 15 | ||||
-rw-r--r-- | include/Scintilla.iface | 36 | ||||
-rw-r--r-- | src/Document.cxx | 35 | ||||
-rw-r--r-- | src/Document.h | 8 | ||||
-rw-r--r-- | src/EditView.cxx | 94 | ||||
-rw-r--r-- | src/EditView.h | 2 | ||||
-rw-r--r-- | src/Editor.cxx | 50 | ||||
-rw-r--r-- | src/Editor.h | 1 | ||||
-rw-r--r-- | src/ViewStyle.cxx | 4 | ||||
-rw-r--r-- | src/ViewStyle.h | 2 |
13 files changed, 343 insertions, 4 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 6ec941395..786b6f27f 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -457,6 +457,8 @@ <tr> <td>○ <a class="toc" href="#BuildingScintilla">Building Scintilla</a></td> + <td>○ <a class="toc" href="#EndOfLineAnnotations">End of Line Annotations</a></td> + </tr> </tbody> </table> @@ -3725,6 +3727,99 @@ struct Sci_TextToFind { before <code>SCI_ANNOTATIONSETSTYLEOFFSET</code> and use the result as the argument to <code>SCI_ANNOTATIONSETSTYLEOFFSET</code>. </p> + <h2 id="EndOfLineAnnotations">End of Line Annotations</h2> + + <p>End of Line Annotations are read-only lines of text at the end of each line of editable text. + End of Line Annotations can be used to display an assembler version of code for debugging or to show diagnostic messages inline or to + line up different versions of text in a merge tool.</p> + + <p>End of Line Annotations used to display an assembler version of code for debugging</p> + <p><img src="eolannotation.png" alt="End of Line Annotations used to display an assembler version of code for debugging" /></p> + + <code> + <a class="message" href="#SCI_EOLANNOTATIONSETTEXT">SCI_EOLANNOTATIONSETTEXT(line line, const char *text)</a><br /> + <a class="message" href="#SCI_EOLANNOTATIONGETTEXT">SCI_EOLANNOTATIONGETTEXT(line line, char *text) → int</a><br /> + <a class="message" href="#SCI_EOLANNOTATIONSETSTYLE">SCI_EOLANNOTATIONSETSTYLE(line line, int style)</a><br /> + <a class="message" href="#SCI_EOLANNOTATIONGETSTYLE">SCI_EOLANNOTATIONGETSTYLE(line line) → int</a><br /> + <a class="message" href="#SCI_EOLANNOTATIONCLEARALL">SCI_EOLANNOTATIONCLEARALL</a><br /> + <a class="message" href="#SCI_EOLANNOTATIONSETVISIBLE">SCI_EOLANNOTATIONSETVISIBLE(int visible)</a><br /> + <a class="message" href="#SCI_EOLANNOTATIONGETVISIBLE">SCI_EOLANNOTATIONGETVISIBLE → int</a><br /> + <a class="message" href="#SCI_EOLANNOTATIONSETSTYLEOFFSET">SCI_EOLANNOTATIONSETSTYLEOFFSET(int style)</a><br /> + <a class="message" href="#SCI_EOLANNOTATIONGETSTYLEOFFSET">SCI_EOLANNOTATIONGETSTYLEOFFSET → int</a><br /> + </code> + + <p> + <b id="SCI_EOLANNOTATIONSETTEXT">SCI_EOLANNOTATIONSETTEXT(line line, const char *text)</b><br /> + <b id="SCI_EOLANNOTATIONGETTEXT">SCI_EOLANNOTATIONGETTEXT(line line, char *text) → int</b><br /> + <b id="SCI_EOLANNOTATIONSETSTYLE">SCI_EOLANNOTATIONSETSTYLE(line line, int style)</b><br /> + <b id="SCI_EOLANNOTATIONGETSTYLE">SCI_EOLANNOTATIONGETSTYLE(line line) → int</b><br /> + <b id="SCI_EOLANNOTATIONCLEARALL">SCI_EOLANNOTATIONCLEARALL</b><br /> + A different string may be set for each line with <code>SCI_EOLANNOTATIONSETTEXT</code>. + To clear end of line annotations call <code>SCI_EOLANNOTATIONSETTEXT</code> with a NULL pointer. + The whole of the text EOLANNOTATION on a line may be displayed in a particular style with + <code>SCI_EOLANNOTATIONSETSTYLE</code> or each character may be individually styled with + of the corresponding text byte similar to <code>SCI_SETSTYLINGEX</code>. The text must be set first as it + specifies how long the end of line annotation is so how many bytes of styling to read. + Setting an end of line annotation will cause a + <a class="message" href="#SC_MOD_CHANGEEOLANNOTATION"><code>SC_MOD_CHANGEEOLANNOTATION</code></a> + notification to be sent. + </p> + <p> + All the lines can be cleared of end of line annotations with <code>SCI_EOLANNOTATIONCLEARALL</code> + which is equivalent to clearing each line (setting to 0) and then deleting other memory used for this feature. + </p> + <p> + Only some style attributes are active in end of line annotations: font, size/sizeFractional, bold/weight, italics, fore, back, and characterSet. + </p> + <p> + <b id="SCI_EOLANNOTATIONSETVISIBLE">SCI_EOLANNOTATIONSETVISIBLE(int visible)</b><br /> + <b id="SCI_EOLANNOTATIONGETVISIBLE">SCI_EOLANNOTATIONGETVISIBLE → int</b><br /> + End of Line Annotations can be made visible in a view and there is a choice of display style when visible. + The two messages set and get the annotation display mode. The <code class="parameter">visible</code> + argument can be one of:</p> + + <table class="standard" summary="End of Line Annotation visibility"> + <tbody valign="top"> + <tr> + <th align="left"><code>EOLANNOTATION_HIDDEN</code></th> + + <td>0</td> + + <td>End of Line Annotations are not displayed.</td> + </tr> + + <tr> + <th align="left"><code>EOLANNOTATION_STANDARD</code></th> + + <td>1</td> + + <td>End of Line Annotations are drawn left justified with no adornment.</td> + </tr> + + <tr> + <th align="left"><code>EOLANNOTATION_BOXED</code></th> + + <td>2</td> + + <td>End of Line Annotations are indented to match the text and are surrounded by a box.</td> + </tr> + + </tbody> + </table> + + <p> + <b id="SCI_EOLANNOTATIONSETSTYLEOFFSET">SCI_EOLANNOTATIONSETSTYLEOFFSET(int style)</b><br /> + <b id="SCI_EOLANNOTATIONGETSTYLEOFFSET">SCI_EOLANNOTATIONGETSTYLEOFFSET → int</b><br /> + End of Line Annotation styles may be completely separated from standard text styles by setting a style offset. For example, + <code>SCI_EOLANNOTATIONSETSTYLEOFFSET(512)</code> would allow the end of line annotation styles to be numbered from + 512 up to 767 so they do not overlap styles set by lexers (or margins if margins offset is 256). + Each style number set with <code>SCI_EOLANNOTATIONSETSTYLE</code> + or <code>SCI_EOLANNOTATIONSETSTYLES</code> has the offset added before looking up the style. + </p> + <p> + Always call <a class="seealso" href="#SCI_ALLOCATEEXTENDEDSTYLES">SCI_ALLOCATEEXTENDEDSTYLES</a> + before <code>SCI_EOLANNOTATIONSETSTYLEOFFSET</code> and use the result as the argument to <code>SCI_EOLANNOTATIONSETSTYLEOFFSET</code>. + </p> <h2 id="OtherSettings">Other settings</h2> <code> <a class="message" href="#SCI_SETBUFFEREDDRAW">SCI_SETBUFFEREDDRAW(bool buffered)</a><br /> diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index c6d5b0539..10e88fd2a 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -555,6 +555,7 @@ <td>Shmuel Zeigerman</td> <td>Chris Graham</td> <td>Hugues Larrive</td> + <td>Prakash Sahni</td> </tr> </table> <p> @@ -574,6 +575,10 @@ Released 3 June 2020. </li> <li> + End of line annotations implemented. + <a href="https://sourceforge.net/p/scintilla/bugs/2141/">Bug #2141</a>. + </li> + <li> The latex lexer supports lstlisting environment that is similar to verbatim. <a href="https://sourceforge.net/p/scintilla/feature-requests/1358/">Feature #1358</a>. </li> diff --git a/doc/eolannotation.png b/doc/eolannotation.png Binary files differnew file mode 100644 index 000000000..5dacbf569 --- /dev/null +++ b/doc/eolannotation.png diff --git a/include/Scintilla.h b/include/Scintilla.h index ad36c19b2..d3b6ac237 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -1005,6 +1005,18 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETREPRESENTATION 2665 #define SCI_GETREPRESENTATION 2666 #define SCI_CLEARREPRESENTATION 2667 +#define SCI_EOLANNOTATIONSETTEXT 2740 +#define SCI_EOLANNOTATIONGETTEXT 2741 +#define SCI_EOLANNOTATIONSETSTYLE 2742 +#define SCI_EOLANNOTATIONGETSTYLE 2743 +#define SCI_EOLANNOTATIONCLEARALL 2744 +#define EOLANNOTATION_HIDDEN 0 +#define EOLANNOTATION_STANDARD 1 +#define EOLANNOTATION_BOXED 2 +#define SCI_EOLANNOTATIONSETVISIBLE 2745 +#define SCI_EOLANNOTATIONGETVISIBLE 2746 +#define SCI_EOLANNOTATIONSETSTYLEOFFSET 2747 +#define SCI_EOLANNOTATIONGETSTYLEOFFSET 2748 #define SCI_STARTRECORD 3001 #define SCI_STOPRECORD 3002 #define SCI_SETLEXER 4001 @@ -1065,7 +1077,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_MOD_LEXERSTATE 0x80000 #define SC_MOD_INSERTCHECK 0x100000 #define SC_MOD_CHANGETABSTOPS 0x200000 -#define SC_MODEVENTMASKALL 0x3FFFFF +#define SC_MOD_CHANGEEOLANNOTATION 0x400000 +#define SC_MODEVENTMASKALL 0x7FFFFF #define SC_UPDATE_CONTENT 0x1 #define SC_UPDATE_SELECTION 0x2 #define SC_UPDATE_V_SCROLL 0x4 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 2d53ba391..b8d92da19 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -2837,6 +2837,38 @@ get int GetRepresentation=2666(string encodedCharacter, stringresult representat # Remove a character representation. fun void ClearRepresentation=2667(string encodedCharacter,) +# Set the end of line annotation text for a line +set void EOLAnnotationSetText=2740(line line, string text) + +# Get the end of line annotation text for a line +get int EOLAnnotationGetText=2741(line line, stringresult text) + +# Set the style number for the end of line annotations for a line +set void EOLAnnotationSetStyle=2742(line line, int style) + +# Get the style number for the end of line annotations for a line +get int EOLAnnotationGetStyle=2743(line line,) + +# Clear the end of annotations from all lines +fun void EOLAnnotationClearAll=2744(,) + +enu EOLAnnotationVisible=EOLANNOTATION_ +val EOLANNOTATION_HIDDEN=0 +val EOLANNOTATION_STANDARD=1 +val EOLANNOTATION_BOXED=2 + +# Set the visibility for the end of line annotations for a view +set void EOLAnnotationSetVisible=2745(EOLAnnotationVisible visible,) + +# Get the visibility for the end of line annotations for a view +get EOLAnnotationVisible EOLAnnotationGetVisible=2746(,) + +# Get the start of the range of style numbers used for end of line annotations +set void EOLAnnotationSetStyleOffset=2747(int style,) + +# Get the start of the range of style numbers used for end of line annotations +get int EOLAnnotationGetStyleOffset=2748(,) + # Start notifying the container of all key presses and commands. fun void StartRecord=3001(,) @@ -2987,7 +3019,8 @@ val SC_MOD_CONTAINER=0x40000 val SC_MOD_LEXERSTATE=0x80000 val SC_MOD_INSERTCHECK=0x100000 val SC_MOD_CHANGETABSTOPS=0x200000 -val SC_MODEVENTMASKALL=0x3FFFFF +val SC_MOD_CHANGEEOLANNOTATION=0x400000 +val SC_MODEVENTMASKALL=0x7FFFFF ali SC_MOD_INSERTTEXT=INSERT_TEXT ali SC_MOD_DELETETEXT=DELETE_TEXT @@ -3007,6 +3040,7 @@ ali SC_MOD_CHANGEANNOTATION=CHANGE_ANNOTATION ali SC_MOD_LEXERSTATE=LEXER_STATE ali SC_MOD_INSERTCHECK=INSERT_CHECK ali SC_MOD_CHANGETABSTOPS=CHANGE_TAB_STOPS +ali SC_MOD_CHANGEEOLANNOTATION=CHANGE_E_O_L_ANNOTATION ali SC_MODEVENTMASKALL=EVENT_MASK_ALL enu Update=SC_UPDATE_ diff --git a/src/Document.cxx b/src/Document.cxx index ff009ee3e..f17e4f837 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -137,6 +137,7 @@ Document::Document(int options) : perLineData[ldState] = std::make_unique<LineState>(); perLineData[ldMargin] = std::make_unique<LineAnnotation>(); perLineData[ldAnnotation] = std::make_unique<LineAnnotation>(); + perLineData[ldEOLAnnotation] = std::make_unique<LineAnnotation>(); decorations = DecorationListCreate(IsLarge()); @@ -212,6 +213,10 @@ LineAnnotation *Document::Annotations() const noexcept { return dynamic_cast<LineAnnotation *>(perLineData[ldAnnotation].get()); } +LineAnnotation *Document::EOLAnnotations() const noexcept { + return dynamic_cast<LineAnnotation *>(perLineData[ldEOLAnnotation].get()); +} + int Document::LineEndTypesSupported() const { if ((SC_CP_UTF8 == dbcsCodePage) && pli) return pli->LineEndTypesSupported(); @@ -2385,6 +2390,36 @@ void Document::AnnotationClearAll() { Annotations()->ClearAll(); } +StyledText Document::EOLAnnotationStyledText(Sci::Line line) const noexcept { + const LineAnnotation *pla = EOLAnnotations(); + return StyledText(pla->Length(line), pla->Text(line), + pla->MultipleStyles(line), pla->Style(line), pla->Styles(line)); +} + +void Document::EOLAnnotationSetText(Sci::Line line, const char *text) { + if (line >= 0 && line < LinesTotal()) { + EOLAnnotations()->SetText(line, text); + DocModification mh(SC_MOD_CHANGEEOLANNOTATION, LineStart(line), + 0, 0, 0, line); + NotifyModified(mh); + } +} + +void Document::EOLAnnotationSetStyle(Sci::Line line, int style) { + EOLAnnotations()->SetStyle(line, style); + const DocModification mh(SC_MOD_CHANGEEOLANNOTATION, LineStart(line), + 0, 0, 0, line); + NotifyModified(mh); +} + +void Document::EOLAnnotationClearAll() { + const Sci::Line maxEditorLine = LinesTotal(); + for (Sci::Line l=0; l<maxEditorLine; l++) + EOLAnnotationSetText(l, nullptr); + // Free remaining data + EOLAnnotations()->ClearAll(); +} + void Document::IncrementStyleClock() noexcept { styleClock = (styleClock + 1) % 0x100000; } diff --git a/src/Document.h b/src/Document.h index a1017810e..6e8507f04 100644 --- a/src/Document.h +++ b/src/Document.h @@ -244,13 +244,14 @@ private: std::vector<WatcherWithUserData> watchers; // ldSize is not real data - it is for dimensions and loops - enum lineData { ldMarkers, ldLevels, ldState, ldMargin, ldAnnotation, ldSize }; + enum lineData { ldMarkers, ldLevels, ldState, ldMargin, ldAnnotation, ldEOLAnnotation, ldSize }; std::unique_ptr<PerLine> perLineData[ldSize]; LineMarkers *Markers() const noexcept; LineLevels *Levels() const noexcept; LineState *States() const noexcept; LineAnnotation *Margins() const noexcept; LineAnnotation *Annotations() const noexcept; + LineAnnotation *EOLAnnotations() const noexcept; bool matchesValid; std::unique_ptr<RegexSearchBase> regex; @@ -483,6 +484,11 @@ public: int AnnotationLines(Sci::Line line) const noexcept; void AnnotationClearAll(); + StyledText EOLAnnotationStyledText(Sci::Line line) const noexcept; + void EOLAnnotationSetStyle(Sci::Line line, int style); + void EOLAnnotationSetText(Sci::Line line, const char *text); + void EOLAnnotationClearAll(); + bool AddWatcher(DocWatcher *watcher, void *userData); bool RemoveWatcher(DocWatcher *watcher, void *userData); diff --git a/src/EditView.cxx b/src/EditView.cxx index 9599e293f..290106a49 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -1050,7 +1050,8 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle rcSegment.left = rcLine.left; rcSegment.right = rcLine.right; - const bool fillRemainder = !lastSubLine || !model.GetFoldDisplayText(line); + bool drawEOLAnnotationStyledText = (vsDraw.eolAnnotationVisible != EOLANNOTATION_HIDDEN) && model.pdoc->EOLAnnotationStyledText(line).text; + const bool fillRemainder = (!lastSubLine || (!model.GetFoldDisplayText(line) && !drawEOLAnnotationStyledText)); if (fillRemainder) { // Fill the remainder of the line FillLineRemainder(surface, model, vsDraw, ll, line, rcSegment, subLine); @@ -1285,6 +1286,95 @@ void EditView::DrawFoldDisplayText(Surface *surface, const EditModel &model, con } } +void EditView::DrawEOLAnnotationText(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, Sci::Line line, int xStart, PRectangle rcLine, int subLine, XYACCUMULATOR subLineStart, DrawPhase phase) { + + const bool lastSubLine = subLine == (ll->lines - 1); + if (!lastSubLine) + return; + + if (vsDraw.eolAnnotationVisible == EOLANNOTATION_HIDDEN) { + return; + } + const StyledText stEOLAnnotation = model.pdoc->EOLAnnotationStyledText(line); + if (!stEOLAnnotation.text || !ValidStyledText(vsDraw, vsDraw.eolAnnotationStyleOffset, stEOLAnnotation)) { + return; + } + const std::string_view eolAnnotationText(stEOLAnnotation.text, stEOLAnnotation.length); + const size_t style = stEOLAnnotation.style + vsDraw.eolAnnotationStyleOffset; + + PRectangle rcSegment = rcLine; + FontAlias fontText = vsDraw.styles[style].font; + const int widthEOLAnnotationText = static_cast<int>(surface->WidthText(fontText, eolAnnotationText)); + + const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth; + const XYPOSITION virtualSpace = model.sel.VirtualSpaceFor( + model.pdoc->LineEnd(line)) * spaceWidth; + rcSegment.left = xStart + + static_cast<XYPOSITION>(ll->positions[ll->numCharsInLine] - subLineStart) + + virtualSpace + vsDraw.aveCharWidth; + + const char *textFoldDisplay = model.GetFoldDisplayText(line); + if (textFoldDisplay) { + const std::string_view foldDisplayText(textFoldDisplay); + rcSegment.left += (static_cast<int>(surface->WidthText(fontText, foldDisplayText)) + vsDraw.aveCharWidth); + } + rcSegment.right = rcSegment.left + static_cast<XYPOSITION>(widthEOLAnnotationText); + + const ColourOptional background = vsDraw.Background(model.pdoc->GetMark(line), model.caret.active, ll->containsCaret); + ColourDesired textFore = vsDraw.styles[style].fore; + const ColourDesired textBack = TextBackground(model, vsDraw, ll, background, false, + false, static_cast<int>(style), -1); + + if (model.trackLineWidth) { + if (rcSegment.right + 1> lineWidthMaxSeen) { + // EOL Annotation text border drawn on rcSegment.right with width 1 is the last visible object of the line + lineWidthMaxSeen = static_cast<int>(rcSegment.right + 1); + } + } + + if (phase & drawBack) { + surface->FillRectangle(rcSegment, textBack); + + // Fill Remainder of the line + PRectangle rcRemainder = rcSegment; + rcRemainder.left = rcRemainder.right; + if (rcRemainder.left < rcLine.left) + rcRemainder.left = rcLine.left; + rcRemainder.right = rcLine.right; + FillLineRemainder(surface, model, vsDraw, ll, line, rcRemainder, subLine); + } + + if (phase & drawText) { + if (phasesDraw != phasesOne) { + surface->DrawTextTransparent(rcSegment, fontText, + rcSegment.top + vsDraw.maxAscent, eolAnnotationText, + textFore); + } else { + surface->DrawTextNoClip(rcSegment, fontText, + rcSegment.top + vsDraw.maxAscent, eolAnnotationText, + textFore, textBack); + } + } + + if (phase & drawIndicatorsFore) { + if (vsDraw.eolAnnotationVisible == EOLANNOTATION_BOXED ) { + surface->PenColour(textFore); + PRectangle rcBox = rcSegment; + rcBox.left = std::round(rcSegment.left); + rcBox.right = std::round(rcSegment.right); + const IntegerRectangle ircBox(rcBox); + surface->MoveTo(ircBox.left, ircBox.top); + surface->LineTo(ircBox.left, ircBox.bottom); + surface->MoveTo(ircBox.right, ircBox.top); + surface->LineTo(ircBox.right, ircBox.bottom); + surface->MoveTo(ircBox.left, ircBox.top); + surface->LineTo(ircBox.right, ircBox.top); + surface->MoveTo(ircBox.left, ircBox.bottom - 1); + surface->LineTo(ircBox.right, ircBox.bottom - 1); + } + } +} + static constexpr bool AnnotationBoxedOrIndented(int annotationVisible) noexcept { return annotationVisible == ANNOTATION_BOXED || annotationVisible == ANNOTATION_INDENTED; } @@ -2039,6 +2129,7 @@ void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyl DrawBackground(surface, model, vsDraw, ll, rcLine, lineRange, posLineStart, xStart, subLine, background); DrawFoldDisplayText(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, subLineStart, drawBack); + DrawEOLAnnotationText(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, subLineStart, drawBack); phase = static_cast<DrawPhase>(phase & ~drawBack); // Remove drawBack to not draw again in DrawFoldDisplayText DrawEOL(surface, model, vsDraw, ll, rcLine, line, lineRange.end, xStart, subLine, subLineStart, background); @@ -2069,6 +2160,7 @@ void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyl } DrawFoldDisplayText(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, subLineStart, phase); + DrawEOLAnnotationText(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, subLineStart, phase); if (phasesDraw == phasesOne) { DrawEOL(surface, model, vsDraw, ll, rcLine, line, lineRange.end, diff --git a/src/EditView.h b/src/EditView.h index 6eb63a686..8f544f280 100644 --- a/src/EditView.h +++ b/src/EditView.h @@ -133,6 +133,8 @@ public: ColourOptional background); void DrawFoldDisplayText(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, Sci::Line line, int xStart, PRectangle rcLine, int subLine, XYACCUMULATOR subLineStart, DrawPhase phase); + void DrawEOLAnnotationText(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, + Sci::Line line, int xStart, PRectangle rcLine, int subLine, XYACCUMULATOR subLineStart, DrawPhase phase); void DrawAnnotation(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, Sci::Line line, int xStart, PRectangle rcLine, int subLine, DrawPhase phase); void DrawCarets(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, Sci::Line lineDoc, diff --git a/src/Editor.cxx b/src/Editor.cxx index 234a2aaa6..12688da66 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -2126,6 +2126,7 @@ void Editor::ClearAll() { if (!pdoc->IsReadOnly()) { pcs->Clear(); pdoc->AnnotationClearAll(); + pdoc->EOLAnnotationClearAll(); pdoc->MarginClearAll(); } } @@ -2661,6 +2662,11 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) { Redraw(); } } + if (mh.modificationType & SC_MOD_CHANGEEOLANNOTATION) { + if (vs.eolAnnotationVisible) { + Redraw(); + } + } CheckModificationForWrap(mh); if (mh.linesAdded != 0) { // Avoid scrolling of display if change before current display @@ -5303,6 +5309,13 @@ void Editor::SetAnnotationVisible(int visible) { } } +void Editor::SetEOLAnnotationVisible(int visible) { + if (vs.eolAnnotationVisible != visible) { + vs.eolAnnotationVisible = visible; + Redraw(); + } +} + /** * Recursively expand a fold, making lines visible except where they have an unexpanded parent. */ @@ -8069,6 +8082,43 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_ANNOTATIONGETSTYLEOFFSET: return vs.annotationStyleOffset; + case SCI_EOLANNOTATIONSETTEXT: + pdoc->EOLAnnotationSetText(static_cast<Sci::Line>(wParam), CharPtrFromSPtr(lParam)); + break; + + case SCI_EOLANNOTATIONGETTEXT: { + const StyledText st = pdoc->EOLAnnotationStyledText(static_cast<Sci::Line>(wParam)); + return BytesResult(lParam, reinterpret_cast<const unsigned char *>(st.text), st.length); + } + + case SCI_EOLANNOTATIONGETSTYLE: { + const StyledText st = pdoc->EOLAnnotationStyledText(static_cast<Sci::Line>(wParam)); + return st.style; + } + + case SCI_EOLANNOTATIONSETSTYLE: + pdoc->EOLAnnotationSetStyle(static_cast<Sci::Line>(wParam), static_cast<int>(lParam)); + break; + + case SCI_EOLANNOTATIONCLEARALL: + pdoc->EOLAnnotationClearAll(); + break; + + case SCI_EOLANNOTATIONSETVISIBLE: + SetEOLAnnotationVisible(static_cast<int>(wParam)); + break; + + case SCI_EOLANNOTATIONGETVISIBLE: + return vs.eolAnnotationVisible; + + case SCI_EOLANNOTATIONSETSTYLEOFFSET: + vs.eolAnnotationStyleOffset = static_cast<int>(wParam); + InvalidateStyleRedraw(); + break; + + case SCI_EOLANNOTATIONGETSTYLEOFFSET: + return vs.eolAnnotationStyleOffset; + case SCI_RELEASEALLEXTENDEDSTYLES: vs.ReleaseAllExtendedStyles(); break; diff --git a/src/Editor.h b/src/Editor.h index dda14c311..74137cd48 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -546,6 +546,7 @@ protected: // ScintillaBase subclass needs access to much of Editor virtual void SetDocPointer(Document *document); void SetAnnotationVisible(int visible); + void SetEOLAnnotationVisible(int visible); Sci::Line ExpandLine(Sci::Line line); void SetFoldExpanded(Sci::Line lineDoc, bool expanded); diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index b23d7d695..fab1a2406 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -129,6 +129,8 @@ ViewStyle::ViewStyle(const ViewStyle &source) : markers(MARKER_MAX + 1), indicat marginStyleOffset = source.marginStyleOffset; annotationVisible = source.annotationVisible; annotationStyleOffset = source.annotationStyleOffset; + eolAnnotationVisible = source.eolAnnotationVisible; + eolAnnotationStyleOffset = source.eolAnnotationStyleOffset; braceHighlightIndicatorSet = source.braceHighlightIndicatorSet; braceHighlightIndicator = source.braceHighlightIndicator; braceBadLightIndicatorSet = source.braceBadLightIndicatorSet; @@ -262,6 +264,8 @@ void ViewStyle::Init(size_t stylesSize_) { marginStyleOffset = 0; annotationVisible = ANNOTATION_HIDDEN; annotationStyleOffset = 0; + eolAnnotationVisible = EOLANNOTATION_HIDDEN; + eolAnnotationStyleOffset = 0; braceHighlightIndicatorSet = false; braceHighlightIndicator = 0; braceBadLightIndicatorSet = false; diff --git a/src/ViewStyle.h b/src/ViewStyle.h index 33ea1d6c2..e5bf375f4 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -145,6 +145,8 @@ public: int marginStyleOffset; int annotationVisible; int annotationStyleOffset; + int eolAnnotationVisible; + int eolAnnotationStyleOffset; bool braceHighlightIndicatorSet; int braceHighlightIndicator; bool braceBadLightIndicatorSet; |