aboutsummaryrefslogtreecommitdiffstats
path: root/src/textconv.c
diff options
context:
space:
mode:
authorPo Lu2023-05-06 11:32:56 +0800
committerPo Lu2023-05-06 11:32:56 +0800
commit3198b7dc565e0e41d40b6c23509c285e96044a83 (patch)
treec9193f1b8825c30fac483ed66e02eb9181397668 /src/textconv.c
parent96f9fe6514a2139373c50e19a77fd217ef62e6ef (diff)
downloademacs-3198b7dc565e0e41d40b6c23509c285e96044a83.tar.gz
emacs-3198b7dc565e0e41d40b6c23509c285e96044a83.zip
Update Android port
* cross/verbose.mk.android: Get rid of badly aligned ANDROID_CC messages. * java/org/gnu/emacs/EmacsInputConnection.java (syncAfterCommit) (extractAbsoluteOffsets): Add workarounds for several kinds of machines. (commitText, getExtractedText): Likewise. * src/textconv.c (really_commit_text): Improve definition of POSITION. (get_extracted_text): Default to providing at least 4 characters.
Diffstat (limited to 'src/textconv.c')
-rw-r--r--src/textconv.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/textconv.c b/src/textconv.c
index 4fa92f43ecd..e1a73e91397 100644
--- a/src/textconv.c
+++ b/src/textconv.c
@@ -540,7 +540,11 @@ restore_selected_window (Lisp_Object window)
540 540
541/* Commit the given text in the composing region. If there is no 541/* Commit the given text in the composing region. If there is no
542 composing region, then insert the text after F's selected window's 542 composing region, then insert the text after F's selected window's
543 last point instead. Finally, remove the composing region. */ 543 last point instead. Finally, remove the composing region.
544
545 Then, move point to POSITION relative to TEXT. If POSITION is
546 greater than zero, it is relative to the character at the end of
547 TEXT; otherwise, it is relative to the start of TEXT. */
544 548
545static void 549static void
546really_commit_text (struct frame *f, EMACS_INT position, 550really_commit_text (struct frame *f, EMACS_INT position,
@@ -577,14 +581,16 @@ really_commit_text (struct frame *f, EMACS_INT position,
577 Finsert (1, &text); 581 Finsert (1, &text);
578 record_buffer_change (start, PT, text); 582 record_buffer_change (start, PT, text);
579 583
580 /* Move to a the position specified in POSITION. */ 584 /* Move to a the position specified in POSITION. If POSITION is
585 less than zero, it is relative to the start of the text that
586 was inserted. */
581 587
582 if (position < 0) 588 if (position <= 0)
583 { 589 {
584 wanted 590 wanted
585 = marker_position (f->conversion.compose_region_start); 591 = marker_position (f->conversion.compose_region_start);
586 592
587 if (INT_SUBTRACT_WRAPV (wanted, position, &wanted) 593 if (INT_ADD_WRAPV (wanted, position, &wanted)
588 || wanted < BEGV) 594 || wanted < BEGV)
589 wanted = BEGV; 595 wanted = BEGV;
590 596
@@ -595,6 +601,9 @@ really_commit_text (struct frame *f, EMACS_INT position,
595 } 601 }
596 else 602 else
597 { 603 {
604 /* Otherwise, it is relative to the last character in
605 TEXT. */
606
598 wanted 607 wanted
599 = marker_position (f->conversion.compose_region_end); 608 = marker_position (f->conversion.compose_region_end);
600 609
@@ -631,9 +640,9 @@ really_commit_text (struct frame *f, EMACS_INT position,
631 Finsert (1, &text); 640 Finsert (1, &text);
632 record_buffer_change (wanted, PT, text); 641 record_buffer_change (wanted, PT, text);
633 642
634 if (position < 0) 643 if (position <= 0)
635 { 644 {
636 if (INT_SUBTRACT_WRAPV (wanted, position, &wanted) 645 if (INT_ADD_WRAPV (wanted, position, &wanted)
637 || wanted < BEGV) 646 || wanted < BEGV)
638 wanted = BEGV; 647 wanted = BEGV;
639 648
@@ -1533,8 +1542,9 @@ get_extracted_text (struct frame *f, ptrdiff_t n,
1533 /* Figure out the bounds of the text to return. */ 1542 /* Figure out the bounds of the text to return. */
1534 if (n != -1) 1543 if (n != -1)
1535 { 1544 {
1536 /* Make sure n is at least 2. */ 1545 /* Make sure n is at least 4, leaving two characters around
1537 n = max (2, n); 1546 PT. */
1547 n = max (4, n);
1538 1548
1539 start = PT - n / 2; 1549 start = PT - n / 2;
1540 end = PT + n - n / 2; 1550 end = PT + n - n / 2;