aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/CellBuffer.h
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2026-03-30 18:30:55 +1100
committerNeil <nyamatongwe@gmail.com>2026-03-30 18:30:55 +1100
commitf07caccbf33acd188cbe4961ece30251102351cc (patch)
tree9a7b573d41923b77229e28386164d05e9d710fff /src/CellBuffer.h
parenta00464fbff54f486efa3ee103948e3526548fc46 (diff)
downloadscintilla-mirror-f07caccbf33acd188cbe4961ece30251102351cc.tar.gz
Feature [feature-requests:#1582]. Improve performance of Document::SetStyles.
Report changed range for Document::SetStyleFor.
Diffstat (limited to 'src/CellBuffer.h')
-rw-r--r--src/CellBuffer.h24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/CellBuffer.h b/src/CellBuffer.h
index 1b035597a..e48eded4d 100644
--- a/src/CellBuffer.h
+++ b/src/CellBuffer.h
@@ -66,6 +66,24 @@ struct SplitView {
}
};
+struct ChangedRange {
+ Sci::Position start = Sci::invalidPosition;
+ Sci::Position end = Sci::invalidPosition;
+ ChangedRange() noexcept = default;
+ ChangedRange(Sci::Position start_, Sci::Position end_) noexcept : start(start_), end(end_) {}
+ [[nodiscard]] bool Empty() const noexcept {
+ return start < 0;
+ }
+ void Merge(const ChangedRange &cr2) noexcept {
+ if (cr2.start >= 0) {
+ if (start < 0) {
+ *this = cr2;
+ } else {
+ end = cr2.end;
+ }
+ }
+ }
+};
/**
* Holder for an expandable array of characters that supports undo and line markers.
@@ -141,9 +159,9 @@ public:
const char *InsertString(Sci::Position position, const char *s, Sci::Position insertLength, bool &startSequence);
/// Setting styles for positions outside the range of the buffer is safe and has no effect.
- /// @return true if the style of a character is changed.
- bool SetStyleAt(Sci::Position position, char styleValue) noexcept;
- bool SetStyleFor(Sci::Position position, Sci::Position lengthStyle, char styleValue) noexcept;
+ /// @return range where style of characters changed.
+ ChangedRange SetStyles(Sci::Position position, const char *styles, Sci::Position length) noexcept;
+ ChangedRange SetStyleFor(Sci::Position position, Sci::Position lengthStyle, char styleValue) noexcept;
const char *DeleteChars(Sci::Position position, Sci::Position deleteLength, bool &startSequence);