(button_set_text): do nothing if new and current texts are equal.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2019-12-14 17:10:10 +03:00
parent b031b44823
commit d034500fd6
1 changed files with 9 additions and 1 deletions

View File

@ -237,9 +237,17 @@ void
button_set_text (WButton * b, const char *text)
{
Widget *w = WIDGET (b);
hotkey_t hk;
hk = hotkey_new (text);
if (hotkey_equal (b->text, hk))
{
hotkey_free (hk);
return;
}
hotkey_free (b->text);
b->text = hotkey_new (text);
b->text = hk;
b->hotpos = (b->text.hotkey != NULL) ? str_term_width1 (b->text.start) : -1;
w->cols = button_get_len (b);
widget_draw (w);