/* The window. */
android_window window;
+
+ /* Whether or not the mark is active. */
+ bool mark_active;
};
/* Return the extracted text in the extracted text context specified
- by DATA. */
+ by DATA. Save its flags and token into its frame's state. */
static void
android_get_extracted_text (void *data)
= get_extracted_text (f, min (request->hint_max_chars, 600),
&request->start, &request->start_offset,
&request->end_offset, &request->length,
- &request->bytes);
+ &request->bytes, &request->mark_active);
/* See if request->flags & GET_EXTRACTED_TEXT_MONITOR. If so, then
the input method has asked to monitor changes to the extracted
{
jclass class;
jmethodID constructor;
+ jfieldID flags;
jfieldID partial_start_offset;
jfieldID partial_end_offset;
jfieldID selection_start;
TEXT. START is a character position describing the offset of the
first character in TEXT. START_OFFSET is the offset of the lesser
of point or mark relative to START, and END_OFFSET is that of the
- greater of point or mark relative to START.
+ greater of point or mark relative to START. MARK_ACTIVE specifies
+ whether or not the mark is currently active.
Assume that request_class and text_class have already been
initialized.
static jobject
android_build_extracted_text (jstring text, ptrdiff_t start,
ptrdiff_t start_offset,
- ptrdiff_t end_offset)
+ ptrdiff_t end_offset, bool mark_active)
{
JNIEnv *env;
jobject object;
if (!object)
return NULL;
+ (*env)->SetIntField (env, object, text_class.flags,
+ /* ExtractedText.FLAG_SELECTING */
+ mark_active ? 2 : 0);
(*env)->SetIntField (env, object, text_class.partial_start_offset, -1);
(*env)->SetIntField (env, object, text_class.partial_end_offset, -1);
(*env)->SetIntField (env, object, text_class.selection_start,
= (*env)->NewGlobalRef (env, text_class.class);
assert (text_class.class);
+ text_class.flags
+ = (*env)->GetFieldID (env, class, "flags", "I");
text_class.partial_start_offset
= (*env)->GetFieldID (env, class, "partialStartOffset", "I");
text_class.partial_end_offset
if (!object)
return NULL;
+ (*env)->SetIntField (env, object, text_class.flags,
+ /* ExtractedText.FLAG_SELECTING */
+ context.mark_active ? 2 : 0);
(*env)->SetIntField (env, object, text_class.partial_start_offset, -1);
(*env)->SetIntField (env, object, text_class.partial_end_offset, -1);
(*env)->SetIntField (env, object, text_class.selection_start,
char *text;
jobject extracted;
jstring string;
+ bool mark_active;
if (MARKERP (f->conversion.compose_region_start))
{
token = FRAME_ANDROID_OUTPUT (f)->extracted_text_token;
text = get_extracted_text (f, min (hint, 600), &start,
&start_offset, &end_offset,
- &length, &bytes);
+ &length, &bytes, &mark_active);
if (text)
{
/* Make extracted text out of that string. */
extracted = android_build_extracted_text (string, start,
start_offset,
- end_offset);
+ end_offset,
+ mark_active);
android_exception_check_1 (string);
ANDROID_DELETE_LOCAL_REF (string);
to the position of the first character returned, *START_OFFSET to
the offset of the lesser of mark and point within that text,
*END_OFFSET to the greater of mark and point within that text, and
- *LENGTH to the actual number of characters returned, and *BYTES to
- the actual number of bytes returned.
+ *LENGTH to the actual number of characters returned, *BYTES to the
+ actual number of bytes returned, and *MARK_ACTIVE to whether or not
+ the mark is active.
Value is NULL upon failure, and a malloced string upon success. */
ptrdiff_t *start_return,
ptrdiff_t *start_offset,
ptrdiff_t *end_offset, ptrdiff_t *length,
- ptrdiff_t *bytes)
+ ptrdiff_t *bytes, bool *mark_active)
{
specpdl_ref count;
ptrdiff_t start, end, start_byte, end_byte, mark;
/* Get the mark. If it's not active, use PT. */
mark = get_mark ();
+ *mark_active = true;
if (mark == -1)
- mark = PT;
+ {
+ mark = PT;
+ *mark_active = false;
+ }
/* Return the offsets. */
*start_return = start;