diff options
Diffstat (limited to 'source/blender/editors/interface/interface_widgets.c')
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 48f638dac33..a2b86ccd947 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1498,15 +1498,15 @@ static void widget_draw_submenu_tria(const uiBut *but, static void ui_text_clip_give_prev_off(uiBut *but, const char *str) { - const char *prev_utf8 = BLI_str_find_prev_char_utf8(str, str + but->ofs); + const char *prev_utf8 = BLI_str_find_prev_char_utf8(str + but->ofs, str); const int bytes = str + but->ofs - prev_utf8; but->ofs -= bytes; } -static void ui_text_clip_give_next_off(uiBut *but, const char *str) +static void ui_text_clip_give_next_off(uiBut *but, const char *str, const char *str_end) { - const char *next_utf8 = BLI_str_find_next_char_utf8(str + but->ofs, NULL); + const char *next_utf8 = BLI_str_find_next_char_utf8(str + but->ofs, str_end); const int bytes = next_utf8 - (str + but->ofs); but->ofs += bytes; @@ -1739,7 +1739,8 @@ static void ui_text_clip_cursor(const uiFontStyle *fstyle, uiBut *but, const rct but->strwidth = BLF_width(fstyle->uifont_id, but->editstr + but->ofs, INT_MAX); if (but->strwidth > okwidth) { - int len = strlen(but->editstr); + const int editstr_len = strlen(but->editstr); + int len = editstr_len; while (but->strwidth > okwidth) { float width; @@ -1749,7 +1750,7 @@ static void ui_text_clip_cursor(const uiFontStyle *fstyle, uiBut *but, const rct /* if cursor is at 20 pixels of right side button we clip left */ if (width > okwidth - 20) { - ui_text_clip_give_next_off(but, but->editstr); + ui_text_clip_give_next_off(but, but->editstr, but->editstr + editstr_len); } else { int bytes; @@ -1757,7 +1758,7 @@ static void ui_text_clip_cursor(const uiFontStyle *fstyle, uiBut *but, const rct if (width < 20 && but->ofs > 0) { ui_text_clip_give_prev_off(but, but->editstr); } - bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->editstr, but->editstr + len)); + bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->editstr + len, but->editstr)); if (bytes == -1) { bytes = 1; } @@ -1805,7 +1806,7 @@ static void ui_text_clip_right_label(const uiFontStyle *fstyle, uiBut *but, cons /* chop off the leading text, starting from the right */ while (but->strwidth > okwidth && cp2 > but->drawstr) { - const char *prev_utf8 = BLI_str_find_prev_char_utf8(but->drawstr, cp2); + const char *prev_utf8 = BLI_str_find_prev_char_utf8(cp2, but->drawstr); const int bytes = cp2 - prev_utf8; /* shift the text after and including cp2 back by 1 char, @@ -1825,7 +1826,7 @@ static void ui_text_clip_right_label(const uiFontStyle *fstyle, uiBut *but, cons /* after the leading text is gone, chop off the : and following space, with ofs */ while ((but->strwidth > okwidth) && (but->ofs < 2)) { - ui_text_clip_give_next_off(but, but->drawstr); + ui_text_clip_give_next_off(but, but->drawstr, but->drawstr + drawstr_len); but->strwidth = BLF_width( fstyle->uifont_id, but->drawstr + but->ofs, sizeof(but->drawstr) - but->ofs); if (but->strwidth < 10) { |