diff options
| -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 | 92 | ||||
| -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, 341 insertions, 4 deletions
| diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 98040ba94..4f89ef69e 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -426,6 +426,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> @@ -3694,6 +3696,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 ae942e58e..f60a1fb4a 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -548,6 +548,7 @@        </tr><tr>  	<td>Chris Graham</td>  	<td>Hugues Larrive</td> +	<td>Prakash Sahni</td>      </tr>      </table>      <p> @@ -581,6 +582,10 @@  	<a href="https://sourceforge.net/p/scintilla/feature-requests/1347/">Feature #1347</a>.  	</li>  	<li> +	End of line annotations implemented. +	<a href="https://sourceforge.net/p/scintilla/bugs/2141/">Bug #2141</a>. +	</li> +	<li>  	Round SCI_TEXTWIDTH instead of truncating as this may be more accurate when sizing application  	elements to match text.  	<a href="https://sourceforge.net/p/scintilla/feature-requests/1355/">Feature #1355</a>. diff --git a/doc/eolannotation.png b/doc/eolannotation.pngBinary files differ new file mode 100644 index 000000000..5dacbf569 --- /dev/null +++ b/doc/eolannotation.png diff --git a/include/Scintilla.h b/include/Scintilla.h index f709b1534..7cc0211d3 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -1007,6 +1007,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 @@ -1067,7 +1079,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 5b07902de..483208acf 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -2844,6 +2844,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(,) @@ -2994,7 +3026,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 @@ -3014,6 +3047,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 b3ff671da..be3c01fa3 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -140,6 +140,7 @@ Document::Document(int options) :  	perLineData[ldState] = Sci::make_unique<LineState>();  	perLineData[ldMargin] = Sci::make_unique<LineAnnotation>();  	perLineData[ldAnnotation] = Sci::make_unique<LineAnnotation>(); +	perLineData[ldEOLAnnotation] = Sci::make_unique<LineAnnotation>();  	decorations = DecorationListCreate(IsLarge()); @@ -215,6 +216,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(); @@ -2388,6 +2393,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 f56bf01eb..a9c591cb1 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 b3c577177..35fee11f5 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -986,7 +986,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); @@ -1194,6 +1195,93 @@ 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 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, stEOLAnnotation.text, stEOLAnnotation.length)); + +	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) { +		rcSegment.left += (static_cast<int>(surface->WidthText(fontText, textFoldDisplay, static_cast<int>(strlen(textFoldDisplay)))) + 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, stEOLAnnotation.text, stEOLAnnotation.length, +			textFore); +		} else { +			surface->DrawTextNoClip(rcSegment, fontText, +			rcSegment.top + vsDraw.maxAscent, stEOLAnnotation.text, stEOLAnnotation.length, +			textFore, textBack); +		} +	} + +	if (phase & drawIndicatorsFore) { +		if (vsDraw.eolAnnotationVisible == EOLANNOTATION_BOXED ) { +			surface->PenColour(textFore); +			PRectangle rcBox = rcSegment; +			rcBox.left = Sci::round(rcSegment.left); +			rcBox.right = Sci::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;  } @@ -1910,6 +1998,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); @@ -1938,6 +2027,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 5f2950dc5..0ff5ef834 100644 --- a/src/EditView.h +++ b/src/EditView.h @@ -131,6 +131,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 e655b7e82..195be8a01 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -2122,6 +2122,7 @@ void Editor::ClearAll() {  		if (!pdoc->IsReadOnly()) {  			pcs->Clear();  			pdoc->AnnotationClearAll(); +			pdoc->EOLAnnotationClearAll();  			pdoc->MarginClearAll();  		}  	} @@ -2657,6 +2658,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 @@ -5298,6 +5304,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.   */ @@ -8055,6 +8068,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 626b67325..4f629bad4 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 5b8a226f3..e2dc4b70e 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -128,6 +128,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; @@ -261,6 +263,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; | 
