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 TextSelection()9TextSelection::TextSelection() 10 : 11 fAnchor(0), 12 fCaret(0) 13 { 14 } 15 16 TextSelection(int32 anchor,int32 caret)17TextSelection::TextSelection(int32 anchor, int32 caret) 18 : 19 fAnchor(anchor), 20 fCaret(caret) 21 { 22 } 23 24 TextSelection(const TextSelection & other)25TextSelection::TextSelection(const TextSelection& other) 26 : 27 fAnchor(other.fAnchor), 28 fCaret(other.fCaret) 29 { 30 } 31 32 33 TextSelection& operator =(const TextSelection & other)34TextSelection::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 operator ==(const TextSelection & other) const46TextSelection::operator==(const TextSelection& other) const 47 { 48 return (this == &other) 49 || (fAnchor == other.fAnchor && fCaret == other.fCaret); 50 } 51 52 53 bool operator !=(const TextSelection & other) const54TextSelection::operator!=(const TextSelection& other) const 55 { 56 return !(*this == other); 57 } 58 59 60 void SetAnchor(int32 anchor)61TextSelection::SetAnchor(int32 anchor) 62 { 63 fAnchor = anchor; 64 } 65 66 67 void SetCaret(int32 caret)68TextSelection::SetCaret(int32 caret) 69 { 70 fCaret = caret; 71 } 72 73