ui: internal change. replace strcat with BLI string functions for key-event drawing.

This commit is contained in:
Campbell Barton 2013-07-25 13:18:11 +00:00
parent 40d9ab1139
commit 55640288d2

@ -2477,29 +2477,30 @@ void ui_check_but(uiBut *but)
if (!but->editstr) { if (!but->editstr) {
char str[UI_MAX_DRAW_STR]; char str[UI_MAX_DRAW_STR];
ui_get_but_string(but, str, UI_MAX_DRAW_STR - strlen(but->str)); ui_get_but_string(but, str, UI_MAX_DRAW_STR);
BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, str); BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, str);
} }
break; break;
case KEYEVT: case KEYEVT:
BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR); {
const char *str;
if (but->flag & UI_SELECT) { if (but->flag & UI_SELECT) {
strcat(but->drawstr, "Press a key"); str = "Press a key";
} }
else { else {
UI_GET_BUT_VALUE_INIT(but, value); UI_GET_BUT_VALUE_INIT(but, value);
strcat(but->drawstr, WM_key_event_string((short)value)); str = WM_key_event_string((short)value);
} }
BLI_snprintf(but->drawstr, UI_MAX_DRAW_STR, "%s%s", but->str, str);
break; break;
}
case HOTKEYEVT: case HOTKEYEVT:
if (but->flag & UI_SELECT) { if (but->flag & UI_SELECT) {
but->drawstr[0] = '\0';
if (but->modifier_key) { if (but->modifier_key) {
char *str = but->drawstr; char *str = but->drawstr;
but->drawstr[0] = '\0';
if (but->modifier_key & KM_SHIFT) if (but->modifier_key & KM_SHIFT)
str += BLI_strcpy_rlen(str, "Shift "); str += BLI_strcpy_rlen(str, "Shift ");
@ -2512,8 +2513,9 @@ void ui_check_but(uiBut *but)
(void)str; /* UNUSED */ (void)str; /* UNUSED */
} }
else else {
strcat(but->drawstr, "Press a key "); BLI_strncpy(but->drawstr, "Press a key", UI_MAX_DRAW_STR);
}
} }
else else
BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR); BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);