From ee0f914744608d9a859aa7212fe839e5e638776e Mon Sep 17 00:00:00 2001 From: Prakash Sahni Date: Fri, 12 Jun 2020 09:34:59 +1000 Subject: Backport: Bug [#2141]. Implement end of line annotations. Backport of changeset 8306:1b383adfdf71. --- src/Document.cxx | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/Document.cxx') 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(); perLineData[ldMargin] = Sci::make_unique(); perLineData[ldAnnotation] = Sci::make_unique(); + perLineData[ldEOLAnnotation] = Sci::make_unique(); decorations = DecorationListCreate(IsLarge()); @@ -215,6 +216,10 @@ LineAnnotation *Document::Annotations() const noexcept { return dynamic_cast(perLineData[ldAnnotation].get()); } +LineAnnotation *Document::EOLAnnotations() const noexcept { + return dynamic_cast(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; lClearAll(); +} + void Document::IncrementStyleClock() noexcept { styleClock = (styleClock + 1) % 0x100000; } -- cgit v1.2.3