text-cursor.cpp 894 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #if defined(Hiro_TextCursor)
  2. TextCursor::TextCursor(int offset, int length) {
  3. setTextCursor(offset, length);
  4. }
  5. TextCursor::operator bool() const {
  6. return offset() || length();
  7. }
  8. auto TextCursor::operator==(const TextCursor& source) const -> bool {
  9. return offset() == source.offset() && length() == source.length();
  10. }
  11. auto TextCursor::operator!=(const TextCursor& source) const -> bool {
  12. return !operator==(source);
  13. }
  14. auto TextCursor::length() const -> int {
  15. return state.length;
  16. }
  17. auto TextCursor::offset() const -> int {
  18. return state.offset;
  19. }
  20. auto TextCursor::setLength(int length) -> type& {
  21. state.length = length;
  22. return *this;
  23. }
  24. auto TextCursor::setOffset(int offset) -> type& {
  25. state.offset = offset;
  26. return *this;
  27. }
  28. auto TextCursor::setTextCursor(int offset, int length) -> type& {
  29. state.offset = offset;
  30. state.length = length;
  31. return *this;
  32. }
  33. #endif