Mercurial > emacs
comparison src/indent.c @ 18977:801bc19b01dc
(compute_motion): Handle display table correctly for
multibyte characters.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 25 Jul 1997 08:01:02 +0000 |
parents | 614b916ff5bf |
children | 0d238726e4c3 |
comparison
equal
deleted
inserted
replaced
18976:ebb3e71c6dfd | 18977:801bc19b01dc |
---|---|
1325 } | 1325 } |
1326 else if (multibyte && BASE_LEADING_CODE_P (c)) | 1326 else if (multibyte && BASE_LEADING_CODE_P (c)) |
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 ptr = (((pos) >= GPT ? GAP_SIZE : 0) + (pos) + BEG_ADDR - 1); |
1334 if (c == LEADING_CODE_COMPOSITION) | 1335 len = ((pos) >= GPT ? ZV : GPT) - (pos); |
1336 | |
1337 c = STRING_CHAR_AND_LENGTH (ptr, len, actual_len); | |
1338 | |
1339 if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c))) | |
1340 hpos += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size; | |
1341 else if (actual_len == 1) | |
1342 hpos += 4; | |
1343 else if (COMPOSITE_CHAR_P (c)) | |
1335 { | 1344 { |
1336 int cmpchar_id = str_cmpchar_id (ptr, next_boundary - pos); | 1345 int id = COMPOSITE_CHAR_ID (c); |
1337 | 1346 int width = (id < n_cmpchars) ? cmpchar_table[id]->width : 0; |
1338 if (cmpchar_id >= 0) | 1347 hpos += width; |
1339 { | 1348 if (width > 1) |
1340 if (cmpchar_table[cmpchar_id]->width >= 2) | 1349 wide_column = 1; |
1341 wide_column = 1; | |
1342 hpos += cmpchar_table[cmpchar_id]->width; | |
1343 pos += cmpchar_table[cmpchar_id]->len; | |
1344 } | |
1345 else | |
1346 { /* invalid composite character */ | |
1347 hpos += 4; | |
1348 pos ++; | |
1349 } | |
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; |
1369 } | 1363 } |
1370 } | 1364 } |