Flutter Engine
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
 
TextRangeoperator= (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)
inlineexplicit

Definition at line 21 of file text_range.h.

Referenced by TextRange().

21 : base_(position), extent_(position) {}
size_t position() const
Definition: text_range.h:68

◆ TextRange() [2/3]

flutter::TextRange::TextRange ( size_t  base,
size_t  extent 
)
inlineexplicit

Definition at line 22 of file text_range.h.

References operator=(), TextRange(), and ~TextRange().

23  : base_(base), extent_(extent) {}
size_t extent() const
Definition: text_range.h:36

◆ TextRange() [3/3]

flutter::TextRange::TextRange ( const TextRange )
default

◆ ~TextRange()

virtual flutter::TextRange::~TextRange ( )
virtualdefault

Referenced by TextRange().

Member Function Documentation

◆ base()

◆ collapsed()

◆ Contains() [1/2]

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

Definition at line 83 of file text_range.h.

References end(), and start().

Referenced by flutter::TextInputModel::SetSelection(), and flutter::TEST().

83  {
84  return position >= start() && position <= end();
85  }
size_t end() const
Definition: text_range.h:54
size_t position() const
Definition: text_range.h:68
size_t start() const
Definition: text_range.h:42

◆ Contains() [2/2]

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

Definition at line 88 of file text_range.h.

References end(), and start().

88  {
89  return range.start() >= start() && range.end() <= end();
90  }
size_t end() const
Definition: text_range.h:54
size_t start() const
Definition: text_range.h:42

◆ end()

◆ extent()

◆ length()

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

◆ operator=()

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

Referenced by TextRange().

◆ 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()

◆ reversed()

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

Definition at line 80 of file text_range.h.

Referenced by flutter::TEST().

80 { return base_ > extent_; }

◆ set_base()

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

Definition at line 33 of file text_range.h.

Referenced by flutter::TEST().

33 { base_ = pos; }

◆ set_end()

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

Definition at line 57 of file text_range.h.

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

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

◆ set_extent()

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

Definition at line 39 of file text_range.h.

Referenced by flutter::TEST().

39 { extent_ = pos; }

◆ set_start()

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

Definition at line 45 of file text_range.h.

Referenced by flutter::TEST().

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

◆ start()


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