diff options
| author | Karl Heuer | 1998-04-13 18:58:10 +0000 |
|---|---|---|
| committer | Karl Heuer | 1998-04-13 18:58:10 +0000 |
| commit | 4ad8bb205e89d91ca2703641bfc602499ac6678c (patch) | |
| tree | e1675830c6b7ca4d3e9146fd8a55cd84f9e08b5d /src | |
| parent | 22ad9937f56f2a4e6cef7ec64c815e9481e69201 (diff) | |
| download | emacs-4ad8bb205e89d91ca2703641bfc602499ac6678c.tar.gz emacs-4ad8bb205e89d91ca2703641bfc602499ac6678c.zip | |
(strout): Convert old echo area to multibyte, like printchar.
(printchar, strout): If echo area text converted to multibyte
does not all fit, truncate it at char boundary.
Diffstat (limited to 'src')
| -rw-r--r-- | src/print.c | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/src/print.c b/src/print.c index dc6272d2f82..8bfefe0508c 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -398,11 +398,15 @@ printchar (ch, fun) | |||
| 398 | 0, 1); | 398 | 0, 1); |
| 399 | printbufidx = size; | 399 | printbufidx = size; |
| 400 | if (printbufidx > FRAME_MESSAGE_BUF_SIZE (mini_frame)) | 400 | if (printbufidx > FRAME_MESSAGE_BUF_SIZE (mini_frame)) |
| 401 | printbufidx = FRAME_MESSAGE_BUF_SIZE (mini_frame); | 401 | { |
| 402 | printbufidx = FRAME_MESSAGE_BUF_SIZE (mini_frame); | ||
| 403 | /* Rewind incomplete multi-byte form. */ | ||
| 404 | while (printbufidx > 0 && tembuf[printbufidx] >= 0xA0) | ||
| 405 | printbufidx--; | ||
| 406 | } | ||
| 402 | bcopy (tembuf, FRAME_MESSAGE_BUF (mini_frame), printbufidx); | 407 | bcopy (tembuf, FRAME_MESSAGE_BUF (mini_frame), printbufidx); |
| 408 | message_enable_multibyte = 1; | ||
| 403 | } | 409 | } |
| 404 | message_enable_multibyte | ||
| 405 | = ! NILP (current_buffer->enable_multibyte_characters); | ||
| 406 | 410 | ||
| 407 | if (printbufidx < FRAME_MESSAGE_BUF_SIZE (mini_frame) - len) | 411 | if (printbufidx < FRAME_MESSAGE_BUF_SIZE (mini_frame) - len) |
| 408 | bcopy (str, &FRAME_MESSAGE_BUF (mini_frame)[printbufidx], len), | 412 | bcopy (str, &FRAME_MESSAGE_BUF (mini_frame)[printbufidx], len), |
| @@ -489,16 +493,44 @@ strout (ptr, size, size_byte, printcharfun, multibyte) | |||
| 489 | } | 493 | } |
| 490 | 494 | ||
| 491 | message_dolog (ptr, size_byte, 0, multibyte); | 495 | message_dolog (ptr, size_byte, 0, multibyte); |
| 496 | |||
| 497 | /* Convert message to multibyte if we are now adding multibyte text. */ | ||
| 498 | if (multibyte | ||
| 499 | && ! message_enable_multibyte | ||
| 500 | && printbufidx > 0) | ||
| 501 | { | ||
| 502 | int size = count_size_as_multibyte (FRAME_MESSAGE_BUF (mini_frame), | ||
| 503 | printbufidx); | ||
| 504 | unsigned char *tembuf = (unsigned char *) alloca (size + 1); | ||
| 505 | copy_text (FRAME_MESSAGE_BUF (mini_frame), tembuf, printbufidx, | ||
| 506 | 0, 1); | ||
| 507 | printbufidx = size; | ||
| 508 | if (printbufidx > FRAME_MESSAGE_BUF_SIZE (mini_frame)) | ||
| 509 | { | ||
| 510 | printbufidx = FRAME_MESSAGE_BUF_SIZE (mini_frame); | ||
| 511 | /* Rewind incomplete multi-byte form. */ | ||
| 512 | while (printbufidx > 0 && tembuf[printbufidx] >= 0xA0) | ||
| 513 | printbufidx--; | ||
| 514 | } | ||
| 515 | |||
| 516 | bcopy (tembuf, FRAME_MESSAGE_BUF (mini_frame), printbufidx); | ||
| 517 | message_enable_multibyte = 1; | ||
| 518 | } | ||
| 519 | |||
| 520 | /* Compute how much of the new text will fit there. */ | ||
| 492 | if (size_byte > FRAME_MESSAGE_BUF_SIZE (mini_frame) - printbufidx - 1) | 521 | if (size_byte > FRAME_MESSAGE_BUF_SIZE (mini_frame) - printbufidx - 1) |
| 493 | { | 522 | { |
| 494 | size_byte = FRAME_MESSAGE_BUF_SIZE (mini_frame) - printbufidx - 1; | 523 | size_byte = FRAME_MESSAGE_BUF_SIZE (mini_frame) - printbufidx - 1; |
| 495 | /* Rewind incomplete multi-byte form. */ | 524 | /* Rewind incomplete multi-byte form. */ |
| 496 | while (size_byte && (unsigned char) ptr[size] >= 0xA0) size--; | 525 | while (size_byte && (unsigned char) ptr[size_byte] >= 0xA0) |
| 526 | size_byte--; | ||
| 497 | } | 527 | } |
| 528 | |||
| 529 | /* Put that part of the new text in. */ | ||
| 498 | bcopy (ptr, &FRAME_MESSAGE_BUF (mini_frame) [printbufidx], size_byte); | 530 | bcopy (ptr, &FRAME_MESSAGE_BUF (mini_frame) [printbufidx], size_byte); |
| 499 | printbufidx += size_byte; | 531 | printbufidx += size_byte; |
| 500 | echo_area_glyphs_length = printbufidx; | ||
| 501 | FRAME_MESSAGE_BUF (mini_frame) [printbufidx] = 0; | 532 | FRAME_MESSAGE_BUF (mini_frame) [printbufidx] = 0; |
| 533 | echo_area_glyphs_length = printbufidx; | ||
| 502 | 534 | ||
| 503 | return; | 535 | return; |
| 504 | } | 536 | } |