Cleanup: correct private function naming
Use term 'glyph' instead of 'icon' since we already have event icons.
This commit is contained in:
parent
501dd9e231
commit
eaa730ce8c
|
@ -1091,17 +1091,21 @@ static void wm_user_modal_keymap_set_items(wmWindowManager *wm, wmKeyMap *km)
|
|||
/** \name Text from Key Events
|
||||
* \{ */
|
||||
|
||||
static const char *key_event_icon_or_text(const int font_id, const char *text, const char *icon)
|
||||
static const char *key_event_glyph_or_text(const int font_id,
|
||||
const char *text,
|
||||
const char *single_glyph)
|
||||
{
|
||||
BLI_assert(icon == NULL || (BLI_strlen_utf8(icon) == 1));
|
||||
return (icon && BLF_has_glyph(font_id, BLI_str_utf8_as_unicode(icon))) ? icon : text;
|
||||
BLI_assert(single_glyph == NULL || (BLI_strlen_utf8(single_glyph) == 1));
|
||||
return (single_glyph && BLF_has_glyph(font_id, BLI_str_utf8_as_unicode(single_glyph))) ?
|
||||
single_glyph :
|
||||
text;
|
||||
}
|
||||
|
||||
const char *WM_key_event_string(const short type, const bool compact)
|
||||
{
|
||||
if (compact) {
|
||||
/* String storing a single unicode character or NULL. */
|
||||
const char *icon_glyph = NULL;
|
||||
const char *single_glyph = NULL;
|
||||
int font_id = BLF_default();
|
||||
const enum {
|
||||
UNIX,
|
||||
|
@ -1122,10 +1126,10 @@ const char *WM_key_event_string(const short type, const bool compact)
|
|||
case LEFTSHIFTKEY:
|
||||
case RIGHTSHIFTKEY: {
|
||||
if (platform == MACOS) {
|
||||
icon_glyph = "\xe2\x87\xa7";
|
||||
single_glyph = "\xe2\x87\xa7";
|
||||
}
|
||||
return key_event_icon_or_text(
|
||||
font_id, CTX_IFACE_(BLT_I18NCONTEXT_ID_WINDOWMANAGER, "Shift"), icon_glyph);
|
||||
return key_event_glyph_or_text(
|
||||
font_id, CTX_IFACE_(BLT_I18NCONTEXT_ID_WINDOWMANAGER, "Shift"), single_glyph);
|
||||
}
|
||||
case LEFTCTRLKEY:
|
||||
case RIGHTCTRLKEY:
|
||||
|
@ -1136,45 +1140,45 @@ const char *WM_key_event_string(const short type, const bool compact)
|
|||
case LEFTALTKEY:
|
||||
case RIGHTALTKEY: {
|
||||
if (platform == MACOS) {
|
||||
icon_glyph = "\xe2\x8c\xa5";
|
||||
single_glyph = "\xe2\x8c\xa5";
|
||||
}
|
||||
return key_event_icon_or_text(font_id, IFACE_("Alt"), icon_glyph);
|
||||
return key_event_glyph_or_text(font_id, IFACE_("Alt"), single_glyph);
|
||||
}
|
||||
case OSKEY: {
|
||||
if (platform == MACOS) {
|
||||
return key_event_icon_or_text(font_id, IFACE_("Cmd"), "\xe2\x8c\x98");
|
||||
return key_event_glyph_or_text(font_id, IFACE_("Cmd"), "\xe2\x8c\x98");
|
||||
}
|
||||
else if (platform == MSWIN) {
|
||||
return key_event_icon_or_text(font_id, IFACE_("Win"), "\xe2\x8a\x9e");
|
||||
return key_event_glyph_or_text(font_id, IFACE_("Win"), "\xe2\x8a\x9e");
|
||||
}
|
||||
return IFACE_("OSkey");
|
||||
} break;
|
||||
case TABKEY: {
|
||||
if (platform == MACOS) {
|
||||
icon_glyph = "\xe2\x86\xb9";
|
||||
single_glyph = "\xe2\x86\xb9";
|
||||
}
|
||||
return key_event_icon_or_text(font_id, IFACE_("Tab"), icon_glyph);
|
||||
return key_event_glyph_or_text(font_id, IFACE_("Tab"), single_glyph);
|
||||
}
|
||||
case BACKSPACEKEY:
|
||||
return key_event_icon_or_text(font_id, IFACE_("Bksp"), "\xe2\x8c\xab");
|
||||
return key_event_glyph_or_text(font_id, IFACE_("Bksp"), "\xe2\x8c\xab");
|
||||
case ESCKEY:
|
||||
return key_event_icon_or_text(font_id, IFACE_("Esc"), NULL /* "\xe2\x8e\x8b" */);
|
||||
return key_event_glyph_or_text(font_id, IFACE_("Esc"), NULL /* "\xe2\x8e\x8b" */);
|
||||
case RETKEY: {
|
||||
if (platform == MACOS) {
|
||||
icon_glyph = "\xe2\x8f\x8e";
|
||||
single_glyph = "\xe2\x8f\x8e";
|
||||
}
|
||||
return key_event_icon_or_text(font_id, IFACE_("Enter"), icon_glyph);
|
||||
return key_event_glyph_or_text(font_id, IFACE_("Enter"), single_glyph);
|
||||
}
|
||||
case SPACEKEY:
|
||||
return key_event_icon_or_text(font_id, IFACE_("Space"), NULL /* "\xe2\x90\xa3" */);
|
||||
return key_event_glyph_or_text(font_id, IFACE_("Space"), NULL /* "\xe2\x90\xa3" */);
|
||||
case LEFTARROWKEY:
|
||||
return key_event_icon_or_text(font_id, IFACE_("Left"), "\xe2\x86\x90");
|
||||
return key_event_glyph_or_text(font_id, IFACE_("Left"), "\xe2\x86\x90");
|
||||
case UPARROWKEY:
|
||||
return key_event_icon_or_text(font_id, IFACE_("Up"), "\xe2\x86\x91");
|
||||
return key_event_glyph_or_text(font_id, IFACE_("Up"), "\xe2\x86\x91");
|
||||
case RIGHTARROWKEY:
|
||||
return key_event_icon_or_text(font_id, IFACE_("Right"), "\xe2\x86\x92");
|
||||
return key_event_glyph_or_text(font_id, IFACE_("Right"), "\xe2\x86\x92");
|
||||
case DOWNARROWKEY:
|
||||
return key_event_icon_or_text(font_id, IFACE_("Down"), "\xe2\x86\x93");
|
||||
return key_event_glyph_or_text(font_id, IFACE_("Down"), "\xe2\x86\x93");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue