diff options
| author | Po Lu | 2023-06-03 10:16:30 +0800 |
|---|---|---|
| committer | Po Lu | 2023-06-03 10:16:30 +0800 |
| commit | a696ed5c30fb9a7ba2d37f0e691de17872fdab16 (patch) | |
| tree | 392331d300e02b43e5098b9b4a56f008780efdfd /src/androidterm.c | |
| parent | d84cbcb8ce970d8a54e164a5ef6f0074c0e59f91 (diff) | |
| download | emacs-a696ed5c30fb9a7ba2d37f0e691de17872fdab16.tar.gz emacs-a696ed5c30fb9a7ba2d37f0e691de17872fdab16.zip | |
Update Android port
* src/androidterm.c (struct android_get_extracted_text_context):
New field `mark_active'.
(android_get_extracted_text): Set that field.
(struct android_extracted_text_class): New field `flags'.
(android_build_extracted_text): New argument `mark_active'. Set
flags appropriately.
(NATIVE_NAME, android_update_selection): Likewise.
* src/textconv.c (get_extracted_text): New argument
`mark_active'. Set it if the mark is active.
* src/textconv.h: Update prototypes.
Diffstat (limited to 'src/androidterm.c')
| -rw-r--r-- | src/androidterm.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/androidterm.c b/src/androidterm.c index 211faabf5c2..2894a58e6b9 100644 --- a/src/androidterm.c +++ b/src/androidterm.c | |||
| @@ -5274,10 +5274,13 @@ struct android_get_extracted_text_context | |||
| 5274 | 5274 | ||
| 5275 | /* The window. */ | 5275 | /* The window. */ |
| 5276 | android_window window; | 5276 | android_window window; |
| 5277 | |||
| 5278 | /* Whether or not the mark is active. */ | ||
| 5279 | bool mark_active; | ||
| 5277 | }; | 5280 | }; |
| 5278 | 5281 | ||
| 5279 | /* Return the extracted text in the extracted text context specified | 5282 | /* Return the extracted text in the extracted text context specified |
| 5280 | by DATA. */ | 5283 | by DATA. Save its flags and token into its frame's state. */ |
| 5281 | 5284 | ||
| 5282 | static void | 5285 | static void |
| 5283 | android_get_extracted_text (void *data) | 5286 | android_get_extracted_text (void *data) |
| @@ -5298,7 +5301,7 @@ android_get_extracted_text (void *data) | |||
| 5298 | = get_extracted_text (f, min (request->hint_max_chars, 600), | 5301 | = get_extracted_text (f, min (request->hint_max_chars, 600), |
| 5299 | &request->start, &request->start_offset, | 5302 | &request->start, &request->start_offset, |
| 5300 | &request->end_offset, &request->length, | 5303 | &request->end_offset, &request->length, |
| 5301 | &request->bytes); | 5304 | &request->bytes, &request->mark_active); |
| 5302 | 5305 | ||
| 5303 | /* See if request->flags & GET_EXTRACTED_TEXT_MONITOR. If so, then | 5306 | /* See if request->flags & GET_EXTRACTED_TEXT_MONITOR. If so, then |
| 5304 | the input method has asked to monitor changes to the extracted | 5307 | the input method has asked to monitor changes to the extracted |
| @@ -5326,6 +5329,7 @@ struct android_extracted_text_class | |||
| 5326 | { | 5329 | { |
| 5327 | jclass class; | 5330 | jclass class; |
| 5328 | jmethodID constructor; | 5331 | jmethodID constructor; |
| 5332 | jfieldID flags; | ||
| 5329 | jfieldID partial_start_offset; | 5333 | jfieldID partial_start_offset; |
| 5330 | jfieldID partial_end_offset; | 5334 | jfieldID partial_end_offset; |
| 5331 | jfieldID selection_start; | 5335 | jfieldID selection_start; |
| @@ -5345,7 +5349,8 @@ struct android_extracted_text_class text_class; | |||
| 5345 | TEXT. START is a character position describing the offset of the | 5349 | TEXT. START is a character position describing the offset of the |
| 5346 | first character in TEXT. START_OFFSET is the offset of the lesser | 5350 | first character in TEXT. START_OFFSET is the offset of the lesser |
| 5347 | of point or mark relative to START, and END_OFFSET is that of the | 5351 | of point or mark relative to START, and END_OFFSET is that of the |
| 5348 | greater of point or mark relative to START. | 5352 | greater of point or mark relative to START. MARK_ACTIVE specifies |
| 5353 | whether or not the mark is currently active. | ||
| 5349 | 5354 | ||
| 5350 | Assume that request_class and text_class have already been | 5355 | Assume that request_class and text_class have already been |
| 5351 | initialized. | 5356 | initialized. |
| @@ -5356,7 +5361,7 @@ struct android_extracted_text_class text_class; | |||
| 5356 | static jobject | 5361 | static jobject |
| 5357 | android_build_extracted_text (jstring text, ptrdiff_t start, | 5362 | android_build_extracted_text (jstring text, ptrdiff_t start, |
| 5358 | ptrdiff_t start_offset, | 5363 | ptrdiff_t start_offset, |
| 5359 | ptrdiff_t end_offset) | 5364 | ptrdiff_t end_offset, bool mark_active) |
| 5360 | { | 5365 | { |
| 5361 | JNIEnv *env; | 5366 | JNIEnv *env; |
| 5362 | jobject object; | 5367 | jobject object; |
| @@ -5373,6 +5378,9 @@ android_build_extracted_text (jstring text, ptrdiff_t start, | |||
| 5373 | if (!object) | 5378 | if (!object) |
| 5374 | return NULL; | 5379 | return NULL; |
| 5375 | 5380 | ||
| 5381 | (*env)->SetIntField (env, object, text_class.flags, | ||
| 5382 | /* ExtractedText.FLAG_SELECTING */ | ||
| 5383 | mark_active ? 2 : 0); | ||
| 5376 | (*env)->SetIntField (env, object, text_class.partial_start_offset, -1); | 5384 | (*env)->SetIntField (env, object, text_class.partial_start_offset, -1); |
| 5377 | (*env)->SetIntField (env, object, text_class.partial_end_offset, -1); | 5385 | (*env)->SetIntField (env, object, text_class.partial_end_offset, -1); |
| 5378 | (*env)->SetIntField (env, object, text_class.selection_start, | 5386 | (*env)->SetIntField (env, object, text_class.selection_start, |
| @@ -5432,6 +5440,8 @@ NATIVE_NAME (getExtractedText) (JNIEnv *env, jobject ignored_object, | |||
| 5432 | = (*env)->NewGlobalRef (env, text_class.class); | 5440 | = (*env)->NewGlobalRef (env, text_class.class); |
| 5433 | assert (text_class.class); | 5441 | assert (text_class.class); |
| 5434 | 5442 | ||
| 5443 | text_class.flags | ||
| 5444 | = (*env)->GetFieldID (env, class, "flags", "I"); | ||
| 5435 | text_class.partial_start_offset | 5445 | text_class.partial_start_offset |
| 5436 | = (*env)->GetFieldID (env, class, "partialStartOffset", "I"); | 5446 | = (*env)->GetFieldID (env, class, "partialStartOffset", "I"); |
| 5437 | text_class.partial_end_offset | 5447 | text_class.partial_end_offset |
| @@ -5478,6 +5488,9 @@ NATIVE_NAME (getExtractedText) (JNIEnv *env, jobject ignored_object, | |||
| 5478 | if (!object) | 5488 | if (!object) |
| 5479 | return NULL; | 5489 | return NULL; |
| 5480 | 5490 | ||
| 5491 | (*env)->SetIntField (env, object, text_class.flags, | ||
| 5492 | /* ExtractedText.FLAG_SELECTING */ | ||
| 5493 | context.mark_active ? 2 : 0); | ||
| 5481 | (*env)->SetIntField (env, object, text_class.partial_start_offset, -1); | 5494 | (*env)->SetIntField (env, object, text_class.partial_start_offset, -1); |
| 5482 | (*env)->SetIntField (env, object, text_class.partial_end_offset, -1); | 5495 | (*env)->SetIntField (env, object, text_class.partial_end_offset, -1); |
| 5483 | (*env)->SetIntField (env, object, text_class.selection_start, | 5496 | (*env)->SetIntField (env, object, text_class.selection_start, |
| @@ -5591,6 +5604,7 @@ android_update_selection (struct frame *f, struct window *w) | |||
| 5591 | char *text; | 5604 | char *text; |
| 5592 | jobject extracted; | 5605 | jobject extracted; |
| 5593 | jstring string; | 5606 | jstring string; |
| 5607 | bool mark_active; | ||
| 5594 | 5608 | ||
| 5595 | if (MARKERP (f->conversion.compose_region_start)) | 5609 | if (MARKERP (f->conversion.compose_region_start)) |
| 5596 | { | 5610 | { |
| @@ -5639,7 +5653,7 @@ android_update_selection (struct frame *f, struct window *w) | |||
| 5639 | token = FRAME_ANDROID_OUTPUT (f)->extracted_text_token; | 5653 | token = FRAME_ANDROID_OUTPUT (f)->extracted_text_token; |
| 5640 | text = get_extracted_text (f, min (hint, 600), &start, | 5654 | text = get_extracted_text (f, min (hint, 600), &start, |
| 5641 | &start_offset, &end_offset, | 5655 | &start_offset, &end_offset, |
| 5642 | &length, &bytes); | 5656 | &length, &bytes, &mark_active); |
| 5643 | 5657 | ||
| 5644 | if (text) | 5658 | if (text) |
| 5645 | { | 5659 | { |
| @@ -5652,7 +5666,8 @@ android_update_selection (struct frame *f, struct window *w) | |||
| 5652 | /* Make extracted text out of that string. */ | 5666 | /* Make extracted text out of that string. */ |
| 5653 | extracted = android_build_extracted_text (string, start, | 5667 | extracted = android_build_extracted_text (string, start, |
| 5654 | start_offset, | 5668 | start_offset, |
| 5655 | end_offset); | 5669 | end_offset, |
| 5670 | mark_active); | ||
| 5656 | android_exception_check_1 (string); | 5671 | android_exception_check_1 (string); |
| 5657 | ANDROID_DELETE_LOCAL_REF (string); | 5672 | ANDROID_DELETE_LOCAL_REF (string); |
| 5658 | 5673 | ||