aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/RunStyles.cxx
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2018-03-27 19:35:55 +1100
committerNeil <nyamatongwe@gmail.com>2018-03-27 19:35:55 +1100
commite93a47975d317f59df0fdcca7cee95b6ab4ff33f (patch)
tree852d09d665ca8cb76fa919805db7fcfa0028ea39 /src/RunStyles.cxx
parentfb9f493960b075b034b18d61036d36f384f2e3f8 (diff)
downloadscintilla-mirror-e93a47975d317f59df0fdcca7cee95b6ab4ff33f.tar.gz
Return a FillResult struct from RunStyles::FillRange instead of modifying
arguments as that is clumsy when converting types.
Diffstat (limited to 'src/RunStyles.cxx')
-rw-r--r--src/RunStyles.cxx17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/RunStyles.cxx b/src/RunStyles.cxx
index fa8844bfe..03692f673 100644
--- a/src/RunStyles.cxx
+++ b/src/RunStyles.cxx
@@ -126,13 +126,14 @@ DISTANCE RunStyles<DISTANCE, STYLE>::EndRun(DISTANCE position) const {
}
template <typename DISTANCE, typename STYLE>
-bool RunStyles<DISTANCE, STYLE>::FillRange(DISTANCE &position, STYLE value, DISTANCE &fillLength) {
+FillResult<DISTANCE> RunStyles<DISTANCE, STYLE>::FillRange(DISTANCE position, STYLE value, DISTANCE fillLength) {
+ const FillResult<DISTANCE> resultNoChange{false, position, fillLength};
if (fillLength <= 0) {
- return false;
+ return resultNoChange;
}
DISTANCE end = position + fillLength;
if (end > Length()) {
- return false;
+ return resultNoChange;
}
DISTANCE runEnd = RunFromPosition(end);
if (styles->ValueAt(runEnd) == value) {
@@ -140,7 +141,7 @@ bool RunStyles<DISTANCE, STYLE>::FillRange(DISTANCE &position, STYLE value, DIST
end = starts->PositionFromPartition(runEnd);
if (position >= end) {
// Whole range is already same as value so no action
- return false;
+ return resultNoChange;
}
fillLength = end - position;
} else {
@@ -159,6 +160,7 @@ bool RunStyles<DISTANCE, STYLE>::FillRange(DISTANCE &position, STYLE value, DIST
}
}
if (runStart < runEnd) {
+ const FillResult<DISTANCE> result{ true, position, fillLength };
styles->SetValueAt(runStart, value);
// Remove each old run over the range
for (DISTANCE run=runStart+1; run<runEnd; run++) {
@@ -169,16 +171,15 @@ bool RunStyles<DISTANCE, STYLE>::FillRange(DISTANCE &position, STYLE value, DIST
RemoveRunIfSameAsPrevious(runStart);
runEnd = RunFromPosition(end);
RemoveRunIfEmpty(runEnd);
- return true;
+ return result;
} else {
- return false;
+ return resultNoChange;
}
}
template <typename DISTANCE, typename STYLE>
void RunStyles<DISTANCE, STYLE>::SetValueAt(DISTANCE position, STYLE value) {
- DISTANCE len = 1;
- FillRange(position, value, len);
+ FillRange(position, value, 1);
}
template <typename DISTANCE, typename STYLE>