diff options
| author | Eli Zaretskii | 2023-07-02 11:10:59 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2023-07-02 11:10:59 +0300 |
| commit | f893ace8352d39c95048b143bf01d35973343ea0 (patch) | |
| tree | a61f23e7a62c5933c36c9e6a59f0a76faabaed97 /src | |
| parent | 9b9dcc146ba8132ef02afd12f20b302a78c7bbe2 (diff) | |
| download | emacs-f893ace8352d39c95048b143bf01d35973343ea0.tar.gz emacs-f893ace8352d39c95048b143bf01d35973343ea0.zip | |
Fix display of wide characters on TTY frame's mode line
* src/xdisp.c (pad_mode_line): New function.
(display_string): Use it instead of 'produce_special_glyphs' to
replace a character that's too wide to fit on the mode/header/tab
line, but which occupies some columns that do fit. (Bug#64395)
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 85ece901111..a3464c2c375 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -1194,6 +1194,7 @@ static void get_cursor_offset_for_mouse_face (struct window *w, | |||
| 1194 | #endif /* HAVE_WINDOW_SYSTEM */ | 1194 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 1195 | 1195 | ||
| 1196 | static void produce_special_glyphs (struct it *, enum display_element_type); | 1196 | static void produce_special_glyphs (struct it *, enum display_element_type); |
| 1197 | static void pad_mode_line (struct it *, bool); | ||
| 1197 | static void show_mouse_face (Mouse_HLInfo *, enum draw_glyphs_face); | 1198 | static void show_mouse_face (Mouse_HLInfo *, enum draw_glyphs_face); |
| 1198 | static bool coords_in_mouse_face_p (struct window *, int, int); | 1199 | static bool coords_in_mouse_face_p (struct window *, int, int); |
| 1199 | static void reset_box_start_end_flags (struct it *); | 1200 | static void reset_box_start_end_flags (struct it *); |
| @@ -28770,7 +28771,11 @@ display_string (const char *string, Lisp_Object lisp_string, Lisp_Object face_st | |||
| 28770 | { | 28771 | { |
| 28771 | /* Add truncation mark, but don't do it if the line is | 28772 | /* Add truncation mark, but don't do it if the line is |
| 28772 | truncated at a padding space. */ | 28773 | truncated at a padding space. */ |
| 28773 | if (it_charpos < it->string_nchars) | 28774 | /* Need to do the below for the last string character as |
| 28775 | well, since it could be a double-width character, in | ||
| 28776 | which case the previous character ends before | ||
| 28777 | last_visible_x. Thus, comparison with <=, not <. */ | ||
| 28778 | if (it_charpos <= it->string_nchars) | ||
| 28774 | { | 28779 | { |
| 28775 | if (!FRAME_WINDOW_P (it->f)) | 28780 | if (!FRAME_WINDOW_P (it->f)) |
| 28776 | { | 28781 | { |
| @@ -28778,6 +28783,18 @@ display_string (const char *string, Lisp_Object lisp_string, Lisp_Object face_st | |||
| 28778 | 28783 | ||
| 28779 | if (it->current_x > it->last_visible_x) | 28784 | if (it->current_x > it->last_visible_x) |
| 28780 | { | 28785 | { |
| 28786 | /* This flag is true if we are displaying mode | ||
| 28787 | line, false for header-line or tab-line. */ | ||
| 28788 | bool mode_line_p = false; | ||
| 28789 | |||
| 28790 | /* ROW->mode_line_p is true if we display mode | ||
| 28791 | line or header-line or tab-line. */ | ||
| 28792 | if (row->mode_line_p) | ||
| 28793 | { | ||
| 28794 | struct window *w = it->w; | ||
| 28795 | if (row == MATRIX_MODE_LINE_ROW (w->desired_matrix)) | ||
| 28796 | mode_line_p = true; | ||
| 28797 | } | ||
| 28781 | if (!row->reversed_p) | 28798 | if (!row->reversed_p) |
| 28782 | { | 28799 | { |
| 28783 | for (ii = row->used[TEXT_AREA] - 1; ii > 0; --ii) | 28800 | for (ii = row->used[TEXT_AREA] - 1; ii > 0; --ii) |
| @@ -28795,7 +28812,10 @@ display_string (const char *string, Lisp_Object lisp_string, Lisp_Object face_st | |||
| 28795 | for (n = row->used[TEXT_AREA]; ii < n; ++ii) | 28812 | for (n = row->used[TEXT_AREA]; ii < n; ++ii) |
| 28796 | { | 28813 | { |
| 28797 | row->used[TEXT_AREA] = ii; | 28814 | row->used[TEXT_AREA] = ii; |
| 28798 | produce_special_glyphs (it, IT_TRUNCATION); | 28815 | if (row->mode_line_p) |
| 28816 | pad_mode_line (it, mode_line_p); | ||
| 28817 | else | ||
| 28818 | produce_special_glyphs (it, IT_TRUNCATION); | ||
| 28799 | } | 28819 | } |
| 28800 | } | 28820 | } |
| 28801 | produce_special_glyphs (it, IT_TRUNCATION); | 28821 | produce_special_glyphs (it, IT_TRUNCATION); |
| @@ -31621,6 +31641,38 @@ produce_special_glyphs (struct it *it, enum display_element_type what) | |||
| 31621 | it->nglyphs = temp_it.nglyphs; | 31641 | it->nglyphs = temp_it.nglyphs; |
| 31622 | } | 31642 | } |
| 31623 | 31643 | ||
| 31644 | /* Produce padding glyphs for mode/header/tab-line whose text needs to | ||
| 31645 | be truncated. This is used when the last visible character leaves | ||
| 31646 | one or more columns till the window edge, but the next character is | ||
| 31647 | wider than that number of columns, and therefore cannot fit on the | ||
| 31648 | line. We then replace these columns with the appropriate padding | ||
| 31649 | character: '-' for the mode line and SPC for the other two. That's | ||
| 31650 | because these lines should not show the usual truncation glyphs | ||
| 31651 | there. This function is only used on TTY frames. */ | ||
| 31652 | static void | ||
| 31653 | pad_mode_line (struct it *it, bool mode_line_p) | ||
| 31654 | { | ||
| 31655 | struct it temp_it; | ||
| 31656 | GLYPH glyph; | ||
| 31657 | |||
| 31658 | eassert (!FRAME_WINDOW_P (it->f)); | ||
| 31659 | temp_it = *it; | ||
| 31660 | temp_it.object = Qnil; | ||
| 31661 | memset (&temp_it.current, 0, sizeof temp_it.current); | ||
| 31662 | |||
| 31663 | SET_GLYPH (glyph, mode_line_p ? '-' : ' ', it->base_face_id); | ||
| 31664 | |||
| 31665 | temp_it.dp = NULL; | ||
| 31666 | temp_it.what = IT_CHARACTER; | ||
| 31667 | temp_it.c = temp_it.char_to_display = GLYPH_CHAR (glyph); | ||
| 31668 | temp_it.face_id = GLYPH_FACE (glyph); | ||
| 31669 | temp_it.len = CHAR_BYTES (temp_it.c); | ||
| 31670 | |||
| 31671 | PRODUCE_GLYPHS (&temp_it); | ||
| 31672 | it->pixel_width = temp_it.pixel_width; | ||
| 31673 | it->nglyphs = temp_it.nglyphs; | ||
| 31674 | } | ||
| 31675 | |||
| 31624 | #ifdef HAVE_WINDOW_SYSTEM | 31676 | #ifdef HAVE_WINDOW_SYSTEM |
| 31625 | 31677 | ||
| 31626 | /* Calculate line-height and line-spacing properties. | 31678 | /* Calculate line-height and line-spacing properties. |