MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / FillRange

Method FillRange

scintilla/src/RunStyles.cxx:117–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117bool RunStyles::FillRange(int &position, int value, int &fillLength) {
118 if (fillLength <= 0) {
119 return false;
120 }
121 int end = position + fillLength;
122 if (end > Length()) {
123 return false;
124 }
125 int runEnd = RunFromPosition(end);
126 if (styles->ValueAt(runEnd) == value) {
127 // End already has value so trim range.
128 end = starts->PositionFromPartition(runEnd);
129 if (position >= end) {
130 // Whole range is already same as value so no action
131 return false;
132 }
133 fillLength = end - position;
134 } else {
135 runEnd = SplitRun(end);
136 }
137 int runStart = RunFromPosition(position);
138 if (styles->ValueAt(runStart) == value) {
139 // Start is in expected value so trim range.
140 runStart++;
141 position = starts->PositionFromPartition(runStart);
142 fillLength = end - position;
143 } else {
144 if (starts->PositionFromPartition(runStart) < position) {
145 runStart = SplitRun(position);
146 runEnd++;
147 }
148 }
149 if (runStart < runEnd) {
150 styles->SetValueAt(runStart, value);
151 // Remove each old run over the range
152 for (int run=runStart+1; run<runEnd; run++) {
153 RemoveRun(runStart+1);
154 }
155 runEnd = RunFromPosition(end);
156 RemoveRunIfSameAsPrevious(runEnd);
157 RemoveRunIfSameAsPrevious(runStart);
158 runEnd = RunFromPosition(end);
159 RemoveRunIfEmpty(runEnd);
160 return true;
161 } else {
162 return false;
163 }
164}
165
166void RunStyles::SetValueAt(int position, int value) {
167 int len = 1;

Callers 1

DecorationFillRangeMethod · 0.45

Calls 3

PositionFromPartitionMethod · 0.80
ValueAtMethod · 0.45
SetValueAtMethod · 0.45

Tested by

no test coverage detected