Mercurial > vim
comparison src/popupwin.c @ 24709:9d304d363ab6 v8.2.2893
patch 8.2.2893: multi-byte text in popup title shows up wrong
Commit: https://github.com/vim/vim/commit/bc869874fedf094129831836f131c64f10d98854
Author: Ralf Schandl <rakus@users.noreply.github.com>
Date: Fri May 28 14:12:14 2021 +0200
patch 8.2.2893: multi-byte text in popup title shows up wrong
Problem: Multi-byte text in popup title shows up wrong.
Solution: Use the character width instead of the byte length. (Ralf Schandl,
closes #8267, closes #8264)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 28 May 2021 14:15:03 +0200 |
parents | 0967c54ff3b2 |
children | 7334bf933510 |
comparison
equal
deleted
inserted
replaced
24708:46c0305949ee | 24709:9d304d363ab6 |
---|---|
3820 | 3820 |
3821 // Title goes on top of border or padding. | 3821 // Title goes on top of border or padding. |
3822 title_wincol = wp->w_wincol + 1; | 3822 title_wincol = wp->w_wincol + 1; |
3823 if (wp->w_popup_title != NULL) | 3823 if (wp->w_popup_title != NULL) |
3824 { | 3824 { |
3825 char_u *title_text; | 3825 title_len = (int)MB_CHARLEN(wp->w_popup_title); |
3826 | 3826 |
3827 title_len = (int)STRLEN(wp->w_popup_title); | 3827 // truncate the title if too long |
3828 title_text = alloc(title_len + 1); | 3828 if (title_len > total_width - 2) |
3829 trunc_string(wp->w_popup_title, title_text, | 3829 { |
3830 total_width - 2, title_len + 1); | 3830 int title_byte_len = (int)STRLEN(wp->w_popup_title); |
3831 screen_puts(title_text, wp->w_winrow, title_wincol, | 3831 char_u *title_text = alloc(title_byte_len + 1); |
3832 | |
3833 if (title_text != NULL) | |
3834 { | |
3835 trunc_string(wp->w_popup_title, title_text, | |
3836 total_width - 2, title_byte_len + 1); | |
3837 screen_puts(title_text, wp->w_winrow, title_wincol, | |
3838 wp->w_popup_border[0] > 0 | |
3839 ? border_attr[0] : popup_attr); | |
3840 vim_free(title_text); | |
3841 } | |
3842 | |
3843 title_len = total_width - 2; | |
3844 } | |
3845 else | |
3846 screen_puts(wp->w_popup_title, wp->w_winrow, title_wincol, | |
3832 wp->w_popup_border[0] > 0 ? border_attr[0] : popup_attr); | 3847 wp->w_popup_border[0] > 0 ? border_attr[0] : popup_attr); |
3833 vim_free(title_text); | |
3834 if (title_len > total_width - 2) | |
3835 title_len = total_width - 2; | |
3836 } | 3848 } |
3837 | 3849 |
3838 wincol = wp->w_wincol - wp->w_popup_leftoff; | 3850 wincol = wp->w_wincol - wp->w_popup_leftoff; |
3839 top_padding = wp->w_popup_padding[0]; | 3851 top_padding = wp->w_popup_padding[0]; |
3840 if (wp->w_popup_border[0] > 0) | 3852 if (wp->w_popup_border[0] > 0) |