[TextEdit] KEY_UP for toggle case

This commit is contained in:
Bertrand Songis
2021-01-06 08:54:45 +01:00
parent e00a9773aa
commit 5742a67cb9
2 changed files with 15 additions and 6 deletions
+5 -6
View File
@@ -189,14 +189,13 @@ void TextEdit::onEvent(event_t event)
break;
}
case EVT_KEY_BREAK(KEY_UP):
v = toggleCase(v);
break;
case EVT_KEY_LONG(KEY_LEFT):
case EVT_KEY_LONG(KEY_RIGHT):
if (v >= 'A' && v <= 'Z') {
v += 32; // tolower
}
else if (v >= 'a' && v <= 'z') {
v -= 32; // toupper
}
v = toggleCase(v);
if (event == EVT_KEY_LONG(KEY_LEFT)) {
killEvents(KEY_LEFT);
}
+10
View File
@@ -112,5 +112,15 @@ class TextEdit : public FormField {
else
return c - 1;
}
static uint8_t toggleCase(uint8_t c)
{
if (c >= 'A' && c <= 'Z')
return c + 32; // tolower
else if (c >= 'a' && c <= 'z')
return c - 32; // toupper
else
return c;
}
};