diff options
| author | Richard M. Stallman | 1998-01-09 23:19:42 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-01-09 23:19:42 +0000 |
| commit | 0a9dc68b4907a2f1c856fd4eac6b797f245101e1 (patch) | |
| tree | c94f7a84dc9863899b05560fe1dc69def885ed5e | |
| parent | 596ae0cfb6802162559fe179d0ae9a25952eb36a (diff) | |
| download | emacs-0a9dc68b4907a2f1c856fd4eac6b797f245101e1.tar.gz emacs-0a9dc68b4907a2f1c856fd4eac6b797f245101e1.zip | |
(message_dolog, message2): New arg MULTIBYTE.
Callers changed.
(message1, message1_nolog): String must be ASCII-only.
(message2, message2_nolog): Now static.
(x_consider_frame_title): Use size_byte.
(display_text_line): Likewise.
And scan Voverlay_arrow_string by bytes and chars.
(display_menu_bar): Call display_string with a byte size.
(display_mode_line): Call display_string with a byte size.
| -rw-r--r-- | src/xdisp.c | 136 |
1 files changed, 103 insertions, 33 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 147268f6427..495e1f425ba 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -271,18 +271,19 @@ void | |||
| 271 | message_log_maybe_newline () | 271 | message_log_maybe_newline () |
| 272 | { | 272 | { |
| 273 | if (message_log_need_newline) | 273 | if (message_log_need_newline) |
| 274 | message_dolog ("", 0, 1); | 274 | message_dolog ("", 0, 1, 0); |
| 275 | } | 275 | } |
| 276 | 276 | ||
| 277 | 277 | ||
| 278 | /* Add a string to the message log, optionally terminated with a newline. | 278 | /* Add a string to the message log, optionally terminated with a newline. |
| 279 | This function calls low-level routines in order to bypass text property | 279 | This function calls low-level routines in order to bypass text property |
| 280 | hooks, etc. which might not be safe to run. */ | 280 | hooks, etc. which might not be safe to run. |
| 281 | MULTIBYTE, if nonzero, means interpret the contents of M as multibyte. */ | ||
| 281 | 282 | ||
| 282 | void | 283 | void |
| 283 | message_dolog (m, len, nlflag) | 284 | message_dolog (m, len, nlflag, multibyte) |
| 284 | char *m; | 285 | char *m; |
| 285 | int len, nlflag; | 286 | int len, nlflag, multibyte; |
| 286 | { | 287 | { |
| 287 | if (!NILP (Vmessage_log_max)) | 288 | if (!NILP (Vmessage_log_max)) |
| 288 | { | 289 | { |
| @@ -313,7 +314,7 @@ message_dolog (m, len, nlflag) | |||
| 313 | 314 | ||
| 314 | /* Insert the string--maybe converting multibyte to single byte | 315 | /* Insert the string--maybe converting multibyte to single byte |
| 315 | or vice versa, so that all the text fits the buffer. */ | 316 | or vice versa, so that all the text fits the buffer. */ |
| 316 | if (! NILP (oldbuf->enable_multibyte_characters) | 317 | if (multibyte |
| 317 | && NILP (current_buffer->enable_multibyte_characters)) | 318 | && NILP (current_buffer->enable_multibyte_characters)) |
| 318 | { | 319 | { |
| 319 | int c, i = 0, nbytes; | 320 | int c, i = 0, nbytes; |
| @@ -330,7 +331,7 @@ message_dolog (m, len, nlflag) | |||
| 330 | insert_char (c); | 331 | insert_char (c); |
| 331 | } | 332 | } |
| 332 | } | 333 | } |
| 333 | else if (NILP (oldbuf->enable_multibyte_characters) | 334 | else if (! multibyte |
| 334 | && ! NILP (current_buffer->enable_multibyte_characters)) | 335 | && ! NILP (current_buffer->enable_multibyte_characters)) |
| 335 | { | 336 | { |
| 336 | int c, i = 0; | 337 | int c, i = 0; |
| @@ -470,16 +471,16 @@ message_log_check_duplicate (prev_bol, prev_bol_byte, this_bol, this_bol_byte) | |||
| 470 | Do not pass text in a buffer that was alloca'd. */ | 471 | Do not pass text in a buffer that was alloca'd. */ |
| 471 | 472 | ||
| 472 | void | 473 | void |
| 473 | message2 (m, len) | 474 | message2 (m, len, multibyte) |
| 474 | char *m; | 475 | char *m; |
| 475 | int len; | 476 | int len; |
| 477 | int multibyte; | ||
| 476 | { | 478 | { |
| 477 | /* First flush out any partial line written with print. */ | 479 | /* First flush out any partial line written with print. */ |
| 478 | message_log_maybe_newline (); | 480 | message_log_maybe_newline (); |
| 479 | if (m) | 481 | if (m) |
| 480 | message_dolog (m, len, 1); | 482 | message_dolog (m, len, 1, multibyte); |
| 481 | message2_nolog (m, len, | 483 | message2_nolog (m, len, multibyte); |
| 482 | ! NILP (current_buffer->enable_multibyte_characters)); | ||
| 483 | } | 484 | } |
| 484 | 485 | ||
| 485 | 486 | ||
| @@ -541,10 +542,11 @@ message2_nolog (m, len, multibyte) | |||
| 541 | } | 542 | } |
| 542 | } | 543 | } |
| 543 | 544 | ||
| 544 | /* Display a null-terminated echo area message M. If M is 0, clear out any | 545 | /* Display in echo area the null-terminated ASCII-only string M. |
| 545 | existing message, and let the minibuffer text show through. | 546 | If M is 0, clear out any existing message, |
| 547 | and let the minibuffer text show through. | ||
| 546 | 548 | ||
| 547 | The buffer M must continue to exist until after the echo area | 549 | The string M must continue to exist until after the echo area |
| 548 | gets cleared or some other message gets displayed there. | 550 | gets cleared or some other message gets displayed there. |
| 549 | 551 | ||
| 550 | Do not pass text that is stored in a Lisp string. | 552 | Do not pass text that is stored in a Lisp string. |
| @@ -554,15 +556,75 @@ void | |||
| 554 | message1 (m) | 556 | message1 (m) |
| 555 | char *m; | 557 | char *m; |
| 556 | { | 558 | { |
| 557 | message2 (m, (m ? strlen (m) : 0)); | 559 | message2 (m, (m ? strlen (m) : 0), 0); |
| 558 | } | 560 | } |
| 559 | 561 | ||
| 560 | void | 562 | void |
| 561 | message1_nolog (m) | 563 | message1_nolog (m) |
| 562 | char *m; | 564 | char *m; |
| 563 | { | 565 | { |
| 564 | message2_nolog (m, (m ? strlen (m) : 0), | 566 | message2_nolog (m, (m ? strlen (m) : 0), 0); |
| 565 | ! NILP (current_buffer->enable_multibyte_characters)); | 567 | } |
| 568 | |||
| 569 | /* Display a message M which contains a single %s | ||
| 570 | which gets replaced with STRING. */ | ||
| 571 | |||
| 572 | void | ||
| 573 | message_with_string (m, string, log) | ||
| 574 | char *m; | ||
| 575 | Lisp_Object string; | ||
| 576 | int log; | ||
| 577 | { | ||
| 578 | if (noninteractive) | ||
| 579 | { | ||
| 580 | if (m) | ||
| 581 | { | ||
| 582 | if (noninteractive_need_newline) | ||
| 583 | putc ('\n', stderr); | ||
| 584 | noninteractive_need_newline = 0; | ||
| 585 | fprintf (stderr, m, XSTRING (string)->data); | ||
| 586 | if (cursor_in_echo_area == 0) | ||
| 587 | fprintf (stderr, "\n"); | ||
| 588 | fflush (stderr); | ||
| 589 | } | ||
| 590 | } | ||
| 591 | else if (INTERACTIVE) | ||
| 592 | { | ||
| 593 | /* The frame whose minibuffer we're going to display the message on. | ||
| 594 | It may be larger than the selected frame, so we need | ||
| 595 | to use its buffer, not the selected frame's buffer. */ | ||
| 596 | Lisp_Object mini_window; | ||
| 597 | FRAME_PTR f; | ||
| 598 | |||
| 599 | /* Get the frame containing the minibuffer | ||
| 600 | that the selected frame is using. */ | ||
| 601 | mini_window = FRAME_MINIBUF_WINDOW (selected_frame); | ||
| 602 | f = XFRAME (WINDOW_FRAME (XWINDOW (mini_window))); | ||
| 603 | |||
| 604 | /* A null message buffer means that the frame hasn't really been | ||
| 605 | initialized yet. Error messages get reported properly by | ||
| 606 | cmd_error, so this must be just an informative message; toss it. */ | ||
| 607 | if (FRAME_MESSAGE_BUF (f)) | ||
| 608 | { | ||
| 609 | int len; | ||
| 610 | char *a[1]; | ||
| 611 | a[0] = (char *) XSTRING (string)->data; | ||
| 612 | |||
| 613 | len = doprnt (FRAME_MESSAGE_BUF (f), | ||
| 614 | FRAME_MESSAGE_BUF_SIZE (f), m, (char *)0, 3, a); | ||
| 615 | |||
| 616 | if (log) | ||
| 617 | message2 (FRAME_MESSAGE_BUF (f), len, | ||
| 618 | STRING_MULTIBYTE (string)); | ||
| 619 | else | ||
| 620 | message2_nolog (FRAME_MESSAGE_BUF (f), len, | ||
| 621 | STRING_MULTIBYTE (string)); | ||
| 622 | |||
| 623 | /* Print should start at the beginning of the message | ||
| 624 | buffer next time. */ | ||
| 625 | message_buf_print = 0; | ||
| 626 | } | ||
| 627 | } | ||
| 566 | } | 628 | } |
| 567 | 629 | ||
| 568 | /* Truncate what will be displayed in the echo area | 630 | /* Truncate what will be displayed in the echo area |
| @@ -640,7 +702,7 @@ message (m, a1, a2, a3) | |||
| 640 | (char **) &a1); | 702 | (char **) &a1); |
| 641 | #endif /* NO_ARG_ARRAY */ | 703 | #endif /* NO_ARG_ARRAY */ |
| 642 | 704 | ||
| 643 | message2 (FRAME_MESSAGE_BUF (f), len); | 705 | message2 (FRAME_MESSAGE_BUF (f), len, 0); |
| 644 | } | 706 | } |
| 645 | else | 707 | else |
| 646 | message1 (0); | 708 | message1 (0); |
| @@ -668,7 +730,8 @@ message_nolog (m, a1, a2, a3) | |||
| 668 | void | 730 | void |
| 669 | update_echo_area () | 731 | update_echo_area () |
| 670 | { | 732 | { |
| 671 | message2 (echo_area_glyphs, echo_area_glyphs_length); | 733 | message2 (echo_area_glyphs, echo_area_glyphs_length, |
| 734 | ! NILP (current_buffer->enable_multibyte_characters)); | ||
| 672 | } | 735 | } |
| 673 | 736 | ||
| 674 | static void | 737 | static void |
| @@ -815,7 +878,7 @@ x_consider_frame_title (frame) | |||
| 815 | already wasted too much time by walking through the list with | 878 | already wasted too much time by walking through the list with |
| 816 | display_mode_element, then we might need to optimize at a higher | 879 | display_mode_element, then we might need to optimize at a higher |
| 817 | level than this.) */ | 880 | level than this.) */ |
| 818 | if (! STRINGP (f->name) || XSTRING (f->name)->size != len | 881 | if (! STRINGP (f->name) || XSTRING (f->name)->size_byte != len |
| 819 | || bcmp (frame_title_buf, XSTRING (f->name)->data, len) != 0) | 882 | || bcmp (frame_title_buf, XSTRING (f->name)->data, len) != 0) |
| 820 | x_implicitly_set_name (f, make_string (frame_title_buf, len), Qnil); | 883 | x_implicitly_set_name (f, make_string (frame_title_buf, len), Qnil); |
| 821 | } | 884 | } |
| @@ -3171,7 +3234,7 @@ display_text_line (w, start, start_byte, vpos, hpos, taboffset, ovstr_done) | |||
| 3171 | 3234 | ||
| 3172 | minibuf_prompt_width | 3235 | minibuf_prompt_width |
| 3173 | = (display_string (w, vpos, XSTRING (minibuf_prompt)->data, | 3236 | = (display_string (w, vpos, XSTRING (minibuf_prompt)->data, |
| 3174 | XSTRING (minibuf_prompt)->size, | 3237 | XSTRING (minibuf_prompt)->size_byte, |
| 3175 | hpos + WINDOW_LEFT_MARGIN (w), | 3238 | hpos + WINDOW_LEFT_MARGIN (w), |
| 3176 | /* Display a space if we truncate. */ | 3239 | /* Display a space if we truncate. */ |
| 3177 | ' ', | 3240 | ' ', |
| @@ -3181,7 +3244,7 @@ display_text_line (w, start, start_byte, vpos, hpos, taboffset, ovstr_done) | |||
| 3181 | on the first line. */ | 3244 | on the first line. */ |
| 3182 | (XFASTINT (w->width) > 10 | 3245 | (XFASTINT (w->width) > 10 |
| 3183 | ? XFASTINT (w->width) - 4 : -1), | 3246 | ? XFASTINT (w->width) - 4 : -1), |
| 3184 | -1) | 3247 | STRING_MULTIBYTE (minibuf_prompt)) |
| 3185 | - hpos - WINDOW_LEFT_MARGIN (w)); | 3248 | - hpos - WINDOW_LEFT_MARGIN (w)); |
| 3186 | hpos += minibuf_prompt_width; | 3249 | hpos += minibuf_prompt_width; |
| 3187 | taboffset -= minibuf_prompt_width - old_width; | 3250 | taboffset -= minibuf_prompt_width - old_width; |
| @@ -3940,8 +4003,7 @@ display_text_line (w, start, start_byte, vpos, hpos, taboffset, ovstr_done) | |||
| 3940 | && STRINGP (Voverlay_arrow_string) | 4003 | && STRINGP (Voverlay_arrow_string) |
| 3941 | && ! overlay_arrow_seen) | 4004 | && ! overlay_arrow_seen) |
| 3942 | { | 4005 | { |
| 3943 | unsigned char *p = XSTRING (Voverlay_arrow_string)->data; | 4006 | int i, i_byte; |
| 3944 | int i; | ||
| 3945 | int len = XSTRING (Voverlay_arrow_string)->size; | 4007 | int len = XSTRING (Voverlay_arrow_string)->size; |
| 3946 | int arrow_end; | 4008 | int arrow_end; |
| 3947 | 4009 | ||
| @@ -3951,12 +4013,17 @@ display_text_line (w, start, start_byte, vpos, hpos, taboffset, ovstr_done) | |||
| 3951 | if (!NULL_INTERVAL_P (XSTRING (Voverlay_arrow_string)->intervals)) | 4013 | if (!NULL_INTERVAL_P (XSTRING (Voverlay_arrow_string)->intervals)) |
| 3952 | { | 4014 | { |
| 3953 | /* If the arrow string has text props, obey them when displaying. */ | 4015 | /* If the arrow string has text props, obey them when displaying. */ |
| 3954 | for (i = 0; i < len; i++) | 4016 | for (i = 0, i_byte = 0; i < len; ) |
| 3955 | { | 4017 | { |
| 3956 | int c = p[i]; | 4018 | int c; |
| 3957 | Lisp_Object face, ilisp; | 4019 | Lisp_Object face, ilisp; |
| 3958 | int newface; | 4020 | int newface; |
| 3959 | 4021 | ||
| 4022 | if (STRING_MULTIBYTE (Voverlay_arrow_string)) | ||
| 4023 | FETCH_STRING_CHAR_ADVANCE (c, Voverlay_arrow_string, i, i_byte); | ||
| 4024 | else | ||
| 4025 | c = XSTRING (Voverlay_arrow_string)->data[i++]; | ||
| 4026 | |||
| 3960 | XSETFASTINT (ilisp, i); | 4027 | XSETFASTINT (ilisp, i); |
| 3961 | face = Fget_text_property (ilisp, Qface, Voverlay_arrow_string); | 4028 | face = Fget_text_property (ilisp, Qface, Voverlay_arrow_string); |
| 3962 | newface = compute_glyph_face_1 (f, face, 0); | 4029 | newface = compute_glyph_face_1 (f, face, 0); |
| @@ -4023,8 +4090,9 @@ display_menu_bar (w) | |||
| 4023 | if (hpos < maxendcol) | 4090 | if (hpos < maxendcol) |
| 4024 | hpos = display_string (w, vpos, | 4091 | hpos = display_string (w, vpos, |
| 4025 | XSTRING (string)->data, | 4092 | XSTRING (string)->data, |
| 4026 | XSTRING (string)->size, | 4093 | XSTRING (string)->size_byte, |
| 4027 | hpos, 0, 0, hpos, maxendcol, -1); | 4094 | hpos, 0, 0, hpos, maxendcol, |
| 4095 | STRING_MULTIBYTE (string)); | ||
| 4028 | /* Put a space between items. */ | 4096 | /* Put a space between items. */ |
| 4029 | if (hpos < maxendcol) | 4097 | if (hpos < maxendcol) |
| 4030 | { | 4098 | { |
| @@ -4164,7 +4232,8 @@ display_mode_element (w, vpos, hpos, depth, minendcol, maxendcol, elt) | |||
| 4164 | hpos = store_frame_title (last, hpos, min (lim, maxendcol)); | 4232 | hpos = store_frame_title (last, hpos, min (lim, maxendcol)); |
| 4165 | else | 4233 | else |
| 4166 | hpos = display_string (w, vpos, last, -1, hpos, 0, 1, | 4234 | hpos = display_string (w, vpos, last, -1, hpos, 0, 1, |
| 4167 | hpos, min (lim, maxendcol), -1); | 4235 | hpos, min (lim, maxendcol), |
| 4236 | STRING_MULTIBYTE (elt)); | ||
| 4168 | } | 4237 | } |
| 4169 | else /* c == '%' */ | 4238 | else /* c == '%' */ |
| 4170 | { | 4239 | { |
| @@ -4228,8 +4297,9 @@ display_mode_element (w, vpos, hpos, depth, minendcol, maxendcol, elt) | |||
| 4228 | minendcol, maxendcol); | 4297 | minendcol, maxendcol); |
| 4229 | else | 4298 | else |
| 4230 | hpos = display_string (w, vpos, XSTRING (tem)->data, | 4299 | hpos = display_string (w, vpos, XSTRING (tem)->data, |
| 4231 | XSTRING (tem)->size, | 4300 | XSTRING (tem)->size_byte, |
| 4232 | hpos, 0, 1, minendcol, maxendcol, -1); | 4301 | hpos, 0, 1, minendcol, maxendcol, |
| 4302 | STRING_MULTIBYTE (tem)); | ||
| 4233 | } | 4303 | } |
| 4234 | /* Give up right away for nil or t. */ | 4304 | /* Give up right away for nil or t. */ |
| 4235 | else if (!EQ (tem, elt)) | 4305 | else if (!EQ (tem, elt)) |
| @@ -4523,7 +4593,7 @@ decode_mode_spec (w, c, spec_width, maxwidth) | |||
| 4523 | case 'b': | 4593 | case 'b': |
| 4524 | obj = b->name; | 4594 | obj = b->name; |
| 4525 | #if 0 | 4595 | #if 0 |
| 4526 | if (maxwidth >= 3 && XSTRING (obj)->size > maxwidth) | 4596 | if (maxwidth >= 3 && XSTRING (obj)->size_byte > maxwidth) |
| 4527 | { | 4597 | { |
| 4528 | bcopy (XSTRING (obj)->data, decode_mode_spec_buf, maxwidth - 1); | 4598 | bcopy (XSTRING (obj)->data, decode_mode_spec_buf, maxwidth - 1); |
| 4529 | decode_mode_spec_buf[maxwidth - 1] = '\\'; | 4599 | decode_mode_spec_buf[maxwidth - 1] = '\\'; |
| @@ -4557,10 +4627,10 @@ decode_mode_spec (w, c, spec_width, maxwidth) | |||
| 4557 | #if 0 | 4627 | #if 0 |
| 4558 | if (NILP (obj)) | 4628 | if (NILP (obj)) |
| 4559 | return "[none]"; | 4629 | return "[none]"; |
| 4560 | else if (STRINGP (obj) && XSTRING (obj)->size > maxwidth) | 4630 | else if (STRINGP (obj) && XSTRING (obj)->size_byte > maxwidth) |
| 4561 | { | 4631 | { |
| 4562 | bcopy ("...", decode_mode_spec_buf, 3); | 4632 | bcopy ("...", decode_mode_spec_buf, 3); |
| 4563 | bcopy (XSTRING (obj)->data + XSTRING (obj)->size - maxwidth + 3, | 4633 | bcopy (XSTRING (obj)->data + XSTRING (obj)->size_byte - maxwidth + 3, |
| 4564 | decode_mode_spec_buf + 3, maxwidth - 3); | 4634 | decode_mode_spec_buf + 3, maxwidth - 3); |
| 4565 | return decode_mode_spec_buf; | 4635 | return decode_mode_spec_buf; |
| 4566 | } | 4636 | } |