#include <text_input_model.h>
Definition at line 18 of file text_input_model.h.
◆ TextInputModel()
flutter::TextInputModel::TextInputModel |
( |
| ) |
|
|
default |
◆ ~TextInputModel()
flutter::TextInputModel::~TextInputModel |
( |
| ) |
|
|
virtualdefault |
◆ AddCodePoint()
void flutter::TextInputModel::AddCodePoint |
( |
char32_t |
c | ) |
|
Definition at line 122 of file text_input_model.cc.
122 {
123 if (c <= 0xFFFF) {
124 AddText(std::u16string({
static_cast<char16_t>(c)}));
125 } else {
126 char32_t to_decompose = c - 0x10000;
128
129 static_cast<char16_t>((to_decompose >> 10) + 0xd800),
130
131 static_cast<char16_t>((to_decompose % 0x400) + 0xdc00),
132 }));
133 }
134}
void AddText(const std::u16string &text)
◆ AddText() [1/2]
void flutter::TextInputModel::AddText |
( |
const std::string & |
text | ) |
|
Definition at line 149 of file text_input_model.cc.
149 {
151}
std::u16string Utf8ToUtf16(const std::string_view string)
◆ AddText() [2/2]
void flutter::TextInputModel::AddText |
( |
const std::u16string & |
text | ) |
|
Definition at line 136 of file text_input_model.cc.
136 {
137 DeleteSelected();
138 if (composing_) {
139
140 text_.erase(composing_range_.
start(), composing_range_.
length());
143 }
144 size_t position = selection_.
position();
145 text_.insert(position,
text);
147}
SkRange< size_t > TextRange
◆ Backspace()
bool flutter::TextInputModel::Backspace |
( |
| ) |
|
Definition at line 153 of file text_input_model.cc.
153 {
154 if (DeleteSelected()) {
155 return true;
156 }
157
158 size_t position = selection_.
position();
159 if (position != editable_range().
start()) {
160 int count = IsTrailingSurrogate(text_.at(position - 1)) ? 2 : 1;
163 if (composing_) {
165 }
166 return true;
167 }
168 return false;
169}
◆ BeginComposing()
void flutter::TextInputModel::BeginComposing |
( |
| ) |
|
◆ CommitComposing()
void flutter::TextInputModel::CommitComposing |
( |
| ) |
|
Definition at line 94 of file text_input_model.cc.
94 {
95
97 return;
98 }
100 selection_ = composing_range_;
101}
◆ composing()
bool flutter::TextInputModel::composing |
( |
| ) |
const |
|
inline |
◆ composing_range()
TextRange flutter::TextInputModel::composing_range |
( |
| ) |
const |
|
inline |
◆ Delete()
bool flutter::TextInputModel::Delete |
( |
| ) |
|
Definition at line 171 of file text_input_model.cc.
171 {
172 if (DeleteSelected()) {
173 return true;
174 }
175
176 size_t position = selection_.
position();
177 if (position < editable_range().
end()) {
178 int count = IsLeadingSurrogate(text_.at(position)) ? 2 : 1;
179 text_.erase(position,
count);
180 if (composing_) {
182 }
183 return true;
184 }
185 return false;
186}
◆ DeleteSurrounding()
bool flutter::TextInputModel::DeleteSurrounding |
( |
int |
offset_from_cursor, |
|
|
int |
count |
|
) |
| |
Definition at line 188 of file text_input_model.cc.
188 {
189 size_t max_pos = editable_range().
end();
191 if (offset_from_cursor < 0) {
192 for (
int i = 0;
i < -offset_from_cursor;
i++) {
193
194
195 if (start == editable_range().
start()) {
197 break;
198 }
199 start -= IsTrailingSurrogate(text_.at(start - 1)) ? 2 : 1;
200 }
201 } else {
202 for (
int i = 0;
i < offset_from_cursor &&
start != max_pos;
i++) {
203 start += IsLeadingSurrogate(text_.at(start)) ? 2 : 1;
204 }
205 }
206
208 for (
int i = 0;
i <
count &&
end != max_pos;
i++) {
209 end += IsLeadingSurrogate(text_.at(start)) ? 2 : 1;
210 }
211
212 if (start == end) {
213 return false;
214 }
215
217 text_.erase(start, deleted_length);
218
219
220 selection_ =
TextRange(offset_from_cursor <= 0 ? start : selection_.
start());
221
222
223 if (composing_) {
224 composing_range_.
set_end(composing_range_.
end() - deleted_length);
225 }
226 return true;
227}
◆ EndComposing()
void flutter::TextInputModel::EndComposing |
( |
| ) |
|
◆ GetCursorOffset()
int flutter::TextInputModel::GetCursorOffset |
( |
| ) |
const |
Definition at line 301 of file text_input_model.cc.
301 {
302
303
304 auto leading_text = text_.substr(0, selection_.
extent());
306}
std::string Utf16ToUtf8(const std::u16string_view string)
◆ GetText()
std::string flutter::TextInputModel::GetText |
( |
| ) |
const |
◆ MoveCursorBack()
bool flutter::TextInputModel::MoveCursorBack |
( |
| ) |
|
Definition at line 281 of file text_input_model.cc.
281 {
282
285 return true;
286 }
287
288 size_t position = selection_.
position();
289 if (position != editable_range().
start()) {
290 int count = IsTrailingSurrogate(text_.at(position - 1)) ? 2 : 1;
292 return true;
293 }
294 return false;
295}
◆ MoveCursorForward()
bool flutter::TextInputModel::MoveCursorForward |
( |
| ) |
|
Definition at line 265 of file text_input_model.cc.
265 {
266
269 return true;
270 }
271
272 size_t position = selection_.
position();
273 if (position != editable_range().
end()) {
274 int count = IsLeadingSurrogate(text_.at(position)) ? 2 : 1;
276 return true;
277 }
278 return false;
279}
◆ MoveCursorToBeginning()
bool flutter::TextInputModel::MoveCursorToBeginning |
( |
| ) |
|
Definition at line 229 of file text_input_model.cc.
229 {
230 size_t min_pos = editable_range().
start();
232 return false;
233 }
235 return true;
236}
◆ MoveCursorToEnd()
bool flutter::TextInputModel::MoveCursorToEnd |
( |
| ) |
|
Definition at line 238 of file text_input_model.cc.
238 {
239 size_t max_pos = editable_range().
end();
241 return false;
242 }
244 return true;
245}
◆ selection()
TextRange flutter::TextInputModel::selection |
( |
| ) |
const |
|
inline |
◆ SelectToBeginning()
bool flutter::TextInputModel::SelectToBeginning |
( |
| ) |
|
Definition at line 247 of file text_input_model.cc.
247 {
248 size_t min_pos = editable_range().
start();
250 return false;
251 }
253 return true;
254}
◆ SelectToEnd()
bool flutter::TextInputModel::SelectToEnd |
( |
| ) |
|
Definition at line 256 of file text_input_model.cc.
256 {
257 size_t max_pos = editable_range().
end();
259 return false;
260 }
262 return true;
263}
◆ SetComposingRange()
bool flutter::TextInputModel::SetComposingRange |
( |
const TextRange & |
range, |
|
|
size_t |
cursor_offset |
|
) |
| |
Definition at line 57 of file text_input_model.cc.
58 {
60 return false;
61 }
62 composing_range_ = range;
63 selection_ =
TextRange(range.start() + cursor_offset);
64 return true;
65}
TextRange text_range() const
bool Contains(const Container &container, const Value &value)
◆ SetSelection()
bool flutter::TextInputModel::SetSelection |
( |
const TextRange & |
range | ) |
|
Definition at line 46 of file text_input_model.cc.
46 {
47 if (composing_ && !range.collapsed()) {
48 return false;
49 }
50 if (!editable_range().
Contains(range)) {
51 return false;
52 }
53 selection_ = range;
54 return true;
55}
◆ SetText()
Definition at line 31 of file text_input_model.cc.
33 {
37 return false;
38 }
39
43 return true;
44}
TextRange selection() const
TextRange composing_range() const
◆ text_range()
TextRange flutter::TextInputModel::text_range |
( |
| ) |
const |
|
inline |
◆ UpdateComposingText() [1/3]
void flutter::TextInputModel::UpdateComposingText |
( |
const std::string & |
text | ) |
|
Definition at line 90 of file text_input_model.cc.
90 {
92}
void UpdateComposingText(const std::u16string &text, const TextRange &selection)
◆ UpdateComposingText() [2/3]
void flutter::TextInputModel::UpdateComposingText |
( |
const std::u16string & |
text | ) |
|
◆ UpdateComposingText() [3/3]
void flutter::TextInputModel::UpdateComposingText |
( |
const std::u16string & |
text, |
|
|
const TextRange & |
selection |
|
) |
| |
Definition at line 72 of file text_input_model.cc.
73 {
74
76 return;
77 }
79 composing_range_.
collapsed() ? selection_ : composing_range_;
80 text_.replace(rangeToDelete.start(), rangeToDelete.length(),
text);
84}
The documentation for this class was generated from the following files: