| Flutter macOS Embedder |

Public Member Functions | List of all members
flutter::TextRange Class Reference

`#include <text_range.h>`

## Public Member Functions
| TextRange (size_t position)
| TextRange (size_t base, size_t extent)
| TextRange (const TextRange &)=default
TextRange & | operator= (const TextRange &)=default
virtual | ~TextRange ()=default
size_t | base () const
void | set_base (size_t pos)
size_t | extent () const
void | set_extent (size_t pos)
size_t | start () const
void | set_start (size_t pos)
size_t | end () const
void | set_end (size_t pos)
size_t | position () const
size_t | length () const
bool | collapsed () const
bool | reversed () const
bool | Contains (size_t position) const
bool | Contains (const TextRange &range) const
bool | operator== (const TextRange &other) const

## Detailed Description

Definition at line 19 of file text_range.h.

## Constructor & Destructor Documentation

## ◆ TextRange() [1/3]

flutter::TextRange::TextRange | ( | size_t | position | ) |
| inline explicit

Definition at line 21 of file text_range.h.

21 : base_(position), extent_(position) {}

## ◆ TextRange() [2/3]

flutter::TextRange::TextRange | ( | size_t | base,
|  | size_t | extent
| ) |  |
| inline explicit

Definition at line 22 of file text_range.h.

23 : base_(base), extent_(extent) {}

## ◆ TextRange() [3/3]

flutter::TextRange::TextRange | ( | const TextRange & |  | ) |
| default

## ◆ ~TextRange()

virtual flutter::TextRange::~TextRange | ( |  | ) |
| virtual default

## Member Function Documentation

## ◆ base()

size_t flutter::TextRange::base | ( |  | ) | const
| inline

Definition at line 30 of file text_range.h.

30 { return base_; }

Referenced by flutter::TextInputModel::SelectToBeginning(), flutter::TextInputModel::SelectToEnd(), and flutter::TEST().

## ◆ collapsed()

bool flutter::TextRange::collapsed | ( |  | ) | const
| inline

Definition at line 77 of file text_range.h.

77 { return base_ == extent_; }

Referenced by flutter::TextInputModel::CommitComposing(), flutter::TextInputModel::MoveCursorBack(), flutter::TextInputModel::MoveCursorForward(), flutter::TextInputModel::MoveCursorToBeginning(), flutter::TextInputModel::MoveCursorToEnd(), flutter::TextInputModel::SelectToBeginning(), flutter::TextInputModel::SelectToEnd(), flutter::TextInputModel::SetSelection(), flutter::TextInputModel::SetText(), flutter::TEST(), and flutter::TextInputModel::UpdateComposingText().

## ◆ Contains() [1/2]

bool flutter::TextRange::Contains | ( | const TextRange & | range | ) | const
| inline

Definition at line 88 of file text_range.h.

88 {
89 return range.start() >= start() && range.end() <= end();
90 }

References end(), and start().

## ◆ Contains() [2/2]

bool flutter::TextRange::Contains | ( | size_t | position | ) | const
| inline

Definition at line 83 of file text_range.h.

83 {
84 return position >= start() && position <= end();
85 }

References end(), position(), and start().

Referenced by flutter::TEST().

## ◆ end()

size_t flutter::TextRange::end | ( |  | ) | const
| inline

Definition at line 54 of file text_range.h.

54 { return std::max(base_, extent_); }

Referenced by flutter::TextInputModel::Backspace(), flutter::TextInputModel::CommitComposing(), Contains(), flutter::TextInputModel::Delete(), flutter::TextInputModel::DeleteSurrounding(), length(), flutter::TextInputModel::MoveCursorForward(), flutter::TextInputModel::MoveCursorToEnd(), flutter::TextInputModel::SelectToEnd(), and flutter::TEST().

## ◆ extent()

size_t flutter::TextRange::extent | ( |  | ) | const
| inline

Definition at line 36 of file text_range.h.

36 { return extent_; }

Referenced by flutter::TextInputModel::DeleteSurrounding(), flutter::TextInputModel::GetCursorOffset(), flutter::TEST(), and flutter::TextInputModel::UpdateComposingText().

## ◆ length()

size_t flutter::TextRange::length | ( |  | ) | const
| inline

Definition at line 74 of file text_range.h.

74 { return end() - start(); }

References end(), and start().

Referenced by flutter::TextInputModel::AddText(), flutter::TEST(), and flutter::TextInputModel::UpdateComposingText().

## ◆ operator=()

TextRange& flutter::TextRange::operator= | ( | const TextRange & |  | ) |
| default

## ◆ operator==()

bool flutter::TextRange::operator== | ( | const TextRange & | other | ) | const
| inline

Definition at line 92 of file text_range.h.

92 {
93 return base_ == other.base_ && extent_ == other.extent_;
94 }

## ◆ position()

size_t flutter::TextRange::position | ( |  | ) | const
| inline

Definition at line 68 of file text_range.h.

68 {
69 FML_DCHECK(base_ == extent_);
70 return extent_;
71 }

Referenced by flutter::TextInputModel::AddText(), flutter::TextInputModel::Backspace(), Contains(), flutter::TextInputModel::Delete(), flutter::TextInputModel::MoveCursorBack(), flutter::TextInputModel::MoveCursorForward(), flutter::TextInputModel::MoveCursorToBeginning(), flutter::TextInputModel::MoveCursorToEnd(), flutter::TextInputModel::SelectToBeginning(), flutter::TextInputModel::SelectToEnd(), and flutter::TEST().

## ◆ reversed()

bool flutter::TextRange::reversed | ( |  | ) | const
| inline

Definition at line 80 of file text_range.h.

80 { return base_ > extent_; }

Referenced by flutter::TEST().

## ◆ set_base()

void flutter::TextRange::set_base | ( | size_t | pos | ) |
| inline

Definition at line 33 of file text_range.h.

33 { base_ = pos; }

Referenced by flutter::TEST().

## ◆ set_end()

void flutter::TextRange::set_end | ( | size_t | pos | ) |
| inline

Definition at line 57 of file text_range.h.

57 {
58 if (base_ <= extent_) {
59 extent_ = pos;
60 } else {
61 base_ = pos;
62 }
63 }

Referenced by flutter::TextInputModel::AddText(), flutter::TextInputModel::Backspace(), flutter::TextInputModel::Delete(), flutter::TextInputModel::DeleteSurrounding(), flutter::TEST(), and flutter::TextInputModel::UpdateComposingText().

## ◆ set_extent()

void flutter::TextRange::set_extent | ( | size_t | pos | ) |
| inline

Definition at line 39 of file text_range.h.

39 { extent_ = pos; }

Referenced by flutter::TEST().

## ◆ set_start()

void flutter::TextRange::set_start | ( | size_t | pos | ) |
| inline

Definition at line 45 of file text_range.h.

45 {
46 if (base_ <= extent_) {
47 base_ = pos;
48 } else {
49 extent_ = pos;
50 }
51 }

Referenced by flutter::TEST().

## ◆ start()

size_t flutter::TextRange::start | ( |  | ) | const
| inline

Definition at line 42 of file text_range.h.

42 { return std::min(base_, extent_); }

Referenced by flutter::TextInputModel::AddText(), flutter::TextInputModel::BeginComposing(), Contains(), flutter::TextInputModel::DeleteSurrounding(), length(), flutter::TextInputModel::MoveCursorBack(), flutter::TextInputModel::MoveCursorToBeginning(), flutter::TextInputModel::SelectToBeginning(), flutter::TextInputModel::SetComposingRange(), flutter::TEST(), and flutter::TextInputModel::UpdateComposingText().

The documentation for this class was generated from the following file:

- shell/platform/common/text_range.h

flutter::TextRange::end
size_t end() const
Definition: text_range.h:54
flutter::TextRange::position
size_t position() const
Definition: text_range.h:68
flutter::TextRange::base
size_t base() const
Definition: text_range.h:30
flutter::TextRange::extent
size_t extent() const
Definition: text_range.h:36
flutter::TextRange::start
size_t start() const
Definition: text_range.h:42