Normalize newline and backspace characters in key event strings

The system’s key binding dictionaries use both CR and LF for newline and \x08 and \x7F for backspace.
This commit is contained in:
Allan Odgaard
2014-11-10 13:38:59 +01:00
parent a778f0b3da
commit ae02add21c

View File

@@ -167,6 +167,11 @@ namespace ns
std::string key; NSUInteger flags;
parse_event_string(eventString, key, flags, true);
if(utf8::to_ch(key) == NSBackspaceCharacter)
key = NSDeleteCharacter;
else if(utf8::to_ch(key) == NSNewlineCharacter)
key = NSCarriageReturnCharacter;
std::string modifierString = key.empty() ? "" : string_for(flags);
if(startOfKey)
*startOfKey = modifierString.size();