aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Document.cxx
diff options
context:
space:
mode:
authorPrakash Sahni <unknown>2020-06-12 09:34:59 +1000
committerPrakash Sahni <unknown>2020-06-12 09:34:59 +1000
commitee0f914744608d9a859aa7212fe839e5e638776e (patch)
tree3c2546438e5a28d792d8f896e6df84f940e64b04 /src/Document.cxx
parent7bdbad1346fa2d34ab37d7fd7d1574b78f879b6f (diff)
downloadscintilla-mirror-ee0f914744608d9a859aa7212fe839e5e638776e.tar.gz
Backport: Bug [#2141]. Implement end of line annotations.
Backport of changeset 8306:1b383adfdf71.
Diffstat (limited to 'src/Document.cxx')
-rw-r--r--src/Document.cxx35
1 files changed, 35 insertions, 0 deletions
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;
}