diff options
| author | Po Lu | 2024-04-21 21:51:09 +0800 |
|---|---|---|
| committer | Po Lu | 2024-04-29 12:34:39 +0800 |
| commit | 430088c9ccec5fe9be57d267f45acdc87aa3b28e (patch) | |
| tree | a953f845c4176e4a18a542c1e321f80ad34ab4af /src/androidterm.c | |
| parent | ee2e0031d8cc32bb7837ea97ce07ef3b25463223 (diff) | |
| download | emacs-430088c9ccec5fe9be57d267f45acdc87aa3b28e.tar.gz emacs-430088c9ccec5fe9be57d267f45acdc87aa3b28e.zip | |
Take fields into account during text conversion
* lisp/cus-edit.el (Custom-mode): Enable text conversion, now
that fields are correctly treated.
* src/alloc.c (mark_frame): Mark f->conversion.field.
* src/androidterm.c (android_update_selection): Adjust
conversion region and selection position by the field start and
end.
* src/editfns.c (find_field): Export function.
* src/frame.c (make_frame): Clear f->conversion.field.
* src/frame.h (struct text_conversion_state) <field>: New field.
* src/lisp.h (find_fields, reset_frame_conversion): Export
functions.
* src/minibuf.c (Fread_from_minibuffer): Reset frame conversion
if Voverriding_text_conversion_style is set.
* src/textconv.c (textconv_query): Narrow to field.
(reset_frame_conversion): New function.
(reset_frame_state): Clear conversion field.
(really_delete_surrounding_text): Narrow to field.
(locate_and_save_position_in_field): New function.
(really_request_point_update, really_set_point_and_mark)
(complete_edit_check, handle_pending_conversion_events_1)
(handle_pending_conversion_events, get_conversion_field)
(set_composing_region, textconv_set_point_and_mark, replace_text)
(get_extracted_text, get_surrounding_text, report_point_change):
Compute, narrow to and offset by the currently active field
whenever point is updated or a command is received.
(syms_of_textconv): Revise doc strings.
* src/textconv.h (get_conversion_field): Export function.
Diffstat (limited to 'src/androidterm.c')
| -rw-r--r-- | src/androidterm.c | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/src/androidterm.c b/src/androidterm.c index 4549941ee2e..f849f0d9919 100644 --- a/src/androidterm.c +++ b/src/androidterm.c | |||
| @@ -6265,14 +6265,24 @@ android_update_selection (struct frame *f, struct window *w) | |||
| 6265 | jobject extracted; | 6265 | jobject extracted; |
| 6266 | jstring string; | 6266 | jstring string; |
| 6267 | bool mark_active; | 6267 | bool mark_active; |
| 6268 | ptrdiff_t field_start, field_end; | ||
| 6269 | |||
| 6270 | /* Offset these values by the start offset of the field. */ | ||
| 6271 | get_conversion_field (f, &field_start, &field_end); | ||
| 6268 | 6272 | ||
| 6269 | if (MARKERP (f->conversion.compose_region_start)) | 6273 | if (MARKERP (f->conversion.compose_region_start)) |
| 6270 | { | 6274 | { |
| 6271 | eassert (MARKERP (f->conversion.compose_region_end)); | 6275 | eassert (MARKERP (f->conversion.compose_region_end)); |
| 6272 | 6276 | ||
| 6273 | /* Indexing in android starts from 0 instead of 1. */ | 6277 | /* Indexing in android starts from 0 instead of 1. */ |
| 6274 | start = marker_position (f->conversion.compose_region_start) - 1; | 6278 | start = marker_position (f->conversion.compose_region_start); |
| 6275 | end = marker_position (f->conversion.compose_region_end) - 1; | 6279 | end = marker_position (f->conversion.compose_region_end); |
| 6280 | |||
| 6281 | /* Offset and detect underflow. */ | ||
| 6282 | start = max (start, field_start) - field_start - 1; | ||
| 6283 | end = min (end, field_end) - field_start - 1; | ||
| 6284 | if (end < 0 || start < 0) | ||
| 6285 | end = start = -1; | ||
| 6276 | } | 6286 | } |
| 6277 | else | 6287 | else |
| 6278 | start = -1, end = -1; | 6288 | start = -1, end = -1; |
| @@ -6288,24 +6298,27 @@ android_update_selection (struct frame *f, struct window *w) | |||
| 6288 | /* Figure out where the point and mark are. If the mark is not | 6298 | /* Figure out where the point and mark are. If the mark is not |
| 6289 | active, then point is set to equal mark. */ | 6299 | active, then point is set to equal mark. */ |
| 6290 | b = XBUFFER (w->contents); | 6300 | b = XBUFFER (w->contents); |
| 6291 | point = min (w->ephemeral_last_point, | 6301 | point = min (min (max (w->ephemeral_last_point, |
| 6302 | field_start), | ||
| 6303 | field_end) - field_start, | ||
| 6292 | TYPE_MAXIMUM (jint)); | 6304 | TYPE_MAXIMUM (jint)); |
| 6293 | mark = ((!NILP (BVAR (b, mark_active)) | 6305 | mark = ((!NILP (BVAR (b, mark_active)) |
| 6294 | && w->last_mark != -1) | 6306 | && w->last_mark != -1) |
| 6295 | ? min (w->last_mark, TYPE_MAXIMUM (jint)) | 6307 | ? min (min (max (w->last_mark, field_start), |
| 6308 | field_end) - field_start, | ||
| 6309 | TYPE_MAXIMUM (jint)) | ||
| 6296 | : point); | 6310 | : point); |
| 6297 | 6311 | ||
| 6298 | /* Send the update. Android doesn't employ a concept of ``point'' | 6312 | /* Send the update. Android doesn't employ a concept of "point" and |
| 6299 | and ``mark''; instead, it only has a selection, where the start | 6313 | "mark"; instead, it only has a selection, where the start of the |
| 6300 | of the selection is less than or equal to the end, and the region | 6314 | selection is less than or equal to the end, and the region is |
| 6301 | is ``active'' when those two values differ. Also, convert the | 6315 | "active" when those two values differ. The indices will have been |
| 6302 | indices from 1-based Emacs indices to 0-based Android ones. */ | 6316 | converted from 1-based Emacs indices to 0-based Android ones. */ |
| 6303 | android_update_ic (FRAME_ANDROID_WINDOW (f), min (point, mark) - 1, | 6317 | android_update_ic (FRAME_ANDROID_WINDOW (f), min (point, mark), |
| 6304 | max (point, mark) - 1, start, end); | 6318 | max (point, mark), start, end); |
| 6305 | 6319 | ||
| 6306 | /* Update the extracted text as well, if the input method has asked | 6320 | /* Update the extracted text as well, if the input method has asked |
| 6307 | for updates. 1 is | 6321 | for updates. 1 is InputConnection.GET_EXTRACTED_TEXT_MONITOR. */ |
| 6308 | InputConnection.GET_EXTRACTED_TEXT_MONITOR. */ | ||
| 6309 | 6322 | ||
| 6310 | if (FRAME_ANDROID_OUTPUT (f)->extracted_text_flags & 1) | 6323 | if (FRAME_ANDROID_OUTPUT (f)->extracted_text_flags & 1) |
| 6311 | { | 6324 | { |