diff options
Diffstat (limited to 'src/Selection.h')
-rw-r--r-- | src/Selection.h | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/Selection.h b/src/Selection.h index 94d6fc65e..0cb1200f8 100644 --- a/src/Selection.h +++ b/src/Selection.h @@ -56,6 +56,26 @@ public: } }; +// Ordered range to make drawing simpler +struct SelectionSegment { + SelectionPosition start; + SelectionPosition end; + SelectionSegment() { + } + SelectionSegment(SelectionPosition a, SelectionPosition b) { + if (a < b) { + start = a; + end = b; + } else { + start = b; + end = a; + } + } + bool Empty() const { + return start == end; + } +}; + struct SelectionRange { SelectionPosition caret; SelectionPosition anchor; @@ -87,7 +107,7 @@ struct SelectionRange { bool Contains(int pos) const; bool Contains(SelectionPosition sp) const; bool ContainsCharacter(int posCharacter) const; - bool Intersect(int start, int end, SelectionPosition &selStart, SelectionPosition &selEnd) const; + SelectionSegment Intersect(SelectionSegment check) const; SelectionPosition Start() const { return (anchor < caret) ? anchor : caret; } |