aboutsummaryrefslogtreecommitdiffstats
path: root/src/textconv.c
diff options
context:
space:
mode:
authorPo Lu2023-03-12 17:07:57 +0800
committerPo Lu2023-03-12 17:07:57 +0800
commit82b4b9e8692c349a45d319fe05c9fbfed4ab203d (patch)
tree5fe33349f7992327f23d124c19b6d9e5ebb8f023 /src/textconv.c
parent3573db24ad0125d1a553e85eb08c93c61c62ef33 (diff)
downloademacs-82b4b9e8692c349a45d319fe05c9fbfed4ab203d.tar.gz
emacs-82b4b9e8692c349a45d319fe05c9fbfed4ab203d.zip
Update Android port
* src/androidterm.c (NATIVE_NAME, JNICALL) (android_build_extracted_text, android_update_selection): Use 0-based indices for Android buffer positions. Also, report surrounding text relative to the region, not to the cursor. * src/textconv.c (textconv_query): Accept new values of position. (really_set_composing_text): Use ephemeral last point.
Diffstat (limited to 'src/textconv.c')
-rw-r--r--src/textconv.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/textconv.c b/src/textconv.c
index 3206bb48204..900277016f2 100644
--- a/src/textconv.c
+++ b/src/textconv.c
@@ -137,6 +137,10 @@ select_window (Lisp_Object window, Lisp_Object norecord)
137 window and QUERY->factor times QUERY->direction from that 137 window and QUERY->factor times QUERY->direction from that
138 position. Return it in QUERY->text. 138 position. Return it in QUERY->text.
139 139
140 If QUERY->position is TYPE_MINIMUM (EMACS_INT) or EMACS_INT_MAX,
141 start at the window's last point or mark, whichever is greater or
142 smaller.
143
140 Then, either delete that text from the buffer if QUERY->operation 144 Then, either delete that text from the buffer if QUERY->operation
141 is TEXTCONV_SUBSTITUTION, or return 0. 145 is TEXTCONV_SUBSTITUTION, or return 0.
142 146
@@ -155,8 +159,9 @@ textconv_query (struct frame *f, struct textconv_callback_struct *query,
155{ 159{
156 specpdl_ref count; 160 specpdl_ref count;
157 ptrdiff_t pos, pos_byte, end, end_byte, start; 161 ptrdiff_t pos, pos_byte, end, end_byte, start;
158 ptrdiff_t temp, temp1; 162 ptrdiff_t temp, temp1, mark;
159 char *buffer; 163 char *buffer;
164 struct window *w;
160 165
161 /* Save the excursion, as there will be extensive changes to the 166 /* Save the excursion, as there will be extensive changes to the
162 selected window. */ 167 selected window. */
@@ -171,12 +176,35 @@ textconv_query (struct frame *f, struct textconv_callback_struct *query,
171 select_window ((WINDOW_LIVE_P (f->old_selected_window) 176 select_window ((WINDOW_LIVE_P (f->old_selected_window)
172 ? f->old_selected_window 177 ? f->old_selected_window
173 : f->selected_window), Qt); 178 : f->selected_window), Qt);
179 w = XWINDOW (selected_window);
174 180
175 /* Now find the appropriate text bounds for QUERY. First, move 181 /* Now find the appropriate text bounds for QUERY. First, move
176 point QUERY->position steps forward or backwards. */ 182 point QUERY->position steps forward or backwards. */
177 183
178 pos = PT; 184 pos = PT;
179 185
186 /* If QUERY->position is EMACS_INT_MAX, use the last mark or the
187 ephemeral last point, whichever is greater.
188
189 The opposite applies for EMACS_INT_MIN. */
190
191 mark = get_mark ();
192
193 if (query->position == EMACS_INT_MAX)
194 {
195 pos = (mark == -1
196 ? w->ephemeral_last_point
197 : max (w->ephemeral_last_point, mark));
198 goto escape1;
199 }
200 else if (query->position == TYPE_MINIMUM (EMACS_INT))
201 {
202 pos = (mark == -1
203 ? w->ephemeral_last_point
204 : min (w->ephemeral_last_point, mark));
205 goto escape1;
206 }
207
180 /* Next, if POS lies within the conversion region and the caller 208 /* Next, if POS lies within the conversion region and the caller
181 asked for it to be moved away, move it away from the conversion 209 asked for it to be moved away, move it away from the conversion
182 region. */ 210 region. */
@@ -210,7 +238,7 @@ textconv_query (struct frame *f, struct textconv_callback_struct *query,
210 238
211 if (flags & TEXTCONV_SKIP_ACTIVE_REGION) 239 if (flags & TEXTCONV_SKIP_ACTIVE_REGION)
212 { 240 {
213 temp = get_mark (); 241 temp = mark;
214 242
215 if (temp == -1) 243 if (temp == -1)
216 goto escape; 244 goto escape;
@@ -246,6 +274,8 @@ textconv_query (struct frame *f, struct textconv_callback_struct *query,
246 if (INT_ADD_WRAPV (pos, query->position, &pos)) 274 if (INT_ADD_WRAPV (pos, query->position, &pos))
247 pos = PT; 275 pos = PT;
248 276
277 escape1:
278
249 if (pos < BEGV) 279 if (pos < BEGV)
250 pos = BEGV; 280 pos = BEGV;
251 281
@@ -792,7 +822,7 @@ really_set_composing_text (struct frame *f, ptrdiff_t position,
792 /* If PT hasn't changed, the conversion region definitely has. 822 /* If PT hasn't changed, the conversion region definitely has.
793 Otherwise, redisplay will update the input method instead. */ 823 Otherwise, redisplay will update the input method instead. */
794 824
795 if (PT == w->last_point 825 if (PT == w->ephemeral_last_point
796 && text_interface 826 && text_interface
797 && text_interface->compose_region_changed) 827 && text_interface->compose_region_changed)
798 { 828 {