5package io.flutter.plugin.editing;
7import io.flutter.embedding.engine.FlutterJNI;
18 this.flutterJNI = flutterJNI;
42 return 0xE0020 <= codePoint && codePoint <= 0xE007E;
46 return (
'0' <= codePoint && codePoint <=
'9') || codePoint ==
'#' || codePoint ==
'*';
62 int codePoint = Character.codePointBefore(
text,
offset);
63 int deleteCharCount = Character.charCount(codePoint);
64 int lastOffset =
offset - deleteCharCount;
66 if (lastOffset == 0) {
72 codePoint = Character.codePointBefore(
text, lastOffset);
76 return offset - deleteCharCount;
81 codePoint = Character.codePointBefore(
text, lastOffset);
82 lastOffset -= Character.charCount(codePoint);
83 int regionalIndicatorSymbolCount = 1;
85 codePoint = Character.codePointBefore(
text, lastOffset);
86 lastOffset -= Character.charCount(codePoint);
87 regionalIndicatorSymbolCount++;
89 if (regionalIndicatorSymbolCount % 2 == 0) {
92 return offset - deleteCharCount;
97 codePoint = Character.codePointBefore(
text, lastOffset);
98 lastOffset -= Character.charCount(codePoint);
100 int tmpCodePoint = Character.codePointBefore(
text, lastOffset);
102 deleteCharCount += Character.charCount(codePoint) + Character.charCount(tmpCodePoint);
105 deleteCharCount += Character.charCount(codePoint);
107 return offset - deleteCharCount;
117 codePoint = Character.codePointBefore(
text, lastOffset);
118 lastOffset -= Character.charCount(codePoint);
120 deleteCharCount += Character.charCount(codePoint);
121 codePoint = Character.codePointBefore(
text, lastOffset);
122 lastOffset -= Character.charCount(codePoint);
127 deleteCharCount += Character.charCount(codePoint);
131 codePoint = Character.codePointBefore(
text, lastOffset);
133 return offset - deleteCharCount;
135 deleteCharCount += Character.charCount(codePoint);
137 lastOffset -= deleteCharCount;
141 boolean isZwj =
false;
142 int lastSeenVariantSelectorCharCount = 0;
145 deleteCharCount += Character.charCount(codePoint) + lastSeenVariantSelectorCharCount + 1;
148 lastSeenVariantSelectorCharCount = 0;
150 codePoint = Character.codePointBefore(
text, lastOffset);
151 lastOffset -= Character.charCount(codePoint);
153 codePoint = Character.codePointBefore(
text, lastOffset);
155 return offset - deleteCharCount;
157 lastSeenVariantSelectorCharCount = Character.charCount(codePoint);
158 lastOffset -= Character.charCount(codePoint);
161 deleteCharCount += lastSeenVariantSelectorCharCount + Character.charCount(codePoint);
166 if (lastOffset > 0) {
167 codePoint = Character.codePointBefore(
text, lastOffset);
168 lastOffset -= Character.charCount(codePoint);
171 codePoint = Character.codePointBefore(
text, lastOffset);
172 lastOffset -= Character.charCount(codePoint);
174 codePoint = Character.codePointBefore(
text, lastOffset);
175 lastSeenVariantSelectorCharCount = Character.charCount(codePoint);
176 lastOffset -= Character.charCount(codePoint);
181 if (lastOffset == 0) {
184 }
while (isZwj &&
isEmoji(codePoint));
187 return offset - deleteCharCount;
204 int codePoint = Character.codePointAt(
text,
offset);
205 int nextCharCount = Character.charCount(codePoint);
206 int nextOffset =
offset + nextCharCount;
208 if (nextOffset == 0) {
214 codePoint = Character.codePointAt(
text, nextOffset);
218 return offset + nextCharCount;
223 if (nextOffset >=
len - 1
225 return offset + nextCharCount;
231 int regionalIndicatorSymbolCount = 0;
232 int regionOffset =
offset;
233 while (regionOffset > 0
235 regionOffset -= Character.charCount(Character.codePointBefore(
text,
offset));
236 regionalIndicatorSymbolCount++;
238 if (regionalIndicatorSymbolCount % 2 == 0) {
241 return offset + nextCharCount;
246 nextCharCount += Character.charCount(codePoint);
249 codePoint = Character.codePointBefore(
text, nextOffset);
250 nextOffset += Character.charCount(codePoint);
252 int tmpCodePoint = Character.codePointAt(
text, nextOffset);
254 nextCharCount += Character.charCount(codePoint) + Character.charCount(tmpCodePoint);
257 nextCharCount += Character.charCount(codePoint);
259 return offset + nextCharCount;
263 boolean isZwj =
false;
264 int lastSeenVariantSelectorCharCount = 0;
267 nextCharCount += Character.charCount(codePoint) + lastSeenVariantSelectorCharCount + 1;
270 lastSeenVariantSelectorCharCount = 0;
275 if (nextOffset <
len) {
276 codePoint = Character.codePointAt(
text, nextOffset);
277 nextOffset += Character.charCount(codePoint);
279 codePoint = Character.codePointBefore(
text, nextOffset);
280 nextOffset += Character.charCount(codePoint);
282 int tmpCodePoint = Character.codePointAt(
text, nextOffset);
284 nextCharCount += Character.charCount(codePoint) + Character.charCount(tmpCodePoint);
287 nextCharCount += Character.charCount(codePoint);
289 return offset + nextCharCount;
292 nextCharCount += lastSeenVariantSelectorCharCount + Character.charCount(codePoint);
296 nextCharCount += lastSeenVariantSelectorCharCount + Character.charCount(codePoint);
301 codePoint = Character.codePointAt(
text, nextOffset);
302 nextOffset += Character.charCount(codePoint);
304 codePoint = Character.codePointAt(
text, nextOffset);
305 lastSeenVariantSelectorCharCount = Character.charCount(codePoint);
306 nextOffset += Character.charCount(codePoint);
311 if (nextOffset >=
len) {
314 }
while (isZwj &&
isEmoji(codePoint));
317 return offset + nextCharCount;
boolean isCodePointEmojiModifier(int codePoint)
boolean isCodePointEmojiModifierBase(int codePoint)
boolean isCodePointRegionalIndicator(int codePoint)
boolean isCodePointEmoji(int codePoint)
boolean isCodePointVariantSelector(int codePoint)
boolean isRegionalIndicatorSymbol(int codePoint)
boolean isEmojiModifierBase(int codePoint)
boolean isKeycapBase(int codePoint)
boolean isEmoji(int codePoint)
static final int LINE_FEED
static final int COMBINING_ENCLOSING_KEYCAP
int getOffsetAfter(CharSequence text, int offset)
static final int CARRIAGE_RETURN
static final int CANCEL_TAG
int getOffsetBefore(CharSequence text, int offset)
boolean isVariationSelector(int codePoint)
boolean isTagSpecChar(int codePoint)
FlutterTextUtils(FlutterJNI flutterJNI)
static final int ZERO_WIDTH_JOINER
boolean isEmojiModifier(int codePoint)