aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Selection.cxx
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2021-05-01 16:48:50 +1000
committerNeil <nyamatongwe@gmail.com>2021-05-01 16:48:50 +1000
commit93591238af8bf8b5246adcfe7a115f443442f44e (patch)
tree94b402e2a6c39d622a49be999517ff83be9ce378 /src/Selection.cxx
parent1f5a3b0b2d81351819ebb189a1ae4379e8762e75 (diff)
downloadscintilla-mirror-93591238af8bf8b5246adcfe7a115f443442f44e.tar.gz
Improve selection drawing code. Use InSelection enum instead of int.
Add Selection::RangeType and EditModel::LineEndInSelection to hoist code out of EditView. Replace SimpleAlphaRectangle with Surface::FillRectangleAligned when alpha known to not be SC_ALPHA_NOALPHA.
Diffstat (limited to 'src/Selection.cxx')
-rw-r--r--src/Selection.cxx16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/Selection.cxx b/src/Selection.cxx
index 7f2361f08..0675ceefe 100644
--- a/src/Selection.cxx
+++ b/src/Selection.cxx
@@ -392,20 +392,24 @@ void Selection::CommitTentative() noexcept {
tentativeMain = false;
}
-int Selection::CharacterInSelection(Sci::Position posCharacter) const noexcept {
+InSelection Selection::RangeType(size_t r) const noexcept {
+ return r == Main() ? InSelection::inMain : InSelection::inAdditional;
+}
+
+InSelection Selection::CharacterInSelection(Sci::Position posCharacter) const noexcept {
for (size_t i=0; i<ranges.size(); i++) {
if (ranges[i].ContainsCharacter(posCharacter))
- return i == mainRange ? 1 : 2;
+ return RangeType(i);
}
- return 0;
+ return InSelection::inNone;
}
-int Selection::InSelectionForEOL(Sci::Position pos) const noexcept {
+InSelection Selection::InSelectionForEOL(Sci::Position pos) const noexcept {
for (size_t i=0; i<ranges.size(); i++) {
if (!ranges[i].Empty() && (pos > ranges[i].Start().Position()) && (pos <= ranges[i].End().Position()))
- return i == mainRange ? 1 : 2;
+ return RangeType(i);
}
- return 0;
+ return InSelection::inNone;
}
Sci::Position Selection::VirtualSpaceFor(Sci::Position pos) const noexcept {