GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing api.flutter.dev — Flutter Linux Embedder: flutter::TextInputModel Class Reference
flutter::TextInputModel Class Reference
Detailed DescriptionDefinition at line 18 of file text_input_model.h. Constructor & Destructor Documentation◆ TextInputModel()
◆ ~TextInputModel()
Member Function Documentation◆ AddCodePoint()
Definition at line 136 of file text_input_model.cc. 136 {
137 if (c <= 0xFFFF) {
139 } else {
140 char32_t to_decompose = c - 0x10000;
141 AddText(std::u16string({
142 // High surrogate.
143 static_cast<char16_t>((to_decompose >> 10) + 0xd800),
144 // Low surrogate.
145 static_cast<char16_t>((to_decompose % 0x400) + 0xdc00),
146 }));
147 }
148 }
void AddText(const std::u16string &text) Definition: text_input_model.cc:150 References AddText(). ◆ AddText() [1/2]
Definition at line 163 of file text_input_model.cc. References AddText(). ◆ AddText() [2/2]
Definition at line 150 of file text_input_model.cc. 150 {
151 DeleteSelected();
152 if (composing_) {
153 // Delete the current composing text, set the cursor to composing start.
155 selection_ = TextRange(composing_range_.start());
157 }
159 text_.insert(position, text);
160 selection_ = TextRange(position + text.length());
161 }
References flutter::TextRange::length(), flutter::TextRange::position(), flutter::TextRange::set_end(), and flutter::TextRange::start(). Referenced by AddCodePoint(), and AddText(). ◆ Backspace()
Definition at line 167 of file text_input_model.cc. 167 {
168 if (DeleteSelected()) {
169 return true;
170 }
171 // There is no selection. Delete the preceding codepoint.
174 int count = IsTrailingSurrogate(text_.at(position - 1)) ? 2 : 1;
175 text_.erase(position - count, count);
176 selection_ = TextRange(position - count);
177 if (composing_) {
179 }
180 return true;
181 }
182 return false;
183 }
References flutter::TextRange::end(), flutter::TextRange::position(), flutter::TextRange::set_end(), and start. ◆ BeginComposing()
Definition at line 72 of file text_input_model.cc. References flutter::TextRange::start(). ◆ CommitComposing()
Definition at line 108 of file text_input_model.cc. 108 {
109 // Preserve selection if no composing text was entered.
111 return;
112 }
113 composing_range_ = TextRange(composing_range_.end());
114 selection_ = composing_range_;
115 }
References flutter::TextRange::collapsed(), and flutter::TextRange::end(). ◆ composing()
Definition at line 214 of file text_input_model.h. 214 { return composing_; }
◆ composing_range()
Definition at line 211 of file text_input_model.h. 211 { return composing_range_; }
Referenced by SetText(). ◆ Delete()
Definition at line 185 of file text_input_model.cc. 185 {
186 if (DeleteSelected()) {
187 return true;
188 }
189 // There is no selection. Delete the preceding codepoint.
192 int count = IsLeadingSurrogate(text_.at(position)) ? 2 : 1;
193 text_.erase(position, count);
194 if (composing_) {
196 }
197 return true;
198 }
199 return false;
200 }
References flutter::TextRange::end(), end, flutter::TextRange::position(), and flutter::TextRange::set_end(). ◆ DeleteSurrounding()
Definition at line 202 of file text_input_model.cc. 202 {
205 if (offset_from_cursor < 0) {
207 // If the requested start is at or before the beginning of the
208 // available text then reduce the number of characters to delete. A step
209 // of 2 (crossing a surrogate pair) can land before the start of the
210 // range rather than exactly on it.
212 count = i;
213 break;
214 }
216 }
217 } else {
220 }
221 }
222
226 }
227
229 return false;
230 }
231
233 text_.erase(start, deleted_length);
234
235 // Cursor moves only if deleted area is before it.
237
238 // Adjust composing range: a bound inside the deleted span collapses to its
239 // start, a bound after it shifts back by the deleted length, and a bound
240 // before it is unaffected. The deleted span can extend past the composing
241 // range's stored bounds when a surrogate pair straddles them, so shifting
242 // the end unconditionally could underflow, and the start needs the same
243 // treatment when the span extends past it in the other direction.
244 if (composing_) {
247 return pos;
248 }
250 return pos - deleted_length;
251 }
253 };
256 }
257 return true;
258 }
References flutter::TextRange::base(), flutter::TextRange::end(), end, flutter::TextRange::extent(), i, flutter::TextRange::set_base(), flutter::TextRange::set_extent(), flutter::TextRange::start(), and start. ◆ EndComposing()
Definition at line 117 of file text_input_model.cc. 117 {
118 composing_ = false;
119 composing_range_ = TextRange(0);
120 }
◆ GetCursorOffset()
Definition at line 332 of file text_input_model.cc. 332 {
333 // Measure the length of the current text up to the selection extent.
334 // There is probably a much more efficient way of doing this.
336 return fml::Utf16ToUtf8(leading_text).size();
337 }
References flutter::TextRange::extent(). ◆ GetText()
Definition at line 328 of file text_input_model.cc. 328 {
329 return fml::Utf16ToUtf8(text_);
330 }
◆ MoveCursorBack()
Definition at line 312 of file text_input_model.cc. 312 {
313 // If there's a selection, move to the beginning of the selection.
315 selection_ = TextRange(selection_.start());
316 return true;
317 }
318 // Otherwise, move the cursor backward.
321 int count = IsTrailingSurrogate(text_.at(position - 1)) ? 2 : 1;
322 selection_ = TextRange(position - count);
323 return true;
324 }
325 return false;
326 }
References flutter::TextRange::collapsed(), flutter::TextRange::position(), flutter::TextRange::start(), and start. ◆ MoveCursorForward()
Definition at line 296 of file text_input_model.cc. 296 {
297 // If there's a selection, move to the end of the selection.
299 selection_ = TextRange(selection_.end());
300 return true;
301 }
302 // Otherwise, move the cursor forward.
305 int count = IsLeadingSurrogate(text_.at(position)) ? 2 : 1;
306 selection_ = TextRange(position + count);
307 return true;
308 }
309 return false;
310 }
References flutter::TextRange::collapsed(), flutter::TextRange::end(), end, and flutter::TextRange::position(). ◆ MoveCursorToBeginning()
Definition at line 260 of file text_input_model.cc. 260 {
263 return false;
264 }
265 selection_ = TextRange(min_pos);
266 return true;
267 }
References flutter::TextRange::collapsed(), flutter::TextRange::position(), and flutter::TextRange::start(). ◆ MoveCursorToEnd()
Definition at line 269 of file text_input_model.cc. 269 {
272 return false;
273 }
274 selection_ = TextRange(max_pos);
275 return true;
276 }
References flutter::TextRange::collapsed(), flutter::TextRange::end(), and flutter::TextRange::position(). ◆ selection()
Definition at line 206 of file text_input_model.h. 206 { return selection_; }
Referenced by SetText(), and UpdateComposingText(). ◆ SelectToBeginning()
Definition at line 278 of file text_input_model.cc. 278 {
281 return false;
282 }
283 selection_ = TextRange(selection_.base(), min_pos);
284 return true;
285 }
References flutter::TextRange::base(), flutter::TextRange::collapsed(), flutter::TextRange::position(), and flutter::TextRange::start(). ◆ SelectToEnd()
Definition at line 287 of file text_input_model.cc. 287 {
290 return false;
291 }
292 selection_ = TextRange(selection_.base(), max_pos);
293 return true;
294 }
References flutter::TextRange::base(), flutter::TextRange::collapsed(), flutter::TextRange::end(), and flutter::TextRange::position(). ◆ SetComposingRange()
Definition at line 61 of file text_input_model.cc. 62 {
64 cursor_offset > text_.length() - range.start()) {
65 return false;
66 }
67 composing_range_ = range;
68 selection_ = TextRange(range.start() + cursor_offset);
69 return true;
70 }
References flutter::TextRange::start(), and text_range(). ◆ SetSelection()
Definition at line 50 of file text_input_model.cc. 50 {
51 if (composing_ && !range.collapsed()) {
52 return false;
53 }
54 if (!editable_range().Contains(range)) {
55 return false;
56 }
57 selection_ = range;
58 return true;
59 }
References flutter::TextRange::collapsed(). ◆ SetText()
Definition at line 33 of file text_input_model.cc. 35 {
36 std::u16string new_text = fml::Utf8ToUtf16(text);
37 const TextRange new_text_range(0, new_text.length());
39 !new_text_range.Contains(composing_range)) {
40 return false;
41 }
42
43 text_ = std::move(new_text);
44 selection_ = selection;
45 composing_range_ = composing_range;
47 return true;
48 }
TextRange composing_range() const Definition: text_input_model.h:211 References flutter::TextRange::collapsed(), composing_range(), flutter::TextRange::Contains(), and selection(). ◆ text_range()
Definition at line 203 of file text_input_model.h. 203 { return TextRange(0, text_.length()); }
Referenced by SetComposingRange(), and UpdateComposingText(). ◆ UpdateComposingText() [1/3]
Definition at line 104 of file text_input_model.cc. 104 {
105 UpdateComposingText(fml::Utf8ToUtf16(text));
106 }
void UpdateComposingText(const std::u16string &text, const TextRange &selection) Definition: text_input_model.cc:77 References UpdateComposingText(). ◆ UpdateComposingText() [2/3]
Definition at line 100 of file text_input_model.cc. References UpdateComposingText(). ◆ UpdateComposingText() [3/3]
Definition at line 77 of file text_input_model.cc. 78 {
79 // Re-clamp current selection and composing range to text.
80 FML_DCHECK(text_range().Contains(selection_) &&
81 text_range().Contains(composing_range_));
82 selection_ = selection_.ClampedTo(text_.length());
83 composing_range_ = composing_range_.ClampedTo(text_.length());
84
85 // Preserve selection if we get a no-op update to the composing region.
87 return;
88 }
89 const TextRange& rangeToDelete =
90 composing_range_.collapsed() ? selection_ : composing_range_;
91 text_.replace(rangeToDelete.start(), rangeToDelete.length(), text);
93
94 // Updated |selection| is supplied by the IME. Clamp to text length.
96 selection_ = TextRange(clamped_selection.start() + composing_range_.start(),
97 clamped_selection.extent() + composing_range_.start());
98 }
References flutter::TextRange::ClampedTo(), flutter::TextRange::collapsed(), flutter::TextRange::extent(), flutter::TextRange::length(), selection(), flutter::TextRange::set_end(), flutter::TextRange::start(), and text_range(). Referenced by UpdateComposingText(). The documentation for this class was generated from the following files:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||