Mercurial > emacs
comparison src/xdisp.c @ 39351:17ddc09facff
(decode_mode_spec): Add parameter MULTIBYTE.
(display_mode_element): Display the string from decode_mode_spec
depending on its multibyteness.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Wed, 19 Sep 2001 14:48:30 +0000 |
parents | 52983980d01d |
children | 04336fed250c |
comparison
equal
deleted
inserted
replaced
39350:0be887929f9f | 39351:17ddc09facff |
---|---|
730 static int try_window_id P_ ((struct window *)); | 730 static int try_window_id P_ ((struct window *)); |
731 static int display_line P_ ((struct it *)); | 731 static int display_line P_ ((struct it *)); |
732 static int display_mode_lines P_ ((struct window *)); | 732 static int display_mode_lines P_ ((struct window *)); |
733 static int display_mode_line P_ ((struct window *, enum face_id, Lisp_Object)); | 733 static int display_mode_line P_ ((struct window *, enum face_id, Lisp_Object)); |
734 static int display_mode_element P_ ((struct it *, int, int, int, Lisp_Object)); | 734 static int display_mode_element P_ ((struct it *, int, int, int, Lisp_Object)); |
735 static char *decode_mode_spec P_ ((struct window *, int, int, int)); | 735 static char *decode_mode_spec P_ ((struct window *, int, int, int, int *)); |
736 static void display_menu_bar P_ ((struct window *)); | 736 static void display_menu_bar P_ ((struct window *)); |
737 static int display_count_lines P_ ((int, int, int, int, int *)); | 737 static int display_count_lines P_ ((int, int, int, int, int *)); |
738 static int display_string P_ ((unsigned char *, Lisp_Object, Lisp_Object, | 738 static int display_string P_ ((unsigned char *, Lisp_Object, Lisp_Object, |
739 int, int, struct it *, int, int, int, int)); | 739 int, int, struct it *, int, int, int, int)); |
740 static void compute_line_metrics P_ ((struct it *)); | 740 static void compute_line_metrics P_ ((struct it *)); |
13447 if (c == 'M') | 13447 if (c == 'M') |
13448 n += display_mode_element (it, depth, field, prec, | 13448 n += display_mode_element (it, depth, field, prec, |
13449 Vglobal_mode_string); | 13449 Vglobal_mode_string); |
13450 else if (c != 0) | 13450 else if (c != 0) |
13451 { | 13451 { |
13452 int multibyte; | |
13452 unsigned char *spec | 13453 unsigned char *spec |
13453 = decode_mode_spec (it->w, c, field, prec); | 13454 = decode_mode_spec (it->w, c, field, prec, &multibyte); |
13454 | 13455 |
13455 if (frame_title_ptr) | 13456 if (frame_title_ptr) |
13456 n += store_frame_title (spec, field, prec); | 13457 n += store_frame_title (spec, field, prec); |
13457 else | 13458 else |
13458 { | 13459 { |
13459 int nglyphs_before | 13460 int nglyphs_before, bytepos, charpos, nwritten; |
13460 = it->glyph_row->used[TEXT_AREA]; | 13461 |
13461 int bytepos | 13462 nglyphs_before = it->glyph_row->used[TEXT_AREA]; |
13462 = percent_position - XSTRING (elt)->data; | 13463 bytepos = percent_position - XSTRING (elt)->data; |
13463 int charpos | 13464 charpos = (multibyte |
13464 = string_byte_to_char (elt, bytepos); | 13465 ? string_byte_to_char (elt, bytepos) |
13465 int nwritten | 13466 : bytepos); |
13466 = display_string (spec, Qnil, elt, charpos, 0, it, | 13467 nwritten = display_string (spec, Qnil, elt, |
13467 field, prec, 0, -1); | 13468 charpos, 0, it, |
13469 field, prec, 0, | |
13470 multibyte); | |
13468 | 13471 |
13469 /* Assign to the glyphs written above the | 13472 /* Assign to the glyphs written above the |
13470 string where the `%x' came from, position | 13473 string where the `%x' came from, position |
13471 of the `%'. */ | 13474 of the `%'. */ |
13472 if (nwritten > 0) | 13475 if (nwritten > 0) |
13758 } | 13761 } |
13759 | 13762 |
13760 /* Return a string for the output of a mode line %-spec for window W, | 13763 /* Return a string for the output of a mode line %-spec for window W, |
13761 generated by character C. PRECISION >= 0 means don't return a | 13764 generated by character C. PRECISION >= 0 means don't return a |
13762 string longer than that value. FIELD_WIDTH > 0 means pad the | 13765 string longer than that value. FIELD_WIDTH > 0 means pad the |
13763 string returned with spaces to that value. */ | 13766 string returned with spaces to that value. Return 1 in *MULTIBYTE |
13767 if the result is multibyte text. */ | |
13764 | 13768 |
13765 static char lots_of_dashes[] = "--------------------------------------------------------------------------------------------------------------------------------------------"; | 13769 static char lots_of_dashes[] = "--------------------------------------------------------------------------------------------------------------------------------------------"; |
13766 | 13770 |
13767 static char * | 13771 static char * |
13768 decode_mode_spec (w, c, field_width, precision) | 13772 decode_mode_spec (w, c, field_width, precision, multibyte) |
13769 struct window *w; | 13773 struct window *w; |
13770 register int c; | 13774 register int c; |
13771 int field_width, precision; | 13775 int field_width, precision; |
13776 int *multibyte; | |
13772 { | 13777 { |
13773 Lisp_Object obj; | 13778 Lisp_Object obj; |
13774 struct frame *f = XFRAME (WINDOW_FRAME (w)); | 13779 struct frame *f = XFRAME (WINDOW_FRAME (w)); |
13775 char *decode_mode_spec_buf = f->decode_mode_spec_buffer; | 13780 char *decode_mode_spec_buf = f->decode_mode_spec_buffer; |
13776 struct buffer *b = XBUFFER (w->buffer); | 13781 struct buffer *b = XBUFFER (w->buffer); |
13777 | 13782 |
13778 obj = Qnil; | 13783 obj = Qnil; |
13784 *multibyte = 0; | |
13779 | 13785 |
13780 switch (c) | 13786 switch (c) |
13781 { | 13787 { |
13782 case '*': | 13788 case '*': |
13783 if (!NILP (b->read_only)) | 13789 if (!NILP (b->read_only)) |
14107 return decode_mode_spec_buf; | 14113 return decode_mode_spec_buf; |
14108 } | 14114 } |
14109 } | 14115 } |
14110 | 14116 |
14111 if (STRINGP (obj)) | 14117 if (STRINGP (obj)) |
14112 return (char *) XSTRING (obj)->data; | 14118 { |
14119 *multibyte = STRING_MULTIBYTE (obj); | |
14120 return (char *) XSTRING (obj)->data; | |
14121 } | |
14113 else | 14122 else |
14114 return ""; | 14123 return ""; |
14115 } | 14124 } |
14116 | 14125 |
14117 | 14126 |