| 83 | }; |
| 84 | |
| 85 | struct SelectionRange { |
| 86 | SelectionPosition caret; |
| 87 | SelectionPosition anchor; |
| 88 | |
| 89 | SelectionRange() : caret(), anchor() { |
| 90 | } |
| 91 | SelectionRange(SelectionPosition single) : caret(single), anchor(single) { |
| 92 | } |
| 93 | SelectionRange(int single) : caret(single), anchor(single) { |
| 94 | } |
| 95 | SelectionRange(SelectionPosition caret_, SelectionPosition anchor_) : caret(caret_), anchor(anchor_) { |
| 96 | } |
| 97 | SelectionRange(int caret_, int anchor_) : caret(caret_), anchor(anchor_) { |
| 98 | } |
| 99 | bool Empty() const { |
| 100 | return anchor == caret; |
| 101 | } |
| 102 | int Length() const; |
| 103 | // int Width() const; // Like Length but takes virtual space into account |
| 104 | bool operator ==(const SelectionRange &other) const { |
| 105 | return caret == other.caret && anchor == other.anchor; |
| 106 | } |
| 107 | bool operator <(const SelectionRange &other) const { |
| 108 | return caret < other.caret || ((caret == other.caret) && (anchor < other.anchor)); |
| 109 | } |
| 110 | void Reset() { |
| 111 | anchor.Reset(); |
| 112 | caret.Reset(); |
| 113 | } |
| 114 | void ClearVirtualSpace() { |
| 115 | anchor.SetVirtualSpace(0); |
| 116 | caret.SetVirtualSpace(0); |
| 117 | } |
| 118 | bool Contains(int pos) const; |
| 119 | bool Contains(SelectionPosition sp) const; |
| 120 | bool ContainsCharacter(int posCharacter) const; |
| 121 | SelectionSegment Intersect(SelectionSegment check) const; |
| 122 | SelectionPosition Start() const { |
| 123 | return (anchor < caret) ? anchor : caret; |
| 124 | } |
| 125 | SelectionPosition End() const { |
| 126 | return (anchor < caret) ? caret : anchor; |
| 127 | } |
| 128 | bool Trim(SelectionRange range); |
| 129 | // If range is all virtual collapse to start of virtual space |
| 130 | void MinimizeVirtualSpace(); |
| 131 | }; |
| 132 | |
| 133 | class Selection { |
| 134 | std::vector<SelectionRange> ranges; |
no outgoing calls
no test coverage detected