aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa1997-07-25 08:01:02 +0000
committerKenichi Handa1997-07-25 08:01:02 +0000
commit0f706daceed7a4bcb7c8fd3fc88be799b42d7caa (patch)
tree7ef000b1044718f677fba664a71672071c896b9e
parente3ee2a8a9add5dde63cd451cfb9f68762dedc340 (diff)
downloademacs-0f706daceed7a4bcb7c8fd3fc88be799b42d7caa.tar.gz
emacs-0f706daceed7a4bcb7c8fd3fc88be799b42d7caa.zip
(compute_motion): Handle display table correctly for
multibyte characters.
-rw-r--r--src/indent.c50
1 files changed, 22 insertions, 28 deletions
diff --git a/src/indent.c b/src/indent.c
index ab82f8212b4..6f2738b4165 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -1327,42 +1327,36 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width,
1327 { 1327 {
1328 /* Start of multi-byte form. */ 1328 /* Start of multi-byte form. */
1329 unsigned char *ptr; 1329 unsigned char *ptr;
1330 int len, actual_len;
1330 1331
1331 pos--; /* rewind POS */ 1332 pos--; /* rewind POS */
1332 ptr = POS_ADDR (pos);
1333 1333
1334 if (c == LEADING_CODE_COMPOSITION) 1334 ptr = (((pos) >= GPT ? GAP_SIZE : 0) + (pos) + BEG_ADDR - 1);
1335 { 1335 len = ((pos) >= GPT ? ZV : GPT) - (pos);
1336 int cmpchar_id = str_cmpchar_id (ptr, next_boundary - pos);
1337 1336
1338 if (cmpchar_id >= 0) 1337 c = STRING_CHAR_AND_LENGTH (ptr, len, actual_len);
1339 { 1338
1340 if (cmpchar_table[cmpchar_id]->width >= 2) 1339 if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c)))
1341 wide_column = 1; 1340 hpos += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size;
1342 hpos += cmpchar_table[cmpchar_id]->width; 1341 else if (actual_len == 1)
1343 pos += cmpchar_table[cmpchar_id]->len; 1342 hpos += 4;
1344 } 1343 else if (COMPOSITE_CHAR_P (c))
1345 else 1344 {
1346 { /* invalid composite character */ 1345 int id = COMPOSITE_CHAR_ID (c);
1347 hpos += 4; 1346 int width = (id < n_cmpchars) ? cmpchar_table[id]->width : 0;
1348 pos ++; 1347 hpos += width;
1349 } 1348 if (width > 1)
1349 wide_column = 1;
1350 } 1350 }
1351 else 1351 else
1352 { 1352 {
1353 /* Here, we check that the following bytes are valid 1353 int width = WIDTH_BY_CHAR_HEAD (*ptr);
1354 constituents of multi-byte form. */ 1354 hpos += width;
1355 int len = BYTES_BY_CHAR_HEAD (c), i; 1355 if (width > 1)
1356 1356 wide_column = 1;
1357 for (i = 1, ptr++; i < len; i++, ptr++)
1358 /* We don't need range checking for PTR because
1359 there are anchors ('\0') both at GPT and Z. */
1360 if (CHAR_HEAD_P (ptr)) break;
1361 if (i < len)
1362 hpos += 4, pos++;
1363 else
1364 hpos += WIDTH_BY_CHAR_HEAD (c), pos += i, wide_column = 1;
1365 } 1357 }
1358
1359 pos += actual_len;
1366 } 1360 }
1367 else 1361 else
1368 hpos += (ctl_arrow && c < 0200) ? 2 : 4; 1362 hpos += (ctl_arrow && c < 0200) ? 2 : 4;