1 /* 2 * Copyright 2014, Stephan Aßmus <superstippi@gmx.de>. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 6 #include "TextSelection.h" 7 8 9 TextSelection::TextSelection() 10 : 11 fAnchor(0), 12 fCaret(0) 13 { 14 } 15 16 17 TextSelection::TextSelection(int32 anchor, int32 caret) 18 : 19 fAnchor(anchor), 20 fCaret(caret) 21 { 22 } 23 24 25 TextSelection::TextSelection(const TextSelection& other) 26 : 27 fAnchor(other.fAnchor), 28 fCaret(other.fCaret) 29 { 30 } 31 32 33 TextSelection& 34 TextSelection::operator=(const TextSelection& other) 35 { 36 if (this == &other) 37 return *this; 38 39 fAnchor = other.fAnchor; 40 fCaret = other.fCaret; 41 return *this; 42 } 43 44 45 bool 46 TextSelection::operator==(const TextSelection& other) const 47 { 48 return (this == &other) 49 || (fAnchor == other.fAnchor && fCaret == other.fCaret); 50 } 51 52 53 bool 54 TextSelection::operator!=(const TextSelection& other) const 55 { 56 return !(*this == other); 57 } 58 59 60 void 61 TextSelection::SetAnchor(int32 anchor) 62 { 63 fAnchor = anchor; 64 } 65 66 67 void 68 TextSelection::SetCaret(int32 caret) 69 { 70 fCaret = caret; 71 } 72 73