Flutter Engine
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 14 of file text_range.h.

Constructor & Destructor Documentation

◆ TextRange() [1/3]

TextRange::TextRange ( size_t  position)
inlineexplicit

Definition at line 16 of file text_range.h.

Referenced by TextRange().

16 : base_(position), extent_(position) {}
size_t position() const
Definition: text_range.h:63

◆ TextRange() [2/3]

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

Definition at line 17 of file text_range.h.

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

18  : base_(base), extent_(extent) {}
size_t base() const
Definition: text_range.h:25
size_t extent() const
Definition: text_range.h:31

◆ TextRange() [3/3]

TextRange::TextRange ( const TextRange )
default

◆ ~TextRange()

virtual TextRange::~TextRange ( )
virtualdefault

Referenced by TextRange().

Member Function Documentation

◆ base()

size_t TextRange::base ( ) const
inline

◆ collapsed()

◆ Contains() [1/2]

bool TextRange::Contains ( size_t  position) const
inline

Definition at line 78 of file text_range.h.

References end(), and start().

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

78  {
79  return position >= start() && position <= end();
80  }
size_t end() const
Definition: text_range.h:49
size_t position() const
Definition: text_range.h:63
size_t start() const
Definition: text_range.h:37

◆ Contains() [2/2]

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

Definition at line 83 of file text_range.h.

References end(), and start().

83  {
84  return range.start() >= start() && range.end() <= end();
85  }
size_t end() const
Definition: text_range.h:49
size_t start() const
Definition: text_range.h:37

◆ end()

◆ extent()

◆ length()

size_t TextRange::length ( ) const
inline

Definition at line 69 of file text_range.h.

References end(), and start().

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

69 { return end() - start(); }
size_t end() const
Definition: text_range.h:49
size_t start() const
Definition: text_range.h:37

◆ operator=()

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

Referenced by TextRange().

◆ operator==()

bool TextRange::operator== ( const TextRange other) const
inline

Definition at line 87 of file text_range.h.

87  {
88  return base_ == other.base_ && extent_ == other.extent_;
89  }

◆ position()

◆ reversed()

bool TextRange::reversed ( ) const
inline

Definition at line 75 of file text_range.h.

Referenced by flutter::TEST().

75 { return base_ > extent_; }

◆ set_base()

void TextRange::set_base ( size_t  pos)
inline

Definition at line 28 of file text_range.h.

Referenced by flutter::TEST().

28 { base_ = pos; }

◆ set_end()

void TextRange::set_end ( size_t  pos)
inline

Definition at line 52 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().

52  {
53  if (base_ <= extent_) {
54  extent_ = pos;
55  } else {
56  base_ = pos;
57  }
58  }

◆ set_extent()

void TextRange::set_extent ( size_t  pos)
inline

Definition at line 34 of file text_range.h.

Referenced by flutter::TEST().

34 { extent_ = pos; }

◆ set_start()

void TextRange::set_start ( size_t  pos)
inline

Definition at line 40 of file text_range.h.

Referenced by flutter::TEST().

40  {
41  if (base_ <= extent_) {
42  base_ = pos;
43  } else {
44  extent_ = pos;
45  }
46  }

◆ start()


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